From b1f225da0220beb7de5797296eff77162dc70893 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Tue, 11 Apr 2023 22:07:25 +0700 Subject: [PATCH] TSK-1009: Configurable platform Signed-off-by: Andrey Sobolev --- README.md | 23 +- dev/docker-compose.yaml | 1 + dev/prod/src/platform.ts | 6 +- dev/storage/src/storage.ts | 2 +- dev/tool/src/__start.ts | 14 +- dev/tool/src/clean.ts | 4 +- dev/tool/src/configuration.ts | 70 +++ dev/tool/src/index.ts | 14 +- models/activity/src/index.ts | 2 + models/all/package.json | 1 + models/all/src/__genmodel.ts | 2 +- models/all/src/index.ts | 410 +++++++++++++----- models/attachment/src/index.ts | 1 + models/automation/src/index.ts | 9 +- models/bitrix/src/index.ts | 6 +- models/bitrix/src/plugin.ts | 4 +- models/board/src/index.ts | 7 +- models/board/src/plugin.ts | 4 +- models/calendar/src/index.ts | 7 +- models/calendar/src/plugin.ts | 4 +- models/chunter/src/index.ts | 6 +- models/chunter/src/plugin.ts | 4 +- models/contact/src/index.ts | 7 +- models/contact/src/plugin.ts | 6 +- models/core/src/core.ts | 8 +- models/core/src/index.ts | 17 +- models/demo/src/migration.ts | 2 +- models/document/src/index.ts | 13 +- models/document/src/plugin.ts | 6 +- models/gmail/src/index.ts | 6 +- models/gmail/src/plugin.ts | 4 +- models/hr/src/index.ts | 15 +- models/hr/src/plugin.ts | 4 +- models/inventory/src/index.ts | 9 +- models/inventory/src/plugin.ts | 6 +- models/lead/src/index.ts | 7 +- models/lead/src/plugin.ts | 4 +- .../model-rig/profiles/default/tsconfig.json | 3 +- models/notification/src/index.ts | 11 +- models/preference/src/index.ts | 7 +- models/presentation/src/index.ts | 1 + models/recruit/src/index.ts | 17 +- models/recruit/src/plugin.ts | 4 +- models/request/src/index.ts | 11 +- models/server-attachment/src/index.ts | 4 +- models/server-calendar/src/index.ts | 4 +- models/server-chunter/src/index.ts | 1 + models/server-contact/src/index.ts | 7 +- models/server-core/src/index.ts | 2 + models/server-gmail/src/index.ts | 3 +- models/server-hr/src/index.ts | 6 +- models/server-inventory/src/index.ts | 2 + models/server-lead/src/index.ts | 6 +- models/server-notification/src/index.ts | 8 +- models/server-openai/src/index.ts | 2 + models/server-recruit/src/index.ts | 4 +- models/server-request/src/index.ts | 2 + models/server-setting/src/index.ts | 4 +- models/server-tags/src/index.ts | 2 + models/server-task/src/index.ts | 2 + models/server-telegram/src/index.ts | 4 +- models/server-tracker/src/index.ts | 6 +- models/server-translate/src/index.ts | 2 + models/server-view/src/index.ts | 4 +- models/setting/src/index.ts | 25 +- models/setting/src/plugin.ts | 6 +- models/tags/src/index.ts | 2 +- models/task/src/index.ts | 3 +- models/telegram/src/index.ts | 8 +- models/telegram/src/plugin.ts | 4 +- models/templates/src/index.ts | 7 +- models/text-editor/src/index.ts | 1 + models/tracker/src/index.ts | 5 +- models/tracker/src/plugin.ts | 4 +- models/view/src/index.ts | 19 +- models/workbench/src/index.ts | 13 +- packages/core/src/__tests__/client.test.ts | 22 +- packages/core/src/classes.ts | 15 +- packages/core/src/client.ts | 25 +- packages/core/src/component.ts | 7 +- packages/core/src/hierarchy.ts | 11 +- packages/platform/src/resource.ts | 14 +- packages/presentation/src/configuration.ts | 65 +++ packages/presentation/src/index.ts | 1 + packages/presentation/src/utils.ts | 11 +- .../src/components/ActivityFilter.svelte | 6 +- plugins/activity-resources/src/utils.ts | 2 +- plugins/bitrix-assets/lang/en.json | 4 +- plugins/bitrix-assets/lang/ru.json | 4 +- plugins/board-assets/lang/en.json | 4 +- plugins/board-assets/lang/ru.json | 4 +- plugins/calendar-assets/lang/en.json | 4 +- plugins/calendar-assets/lang/ru.json | 4 +- plugins/chunter-assets/lang/en.json | 4 +- plugins/chunter-assets/lang/ru.json | 4 +- plugins/client-resources/src/index.ts | 2 +- plugins/client/src/index.ts | 3 +- plugins/contact-assets/lang/en.json | 4 +- plugins/contact-assets/lang/ru.json | 4 +- .../src/components/EditEmployee.svelte | 4 +- plugins/document-assets/lang/en.json | 5 +- plugins/document-assets/lang/ru.json | 4 +- plugins/gmail-assets/lang/en.json | 4 +- plugins/gmail-assets/lang/ru.json | 4 +- plugins/hr-assets/lang/en.json | 4 +- plugins/hr-assets/lang/ru.json | 4 +- plugins/inventory-assets/lang/en.json | 4 +- plugins/inventory-assets/lang/ru.json | 4 +- plugins/lead-assets/lang/en.json | 4 +- plugins/lead-assets/lang/ru.json | 4 +- .../src/components/CreateWorkspaceForm.svelte | 2 +- plugins/recruit-assets/lang/en.json | 4 +- plugins/recruit-assets/lang/ru.json | 4 +- plugins/setting-assets/lang/en.json | 7 +- plugins/setting-assets/lang/ru.json | 7 +- .../src/components/Configure.svelte | 81 ++++ .../src/components/InviteSetting.svelte | 2 +- .../src/components/Owners.svelte | 44 +- .../src/components/statuses/Folders.svelte | 32 +- plugins/setting-resources/src/index.ts | 4 +- plugins/setting-resources/src/plugin.ts | 7 +- plugins/telegram-assets/lang/en.json | 4 +- plugins/telegram-assets/lang/ru.json | 4 +- plugins/tracker-assets/lang/en.json | 4 +- plugins/tracker-assets/lang/ru.json | 4 +- .../related/RelatedIssuesSection.svelte | 82 ++-- .../src/components/DocNavLink.svelte | 2 +- .../src/components/EditDoc.svelte | 5 +- .../src/components/ViewletSetting.svelte | 10 +- plugins/view-resources/src/utils.ts | 35 +- .../src/components/Workbench.svelte | 59 +-- pods/account/src/__start.ts | 5 +- products/tracker/package.json | 1 + products/tracker/src/platform.ts | 1 + server/account/src/__tests__/account.test.ts | 2 +- server/core/src/index.ts | 2 +- server/core/src/plugin.ts | 3 +- server/translate/src/index.ts | 2 +- tests/docker-compose.yaml | 1 + tests/restore-workspace.sh | 2 + 140 files changed, 1170 insertions(+), 462 deletions(-) create mode 100644 dev/tool/src/configuration.ts create mode 100644 packages/presentation/src/configuration.ts create mode 100644 plugins/setting-resources/src/components/Configure.svelte diff --git a/README.md b/README.md index 3b724092f59..65504ff35ab 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,12 @@ Before we could start we need to create workspace/account and associate it with cd ./tool rushx run-local create-workspace ws1 -o DevWorkspace # Create workspace rushx run-local create-account user1 -p 1234 -f John -l Appleseed # Create account -rushx run-local assign-workspace user1 ws1 # Assign worksapce to user +rushx run-local configure sanity-ws --list --enable '*' # Enable all modules, then if they are not yet intended to be used by wide audience. +rushx run-local assign-workspace user1 ws1 # Assign workspace to user + ``` -Following URL http://localhost:8087/login:component:LoginApp will lead us to app in production mode. +Following URL http://localhost:8087 will lead us to app in production mode. ## Run in development mode @@ -39,7 +41,7 @@ cd dev/prod rushx dev-server ``` -Then go to http://localhost:8080/login:component:LoginApp +Then go to http://localhost:8080 ## Update project structure and database @@ -51,6 +53,7 @@ rush build ``` It also might be required to upgrade running database. + ```bash cd ./dev/tool rushx upgrade @@ -73,22 +76,12 @@ rush bundle rush docker:build ## creates test docker containers and setups test database ./prepare.sh -## runs UI tests +## runs UI tests rushx uitest ``` - ## Package publishing -``` -npm login --registry=https://npm.pkg.github.com --scope=@hcengineering/anticrm -npm publish -``` - - -### Libretranslate - ```bash -pip install libretranslate -libretranslate --ssl --host 0.0.0.0 --port 4500 --load-only en,ru --update-models +node ./common/scripts/bump.js packageName ``` diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index 72423a67ba8..d8abd7c3f72 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -60,6 +60,7 @@ services: - MINIO_SECRET_KEY=minioadmin - FRONT_URL=http://front:8080 - SES_URL=http://localhost:8091 + - MODEL_ENABLED=* restart: unless-stopped collaborator: image: hardcoreeng/collaborator diff --git a/dev/prod/src/platform.ts b/dev/prod/src/platform.ts index 82e6d1c1615..2c504e3a6fb 100644 --- a/dev/prod/src/platform.ts +++ b/dev/prod/src/platform.ts @@ -13,7 +13,7 @@ // limitations under the License. // -import { addLocation } from '@hcengineering/platform' +import { Plugin, addLocation } from '@hcengineering/platform' import { activityId } from '@hcengineering/activity' import { attachmentId } from '@hcengineering/attachment' @@ -21,7 +21,7 @@ import { automationId } from '@hcengineering/automation' import { boardId } from '@hcengineering/board' import { calendarId } from '@hcengineering/calendar' import { chunterId } from '@hcengineering/chunter' -import { clientId } from '@hcengineering/client' +import client, { clientId } from '@hcengineering/client' import { contactId } from '@hcengineering/contact' import document, { documentId } from '@hcengineering/document' import gmail, { gmailId } from '@hcengineering/gmail' @@ -153,6 +153,8 @@ export async function configurePlatform() { addLocation(bitrixId, () => import(/* webpackChunkName: "bitrix" */ '@hcengineering/bitrix-resources')) addLocation(requestId, () => import(/* webpackChunkName: "request" */ '@hcengineering/request-resources')) + setMetadata(client.metadata.FilterModel, true) + setMetadata(client.metadata.ExtraPlugins, ['preference' as Plugin]) setMetadata(workbench.metadata.PlatformTitle, 'Platform') } diff --git a/dev/storage/src/storage.ts b/dev/storage/src/storage.ts index ad2e135c264..36d0fd789c2 100644 --- a/dev/storage/src/storage.ts +++ b/dev/storage/src/storage.ts @@ -65,7 +65,7 @@ class InMemoryTxAdapter extends DummyDbAdapter implements TxAdapter { } async getModel (): Promise { - return builder.getTxes() + return builder().getTxes() } } diff --git a/dev/tool/src/__start.ts b/dev/tool/src/__start.ts index 5db4b1338f3..521ba7fc406 100644 --- a/dev/tool/src/__start.ts +++ b/dev/tool/src/__start.ts @@ -16,29 +16,29 @@ import { prepareTools as prepareToolsRaw } from '@hcengineering/server-tool' import { Data, Tx, Version } from '@hcengineering/core' +import { MinioService } from '@hcengineering/minio' import { MigrateOperation } from '@hcengineering/model' import builder, { migrateOperations, version } from '@hcengineering/model-all' -import { MinioService } from '@hcengineering/minio' import { devTool } from '.' +import { addLocation } from '@hcengineering/platform' import { serverAttachmentId } from '@hcengineering/server-attachment' import { serverCalendarId } from '@hcengineering/server-calendar' import { serverChunterId } from '@hcengineering/server-chunter' import { serverContactId } from '@hcengineering/server-contact' import { serverGmailId } from '@hcengineering/server-gmail' +import { serverHrId } from '@hcengineering/server-hr' import { serverInventoryId } from '@hcengineering/server-inventory' import { serverLeadId } from '@hcengineering/server-lead' import { serverNotificationId } from '@hcengineering/server-notification' import { serverRecruitId } from '@hcengineering/server-recruit' +import { serverRequestId } from '@hcengineering/server-request' import { serverSettingId } from '@hcengineering/server-setting' import { serverTagsId } from '@hcengineering/server-tags' import { serverTaskId } from '@hcengineering/server-task' -import { serverTrackerId } from '@hcengineering/server-tracker' import { serverTelegramId } from '@hcengineering/server-telegram' -import { serverHrId } from '@hcengineering/server-hr' -import { serverRequestId } from '@hcengineering/server-request' +import { serverTrackerId } from '@hcengineering/server-tracker' import { serverViewId } from '@hcengineering/server-view' -import { addLocation } from '@hcengineering/platform' addLocation(serverAttachmentId, () => import('@hcengineering/server-attachment-resources')) addLocation(serverContactId, () => import('@hcengineering/server-contact-resources')) @@ -65,7 +65,9 @@ function prepareTools (): { version: Data migrateOperations: [string, MigrateOperation][] } { - return { ...prepareToolsRaw(builder.getTxes()), version, migrateOperations } + const enabled = (process.env.MODEL_ENABLED ?? '*').split(',').map((it) => it.trim()) + const disabled = (process.env.MODEL_DISABLED ?? '').split(',').map((it) => it.trim()) + return { ...prepareToolsRaw(builder(enabled, disabled).getTxes()), version, migrateOperations } } devTool(prepareTools, '') diff --git a/dev/tool/src/clean.ts b/dev/tool/src/clean.ts index b28c1e3e809..29ddfb8e201 100644 --- a/dev/tool/src/clean.ts +++ b/dev/tool/src/clean.ts @@ -29,7 +29,7 @@ export async function cleanWorkspace ( minio: MinioService, elasticUrl: string, transactorUrl: string, - opt: { recruit: boolean, tracker: boolean, removeTx: boolean } + opt: { recruit: boolean, tracker: boolean, removedTx: boolean } ): Promise { const connection = (await connect(transactorUrl, workspaceId, undefined, { mode: 'backup', @@ -106,7 +106,7 @@ export async function cleanWorkspace ( await client.connect() const db = getWorkspaceDB(client, workspaceId) - if (opt.removeTx) { + if (opt.removedTx) { const txes = await db.collection(DOMAIN_TX).find({}).toArray() for (const tx of txes) { diff --git a/dev/tool/src/configuration.ts b/dev/tool/src/configuration.ts new file mode 100644 index 00000000000..78035756aab --- /dev/null +++ b/dev/tool/src/configuration.ts @@ -0,0 +1,70 @@ +// +// Copyright © 2023 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import core, { BackupClient, Client as CoreClient, TxFactory, WorkspaceId } from '@hcengineering/core' +import { connect } from '@hcengineering/server-tool' + +function toLen (val: string, sep: string, len: number): string { + while (val.length < len) { + val += sep + } + return val +} +export async function changeConfiguration ( + workspaceId: WorkspaceId, + transactorUrl: string, + cmd: { enable?: string, disable?: string, list?: boolean } +): Promise { + const connection = (await connect(transactorUrl, workspaceId, undefined, { + mode: 'backup' + })) as unknown as CoreClient & BackupClient + try { + const config = await connection.findAll(core.class.PluginConfiguration, {}) + if (cmd.list ?? true) { + for (const c of config) { + if (c.label !== undefined) { + console.log(toLen(c.pluginId, '-', 20), c.enabled) + } + } + } + const enable = (cmd.enable ?? '').trim().split(',') + console.log('enable', enable) + const ops = new TxFactory(core.account.ConfigUser) + if (enable.length > 0) { + const p = config.filter((it) => enable.includes(it.pluginId) || enable.includes('*')) + for (const pp of p) { + if (!pp.enabled) { + console.log('Enabling', pp.pluginId) + await connection.tx( + ops.createTxUpdateDoc(core.class.PluginConfiguration, core.space.Model, pp._id, { enabled: true }) + ) + } + } + } + + if ((cmd.disable ?? '').trim() !== '') { + const p = config.find((it) => it.pluginId === (cmd.disable ?? '').trim()) + if (p !== undefined) { + await connection.tx( + ops.createTxUpdateDoc(core.class.PluginConfiguration, core.space.Model, p._id, { enabled: false }) + ) + } + } + } catch (err: any) { + console.trace(err) + } finally { + await connection.close() + } +} diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index 0970fdc4645..6e5a48ee27d 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -52,6 +52,7 @@ import { openAIConfigDefaults } from '@hcengineering/openai' import { cleanArchivedSpaces, cleanRemovedTransactions, cleanWorkspace } from './clean' import { rebuildElastic } from './elastic' import { openAIConfig } from './openai' +import { changeConfiguration } from './configuration' /** * @public @@ -442,7 +443,7 @@ export function devTool ( .option('--recruit', 'Clean recruit', false) .option('--tracker', 'Clean tracker', false) .option('--removedTx', 'Clean removed transactions', false) - .action(async (workspace: string, cmd: { recruit: boolean, tracker: boolean, removeTx: boolean }) => { + .action(async (workspace: string, cmd: { recruit: boolean, tracker: boolean, removedTx: boolean }) => { const { mongodbUri, minio } = prepareTools() return await withDatabase(mongodbUri, async (db) => { await cleanWorkspace( @@ -470,5 +471,16 @@ export function devTool ( await cleanArchivedSpaces(getWorkspaceId(workspace, productId), transactorUrl) }) + program + .command('configure ') + .description('clean archived spaces') + .option('--enable ', 'Enable plugin configuration', '') + .option('--disable ', 'Disable plugin configuration', '') + .option('--list', 'List plugin states', true) + .action(async (workspace: string, cmd: { enable: string, disable: string, list: boolean }) => { + console.log(JSON.stringify(cmd)) + await changeConfiguration(getWorkspaceId(workspace, productId), transactorUrl, cmd) + }) + program.parse(process.argv) } diff --git a/models/activity/src/index.ts b/models/activity/src/index.ts index 02e43a406df..eb1a6ce6445 100644 --- a/models/activity/src/index.ts +++ b/models/activity/src/index.ts @@ -21,6 +21,8 @@ import { TClass, TDoc } from '@hcengineering/model-core' import type { Asset, IntlString, Resource } from '@hcengineering/platform' import { AnyComponent } from '@hcengineering/ui' +export { activityId } from '@hcengineering/activity' + @Model(activity.class.TxViewlet, core.class.Doc, DOMAIN_MODEL) export class TTxViewlet extends TDoc implements TxViewlet { icon!: Asset diff --git a/models/all/package.json b/models/all/package.json index b465a319d70..3b02ed533f1 100644 --- a/models/all/package.json +++ b/models/all/package.json @@ -64,6 +64,7 @@ "@hcengineering/model-notification": "^0.6.0", "@hcengineering/model-text-editor": "^0.6.0", "@hcengineering/core": "^0.6.23", + "@hcengineering/platform": "^0.6.8", "@hcengineering/model-tags": "^0.6.0", "@hcengineering/model-calendar": "^0.6.0", "@hcengineering/model-server-calendar": "^0.6.0", diff --git a/models/all/src/__genmodel.ts b/models/all/src/__genmodel.ts index d519a129636..7f621e45fc6 100644 --- a/models/all/src/__genmodel.ts +++ b/models/all/src/__genmodel.ts @@ -16,7 +16,7 @@ import builder from '.' // import { writeFileSync } from 'fs' -const content = JSON.stringify(builder.getTxes(), undefined, 2) +const content = JSON.stringify(builder().getTxes(), undefined, 2) console.log(content) // writeFileSync('../../dev/storage/src/model.tx.json', content) // writeFileSync('../../server/workspace/src/model.tx.json', content) diff --git a/models/all/src/index.ts b/models/all/src/index.ts index 84dac2451ab..1429e5157df 100644 --- a/models/all/src/index.ts +++ b/models/all/src/index.ts @@ -17,132 +17,310 @@ import core, { coreId, Data, PluginConfiguration, Ref, Tx, Version } from '@hcen import jsonVersion from './version.json' import { Builder } from '@hcengineering/model' -import { createModel as activityModel } from '@hcengineering/model-activity' -import { createModel as attachmentModel } from '@hcengineering/model-attachment' -import { createModel as automationModel } from '@hcengineering/model-automation' -import { createModel as chunterModel } from '@hcengineering/model-chunter' -import { createModel as contactModel } from '@hcengineering/model-contact' +import { activityId, createModel as activityModel } from '@hcengineering/model-activity' +import { attachmentId, createModel as attachmentModel } from '@hcengineering/model-attachment' +import { automationId, createModel as automationModel } from '@hcengineering/model-automation' +import bitrix, { bitrixId, createModel as bitrixModel } from '@hcengineering/model-bitrix' +import board, { boardId, createModel as boardModel } from '@hcengineering/model-board' +import calendar, { calendarId, createModel as calendarModel } from '@hcengineering/model-calendar' +import chunter, { chunterId, createModel as chunterModel } from '@hcengineering/model-chunter' +import contact, { contactId, createModel as contactModel } from '@hcengineering/model-contact' import { createModel as coreModel } from '@hcengineering/model-core' -import { createModel as gmailModel } from '@hcengineering/model-gmail' -import { createModel as inventoryModel } from '@hcengineering/model-inventory' -import { createModel as leadModel } from '@hcengineering/model-lead' -import { createModel as presentationModel } from '@hcengineering/model-presentation' -import { createModel as recruitModel } from '@hcengineering/model-recruit' -import { createModel as serverAttachmentModel } from '@hcengineering/model-server-attachment' -import { createModel as serverContactModel } from '@hcengineering/model-server-contact' -import { createModel as serverNotificationModel } from '@hcengineering/model-server-notification' -import { createModel as serverChunterModel } from '@hcengineering/model-server-chunter' -import { createModel as serverInventoryModel } from '@hcengineering/model-server-inventory' -import { createModel as serverLeadModel } from '@hcengineering/model-server-lead' -import { createModel as serverTaskModel } from '@hcengineering/model-server-task' -import { createModel as serverTrackerModel } from '@hcengineering/model-server-tracker' -import { createModel as serverTagsModel } from '@hcengineering/model-server-tags' -import { createModel as serveSettingModel } from '@hcengineering/model-server-setting' -import { createModel as serverRecruitModel } from '@hcengineering/model-server-recruit' -import { createModel as serverCoreModel } from '@hcengineering/model-server-core' -import { createModel as settingModel } from '@hcengineering/model-setting' -import { createModel as taskModel } from '@hcengineering/model-task' -import { createModel as telegramModel } from '@hcengineering/model-telegram' -import { createModel as templatesModel } from '@hcengineering/model-templates' -import { createModel as textEditorModel } from '@hcengineering/model-text-editor' -import { createModel as viewModel } from '@hcengineering/model-view' -import { createModel as workbenchModel } from '@hcengineering/model-workbench' -import { createModel as notificationModel } from '@hcengineering/model-notification' -import { createModel as tagsModel } from '@hcengineering/model-tags' -import { createModel as calendarModel } from '@hcengineering/model-calendar' -import { createModel as serverCalendarModel } from '@hcengineering/model-server-calendar' -import { createModel as serverGmailModel } from '@hcengineering/model-server-gmail' -import { createModel as serverTelegramModel } from '@hcengineering/model-server-telegram' -import { createModel as trackerModel } from '@hcengineering/model-tracker' -import { createModel as boardModel } from '@hcengineering/model-board' -import { createModel as preferenceModel } from '@hcengineering/model-preference' -import { createModel as hrModel } from '@hcengineering/model-hr' -import { createModel as serverHrModel } from '@hcengineering/model-server-hr' -import { createModel as documentModel } from '@hcengineering/model-document' -import { createModel as bitrixModel } from '@hcengineering/model-bitrix' -import { createModel as requestModel } from '@hcengineering/model-request' -import { createModel as serverRequestModel } from '@hcengineering/model-server-request' -import { createModel as serverViewModel } from '@hcengineering/model-server-view' +import document, { documentId, createModel as documentModel } from '@hcengineering/model-document' +import gmail, { gmailId, createModel as gmailModel } from '@hcengineering/model-gmail' +import hr, { hrId, createModel as hrModel } from '@hcengineering/model-hr' +import inventory, { inventoryId, createModel as inventoryModel } from '@hcengineering/model-inventory' +import lead, { leadId, createModel as leadModel } from '@hcengineering/model-lead' +import { notificationId, createModel as notificationModel } from '@hcengineering/model-notification' +import { preferenceId, createModel as preferenceModel } from '@hcengineering/model-preference' +import { presentationId, createModel as presentationModel } from '@hcengineering/model-presentation' +import recruit, { recruitId, createModel as recruitModel } from '@hcengineering/model-recruit' +import { requestId, createModel as requestModel } from '@hcengineering/model-request' +import { serverAttachmentId, createModel as serverAttachmentModel } from '@hcengineering/model-server-attachment' +import { serverCalendarId, createModel as serverCalendarModel } from '@hcengineering/model-server-calendar' +import { serverChunterId, createModel as serverChunterModel } from '@hcengineering/model-server-chunter' +import { serverContactId, createModel as serverContactModel } from '@hcengineering/model-server-contact' +import { serverCoreId, createModel as serverCoreModel } from '@hcengineering/model-server-core' +import { serverGmailId, createModel as serverGmailModel } from '@hcengineering/model-server-gmail' +import { serverHrId, createModel as serverHrModel } from '@hcengineering/model-server-hr' +import { serverInventoryId, createModel as serverInventoryModel } from '@hcengineering/model-server-inventory' +import { serverLeadId, createModel as serverLeadModel } from '@hcengineering/model-server-lead' +import { serverNotificationId, createModel as serverNotificationModel } from '@hcengineering/model-server-notification' +import { serverRecruitId, createModel as serverRecruitModel } from '@hcengineering/model-server-recruit' +import { serverRequestId, createModel as serverRequestModel } from '@hcengineering/model-server-request' +import { serverSettingId, createModel as serveSettingModel } from '@hcengineering/model-server-setting' +import { serverTagsId, createModel as serverTagsModel } from '@hcengineering/model-server-tags' +import { serverTaskId, createModel as serverTaskModel } from '@hcengineering/model-server-task' +import { serverTelegramId, createModel as serverTelegramModel } from '@hcengineering/model-server-telegram' +import { serverTrackerId, createModel as serverTrackerModel } from '@hcengineering/model-server-tracker' +import { serverViewId, createModel as serverViewModel } from '@hcengineering/model-server-view' +import setting, { settingId, createModel as settingModel } from '@hcengineering/model-setting' +import { tagsId, createModel as tagsModel } from '@hcengineering/model-tags' +import { taskId, createModel as taskModel } from '@hcengineering/model-task' +import telegram, { telegramId, createModel as telegramModel } from '@hcengineering/model-telegram' +import { templatesId, createModel as templatesModel } from '@hcengineering/model-templates' +import { textEditorId, createModel as textEditorModel } from '@hcengineering/model-text-editor' +import tracker, { trackerId, createModel as trackerModel } from '@hcengineering/model-tracker' +import view, { viewId, createModel as viewModel } from '@hcengineering/model-view' +import workbench, { workbenchId, createModel as workbenchModel } from '@hcengineering/model-workbench' -import { createModel as serverTranslate } from '@hcengineering/model-server-translate' -import { createModel as serverOpenAI } from '@hcengineering/model-server-openai' +import { openAIId, createModel as serverOpenAI } from '@hcengineering/model-server-openai' +import { createModel as serverTranslate, translateId } from '@hcengineering/model-server-translate' + +import { Plugin } from '@hcengineering/platform' export const version: Data = jsonVersion as Data -const builder = new Builder() +interface ConfigurablePlugin extends Omit, 'pluginId' | 'transactions'> {} + +type BuilderConfig = [(b: Builder) => void, Plugin] | [(b: Builder) => void, Plugin, ConfigurablePlugin | undefined] + +/** + * @public + * @param enabled - a set of enabled plugins + * @param disabled - a set of disabled plugins + * @returns + */ +export default function buildModel (enabled: string[] = ['*'], disabled: string[] = []): Builder { + const builder = new Builder() -const builders: [(b: Builder) => void, string][] = [ - [coreModel, coreId], - [activityModel, 'activity'], - [attachmentModel, 'attachment'], - [tagsModel, 'tags'], - [viewModel, 'view'], - [workbenchModel, 'workbench'], - [contactModel, 'contact'], - [chunterModel, 'chunter'], - [taskModel, 'task'], - [recruitModel, 'recruit'], - [settingModel, 'setting'], - [telegramModel, 'telegram'], - [leadModel, 'lead'], - [gmailModel, 'gmail'], - [inventoryModel, 'inventory'], - [presentationModel, 'presentation'], - [templatesModel, 'templates'], - [textEditorModel, 'text-editor'], - [notificationModel, 'notification'], - [preferenceModel, 'preference'], - [hrModel, 'hr'], - [documentModel, 'document'], - [trackerModel, 'tracker'], - [boardModel, 'board'], - [calendarModel, 'calendar'], - [bitrixModel, 'bitrix'], - [requestModel, 'request'], + const builders: BuilderConfig[] = [ + [coreModel, coreId], + [activityModel, activityId], + [attachmentModel, attachmentId], + [tagsModel, tagsId], + [viewModel, viewId], + [workbenchModel, workbenchId], + [ + contactModel, + contactId, + { + label: contact.string.ConfigLabel, + description: contact.string.ConfigDescription, + enabled: true, + configurable: false, + icon: contact.icon.ContactApplication, + classFilter: [workbench.class.Application] + } + ], + [ + chunterModel, + chunterId, + { + label: chunter.string.ConfigLabel, + description: chunter.string.ConfigDescription, + enabled: false, + configurable: false, + icon: chunter.icon.Chunter, + classFilter: [workbench.class.Application] + } + ], + [taskModel, taskId], + [ + recruitModel, + recruitId, + { + label: recruit.string.ConfigLabel, + description: recruit.string.ConfigDescription, + enabled: true, + icon: recruit.icon.RecruitApplication, + classFilter: [workbench.class.Application, view.class.Action], + configurable: true + } + ], + [settingModel, settingId], + [ + telegramModel, + telegramId, + { + label: telegram.string.ConfigLabel, + description: telegram.string.ConfigDescription, + enabled: true, + classFilter: [ + workbench.class.Application, + view.class.Action, + contact.class.ChannelProvider, + setting.class.IntegrationType + ], + configurable: true + } + ], + [ + leadModel, + leadId, + { + label: lead.string.ConfigLabel, + description: lead.string.ConfigDescription, + enabled: true, + icon: lead.icon.LeadApplication, + configurable: false + } + ], + [ + gmailModel, + gmailId, + { + label: gmail.string.ConfigLabel, + description: gmail.string.ConfigDescription, + enabled: true, + classFilter: [ + workbench.class.Application, + view.class.Action, + contact.class.ChannelProvider, + setting.class.IntegrationType + ], + configurable: true + } + ], + [ + inventoryModel, + inventoryId, + { + label: inventory.string.ConfigLabel, + description: inventory.string.ConfigDescription, + enabled: true, + icon: inventory.icon.InventoryApplication, + classFilter: [workbench.class.Application, view.class.Action], + configurable: false + } + ], + [presentationModel, presentationId], + [templatesModel, templatesId], + [textEditorModel, textEditorId], + [notificationModel, notificationId], + [preferenceModel, preferenceId], + [ + hrModel, + hrId, + { + label: hr.string.ConfigLabel, + description: hr.string.ConfigDescription, + enabled: true, + icon: hr.icon.Structure, + classFilter: [workbench.class.Application, view.class.Action], + configurable: true + } + ], + [ + documentModel, + documentId, + { + label: document.string.ConfigLabel, + description: document.string.ConfigDescription, + enabled: true, + icon: document.icon.DocumentApplication, + configurable: false + } + ], + [ + trackerModel, + trackerId, + { + label: tracker.string.ConfigLabel, + description: tracker.string.ConfigDescription, + enabled: true, + icon: tracker.icon.TrackerApplication, + classFilter: [workbench.class.Application, view.class.Action], + configurable: true + } + ], + [ + boardModel, + boardId, + { + label: board.string.ConfigLabel, + description: board.string.ConfigDescription, + enabled: true, + icon: board.icon.Board, + classFilter: [workbench.class.Application, view.class.Action], + configurable: false + } + ], + [ + calendarModel, + calendarId, + { + label: calendar.string.ConfigLabel, + description: calendar.string.ConfigDescription, + enabled: true, + icon: calendar.icon.Calendar, + classFilter: [workbench.class.Application], + configurable: false + } + ], + [ + bitrixModel, + bitrixId, + { + label: bitrix.string.ConfigLabel, + description: bitrix.string.ConfigDescription, + enabled: false, + icon: bitrix.icon.Bitrix, + configurable: false + } + ], + [ + requestModel, + requestId, + { + // label: request.string.ConfigLabel, + // description: request.string.ConfigDescription, + enabled: false, + configurable: false, + classFilter: [workbench.class.Application, view.class.Action] + } + ], + [automationModel, automationId], - [serverCoreModel, 'server-core'], - [serverAttachmentModel, 'server-attachment'], - [serverContactModel, 'server-contact'], - [serveSettingModel, 'server-setting'], - [serverChunterModel, 'server-chunter'], - [serverInventoryModel, 'server-inventory'], - [serverLeadModel, 'server-lead'], - [serverTagsModel, 'server-tags'], - [serverTaskModel, 'server-task'], - [serverTrackerModel, 'server-tracker'], - [serverRecruitModel, 'server-recruit'], - [serverCalendarModel, 'server-calendar'], - [serverGmailModel, 'server-gmail'], - [serverTelegramModel, 'server-telegram'], - [serverHrModel, 'server-hr'], - [serverNotificationModel, 'server-notification'], - [serverRequestModel, 'server-request'], - [serverViewModel, 'server-view'], - [automationModel, 'automation'], - [serverTranslate, 'translate'], - [serverOpenAI, 'openai'] -] + [serverCoreModel, serverCoreId], + [serverAttachmentModel, serverAttachmentId], + [serverContactModel, serverContactId], + [serveSettingModel, serverSettingId], + [serverChunterModel, serverChunterId], + [serverInventoryModel, serverInventoryId], + [serverLeadModel, serverLeadId], + [serverTagsModel, serverTagsId], + [serverTaskModel, serverTaskId], + [serverTrackerModel, serverTrackerId], + [serverRecruitModel, serverRecruitId], + [serverCalendarModel, serverCalendarId], + [serverGmailModel, serverGmailId], + [serverTelegramModel, serverTelegramId], + [serverHrModel, serverHrId], + [serverNotificationModel, serverNotificationId], + [serverRequestModel, serverRequestId], + [serverViewModel, serverViewId], -for (const [b, id] of builders) { - const txes: Tx[] = [] - builder.onTx = (tx) => { - txes.push(tx) + [serverTranslate, translateId], + [serverOpenAI, openAIId] + ] + + for (const [b, id, config] of builders) { + const txes: Tx[] = [] + builder.onTx = (tx) => { + txes.push(tx) + } + b(builder) + builder.createDoc( + core.class.PluginConfiguration, + core.space.Model, + { + pluginId: id, + transactions: txes.map((it) => it._id), + ...config, + enabled: + config?.label === undefined || + ((config?.enabled ?? true) && (enabled.includes(id) || enabled.includes('*')) && !disabled.includes(id)), + configurable: config?.configurable ?? false + }, + ('plugin-configuration-' + id) as Ref + ) + builder.onTx = undefined } - b(builder) - builder.createDoc( - core.class.PluginConfiguration, - core.space.Model, - { - pluginId: id, - transactions: txes.map((it) => it._id) - }, - ('plugin-configuration-' + id) as Ref - ) - builder.onTx = undefined -} -builder.createDoc(core.class.Version, core.space.Model, version, core.version.Model) -export default builder + builder.createDoc(core.class.Version, core.space.Model, version, core.version.Model) + return builder +} // Export upgrade procedures export { migrateOperations } from './migration' diff --git a/models/attachment/src/index.ts b/models/attachment/src/index.ts index 7c57d4b8d8f..a46f2443994 100644 --- a/models/attachment/src/index.ts +++ b/models/attachment/src/index.ts @@ -33,6 +33,7 @@ import preference, { TPreference } from '@hcengineering/model-preference' import view, { createAction } from '@hcengineering/model-view' import attachment from './plugin' +export { attachmentId } from '@hcengineering/attachment' export { attachmentOperation } from './migration' export const DOMAIN_ATTACHMENT = 'attachment' as Domain diff --git a/models/automation/src/index.ts b/models/automation/src/index.ts index 2c4d851e509..7be366e9377 100644 --- a/models/automation/src/index.ts +++ b/models/automation/src/index.ts @@ -15,10 +15,10 @@ // To help typescript locate view plugin properly import automation, { - Automation, - AutomationSupport, AttributeAutomationSupport, + Automation, AutomationSortSupport, + AutomationSupport, AutomationTriggerSupport, Command, TriggerType @@ -28,6 +28,9 @@ import { Builder, Mixin, Model, Prop, TypeString, UX } from '@hcengineering/mode import core, { TAttachedDoc, TClass } from '@hcengineering/model-core' import view from '@hcengineering/view' +export { automationId } from '@hcengineering/automation' +export { automationOperation } from './migration' + export const DOMAIN_AUTOMATION = 'automation' as Domain @Model(automation.class.Automation, core.class.AttachedDoc, DOMAIN_AUTOMATION) @@ -90,5 +93,3 @@ export function createModel (builder: Builder): void { actions: [view.action.Delete] }) } - -export { automationOperation } from './migration' diff --git a/models/bitrix/src/index.ts b/models/bitrix/src/index.ts index d3c1dc73b3a..303f94678a0 100644 --- a/models/bitrix/src/index.ts +++ b/models/bitrix/src/index.ts @@ -26,6 +26,10 @@ import view, { createAction } from '@hcengineering/model-view' import { getEmbeddedLabel } from '@hcengineering/platform' import setting from '@hcengineering/setting' +export { bitrixId } from '@hcengineering/bitrix' +export { bitrixOperation } from './migration' +export { default } from './plugin' + const DOMAIN_BITRIX = 'bitrix' as Domain @Mixin(bitrix.mixin.BitrixSyncDoc, core.class.Doc) @@ -103,5 +107,3 @@ export function createModel (builder: Builder): void { bitrix.action.BitrixImport ) } - -export { bitrixOperation } from './migration' diff --git a/models/bitrix/src/plugin.ts b/models/bitrix/src/plugin.ts index 7e215d21cd2..eae3a863f37 100644 --- a/models/bitrix/src/plugin.ts +++ b/models/bitrix/src/plugin.ts @@ -29,7 +29,9 @@ export default mergeIds(bitrixId, bitrix, { BitrixImport: '' as AnyComponent }, string: { - BitrixImport: '' as IntlString + BitrixImport: '' as IntlString, + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, action: { BitrixImport: '' as Ref diff --git a/models/board/src/index.ts b/models/board/src/index.ts index 80b666caaee..f87c6e19aa1 100644 --- a/models/board/src/index.ts +++ b/models/board/src/index.ts @@ -44,6 +44,10 @@ import { IntlString } from '@hcengineering/platform' import type { AnyComponent } from '@hcengineering/ui' import board from './plugin' +export { boardId } from '@hcengineering/board' +export { boardOperation } from './migration' +export { default } from './plugin' + @Model(board.class.Board, task.class.SpaceWithStates) @UX(board.string.Board, board.icon.Board) export class TBoard extends TSpaceWithStates implements Board { @@ -542,6 +546,3 @@ export function createModel (builder: Builder): void { } }) } - -export { boardOperation } from './migration' -export { default } from './plugin' diff --git a/models/board/src/plugin.ts b/models/board/src/plugin.ts index 650af33cb9f..9a78e09e696 100644 --- a/models/board/src/plugin.ts +++ b/models/board/src/plugin.ts @@ -58,7 +58,9 @@ export default mergeIds(boardId, board, { }, string: { CommonBoardPreference: '' as IntlString, - ConvertToCard: '' as IntlString + ConvertToCard: '' as IntlString, + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, action: { ConvertToCard: '' as Ref diff --git a/models/calendar/src/index.ts b/models/calendar/src/index.ts index c142fc72a8b..2fe70ecffcd 100644 --- a/models/calendar/src/index.ts +++ b/models/calendar/src/index.ts @@ -14,9 +14,9 @@ // import activity from '@hcengineering/activity' -import { calendarId, Calendar, Event, Reminder } from '@hcengineering/calendar' +import { Calendar, Event, Reminder, calendarId } from '@hcengineering/calendar' import { Employee } from '@hcengineering/contact' -import { DateRangeMode, Domain, Markup, Ref, Timestamp, IndexKind } from '@hcengineering/core' +import { DateRangeMode, Domain, IndexKind, Markup, Ref, Timestamp } from '@hcengineering/core' import { ArrOf, Builder, @@ -43,6 +43,8 @@ import notification from '@hcengineering/notification' import calendar from './plugin' export * from '@hcengineering/calendar' +export { calendarId } from '@hcengineering/calendar' +export { calendarOperation } from './migration' export const DOMAIN_CALENDAR = 'calendar' as Domain @@ -200,5 +202,4 @@ export function createModel (builder: Builder): void { }) } -export { calendarOperation } from './migration' export default calendar diff --git a/models/calendar/src/plugin.ts b/models/calendar/src/plugin.ts index 2df168db28e..d04fd02fd16 100644 --- a/models/calendar/src/plugin.ts +++ b/models/calendar/src/plugin.ts @@ -45,7 +45,9 @@ export default mergeIds(calendarId, calendar, { Reminder: '' as IntlString, Shift: '' as IntlString, State: '' as IntlString, - CreatedReminder: '' as IntlString + CreatedReminder: '' as IntlString, + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, viewlet: { Calendar: '' as Ref, diff --git a/models/chunter/src/index.ts b/models/chunter/src/index.ts index 6ecccaea788..c0288a9c1f6 100644 --- a/models/chunter/src/index.ts +++ b/models/chunter/src/index.ts @@ -48,9 +48,11 @@ import attachment from '@hcengineering/model-attachment' import core, { TAttachedDoc, TSpace } from '@hcengineering/model-core' import notification from '@hcengineering/model-notification' import preference, { TPreference } from '@hcengineering/model-preference' -import view, { actionTemplates as viewTemplates, createAction } from '@hcengineering/model-view' +import view, { createAction, actionTemplates as viewTemplates } from '@hcengineering/model-view' import workbench from '@hcengineering/model-workbench' import chunter from './plugin' +export { chunterId } from '@hcengineering/chunter' +export { chunterOperation } from './migration' export const DOMAIN_CHUNTER = 'chunter' as Domain export const DOMAIN_COMMENT = 'comment' as Domain @@ -653,6 +655,4 @@ export function createModel (builder: Builder, options = { addApplication: true }) } -export { chunterOperation } from './migration' - export default chunter diff --git a/models/chunter/src/plugin.ts b/models/chunter/src/plugin.ts index c5991777ba2..940b3b72b82 100644 --- a/models/chunter/src/plugin.ts +++ b/models/chunter/src/plugin.ts @@ -74,7 +74,9 @@ export default mergeIds(chunterId, chunter, { Reactions: '' as IntlString, Emoji: '' as IntlString, FilterComments: '' as IntlString, - FilterBacklinks: '' as IntlString + FilterBacklinks: '' as IntlString, + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, viewlet: { Chat: '' as Ref diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index b7f28582f3d..0724db51139 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -60,6 +60,10 @@ import templates from '@hcengineering/templates' import { AnyComponent } from '@hcengineering/ui' import contact from './plugin' +export { contactId } from '@hcengineering/contact' +export { contactOperation } from './migration' +export { contact as default } + export const DOMAIN_CONTACT = 'contact' as Domain export const DOMAIN_CHANNEL = 'channel' as Domain @@ -767,6 +771,3 @@ export function createModel (builder: Builder): void { component: contact.component.ActivityChannelMessage }) } - -export { contactOperation } from './migration' -export { contact as default } diff --git a/models/contact/src/plugin.ts b/models/contact/src/plugin.ts index cd2cec0f7a7..ff424b5bd9f 100644 --- a/models/contact/src/plugin.ts +++ b/models/contact/src/plugin.ts @@ -82,7 +82,11 @@ export default mergeIds(contactId, contact, { WhatsappPlaceholder: '' as IntlString, Profile: '' as IntlString, ProfilePlaceholder: '' as IntlString, - CurrentEmployee: '' as IntlString + + CurrentEmployee: '' as IntlString, + + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, completion: { PersonQuery: '' as Resource, diff --git a/models/core/src/core.ts b/models/core/src/core.ts index 60a21d583fc..58be744dc52 100644 --- a/models/core/src/core.ts +++ b/models/core/src/core.ts @@ -65,7 +65,7 @@ import { TypeTimestamp, UX } from '@hcengineering/model' -import { getEmbeddedLabel, IntlString } from '@hcengineering/platform' +import { getEmbeddedLabel, IntlString, Plugin } from '@hcengineering/platform' import core from './component' // C O R E @@ -237,8 +237,12 @@ export class TVersion extends TDoc implements Version { @Model(core.class.PluginConfiguration, core.class.Doc, DOMAIN_MODEL) export class TPluginConfiguration extends TDoc implements PluginConfiguration { - pluginId!: string + pluginId!: Plugin transactions!: Ref[] + + label!: IntlString + enabled!: boolean + configurable!: boolean } @Model(core.class.BlobData, core.class.Doc, DOMAIN_BLOB) diff --git a/models/core/src/index.ts b/models/core/src/index.ts index 74e91439d4b..2a4addee598 100644 --- a/models/core/src/index.ts +++ b/models/core/src/index.ts @@ -15,13 +15,13 @@ import { AccountRole, - TxCollectionCUD, - Doc, AttachedDoc, - IndexingConfiguration, Class, - systemAccountEmail, - DocIndexState + Doc, + DocIndexState, + IndexingConfiguration, + TxCollectionCUD, + systemAccountEmail } from '@hcengineering/core' import { Builder } from '@hcengineering/model' import core from './component' @@ -38,8 +38,8 @@ import { TDocIndexState, TEnum, TEnumOf, - TFulltextData, TFullTextSearchContext, + TFulltextData, TIndexConfiguration, TIndexStageState, TInterface, @@ -63,13 +63,14 @@ import { import { TAccount, TSpace } from './security' import { TStatus, TStatusCategory } from './status' import { TUserStatus } from './transient' -import { TTx, TTxApplyIf, TTxCollectionCUD, TTxCreateDoc, TTxCUD, TTxMixin, TTxRemoveDoc, TTxUpdateDoc } from './tx' +import { TTx, TTxApplyIf, TTxCUD, TTxCollectionCUD, TTxCreateDoc, TTxMixin, TTxRemoveDoc, TTxUpdateDoc } from './tx' +export { coreId } from '@hcengineering/core' export * from './core' export { coreOperation } from './migration' export * from './security' -export * from './tx' export * from './status' +export * from './tx' export { core as default } export function createModel (builder: Builder): void { diff --git a/models/demo/src/migration.ts b/models/demo/src/migration.ts index c778aaf78ee..527fa0b26c3 100644 --- a/models/demo/src/migration.ts +++ b/models/demo/src/migration.ts @@ -82,7 +82,7 @@ export const demoOperation: MigrateOperation = { email: 'rosamund@hc.engineering', employee, name: 'Chen,Rosamund', - role: AccountRole.Owner + role: AccountRole.User }) } diff --git a/models/document/src/index.ts b/models/document/src/index.ts index 95aae9e2b52..045fb2a312f 100644 --- a/models/document/src/index.ts +++ b/models/document/src/index.ts @@ -19,11 +19,11 @@ import { IndexKind } from '@hcengineering/core' import { CollaboratorDocument, Document, - documentId, DocumentRequest, DocumentRequestKind, DocumentVersion, - DocumentVersionState + DocumentVersionState, + documentId } from '@hcengineering/document' import { ArrOf, @@ -45,10 +45,14 @@ import core, { TAttachedDoc, TDoc } from '@hcengineering/model-core' import presentation from '@hcengineering/model-presentation' import view, { actionTemplates, createAction } from '@hcengineering/model-view' import workbench from '@hcengineering/model-workbench' -import tags from '@hcengineering/tags' import notification from '@hcengineering/notification' +import tags from '@hcengineering/tags' import document from './plugin' +export { documentId } from '@hcengineering/document' +export { documentOperation } from './migration' +export { document as default } + export const DOMAIN_DOCUMENT = 'document' as Domain @Model(document.class.DocumentRequest, core.class.AttachedDoc, DOMAIN_DOCUMENT) @@ -266,6 +270,3 @@ export function createModel (builder: Builder): void { editor: document.component.DocumentVersions }) } - -export { documentOperation } from './migration' -export { document as default } diff --git a/models/document/src/plugin.ts b/models/document/src/plugin.ts index 9e099932055..c9ff392d848 100644 --- a/models/document/src/plugin.ts +++ b/models/document/src/plugin.ts @@ -18,7 +18,7 @@ import {} from '@hcengineering/core' import { documentId } from '@hcengineering/document' import document from '@hcengineering/document-resources/src/plugin' import { ObjectSearchCategory, ObjectSearchFactory } from '@hcengineering/model-presentation' -import { mergeIds, Resource } from '@hcengineering/platform' +import { IntlString, mergeIds, Resource } from '@hcengineering/platform' import { TagCategory } from '@hcengineering/tags' import { AnyComponent } from '@hcengineering/ui' import { ActionCategory } from '@hcengineering/view' @@ -40,5 +40,9 @@ export default mergeIds(documentId, document, { }, viewlet: { TableDocument: '' as Ref + }, + string: { + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString } }) diff --git a/models/gmail/src/index.ts b/models/gmail/src/index.ts index c7a1a907356..5c8496823ac 100644 --- a/models/gmail/src/index.ts +++ b/models/gmail/src/index.ts @@ -35,6 +35,10 @@ import view, { createAction } from '@hcengineering/model-view' import setting from '@hcengineering/setting' import gmail from './plugin' +export { gmailId } from '@hcengineering/gmail' +export { gmailOperation } from './migration' +export { default } from './plugin' + export const DOMAIN_GMAIL = 'gmail' as Domain function TypeSharedMessage (): Type { @@ -213,5 +217,3 @@ export function createModel (builder: Builder): void { parentPropagate: false }) } - -export { gmailOperation } from './migration' diff --git a/models/gmail/src/plugin.ts b/models/gmail/src/plugin.ts index 08e1458a760..5e90ee4ff48 100644 --- a/models/gmail/src/plugin.ts +++ b/models/gmail/src/plugin.ts @@ -37,7 +37,9 @@ export default mergeIds(gmailId, gmail, { Messages: '' as IntlString, Incoming: '' as IntlString, Status: '' as IntlString, - EmailPlaceholder: '' as IntlString + EmailPlaceholder: '' as IntlString, + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, ids: { TxSharedCreate: '' as Ref diff --git a/models/hr/src/index.ts b/models/hr/src/index.ts index 901bba2bf6b..10f82797625 100644 --- a/models/hr/src/index.ts +++ b/models/hr/src/index.ts @@ -14,16 +14,16 @@ // import { Contact, Employee } from '@hcengineering/contact' -import { Arr, Class, Domain, DOMAIN_MODEL, IndexKind, Markup, Ref, Type } from '@hcengineering/core' +import { Arr, Class, DOMAIN_MODEL, Domain, IndexKind, Markup, Ref, Type } from '@hcengineering/core' import { Department, DepartmentMember, - hrId, PublicHoliday, Request, RequestType, Staff, - TzDate + TzDate, + hrId } from '@hcengineering/hr' import { ArrOf, @@ -47,9 +47,13 @@ import contact, { TEmployee, TEmployeeAccount } from '@hcengineering/model-conta import core, { TAttachedDoc, TDoc, TSpace, TType } from '@hcengineering/model-core' import view, { classPresenter, createAction } from '@hcengineering/model-view' import workbench from '@hcengineering/model-workbench' +import notification from '@hcengineering/notification' import { Asset, IntlString } from '@hcengineering/platform' import hr from './plugin' -import notification from '@hcengineering/notification' + +export { hrId } from '@hcengineering/hr' +export { hrOperation } from './migration' +export { default } from './plugin' export const DOMAIN_HR = 'hr' as Domain @@ -482,6 +486,3 @@ export function createModel (builder: Builder): void { hr.ids.CreatePublicHolidayNotification ) } - -export { hrOperation } from './migration' -export { default } from './plugin' diff --git a/models/hr/src/plugin.ts b/models/hr/src/plugin.ts index 55d031f94d1..dcffec6602a 100644 --- a/models/hr/src/plugin.ts +++ b/models/hr/src/plugin.ts @@ -33,7 +33,9 @@ export default mergeIds(hrId, hr, { Overtime: '' as IntlString, Overtime2: '' as IntlString, Subscribers: '' as IntlString, - PublicHoliday: '' as IntlString + PublicHoliday: '' as IntlString, + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, component: { Structure: '' as AnyComponent, diff --git a/models/inventory/src/index.ts b/models/inventory/src/index.ts index cea2561d7c0..e5ee904fb8e 100644 --- a/models/inventory/src/index.ts +++ b/models/inventory/src/index.ts @@ -14,7 +14,7 @@ // import { Domain, IndexKind, Ref } from '@hcengineering/core' -import { Category, inventoryId, Product, Variant } from '@hcengineering/inventory' +import { Category, Product, Variant, inventoryId } from '@hcengineering/inventory' import { Builder, Collection, Index, Model, Prop, TypeRef, TypeString, UX } from '@hcengineering/model' import attachment from '@hcengineering/model-attachment' import core, { TAttachedDoc } from '@hcengineering/model-core' @@ -25,6 +25,10 @@ import setting from '@hcengineering/setting' import view, { Viewlet } from '@hcengineering/view' import inventory from './plugin' +export { inventoryId } from '@hcengineering/inventory' +export { inventoryOperation } from './migration' +export { default } from './plugin' + export const DOMAIN_INVENTORY = 'inventory' as Domain @Model(inventory.class.Category, core.class.AttachedDoc, DOMAIN_INVENTORY) @UX(inventory.string.Category, inventory.icon.Categories, undefined, 'name') @@ -175,6 +179,3 @@ export function createModel (builder: Builder): void { filters: ['attachedTo'] }) } - -export { inventoryOperation } from './migration' -export { default } from './plugin' diff --git a/models/inventory/src/plugin.ts b/models/inventory/src/plugin.ts index a5d1d9dc2e1..ce3690a22f4 100644 --- a/models/inventory/src/plugin.ts +++ b/models/inventory/src/plugin.ts @@ -17,7 +17,7 @@ import type { Ref } from '@hcengineering/core' import { inventoryId } from '@hcengineering/inventory' import inventory from '@hcengineering/inventory-resources/src/plugin' -import { mergeIds } from '@hcengineering/platform' +import { IntlString, mergeIds } from '@hcengineering/platform' import type { AnyComponent } from '@hcengineering/ui' import { Action, ActionCategory, ViewAction, Viewlet } from '@hcengineering/view' @@ -43,5 +43,9 @@ export default mergeIds(inventoryId, inventory, { }, viewlet: { TableProduct: '' as Ref + }, + string: { + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString } }) diff --git a/models/lead/src/index.ts b/models/lead/src/index.ts index dbf0c8f44d5..ee54d15bf22 100644 --- a/models/lead/src/index.ts +++ b/models/lead/src/index.ts @@ -40,6 +40,10 @@ import setting from '@hcengineering/setting' import { ViewOptionsModel } from '@hcengineering/view' import lead from './plugin' +export { leadId } from '@hcengineering/lead' +export { leadOperation } from './migration' +export { default } from './plugin' + @Model(lead.class.Funnel, task.class.SpaceWithStates) @UX(lead.string.Funnel, lead.icon.Funnel) export class TFunnel extends TSpaceWithStates implements Funnel { @@ -419,6 +423,3 @@ export function createModel (builder: Builder): void { lead.action.CreateGlobalLead ) } - -export { leadOperation } from './migration' -export { default } from './plugin' diff --git a/models/lead/src/plugin.ts b/models/lead/src/plugin.ts index ab237623c51..535e930475c 100644 --- a/models/lead/src/plugin.ts +++ b/models/lead/src/plugin.ts @@ -32,7 +32,9 @@ export default mergeIds(leadId, lead, { Title: '' as IntlString, ManageFunnelStatuses: '' as IntlString, FunnelBrowser: '' as IntlString, - GotoLeadApplication: '' as IntlString + GotoLeadApplication: '' as IntlString, + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, component: { CreateLead: '' as AnyComponent, diff --git a/models/model-rig/profiles/default/tsconfig.json b/models/model-rig/profiles/default/tsconfig.json index 6bc3c8fe3be..2841b9a0e60 100644 --- a/models/model-rig/profiles/default/tsconfig.json +++ b/models/model-rig/profiles/default/tsconfig.json @@ -8,6 +8,7 @@ "resolveJsonModule": true, "experimentalDecorators": true, "skipLibCheck": true, - "incremental": true + "incremental": true, + "declarationMap": true } } \ No newline at end of file diff --git a/models/notification/src/index.ts b/models/notification/src/index.ts index f02a7c92eee..a577cc703a8 100644 --- a/models/notification/src/index.ts +++ b/models/notification/src/index.ts @@ -17,6 +17,7 @@ import { Account, Class, Doc, Domain, DOMAIN_MODEL, IndexKind, Ref, Timestamp, TxCUD } from '@hcengineering/core' import { ArrOf, Builder, Index, Mixin, Model, Prop, TypeRef, TypeString, UX } from '@hcengineering/model' import core, { TAttachedDoc, TClass, TDoc } from '@hcengineering/model-core' +import view, { createAction } from '@hcengineering/model-view' import { AnotherUserNotifications, DocUpdates, @@ -33,10 +34,13 @@ import { } from '@hcengineering/notification' import type { IntlString } from '@hcengineering/platform' import setting from '@hcengineering/setting' +import { AnyComponent } from '@hcengineering/ui' import workbench from '@hcengineering/workbench' import notification from './plugin' -import { AnyComponent } from '@hcengineering/ui' -import view, { createAction } from '@hcengineering/model-view' + +export { notificationId } from '@hcengineering/notification' +export { notificationOperation } from './migration' +export { notification as default } export const DOMAIN_NOTIFICATION = 'notification' as Domain @@ -296,6 +300,3 @@ export function createModel (builder: Builder): void { actions: [view.action.Delete, view.action.Open] }) } - -export { notificationOperation } from './migration' -export { notification as default } diff --git a/models/preference/src/index.ts b/models/preference/src/index.ts index 9441e06d832..3339e80bfd7 100644 --- a/models/preference/src/index.ts +++ b/models/preference/src/index.ts @@ -18,6 +18,10 @@ import { Builder, Model, Prop, TypeRef } from '@hcengineering/model' import core, { TDoc } from '@hcengineering/model-core' import preference, { DOMAIN_PREFERENCE, Preference, SpacePreference } from '@hcengineering/preference' +export { preferenceId } from '@hcengineering/preference' +export { preferenceOperation } from './migration' +export { preference as default } + @Model(preference.class.Preference, core.class.Doc, DOMAIN_PREFERENCE) export class TPreference extends TDoc implements Preference { @Prop(TypeRef(core.class.Doc), core.string.AttachedTo) @@ -33,6 +37,3 @@ export class TSpacePreference extends TPreference implements SpacePreference { export function createModel (builder: Builder): void { builder.createModel(TPreference, TSpacePreference) } - -export { preference as default } -export { preferenceOperation } from './migration' diff --git a/models/presentation/src/index.ts b/models/presentation/src/index.ts index 8145728ea8d..fab507f7844 100644 --- a/models/presentation/src/index.ts +++ b/models/presentation/src/index.ts @@ -21,6 +21,7 @@ import type { Asset, IntlString, Resource } from '@hcengineering/platform' import { ObjectSearchCategory, ObjectSearchFactory } from '@hcengineering/presentation/src/types' import presentation from './plugin' +export { presentationId } from '@hcengineering/presentation/src/plugin' export { default } from './plugin' export { ObjectSearchCategory, ObjectSearchFactory } diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 47acf34634a..b6d0a2c00a2 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -39,20 +39,20 @@ import contact, { TOrganization, TPerson } from '@hcengineering/model-contact' import core, { TAttachedDoc, TSpace } from '@hcengineering/model-core' import presentation from '@hcengineering/model-presentation' import tags from '@hcengineering/model-tags' -import task, { actionTemplates, DOMAIN_TASK, TSpaceWithStates, TTask } from '@hcengineering/model-task' +import task, { DOMAIN_TASK, TSpaceWithStates, TTask, actionTemplates } from '@hcengineering/model-task' import tracker from '@hcengineering/model-tracker' -import view, { actionTemplates as viewTemplates, createAction } from '@hcengineering/model-view' +import view, { createAction, actionTemplates as viewTemplates } from '@hcengineering/model-view' import workbench, { Application, createNavigateAction } from '@hcengineering/model-workbench' import notification from '@hcengineering/notification' -import { getEmbeddedLabel, IntlString } from '@hcengineering/platform' +import { IntlString, getEmbeddedLabel } from '@hcengineering/platform' import { Applicant, ApplicantMatch, Candidate, Candidates, - recruitId, Vacancy, - VacancyList + VacancyList, + recruitId } from '@hcengineering/recruit' import setting from '@hcengineering/setting' import { KeyBinding, ViewOptionsModel } from '@hcengineering/view' @@ -60,6 +60,10 @@ import recruit from './plugin' import { createReviewModel, reviewTableConfig, reviewTableOptions } from './review' import { TOpinion, TReview } from './review-model' +export { recruitId } from '@hcengineering/recruit' +export { recruitOperation } from './migration' +export { default } from './plugin' + @Model(recruit.class.Vacancy, task.class.SpaceWithStates) @UX(recruit.string.Vacancy, recruit.icon.Vacancy, 'VCN', 'name') export class TVacancy extends TSpaceWithStates implements Vacancy { @@ -1190,6 +1194,3 @@ export function createModel (builder: Builder): void { recruit.action.MoveApplicant ) } - -export { recruitOperation } from './migration' -export { default } from './plugin' diff --git a/models/recruit/src/plugin.ts b/models/recruit/src/plugin.ts index cf9435fb96d..5fd12050633 100644 --- a/models/recruit/src/plugin.ts +++ b/models/recruit/src/plugin.ts @@ -60,7 +60,9 @@ export default mergeIds(recruitId, recruit, { GotoAssigned: '' as IntlString, GotoApplicants: '' as IntlString, GotoRecruitApplication: '' as IntlString, - VacancyList: '' as IntlString + VacancyList: '' as IntlString, + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, validator: { ApplicantValidator: '' as Resource<(doc: T, client: Client) => Promise> diff --git a/models/request/src/index.ts b/models/request/src/index.ts index e5e2039874b..006604ccbbf 100644 --- a/models/request/src/index.ts +++ b/models/request/src/index.ts @@ -31,12 +31,15 @@ import { TypeString, UX } from '@hcengineering/model' +import { TComment } from '@hcengineering/model-chunter' import core, { TAttachedDoc, TClass } from '@hcengineering/model-core' -import { Request, RequestDecisionComment, RequestStatus, RequestPresenter } from '@hcengineering/request' -import request from './plugin' import view from '@hcengineering/model-view' -import { TComment } from '@hcengineering/model-chunter' +import { Request, RequestDecisionComment, RequestPresenter, RequestStatus } from '@hcengineering/request' import { AnyComponent } from '@hcengineering/ui' +import request from './plugin' + +export { requestId } from '@hcengineering/request' +export { default } from './plugin' export const DOMAIN_REQUEST = 'request' as Domain @@ -105,5 +108,3 @@ export function createModel (builder: Builder): void { request.ids.TxRequestCreate ) } - -export { default } from './plugin' diff --git a/models/server-attachment/src/index.ts b/models/server-attachment/src/index.ts index a27f0492713..ed17071381d 100644 --- a/models/server-attachment/src/index.ts +++ b/models/server-attachment/src/index.ts @@ -16,9 +16,11 @@ import { Builder } from '@hcengineering/model' -import serverCore from '@hcengineering/server-core' import core from '@hcengineering/core' import serverAttachment from '@hcengineering/server-attachment' +import serverCore from '@hcengineering/server-core' + +export { serverAttachmentId } from '@hcengineering/server-attachment' export function createModel (builder: Builder): void { builder.createDoc(serverCore.class.Trigger, core.space.Model, { diff --git a/models/server-calendar/src/index.ts b/models/server-calendar/src/index.ts index 00371c240ba..a6aa90c3694 100644 --- a/models/server-calendar/src/index.ts +++ b/models/server-calendar/src/index.ts @@ -16,8 +16,10 @@ import { Builder } from '@hcengineering/model' import core, { Class, Doc } from '@hcengineering/core' -import serverCore, { ObjectDDParticipant } from '@hcengineering/server-core' import serverCalendar from '@hcengineering/server-calendar' +import serverCore, { ObjectDDParticipant } from '@hcengineering/server-core' + +export { serverCalendarId } from '@hcengineering/server-calendar' export function createModel (builder: Builder): void { builder.mixin, ObjectDDParticipant>( diff --git a/models/server-chunter/src/index.ts b/models/server-chunter/src/index.ts index 45b90eb9ee3..58632be8582 100644 --- a/models/server-chunter/src/index.ts +++ b/models/server-chunter/src/index.ts @@ -20,6 +20,7 @@ import chunter from '@hcengineering/chunter' import serverNotification from '@hcengineering/server-notification' import serverCore, { ObjectDDParticipant } from '@hcengineering/server-core' import serverChunter from '@hcengineering/server-chunter' +export { serverChunterId } from '@hcengineering/server-chunter' export function createModel (builder: Builder): void { builder.mixin(chunter.class.Channel, core.class.Class, serverNotification.mixin.HTMLPresenter, { diff --git a/models/server-contact/src/index.ts b/models/server-contact/src/index.ts index 9720813774e..5a4729d2f93 100644 --- a/models/server-contact/src/index.ts +++ b/models/server-contact/src/index.ts @@ -16,11 +16,12 @@ import { Builder } from '@hcengineering/model' -import serverCore from '@hcengineering/server-core' -import core from '@hcengineering/core' import contact from '@hcengineering/contact' -import serverNotification from '@hcengineering/server-notification' +import core from '@hcengineering/core' import serverContact from '@hcengineering/server-contact' +import serverCore from '@hcengineering/server-core' +import serverNotification from '@hcengineering/server-notification' +export { serverContactId } from '@hcengineering/server-contact' export function createModel (builder: Builder): void { builder.mixin(contact.class.Person, core.class.Class, serverNotification.mixin.HTMLPresenter, { diff --git a/models/server-core/src/index.ts b/models/server-core/src/index.ts index 7e40e2a6f7d..4b460f2bf7c 100644 --- a/models/server-core/src/index.ts +++ b/models/server-core/src/index.ts @@ -31,6 +31,8 @@ import core, { import type { ObjectDDParticipant, Trigger, TriggerFunc } from '@hcengineering/server-core' import serverCore from '@hcengineering/server-core' +export { serverCoreId } from '@hcengineering/server-core' + @Model(serverCore.class.Trigger, core.class.Doc, DOMAIN_MODEL) export class TTrigger extends TDoc implements Trigger { trigger!: Resource diff --git a/models/server-gmail/src/index.ts b/models/server-gmail/src/index.ts index 9004ef64b8a..b5b2e19b87f 100644 --- a/models/server-gmail/src/index.ts +++ b/models/server-gmail/src/index.ts @@ -15,10 +15,11 @@ import { Builder } from '@hcengineering/model' +import contact from '@hcengineering/contact' import core, { Class, Doc } from '@hcengineering/core' import serverCore, { ObjectDDParticipant } from '@hcengineering/server-core' -import contact from '@hcengineering/contact' import serverGmail from '@hcengineering/server-gmail' +export { serverGmailId } from '@hcengineering/server-gmail' export function createModel (builder: Builder): void { builder.mixin, ObjectDDParticipant>( diff --git a/models/server-hr/src/index.ts b/models/server-hr/src/index.ts index c772a1096df..4b404d6fab3 100644 --- a/models/server-hr/src/index.ts +++ b/models/server-hr/src/index.ts @@ -15,11 +15,13 @@ import { Builder } from '@hcengineering/model' -import serverCore from '@hcengineering/server-core' import core from '@hcengineering/core' +import hr from '@hcengineering/hr' +import serverCore from '@hcengineering/server-core' import serverHr from '@hcengineering/server-hr' import serverNotification from '@hcengineering/server-notification' -import hr from '@hcengineering/hr' + +export { serverHrId } from '@hcengineering/server-hr' export function createModel (builder: Builder): void { builder.createDoc(serverCore.class.Trigger, core.space.Model, { diff --git a/models/server-inventory/src/index.ts b/models/server-inventory/src/index.ts index 4838c2503bd..76119984df9 100644 --- a/models/server-inventory/src/index.ts +++ b/models/server-inventory/src/index.ts @@ -20,6 +20,8 @@ import inventory from '@hcengineering/inventory' import serverInventory from '@hcengineering/server-inventory' import serverNotification from '@hcengineering/server-notification' +export { serverInventoryId } from '@hcengineering/server-inventory' + export function createModel (builder: Builder): void { builder.mixin(inventory.class.Product, core.class.Class, serverNotification.mixin.HTMLPresenter, { presenter: serverInventory.function.ProductHTMLPresenter diff --git a/models/server-lead/src/index.ts b/models/server-lead/src/index.ts index c4bc5ac9d7f..43f709ba4cd 100644 --- a/models/server-lead/src/index.ts +++ b/models/server-lead/src/index.ts @@ -17,9 +17,11 @@ import { Builder } from '@hcengineering/model' import core from '@hcengineering/core' import lead from '@hcengineering/lead' -import serverNotification from '@hcengineering/server-notification' -import serverLead from '@hcengineering/server-lead' import serverCore from '@hcengineering/server-core' +import serverLead from '@hcengineering/server-lead' +import serverNotification from '@hcengineering/server-notification' + +export { serverLeadId } from '@hcengineering/server-lead' export function createModel (builder: Builder): void { builder.mixin(lead.class.Lead, core.class.Class, serverNotification.mixin.HTMLPresenter, { diff --git a/models/server-notification/src/index.ts b/models/server-notification/src/index.ts index 83ed1fa5605..2073649dcf7 100644 --- a/models/server-notification/src/index.ts +++ b/models/server-notification/src/index.ts @@ -16,11 +16,13 @@ import { Builder, Mixin } from '@hcengineering/model' -import serverCore from '@hcengineering/server-core' import core from '@hcengineering/core' -import serverNotification, { HTMLPresenter, TextPresenter, Presenter } from '@hcengineering/server-notification' -import { Resource } from '@hcengineering/platform' import { TClass } from '@hcengineering/model-core' +import { Resource } from '@hcengineering/platform' +import serverCore from '@hcengineering/server-core' +import serverNotification, { HTMLPresenter, Presenter, TextPresenter } from '@hcengineering/server-notification' + +export { serverNotificationId } from '@hcengineering/server-notification' @Mixin(serverNotification.mixin.HTMLPresenter, core.class.Class) export class THTMLPresenter extends TClass implements HTMLPresenter { diff --git a/models/server-openai/src/index.ts b/models/server-openai/src/index.ts index 98e669543b1..a96beb2c49e 100644 --- a/models/server-openai/src/index.ts +++ b/models/server-openai/src/index.ts @@ -25,6 +25,8 @@ import serverCore from '@hcengineering/server-core' import chunter from '@hcengineering/model-chunter' import recruit from '@hcengineering/model-recruit' +export { openAIId } from '@hcengineering/openai/src/plugin' + @Model(openai.class.OpenAIConfiguration, core.class.Configuration, DOMAIN_CONFIGURATION) @UX(getEmbeddedLabel('OpenAI')) export class TOpenAIConfiguration extends TConfiguration implements OpenAIConfiguration { diff --git a/models/server-recruit/src/index.ts b/models/server-recruit/src/index.ts index 24d460208b2..5cfb1cebea7 100644 --- a/models/server-recruit/src/index.ts +++ b/models/server-recruit/src/index.ts @@ -17,9 +17,11 @@ import { Builder } from '@hcengineering/model' import core from '@hcengineering/core' import recruit from '@hcengineering/recruit' +import serverCore from '@hcengineering/server-core' import serverNotification from '@hcengineering/server-notification' import serverRecruit from '@hcengineering/server-recruit' -import serverCore from '@hcengineering/server-core' + +export { serverRecruitId } from '@hcengineering/server-recruit' export function createModel (builder: Builder): void { builder.mixin(recruit.class.Applicant, core.class.Class, serverNotification.mixin.HTMLPresenter, { diff --git a/models/server-request/src/index.ts b/models/server-request/src/index.ts index a61e849ead7..2b4c976470c 100644 --- a/models/server-request/src/index.ts +++ b/models/server-request/src/index.ts @@ -19,6 +19,8 @@ import core from '@hcengineering/core' import serverCore from '@hcengineering/server-core' import serverRequest from '@hcengineering/server-request' +export { serverRequestId } from '@hcengineering/server-request' + export function createModel (builder: Builder): void { builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverRequest.trigger.OnRequestUpdate diff --git a/models/server-setting/src/index.ts b/models/server-setting/src/index.ts index 0bc215351c9..4c034e4180a 100644 --- a/models/server-setting/src/index.ts +++ b/models/server-setting/src/index.ts @@ -16,10 +16,12 @@ import { Builder } from '@hcengineering/model' -import serverCore from '@hcengineering/server-core' import core from '@hcengineering/core' +import serverCore from '@hcengineering/server-core' import serverSetting from '@hcengineering/server-setting' +export { serverSettingId } from '@hcengineering/server-setting' + export function createModel (builder: Builder): void { builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverSetting.trigger.OnIntegrationDisable diff --git a/models/server-tags/src/index.ts b/models/server-tags/src/index.ts index 8f458a13753..6a3d9818ac2 100644 --- a/models/server-tags/src/index.ts +++ b/models/server-tags/src/index.ts @@ -19,6 +19,8 @@ import serverCore, { ObjectDDParticipant } from '@hcengineering/server-core' import serverTags from '@hcengineering/server-tags' import tags from '@hcengineering/tags' +export { serverTagsId } from '@hcengineering/server-tags' + export function createModel (builder: Builder): void { builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverTags.trigger.onTagReference diff --git a/models/server-task/src/index.ts b/models/server-task/src/index.ts index b1cd96c4110..9939adf9a36 100644 --- a/models/server-task/src/index.ts +++ b/models/server-task/src/index.ts @@ -15,4 +15,6 @@ import { Builder } from '@hcengineering/model' +export { serverTaskId } from '@hcengineering/server-task' + export function createModel (builder: Builder): void {} diff --git a/models/server-telegram/src/index.ts b/models/server-telegram/src/index.ts index 59a7ea1afc7..deaa44e2dca 100644 --- a/models/server-telegram/src/index.ts +++ b/models/server-telegram/src/index.ts @@ -15,11 +15,13 @@ import { Builder } from '@hcengineering/model' +import contact from '@hcengineering/contact' import core, { Class, Doc } from '@hcengineering/core' import serverCore, { ObjectDDParticipant } from '@hcengineering/server-core' -import contact from '@hcengineering/contact' import serverTelegram from '@hcengineering/server-telegram' +export { serverTelegramId } from '@hcengineering/server-telegram' + export function createModel (builder: Builder): void { builder.mixin, ObjectDDParticipant>( contact.class.Channel, diff --git a/models/server-tracker/src/index.ts b/models/server-tracker/src/index.ts index fe1ebe03034..26f2eed700e 100644 --- a/models/server-tracker/src/index.ts +++ b/models/server-tracker/src/index.ts @@ -13,12 +13,14 @@ // limitations under the License. // -import { Builder } from '@hcengineering/model' import core from '@hcengineering/core' +import { Builder } from '@hcengineering/model' import serverCore from '@hcengineering/server-core' +import serverNotification from '@hcengineering/server-notification' import serverTracker from '@hcengineering/server-tracker' import tracker from '@hcengineering/tracker' -import serverNotification from '@hcengineering/server-notification' + +export { serverTrackerId } from '@hcengineering/server-tracker' export function createModel (builder: Builder): void { builder.mixin(tracker.class.Issue, core.class.Class, serverNotification.mixin.HTMLPresenter, { diff --git a/models/server-translate/src/index.ts b/models/server-translate/src/index.ts index 5769f98054f..9fed2e19361 100644 --- a/models/server-translate/src/index.ts +++ b/models/server-translate/src/index.ts @@ -20,6 +20,8 @@ import { getEmbeddedLabel } from '@hcengineering/platform' import core, { DOMAIN_CONFIGURATION } from '@hcengineering/core' import translate, { TranslateConfiguration } from '@hcengineering/translate/src/plugin' +export { translateId } from '@hcengineering/translate/src/plugin' + @Model(translate.class.TranslateConfiguration, core.class.Configuration, DOMAIN_CONFIGURATION) @UX(getEmbeddedLabel('Retranslation')) export class TTranslateConfiguration extends TConfiguration implements TranslateConfiguration { diff --git a/models/server-view/src/index.ts b/models/server-view/src/index.ts index ccfd65a65fb..390ead58d4b 100644 --- a/models/server-view/src/index.ts +++ b/models/server-view/src/index.ts @@ -13,11 +13,13 @@ // limitations under the License. // -import { Builder } from '@hcengineering/model' import core from '@hcengineering/core' +import { Builder } from '@hcengineering/model' import serverCore from '@hcengineering/server-core' import serverView from '@hcengineering/server-view' +export { serverViewId } from '@hcengineering/server-view' + export function createModel (builder: Builder): void { builder.createDoc(serverCore.class.Trigger, core.space.Model, { trigger: serverView.trigger.OnCustomAttributeRemove diff --git a/models/setting/src/index.ts b/models/setting/src/index.ts index 29c2d03d573..0c7a5157e81 100644 --- a/models/setting/src/index.ts +++ b/models/setting/src/index.ts @@ -14,10 +14,12 @@ // import activity from '@hcengineering/activity' +import contact from '@hcengineering/contact' import { Account, Domain, DOMAIN_MODEL, Ref } from '@hcengineering/core' import { Builder, Mixin, Model } from '@hcengineering/model' import core, { TClass, TConfiguration, TDoc } from '@hcengineering/model-core' import view, { createAction } from '@hcengineering/model-view' +import notification from '@hcengineering/notification' import type { Asset, IntlString } from '@hcengineering/platform' import { Editable, @@ -30,14 +32,16 @@ import { UserMixin } from '@hcengineering/setting' import task from '@hcengineering/task' -import setting from './plugin' import templates from '@hcengineering/templates' -import contact from '@hcengineering/contact' -import notification from '@hcengineering/notification' +import setting from './plugin' import workbench from '@hcengineering/model-workbench' import { AnyComponent } from '@hcengineering/ui' +export { settingId } from '@hcengineering/setting' +export { default } from './plugin' +export { settingOperation } from './migration' + export const DOMAIN_SETTING = 'setting' as Domain @Model(setting.class.Integration, core.class.Doc, DOMAIN_SETTING) @@ -180,6 +184,19 @@ export function createModel (builder: Builder): void { }, setting.ids.Owners ) + builder.createDoc( + setting.class.WorkspaceSettingCategory, + core.space.Model, + { + name: 'configuration', + label: setting.string.Configure, + icon: setting.icon.Setting, + component: setting.component.Configure, + order: 1001, + secured: true + }, + setting.ids.Configure + ) builder.createDoc( setting.class.WorkspaceSettingCategory, core.space.Model, @@ -466,5 +483,3 @@ export function createModel (builder: Builder): void { setting.templateField.OwnerPosition ) } - -export { settingOperation } from './migration' diff --git a/models/setting/src/plugin.ts b/models/setting/src/plugin.ts index 261d88b772c..ccee46614ed 100644 --- a/models/setting/src/plugin.ts +++ b/models/setting/src/plugin.ts @@ -28,7 +28,8 @@ export default mergeIds(settingId, setting, { }, ids: { TxIntegrationDisable: '' as Ref, - EnumSetting: '' as Ref + EnumSetting: '' as Ref, + Configure: '' as Ref }, component: { EnumSetting: '' as AnyComponent, @@ -43,7 +44,8 @@ export default mergeIds(settingId, setting, { CreateMixin: '' as AnyComponent, InviteSetting: '' as AnyComponent, ArrayEditor: '' as AnyComponent, - IntegrationPanel: '' as AnyComponent + IntegrationPanel: '' as AnyComponent, + Configure: '' as AnyComponent }, category: { Settings: '' as Ref diff --git a/models/tags/src/index.ts b/models/tags/src/index.ts index 0da64715561..8ab0e2aaf8b 100644 --- a/models/tags/src/index.ts +++ b/models/tags/src/index.ts @@ -27,7 +27,7 @@ import type { } from '@hcengineering/tags' import tags from './plugin' -export { TagCategory, TagElement, TagReference } from '@hcengineering/tags' +export { TagCategory, TagElement, TagReference, tagsId } from '@hcengineering/tags' export { tagsOperation } from './migration' export { tags as default } diff --git a/models/task/src/index.ts b/models/task/src/index.ts index f36aebb843c..f66c3720017 100644 --- a/models/task/src/index.ts +++ b/models/task/src/index.ts @@ -33,7 +33,7 @@ import { UX } from '@hcengineering/model' import core, { TAttachedDoc, TClass, TDoc, TSpace, TStatus } from '@hcengineering/model-core' -import view, { actionTemplates as viewTemplates, createAction, template } from '@hcengineering/model-view' +import view, { createAction, template, actionTemplates as viewTemplates } from '@hcengineering/model-view' import notification from '@hcengineering/notification' import { IntlString } from '@hcengineering/platform' import tags from '@hcengineering/tags' @@ -58,6 +58,7 @@ import { AnyComponent } from '@hcengineering/ui' import { ViewAction } from '@hcengineering/view' import task from './plugin' +export { taskId } from '@hcengineering/task' export { createKanbanTemplate, createSequence, taskOperation } from './migration' export { default } from './plugin' diff --git a/models/telegram/src/index.ts b/models/telegram/src/index.ts index 3190e74b2b5..d52abc1117f 100644 --- a/models/telegram/src/index.ts +++ b/models/telegram/src/index.ts @@ -39,8 +39,12 @@ import type { TelegramMessage } from '@hcengineering/telegram' import templates from '@hcengineering/templates' -import telegram from './plugin' import view from '@hcengineering/view' +import telegram from './plugin' + +export { telegramId } from '@hcengineering/telegram' +export { telegramOperation } from './migration' +export { default } from './plugin' export const DOMAIN_TELEGRAM = 'telegram' as Domain @@ -175,5 +179,3 @@ export function createModel (builder: Builder): void { parentPropagate: false }) } - -export { telegramOperation } from './migration' diff --git a/models/telegram/src/plugin.ts b/models/telegram/src/plugin.ts index 2e7a9e9faa1..6a8d2a0ff2d 100644 --- a/models/telegram/src/plugin.ts +++ b/models/telegram/src/plugin.ts @@ -31,7 +31,9 @@ export default mergeIds(telegramId, telegram, { Messages: '' as IntlString, Telegram: '' as IntlString, TelegramIntegrationDesc: '' as IntlString, - Status: '' as IntlString + Status: '' as IntlString, + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, ids: { TxMessage: '' as Ref, diff --git a/models/templates/src/index.ts b/models/templates/src/index.ts index ce9bb90c33c..ed34f3192f6 100644 --- a/models/templates/src/index.ts +++ b/models/templates/src/index.ts @@ -18,6 +18,7 @@ import { Domain, DOMAIN_MODEL, IndexKind, Ref } from '@hcengineering/core' import { Builder, Index, Model, Prop, TypeString, UX } from '@hcengineering/model' import core, { TDoc, TSpace } from '@hcengineering/model-core' import textEditor from '@hcengineering/model-text-editor' +import tracker from '@hcengineering/model-tracker' import view, { createAction } from '@hcengineering/model-view' import { IntlString, Resource } from '@hcengineering/platform' import setting from '@hcengineering/setting' @@ -29,7 +30,9 @@ import type { TemplateFieldFunc } from '@hcengineering/templates' import templates from './plugin' -import tracker from '@hcengineering/model-tracker' + +export { templatesId } from '@hcengineering/templates' +export { templatesOperation } from './migration' export const DOMAIN_TEMPLATES = 'templates' as Domain @@ -165,5 +168,3 @@ export function createModel (builder: Builder): void { actions: [view.action.Open, tracker.action.NewRelatedIssue] }) } - -export { templatesOperation } from './migration' diff --git a/models/text-editor/src/index.ts b/models/text-editor/src/index.ts index 8090abf55b8..4485b4b0cf8 100644 --- a/models/text-editor/src/index.ts +++ b/models/text-editor/src/index.ts @@ -21,6 +21,7 @@ import type { Asset, IntlString, Resource } from '@hcengineering/platform' import { RefInputAction, RefInputActionItem } from '@hcengineering/text-editor/src/types' import textEditor from './plugin' +export { textEditorId } from '@hcengineering/text-editor/src/plugin' export { default } from './plugin' export { RefInputAction, RefInputActionItem } diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 0ce7abe63bd..5105a7acc1c 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -13,12 +13,13 @@ // limitations under the License. // +import activity from '@hcengineering/activity' import type { Employee, EmployeeAccount } from '@hcengineering/contact' import contact from '@hcengineering/contact' import { + DOMAIN_MODEL, DateRangeMode, Domain, - DOMAIN_MODEL, FindOptions, IndexKind, Markup, @@ -46,7 +47,6 @@ import { UX } from '@hcengineering/model' import attachment from '@hcengineering/model-attachment' -import activity from '@hcengineering/activity' import chunter from '@hcengineering/model-chunter' import core, { DOMAIN_SPACE, TAttachedDoc, TDoc, TSpace, TStatus, TType } from '@hcengineering/model-core' import view, { actionTemplates, classPresenter, createAction } from '@hcengineering/model-view' @@ -81,6 +81,7 @@ import tracker from './plugin' import presentation from '@hcengineering/model-presentation' import { defaultPriorities, issuePriorities } from '@hcengineering/tracker-resources/src/types' +export { trackerId } from '@hcengineering/tracker' export { trackerOperation } from './migration' export { default } from './plugin' diff --git a/models/tracker/src/plugin.ts b/models/tracker/src/plugin.ts index c10b96b0726..6912edb320f 100644 --- a/models/tracker/src/plugin.ts +++ b/models/tracker/src/plugin.ts @@ -36,7 +36,9 @@ export default mergeIds(trackerId, tracker, { GotoTrackerApplication: '' as IntlString, SearchIssue: '' as IntlString, Parent: '' as IntlString, - CreatedOn: '' as IntlString + CreatedOn: '' as IntlString, + ConfigLabel: '' as IntlString, + ConfigDescription: '' as IntlString }, activity: { TxIssueCreated: '' as AnyComponent, diff --git a/models/view/src/index.ts b/models/view/src/index.ts index 5a01285d7fd..ec7d39cf120 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -24,6 +24,7 @@ import type { AnyComponent, Location } from '@hcengineering/ui' import type { Action, ActionCategory, + AllValuesFunc, ArrayEditor, AttributeEditor, AttributeFilter, @@ -34,19 +35,22 @@ import type { CollectionEditor, CollectionPresenter, Filter, - FilteredView, FilterMode, + FilteredView, + GetAllValuesFunc, IgnoreActions, InlineAttributEditor, KeyBinding, KeyFilter, LinkPresenter, + LinkProvider, ListHeaderExtra, ListItemPresenter, ObjectEditor, - ObjectEditorHeader, ObjectEditorFooter, + ObjectEditorHeader, ObjectFactory, + ObjectPanel, ObjectPresenter, ObjectTitle, ObjectValidator, @@ -57,18 +61,15 @@ import type { ViewAction, ViewActionInput, ViewContext, + ViewOptions, + ViewOptionsModel, Viewlet, ViewletDescriptor, - ViewletPreference, - ViewOptionsModel, - ViewOptions, - AllValuesFunc, - GetAllValuesFunc, - LinkProvider, - ObjectPanel + ViewletPreference } from '@hcengineering/view' import view from './plugin' +export { viewId } from '@hcengineering/view' export { viewOperation } from './migration' export { ViewAction, Viewlet } diff --git a/models/workbench/src/index.ts b/models/workbench/src/index.ts index 003cf197101..2ce3eef5547 100644 --- a/models/workbench/src/index.ts +++ b/models/workbench/src/index.ts @@ -13,17 +13,18 @@ // limitations under the License. // -import type { IntlString, Asset } from '@hcengineering/platform' import { Class, DOMAIN_MODEL, Ref, Space } from '@hcengineering/core' -import { Model, Mixin, Builder, UX, Prop, TypeRef } from '@hcengineering/model' -import type { Application, SpaceView, ViewConfiguration, HiddenApplication } from '@hcengineering/workbench' -import view, { KeyBinding } from '@hcengineering/view' -import { createAction } from '@hcengineering/model-view' +import { Builder, Mixin, Model, Prop, TypeRef, UX } from '@hcengineering/model' import preference, { TPreference } from '@hcengineering/model-preference' +import { createAction } from '@hcengineering/model-view' +import type { Asset, IntlString } from '@hcengineering/platform' +import view, { KeyBinding } from '@hcengineering/view' +import type { Application, HiddenApplication, SpaceView, ViewConfiguration } from '@hcengineering/workbench' -import core, { TDoc, TClass } from '@hcengineering/model-core' +import core, { TClass, TDoc } from '@hcengineering/model-core' import workbench from './plugin' +export { workbenchId } from '@hcengineering/workbench' export { Application } @Model(workbench.class.Application, core.class.Doc, DOMAIN_MODEL) diff --git a/packages/core/src/__tests__/client.test.ts b/packages/core/src/__tests__/client.test.ts index a7cfc66dcca..cd830ec6611 100644 --- a/packages/core/src/__tests__/client.test.ts +++ b/packages/core/src/__tests__/client.test.ts @@ -14,7 +14,7 @@ // limitations under the License. // import { Plugin, IntlString } from '@hcengineering/platform' -import type { Class, Doc, Domain, Ref } from '../classes' +import type { Class, Data, Doc, Domain, PluginConfiguration, Ref } from '../classes' import { Space, ClassifierKind, DOMAIN_MODEL } from '../classes' import { createClient, ClientConnection } from '../client' import core from '../component' @@ -118,9 +118,11 @@ describe('client', () => { const spyCreate = jest.spyOn(TxProcessor, 'createDoc2Doc') const spyUpdate = jest.spyOn(TxProcessor, 'updateDoc2Doc') - const pluginData1 = { - pluginId: 'testPlugin1', - transactions: [] + const pluginData1: Data = { + pluginId: 'testPlugin1' as Plugin, + transactions: [], + configurable: true, + enabled: true } const txCreateDoc1 = txFactory.createTxCreateDoc(core.class.PluginConfiguration, core.space.Model, pluginData1) txes.push(txCreateDoc1) @@ -134,8 +136,10 @@ describe('client', () => { await client1.close() const pluginData2 = { - pluginId: 'testPlugin2', - transactions: [] + pluginId: 'testPlugin2' as Plugin, + transactions: [], + configurable: true, + enabled: true } const txCreateDoc2 = txFactory.createTxCreateDoc(core.class.PluginConfiguration, core.space.Model, pluginData2) txes.push(txCreateDoc2) @@ -150,8 +154,10 @@ describe('client', () => { await client2.close() const pluginData3 = { - pluginId: 'testPlugin3', - transactions: [txCreateDoc1._id] + pluginId: 'testPlugin3' as Plugin, + transactions: [txCreateDoc1._id], + configurable: true, + enabled: true } const txUpdateDoc = txFactory.createTxUpdateDoc( core.class.PluginConfiguration, diff --git a/packages/core/src/classes.ts b/packages/core/src/classes.ts index b72652d6a1a..2611ee3ac92 100644 --- a/packages/core/src/classes.ts +++ b/packages/core/src/classes.ts @@ -14,7 +14,7 @@ // limitations under the License. // -import type { Asset, IntlString } from '@hcengineering/platform' +import type { Asset, IntlString, Plugin } from '@hcengineering/platform' /** * @public @@ -172,8 +172,19 @@ export interface Class extends Classifier { * Define a set of plugin to model document bindings. */ export interface PluginConfiguration extends Doc { - pluginId: string + pluginId: Plugin transactions: Ref[] + + label?: IntlString + icon?: Asset + description?: IntlString + enabled: boolean + + // If specified, will allow user to enable/disable item. + configurable: boolean + + // If defined, will only remove classes in list. + classFilter?: Ref>[] } /** diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index 7bce7a57f46..73af6c5ca8f 100644 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -272,10 +272,12 @@ async function loadModel ( atxes.forEach((tx) => (tx.modifiedBy === core.account.System && !isEmployeeAccount(tx) ? systemTx : userTx).push(tx)) - if (allowedPlugins !== undefined) { + if (allowedPlugins != null) { fillConfiguration(systemTx, configs) - const excludedPlugins = Array.from(configs.values()).filter((it) => !allowedPlugins.includes(it.pluginId as Plugin)) - + fillConfiguration(userTx, configs) + const excludedPlugins = Array.from(configs.values()).filter( + (it) => !it.enabled || !allowedPlugins.includes(it.pluginId) + ) systemTx = pluginFilterTx(excludedPlugins, configs, systemTx) } @@ -331,7 +333,22 @@ function pluginFilterTx ( if (a.pluginId === c.pluginId) { const excluded = new Set>() for (const id of c.transactions) { - excluded.add(id as Ref) + if (c.classFilter !== undefined) { + const filter = new Set(c.classFilter) + const tx = systemTx.find((it) => it._id === id) + if ( + tx?._class === core.class.TxCreateDoc || + tx?._class === core.class.TxUpdateDoc || + tx?._class === core.class.TxRemoveDoc + ) { + const cud = tx as TxCUD + if (filter.has(cud.objectClass)) { + excluded.add(id as Ref) + } + } + } else { + excluded.add(id as Ref) + } } const exclude = systemTx.filter((t) => excluded.has(t._id)) console.log('exclude plugin', c.pluginId, exclude.length) diff --git a/packages/core/src/component.ts b/packages/core/src/component.ts index 645912278d9..f26a16b2fa3 100644 --- a/packages/core/src/component.ts +++ b/packages/core/src/component.ts @@ -32,8 +32,8 @@ import type { FullTextData, FullTextSearchContext, Hyperlink, - IndexingConfiguration, IndexStageState, + IndexingConfiguration, Interface, Obj, PluginConfiguration, @@ -49,9 +49,9 @@ import { Status, StatusCategory } from './status' import type { Tx, TxApplyIf, + TxCUD, TxCollectionCUD, TxCreateDoc, - TxCUD, TxMixin, TxModelUpgrade, TxRemoveDoc, @@ -133,7 +133,8 @@ export default plugin(coreId, { Configuration: '' as Ref }, account: { - System: '' as Ref + System: '' as Ref, + ConfigUser: '' as Ref }, status: { ObjectNotFound: '' as StatusCode<{ _id: Ref }>, diff --git a/packages/core/src/hierarchy.ts b/packages/core/src/hierarchy.ts index 9ee8a12ef49..b0634953079 100644 --- a/packages/core/src/hierarchy.ts +++ b/packages/core/src/hierarchy.ts @@ -74,11 +74,18 @@ export class Hierarchy { return typeof (d as any)[mixin] === 'object' } - classHierarchyMixin(_class: Ref>, mixin: Ref>): M | undefined { + classHierarchyMixin( + _class: Ref>, + mixin: Ref>, + filter?: (value: M) => boolean + ): M | undefined { let clazz = this.getClass(_class) while (true) { if (this.hasMixin(clazz, mixin)) { - return this.as(clazz, mixin) as any as M + const m = this.as(clazz, mixin) as any as M + if (m !== undefined && (filter?.(m) ?? true)) { + return m + } } if (clazz.extends === undefined) return clazz = this.getClass(clazz.extends) diff --git a/packages/platform/src/resource.ts b/packages/platform/src/resource.ts index 156e653e2e8..8be588cec02 100644 --- a/packages/platform/src/resource.ts +++ b/packages/platform/src/resource.ts @@ -14,10 +14,10 @@ // limitations under the License. // -import type { Resource, Plugin } from './platform' -import { Status, Severity, PlatformError } from './status' -import { _parseId } from './ident' import { monitor } from './event' +import { _parseId } from './ident' +import type { Plugin, Resource } from './platform' +import { PlatformError, Severity, Status } from './status' import platform from './platform' @@ -105,3 +105,11 @@ export async function getResource (resource: Resource): Promise { cachedResource.set(resource, value) return value } + +/** + * @public + */ +export function getResourcePlugin (resource: Resource): Plugin { + const info = _parseId(resource) + return info.component +} diff --git a/packages/presentation/src/configuration.ts b/packages/presentation/src/configuration.ts new file mode 100644 index 00000000000..a7a75b05ea9 --- /dev/null +++ b/packages/presentation/src/configuration.ts @@ -0,0 +1,65 @@ +// +// Copyright © 2023 Hardcore Engineering Inc. +// +// Licensed under the Eclipse Public License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. You may +// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import core, { PluginConfiguration, SortingOrder } from '@hcengineering/core' +import { Plugin, Resource, getResourcePlugin } from '@hcengineering/platform' +import { writable } from 'svelte/store' +import { createQuery } from '.' +import { statusStore } from './status' +export { statusStore } + +/** + * @public + */ +export class ConfigurationManager { + constructor (readonly list: PluginConfiguration[], readonly configuration: Map) {} + + has (plugin: Plugin): boolean { + return this.configuration.get(plugin)?.enabled !== false + } + + hasResource(resource?: Resource | null): boolean { + if (resource == null) { + return false + } + return this.has(getResourcePlugin(resource)) + } +} +// Issue status live query +export let configuration = new ConfigurationManager([], new Map()) +export const configurationStore = writable(configuration) + +const configQuery = createQuery(true) + +/** + * @public + */ +export function hasResource (resource?: Resource): boolean { + return configuration.hasResource(resource) +} + +configQuery.query( + core.class.PluginConfiguration, + {}, + (res) => { + if (configuration.list.length > 0) { + // Configuration + location.reload() + } + configuration = new ConfigurationManager(res, new Map(res.map((it) => [it.pluginId, it]))) + configurationStore.set(configuration) + }, + { sort: { label: SortingOrder.Ascending } } +) diff --git a/packages/presentation/src/index.ts b/packages/presentation/src/index.ts index e6af498b44e..c3dea9eef1a 100644 --- a/packages/presentation/src/index.ts +++ b/packages/presentation/src/index.ts @@ -43,6 +43,7 @@ export * from './types' export * from './utils' export * from './drafts' export { presentationId } +export * from './configuration' addStringsLoader(presentationId, async (lang: string) => { return await import(`../lang/${lang}.json`) diff --git a/packages/presentation/src/utils.ts b/packages/presentation/src/utils.ts index 7c3738bdac4..b45f1569791 100644 --- a/packages/presentation/src/utils.ts +++ b/packages/presentation/src/utils.ts @@ -127,7 +127,7 @@ export async function setClient (_client: Client): Promise { txListeners.forEach((it) => it(tx)) } - if (needRefresh) { + if (needRefresh || globalQueries.length > 0) { await refreshClient() } } @@ -187,6 +187,15 @@ export class LiveQuery { callback: (result: FindResult) => void, options: FindOptions | undefined ): Promise { + if (pipeline === undefined) { + // We need remember values to perform refresh. + this.oldCallback = callback + this.oldClass = _class + this.oldOptions = options + this.oldQuery = query + + return + } const id = ++this.reqId const piplineQuery = await pipeline.subscribe(_class, query, options, () => { // Refresh query if pipeline decide it is required. diff --git a/plugins/activity-resources/src/components/ActivityFilter.svelte b/plugins/activity-resources/src/components/ActivityFilter.svelte index 3d09a4eb745..cb4cec927fd 100644 --- a/plugins/activity-resources/src/components/ActivityFilter.svelte +++ b/plugins/activity-resources/src/components/ActivityFilter.svelte @@ -16,7 +16,7 @@ import activity, { ActivityFilter, DisplayTx } from '@hcengineering/activity' import { Class, Doc, Ref } from '@hcengineering/core' import { IntlString, getResource } from '@hcengineering/platform' - import { getClient } from '@hcengineering/presentation' + import { getClient, hasResource } from '@hcengineering/presentation' import { ActionIcon, AnyComponent, Icon, Label, eventToHTMLElement, showPopup } from '@hcengineering/ui' import { createEventDispatcher } from 'svelte' import activityPlg from '../plugin' @@ -51,7 +51,9 @@ function getAdditionalComponent (_class: Ref>): AnyComponent | undefined { const hierarchy = client.getHierarchy() - const mixin = hierarchy.classHierarchyMixin(_class, activity.mixin.ExtraActivityComponent) + const mixin = hierarchy.classHierarchyMixin(_class, activity.mixin.ExtraActivityComponent, (m) => + hasResource(m.component) + ) if (mixin !== undefined) { return mixin.component } diff --git a/plugins/activity-resources/src/utils.ts b/plugins/activity-resources/src/utils.ts index de44544addb..acfd1c7833c 100644 --- a/plugins/activity-resources/src/utils.ts +++ b/plugins/activity-resources/src/utils.ts @@ -52,7 +52,7 @@ async function createPseudoViewlet ( } // Check if it is attached doc and collection have title override. - const presenter = await getObjectPresenter(client, dtx.tx.objectClass, { key: 'doc-presenter' }) + const presenter = await getObjectPresenter(client, dtx.tx.objectClass, { key: 'doc-presenter' }, false, false) if (presenter !== undefined) { let collection = '' if (dtx.collectionAttribute?.label !== undefined) { diff --git a/plugins/bitrix-assets/lang/en.json b/plugins/bitrix-assets/lang/en.json index 5a4cf1ae1ac..a7fbb9a0b65 100644 --- a/plugins/bitrix-assets/lang/en.json +++ b/plugins/bitrix-assets/lang/en.json @@ -11,6 +11,8 @@ "Attribute": "Attribute", "MapField": "Map...", "BitrixImport": "Synchronize with Bitrix", - "AddMapping": "Add entity mapping" + "AddMapping": "Add entity mapping", + "ConfigLabel": "Bitrix24", + "ConfigDescription": "Extension for Bitrix 24 integration" } } diff --git a/plugins/bitrix-assets/lang/ru.json b/plugins/bitrix-assets/lang/ru.json index 5ce20346c6c..487232af04e 100644 --- a/plugins/bitrix-assets/lang/ru.json +++ b/plugins/bitrix-assets/lang/ru.json @@ -11,6 +11,8 @@ "Attribute": "Attribute", "MapField": "Map...", "BitrixImport": "Synchronize with Bitrix", - "AddMapping": "Добавить отображение" + "AddMapping": "Добавить отображение", + "ConfigLabel": "Bitrix24", + "ConfigDescription": "Extension for Bitrix 24 integration" } } diff --git a/plugins/board-assets/lang/en.json b/plugins/board-assets/lang/en.json index 52dd2c73552..a3d4a74fcca 100644 --- a/plugins/board-assets/lang/en.json +++ b/plugins/board-assets/lang/en.json @@ -101,6 +101,8 @@ "RemoveCover": "Remove cover", "DeleteChecklist": "Delete checklist", "DeleteChecklistConfirm": "Deleting a checklist is permanent and there is no way to get it back.", - "ConvertToCard": "Convert to card" + "ConvertToCard": "Convert to card", + "ConfigLabel": "Board", + "ConfigDescription": "Extension to manage Kanban boards." } } diff --git a/plugins/board-assets/lang/ru.json b/plugins/board-assets/lang/ru.json index 3f4f28e21e7..ef29bb60904 100644 --- a/plugins/board-assets/lang/ru.json +++ b/plugins/board-assets/lang/ru.json @@ -101,6 +101,8 @@ "RemoveCover": "Удалить обложку", "DeleteChecklist": "Удалить список задач", "DeleteChecklistConfirm": "Удаление списка задач необратимо, и не будет возможности его вернуть.", - "ConvertToCard": "Конвертировать в карточку" + "ConvertToCard": "Конвертировать в карточку", + "ConfigLabel": "Доски", + "ConfigDescription": "Расширение для управления канбан досками." } } diff --git a/plugins/calendar-assets/lang/en.json b/plugins/calendar-assets/lang/en.json index 02936177064..0ff72c1a1ac 100644 --- a/plugins/calendar-assets/lang/en.json +++ b/plugins/calendar-assets/lang/en.json @@ -37,6 +37,8 @@ "AllDay": "All day", "AndMore": "And {count} more", "CreateEvent": "Create event", - "EventFor": "Event for: " + "EventFor": "Event for: ", + "ConfigLabel": "Calendar", + "ConfigDescription": "Extension to see calendar with Events" } } \ No newline at end of file diff --git a/plugins/calendar-assets/lang/ru.json b/plugins/calendar-assets/lang/ru.json index ad1f64cbdbc..3a2761d00d0 100644 --- a/plugins/calendar-assets/lang/ru.json +++ b/plugins/calendar-assets/lang/ru.json @@ -37,6 +37,8 @@ "AllDay": "Весь день", "AndMore": "И еще {count}", "CreateEvent": "Создать событие", - "EventFor": "Событие для: " + "EventFor": "Событие для: ", + "ConfigLabel": "Календаоь", + "ConfigDescription": "Расширение для календаря с событиями" } } \ No newline at end of file diff --git a/plugins/chunter-assets/lang/en.json b/plugins/chunter-assets/lang/en.json index 6f49cf5f629..f35c3260eed 100644 --- a/plugins/chunter-assets/lang/en.json +++ b/plugins/chunter-assets/lang/en.json @@ -65,6 +65,8 @@ "NoResults": "No results", "CopyLink": "Copy link", "FilterComments": "Comments", - "FilterBacklinks": "Backlinks" + "FilterBacklinks": "Backlinks", + "ConfigLabel": "Chat", + "ConfigDescription": "Extension to perform text communications" } } \ No newline at end of file diff --git a/plugins/chunter-assets/lang/ru.json b/plugins/chunter-assets/lang/ru.json index 35c845ce4bc..0b7c5f8859c 100644 --- a/plugins/chunter-assets/lang/ru.json +++ b/plugins/chunter-assets/lang/ru.json @@ -65,6 +65,8 @@ "NoResults": "Нет результатов", "CopyLink": "Копировать ссылку", "FilterComments": "Коментарии", - "FilterBacklinks": "Упоминания" + "FilterBacklinks": "Упоминания", + "ConfigLabel": "Чат", + "ConfigDescription": "Расширение для текстовых переписок" } } \ No newline at end of file diff --git a/plugins/client-resources/src/index.ts b/plugins/client-resources/src/index.ts index a6fb6c3958f..6e89252a225 100644 --- a/plugins/client-resources/src/index.ts +++ b/plugins/client-resources/src/index.ts @@ -48,7 +48,7 @@ export default async () => { return connect(url.href, upgradeHandler, onUpgrade, onUnauthorized, onConnect) }, - filterModel ? getPlugins() : undefined + filterModel ? [...getPlugins(), ...(getMetadata(clientPlugin.metadata.ExtraPlugins) ?? [])] : undefined ) // Check if we had dev hook for client. client = hookClient(client) diff --git a/plugins/client/src/index.ts b/plugins/client/src/index.ts index 1c06f57f924..37ba220adcd 100644 --- a/plugins/client/src/index.ts +++ b/plugins/client/src/index.ts @@ -76,7 +76,8 @@ export default plugin(clientId, { metadata: { ClientHook: '' as Metadata>, ClientSocketFactory: '' as Metadata, - FilterModel: '' as Metadata + FilterModel: '' as Metadata, + ExtraPlugins: '' as Metadata }, function: { GetClient: '' as Resource diff --git a/plugins/contact-assets/lang/en.json b/plugins/contact-assets/lang/en.json index 7296f3e1fc3..c351795b495 100644 --- a/plugins/contact-assets/lang/en.json +++ b/plugins/contact-assets/lang/en.json @@ -93,6 +93,8 @@ "CategoryCurrentUser": "Current user", "CategoryOther": "Other", "NumberMembers": "{count, plural, =0 {no members} =1 {1 member} other {# members}}", - "Position": "Position" + "Position": "Position", + "ConfigLabel": "Contacts", + "ConfigDescription": "Extension to hold information about all Employees and other Person/Organization contacts." } } diff --git a/plugins/contact-assets/lang/ru.json b/plugins/contact-assets/lang/ru.json index 596d9c59a49..17bb87c4a80 100644 --- a/plugins/contact-assets/lang/ru.json +++ b/plugins/contact-assets/lang/ru.json @@ -93,6 +93,8 @@ "CategoryProjectLead": "Руководитель проекта", "CategoryProjectMembers": "Участники проекта", "CategoryOther": "Прочие", - "Position": "Должность" + "Position": "Должность", + "ConfigLabel": "Контакты", + "ConfigDescription": "Расширение по работе с сотрудниками и другими контактами." } } diff --git a/plugins/contact-resources/src/components/EditEmployee.svelte b/plugins/contact-resources/src/components/EditEmployee.svelte index 4472a33fb9b..67c89aeca56 100644 --- a/plugins/contact-resources/src/components/EditEmployee.svelte +++ b/plugins/contact-resources/src/components/EditEmployee.svelte @@ -121,7 +121,7 @@
-
+
{#if owner} -
+
{#if owner} + + +
+
+
+
+
+
+ {#each $configurationStore.list as config} + {#if config.label} +
+
+
+ +
+
+
+
+ {#if config.description} +
+
+ {/if} + {#if config.configurable} +
+
+ {/if} +
+ {/if} + {/each} +
+
+ + diff --git a/plugins/setting-resources/src/components/InviteSetting.svelte b/plugins/setting-resources/src/components/InviteSetting.svelte index e6ead57d841..aaf945f5214 100644 --- a/plugins/setting-resources/src/components/InviteSetting.svelte +++ b/plugins/setting-resources/src/components/InviteSetting.svelte @@ -28,7 +28,7 @@ $: query.query(setting.class.InviteSettings, {}, (set) => { existingInviteSettings = set - if (existingInviteSettings !== undefined) { + if (existingInviteSettings !== undefined && existingInviteSettings.length > 0) { expTime = existingInviteSettings[0].expirationTime mask = existingInviteSettings[0].emailMask limit = existingInviteSettings[0].limit diff --git a/plugins/setting-resources/src/components/Owners.svelte b/plugins/setting-resources/src/components/Owners.svelte index d7b79c1a807..ccc25e520cf 100644 --- a/plugins/setting-resources/src/components/Owners.svelte +++ b/plugins/setting-resources/src/components/Owners.svelte @@ -17,7 +17,7 @@ import { employeeByIdStore, EmployeePresenter } from '@hcengineering/contact-resources' import { AccountRole, getCurrentAccount, SortingOrder } from '@hcengineering/core' import { createQuery, getClient } from '@hcengineering/presentation' - import { DropdownIntlItem, DropdownLabelsIntl, Icon, Label } from '@hcengineering/ui' + import { DropdownIntlItem, DropdownLabelsIntl, Icon, Label, EditBox } from '@hcengineering/ui' import setting from '../plugin' const client = getClient() @@ -51,35 +51,41 @@ role: value }) } + let search = ''
+
{#each accounts as account (account._id)} {@const employee = $employeeByIdStore.get(account.employee)} -
- {#if employee} - - {:else} - {formatName(account.name)} - {/if} - currentRole || (account.role === AccountRole.Owner && owners.length === 1)} - kind={'transparent'} - size={'medium'} - {items} - selected={account.role.toString()} - on:selected={(e) => { - change(account, Number(e.detail)) - }} - /> -
+ {#if account.name.includes(search)} +
+
+ {#if employee} + + {:else} + {formatName(account.name)} + {/if} +
+ currentRole || (account.role === AccountRole.Owner && owners.length === 1)} + kind={'primary'} + size={'medium'} + {items} + selected={account.role.toString()} + on:selected={(e) => { + change(account, Number(e.detail)) + }} + /> +
+ {/if} {/each}
diff --git a/plugins/setting-resources/src/components/statuses/Folders.svelte b/plugins/setting-resources/src/components/statuses/Folders.svelte index 1d76a1110d8..cf19245ed95 100644 --- a/plugins/setting-resources/src/components/statuses/Folders.svelte +++ b/plugins/setting-resources/src/components/statuses/Folders.svelte @@ -14,7 +14,7 @@ // limitations under the License. --> -
-
-
- -
- - - {#if headerRemoval} -
- -
- {#if extraHeaders} - {#each extraHeaders as extra} - - {/each} - {/if} - {subIssues.length} -
+{#if $configurationStore.has(trackerId)} +
+
+
+
- {:else} - - {/if} -
- {#if viewlet && viewOptions} - + + + {#if headerRemoval} +
+ +
+ {#if extraHeaders} + {#each extraHeaders as extra} + + {/each} + {/if} + {subIssues.length} +
+
+ {:else} + {/if} -
+ {#if viewlet} + + {/if}
- {#if viewlet} - - {/if} -
+{/if} diff --git a/plugins/view-resources/src/components/DocNavLink.svelte b/plugins/view-resources/src/components/DocNavLink.svelte index 5b4cf642801..9e35e4f46bc 100644 --- a/plugins/view-resources/src/components/DocNavLink.svelte +++ b/plugins/view-resources/src/components/DocNavLink.svelte @@ -14,7 +14,7 @@ -->