mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-09 09:20:54 +00:00
move triggers from core
to server-core
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
81c5580fbf
commit
cb68860a93
@ -8,6 +8,7 @@ specifiers:
|
||||
'@rush-temp/platform': file:./projects/platform.tgz
|
||||
'@rush-temp/platform-rig': file:./projects/platform-rig.tgz
|
||||
'@rush-temp/prod': file:./projects/prod.tgz
|
||||
'@rush-temp/server-core': file:./projects/server-core.tgz
|
||||
'@rush-temp/server-ws': file:./projects/server-ws.tgz
|
||||
'@rush-temp/theme': file:./projects/theme.tgz
|
||||
'@rush-temp/ui': file:./projects/ui.tgz
|
||||
@ -55,6 +56,7 @@ dependencies:
|
||||
'@rush-temp/platform': file:projects/platform.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/platform-rig': file:projects/platform-rig.tgz_6ab28797e7a22071465f7d680ae81ae5
|
||||
'@rush-temp/prod': file:projects/prod.tgz_typescript@4.3.5
|
||||
'@rush-temp/server-core': file:projects/server-core.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/server-ws': file:projects/server-ws.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/theme': file:projects/theme.tgz_c38cf1a7a413db8918b0b4754c21e4c5
|
||||
'@rush-temp/ui': file:projects/ui.tgz_c38cf1a7a413db8918b0b4754c21e4c5
|
||||
@ -7629,6 +7631,26 @@ packages:
|
||||
- webpack-bundle-analyzer
|
||||
dev: false
|
||||
|
||||
file:projects/server-core.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||
resolution: {integrity: sha512-Y/tFe0ms52BXamdAMTFcI8GLan6+g39TKzG8taX7PiwXTdpVr170mZ4zTnER6OnxBHOlKXfwaHvgFTUmdupnEw==, tarball: file:projects/server-core.tgz}
|
||||
id: file:projects/server-core.tgz
|
||||
name: '@rush-temp/server-core'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
'@types/heft-jest': 1.0.2
|
||||
'@types/node': 16.4.10
|
||||
'@types/ws': 7.4.7
|
||||
'@typescript-eslint/eslint-plugin': 4.28.5_a8e83fcad666e1ba86be4b2e27a20aea
|
||||
eslint: 7.32.0
|
||||
eslint-plugin-import: 2.23.4_eslint@7.32.0
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
eslint-plugin-promise: 4.3.1
|
||||
transitivePeerDependencies:
|
||||
- '@typescript-eslint/parser'
|
||||
- supports-color
|
||||
- typescript
|
||||
dev: false
|
||||
|
||||
file:projects/server-ws.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||
resolution: {integrity: sha512-8bO8luxe1YvzgRj7tfSZdn8M59g82abZeSIEv8Kb9z8Yu9oin/teg61Uu4dPnxwcGyOB43WYYAdm2dW+aozC4Q==, tarball: file:projects/server-ws.tgz}
|
||||
id: file:projects/server-ws.tgz
|
||||
|
@ -14,7 +14,8 @@
|
||||
//
|
||||
|
||||
import type { Storage, DocumentQuery, FindResult } from '../storage'
|
||||
import type { Class, Doc, Ref, Tx } from '../classes'
|
||||
import type { Class, Doc, Ref } from '../classes'
|
||||
import type { Tx } from '../tx'
|
||||
import core from '../component'
|
||||
import { Hierarchy } from '../hierarchy'
|
||||
import { ModelDb, TxDb } from '../memdb'
|
||||
|
@ -13,7 +13,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import type { Class, Doc, Obj, Ref, TxCreateDoc } from '../classes'
|
||||
import type { Class, Doc, Obj, Ref } from '../classes'
|
||||
import type { TxCreateDoc } from '../tx'
|
||||
import core from '../component'
|
||||
import { Hierarchy } from '../hierarchy'
|
||||
import { genMinModel } from './minmodel'
|
||||
|
@ -1,4 +1,21 @@
|
||||
import { Account, Class, ClassifierKind, Data, Doc, Domain, DOMAIN_MODEL, Obj, Ref, Tx, TxCreateDoc } from '../classes'
|
||||
//
|
||||
// Copyright © 2020 Anticrm Platform Contributors.
|
||||
//
|
||||
// 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 { Account, Class, Data, Doc, Domain, Obj, Ref } from '../classes'
|
||||
import { ClassifierKind, DOMAIN_MODEL } from '../classes'
|
||||
import type { Tx, TxCreateDoc } from '../tx'
|
||||
import core from '../component'
|
||||
import { DOMAIN_TX } from '../tx'
|
||||
import { generateId } from '../utils'
|
||||
|
@ -14,7 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import type { IntlString, Asset, Resource } from '@anticrm/platform'
|
||||
import type { IntlString, Asset } from '@anticrm/platform'
|
||||
|
||||
/**
|
||||
* @public
|
||||
@ -108,7 +108,6 @@ export type Domain = string & { __domain: true }
|
||||
export interface Class<T extends Obj> extends Classifier {
|
||||
extends?: Ref<Class<Obj>>
|
||||
domain?: Domain
|
||||
triggers?: Trigger[]
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,47 +176,3 @@ export interface Space extends Doc {
|
||||
* @public
|
||||
*/
|
||||
export interface Account extends Doc {}
|
||||
|
||||
// T X
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface TxFactory {
|
||||
createTxCreateDoc: <T extends Doc>(_class: Ref<Class<T>>, space: Ref<Space>, attributes: Data<T>) => TxCreateDoc<T>
|
||||
createTxMixin: <D extends Doc, M extends D>(objectId: Ref<D>, objectClass: Ref<Class<D>>, mixin: Ref<Mixin<M>>, attributes: ExtendedAttributes<D, M>) => TxMixin<D, M>
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type Trigger = Resource<(tx: Tx, txFactory: TxFactory) => Promise<Tx[]>>
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface Tx<T extends Doc = Doc> extends Doc {
|
||||
objectId: Ref<T>
|
||||
objectClass: Ref<Class<T>>
|
||||
objectSpace: Ref<Space>
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface TxCreateDoc<T extends Doc> extends Tx<T> {
|
||||
attributes: Data<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ExtendedAttributes<D extends Doc, M extends D> = Omit<M, keyof D>
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface TxMixin<D extends Doc, M extends D> extends Tx<D> {
|
||||
mixin: Ref<Mixin<M>>
|
||||
attributes: ExtendedAttributes<D, M>
|
||||
}
|
||||
|
@ -13,7 +13,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import type { Doc, Ref, Class, Tx } from './classes'
|
||||
import type { Doc, Ref, Class } from './classes'
|
||||
import type { Tx } from './tx'
|
||||
import type { Storage, DocumentQuery, FindOptions, FindResult } from './storage'
|
||||
|
||||
import { Hierarchy } from './hierarchy'
|
||||
|
@ -14,8 +14,8 @@
|
||||
//
|
||||
import type { Plugin, StatusCode } from '@anticrm/platform'
|
||||
import { plugin } from '@anticrm/platform'
|
||||
import type { Account, Class, Doc, Obj, Ref, Space, AnyAttribute, Tx, TxCreateDoc, TxMixin } from './classes'
|
||||
import type { TxRemoveDoc, TxUpdateDoc } from './tx'
|
||||
import type { Account, Class, Doc, Obj, Ref, Space, AnyAttribute } from './classes'
|
||||
import type { Tx, TxCreateDoc, TxMixin, TxRemoveDoc, TxUpdateDoc } from './tx'
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
@ -13,9 +13,9 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import type { Ref, Class, Obj, Domain, Mixin, Doc, AnyAttribute, Tx, TxCreateDoc, TxMixin } from './classes'
|
||||
import type { Ref, Class, Obj, Domain, Mixin, Doc, AnyAttribute } from './classes'
|
||||
import { ClassifierKind } from './classes'
|
||||
import { TxProcessor } from './tx'
|
||||
import { Tx, TxCreateDoc, TxMixin, TxProcessor } from './tx'
|
||||
|
||||
import core from './component'
|
||||
|
||||
|
@ -14,13 +14,13 @@
|
||||
//
|
||||
|
||||
import { PlatformError, Severity, Status } from '@anticrm/platform'
|
||||
import type { Class, Doc, Ref, Tx, TxCreateDoc, TxMixin } from './classes'
|
||||
import type { Class, Doc, Ref } from './classes'
|
||||
import type { Tx, TxCreateDoc, TxMixin, TxRemoveDoc, TxUpdateDoc } from './tx'
|
||||
import core from './component'
|
||||
import type { Hierarchy } from './hierarchy'
|
||||
import { _getOperator } from './operator'
|
||||
import { findProperty, resultSort } from './query'
|
||||
import type { DocumentQuery, FindOptions, FindResult, Storage, WithLookup, LookupData, Refs } from './storage'
|
||||
import type { TxRemoveDoc, TxUpdateDoc } from './tx'
|
||||
import { TxProcessor } from './tx'
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,8 @@
|
||||
//
|
||||
|
||||
import type { KeysByType } from 'simplytyped'
|
||||
import type { Class, Doc, Ref, Tx } from './classes'
|
||||
import type { Class, Doc, Ref } from './classes'
|
||||
import type { Tx } from './tx'
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
@ -14,10 +14,44 @@
|
||||
//
|
||||
|
||||
import type { KeysByType } from 'simplytyped'
|
||||
import type { Class, Data, Doc, Domain, Ref, Account, Space, Arr, Mixin, Tx, TxCreateDoc, TxFactory, TxMixin, ExtendedAttributes } from './classes'
|
||||
import type { Class, Data, Doc, Domain, Ref, Account, Space, Arr, Mixin } from './classes'
|
||||
import core from './component'
|
||||
import { generateId } from './utils'
|
||||
|
||||
// export interface TxFactory {
|
||||
// createTxCreateDoc: <T extends Doc>(_class: Ref<Class<T>>, space: Ref<Space>, attributes: Data<T>) => TxCreateDoc<T>
|
||||
// createTxMixin: <D extends Doc, M extends D>(objectId: Ref<D>, objectClass: Ref<Class<D>>, mixin: Ref<Mixin<M>>, attributes: ExtendedAttributes<D, M>) => TxMixin<D, M>
|
||||
// }
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface Tx<T extends Doc = Doc> extends Doc {
|
||||
objectId: Ref<T>
|
||||
objectClass: Ref<Class<T>>
|
||||
objectSpace: Ref<Space>
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface TxCreateDoc<T extends Doc> extends Tx<T> {
|
||||
attributes: Data<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type ExtendedAttributes<D extends Doc, M extends D> = Omit<M, keyof D>
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface TxMixin<D extends Doc, M extends D> extends Tx<D> {
|
||||
mixin: Ref<Mixin<M>>
|
||||
attributes: ExtendedAttributes<D, M>
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
@ -186,7 +220,7 @@ export function withOperations<T extends WithTx> (user: Ref<Account>, storage: T
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export class DefaultTxFactory implements TxFactory {
|
||||
export class TxFactory {
|
||||
constructor (readonly account: Ref<Account>) {}
|
||||
|
||||
createTxCreateDoc<T extends Doc>(_class: Ref<Class<T>>, space: Ref<Space>, attributes: Data<T>, objectId?: Ref<T>): TxCreateDoc<T> {
|
||||
|
@ -490,6 +490,11 @@
|
||||
"packageName": "prod",
|
||||
"projectFolder": "dev/prod",
|
||||
"shouldPublish": true
|
||||
},
|
||||
{
|
||||
"packageName": "@anticrm/server-core",
|
||||
"projectFolder": "server/core",
|
||||
"shouldPublish": true
|
||||
}
|
||||
|
||||
]
|
||||
|
6
server/core/.eslintrc.js
Normal file
6
server/core/.eslintrc.js
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
extends: ['./node_modules/@anticrm/platform-rig/profiles/default/config/eslint.config.json'],
|
||||
parserOptions: {
|
||||
project: './tsconfig.json'
|
||||
}
|
||||
}
|
4
server/core/.npmignore
Normal file
4
server/core/.npmignore
Normal file
@ -0,0 +1,4 @@
|
||||
*
|
||||
!/lib/**
|
||||
!CHANGELOG.md
|
||||
/lib/**/__tests__/
|
18
server/core/config/rig.json
Normal file
18
server/core/config/rig.json
Normal file
@ -0,0 +1,18 @@
|
||||
// The "rig.json" file directs tools to look for their config files in an external package.
|
||||
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
||||
|
||||
/**
|
||||
* (Required) The name of the rig package to inherit from.
|
||||
* It should be an NPM package name with the "-rig" suffix.
|
||||
*/
|
||||
"rigPackageName": "@anticrm/platform-rig"
|
||||
|
||||
/**
|
||||
* (Optional) Selects a config profile from the rig package. The name must consist of
|
||||
* lowercase alphanumeric words separated by hyphens, for example "sample-profile".
|
||||
* If omitted, then the "default" profile will be used."
|
||||
*/
|
||||
// "rigProfile": "your-profile-name"
|
||||
}
|
26
server/core/package.json
Normal file
26
server/core/package.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@anticrm/server-core",
|
||||
"version": "0.6.0",
|
||||
"main": "lib/index.js",
|
||||
"author": "Anticrm Platform Contributors",
|
||||
"license": "EPL-2.0",
|
||||
"scripts": {
|
||||
"build": "heft build",
|
||||
"lint:fix": "eslint --fix src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anticrm/platform-rig":"~0.6.0",
|
||||
"@types/heft-jest":"^1.0.2",
|
||||
"@types/node": "^16.4.10",
|
||||
"@typescript-eslint/eslint-plugin":"4",
|
||||
"eslint-plugin-import":"2",
|
||||
"eslint-plugin-promise":"4",
|
||||
"eslint-plugin-node":"11",
|
||||
"eslint":"^7.32.0",
|
||||
"@types/ws":"^7.4.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anticrm/core": "~0.6.3",
|
||||
"@anticrm/platform": "~0.6.3"
|
||||
}
|
||||
}
|
28
server/core/src/index.ts
Normal file
28
server/core/src/index.ts
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// 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'
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export type Trigger = Resource<(tx: Tx, txFactory: TxFactory) => Promise<Tx[]>>
|
||||
|
||||
|
||||
export interface Triggers extends Class<Obj> {
|
||||
triggers: Arr<Resource
|
||||
}
|
9
server/core/tsconfig.json
Normal file
9
server/core/tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "./node_modules/@anticrm/platform-rig/profiles/default/tsconfig.json",
|
||||
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user