@nocobase/plugin-workflow 0.20.0-alpha.8 → 0.21.0-alpha.1

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.
Files changed (35) hide show
  1. package/dist/client/ExecutionContextProvider.d.ts +7 -0
  2. package/dist/client/components/CollectionBlockInitializer.d.ts +1 -1
  3. package/dist/client/components/DetailsBlockProvider.d.ts +6 -0
  4. package/dist/client/components/SimpleDesigner.d.ts +2 -0
  5. package/dist/client/components/ValueBlock.d.ts +1 -0
  6. package/dist/client/components/index.d.ts +2 -0
  7. package/dist/client/hooks/index.d.ts +3 -0
  8. package/dist/client/hooks/useWorkflowExecuted.d.ts +2 -0
  9. package/dist/client/index.d.ts +12 -12
  10. package/dist/client/index.js +37 -37
  11. package/dist/client/nodes/calculation.d.ts +1 -0
  12. package/dist/client/nodes/create.d.ts +2 -5
  13. package/dist/client/nodes/destroy.d.ts +1 -4
  14. package/dist/client/nodes/query.d.ts +1 -4
  15. package/dist/client/nodes/update.d.ts +2 -5
  16. package/dist/client/schemas/collection.d.ts +1 -4
  17. package/dist/client/triggers/collection.d.ts +6 -3
  18. package/dist/client/triggers/schedule/OnField.d.ts +1 -1
  19. package/dist/client/utils.d.ts +2 -0
  20. package/dist/externalVersion.js +11 -10
  21. package/dist/node_modules/cron-parser/package.json +1 -1
  22. package/dist/node_modules/lru-cache/package.json +1 -1
  23. package/dist/server/Plugin.d.ts +3 -1
  24. package/dist/server/Plugin.js +20 -8
  25. package/dist/server/collections/executions.js +1 -1
  26. package/dist/server/instructions/CreateInstruction.js +6 -3
  27. package/dist/server/instructions/DestroyInstruction.js +5 -3
  28. package/dist/server/instructions/QueryInstruction.js +5 -3
  29. package/dist/server/instructions/UpdateInstruction.js +5 -3
  30. package/dist/server/migrations/20230411034722-manual-multi-form.js +2 -2
  31. package/dist/server/migrations/20230612021134-manual-collection-block.js +1 -1
  32. package/dist/server/triggers/CollectionTrigger.js +30 -19
  33. package/dist/server/triggers/ScheduleTrigger/DateFieldScheduleTrigger.js +12 -6
  34. package/package.json +3 -3
  35. package/dist/client/constant.d.ts +0 -2
@@ -51,6 +51,7 @@ export default class extends Instruction {
51
51
  ValueBlock: (() => JSX.Element) & {
52
52
  Initializer: () => JSX.Element;
53
53
  Result: (props: any) => JSX.Element;
54
+ Designer: () => JSX.Element;
54
55
  };
55
56
  };
