From b34b70feeb24239525f69ddd31d0322b348c7858 Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Mon, 15 Apr 2024 19:43:39 +0700 Subject: [PATCH] fix: workspace creation issues (#5362) Signed-off-by: Alexander Onnikov --- models/activity/src/index.ts | 6 ++++-- models/chunter/src/index.ts | 3 +-- models/guest/src/index.ts | 3 ++- models/tracker/src/index.ts | 3 +-- packages/model/src/dsl.ts | 4 ++-- plugins/chunter/src/index.ts | 3 +-- pods/server/src/server.ts | 5 +++-- server/tool/src/index.ts | 38 ++++++++++++++++++++++++------------ 8 files changed, 40 insertions(+), 25 deletions(-) diff --git a/models/activity/src/index.ts b/models/activity/src/index.ts index 3692f3ae1b..a9db7be15a 100644 --- a/models/activity/src/index.ts +++ b/models/activity/src/index.ts @@ -375,7 +375,8 @@ export function createModel (builder: Builder): void { core.class.Class, core.mixin.IndexConfiguration, { - searchDisabled: true + searchDisabled: true, + indexes: [] } ) @@ -384,7 +385,8 @@ export function createModel (builder: Builder): void { core.class.Class, core.mixin.IndexConfiguration, { - searchDisabled: true + searchDisabled: true, + indexes: [] } ) diff --git a/models/chunter/src/index.ts b/models/chunter/src/index.ts index b45b9650d1..356ef4c3cb 100644 --- a/models/chunter/src/index.ts +++ b/models/chunter/src/index.ts @@ -62,7 +62,7 @@ import notification, { notificationActionTemplates } from '@hcengineering/model- import view, { createAction, template, actionTemplates as viewTemplates } from '@hcengineering/model-view' import workbench from '@hcengineering/model-workbench' import { type AnyComponent } from '@hcengineering/ui/src/types' -import type { IntlString, Resource } from '@hcengineering/platform' +import type { IntlString } from '@hcengineering/platform' import { TActivityMessage } from '@hcengineering/model-activity' import chunter from './plugin' @@ -190,7 +190,6 @@ export class TChatMessageViewlet extends TDoc implements ChatMessageViewlet { @Mixin(chunter.mixin.ObjectChatPanel, core.class.Class) export class TObjectChatPanel extends TClass implements ObjectChatPanel { ignoreKeys!: string[] - titleProvider!: Resource<(object: Doc) => string> } const actionTemplates = template({ diff --git a/models/guest/src/index.ts b/models/guest/src/index.ts index 28d5938807..5d6ed0a681 100644 --- a/models/guest/src/index.ts +++ b/models/guest/src/index.ts @@ -51,7 +51,8 @@ export function createModel (builder: Builder): void { core.class.Class, core.mixin.IndexConfiguration, { - searchDisabled: true + searchDisabled: true, + indexes: [] } ) } diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 7661f29ea7..e3b50a9dcf 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -182,8 +182,7 @@ function defineFilters (builder: Builder): void { 'description', 'remainingTime', 'reportedTime' - ], - titleProvider: tracker.function.IssueChatTitleProvider + ] }) // diff --git a/packages/model/src/dsl.ts b/packages/model/src/dsl.ts index 1aaeb7170b..9cb302deb6 100644 --- a/packages/model/src/dsl.ts +++ b/packages/model/src/dsl.ts @@ -32,7 +32,7 @@ import core, { IndexKind, Interface, Markup, - MixinUpdate, + MixinData, Obj, PropertyType, Rank, @@ -359,7 +359,7 @@ export class Builder { objectId: Ref, objectClass: Ref>, mixin: Ref>, - attributes: MixinUpdate + attributes: MixinData ): void { const tx = txFactory.createTxMixin(objectId, objectClass, core.space.Model, mixin, attributes) this.txes.push(tx) diff --git a/plugins/chunter/src/index.ts b/plugins/chunter/src/index.ts index c9a2402e8b..ddb523b21c 100644 --- a/plugins/chunter/src/index.ts +++ b/plugins/chunter/src/index.ts @@ -17,7 +17,7 @@ import { ActivityMessage, ActivityMessageViewlet } from '@hcengineering/activity import type { Person } from '@hcengineering/contact' import type { Account, AttachedDoc, Class, Doc, Markup, Mixin, Ref, Space, Timestamp } from '@hcengineering/core' import { NotificationType } from '@hcengineering/notification' -import type { Asset, Plugin, Resource } from '@hcengineering/platform' +import type { Asset, Plugin } from '@hcengineering/platform' import { IntlString, plugin } from '@hcengineering/platform' import { AnyComponent } from '@hcengineering/ui' import { Action } from '@hcengineering/view' @@ -83,7 +83,6 @@ export interface DirectMessageInput extends Class { */ export interface ObjectChatPanel extends Class { ignoreKeys: string[] - titleProvider: Resource<(object: Doc) => string> } /** diff --git a/pods/server/src/server.ts b/pods/server/src/server.ts index 0c16080c50..9ddccac0d8 100644 --- a/pods/server/src/server.ts +++ b/pods/server/src/server.ts @@ -36,7 +36,7 @@ import { } from '@hcengineering/middleware' import { createMongoAdapter, createMongoTxAdapter } from '@hcengineering/mongo' import { OpenAIEmbeddingsStage, openAIId, openAIPluginImpl } from '@hcengineering/openai' -import { addLocation, addStringsLoader } from '@hcengineering/platform' +import { addLocation, addStringsLoader, platformId } from '@hcengineering/platform' import { BackupClientSession, buildStorageFromConfig, @@ -123,8 +123,8 @@ import { viewId } from '@hcengineering/view' import { workbenchId } from '@hcengineering/workbench' import coreEng from '@hcengineering/core/lang/en.json' - import loginEng from '@hcengineering/login-assets/lang/en.json' +import platformEng from '@hcengineering/platform/lang/en.json' import activityEn from '@hcengineering/activity-assets/lang/en.json' import attachmentEn from '@hcengineering/attachment-assets/lang/en.json' @@ -154,6 +154,7 @@ import workbenchEn from '@hcengineering/workbench-assets/lang/en.json' addStringsLoader(coreId, async (lang: string) => coreEng) addStringsLoader(loginId, async (lang: string) => loginEng) +addStringsLoader(platformId, async (lang: string) => platformEng) addStringsLoader(taskId, async (lang: string) => taskEn) addStringsLoader(viewId, async (lang: string) => viewEn) diff --git a/server/tool/src/index.ts b/server/tool/src/index.ts index ee832daf43..a47e7bf88b 100644 --- a/server/tool/src/index.ts +++ b/server/tool/src/index.ts @@ -356,8 +356,8 @@ async function createUpdateIndexes ( // Find all domains and indexed fields inside for (const c of classes) { try { - const domain = hierarchy.getDomain(c._id) - if (domain === DOMAIN_MODEL) { + const domain = hierarchy.findDomain(c._id) + if (domain === undefined || domain === DOMAIN_MODEL) { continue } const attrs = hierarchy.getAllAttributes(c._id) @@ -396,11 +396,17 @@ async function createUpdateIndexes ( for (const [d, v] of allDomains) { const cfg = domainConfigurations.find((it) => it.domain === d) - if (cfg?.disableCollection === true) { - await db.dropCollection(d) + const collInfo = collections.find((it) => it.name === d) + + if (cfg?.disableCollection === true && collInfo != null) { + try { + await db.dropCollection(d) + } catch (err) { + logger.error('error: failed to delete collection', { d, err }) + } continue } - const collInfo = collections.find((it) => it.name === d) + if (collInfo == null) { await ctx.with('create-collection', { d }, async () => await db.createCollection(d)) } @@ -458,13 +464,17 @@ async function createUpdateIndexes ( } if (allIndexes.length > 0) { for (const c of allIndexes) { - if (cfg?.skip !== undefined) { - if (Array.from(cfg.skip ?? []).some((it) => c.name.includes(it))) { - continue + try { + if (cfg?.skip !== undefined) { + if (Array.from(cfg.skip ?? []).some((it) => c.name.includes(it))) { + continue + } } + logger.log('drop unused indexes', { name: c.name }) + await collection.dropIndex(c.name) + } catch (err) { + console.error('error: failed to drop index', { c, err }) } - logger.log('drop unused indexes', { name: c.name }) - await collection.dropIndex(c.name) } } @@ -483,8 +493,12 @@ async function createUpdateIndexes ( if (collections.length > 0) { // We could drop unused collections. for (const c of collections) { - logger.log('drop unused collection', { name: c.name }) - await db.dropCollection(c.name) + try { + logger.log('drop unused collection', { name: c.name }) + await db.dropCollection(c.name) + } catch (err) { + console.error('error: failed to drop collection', { c, err }) + } } } }