@nocobase/plugin-workflow 0.20.0-alpha.16 → 0.20.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/ExecutionContextProvider.d.ts +7 -0
- package/dist/client/components/CollectionBlockInitializer.d.ts +1 -1
- package/dist/client/components/DetailsBlockProvider.d.ts +6 -0
- package/dist/client/components/SimpleDesigner.d.ts +2 -0
- package/dist/client/components/ValueBlock.d.ts +1 -0
- package/dist/client/components/index.d.ts +2 -0
- package/dist/client/hooks/index.d.ts +3 -0
- package/dist/client/hooks/useWorkflowExecuted.d.ts +2 -0
- package/dist/client/index.d.ts +12 -12
- package/dist/client/index.js +37 -37
- package/dist/client/nodes/calculation.d.ts +1 -0
- package/dist/client/nodes/create.d.ts +2 -5
- package/dist/client/nodes/destroy.d.ts +1 -4
- package/dist/client/nodes/query.d.ts +1 -4
- package/dist/client/nodes/update.d.ts +2 -5
- package/dist/client/schemas/collection.d.ts +1 -4
- package/dist/client/triggers/collection.d.ts +6 -3
- package/dist/client/triggers/schedule/OnField.d.ts +1 -1
- package/dist/client/utils.d.ts +2 -0
- package/dist/externalVersion.js +11 -10
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/instructions/CreateInstruction.js +3 -1
- package/dist/server/instructions/DestroyInstruction.js +4 -2
- package/dist/server/instructions/QueryInstruction.js +4 -2
- package/dist/server/instructions/UpdateInstruction.js +4 -2
- package/dist/server/triggers/CollectionTrigger.js +29 -18
- package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.js +12 -6
- package/package.json +3 -3
- package/dist/client/constant.d.ts +0 -2
|
@@ -8,15 +8,12 @@ export default class extends Instruction {
|
|
|
8
8
|
description: string;
|
|
9
9
|
fieldset: {
|
|
10
10
|
collection: {
|
|
11
|
+
'x-reactions': any[];
|
|
11
12
|
type: string;
|
|
12
13
|
title: string;
|
|
13
14
|
required: boolean;
|
|
14
|
-
'x-reactions': any[];
|
|
15
15
|
'x-decorator': string;
|
|
16
16
|
'x-component': string;
|
|
17
|
-
'x-component-props': {
|
|
18
|
-
className: string;
|
|
19
|
-
};
|
|
20
17
|
};
|
|
21
18
|
params: {
|
|
22
19
|
type: string;
|
|
@@ -24,13 +21,13 @@ export default class extends Instruction {
|
|
|
24
21
|
values: {
|
|
25
22
|
type: string;
|
|
26
23
|
title: string;
|
|
24
|
+
description: string;
|
|
27
25
|
'x-decorator': string;
|
|
28
26
|
'x-decorator-props': {
|
|
29
27
|
labelAlign: string;
|
|
30
28
|
className: string;
|
|
31
29
|
};
|
|
32
30
|
'x-component': string;
|
|
33
|
-
description: string;
|
|
34
31
|
};
|
|
35
32
|
appends: {
|
|
36
33
|
type: string;
|
|
@@ -8,15 +8,12 @@ export default class extends Instruction {
|
|
|
8
8
|
description: string;
|
|
9
9
|
fieldset: {
|
|
10
10
|
collection: {
|
|
11
|
+
'x-reactions': any[];
|
|
11
12
|
type: string;
|
|
12
13
|
title: string;
|
|
13
14
|
required: boolean;
|
|
14
|
-
'x-reactions': any[];
|
|
15
15
|
'x-decorator': string;
|
|
16
16
|
'x-component': string;
|
|
17
|
-
'x-component-props': {
|
|
18
|
-
className: string;
|
|
19
|
-
};
|
|
20
17
|
};
|
|
21
18
|
params: {
|
|
22
19
|
type: string;
|
|
@@ -10,15 +10,12 @@ export default class extends Instruction {
|
|
|
10
10
|
description: string;
|
|
11
11
|
fieldset: {
|
|
12
12
|
collection: {
|
|
13
|
+
'x-reactions': any[];
|
|
13
14
|
type: string;
|
|
14
15
|
title: string;
|
|
15
16
|
required: boolean;
|
|
16
|
-
'x-reactions': any[];
|
|
17
17
|
'x-decorator': string;
|
|
18
18
|
'x-component': string;
|
|
19
|
-
'x-component-props': {
|
|
20
|
-
className: string;
|
|
21
|
-
};
|
|
22
19
|
};
|
|
23
20
|
multiple: {
|
|
24
21
|
type: string;
|
|
@@ -13,15 +13,12 @@ export default class extends Instruction {
|
|
|
13
13
|
description: string;
|
|
14
14
|
fieldset: {
|
|
15
15
|
collection: {
|
|
16
|
+
'x-reactions': any[];
|
|
16
17
|
type: string;
|
|
17
18
|
title: string;
|
|
18
19
|
required: boolean;
|
|
19
|
-
'x-reactions': any[];
|
|
20
20
|
'x-decorator': string;
|
|
21
21
|
'x-component': string;
|
|
22
|
-
'x-component-props': {
|
|
23
|
-
className: string;
|
|
24
|
-
};
|
|
25
22
|
};
|
|
26
23
|
params: {
|
|
27
24
|
type: string;
|
|
@@ -60,13 +57,13 @@ export default class extends Instruction {
|
|
|
60
57
|
};
|
|
61
58
|
type: string;
|
|
62
59
|
title: string;
|
|
60
|
+
description: string;
|
|
63
61
|
'x-decorator': string;
|
|
64
62
|
'x-decorator-props': {
|
|
65
63
|
labelAlign: string;
|
|
66
64
|
className: string;
|
|
67
65
|
};
|
|
68
66
|
'x-component': string;
|
|
69
|
-
description: string;
|
|
70
67
|
};
|
|
71
68
|
};
|
|
72
69
|
};
|
|
@@ -5,20 +5,17 @@ export declare const collection: {
|
|
|
5
5
|
'x-reactions': any[];
|
|
6
6
|
'x-decorator': string;
|
|
7
7
|
'x-component': string;
|
|
8
|
-
'x-component-props': {
|
|
9
|
-
className: string;
|
|
10
|
-
};
|
|
11
8
|
};
|
|
12
9
|
export declare const values: {
|
|
13
10
|
type: string;
|
|
14
11
|
title: string;
|
|
12
|
+
description: string;
|
|
15
13
|
'x-decorator': string;
|
|
16
14
|
'x-decorator-props': {
|
|
17
15
|
labelAlign: string;
|
|
18
16
|
className: string;
|
|
19
17
|
};
|
|
20
18
|
'x-component': string;
|
|
21
|
-
description: string;
|
|
22
19
|
};
|
|
23
20
|
export declare const filter: {
|
|
24
21
|
type: string;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SchemaInitializerItemType, useCollectionDataSource } from '@nocobase/client';
|
|
3
|
+
import { useWorkflowAnyExecuted } from '../hooks';
|
|
3
4
|
import { Trigger } from '.';
|
|
4
5
|
export default class extends Trigger {
|
|
5
6
|
title: string;
|
|
6
7
|
description: string;
|
|
7
8
|
fieldset: {
|
|
8
9
|
collection: {
|
|
10
|
+
'x-disabled': string;
|
|
11
|
+
'x-component-props': {
|
|
12
|
+
dataSourceFilter(item: any): any;
|
|
13
|
+
};
|
|
9
14
|
"x-reactions": any[];
|
|
10
15
|
type: string;
|
|
11
16
|
title: string;
|
|
12
17
|
required: boolean;
|
|
13
18
|
'x-decorator': string;
|
|
14
19
|
'x-component': string;
|
|
15
|
-
'x-component-props': {
|
|
16
|
-
className: string;
|
|
17
|
-
};
|
|
18
20
|
};
|
|
19
21
|
mode: {
|
|
20
22
|
type: string;
|
|
@@ -103,6 +105,7 @@ export default class extends Trigger {
|
|
|
103
105
|
};
|
|
104
106
|
scope: {
|
|
105
107
|
useCollectionDataSource: typeof useCollectionDataSource;
|
|
108
|
+
useWorkflowAnyExecuted: typeof useWorkflowAnyExecuted;
|
|
106
109
|
};
|
|
107
110
|
components: {
|
|
108
111
|
FieldsSelect: import("react").MemoExoticComponent<import("@formily/reactive-react").ReactFC<Omit<any, "ref">>>;
|
package/dist/client/utils.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare function linkNodes(nodes: any): void;
|
|
2
2
|
export declare function isValidFilter(condition: any): any;
|
|
3
3
|
export declare function traverseSchema(schema: any, fn: any): void;
|
|
4
|
+
export declare function getWorkflowDetailPath(id: string | number): string;
|
|
5
|
+
export declare function getWorkflowExecutionsPath(id: string | number): string;
|
package/dist/externalVersion.js
CHANGED
|
@@ -2,22 +2,23 @@ module.exports = {
|
|
|
2
2
|
"react": "18.2.0",
|
|
3
3
|
"antd": "5.12.8",
|
|
4
4
|
"@ant-design/icons": "5.2.6",
|
|
5
|
-
"@nocobase/client": "0.20.0-alpha.
|
|
5
|
+
"@nocobase/client": "0.20.0-alpha.17",
|
|
6
6
|
"react-router-dom": "6.21.0",
|
|
7
|
-
"@nocobase/utils": "0.20.0-alpha.
|
|
7
|
+
"@nocobase/utils": "0.20.0-alpha.17",
|
|
8
8
|
"react-i18next": "11.18.6",
|
|
9
9
|
"@formily/core": "2.3.0",
|
|
10
10
|
"@formily/react": "2.3.0",
|
|
11
|
-
"@nocobase/database": "0.20.0-alpha.
|
|
12
|
-
"@nocobase/server": "0.20.0-alpha.
|
|
13
|
-
"@nocobase/logger": "0.20.0-alpha.
|
|
14
|
-
"@nocobase/evaluators": "0.20.0-alpha.
|
|
11
|
+
"@nocobase/database": "0.20.0-alpha.17",
|
|
12
|
+
"@nocobase/server": "0.20.0-alpha.17",
|
|
13
|
+
"@nocobase/logger": "0.20.0-alpha.17",
|
|
14
|
+
"@nocobase/evaluators": "0.20.0-alpha.17",
|
|
15
|
+
"@formily/shared": "2.3.0",
|
|
15
16
|
"lodash": "4.17.21",
|
|
16
17
|
"@formily/antd-v5": "1.1.9",
|
|
17
|
-
"@
|
|
18
|
-
"@nocobase/
|
|
18
|
+
"@nocobase/actions": "0.20.0-alpha.17",
|
|
19
|
+
"@nocobase/data-source-manager": "0.20.0-alpha.17",
|
|
19
20
|
"sequelize": "6.35.2",
|
|
20
|
-
"@nocobase/plugin-workflow-test": "0.20.0-alpha.
|
|
21
|
-
"@nocobase/test": "0.20.0-alpha.
|
|
21
|
+
"@nocobase/plugin-workflow-test": "0.20.0-alpha.17",
|
|
22
|
+
"@nocobase/test": "0.20.0-alpha.17",
|
|
22
23
|
"dayjs": "1.11.10"
|
|
23
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-03-
|
|
1
|
+
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2024-03-26T09:59:12.161Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-03-
|
|
1
|
+
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2024-03-26T09:59:11.824Z"}
|
|
@@ -21,13 +21,15 @@ __export(CreateInstruction_exports, {
|
|
|
21
21
|
default: () => CreateInstruction_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(CreateInstruction_exports);
|
|
24
|
+
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
24
25
|
var import_constants = require("../constants");
|
|
25
26
|
var import_utils = require("../utils");
|
|
26
27
|
var import__ = require(".");
|
|
27
28
|
class CreateInstruction extends import__.Instruction {
|
|
28
29
|
async run(node, input, processor) {
|
|
29
30
|
const { collection, params: { appends = [], ...params } = {} } = node.config;
|
|
30
|
-
const
|
|
31
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
32
|
+
const { repository, model } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
31
33
|
const options = processor.getParsedValue(params, node.id);
|
|
32
34
|
const created = await repository.create({
|
|
33
35
|
...options,
|
|
@@ -21,14 +21,16 @@ __export(DestroyInstruction_exports, {
|
|
|
21
21
|
default: () => DestroyInstruction_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(DestroyInstruction_exports);
|
|
24
|
+
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
24
25
|
var import__ = require(".");
|
|
25
26
|
var import_constants = require("../constants");
|
|
26
27
|
class DestroyInstruction extends import__.Instruction {
|
|
27
28
|
async run(node, input, processor) {
|
|
28
29
|
const { collection, params = {} } = node.config;
|
|
29
|
-
const
|
|
30
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
31
|
+
const { repository } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
30
32
|
const options = processor.getParsedValue(params, node.id);
|
|
31
|
-
const result = await
|
|
33
|
+
const result = await repository.destroy({
|
|
32
34
|
...options,
|
|
33
35
|
context: {
|
|
34
36
|
stack: Array.from(new Set((processor.execution.context.stack ?? []).concat(processor.execution.id)))
|
|
@@ -22,13 +22,15 @@ __export(QueryInstruction_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(QueryInstruction_exports);
|
|
24
24
|
var import_actions = require("@nocobase/actions");
|
|
25
|
+
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
25
26
|
var import_constants = require("../constants");
|
|
26
27
|
var import_utils = require("../utils");
|
|
27
28
|
var import__ = require(".");
|
|
28
29
|
class QueryInstruction extends import__.Instruction {
|
|
29
30
|
async run(node, input, processor) {
|
|
30
31
|
const { collection, multiple, params = {}, failOnEmpty = false } = node.config;
|
|
31
|
-
const
|
|
32
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
33
|
+
const { repository } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
32
34
|
const {
|
|
33
35
|
page = import_actions.DEFAULT_PAGE,
|
|
34
36
|
pageSize = import_actions.DEFAULT_PER_PAGE,
|
|
@@ -42,7 +44,7 @@ class QueryInstruction extends import__.Instruction {
|
|
|
42
44
|
return set;
|
|
43
45
|
}, /* @__PURE__ */ new Set())
|
|
44
46
|
) : options.appends;
|
|
45
|
-
const result = await (multiple ?
|
|
47
|
+
const result = await (multiple ? repository.find : repository.findOne).call(repository, {
|
|
46
48
|
...options,
|
|
47
49
|
...import_actions.utils.pageArgsToLimitArgs(page, pageSize),
|
|
48
50
|
sort: sort.filter((item) => item.field).map((item) => {
|
|
@@ -21,14 +21,16 @@ __export(UpdateInstruction_exports, {
|
|
|
21
21
|
default: () => UpdateInstruction_default
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(UpdateInstruction_exports);
|
|
24
|
+
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
24
25
|
var import_constants = require("../constants");
|
|
25
26
|
var import__ = require(".");
|
|
26
27
|
class UpdateInstruction extends import__.Instruction {
|
|
27
28
|
async run(node, input, processor) {
|
|
28
29
|
const { collection, params = {} } = node.config;
|
|
29
|
-
const
|
|
30
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
31
|
+
const { repository } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
30
32
|
const options = processor.getParsedValue(params, node.id);
|
|
31
|
-
const result = await
|
|
33
|
+
const result = await repository.update({
|
|
32
34
|
...options,
|
|
33
35
|
context: {
|
|
34
36
|
stack: Array.from(new Set((processor.execution.context.stack ?? []).concat(processor.execution.id)))
|
|
@@ -32,6 +32,7 @@ __export(CollectionTrigger_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(CollectionTrigger_exports);
|
|
33
33
|
var import__ = __toESM(require("."));
|
|
34
34
|
var import_utils = require("../utils");
|
|
35
|
+
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
35
36
|
const MODE_BITMAP = {
|
|
36
37
|
CREATE: 1,
|
|
37
38
|
UPDATE: 2,
|
|
@@ -46,21 +47,24 @@ function getHookId(workflow, type) {
|
|
|
46
47
|
}
|
|
47
48
|
function getFieldRawName(collection, name) {
|
|
48
49
|
const field = collection.getField(name);
|
|
49
|
-
if (field && field.type === "belongsTo") {
|
|
50
|
-
return field.foreignKey;
|
|
50
|
+
if (field && field.options.type === "belongsTo") {
|
|
51
|
+
return field.options.foreignKey;
|
|
51
52
|
}
|
|
52
53
|
return name;
|
|
53
54
|
}
|
|
54
55
|
async function handler(workflow, data, options) {
|
|
55
|
-
var _a;
|
|
56
|
-
const {
|
|
57
|
-
const
|
|
56
|
+
var _a, _b;
|
|
57
|
+
const { condition, changed, mode, appends } = workflow.config;
|
|
58
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(workflow.config.collection);
|
|
59
|
+
const collection = (_a = this.workflow.app.dataSourceManager) == null ? void 0 : _a.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
58
60
|
const { transaction, context } = options;
|
|
59
61
|
const { repository, model } = collection;
|
|
60
|
-
if (changed && changed.length && changed.filter(
|
|
62
|
+
if (changed && changed.length && changed.filter(
|
|
63
|
+
(name) => !["linkTo", "hasOne", "hasMany", "belongsToMany"].includes(collection.getField(name).options.type)
|
|
64
|
+
).every((name) => !data.changedWithAssociations(getFieldRawName(collection, name)))) {
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
63
|
-
if (condition && ((
|
|
67
|
+
if (condition && ((_b = condition.$and) == null ? void 0 : _b.length)) {
|
|
64
68
|
const count = await repository.count({
|
|
65
69
|
filter: {
|
|
66
70
|
$and: [condition, { [model.primaryKeyAttribute]: data[model.primaryKeyAttribute] }]
|
|
@@ -101,15 +105,19 @@ async function handler(workflow, data, options) {
|
|
|
101
105
|
class CollectionTrigger extends import__.default {
|
|
102
106
|
events = /* @__PURE__ */ new Map();
|
|
103
107
|
on(workflow) {
|
|
104
|
-
|
|
108
|
+
var _a, _b;
|
|
105
109
|
const { collection, mode } = workflow.config;
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
if (!collection) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
114
|
+
const { db } = ((_b = (_a = this.workflow.app.dataSourceManager) == null ? void 0 : _a.dataSources.get(dataSourceName)) == null ? void 0 : _b.collectionManager) ?? {};
|
|
115
|
+
if (!db || !db.getCollection(collectionName)) {
|
|
108
116
|
return;
|
|
109
117
|
}
|
|
110
118
|
for (const [key, type] of MODE_BITMAP_EVENTS.entries()) {
|
|
111
|
-
const event = `${
|
|
112
|
-
const name = getHookId(workflow,
|
|
119
|
+
const event = `${collectionName}.${type}`;
|
|
120
|
+
const name = getHookId(workflow, `${collection}.${type}`);
|
|
113
121
|
if (mode & key) {
|
|
114
122
|
if (!this.events.has(name)) {
|
|
115
123
|
const listener = handler.bind(this, workflow);
|
|
@@ -126,19 +134,22 @@ class CollectionTrigger extends import__.default {
|
|
|
126
134
|
}
|
|
127
135
|
}
|
|
128
136
|
off(workflow) {
|
|
129
|
-
|
|
137
|
+
var _a;
|
|
130
138
|
const { collection, mode } = workflow.config;
|
|
131
|
-
|
|
132
|
-
|
|
139
|
+
if (!collection) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
143
|
+
const { db } = ((_a = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName)) == null ? void 0 : _a.collectionManager) ?? {};
|
|
144
|
+
if (!db || !db.getCollection(collectionName)) {
|
|
133
145
|
return;
|
|
134
146
|
}
|
|
135
147
|
for (const [key, type] of MODE_BITMAP_EVENTS.entries()) {
|
|
136
|
-
const
|
|
137
|
-
const name = getHookId(workflow, event);
|
|
148
|
+
const name = getHookId(workflow, `${collection}.${type}`);
|
|
138
149
|
if (mode & key) {
|
|
139
150
|
const listener = this.events.get(name);
|
|
140
151
|
if (listener) {
|
|
141
|
-
db.off(
|
|
152
|
+
db.off(`${collectionName}.${type}`, listener);
|
|
142
153
|
this.events.delete(name);
|
|
143
154
|
}
|
|
144
155
|
}
|
|
@@ -33,6 +33,7 @@ module.exports = __toCommonJS(DateFieldScheduleTrigger_exports);
|
|
|
33
33
|
var import_database = require("@nocobase/database");
|
|
34
34
|
var import_cron_parser = __toESM(require("cron-parser"));
|
|
35
35
|
var import_utils = require("./utils");
|
|
36
|
+
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
36
37
|
function getOnTimestampWithOffset({ field, offset = 0, unit = 1e3 }, now) {
|
|
37
38
|
if (!field) {
|
|
38
39
|
return null;
|
|
@@ -303,7 +304,9 @@ class ScheduleTrigger {
|
|
|
303
304
|
on(workflow) {
|
|
304
305
|
this.inspect([workflow]);
|
|
305
306
|
const { collection } = workflow.config;
|
|
306
|
-
const
|
|
307
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
308
|
+
const event = `${collectionName}.afterSaveWithAssociations`;
|
|
309
|
+
const eventKey = `${collection}.afterSaveWithAssociations`;
|
|
307
310
|
const name = getHookId(workflow, event);
|
|
308
311
|
if (this.events.has(name)) {
|
|
309
312
|
return;
|
|
@@ -313,7 +316,7 @@ class ScheduleTrigger {
|
|
|
313
316
|
return this.schedule(workflow, data, nextTime, Boolean(nextTime), { transaction });
|
|
314
317
|
};
|
|
315
318
|
this.events.set(name, listener);
|
|
316
|
-
this.workflow.app.db.on(event, listener);
|
|
319
|
+
this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.db.on(event, listener);
|
|
317
320
|
}
|
|
318
321
|
off(workflow) {
|
|
319
322
|
for (const [key, timer] of this.cache.entries()) {
|
|
@@ -323,12 +326,15 @@ class ScheduleTrigger {
|
|
|
323
326
|
}
|
|
324
327
|
}
|
|
325
328
|
const { collection } = workflow.config;
|
|
326
|
-
const
|
|
329
|
+
const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
|
|
330
|
+
const event = `${collectionName}.afterSaveWithAssociations`;
|
|
331
|
+
const eventKey = `${collection}.afterSaveWithAssociations`;
|
|
327
332
|
const name = getHookId(workflow, event);
|
|
328
|
-
if (this.events.has(
|
|
333
|
+
if (this.events.has(eventKey)) {
|
|
329
334
|
const listener = this.events.get(name);
|
|
330
|
-
this.
|
|
331
|
-
|
|
335
|
+
const { db } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager;
|
|
336
|
+
db.off(event, listener);
|
|
337
|
+
this.events.delete(eventKey);
|
|
332
338
|
}
|
|
333
339
|
}
|
|
334
340
|
}
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流",
|
|
5
5
|
"description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
|
|
6
6
|
"description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
|
|
7
|
-
"version": "0.20.0-alpha.
|
|
7
|
+
"version": "0.20.0-alpha.17",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"homepage": "https://docs.nocobase.com/handbook/workflow",
|
|
11
11
|
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/workflow",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nocobase/plugin-workflow-test": "0.20.0-alpha.
|
|
13
|
+
"@nocobase/plugin-workflow-test": "0.20.0-alpha.17"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@ant-design/icons": "5.x",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@nocobase/test": "0.x",
|
|
46
46
|
"@nocobase/utils": "0.x"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "a2460c222bc0b8a3bcb783b5c856499d756efa82",
|
|
49
49
|
"keywords": [
|
|
50
50
|
"Workflow"
|
|
51
51
|
]
|