diff --git a/dev/storage/package.json b/dev/storage/package.json index 3583a42f8c..bbb9aa3845 100644 --- a/dev/storage/package.json +++ b/dev/storage/package.json @@ -19,6 +19,7 @@ }, "dependencies": { "@anticrm/core": "~0.6.7", - "@anticrm/platform": "~0.6.3" + "@anticrm/platform": "~0.6.3", + "@anticrm/server-core": "~0.6.0" } } diff --git a/dev/storage/src/storage.ts b/dev/storage/src/storage.ts index 3421279af1..aa53e45d83 100644 --- a/dev/storage/src/storage.ts +++ b/dev/storage/src/storage.ts @@ -13,17 +13,10 @@ // limitations under the License. // -import type { - Tx, - Ref, - Doc, - Class, - DocumentQuery, - FindResult, - FindOptions -} from '@anticrm/core' +import type { Tx, Ref, Doc, Class, DocumentQuery, FindResult, FindOptions } from '@anticrm/core' import { getResource } from '@anticrm/platform' import core, { ModelDb, TxDb, Hierarchy, DOMAIN_TX, TxFactory } from '@anticrm/core' +import serverCore from '@anticrm/server-core' import * as txJson from './model.tx.json' @@ -66,7 +59,8 @@ class DevStorage implements ServerStorage { } await Promise.all([this.modeldb.tx(tx), this.txdb.tx(tx)]) // invoke triggers - const triggers = this.hierarchy.getClass(tx.objectClass).triggers + const clazz = this.hierarchy.getClass(tx.objectClass) + const triggers = this.hierarchy.as(clazz, serverCore.mixin.Triggers).triggers if (triggers !== undefined) { const derived: Tx[] = [] for (const trigger of triggers) { diff --git a/server/core/src/index.ts b/server/core/src/index.ts index 2d1a2c59dd..37ecd6f974 100644 --- a/server/core/src/index.ts +++ b/server/core/src/index.ts @@ -1,28 +1,45 @@ // // Copyright © 2020, 2021 Anticrm Platform Contributors. // Copyright © 2021 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 type { Resource } from '@anticrm/platform' -import type { Class, Obj, Arr, Tx, TxFactory } from '@anticrm/core' +import type { Resource, Plugin } from '@anticrm/platform' +import { plugin } from '@anticrm/platform' +import type { Class, Obj, Arr, Tx, TxFactory, Mixin, Ref } from '@anticrm/core' /** * @public */ - export type Trigger = Resource<(tx: Tx, txFactory: TxFactory) => Promise> - +export type Trigger = Resource<(tx: Tx, txFactory: TxFactory) => Promise> +/** + * @public + */ export interface Triggers extends Class { - triggers: Arr +} + +/** + * @public + */ +export const serverCoreId = 'server-core' as Plugin + +/** + * @public + */ +export default plugin(serverCoreId, { + mixin: { + Triggers: '' as Ref> + } +})