@nocobase/plugin-workflow 0.17.0-alpha.2 → 0.17.0-alpha.4
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/WorkflowPane.d.ts +2 -0
- package/dist/client/components/index.d.ts +5 -0
- package/dist/client/hooks/useTriggerWorkflowActionProps.d.ts +3 -0
- package/dist/client/index.d.ts +14 -6
- package/dist/client/index.js +136 -186
- package/dist/client/nodes/calculation.d.ts +8 -62
- package/dist/client/nodes/condition.d.ts +9 -9
- package/dist/client/nodes/create.d.ts +3 -5
- package/dist/client/nodes/destroy.d.ts +3 -4
- package/dist/client/nodes/index.d.ts +2 -6
- package/dist/client/nodes/query.d.ts +3 -5
- package/dist/client/nodes/update.d.ts +4 -4
- package/dist/client/triggers/collection.d.ts +3 -4
- package/dist/client/triggers/index.d.ts +2 -11
- package/dist/client/triggers/schedule/index.d.ts +3 -4
- package/dist/client/utils.d.ts +1 -0
- package/dist/externalVersion.js +11 -13
- package/dist/locale/{en-US.js → en-US.json} +41 -94
- package/dist/locale/es-ES.json +98 -0
- package/dist/locale/fr-FR.json +98 -0
- package/dist/locale/ja-JP.json +82 -0
- package/dist/locale/pt-BR.json +98 -0
- package/dist/locale/ru-RU.json +82 -0
- package/dist/locale/tr-TR.json +82 -0
- package/dist/locale/zh-CN.json +176 -0
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.d.ts +12 -2
- package/dist/server/Plugin.js +31 -7
- package/dist/server/Processor.d.ts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/instructions/CalculationInstruction.d.ts +15 -0
- package/dist/server/instructions/{calculation.js → CalculationInstruction.js} +13 -6
- package/dist/server/instructions/ConditionInstruction.d.ts +19 -0
- package/dist/server/instructions/{condition.js → ConditionInstruction.js} +11 -7
- package/dist/server/instructions/CreateInstruction.d.ts +10 -0
- package/dist/server/instructions/{create.js → CreateInstruction.js} +13 -6
- package/dist/server/instructions/DestroyInstruction.d.ts +10 -0
- package/dist/server/instructions/{destroy.js → DestroyInstruction.js} +13 -6
- package/dist/server/instructions/{update.d.ts → QueryInstruction.d.ts} +5 -4
- package/dist/server/instructions/{query.js → QueryInstruction.js} +13 -6
- package/dist/server/instructions/{aggregate.d.ts → UpdateInstruction.d.ts} +5 -4
- package/dist/server/instructions/{update.js → UpdateInstruction.js} +13 -6
- package/dist/server/instructions/index.d.ts +10 -14
- package/dist/server/instructions/index.js +9 -39
- package/dist/server/migrations/20231122143143-split-to-plugins.d.ts +4 -0
- package/dist/server/migrations/20231122143143-split-to-plugins.js +87 -0
- package/dist/server/triggers/{collection.d.ts → CollectionTrigger.d.ts} +1 -1
- package/dist/server/triggers/{collection.js → CollectionTrigger.js} +15 -5
- package/dist/server/triggers/{schedule.d.ts → ScheduleTrigger.d.ts} +2 -1
- package/dist/server/triggers/{schedule.js → ScheduleTrigger.js} +5 -5
- package/dist/server/triggers/index.d.ts +2 -6
- package/dist/server/triggers/index.js +1 -21
- package/package.json +3 -2
- package/dist/client/WorkflowProvider.d.ts +0 -5
- package/dist/client/components/Duration.d.ts +0 -5
- package/dist/client/components/DynamicExpression.d.ts +0 -6
- package/dist/client/components/NullRender.d.ts +0 -1
- package/dist/client/interfaces/expression.d.ts +0 -3
- package/dist/client/nodes/aggregate.d.ts +0 -196
- package/dist/client/nodes/delay.d.ts +0 -35
- package/dist/client/nodes/loop.d.ts +0 -33
- package/dist/client/nodes/manual/AssigneesSelect.d.ts +0 -6
- package/dist/client/nodes/manual/DetailsBlockProvider.d.ts +0 -2
- package/dist/client/nodes/manual/FormBlockInitializer.d.ts +0 -2
- package/dist/client/nodes/manual/FormBlockProvider.d.ts +0 -2
- package/dist/client/nodes/manual/ModeConfig.d.ts +0 -5
- package/dist/client/nodes/manual/SchemaConfig.d.ts +0 -49
- package/dist/client/nodes/manual/WorkflowTodo.d.ts +0 -5
- package/dist/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +0 -2
- package/dist/client/nodes/manual/forms/create.d.ts +0 -3
- package/dist/client/nodes/manual/forms/custom.d.ts +0 -5
- package/dist/client/nodes/manual/forms/update.d.ts +0 -3
- package/dist/client/nodes/manual/index.d.ts +0 -86
- package/dist/client/nodes/manual/utils.d.ts +0 -2
- package/dist/client/nodes/parallel.d.ts +0 -32
- package/dist/client/nodes/request.d.ts +0 -183
- package/dist/client/nodes/sql.d.ts +0 -35
- package/dist/client/triggers/form.d.ts +0 -52
- package/dist/locale/en-US.d.ts +0 -130
- package/dist/locale/es-ES.d.ts +0 -130
- package/dist/locale/es-ES.js +0 -151
- package/dist/locale/fr-FR.d.ts +0 -130
- package/dist/locale/fr-FR.js +0 -151
- package/dist/locale/ja-JP.d.ts +0 -88
- package/dist/locale/ja-JP.js +0 -109
- package/dist/locale/pt-BR.d.ts +0 -130
- package/dist/locale/pt-BR.js +0 -151
- package/dist/locale/ru-RU.d.ts +0 -88
- package/dist/locale/ru-RU.js +0 -109
- package/dist/locale/tr-TR.d.ts +0 -88
- package/dist/locale/tr-TR.js +0 -109
- package/dist/locale/zh-CN.d.ts +0 -249
- package/dist/locale/zh-CN.js +0 -270
- package/dist/server/fields/expression-field.d.ts +0 -7
- package/dist/server/fields/expression-field.js +0 -32
- package/dist/server/fields/index.d.ts +0 -1
- package/dist/server/fields/index.js +0 -28
- package/dist/server/instructions/aggregate.js +0 -54
- package/dist/server/instructions/calculation.d.ts +0 -3
- package/dist/server/instructions/condition.d.ts +0 -6
- package/dist/server/instructions/create.d.ts +0 -8
- package/dist/server/instructions/delay.d.ts +0 -15
- package/dist/server/instructions/delay.js +0 -104
- package/dist/server/instructions/destroy.d.ts +0 -8
- package/dist/server/instructions/loop.d.ts +0 -15
- package/dist/server/instructions/loop.js +0 -94
- package/dist/server/instructions/manual/actions.d.ts +0 -2
- package/dist/server/instructions/manual/actions.js +0 -94
- package/dist/server/instructions/manual/collecions/jobs.d.ts +0 -19
- package/dist/server/instructions/manual/collecions/jobs.js +0 -39
- package/dist/server/instructions/manual/collecions/users.d.ts +0 -15
- package/dist/server/instructions/manual/collecions/users.js +0 -37
- package/dist/server/instructions/manual/collecions/users_jobs.d.ts +0 -3
- package/dist/server/instructions/manual/collecions/users_jobs.js +0 -70
- package/dist/server/instructions/manual/forms/create.d.ts +0 -5
- package/dist/server/instructions/manual/forms/create.js +0 -41
- package/dist/server/instructions/manual/forms/index.d.ts +0 -6
- package/dist/server/instructions/manual/forms/index.js +0 -38
- package/dist/server/instructions/manual/forms/update.d.ts +0 -6
- package/dist/server/instructions/manual/forms/update.js +0 -41
- package/dist/server/instructions/manual/index.d.ts +0 -29
- package/dist/server/instructions/manual/index.js +0 -179
- package/dist/server/instructions/parallel.d.ts +0 -12
- package/dist/server/instructions/parallel.js +0 -124
- package/dist/server/instructions/query.d.ts +0 -9
- package/dist/server/instructions/request.d.ts +0 -18
- package/dist/server/instructions/request.js +0 -92
- package/dist/server/instructions/sql.d.ts +0 -12
- package/dist/server/instructions/sql.js +0 -43
- package/dist/server/triggers/form.d.ts +0 -11
- package/dist/server/triggers/form.js +0 -116
|
@@ -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":"2023-12-
|
|
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":"2023-12-12T06:32:41.574Z"}
|
package/dist/server/Plugin.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { Registry } from '@nocobase/utils';
|
|
|
3
3
|
import { Logger } from '@nocobase/logger';
|
|
4
4
|
import Processor from './Processor';
|
|
5
5
|
import { CustomFunction } from './functions';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import type Trigger from './triggers';
|
|
7
|
+
import type Instruction from './instructions';
|
|
8
8
|
import type { ExecutionModel, WorkflowModel } from './types';
|
|
9
9
|
type ID = number | string;
|
|
10
10
|
export default class WorkflowPlugin extends Plugin {
|
|
@@ -18,6 +18,16 @@ export default class WorkflowPlugin extends Plugin {
|
|
|
18
18
|
private loggerCache;
|
|
19
19
|
getLogger(workflowId: ID): Logger;
|
|
20
20
|
onBeforeSave: (instance: WorkflowModel, options: any) => Promise<void>;
|
|
21
|
+
initTriggers<T extends Trigger>(more?: {
|
|
22
|
+
[key: string]: T | {
|
|
23
|
+
new (p: Plugin): T;
|
|
24
|
+
};
|
|
25
|
+
}): void;
|
|
26
|
+
initInstructions<T extends Instruction>(more?: {
|
|
27
|
+
[key: string]: T | {
|
|
28
|
+
new (p: Plugin): T;
|
|
29
|
+
};
|
|
30
|
+
}): void;
|
|
21
31
|
load(): Promise<void>;
|
|
22
32
|
toggle(workflow: WorkflowModel, enable?: boolean): void;
|
|
23
33
|
trigger(workflow: WorkflowModel, context: object, options?: {
|
package/dist/server/Plugin.js
CHANGED
|
@@ -40,10 +40,15 @@ var import_logger = require("@nocobase/logger");
|
|
|
40
40
|
var import_Processor = __toESM(require("./Processor"));
|
|
41
41
|
var import_actions = __toESM(require("./actions"));
|
|
42
42
|
var import_constants = require("./constants");
|
|
43
|
-
var import_fields = __toESM(require("./fields"));
|
|
44
43
|
var import_functions = __toESM(require("./functions"));
|
|
45
|
-
var
|
|
46
|
-
var
|
|
44
|
+
var import_CollectionTrigger = __toESM(require("./triggers/CollectionTrigger"));
|
|
45
|
+
var import_ScheduleTrigger = __toESM(require("./triggers/ScheduleTrigger"));
|
|
46
|
+
var import_CalculationInstruction = __toESM(require("./instructions/CalculationInstruction"));
|
|
47
|
+
var import_ConditionInstruction = __toESM(require("./instructions/ConditionInstruction"));
|
|
48
|
+
var import_CreateInstruction = __toESM(require("./instructions/CreateInstruction"));
|
|
49
|
+
var import_DestroyInstruction = __toESM(require("./instructions/DestroyInstruction"));
|
|
50
|
+
var import_QueryInstruction = __toESM(require("./instructions/QueryInstruction"));
|
|
51
|
+
var import_UpdateInstruction = __toESM(require("./instructions/UpdateInstruction"));
|
|
47
52
|
class WorkflowPlugin extends import_server.Plugin {
|
|
48
53
|
instructions = new import_utils.Registry();
|
|
49
54
|
triggers = new import_utils.Registry();
|
|
@@ -62,7 +67,7 @@ class WorkflowPlugin extends import_server.Plugin {
|
|
|
62
67
|
}
|
|
63
68
|
const logger = (0, import_logger.createLogger)({
|
|
64
69
|
transports: [
|
|
65
|
-
"console",
|
|
70
|
+
...process.env.NODE_ENV !== "production" ? ["console"] : [],
|
|
66
71
|
new import_winston.default.transports.File({
|
|
67
72
|
filename: (0, import_logger.getLoggerFilePath)("workflows", date, `${workflowId}.log`),
|
|
68
73
|
level: (0, import_logger.getLoggerLevel)()
|
|
@@ -111,12 +116,31 @@ class WorkflowPlugin extends import_server.Plugin {
|
|
|
111
116
|
this.toggle(previous, false);
|
|
112
117
|
}
|
|
113
118
|
};
|
|
119
|
+
initTriggers(more = {}) {
|
|
120
|
+
const { triggers } = this;
|
|
121
|
+
triggers.register("collection", new import_CollectionTrigger.default(this));
|
|
122
|
+
triggers.register("schedule", new import_ScheduleTrigger.default(this));
|
|
123
|
+
for (const [name, trigger] of Object.entries(more)) {
|
|
124
|
+
triggers.register(name, typeof trigger === "function" ? new trigger(this) : trigger);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
initInstructions(more = {}) {
|
|
128
|
+
const { instructions } = this;
|
|
129
|
+
instructions.register("calculation", new import_CalculationInstruction.default(this));
|
|
130
|
+
instructions.register("condition", new import_ConditionInstruction.default(this));
|
|
131
|
+
instructions.register("create", new import_CreateInstruction.default(this));
|
|
132
|
+
instructions.register("destroy", new import_DestroyInstruction.default(this));
|
|
133
|
+
instructions.register("query", new import_QueryInstruction.default(this));
|
|
134
|
+
instructions.register("update", new import_UpdateInstruction.default(this));
|
|
135
|
+
for (const [name, instruction] of Object.entries({ ...more })) {
|
|
136
|
+
instructions.register(name, typeof instruction === "function" ? new instruction(this) : instruction);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
114
139
|
async load() {
|
|
115
140
|
const { db, options } = this;
|
|
116
|
-
(0, import_fields.default)(this);
|
|
117
141
|
(0, import_actions.default)(this);
|
|
118
|
-
|
|
119
|
-
|
|
142
|
+
this.initTriggers(options.triggers);
|
|
143
|
+
this.initInstructions(options.instructions);
|
|
120
144
|
(0, import_functions.default)(this, options.functions);
|
|
121
145
|
this.loggerCache = new import_lru_cache.default({
|
|
122
146
|
max: 20,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transaction, Transactionable } from '@nocobase/database';
|
|
2
2
|
import { Logger } from '@nocobase/logger';
|
|
3
|
-
import Plugin from '
|
|
3
|
+
import type Plugin from './Plugin';
|
|
4
4
|
import type { ExecutionModel, FlowNodeModel, JobModel } from './types';
|
|
5
5
|
export interface ProcessorOptions extends Transactionable {
|
|
6
6
|
plugin: Plugin;
|
package/dist/server/index.d.ts
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(server_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(server_exports);
|
|
36
36
|
__reExport(server_exports, require("./utils"), module.exports);
|
|
37
37
|
__reExport(server_exports, require("./constants"), module.exports);
|
|
38
|
+
__reExport(server_exports, require("./instructions"), module.exports);
|
|
38
39
|
var import_triggers = require("./triggers");
|
|
39
40
|
var import_Processor = __toESM(require("./Processor"));
|
|
40
41
|
var import_Plugin = __toESM(require("./Plugin"));
|
|
@@ -45,5 +46,6 @@ __reExport(server_exports, require("./types"), module.exports);
|
|
|
45
46
|
Trigger,
|
|
46
47
|
...require("./utils"),
|
|
47
48
|
...require("./constants"),
|
|
49
|
+
...require("./instructions"),
|
|
48
50
|
...require("./types")
|
|
49
51
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Instruction } from '.';
|
|
2
|
+
import type Processor from '../Processor';
|
|
3
|
+
import type { FlowNodeModel } from '../types';
|
|
4
|
+
export interface CalculationConfig {
|
|
5
|
+
dynamic?: boolean | string;
|
|
6
|
+
engine?: string;
|
|
7
|
+
expression?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class CalculationInstruction extends Instruction {
|
|
10
|
+
run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<{
|
|
11
|
+
result: any;
|
|
12
|
+
status: number;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export default CalculationInstruction;
|
|
@@ -15,15 +15,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
20
|
-
|
|
18
|
+
var CalculationInstruction_exports = {};
|
|
19
|
+
__export(CalculationInstruction_exports, {
|
|
20
|
+
CalculationInstruction: () => CalculationInstruction,
|
|
21
|
+
default: () => CalculationInstruction_default
|
|
21
22
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(CalculationInstruction_exports);
|
|
23
24
|
var import_evaluators = require("@nocobase/evaluators");
|
|
24
25
|
var import_utils = require("@nocobase/utils");
|
|
26
|
+
var import__ = require(".");
|
|
25
27
|
var import_constants = require("../constants");
|
|
26
|
-
|
|
28
|
+
class CalculationInstruction extends import__.Instruction {
|
|
27
29
|
async run(node, prevJob, processor) {
|
|
28
30
|
const { dynamic = false } = node.config || {};
|
|
29
31
|
let { engine = "math.js", expression = "" } = node.config;
|
|
@@ -48,4 +50,9 @@ var calculation_default = {
|
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
}
|
|
53
|
+
}
|
|
54
|
+
var CalculationInstruction_default = CalculationInstruction;
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
CalculationInstruction
|
|
58
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Registry } from '@nocobase/utils';
|
|
2
|
+
import { Instruction } from '.';
|
|
3
|
+
import type Processor from '../Processor';
|
|
4
|
+
import type { FlowNodeModel, JobModel } from '../types';
|
|
5
|
+
type Comparer = (a: any, b: any) => boolean;
|
|
6
|
+
export declare const calculators: Registry<Comparer>;
|
|
7
|
+
export declare class ConditionInstruction extends Instruction {
|
|
8
|
+
run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<{
|
|
9
|
+
status: number;
|
|
10
|
+
result: boolean;
|
|
11
|
+
nodeId: number;
|
|
12
|
+
upstreamId: any;
|
|
13
|
+
} | {
|
|
14
|
+
result: any;
|
|
15
|
+
status: number;
|
|
16
|
+
}>;
|
|
17
|
+
resume(node: FlowNodeModel, branchJob: JobModel, processor: Processor): Promise<any>;
|
|
18
|
+
}
|
|
19
|
+
export default ConditionInstruction;
|
|
@@ -15,14 +15,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
18
|
+
var ConditionInstruction_exports = {};
|
|
19
|
+
__export(ConditionInstruction_exports, {
|
|
20
|
+
ConditionInstruction: () => ConditionInstruction,
|
|
20
21
|
calculators: () => calculators,
|
|
21
|
-
default: () =>
|
|
22
|
+
default: () => ConditionInstruction_default
|
|
22
23
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(ConditionInstruction_exports);
|
|
24
25
|
var import_evaluators = require("@nocobase/evaluators");
|
|
25
26
|
var import_utils = require("@nocobase/utils");
|
|
27
|
+
var import__ = require(".");
|
|
26
28
|
var import_constants = require("../constants");
|
|
27
29
|
const calculators = new import_utils.Registry();
|
|
28
30
|
function equal(a, b) {
|
|
@@ -96,7 +98,7 @@ function logicCalculate(calculation) {
|
|
|
96
98
|
}
|
|
97
99
|
return calculate(calculation);
|
|
98
100
|
}
|
|
99
|
-
|
|
101
|
+
class ConditionInstruction extends import__.Instruction {
|
|
100
102
|
async run(node, prevJob, processor) {
|
|
101
103
|
const { engine, calculation, expression, rejectOnFalse } = node.config || {};
|
|
102
104
|
const evaluator = import_evaluators.evaluators.get(engine);
|
|
@@ -131,7 +133,7 @@ var condition_default = {
|
|
|
131
133
|
const savedJob = await processor.saveJob(job);
|
|
132
134
|
await processor.run(branchNode, savedJob);
|
|
133
135
|
return null;
|
|
134
|
-
}
|
|
136
|
+
}
|
|
135
137
|
async resume(node, branchJob, processor) {
|
|
136
138
|
const job = processor.findBranchParentJob(branchJob, node);
|
|
137
139
|
if (branchJob.status === import_constants.JOB_STATUS.RESOLVED) {
|
|
@@ -139,8 +141,10 @@ var condition_default = {
|
|
|
139
141
|
}
|
|
140
142
|
return processor.exit(branchJob.status);
|
|
141
143
|
}
|
|
142
|
-
}
|
|
144
|
+
}
|
|
145
|
+
var ConditionInstruction_default = ConditionInstruction;
|
|
143
146
|
// Annotate the CommonJS export names for ESM import in node:
|
|
144
147
|
0 && (module.exports = {
|
|
148
|
+
ConditionInstruction,
|
|
145
149
|
calculators
|
|
146
150
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type Processor from '../Processor';
|
|
2
|
+
import type { FlowNodeModel } from '../types';
|
|
3
|
+
import { Instruction } from '.';
|
|
4
|
+
export declare class CreateInstruction extends Instruction {
|
|
5
|
+
run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
|
|
6
|
+
result: object;
|
|
7
|
+
status: number;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export default CreateInstruction;
|
|
@@ -15,14 +15,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
20
|
-
|
|
18
|
+
var CreateInstruction_exports = {};
|
|
19
|
+
__export(CreateInstruction_exports, {
|
|
20
|
+
CreateInstruction: () => CreateInstruction,
|
|
21
|
+
default: () => CreateInstruction_default
|
|
21
22
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(CreateInstruction_exports);
|
|
23
24
|
var import_constants = require("../constants");
|
|
24
25
|
var import_utils = require("../utils");
|
|
25
|
-
var
|
|
26
|
+
var import__ = require(".");
|
|
27
|
+
class CreateInstruction extends import__.Instruction {
|
|
26
28
|
async run(node, input, processor) {
|
|
27
29
|
const { collection, params: { appends = [], ...params } = {} } = node.config;
|
|
28
30
|
const { repository, model } = node.constructor.database.getCollection(collection);
|
|
@@ -53,4 +55,9 @@ var create_default = {
|
|
|
53
55
|
status: import_constants.JOB_STATUS.RESOLVED
|
|
54
56
|
};
|
|
55
57
|
}
|
|
56
|
-
}
|
|
58
|
+
}
|
|
59
|
+
var CreateInstruction_default = CreateInstruction;
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
CreateInstruction
|
|
63
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Instruction } from '.';
|
|
2
|
+
import type Processor from '../Processor';
|
|
3
|
+
import type { FlowNodeModel } from '../types';
|
|
4
|
+
export declare class DestroyInstruction extends Instruction {
|
|
5
|
+
run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
|
|
6
|
+
result: any;
|
|
7
|
+
status: number;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export default DestroyInstruction;
|
|
@@ -15,13 +15,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
20
|
-
|
|
18
|
+
var DestroyInstruction_exports = {};
|
|
19
|
+
__export(DestroyInstruction_exports, {
|
|
20
|
+
DestroyInstruction: () => DestroyInstruction,
|
|
21
|
+
default: () => DestroyInstruction_default
|
|
21
22
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(DestroyInstruction_exports);
|
|
24
|
+
var import__ = require(".");
|
|
23
25
|
var import_constants = require("../constants");
|
|
24
|
-
|
|
26
|
+
class DestroyInstruction extends import__.Instruction {
|
|
25
27
|
async run(node, input, processor) {
|
|
26
28
|
const { collection, params = {} } = node.config;
|
|
27
29
|
const repo = node.constructor.database.getRepository(collection);
|
|
@@ -38,4 +40,9 @@ var destroy_default = {
|
|
|
38
40
|
status: import_constants.JOB_STATUS.RESOLVED
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
|
-
}
|
|
43
|
+
}
|
|
44
|
+
var DestroyInstruction_default = DestroyInstruction;
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
DestroyInstruction
|
|
48
|
+
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import Processor from '../Processor';
|
|
1
|
+
import type Processor from '../Processor';
|
|
2
2
|
import type { FlowNodeModel } from '../types';
|
|
3
|
-
|
|
3
|
+
import { Instruction } from '.';
|
|
4
|
+
export declare class QueryInstruction extends Instruction {
|
|
4
5
|
run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
|
|
5
6
|
result: any;
|
|
6
7
|
status: number;
|
|
7
8
|
}>;
|
|
8
|
-
}
|
|
9
|
-
export default
|
|
9
|
+
}
|
|
10
|
+
export default QueryInstruction;
|
|
@@ -15,15 +15,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
20
|
-
|
|
18
|
+
var QueryInstruction_exports = {};
|
|
19
|
+
__export(QueryInstruction_exports, {
|
|
20
|
+
QueryInstruction: () => QueryInstruction,
|
|
21
|
+
default: () => QueryInstruction_default
|
|
21
22
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(QueryInstruction_exports);
|
|
23
24
|
var import_actions = require("@nocobase/actions");
|
|
24
25
|
var import_constants = require("../constants");
|
|
25
26
|
var import_utils = require("../utils");
|
|
26
|
-
var
|
|
27
|
+
var import__ = require(".");
|
|
28
|
+
class QueryInstruction extends import__.Instruction {
|
|
27
29
|
async run(node, input, processor) {
|
|
28
30
|
const { collection, multiple, params = {}, failOnEmpty = false } = node.config;
|
|
29
31
|
const repo = node.constructor.database.getRepository(collection);
|
|
@@ -61,4 +63,9 @@ var query_default = {
|
|
|
61
63
|
status: import_constants.JOB_STATUS.RESOLVED
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
|
-
}
|
|
66
|
+
}
|
|
67
|
+
var QueryInstruction_default = QueryInstruction;
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
QueryInstruction
|
|
71
|
+
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import Processor from '../Processor';
|
|
1
|
+
import type Processor from '../Processor';
|
|
2
2
|
import type { FlowNodeModel } from '../types';
|
|
3
|
-
|
|
3
|
+
import { Instruction } from '.';
|
|
4
|
+
export declare class UpdateInstruction extends Instruction {
|
|
4
5
|
run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
|
|
5
6
|
result: any;
|
|
6
7
|
status: number;
|
|
7
8
|
}>;
|
|
8
|
-
}
|
|
9
|
-
export default
|
|
9
|
+
}
|
|
10
|
+
export default UpdateInstruction;
|
|
@@ -15,13 +15,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
20
|
-
|
|
18
|
+
var UpdateInstruction_exports = {};
|
|
19
|
+
__export(UpdateInstruction_exports, {
|
|
20
|
+
UpdateInstruction: () => UpdateInstruction,
|
|
21
|
+
default: () => UpdateInstruction_default
|
|
21
22
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(UpdateInstruction_exports);
|
|
23
24
|
var import_constants = require("../constants");
|
|
24
|
-
var
|
|
25
|
+
var import__ = require(".");
|
|
26
|
+
class UpdateInstruction extends import__.Instruction {
|
|
25
27
|
async run(node, input, processor) {
|
|
26
28
|
const { collection, params = {} } = node.config;
|
|
27
29
|
const repo = node.constructor.database.getRepository(collection);
|
|
@@ -38,4 +40,9 @@ var update_default = {
|
|
|
38
40
|
status: import_constants.JOB_STATUS.RESOLVED
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
|
-
}
|
|
43
|
+
}
|
|
44
|
+
var UpdateInstruction_default = UpdateInstruction;
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
UpdateInstruction
|
|
48
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transactionable } from '@nocobase/database';
|
|
2
|
-
import Plugin from '
|
|
3
|
-
import Processor from '../Processor';
|
|
2
|
+
import type Plugin from '../Plugin';
|
|
3
|
+
import type Processor from '../Processor';
|
|
4
4
|
import type { FlowNodeModel } from '../types';
|
|
5
5
|
export interface IJob {
|
|
6
6
|
status: number;
|
|
@@ -9,16 +9,12 @@ export interface IJob {
|
|
|
9
9
|
}
|
|
10
10
|
export type InstructionResult = IJob | Promise<IJob> | null;
|
|
11
11
|
export type Runner = (node: FlowNodeModel, input: any, processor: Processor) => InstructionResult;
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
export declare abstract class Instruction {
|
|
13
|
+
plugin: Plugin;
|
|
14
|
+
constructor(plugin: Plugin);
|
|
15
|
+
abstract run(node: FlowNodeModel, input: any, processor: Processor): InstructionResult;
|
|
16
|
+
resume?(node: FlowNodeModel, input: any, processor: Processor): InstructionResult;
|
|
17
|
+
getScope?(node: FlowNodeModel, data: any, processor: Processor): any;
|
|
18
|
+
duplicateConfig?(node: FlowNodeModel, options: Transactionable): object | Promise<object>;
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
new (p: Plugin): T;
|
|
20
|
-
};
|
|
21
|
-
export default function <T extends Instruction>(plugin: any, more?: {
|
|
22
|
-
[key: string]: T | InstructionConstructor<T>;
|
|
23
|
-
}): void;
|
|
24
|
-
export {};
|
|
20
|
+
export default Instruction;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,48 +14,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
var instructions_exports = {};
|
|
29
19
|
__export(instructions_exports, {
|
|
20
|
+
Instruction: () => Instruction,
|
|
30
21
|
default: () => instructions_default
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(instructions_exports);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const { instructions } = plugin;
|
|
37
|
-
const natives = [
|
|
38
|
-
"calculation",
|
|
39
|
-
"condition",
|
|
40
|
-
"parallel",
|
|
41
|
-
"loop",
|
|
42
|
-
"delay",
|
|
43
|
-
"manual",
|
|
44
|
-
"query",
|
|
45
|
-
"create",
|
|
46
|
-
"update",
|
|
47
|
-
"destroy",
|
|
48
|
-
"aggregate",
|
|
49
|
-
"request",
|
|
50
|
-
"sql"
|
|
51
|
-
].reduce(
|
|
52
|
-
(result, key) => Object.assign(result, {
|
|
53
|
-
[key]: (0, import_utils.requireModule)(import_path.default.isAbsolute(key) ? key : import_path.default.join(__dirname, key))
|
|
54
|
-
}),
|
|
55
|
-
{}
|
|
56
|
-
);
|
|
57
|
-
for (const [name, instruction] of Object.entries({ ...more, ...natives })) {
|
|
58
|
-
instructions.register(
|
|
59
|
-
name,
|
|
60
|
-
typeof instruction === "function" ? new instruction(plugin) : instruction
|
|
61
|
-
);
|
|
24
|
+
class Instruction {
|
|
25
|
+
constructor(plugin) {
|
|
26
|
+
this.plugin = plugin;
|
|
62
27
|
}
|
|
63
28
|
}
|
|
29
|
+
var instructions_default = Instruction;
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
Instruction
|
|
33
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var split_to_plugins_exports = {};
|
|
19
|
+
__export(split_to_plugins_exports, {
|
|
20
|
+
default: () => split_to_plugins_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(split_to_plugins_exports);
|
|
23
|
+
var import_server = require("@nocobase/server");
|
|
24
|
+
class split_to_plugins_default extends import_server.Migration {
|
|
25
|
+
async up() {
|
|
26
|
+
const match = await this.app.version.satisfies("<0.17.0-alpha.4");
|
|
27
|
+
if (!match) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const { db } = this.context;
|
|
31
|
+
const PluginModel = db.getModel("applicationPlugins");
|
|
32
|
+
const NodeRepo = db.getRepository("flow_nodes");
|
|
33
|
+
await db.sequelize.transaction(async (transaction) => {
|
|
34
|
+
await [
|
|
35
|
+
"@nocobase/plugin-workflow-aggregate",
|
|
36
|
+
"@nocobase/plugin-workflow-delay",
|
|
37
|
+
"@nocobase/plugin-workflow-dynamic-calculation",
|
|
38
|
+
"@nocobase/plugin-workflow-loop",
|
|
39
|
+
"@nocobase/plugin-workflow-manual",
|
|
40
|
+
"@nocobase/plugin-workflow-parallel",
|
|
41
|
+
"@nocobase/plugin-workflow-request",
|
|
42
|
+
"@nocobase/plugin-workflow-sql",
|
|
43
|
+
"@nocobase/plugin-workflow-form-trigger"
|
|
44
|
+
].reduce(
|
|
45
|
+
(promise, packageName) => promise.then(async () => {
|
|
46
|
+
const existed = await PluginModel.findOne({ where: { packageName }, transaction });
|
|
47
|
+
if (!existed) {
|
|
48
|
+
await PluginModel.create(
|
|
49
|
+
{
|
|
50
|
+
name: packageName,
|
|
51
|
+
packageName,
|
|
52
|
+
version: "0.17.0-alpha.1",
|
|
53
|
+
enabled: true,
|
|
54
|
+
installed: true,
|
|
55
|
+
builtin: true
|
|
56
|
+
},
|
|
57
|
+
{ transaction }
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
Promise.resolve()
|
|
62
|
+
);
|
|
63
|
+
const nodes = await NodeRepo.find({
|
|
64
|
+
transaction
|
|
65
|
+
});
|
|
66
|
+
await nodes.reduce(
|
|
67
|
+
(promise, node) => promise.then(() => {
|
|
68
|
+
if (node.type === "calculation" && node.config.dynamic) {
|
|
69
|
+
node.set({
|
|
70
|
+
type: "dynamic-calculation",
|
|
71
|
+
config: {
|
|
72
|
+
expression: node.config.dynamic,
|
|
73
|
+
scope: node.config.scope
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
node.changed("config", true);
|
|
77
|
+
}
|
|
78
|
+
return node.save({
|
|
79
|
+
silent: true,
|
|
80
|
+
transaction
|
|
81
|
+
});
|
|
82
|
+
}),
|
|
83
|
+
Promise.resolve()
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|