diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index fa5472b63e..4d6b5bf717 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1877,13 +1877,13 @@ packages: /@types/ws/7.4.7: resolution: {integrity: sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==} dependencies: - '@types/node': 16.11.14 + '@types/node': 17.0.0 dev: false /@types/ws/8.2.2: resolution: {integrity: sha512-NOn5eIcgWLOo6qW8AcuLZ7G8PycXu0xTxxkS6Q18VWFxgPUSOwV0pBj2a/4viNZVu25i7RIB7GttdkAIUUXOOg==} dependencies: - '@types/node': 16.11.14 + '@types/node': 17.0.0 dev: false /@types/yargs-parser/20.2.1: @@ -2771,6 +2771,7 @@ packages: /bindings/1.5.0: resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} + requiresBuild: true dependencies: file-uri-to-path: 1.0.0 dev: false @@ -4737,6 +4738,7 @@ packages: /file-uri-to-path/1.0.0: resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} + requiresBuild: true dev: false optional: true @@ -6987,6 +6989,7 @@ packages: /nan/2.15.0: resolution: {integrity: sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==} + requiresBuild: true dev: false optional: true @@ -10586,7 +10589,7 @@ packages: dev: false file:projects/core.tgz: - resolution: {integrity: sha512-Xjk/aGZgRnNWYrQpTy8f2H8oQVVIvbkX6MdesJnRH7AjJTI2RtloF+8sUQMSjSahPh7thHwaYyDVlJ37vMXXNQ==, tarball: file:projects/core.tgz} + resolution: {integrity: sha512-1RXdycw5v+KGu+kmqXvnrKAZpNYbc0U/rInLVwKYJ17U/hED4ONAIPEaVDxp+fxgyPHpEo7AQjZe2aD87ogwtg==, tarball: file:projects/core.tgz} name: '@rush-temp/core' version: 0.0.0 dependencies: @@ -11265,7 +11268,7 @@ packages: dev: false file:projects/model-setting.tgz_typescript@4.5.4: - resolution: {integrity: sha512-U6P3iLbt33/iJI21fs7trAHtpwWzmI/zJn+3qyxjjnFP88i11vmbd1zfb6+GYu5muRCutqNi1pTX/5cDo+NtrA==, tarball: file:projects/model-setting.tgz} + resolution: {integrity: sha512-zwbVN3PDOfDeqGcL36IHQIufdePTd68yLUm83rfIg4v8+uilseid981y/BrAysmxTXAfhVYWlDmtYXvNPS4DMQ==, tarball: file:projects/model-setting.tgz} id: file:projects/model-setting.tgz name: '@rush-temp/model-setting' version: 0.0.0 @@ -11948,7 +11951,7 @@ packages: dev: false file:projects/task.tgz: - resolution: {integrity: sha512-H61a9iYDCDExaqx08I8pBpSZj2gDyDvF+K+R/QjML1YouYeUa1M1UPpjfz4DHwT7a67TJCasvqJ9nh0/ZNvcDw==, tarball: file:projects/task.tgz} + resolution: {integrity: sha512-hVBsBOFHd4nIZZipEk0yQP/C0/oQLXFcky7Q8cH37+nNFNdq4JN+MGhrfFnwWL7WzjxYEX2MW/UdiRpFszzhjA==, tarball: file:projects/task.tgz} name: '@rush-temp/task' version: 0.0.0 dependencies: @@ -11961,6 +11964,7 @@ packages: eslint-plugin-import: 2.25.3_eslint@7.32.0 eslint-plugin-node: 11.1.0_eslint@7.32.0 eslint-plugin-promise: 5.2.0_eslint@7.32.0 + lexorank: 1.0.4 prettier: 2.5.1 typescript: 4.5.4 transitivePeerDependencies: @@ -12199,7 +12203,7 @@ packages: dev: false file:projects/view-resources.tgz_096c09b0b673a57c275d9767a12070b1: - resolution: {integrity: sha512-hpnFAMhZPPs+w9TmZF4XlddOrE2XwPH58k0/CJrj303Lyb8g4IDfN29B/G+sv8npFpAXUIc+w9JhV5IsMxZJJg==, tarball: file:projects/view-resources.tgz} + resolution: {integrity: sha512-oT79PCOUvwaL6QgjuwTNVJJqyE82WDmBx37jF5/c6SpSrYNF14+hN41rrPReKQyhhxkyrBts73IePyHxIn653Q==, tarball: file:projects/view-resources.tgz} id: file:projects/view-resources.tgz name: '@rush-temp/view-resources' version: 0.0.0 diff --git a/dev/generator/src/kanban.ts b/dev/generator/src/kanban.ts index b39f3b1ffa..03557cbb71 100644 --- a/dev/generator/src/kanban.ts +++ b/dev/generator/src/kanban.ts @@ -1,6 +1,6 @@ -import { genRanks, Ref, TxOperations } from '@anticrm/core' -import task, { DoneState, Kanban, SpaceWithStates, State } from '@anticrm/task' +import { Ref, TxOperations } from '@anticrm/core' +import task, { DoneState, genRanks, Kanban, SpaceWithStates, State } from '@anticrm/task' import { findOrUpdate } from './utils' export async function createUpdateSpaceKanban (spaceId: Ref, client: TxOperations): Promise[]> { diff --git a/dev/generator/src/recruit.ts b/dev/generator/src/recruit.ts index 7a61f1fc21..e4a49a1322 100644 --- a/dev/generator/src/recruit.ts +++ b/dev/generator/src/recruit.ts @@ -1,7 +1,8 @@ import contact from '@anticrm/contact' -import core, { AttachedData, Data, generateId, genRanks, Ref, TxOperations } from '@anticrm/core' +import core, { AttachedData, Data, generateId, Ref, TxOperations } from '@anticrm/core' import recruit from '@anticrm/model-recruit' import { Applicant, Candidate, Vacancy } from '@anticrm/recruit' +import { genRanks } from '@anticrm/task' import faker from 'faker' import jpeg, { BufferRet } from 'jpeg-js' import { Client } from 'minio' diff --git a/models/core/src/security.ts b/models/core/src/security.ts index 99f27079ce..f91c8ab5a6 100644 --- a/models/core/src/security.ts +++ b/models/core/src/security.ts @@ -15,7 +15,7 @@ import type { Account, Arr, Ref, Space } from '@anticrm/core' import { DOMAIN_MODEL } from '@anticrm/core' -import { Implements, Model, Prop, TypeBoolean, TypeString } from '@anticrm/model' +import { Model, Prop, TypeBoolean, TypeString } from '@anticrm/model' import type { IntlString } from '@anticrm/platform' import core from './component' import { TDoc } from './core' @@ -43,8 +43,3 @@ export class TSpace extends TDoc implements Space { export class TAccount extends TDoc implements Account { email!: string } -@Implements(core.interface.DocWithRank) -export class TDocWithRank extends TDoc { - @Prop(TypeString(), 'Rank' as IntlString) - rank!: string -} diff --git a/models/task/src/index.ts b/models/task/src/index.ts index 55e0f99629..5dfd9bdd2e 100644 --- a/models/task/src/index.ts +++ b/models/task/src/index.ts @@ -20,7 +20,7 @@ import attachment from '@anticrm/model-attachment' import type { Employee } from '@anticrm/contact' import contact from '@anticrm/contact' import { Arr, Class, Doc, Domain, DOMAIN_MODEL, FindOptions, Ref, Space, Timestamp } from '@anticrm/core' -import { Builder, Collection, Mixin, Model, Prop, TypeBoolean, TypeDate, TypeRef, TypeString, UX } from '@anticrm/model' +import { Builder, Collection, Implements, Mixin, Model, Prop, TypeBoolean, TypeDate, TypeRef, TypeString, UX } from '@anticrm/model' import chunter from '@anticrm/model-chunter' import core, { TAttachedDoc, TClass, TDoc, TSpace } from '@anticrm/model-core' import view from '@anticrm/model-view' @@ -54,7 +54,7 @@ export { default } from './plugin' export const DOMAIN_TASK = 'task' as Domain export const DOMAIN_STATE = 'state' as Domain export const DOMAIN_KANBAN = 'kanban' as Domain -@Model(task.class.State, core.class.Doc, DOMAIN_STATE, [core.interface.DocWithRank]) +@Model(task.class.State, core.class.Doc, DOMAIN_STATE, [task.interface.DocWithRank]) @UX('State' as IntlString, undefined, undefined, 'title') export class TState extends TDoc implements State { @Prop(TypeString(), 'Title' as IntlString) @@ -65,7 +65,7 @@ export class TState extends TDoc implements State { declare rank: string } -@Model(task.class.DoneState, core.class.Doc, DOMAIN_STATE, [core.interface.DocWithRank]) +@Model(task.class.DoneState, core.class.Doc, DOMAIN_STATE, [task.interface.DocWithRank]) @UX('Done' as IntlString, undefined, undefined, 'title') export class TDoneState extends TDoc implements DoneState { @Prop(TypeString(), 'Title' as IntlString) @@ -85,7 +85,7 @@ export class TLostState extends TDoneState implements LostState {} * * No domain is specified, since pure Tasks could not exists */ -@Model(task.class.Task, core.class.AttachedDoc, DOMAIN_TASK, [core.interface.DocWithRank]) +@Model(task.class.Task, core.class.AttachedDoc, DOMAIN_TASK, [task.interface.DocWithRank]) export class TTask extends TAttachedDoc implements Task { @Prop(TypeRef(task.class.State), 'State' as IntlString) state!: Ref @@ -168,7 +168,7 @@ export class TKanbanTemplateSpace extends TSpace implements KanbanTemplateSpace icon!: AnyComponent } -@Model(task.class.StateTemplate, core.class.AttachedDoc, DOMAIN_KANBAN, [core.interface.DocWithRank]) +@Model(task.class.StateTemplate, core.class.AttachedDoc, DOMAIN_KANBAN, [task.interface.DocWithRank]) export class TStateTemplate extends TAttachedDoc implements StateTemplate { @Prop(TypeString(), 'Title' as IntlString) title!: string @@ -179,7 +179,7 @@ export class TStateTemplate extends TAttachedDoc implements StateTemplate { declare rank: string } -@Model(task.class.DoneStateTemplate, core.class.AttachedDoc, DOMAIN_KANBAN, [core.interface.DocWithRank]) +@Model(task.class.DoneStateTemplate, core.class.AttachedDoc, DOMAIN_KANBAN, [task.interface.DocWithRank]) export class TDoneStateTemplate extends TAttachedDoc implements DoneStateTemplate { @Prop(TypeString(), 'Title' as IntlString) title!: string @@ -211,8 +211,15 @@ export class TSequence extends TDoc implements Sequence { sequence!: number } +@Implements(task.interface.DocWithRank) +export class TDocWithRank extends TDoc { + @Prop(TypeString(), 'Rank' as IntlString) + rank!: string +} + export function createModel (builder: Builder): void { builder.createModel( + TDocWithRank, TState, TDoneState, TWonState, diff --git a/models/task/src/migration.ts b/models/task/src/migration.ts index 5b699bfade..a1cbfbf955 100644 --- a/models/task/src/migration.ts +++ b/models/task/src/migration.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import { AttachedDoc, Class, Client, Doc, DocWithRank, Domain, DOMAIN_TX, genRanks, Ref, Space, TxCUD, TxOperations } from '@anticrm/core' +import { AttachedDoc, Class, Client, Doc, Domain, DOMAIN_TX, Ref, Space, TxCUD, TxOperations } from '@anticrm/core' import { MigrateOperation, MigrateUpdate, @@ -22,7 +22,7 @@ import { MigrationUpgradeClient } from '@anticrm/model' import core from '@anticrm/model-core' -import { createProjectKanban, KanbanTemplate } from '@anticrm/task' +import { createProjectKanban, DocWithRank, genRanks, KanbanTemplate } from '@anticrm/task' import { DOMAIN_TASK, DOMAIN_STATE, DOMAIN_KANBAN } from '.' import task from './plugin' diff --git a/packages/core/package.json b/packages/core/package.json index 013f9edc38..b01ec98392 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -29,7 +29,6 @@ }, "dependencies": { "@anticrm/platform": "~0.6.5", - "just-clone": "^3.2.1", - "lexorank": "~1.0.4" + "just-clone": "^3.2.1" } } diff --git a/packages/core/src/classes.ts b/packages/core/src/classes.ts index 0f68d35b74..0b976db7c1 100644 --- a/packages/core/src/classes.ts +++ b/packages/core/src/classes.ts @@ -220,10 +220,3 @@ export interface Space extends Doc { export interface Account extends Doc { email: string } - -/** - * @public - */ -export interface DocWithRank extends Doc { - rank: string -} diff --git a/packages/core/src/component.ts b/packages/core/src/component.ts index 1383c5796b..39deef8015 100644 --- a/packages/core/src/component.ts +++ b/packages/core/src/component.ts @@ -14,7 +14,7 @@ // import type { Plugin, StatusCode } from '@anticrm/platform' import { plugin } from '@anticrm/platform' -import type { Account, ArrOf, AnyAttribute, AttachedDoc, DocWithRank, Class, Doc, Interface, Obj, PropertyType, Ref, Space, Timestamp, Type, Collection, RefTo } from './classes' +import type { Account, ArrOf, AnyAttribute, AttachedDoc, Class, Doc, Interface, Obj, PropertyType, Ref, Space, Timestamp, Type, Collection, RefTo } from './classes' import type { Tx, TxBulkWrite, TxCollectionCUD, TxCreateDoc, TxCUD, TxMixin, TxPutBag, TxRemoveDoc, TxUpdateDoc } from './tx' /** @@ -50,9 +50,6 @@ export default plugin(coreId, { Collection: '' as Ref>>, Bag: '' as Ref>>> }, - interface: { - DocWithRank: '' as Ref> - }, space: { Tx: '' as Ref, Model: '' as Ref diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index a4728b379b..eb6b3825eb 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -13,9 +13,6 @@ // limitations under the License. // -import { LexoRank, LexoDecimal, LexoNumeralSystem36 } from 'lexorank' -import LexoRankBucket from 'lexorank/lib/lexoRank/lexoRankBucket' - import type { Doc, Ref, Account } from './classes' function toHex (value: number, chars: number): string { @@ -62,30 +59,3 @@ export function getCurrentAccount (): Account { return currentAccount } export function setCurrentAccount (account: Account): void { currentAccount = account } - -/** - * @public - */ -export const genRanks = (count: number): Generator => - (function * () { - const sys = new LexoNumeralSystem36() - const base = 36 - const max = base ** 6 - const gap = LexoDecimal.parse(Math.trunc(max / (count + 2)).toString(base), sys) - let cur = LexoDecimal.parse('0', sys) - - for (let i = 0; i < count; i++) { - cur = cur.add(gap) - yield new LexoRank(LexoRankBucket.BUCKET_0, cur).toString() - } - })() - -/** - * @public - */ -export const calcRank = (prev?: { rank: string }, next?: { rank: string }): string => { - const a = prev?.rank !== undefined ? LexoRank.parse(prev.rank) : LexoRank.min() - const b = next?.rank !== undefined ? LexoRank.parse(next.rank) : LexoRank.max() - - return a.between(b).toString() -} diff --git a/plugins/lead-resources/src/components/CreateLead.svelte b/plugins/lead-resources/src/components/CreateLead.svelte index 3ea90a1676..297baa7533 100644 --- a/plugins/lead-resources/src/components/CreateLead.svelte +++ b/plugins/lead-resources/src/components/CreateLead.svelte @@ -15,7 +15,7 @@ -->