mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-04 23:04:47 +00:00
fix triggers
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
e25d9ed618
commit
e1f87b97ea
@ -19,6 +19,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@anticrm/core": "~0.6.7",
|
"@anticrm/core": "~0.6.7",
|
||||||
"@anticrm/platform": "~0.6.3"
|
"@anticrm/platform": "~0.6.3",
|
||||||
|
"@anticrm/server-core": "~0.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,17 +13,10 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import type {
|
import type { Tx, Ref, Doc, Class, DocumentQuery, FindResult, FindOptions } from '@anticrm/core'
|
||||||
Tx,
|
|
||||||
Ref,
|
|
||||||
Doc,
|
|
||||||
Class,
|
|
||||||
DocumentQuery,
|
|
||||||
FindResult,
|
|
||||||
FindOptions
|
|
||||||
} from '@anticrm/core'
|
|
||||||
import { getResource } from '@anticrm/platform'
|
import { getResource } from '@anticrm/platform'
|
||||||
import core, { ModelDb, TxDb, Hierarchy, DOMAIN_TX, TxFactory } from '@anticrm/core'
|
import core, { ModelDb, TxDb, Hierarchy, DOMAIN_TX, TxFactory } from '@anticrm/core'
|
||||||
|
import serverCore from '@anticrm/server-core'
|
||||||
|
|
||||||
import * as txJson from './model.tx.json'
|
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)])
|
await Promise.all([this.modeldb.tx(tx), this.txdb.tx(tx)])
|
||||||
// invoke triggers
|
// 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) {
|
if (triggers !== undefined) {
|
||||||
const derived: Tx[] = []
|
const derived: Tx[] = []
|
||||||
for (const trigger of triggers) {
|
for (const trigger of triggers) {
|
||||||
|
@ -14,15 +14,32 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import type { Resource } from '@anticrm/platform'
|
import type { Resource, Plugin } from '@anticrm/platform'
|
||||||
import type { Class, Obj, Arr, Tx, TxFactory } from '@anticrm/core'
|
import { plugin } from '@anticrm/platform'
|
||||||
|
import type { Class, Obj, Arr, Tx, TxFactory, Mixin, Ref } from '@anticrm/core'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export type Trigger = Resource<(tx: Tx, txFactory: TxFactory) => Promise<Tx[]>>
|
export type Trigger = Resource<(tx: Tx, txFactory: TxFactory) => Promise<Tx[]>>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
export interface Triggers extends Class<Obj> {
|
export interface Triggers extends Class<Obj> {
|
||||||
triggers: Arr<Resource
|
triggers: Arr<Trigger>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export const serverCoreId = 'server-core' as Plugin
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export default plugin(serverCoreId, {
|
||||||
|
mixin: {
|
||||||
|
Triggers: '' as Ref<Mixin<Triggers>>
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user