diff --git a/models/board/src/migration.ts b/models/board/src/migration.ts index 4044e41f92..19835e7c9c 100644 --- a/models/board/src/migration.ts +++ b/models/board/src/migration.ts @@ -56,7 +56,7 @@ async function createDefaults (tx: TxOperations): Promise { await createOrUpdate( tx, tags.class.TagCategory, - tags.space.Tags, + core.space.Workspace, { icon: tags.icon.Tags, label: 'Other', diff --git a/models/controlled-documents/src/migration.ts b/models/controlled-documents/src/migration.ts index b619216820..e81d4f9d7f 100644 --- a/models/controlled-documents/src/migration.ts +++ b/models/controlled-documents/src/migration.ts @@ -243,7 +243,7 @@ async function createTagCategories (tx: TxOperations): Promise { await createOrUpdate( tx, tags.class.TagCategory, - tags.space.Tags, + core.space.Workspace, { icon: tags.icon.Tags, label: 'Labels', @@ -257,7 +257,7 @@ async function createTagCategories (tx: TxOperations): Promise { await createOrUpdate( tx, tags.class.TagCategory, - tags.space.Tags, + core.space.Workspace, { icon: tags.icon.Tags, label: 'Labels', diff --git a/models/gmail/src/migration.ts b/models/gmail/src/migration.ts index d24ee0985f..b409744304 100644 --- a/models/gmail/src/migration.ts +++ b/models/gmail/src/migration.ts @@ -13,29 +13,27 @@ // limitations under the License. // +import core, { type Ref, type Space } from '@hcengineering/core' import { gmailId } from '@hcengineering/gmail' import { - createDefaultSpace, - tryUpgrade, + migrateSpace, + tryMigrate, type MigrateOperation, type MigrationClient, type MigrationUpgradeClient } from '@hcengineering/model' -import gmail from './plugin' +import { DOMAIN_GMAIL } from '.' export const gmailOperation: MigrateOperation = { - async migrate (client: MigrationClient): Promise {}, - async upgrade (state: Map>, client: () => Promise): Promise { - await tryUpgrade(state, client, gmailId, [ + async migrate (client: MigrationClient): Promise { + await tryMigrate(client, gmailId, [ { - state: 'create-defaults-v2', - func: async (client) => { - await createDefaultSpace(client, gmail.space.Gmail, { - name: 'Gmail', - description: 'Space for all gmail messages' - }) + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'gmail:space:Gmail' as Ref, core.space.Workspace, [DOMAIN_GMAIL]) } } ]) - } + }, + async upgrade (state: Map>, client: () => Promise): Promise {} } diff --git a/models/guest/src/index.ts b/models/guest/src/index.ts index a50576874e..bf9fe3e495 100644 --- a/models/guest/src/index.ts +++ b/models/guest/src/index.ts @@ -12,7 +12,7 @@ import core, { TDoc } from '@hcengineering/model-core' import { type Location } from '@hcengineering/ui' import guest from './plugin' -const GUEST_DOMAIN = 'guest' as Domain +export const GUEST_DOMAIN = 'guest' as Domain @Model(guest.class.PublicLink, core.class.Doc, GUEST_DOMAIN) export class TPublicLink extends TDoc implements PublicLink { diff --git a/models/guest/src/migration.ts b/models/guest/src/migration.ts index 4a3b77f9fd..12e08146aa 100644 --- a/models/guest/src/migration.ts +++ b/models/guest/src/migration.ts @@ -1,16 +1,23 @@ -import { AccountRole, DOMAIN_TX, type Account, type TxCreateDoc, type TxUpdateDoc } from '@hcengineering/core' +import { + AccountRole, + DOMAIN_TX, + type Ref, + type Space, + type Account, + type TxCreateDoc, + type TxUpdateDoc +} from '@hcengineering/core' import { guestId } from '@hcengineering/guest' import { - createDefaultSpace, + migrateSpace, tryMigrate, - tryUpgrade, type MigrateOperation, type MigrationClient, type MigrationUpgradeClient, type ModelLogger } from '@hcengineering/model' import core from '@hcengineering/model-core' -import guest from './plugin' +import { GUEST_DOMAIN } from '.' export const guestOperation: MigrateOperation = { async migrate (client: MigrationClient, logger: ModelLogger): Promise { @@ -58,20 +65,14 @@ export const guestOperation: MigrateOperation = { ) } } - } - ]) - }, - async upgrade (state: Map>, client: () => Promise): Promise { - await tryUpgrade(state, client, guestId, [ + }, { - state: 'create-defaults-v2', - func: async (client) => { - await createDefaultSpace(client, guest.space.Links, { - name: 'Links', - description: 'Space for all guest links' - }) + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'guest:space:Links' as Ref, core.space.Workspace, [GUEST_DOMAIN]) } } ]) - } + }, + async upgrade (state: Map>, client: () => Promise): Promise {} } diff --git a/models/hr/src/migration.ts b/models/hr/src/migration.ts index 30486404a8..29f53575ac 100644 --- a/models/hr/src/migration.ts +++ b/models/hr/src/migration.ts @@ -13,9 +13,10 @@ // limitations under the License. // -import { type Ref, TxOperations } from '@hcengineering/core' +import { type Space, TxOperations, type Ref } from '@hcengineering/core' +import { type Department } from '@hcengineering/hr' import { - createDefaultSpace, + migrateSpace, tryMigrate, tryUpgrade, type MigrateOperation, @@ -24,7 +25,6 @@ import { } from '@hcengineering/model' import core, { DOMAIN_SPACE } from '@hcengineering/model-core' import hr, { DOMAIN_HR, hrId } from './index' -import { type Department } from '@hcengineering/hr' async function createDepartment (tx: TxOperations): Promise { const current = await tx.findOne(hr.class.Department, { @@ -33,7 +33,7 @@ async function createDepartment (tx: TxOperations): Promise { if (current === undefined) { await tx.createDoc( hr.class.Department, - hr.space.HR, + core.space.Workspace, { name: 'Organization', description: '', @@ -49,21 +49,21 @@ async function createDepartment (tx: TxOperations): Promise { async function migrateDepartments (client: MigrationClient): Promise { await client.update( DOMAIN_HR, - { _class: hr.class.PublicHoliday, space: { $ne: hr.space.HR } }, - { space: hr.space.HR } + { _class: hr.class.PublicHoliday, space: { $ne: core.space.Workspace } }, + { space: core.space.Workspace } ) - const objects = await client.find(DOMAIN_HR, { space: { $ne: hr.space.HR }, _class: hr.class.Request }) + const objects = await client.find(DOMAIN_HR, { space: { $ne: core.space.Workspace }, _class: hr.class.Request }) for (const obj of objects) { - await client.update(DOMAIN_HR, { _id: obj._id }, { space: hr.space.HR, department: obj.space }) + await client.update(DOMAIN_HR, { _id: obj._id }, { space: core.space.Workspace, department: obj.space }) } await client.move(DOMAIN_SPACE, { _class: hr.class.Department }, DOMAIN_HR) const departments = await client.find(DOMAIN_HR, { _class: hr.class.Department, - space: { $ne: hr.space.HR } + space: { $ne: core.space.Workspace } }) for (const department of departments) { const upd: Partial = { - space: hr.space.HR + space: core.space.Workspace } if (department._id !== hr.ids.Head) { upd.parent = department.space as unknown as Ref @@ -83,6 +83,12 @@ export const hrOperation: MigrateOperation = { { state: 'migrateDepartments', func: migrateDepartments + }, + { + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'hr:space:HR' as Ref, core.space.Workspace, [DOMAIN_HR]) + } } ]) }, @@ -91,7 +97,6 @@ export const hrOperation: MigrateOperation = { { state: 'create-defaults-v2', func: async (client) => { - await createDefaultSpace(client, hr.space.HR, { name: 'HR', description: 'Human Resources' }) const tx = new TxOperations(client, core.account.System) await createDepartment(tx) } diff --git a/models/inventory/src/migration.ts b/models/inventory/src/migration.ts index d27e2df771..6c443d0b3b 100644 --- a/models/inventory/src/migration.ts +++ b/models/inventory/src/migration.ts @@ -13,33 +13,28 @@ // limitations under the License. // +import core, { type Ref, type Space } from '@hcengineering/core' import { inventoryId } from '@hcengineering/inventory' import { - createDefaultSpace, - tryUpgrade, + migrateSpace, + tryMigrate, type MigrateOperation, type MigrationClient, type MigrationUpgradeClient } from '@hcengineering/model' -import inventory from './plugin' +import { DOMAIN_INVENTORY } from '.' export const inventoryOperation: MigrateOperation = { - async migrate (client: MigrationClient): Promise {}, - async upgrade (state: Map>, client: () => Promise): Promise { - await tryUpgrade(state, client, inventoryId, [ + async migrate (client: MigrationClient): Promise { + await tryMigrate(client, inventoryId, [ { - state: 'create-defaults-v2', - func: async (client) => { - await createDefaultSpace(client, inventory.space.Category, { - name: 'Categories', - description: 'Space for all inventory categories' - }) - await createDefaultSpace(client, inventory.space.Products, { - name: 'Products', - description: 'Space for all inventory products' - }) + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'inventory:space:Category' as Ref, core.space.Workspace, [DOMAIN_INVENTORY]) + await migrateSpace(client, 'inventory:space:Products' as Ref, core.space.Workspace, [DOMAIN_INVENTORY]) } } ]) - } + }, + async upgrade (state: Map>, client: () => Promise): Promise {} } diff --git a/models/love/src/migration.ts b/models/love/src/migration.ts index 573d40f0f5..baa8b83112 100644 --- a/models/love/src/migration.ts +++ b/models/love/src/migration.ts @@ -14,11 +14,13 @@ // import contact from '@hcengineering/contact' -import { TxOperations, type Ref } from '@hcengineering/core' +import { type Space, TxOperations, type Ref } from '@hcengineering/core' import drive from '@hcengineering/drive' import { RoomAccess, RoomType, createDefaultRooms, isOffice, loveId, type Floor } from '@hcengineering/love' import { createDefaultSpace, + migrateSpace, + tryMigrate, tryUpgrade, type MigrateOperation, type MigrationClient, @@ -26,6 +28,7 @@ import { } from '@hcengineering/model' import core from '@hcengineering/model-core' import love from './plugin' +import { DOMAIN_LOVE } from '.' async function createDefaultFloor (tx: TxOperations): Promise { const current = await tx.findOne(love.class.Floor, { @@ -34,7 +37,7 @@ async function createDefaultFloor (tx: TxOperations): Promise { if (current === undefined) { await tx.createDoc( love.class.Floor, - love.space.Rooms, + core.space.Workspace, { name: 'Main' }, @@ -53,7 +56,7 @@ async function createRooms (client: MigrationUpgradeClient): Promise { const data = createDefaultRooms(employees.map((p) => p._id)) for (const room of data) { const _class = isOffice(room) ? love.class.Office : love.class.Room - await tx.createDoc(_class, love.space.Rooms, room) + await tx.createDoc(_class, core.space.Workspace, room) } } @@ -65,7 +68,7 @@ async function createReception (client: MigrationUpgradeClient): Promise { if (current !== undefined) return await tx.createDoc( love.class.Room, - love.space.Rooms, + core.space.Workspace, { name: 'Reception', type: RoomType.Reception, @@ -81,15 +84,18 @@ async function createReception (client: MigrationUpgradeClient): Promise { } export const loveOperation: MigrateOperation = { - async migrate (client: MigrationClient): Promise {}, + async migrate (client: MigrationClient): Promise { + await tryMigrate(client, loveId, [ + { + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'love:space:Rooms' as Ref, core.space.Workspace, [DOMAIN_LOVE]) + } + } + ]) + }, async upgrade (state: Map>, client: () => Promise): Promise { await tryUpgrade(state, client, loveId, [ - { - state: 'create-defaults-v2', - func: async (client) => { - await createDefaultSpace(client, love.space.Rooms, { name: 'Rooms', description: 'Space for all rooms' }) - } - }, { state: 'initial-defaults', func: async (client) => { diff --git a/models/notification/src/migration.ts b/models/notification/src/migration.ts index be43052634..2463de4ddd 100644 --- a/models/notification/src/migration.ts +++ b/models/notification/src/migration.ts @@ -13,11 +13,10 @@ // limitations under the License. // -import { type Doc, type Ref, type Class, type DocumentQuery, DOMAIN_TX } from '@hcengineering/core' +import core, { DOMAIN_TX, type Class, type Doc, type DocumentQuery, type Ref, type Space } from '@hcengineering/core' import { - createDefaultSpace, + migrateSpace, tryMigrate, - tryUpgrade, type MigrateOperation, type MigrationClient, type MigrationUpgradeClient @@ -76,37 +75,29 @@ export const notificationOperation: MigrateOperation = { func: async (client) => { await removeNotifications(client, { hidden: true }) } - } - ]) - await tryMigrate(client, notificationId, [ + }, { state: 'delete-invalid-notifications', func: async (client) => { await removeNotifications(client, { attachedToClass: 'chunter:class:Comment' as Ref> }) } - } - ]) - await tryMigrate(client, notificationId, [ + }, { state: 'remove-old-classes', func: async (client) => { await client.deleteMany(DOMAIN_NOTIFICATION, { _class: 'notification:class:DocUpdates' as Ref> }) await client.deleteMany(DOMAIN_TX, { objectClass: 'notification:class:DocUpdates' as Ref> }) } - } - ]) - }, - async upgrade (state: Map>, client: () => Promise): Promise { - await tryUpgrade(state, client, notificationId, [ + }, { - state: 'create-defaults-v2', - func: async (client) => { - await createDefaultSpace(client, notification.space.Notifications, { - name: 'Notifications', - description: 'Space for all notifications' - }) + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'notification:space:Notifications' as Ref, core.space.Workspace, [ + DOMAIN_NOTIFICATION + ]) } } ]) - } + }, + async upgrade (state: Map>, client: () => Promise): Promise {} } diff --git a/models/preference/src/migration.ts b/models/preference/src/migration.ts index 9170d9a0e1..7bd1dfeffb 100644 --- a/models/preference/src/migration.ts +++ b/models/preference/src/migration.ts @@ -13,25 +13,28 @@ // limitations under the License. // +import core, { type Ref, type Space } from '@hcengineering/core' import { - createDefaultSpace, - tryUpgrade, + migrateSpace, + tryMigrate, type MigrateOperation, type MigrationClient, type MigrationUpgradeClient } from '@hcengineering/model' -import preference, { preferenceId } from '@hcengineering/preference' +import { DOMAIN_PREFERENCE, preferenceId } from '@hcengineering/preference' export const preferenceOperation: MigrateOperation = { - async migrate (client: MigrationClient): Promise {}, - async upgrade (state: Map>, client: () => Promise): Promise { - await tryUpgrade(state, client, preferenceId, [ + async migrate (client: MigrationClient): Promise { + await tryMigrate(client, preferenceId, [ { - state: 'create-defaults-v2', - func: async (client) => { - await createDefaultSpace(client, preference.space.Preference, { name: 'Preference' }) + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'preference:space:Preference' as Ref, core.space.Workspace, [ + DOMAIN_PREFERENCE + ]) } } ]) - } + }, + async upgrade (state: Map>, client: () => Promise): Promise {} } diff --git a/models/recruit/src/migration.ts b/models/recruit/src/migration.ts index ff36b7a2e3..6004bab9b3 100644 --- a/models/recruit/src/migration.ts +++ b/models/recruit/src/migration.ts @@ -14,10 +14,10 @@ // import { getCategories } from '@anticrm/skillset' -import core, { DOMAIN_TX, TxOperations, type Ref, type Status } from '@hcengineering/core' +import core, { DOMAIN_TX, TxOperations, type Ref, type Space, type Status } from '@hcengineering/core' import { - createDefaultSpace, createOrUpdate, + migrateSpace, tryMigrate, tryUpgrade, type MigrateOperation, @@ -29,6 +29,7 @@ import tags, { type TagCategory } from '@hcengineering/model-tags' import task, { DOMAIN_TASK, createSequence, migrateDefaultStatusesBase } from '@hcengineering/model-task' import { recruitId, type Applicant } from '@hcengineering/recruit' +import { DOMAIN_CALENDAR } from '@hcengineering/model-calendar' import { DOMAIN_SPACE } from '@hcengineering/model-core' import recruit from './plugin' import { defaultApplicantStatuses } from './spaceType' @@ -53,6 +54,12 @@ export const recruitOperation: MigrateOperation = { func: async (client) => { await migrateDefaultTypeMixins(client) } + }, + { + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'recruit:space:Reviews' as Ref, core.space.Workspace, [DOMAIN_CALENDAR]) + } } ]) }, @@ -164,12 +171,10 @@ async function migrateDefaultTypeMixins (client: MigrationClient): Promise } async function createDefaults (client: MigrationUpgradeClient, tx: TxOperations): Promise { - await createDefaultSpace(client, recruit.space.Reviews, { name: 'Reviews' }) - await createOrUpdate( tx, tags.class.TagCategory, - tags.space.Tags, + core.space.Workspace, { icon: recruit.icon.Skills, label: 'Other', @@ -184,7 +189,7 @@ async function createDefaults (client: MigrationUpgradeClient, tx: TxOperations) await createOrUpdate( tx, tags.class.TagCategory, - tags.space.Tags, + core.space.Workspace, { icon: recruit.icon.Skills, label: c.label, diff --git a/models/setting/src/migration.ts b/models/setting/src/migration.ts index 84a571ba2b..062ca77dcf 100644 --- a/models/setting/src/migration.ts +++ b/models/setting/src/migration.ts @@ -13,26 +13,27 @@ // limitations under the License. // +import core, { type Ref, type Space } from '@hcengineering/core' import { - createDefaultSpace, - tryUpgrade, + migrateSpace, + tryMigrate, type MigrateOperation, type MigrationClient, type MigrationUpgradeClient } from '@hcengineering/model' import { settingId } from '@hcengineering/setting' -import setting from './plugin' +import { DOMAIN_SETTING } from '.' export const settingOperation: MigrateOperation = { - async migrate (client: MigrationClient): Promise {}, - async upgrade (state: Map>, client: () => Promise): Promise { - await tryUpgrade(state, client, settingId, [ + async migrate (client: MigrationClient): Promise { + await tryMigrate(client, settingId, [ { - state: 'create-defaults-v2', - func: async (client) => { - await createDefaultSpace(client, setting.space.Setting, { name: 'Setting' }) + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'setting:space:Setting' as Ref, core.space.Workspace, [DOMAIN_SETTING]) } } ]) - } + }, + async upgrade (state: Map>, client: () => Promise): Promise {} } diff --git a/models/tags/src/migration.ts b/models/tags/src/migration.ts index c0b0a47dbc..dae6c50a37 100644 --- a/models/tags/src/migration.ts +++ b/models/tags/src/migration.ts @@ -1,23 +1,24 @@ +import core, { type Ref, type Space } from '@hcengineering/core' import { - createDefaultSpace, - tryUpgrade, + migrateSpace, + tryMigrate, type MigrateOperation, type MigrationClient, type MigrationUpgradeClient } from '@hcengineering/model' import { tagsId } from '@hcengineering/tags' -import tags from './plugin' +import { DOMAIN_TAGS } from '.' export const tagsOperation: MigrateOperation = { - async migrate (client: MigrationClient): Promise {}, - async upgrade (state: Map>, client: () => Promise): Promise { - await tryUpgrade(state, client, tagsId, [ + async migrate (client: MigrationClient): Promise { + await tryMigrate(client, tagsId, [ { - state: 'create-defaults-v2', - func: async (client) => { - await createDefaultSpace(client, tags.space.Tags, { name: 'Tags', description: 'Space for all tags' }) + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'tags:space:Tags' as Ref, core.space.Workspace, [DOMAIN_TAGS]) } } ]) - } + }, + async upgrade (state: Map>, client: () => Promise): Promise {} } diff --git a/models/task/src/migration.ts b/models/task/src/migration.ts index 740a97e9c8..93f7b7c0eb 100644 --- a/models/task/src/migration.ts +++ b/models/task/src/migration.ts @@ -30,8 +30,8 @@ import { type TxUpdateDoc } from '@hcengineering/core' import { - createDefaultSpace, createOrUpdate, + migrateSpace, tryMigrate, tryUpgrade, type MigrateOperation, @@ -51,7 +51,7 @@ import { type TaskType } from '@hcengineering/task' -import { DOMAIN_TASK } from '.' +import { DOMAIN_KANBAN, DOMAIN_TASK } from '.' import task from './plugin' /** @@ -59,18 +59,13 @@ import task from './plugin' */ export async function createSequence (tx: TxOperations, _class: Ref>): Promise { if ((await tx.findOne(task.class.Sequence, { attachedTo: _class })) === undefined) { - await tx.createDoc(task.class.Sequence, task.space.Sequence, { + await tx.createDoc(task.class.Sequence, core.space.Workspace, { attachedTo: _class, sequence: 0 }) } } -async function createDefaults (client: MigrationUpgradeClient): Promise { - await createDefaultSpace(client, task.space.Sequence, { name: 'Sequences' }) - await createDefaultSpace(client, task.space.Statuses, { name: 'Statuses' }) -} - export async function migrateDefaultStatusesBase ( client: MigrationClient, logger: ModelLogger, @@ -583,15 +578,17 @@ export const taskOperation: MigrateOperation = { ) } } + }, + { + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, task.space.Sequence, core.space.Workspace, [DOMAIN_KANBAN]) + } } ]) }, async upgrade (state: Map>, client: () => Promise): Promise { await tryUpgrade(state, client, taskId, [ - { - state: 'defaults-v2', - func: createDefaults - }, { state: 'u-task-001', func: async (client) => { @@ -600,7 +597,7 @@ export const taskOperation: MigrateOperation = { await createOrUpdate( tx, tags.class.TagCategory, - tags.space.Tags, + core.space.Workspace, { icon: tags.icon.Tags, label: 'Text Label', diff --git a/models/telegram/src/migration.ts b/models/telegram/src/migration.ts index acf909b2ce..7bad58ad9d 100644 --- a/models/telegram/src/migration.ts +++ b/models/telegram/src/migration.ts @@ -13,31 +13,27 @@ // limitations under the License. // +import core, { type Ref, type Space } from '@hcengineering/core' import { - createDefaultSpace, - tryUpgrade, + migrateSpace, + tryMigrate, type MigrateOperation, type MigrationClient, type MigrationUpgradeClient } from '@hcengineering/model' import { telegramId } from '@hcengineering/telegram' -import telegram from './plugin' - -export async function createSpace (client: MigrationUpgradeClient): Promise { - await createDefaultSpace(client, telegram.space.Telegram, { - name: 'Telegram', - description: 'Space for all telegram messages' - }) -} +import { DOMAIN_TELEGRAM } from '.' export const telegramOperation: MigrateOperation = { - async migrate (client: MigrationClient): Promise {}, - async upgrade (state: Map>, client: () => Promise): Promise { - await tryUpgrade(state, client, telegramId, [ + async migrate (client: MigrationClient): Promise { + await tryMigrate(client, telegramId, [ { - state: 'defaults-v2', - func: createSpace + state: 'removeDeprecatedSpace', + func: async (client: MigrationClient) => { + await migrateSpace(client, 'telegram:space:Telegram' as Ref, core.space.Workspace, [DOMAIN_TELEGRAM]) + } } ]) - } + }, + async upgrade (state: Map>, client: () => Promise): Promise {} } diff --git a/models/time/src/index.ts b/models/time/src/index.ts index 33be2f0f91..785a00ee2a 100644 --- a/models/time/src/index.ts +++ b/models/time/src/index.ts @@ -193,7 +193,6 @@ export function createModel (builder: Builder): void { icon: calendarPlugin.icon.Calendar, alias: timeId, hidden: false, - position: 'top', modern: true, component: time.component.Me }, diff --git a/models/time/src/migration.ts b/models/time/src/migration.ts index dc42f31704..91e282515c 100644 --- a/models/time/src/migration.ts +++ b/models/time/src/migration.ts @@ -190,7 +190,7 @@ export const timeOperation: MigrateOperation = { await createOrUpdate( tx, tags.class.TagCategory, - tags.space.Tags, + core.space.Workspace, { icon: tags.icon.Tags, label: 'Other', diff --git a/models/tracker/src/migration.ts b/models/tracker/src/migration.ts index cc84a53835..f6ccd71142 100644 --- a/models/tracker/src/migration.ts +++ b/models/tracker/src/migration.ts @@ -126,7 +126,7 @@ async function createDefaults (tx: TxOperations): Promise { await createOrUpdate( tx, tags.class.TagCategory, - tags.space.Tags, + core.space.Workspace, { icon: tags.icon.Tags, label: 'Other', diff --git a/packages/core/src/component.ts b/packages/core/src/component.ts index ba9a1751e5..92ec1ad5b6 100644 --- a/packages/core/src/component.ts +++ b/packages/core/src/component.ts @@ -159,7 +159,8 @@ export default plugin(coreId, { DerivedTx: '' as Ref, Model: '' as Ref, Space: '' as Ref, - Configuration: '' as Ref + Configuration: '' as Ref, + Workspace: '' as Ref }, account: { System: '' as Ref, diff --git a/packages/model/src/migration.ts b/packages/model/src/migration.ts index 641ada9945..7cc54caf18 100644 --- a/packages/model/src/migration.ts +++ b/packages/model/src/migration.ts @@ -2,6 +2,7 @@ import core, { Class, Client, DOMAIN_MIGRATION, + DOMAIN_TX, Data, Doc, DocumentQuery, @@ -223,3 +224,18 @@ export async function createDefaultSpace ( await tx.createDoc(_class, core.space.Space, data, _id) } } + +/** + * @public + */ +export async function migrateSpace ( + client: MigrationClient, + from: Ref, + to: Ref, + domains: Domain[] +): Promise { + for (const domain of domains) { + await client.update(domain, { space: from }, { space: to }) + } + await client.update(DOMAIN_TX, { objectSpace: from }, { objectSpace: to }) +} diff --git a/plugins/activity-resources/src/utils.ts b/plugins/activity-resources/src/utils.ts index 4bd458ed2a..c1be13a8ff 100644 --- a/plugins/activity-resources/src/utils.ts +++ b/plugins/activity-resources/src/utils.ts @@ -1,17 +1,16 @@ -import { get } from 'svelte/store' import type { ActivityMessage, Reaction } from '@hcengineering/activity' -import core, { type Doc, type Ref, type TxOperations, getCurrentAccount, isOtherHour } from '@hcengineering/core' +import core, { getCurrentAccount, isOtherHour, type Doc, type Ref, type TxOperations } from '@hcengineering/core' import { getClient } from '@hcengineering/presentation' import { - type Location, - getEventPositionElement, - closePopup, - showPopup, EmojiPopup, - getCurrentResolvedLocation + closePopup, + getCurrentResolvedLocation, + getEventPositionElement, + showPopup, + type Location } from '@hcengineering/ui' import { type AttributeModel } from '@hcengineering/view' -import preference from '@hcengineering/preference' +import { get } from 'svelte/store' import { savedMessagesStore } from './activity' import activity from './plugin' @@ -77,7 +76,7 @@ export async function saveForLater (message?: ActivityMessage): Promise { closePopup() const client = getClient() - await client.createDoc(activity.class.SavedMessage, preference.space.Preference, { + await client.createDoc(activity.class.SavedMessage, core.space.Workspace, { attachedTo: message._id }) } diff --git a/plugins/attachment-resources/src/index.ts b/plugins/attachment-resources/src/index.ts index ea948a75c4..617ebc191a 100644 --- a/plugins/attachment-resources/src/index.ts +++ b/plugins/attachment-resources/src/index.ts @@ -13,57 +13,56 @@ // limitations under the License. // -import attachment, { type Attachment } from '@hcengineering/attachment' -import { type ObjQueryType, SortingOrder, type SortingQuery, type Markup } from '@hcengineering/core' -import { type IntlString, type Resources } from '@hcengineering/platform' -import preference from '@hcengineering/preference' -import { PDFViewer, deleteFile, getClient, uploadFile } from '@hcengineering/presentation' import activity, { type ActivityMessage, type DocUpdateMessage } from '@hcengineering/activity' +import attachment, { type Attachment } from '@hcengineering/attachment' +import core, { SortingOrder, type Markup, type ObjQueryType, type SortingQuery } from '@hcengineering/core' +import { type IntlString, type Resources } from '@hcengineering/platform' +import { PDFViewer, deleteFile, getClient, uploadFile } from '@hcengineering/presentation' +import AccordionEditor from './components/AccordionEditor.svelte' import AddAttachment from './components/AddAttachment.svelte' import AttachmentDocList from './components/AttachmentDocList.svelte' import AttachmentDroppable from './components/AttachmentDroppable.svelte' import AttachmentGalleryPresenter from './components/AttachmentGalleryPresenter.svelte' import AttachmentList from './components/AttachmentList.svelte' import AttachmentPresenter from './components/AttachmentPresenter.svelte' +import AttachmentPreview from './components/AttachmentPreview.svelte' import AttachmentRefInput from './components/AttachmentRefInput.svelte' +import AttachmentStyleBoxCollabEditor from './components/AttachmentStyleBoxCollabEditor.svelte' +import AttachmentStyleBoxEditor from './components/AttachmentStyleBoxEditor.svelte' +import AttachmentStyledBox from './components/AttachmentStyledBox.svelte' import Attachments from './components/Attachments.svelte' import AttachmentsPresenter from './components/AttachmentsPresenter.svelte' -import FileBrowser from './components/FileBrowser.svelte' -import FileDownload from './components/icons/FileDownload.svelte' -import Photos from './components/Photos.svelte' -import AttachmentStyledBox from './components/AttachmentStyledBox.svelte' -import AttachmentStyleBoxEditor from './components/AttachmentStyleBoxEditor.svelte' -import AttachmentStyleBoxCollabEditor from './components/AttachmentStyleBoxCollabEditor.svelte' -import AccordionEditor from './components/AccordionEditor.svelte' -import IconUploadDuo from './components/icons/UploadDuo.svelte' -import IconAttachment from './components/icons/Attachment.svelte' -import AttachmentPreview from './components/AttachmentPreview.svelte' -import AttachmentsUpdatedMessage from './components/activity/AttachmentsUpdatedMessage.svelte' import AttachmentsTooltip from './components/AttachmentsTooltip.svelte' +import FileBrowser from './components/FileBrowser.svelte' +import Photos from './components/Photos.svelte' +import AttachmentsUpdatedMessage from './components/activity/AttachmentsUpdatedMessage.svelte' +import IconAttachment from './components/icons/Attachment.svelte' +import FileDownload from './components/icons/FileDownload.svelte' +import IconUploadDuo from './components/icons/UploadDuo.svelte' export * from './types' export { + AccordionEditor, AddAttachment, + AttachmentDocList, AttachmentDroppable, + AttachmentGalleryPresenter, + AttachmentList, + AttachmentPresenter, + AttachmentPreview, + AttachmentRefInput, + AttachmentStyleBoxCollabEditor, + AttachmentStyleBoxEditor, + AttachmentStyledBox, Attachments, AttachmentsPresenter, - AttachmentPresenter, - AttachmentGalleryPresenter, - AttachmentRefInput, - AttachmentList, - AttachmentDocList, - FileDownload, + AttachmentsTooltip, FileBrowser, - AttachmentStyledBox, - AttachmentStyleBoxEditor, - AttachmentStyleBoxCollabEditor, - AccordionEditor, - IconUploadDuo, + FileDownload, IconAttachment, - AttachmentPreview, - AttachmentsTooltip + IconUploadDuo } export enum FileBrowserSortMode { @@ -211,7 +210,7 @@ export const fileTypeFileBrowserFilters: TypeFilter[] = [ export async function AddAttachmentToSaved (attach: Attachment): Promise { const client = getClient() - await client.createDoc(attachment.class.SavedAttachments, preference.space.Preference, { + await client.createDoc(attachment.class.SavedAttachments, core.space.Workspace, { attachedTo: attach._id }) } diff --git a/plugins/bitrix/src/utils.ts b/plugins/bitrix/src/utils.ts index 9cde3bd37b..2884e4ed25 100644 --- a/plugins/bitrix/src/utils.ts +++ b/plugins/bitrix/src/utils.ts @@ -361,7 +361,7 @@ export async function convert ( description: '', title: vv, targetClass: attr.attributeOf, - space: tags.space.Tags, + space: core.space.Workspace, modifiedBy: document.modifiedBy, modifiedOn: document.modifiedOn } @@ -379,7 +379,7 @@ export async function convert ( weight: o.weight, modifiedBy: document.modifiedBy, modifiedOn: document.modifiedOn, - space: tags.space.Tags, + space: core.space.Workspace, bitrixId: vv } newExtraSyncDocs.push(ref) diff --git a/plugins/board-resources/src/utils/BoardUtils.ts b/plugins/board-resources/src/utils/BoardUtils.ts index cf1a397722..df304c73ed 100644 --- a/plugins/board-resources/src/utils/BoardUtils.ts +++ b/plugins/board-resources/src/utils/BoardUtils.ts @@ -1,6 +1,5 @@ import board, { type Board, type CommonBoardPreference } from '@hcengineering/board' import core, { getCurrentAccount, type Ref, type TxOperations } from '@hcengineering/core' -import preference from '@hcengineering/preference' import { createQuery, getClient } from '@hcengineering/presentation' import type { ProjectType } from '@hcengineering/task' import { @@ -55,7 +54,7 @@ export const commonBoardPreference = readable(undefined, set(result[0]) return } - void getClient().createDoc(board.class.CommonBoardPreference, preference.space.Preference, { + void getClient().createDoc(board.class.CommonBoardPreference, core.space.Workspace, { attachedTo: board.app.Board }) }) diff --git a/plugins/contact/src/index.ts b/plugins/contact/src/index.ts index 55107c4f09..fb4c9df5a3 100644 --- a/plugins/contact/src/index.ts +++ b/plugins/contact/src/index.ts @@ -30,7 +30,7 @@ import { import type { Asset, Metadata, Plugin, Resource } from '@hcengineering/platform' import { IntlString, plugin } from '@hcengineering/platform' import { TemplateField, TemplateFieldCategory } from '@hcengineering/templates' -import type { AnyComponent, ColorDefinition, ResolvedLocation } from '@hcengineering/ui' +import type { AnyComponent, ColorDefinition, ResolvedLocation, Location } from '@hcengineering/ui' import { Action, FilterMode, Viewlet } from '@hcengineering/view' /** diff --git a/plugins/controlled-documents/src/plugin.ts b/plugins/controlled-documents/src/plugin.ts index 582117768d..7dae5b44f3 100644 --- a/plugins/controlled-documents/src/plugin.ts +++ b/plugins/controlled-documents/src/plugin.ts @@ -10,7 +10,7 @@ import { } from '@hcengineering/core' import type { Asset, Plugin, Resource } from '@hcengineering/platform' import { IntlString, plugin } from '@hcengineering/platform' -import type { AnyComponent, ResolvedLocation } from '@hcengineering/ui' +import type { AnyComponent, ResolvedLocation, Location } from '@hcengineering/ui' import { Action } from '@hcengineering/view' import type { diff --git a/plugins/document-resources/src/index.ts b/plugins/document-resources/src/index.ts index 4e55eca510..bdf821935e 100644 --- a/plugins/document-resources/src/index.ts +++ b/plugins/document-resources/src/index.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import { +import core, { generateId, getCurrentAccount, type Class, @@ -25,7 +25,6 @@ import { } from '@hcengineering/core' import { type Document, type Teamspace } from '@hcengineering/document' import { type Resources } from '@hcengineering/platform' -import preference from '@hcengineering/preference' import { getClient, type ObjectSearchResult } from '@hcengineering/presentation' import { showPopup } from '@hcengineering/ui' import { openDoc } from '@hcengineering/view-resources' @@ -117,7 +116,7 @@ async function editTeamspace (teamspace: Teamspace | undefined): Promise { export async function starDocument (doc: Document): Promise { const client = getClient() - await client.createDoc(document.class.SavedDocument, preference.space.Preference, { + await client.createDoc(document.class.SavedDocument, core.space.Workspace, { attachedTo: doc._id }) } diff --git a/plugins/gmail-resources/src/components/NewMessage.svelte b/plugins/gmail-resources/src/components/NewMessage.svelte index 7c995bbb72..a9c3f83296 100644 --- a/plugins/gmail-resources/src/components/NewMessage.svelte +++ b/plugins/gmail-resources/src/components/NewMessage.svelte @@ -17,7 +17,7 @@ import attachmentP, { Attachment } from '@hcengineering/attachment' import { AttachmentPresenter } from '@hcengineering/attachment-resources' import contact, { Channel, Contact, getName } from '@hcengineering/contact' - import { Data, Markup, generateId } from '@hcengineering/core' + import core, { Data, Markup, generateId } from '@hcengineering/core' import { NewMessage, SharedMessage } from '@hcengineering/gmail' import { InboxNotificationsClientImpl } from '@hcengineering/notification-resources' import { getResource, setPlatformStatus, unknownError } from '@hcengineering/platform' @@ -68,7 +68,7 @@ async function sendMsg (): Promise { await client.createDoc( plugin.class.NewMessage, - plugin.space.Gmail, + core.space.Workspace, { ...obj, content: markupToHTML(content), @@ -120,7 +120,7 @@ const uuid = await uploadFile(file) await client.addCollection( attachmentP.class.Attachment, - plugin.space.Gmail, + core.space.Workspace, objectId, plugin.class.NewMessage, 'attachments', diff --git a/plugins/gmail-resources/src/components/NewMessages.svelte b/plugins/gmail-resources/src/components/NewMessages.svelte index 55254cf3e4..38c3693d2a 100644 --- a/plugins/gmail-resources/src/components/NewMessages.svelte +++ b/plugins/gmail-resources/src/components/NewMessages.svelte @@ -17,7 +17,7 @@ import attachmentP, { Attachment } from '@hcengineering/attachment' import { AttachmentPresenter } from '@hcengineering/attachment-resources' import contact, { Channel, Contact, getName as getContactName } from '@hcengineering/contact' - import { generateId, getCurrentAccount, Markup, Ref, toIdMap } from '@hcengineering/core' + import core, { generateId, getCurrentAccount, Markup, Ref, toIdMap } from '@hcengineering/core' import { InboxNotificationsClientImpl } from '@hcengineering/notification-resources' import { getResource, setPlatformStatus, unknownError } from '@hcengineering/platform' import { createQuery, getClient } from '@hcengineering/presentation' @@ -83,7 +83,7 @@ templateProvider.set(contact.class.Contact, target) const htmlContent = markupToHTML(content) const message = await templateProvider.fillTemplate(htmlContent) - const id = await client.createDoc(plugin.class.NewMessage, plugin.space.Gmail, { + const id = await client.createDoc(plugin.class.NewMessage, core.space.Workspace, { subject, content: message, to: channel.value, @@ -98,7 +98,7 @@ for (const attachment of attachments) { await client.addCollection( attachmentP.class.Attachment, - plugin.space.Gmail, + core.space.Workspace, id, plugin.class.NewMessage, 'attachments', @@ -145,7 +145,7 @@ const uuid = await uploadFile(file) await client.addCollection( attachmentP.class.Attachment, - plugin.space.Gmail, + core.space.Workspace, attachmentParentId, plugin.class.NewMessage, 'attachments', diff --git a/plugins/gmail/src/index.ts b/plugins/gmail/src/index.ts index a861168114..b739f45986 100644 --- a/plugins/gmail/src/index.ts +++ b/plugins/gmail/src/index.ts @@ -14,10 +14,10 @@ // import { ChannelItem } from '@hcengineering/contact' -import type { Account, AttachedDoc, Class, Doc, Ref, Space, Timestamp } from '@hcengineering/core' +import type { Account, AttachedDoc, Class, Doc, Ref, Timestamp } from '@hcengineering/core' +import { NotificationType } from '@hcengineering/notification' import type { IntlString, Plugin } from '@hcengineering/platform' import { Metadata, plugin } from '@hcengineering/platform' -import { NotificationType } from '@hcengineering/notification' import type { Handler, IntegrationType } from '@hcengineering/setting' import type { AnyComponent } from '@hcengineering/ui' @@ -106,10 +106,6 @@ export default plugin(gmailId, { ids: { EmailNotification: '' as Ref }, - space: { - // todo remove, should be in contact - Gmail: '' as Ref - }, metadata: { GmailURL: '' as Metadata } diff --git a/plugins/guest/src/index.ts b/plugins/guest/src/index.ts index f35cefc94b..1607669457 100644 --- a/plugins/guest/src/index.ts +++ b/plugins/guest/src/index.ts @@ -1,4 +1,4 @@ -import { Class, Doc, Ref, Space } from '@hcengineering/core' +import { Class, Doc, Ref } from '@hcengineering/core' import type { Asset, Plugin } from '@hcengineering/platform' import { plugin } from '@hcengineering/platform' import { AnyComponent, Location } from '@hcengineering/ui' @@ -30,9 +30,6 @@ export default plugin(guestId, { icon: { Link: '' as Asset }, - space: { - Links: '' as Ref - }, component: { GuestApp: '' as AnyComponent } diff --git a/plugins/guest/src/utils.ts b/plugins/guest/src/utils.ts index 41f754920f..5542075b90 100644 --- a/plugins/guest/src/utils.ts +++ b/plugins/guest/src/utils.ts @@ -2,7 +2,7 @@ // Copyright © 2024 Hardcore Engineering Inc. // -import { Doc, TxOperations } from '@hcengineering/core' +import core, { Doc, TxOperations } from '@hcengineering/core' import { type Location } from '@hcengineering/ui' import guest from './index' @@ -13,7 +13,7 @@ export async function createPublicLink ( location: Location, revokable: boolean = true ): Promise { - await client.createDoc(guest.class.PublicLink, guest.space.Links, { + await client.createDoc(guest.class.PublicLink, core.space.Workspace, { attachedTo: object._id, location, revokable, diff --git a/plugins/hr-resources/src/components/CreateDepartment.svelte b/plugins/hr-resources/src/components/CreateDepartment.svelte index 42191853cd..b04ed70741 100644 --- a/plugins/hr-resources/src/components/CreateDepartment.svelte +++ b/plugins/hr-resources/src/components/CreateDepartment.svelte @@ -15,7 +15,7 @@ diff --git a/plugins/love-resources/src/components/EditFloorPopup.svelte b/plugins/love-resources/src/components/EditFloorPopup.svelte index 91709714d1..985aeab02e 100644 --- a/plugins/love-resources/src/components/EditFloorPopup.svelte +++ b/plugins/love-resources/src/components/EditFloorPopup.svelte @@ -3,7 +3,7 @@ import { EditBox } from '@hcengineering/ui' import { createEventDispatcher } from 'svelte' import love from '../plugin' - import { Ref } from '@hcengineering/core' + import core, { Ref } from '@hcengineering/core' import { Floor } from '@hcengineering/love' export let id: Ref | undefined = undefined @@ -20,11 +20,11 @@ } async function createFloor (): Promise { - await client.createDoc(love.class.Floor, love.space.Rooms, { name }) + await client.createDoc(love.class.Floor, core.space.Workspace, { name }) } async function updateFloor (): Promise { if (id === undefined) return - await client.updateDoc(love.class.Floor, love.space.Rooms, id, { name }) + await client.updateDoc(love.class.Floor, core.space.Workspace, id, { name }) } diff --git a/plugins/love-resources/src/utils.ts b/plugins/love-resources/src/utils.ts index eda4e33498..8593048ca5 100644 --- a/plugins/love-resources/src/utils.ts +++ b/plugins/love-resources/src/utils.ts @@ -1,6 +1,6 @@ import { Analytics } from '@hcengineering/analytics' import contact, { getName, type Person, type PersonAccount } from '@hcengineering/contact' -import { concatLink, getCurrentAccount, type IdMap, type Ref, type Space } from '@hcengineering/core' +import core, { concatLink, getCurrentAccount, type IdMap, type Ref, type Space } from '@hcengineering/core' import { getEmbeddedLabel, getMetadata, type IntlString } from '@hcengineering/platform' import presentation, { createQuery, getClient } from '@hcengineering/presentation' import { getCurrentLocation, navigate, type DropdownTextItem } from '@hcengineering/ui' @@ -483,7 +483,7 @@ async function moveToRoom ( room: room._id }) } else { - await client.createDoc(love.class.ParticipantInfo, love.space.Rooms, { + await client.createDoc(love.class.ParticipantInfo, core.space.Workspace, { x, y, room: room._id, @@ -606,7 +606,7 @@ export async function tryConnect ( await client.update(invite, { status: invite.room === room._id ? RequestStatus.Approved : RequestStatus.Rejected }) } if (room.access === RoomAccess.Knock && (!isOffice(room) || room.person !== currentPerson._id)) { - const _id = await client.createDoc(love.class.JoinRequest, love.space.Rooms, { + const _id = await client.createDoc(love.class.JoinRequest, core.space.Workspace, { person: currentPerson._id, room: room._id, status: RequestStatus.Pending @@ -630,7 +630,7 @@ export async function invite (person: Ref, room: Ref | undefined): if (room === undefined || room === love.ids.Reception) return const client = getClient() const me = getCurrentAccount() - await client.createDoc(love.class.Invite, love.space.Rooms, { + await client.createDoc(love.class.Invite, core.space.Workspace, { target: person, room, status: RequestStatus.Pending, diff --git a/plugins/love/src/index.ts b/plugins/love/src/index.ts index cf45cd32f8..8867fd485a 100644 --- a/plugins/love/src/index.ts +++ b/plugins/love/src/index.ts @@ -1,5 +1,5 @@ import { Person } from '@hcengineering/contact' -import { Class, Doc, Ref, Space } from '@hcengineering/core' +import { Class, Doc, Ref } from '@hcengineering/core' import { Drive } from '@hcengineering/drive' import { NotificationType } from '@hcengineering/notification' import { Asset, IntlString, Metadata, Plugin, plugin } from '@hcengineering/platform' @@ -145,7 +145,6 @@ const love = plugin(loveId, { ServiceEnpdoint: '' as Metadata }, space: { - Rooms: '' as Ref, Drive: '' as Ref }, component: { diff --git a/plugins/notification-resources/src/components/NotificationGroupSetting.svelte b/plugins/notification-resources/src/components/NotificationGroupSetting.svelte index 1003ee4877..7d9314e7d3 100644 --- a/plugins/notification-resources/src/components/NotificationGroupSetting.svelte +++ b/plugins/notification-resources/src/components/NotificationGroupSetting.svelte @@ -13,7 +13,7 @@ // limitations under the License. --> - -
-
-
-
- {#if actions.length === 0} -
-
- {/if} - {#each actions as action, i} - - - {/each} -
-
-
-
- - diff --git a/plugins/tracker-resources/src/components/FilterMenuSection.svelte b/plugins/tracker-resources/src/components/FilterMenuSection.svelte deleted file mode 100644 index 266edf01f3..0000000000 --- a/plugins/tracker-resources/src/components/FilterMenuSection.svelte +++ /dev/null @@ -1,137 +0,0 @@ - - - -
-
-
-
- {#if actions.length === 0} -
-
- {/if} - {#each actions as action, i} - - - {/each} -
-
-
-
- - diff --git a/plugins/tracker-resources/src/components/templates/DraftIssueChildEditor.svelte b/plugins/tracker-resources/src/components/templates/DraftIssueChildEditor.svelte index 7128f62cd2..7beb4a0ce6 100644 --- a/plugins/tracker-resources/src/components/templates/DraftIssueChildEditor.svelte +++ b/plugins/tracker-resources/src/components/templates/DraftIssueChildEditor.svelte @@ -14,7 +14,7 @@ -->