56
57
  useVariables({ key, title }: {
@@ -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">>>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export declare function OnField({ value, onChange }: {
2
+ export declare function OnField({ value: propsValue, onChange }: {
3
3
  value: any;
4
4
  onChange: any;
5
5
  }): React.JSX.Element;
@@ -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;
@@ -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.8",
5
+ "@nocobase/client": "0.21.0-alpha.1",
6
6
  "react-router-dom": "6.21.0",
7
- "@nocobase/utils": "0.20.0-alpha.8",
7
+ "@nocobase/utils": "0.21.0-alpha.1",
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.8",
12
- "@nocobase/server": "0.20.0-alpha.8",
13
- "@nocobase/logger": "0.20.0-alpha.8",
14
- "@nocobase/evaluators": "0.20.0-alpha.8",
11
+ "@nocobase/database": "0.21.0-alpha.1",
12
+ "@nocobase/server": "0.21.0-alpha.1",
13
+ "@nocobase/logger": "0.21.0-alpha.1",
14
+ "@nocobase/evaluators": "0.21.0-alpha.1",
15
+ "@formily/shared": "2.3.0",
15
16
  "lodash": "4.17.21",
16
17
  "@formily/antd-v5": "1.1.9",
17
- "@formily/shared": "2.3.0",
18
- "@nocobase/actions": "0.20.0-alpha.8",
18
+ "@nocobase/actions": "0.21.0-alpha.1",
19
+ "@nocobase/data-source-manager": "0.21.0-alpha.1",
19
20
  "sequelize": "6.35.2",
20
- "@nocobase/plugin-workflow-test": "0.20.0-alpha.8",
21
- "@nocobase/test": "0.20.0-alpha.8",
21
+ "@nocobase/plugin-workflow-test": "0.21.0-alpha.1",
22
+ "@nocobase/test": "0.21.0-alpha.1",
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-11T02:09:47.762Z"}
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-29T09:54:16.962Z"}
@@ -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-11T02:09:47.438Z"}
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-29T09:54:16.648Z"}
@@ -12,6 +12,7 @@ export default class PluginWorkflowServer extends Plugin {
12
12
  instructions: Registry<InstructionInterface>;
13
13
  triggers: Registry<Trigger>;
14
14
  functions: Registry<CustomFunction>;
15
+ enabledCache: Map<number, WorkflowModel>;
15
16
  private ready;
16
17
  private executing;
17
18
  private pending;
@@ -21,7 +22,7 @@ export default class PluginWorkflowServer extends Plugin {
21
22
  private meter;
22
23
  getLogger(workflowId: ID): Logger;
23
24
  isWorkflowSync(workflow: WorkflowModel): boolean;
24
- onBeforeSave: (instance: WorkflowModel, options: any) => Promise<void>;
25
+ private onBeforeSave;
25
26
  registerTrigger<T extends Trigger>(type: string, trigger: T | {
26
27
  new (p: Plugin): T;
27
28
  }): void;
@@ -42,5 +43,6 @@ export default class PluginWorkflowServer extends Plugin {
42
43
  private prepare;
43
44
  private dispatch;
44
45
  private process;
46
+ useDataSourceTransaction(dataSourceName: string, transaction: any, create?: boolean): any;
45
47
  }
46
48
  export {};
@@ -52,6 +52,7 @@ class PluginWorkflowServer extends import_server.Plugin {
52
52
  instructions = new import_utils.Registry();
53
53
  triggers = new import_utils.Registry();
54
54
  functions = new import_utils.Registry();
55
+ enabledCache = /* @__PURE__ */ new Map();
55
56
  ready = false;
56
57
  executing = null;
57
58
  pending = [];
@@ -247,8 +248,10 @@ class PluginWorkflowServer extends import_server.Plugin {
247
248
  trigger.off({ ...workflow.get(), ...prev });
248
249
  }
249
250
  trigger.on(workflow);
251
+ this.enabledCache.set(workflow.id, workflow);
250
252
  } else {
251
253
  trigger.off(workflow);
254
+ this.enabledCache.delete(workflow.id);
252
255
  }
253
256
  }
254
257
  trigger(workflow, context, options = {}) {
@@ -269,9 +272,7 @@ class PluginWorkflowServer extends import_server.Plugin {
269
272
  this.events.push([workflow, context, rest]);
270
273
  this.eventsCount = this.events.length;
271
274
  logger.info(`new event triggered, now events: ${this.events.length}`);
272
- logger.debug(`event data:`, {
273
- data: context
274
- });
275
+ logger.debug(`event data:`, { context });
275
276
  if (this.events.length > 1) {
276
277
  return;
277
278
  }
@@ -419,19 +420,30 @@ class PluginWorkflowServer extends import_server.Plugin {
419
420
  if (execution.status === import_constants.EXECUTION_STATUS.QUEUEING) {
420
421
  await execution.update({ status: import_constants.EXECUTION_STATUS.STARTED }, { transaction: options.transaction });
421
422
  }
423
+ const logger = this.getLogger(execution.workflowId);
422
424
  const processor = this.createProcessor(execution, options);
423
- this.getLogger(execution.workflowId).info(`execution (${execution.id}) ${job ? "resuming" : "starting"}...`);
425
+ logger.info(`execution (${execution.id}) ${job ? "resuming" : "starting"}...`);
424
426
  try {
425
427
  await (job ? processor.resume(job) : processor.start());
426
- this.getLogger(execution.workflowId).info(
427
- `execution (${execution.id}) finished with status: ${execution.status}`
428
- );
428
+ logger.info(`execution (${execution.id}) finished with status: ${execution.status}`, { execution });
429
429
  if (execution.status && ((_b = (_a = execution.workflow.options) == null ? void 0 : _a.deleteExecutionOnStatus) == null ? void 0 : _b.includes(execution.status))) {
430
430
  await execution.destroy();
431
431
  }
432
432
  } catch (err) {
433
- this.getLogger(execution.workflowId).error(`execution (${execution.id}) error: ${err.message}`, err);
433
+ logger.error(`execution (${execution.id}) error: ${err.message}`, err);
434
434
  }
435
435
  return processor;
436
436
  }
437
+ useDataSourceTransaction(dataSourceName = "main", transaction, create = false) {
438
+ const { db } = this.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager;
439
+ if (!db) {
440
+ return;
441
+ }
442
+ if (db.sequelize === (transaction == null ? void 0 : transaction.sequelize)) {
443
+ return transaction;
444
+ }
445
+ if (create) {
446
+ return db.sequelize.transaction();
447
+ }
448
+ }
437
449
  }
@@ -32,7 +32,7 @@ var executions_default = {
32
32
  name: "workflow"
33
33
  },
34
34
  {
35
- type: "uid",
35
+ type: "string",
36
36
  name: "key"
37
37
  },
38
38
  {
@@ -21,20 +21,23 @@ __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 { repository, model } = node.constructor.database.getCollection(collection);
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);
34
+ const transaction = this.workflow.useDataSourceTransaction(dataSourceName, processor.transaction);
32
35
  const created = await repository.create({
33
36
  ...options,
34
37
  context: {
35
38
  stack: Array.from(new Set((processor.execution.context.stack ?? []).concat(processor.execution.id)))
36
39
  },
37
- transaction: processor.transaction
40
+ transaction
38
41
  });
39
42
  let result = created;
40
43
  if (created && appends.length) {
@@ -46,7 +49,7 @@ class CreateInstruction extends import__.Instruction {
46
49
  result = await repository.findOne({
47
50
  filterByTk: created[model.primaryKeyAttribute],
48
51
  appends: Array.from(includeFields),
49
- transaction: processor.transaction
52
+ transaction
50
53
  });
51
54
  }
52
55
  return {
@@ -21,19 +21,21 @@ __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 repo = node.constructor.database.getRepository(collection);
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 repo.destroy({
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)))
35
37
  },
36
- transaction: processor.transaction
38
+ transaction: this.workflow.useDataSourceTransaction(dataSourceName, processor.transaction)
37
39
  });
38
40
  return {
39
41
  result,
@@ -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 repo = node.constructor.database.getRepository(collection);
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 ? repo.find : repo.findOne).call(repo, {
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) => {
@@ -50,7 +52,7 @@ class QueryInstruction extends import__.Instruction {
50
52
  return `${((_a = item.direction) == null ? void 0 : _a.toLowerCase()) === "desc" ? "-" : ""}${item.field}`;
51
53
  }),
52
54
  appends,
53
- transaction: processor.transaction
55
+ transaction: this.workflow.useDataSourceTransaction(dataSourceName, processor.transaction)
54
56
  });
55
57
  if (failOnEmpty && (multiple ? !result.length : !result)) {
56
58
  return {
@@ -21,19 +21,21 @@ __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 repo = node.constructor.database.getRepository(collection);
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 repo.update({
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)))
35
37
  },
36
- transaction: processor.transaction
38
+ transaction: this.workflow.useDataSourceTransaction(dataSourceName, processor.transaction)
37
39
  });
38
40
  return {
39
41
  result: result.length ?? result,
@@ -117,7 +117,7 @@ function migrateConfig({ schema = {}, actions = [] }) {
117
117
  },
118
118
  properties: {
119
119
  grid: Object.assign(formBlock.properties.grid, {
120
- "x-initializer": "AddCustomFormField"
120
+ "x-initializer": "workflowManual:customForm:configureFields"
121
121
  }),
122
122
  // 7.
123
123
  actions: {
@@ -130,7 +130,7 @@ function migrateConfig({ schema = {}, actions = [] }) {
130
130
  marginTop: "1.5em"
131
131
  }
132
132
  },
133
- "x-initializer": "AddActionButton",
133
+ "x-initializer": "workflowManual:form:configureActions",
134
134
  properties: schema.actions
135
135
  }
136
136
  }
@@ -75,7 +75,7 @@ function migrateSchema(schema = {}) {
75
75
  type: "void",
76
76
  name: "grid",
77
77
  "x-component": "Grid",
78
- "x-initializer": "ReadPrettyFormItemInitializers",
78
+ "x-initializer": "details:configureFields",
79
79
  properties: grid.properties
80
80
  }
81
81
  }
@@ -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 { collection: collectionName, condition, changed, mode, appends } = workflow.config;
57
- const collection = data.constructor.database.getCollection(collectionName);
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((name) => !["linkTo", "hasOne", "hasMany", "belongsToMany"].includes(collection.getField(name).type)).every((name) => !data.changedWithAssociations(getFieldRawName(collection, name)))) {
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 && ((_a = condition.$and) == null ? void 0 : _a.length)) {
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] }]
@@ -91,7 +95,7 @@ async function handler(workflow, data, options) {
91
95
  workflow,
92
96
  { data: json, stack: context == null ? void 0 : context.stack },
93
97
  {
94
- transaction
98
+ transaction: this.workflow.useDataSourceTransaction(dataSourceName, transaction)
95
99
  }
96
100
  );
97
101
  } else {
@@ -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
- const { db } = this.workflow.app;
108
+ var _a, _b;
105
109
  const { collection, mode } = workflow.config;
106
- const Collection2 = db.getCollection(collection);
107
- if (!Collection2) {
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 = `${collection}.${type}`;
112
- const name = getHookId(workflow, event);
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
- const { db } = this.workflow.app;
137
+ var _a;
130
138
  const { collection, mode } = workflow.config;
131
- const Collection2 = db.getCollection(collection);
132
- if (!Collection2) {
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 event = `${collection}.${type}`;
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(event, listener);
152
+ db.off(`${collectionName}.${type}`, listener);
142
153
  this.events.delete(name);
143
154
  }
144
155
  }