@nocobase/plugin-workflow 0.7.0-alpha.0
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/LICENSE +201 -0
- package/esm/actions/flow_nodes.d.ts +3 -0
- package/esm/actions/flow_nodes.js +139 -0
- package/esm/actions/flow_nodes.js.map +1 -0
- package/esm/actions/index.d.ts +1 -0
- package/esm/actions/index.js +8 -0
- package/esm/actions/index.js.map +1 -0
- package/esm/calculators/index.d.ts +38 -0
- package/esm/calculators/index.js +128 -0
- package/esm/calculators/index.js.map +1 -0
- package/esm/collections/executions.d.ts +3 -0
- package/esm/collections/executions.js +38 -0
- package/esm/collections/executions.js.map +1 -0
- package/esm/collections/flow_nodes.d.ts +3 -0
- package/esm/collections/flow_nodes.js +72 -0
- package/esm/collections/flow_nodes.js.map +1 -0
- package/esm/collections/jobs.d.ts +3 -0
- package/esm/collections/jobs.js +47 -0
- package/esm/collections/jobs.js.map +1 -0
- package/esm/collections/workflows.d.ts +3 -0
- package/esm/collections/workflows.js +63 -0
- package/esm/collections/workflows.js.map +1 -0
- package/esm/constants.d.ts +17 -0
- package/esm/constants.js +18 -0
- package/esm/constants.js.map +1 -0
- package/esm/index.d.ts +5 -0
- package/esm/index.js +6 -0
- package/esm/index.js.map +1 -0
- package/esm/instructions/calculation.d.ts +8 -0
- package/esm/instructions/calculation.js +55 -0
- package/esm/instructions/calculation.js.map +1 -0
- package/esm/instructions/condition.d.ts +5 -0
- package/esm/instructions/condition.js +99 -0
- package/esm/instructions/condition.js.map +1 -0
- package/esm/instructions/create.d.ts +8 -0
- package/esm/instructions/create.js +25 -0
- package/esm/instructions/create.js.map +1 -0
- package/esm/instructions/destroy.d.ts +8 -0
- package/esm/instructions/destroy.js +25 -0
- package/esm/instructions/destroy.js.map +1 -0
- package/esm/instructions/index.d.ts +15 -0
- package/esm/instructions/index.js +20 -0
- package/esm/instructions/index.js.map +1 -0
- package/esm/instructions/parallel.d.ts +13 -0
- package/esm/instructions/parallel.js +88 -0
- package/esm/instructions/parallel.js.map +1 -0
- package/esm/instructions/prompt.d.ts +7 -0
- package/esm/instructions/prompt.js +13 -0
- package/esm/instructions/prompt.js.map +1 -0
- package/esm/instructions/query.d.ts +8 -0
- package/esm/instructions/query.js +25 -0
- package/esm/instructions/query.js.map +1 -0
- package/esm/instructions/update.d.ts +8 -0
- package/esm/instructions/update.js +25 -0
- package/esm/instructions/update.js.map +1 -0
- package/esm/models/Execution.d.ts +50 -0
- package/esm/models/Execution.js +250 -0
- package/esm/models/Execution.js.map +1 -0
- package/esm/models/FlowNode.d.ts +17 -0
- package/esm/models/FlowNode.js +4 -0
- package/esm/models/FlowNode.js.map +1 -0
- package/esm/models/Job.d.ts +15 -0
- package/esm/models/Job.js +4 -0
- package/esm/models/Job.js.map +1 -0
- package/esm/models/Workflow.d.ts +27 -0
- package/esm/models/Workflow.js +72 -0
- package/esm/models/Workflow.js.map +1 -0
- package/esm/server.d.ts +5 -0
- package/esm/server.js +62 -0
- package/esm/server.js.map +1 -0
- package/esm/triggers/index.d.ts +9 -0
- package/esm/triggers/index.js +6 -0
- package/esm/triggers/index.js.map +1 -0
- package/esm/triggers/model.d.ts +12 -0
- package/esm/triggers/model.js +47 -0
- package/esm/triggers/model.js.map +1 -0
- package/lib/actions/flow_nodes.d.ts +3 -0
- package/lib/actions/flow_nodes.js +163 -0
- package/lib/actions/flow_nodes.js.map +1 -0
- package/lib/actions/index.d.ts +1 -0
- package/lib/actions/index.js +30 -0
- package/lib/actions/index.js.map +1 -0
- package/lib/calculators/index.d.ts +38 -0
- package/lib/calculators/index.js +132 -0
- package/lib/calculators/index.js.map +1 -0
- package/lib/collections/executions.d.ts +3 -0
- package/lib/collections/executions.js +40 -0
- package/lib/collections/executions.js.map +1 -0
- package/lib/collections/flow_nodes.d.ts +3 -0
- package/lib/collections/flow_nodes.js +74 -0
- package/lib/collections/flow_nodes.js.map +1 -0
- package/lib/collections/jobs.d.ts +3 -0
- package/lib/collections/jobs.js +49 -0
- package/lib/collections/jobs.js.map +1 -0
- package/lib/collections/workflows.d.ts +3 -0
- package/lib/collections/workflows.js +65 -0
- package/lib/collections/workflows.js.map +1 -0
- package/lib/constants.d.ts +17 -0
- package/lib/constants.js +21 -0
- package/lib/constants.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +23 -0
- package/lib/index.js.map +1 -0
- package/lib/instructions/calculation.d.ts +8 -0
- package/lib/instructions/calculation.js +57 -0
- package/lib/instructions/calculation.js.map +1 -0
- package/lib/instructions/condition.d.ts +5 -0
- package/lib/instructions/condition.js +120 -0
- package/lib/instructions/condition.js.map +1 -0
- package/lib/instructions/create.d.ts +8 -0
- package/lib/instructions/create.js +27 -0
- package/lib/instructions/create.js.map +1 -0
- package/lib/instructions/destroy.d.ts +8 -0
- package/lib/instructions/destroy.js +27 -0
- package/lib/instructions/destroy.js.map +1 -0
- package/lib/instructions/index.d.ts +15 -0
- package/lib/instructions/index.js +26 -0
- package/lib/instructions/index.js.map +1 -0
- package/lib/instructions/parallel.d.ts +13 -0
- package/lib/instructions/parallel.js +91 -0
- package/lib/instructions/parallel.js.map +1 -0
- package/lib/instructions/prompt.d.ts +7 -0
- package/lib/instructions/prompt.js +15 -0
- package/lib/instructions/prompt.js.map +1 -0
- package/lib/instructions/query.d.ts +8 -0
- package/lib/instructions/query.js +27 -0
- package/lib/instructions/query.js.map +1 -0
- package/lib/instructions/update.d.ts +8 -0
- package/lib/instructions/update.js +27 -0
- package/lib/instructions/update.js.map +1 -0
- package/lib/models/Execution.d.ts +50 -0
- package/lib/models/Execution.js +256 -0
- package/lib/models/Execution.js.map +1 -0
- package/lib/models/FlowNode.d.ts +17 -0
- package/lib/models/FlowNode.js +7 -0
- package/lib/models/FlowNode.js.map +1 -0
- package/lib/models/Job.d.ts +15 -0
- package/lib/models/Job.js +7 -0
- package/lib/models/Job.js.map +1 -0
- package/lib/models/Workflow.d.ts +27 -0
- package/lib/models/Workflow.js +78 -0
- package/lib/models/Workflow.js.map +1 -0
- package/lib/server.d.ts +5 -0
- package/lib/server.js +68 -0
- package/lib/server.js.map +1 -0
- package/lib/triggers/index.d.ts +9 -0
- package/lib/triggers/index.js +12 -0
- package/lib/triggers/index.js.map +1 -0
- package/lib/triggers/model.d.ts +12 -0
- package/lib/triggers/model.js +49 -0
- package/lib/triggers/model.js.map +1 -0
- package/package.json +28 -0
- package/tsconfig.build.json +9 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/calculators/index.ts"],"names":[],"mappings":";;;AAAA,mCAA4C;AAC5C,2CAA2C;AAK9B,QAAA,WAAW,GAAG,IAAI,gBAAQ,EAAY,CAAC;AAEpD,kBAAe,mBAAW,CAAC;AA8C3B,cAAc;AACd,yCAAyC;AACzC,kDAAkD;AAClD,sDAAsD;AACtD,SAAS,GAAG,CAAC,MAAM,EAAE,IAA6B;IAChD,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAA,YAAW,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC3E,CAAC;AAED,QAAQ;AACR,sDAAsD;AACtD,gEAAgE;AAChE,8CAA8C;AAC9C,SAAgB,SAAS,CAAC,OAAgB,EAAE,OAAiB,EAAE,SAAyB;IACtF,QAAQ,OAAO,CAAC,IAAI,EAAE;QACpB,cAAc;QACd,yBAAyB;QACzB,KAAK,UAAU;YACb,OAAO,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEtD,cAAc;QACd,+BAA+B;QAC/B,KAAK,QAAQ;YACX,OAAO,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE9D,cAAc;QACd,wBAAwB;QACxB,KAAK,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AAS,EAAE,CAAS;IACpC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,WAAW,CAAC,CAAS,EAAE,CAAS;IACvC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC;AAED,mBAAW,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC3C,mBAAW,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AACjD,mBAAW,CAAC,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAC/C,mBAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;AACrD,mBAAW,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC3C,mBAAW,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAEjD,SAAS,MAAM,CAAC,CAAS,EAAE,CAAS;IAClC,OAAO,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,mBAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AAE9C,oCAAoC","sourcesContent":["import { get as getWithPath } from 'lodash';\nimport { Registry } from \"@nocobase/utils\";\n\nimport ExecutionModel from '../models/Execution';\nimport JobModel from '../models/Job';\n\nexport const calculators = new Registry<Function>();\n\nexport default calculators;\n\n\nexport type OperandType = '$context' | '$input' | '$jobsMapByNodeId' | '$calculation';\n\nexport type ObjectGetterOptions = {\n path?: string\n};\n\nexport type JobGetterOptions = ObjectGetterOptions & {\n nodeId: number\n};\n\nexport type CalculationOptions = {\n calculator: string,\n operands: Operand[]\n};\n\nexport type ConstantOperand = {\n type?: 'constant';\n value: any\n};\n\nexport type ContextOperand = {\n type: '$context';\n options: ObjectGetterOptions;\n};\n\nexport type InputOperand = {\n type: '$input';\n options: ObjectGetterOptions;\n};\n\nexport type JobOperand = {\n type: '$jobsMapByNodeId';\n options: JobGetterOptions;\n};\n\nexport type Calculation = {\n type: '$calculation';\n options: CalculationOptions\n};\n\n// TODO(type): union type here is wrong\nexport type Operand = ContextOperand | InputOperand | JobOperand | ConstantOperand | Calculation;\n\n// @deprecated\n// HACK: if no path provided, return self\n// @see https://github.com/lodash/lodash/pull/1270\n// TODO(question): should add default value as lodash?\nfunction get(object, path?: string | Array<string>) {\n return path == null || !path.length ? object : getWithPath(object, path);\n}\n\n// NOTE:\n// this method could only be used in executing nodes.\n// because type of 'job' need loaded jobs in runtime execution.\n// or the execution should be prepared first.\nexport function calculate(operand: Operand, lastJob: JobModel, execution: ExecutionModel) {\n switch (operand.type) {\n // @Deprecated\n // from execution context\n case '$context':\n return get(execution.context, operand.options.path);\n\n // @Deprecated\n // from last job (or input job)\n case '$input':\n return lastJob ?? get(lastJob.result, operand.options.path);\n\n // @Deprecated\n // from job in execution\n case '$jobsMapByNodeId':\n // assume jobs have been fetched from execution before\n const job = execution.jobsMapByNodeId[operand.options.nodeId];\n return job && get(job, operand.options.path);\n\n case '$calculation':\n const fn = calculators.get(operand.options.calculator);\n if (!fn) {\n throw new Error(`no calculator function registered for \"${operand.options.calculator}\"`);\n }\n return fn(...operand.options.operands.map(item => calculate(item, lastJob, execution)));\n\n // constant\n default:\n return operand.value;\n }\n}\n\n\n\n// built-in functions\n\nfunction equal(a, b) {\n return a === b;\n}\n\nfunction notEqual(a, b) {\n return a !== b;\n}\n\nfunction gt(a, b) {\n return a > b;\n}\n\nfunction gte(a, b) {\n return a >= b;\n}\n\nfunction lt(a, b) {\n return a < b;\n}\n\nfunction lte(a, b) {\n return a <= b;\n}\n\ncalculators.register('equal', equal);\ncalculators.register('notEqual', notEqual);\ncalculators.register('gt', gt);\ncalculators.register('gte', gte);\ncalculators.register('lt', lt);\ncalculators.register('lte', lte);\n\ncalculators.register('===', equal);\ncalculators.register('!==', notEqual);\ncalculators.register('>', gt);\ncalculators.register('>=', gte);\ncalculators.register('<', lt);\ncalculators.register('<=', lte);\n\n\n\nfunction add(...args) {\n return args.reduce((sum, a) => sum + a, 0);\n}\n\nfunction minus(a, b) {\n return a - b;\n}\n\nfunction multipe(...args) {\n return args.reduce((result, a) => result * a, 1);\n}\n\nfunction divide(a, b) {\n return a / b;\n}\n\nfunction mod(a, b) {\n return a % b;\n}\n\ncalculators.register('add', add);\ncalculators.register('minus', minus);\ncalculators.register('multipe', multipe);\ncalculators.register('divide', divide);\ncalculators.register('mod', mod);\n\ncalculators.register('+', add);\ncalculators.register('-', minus);\ncalculators.register('*', multipe);\ncalculators.register('/', divide);\ncalculators.register('%', mod);\n\nfunction includes(a, b) {\n return a.includes(b);\n}\n\nfunction notIncludes(a, b) {\n return !a.includes(b);\n}\n\nfunction startsWith(a: string, b: string) {\n return a.startsWith(b);\n}\n\nfunction notStartsWith(a: string, b: string) {\n return !a.startsWith(b);\n}\n\nfunction endsWith(a: string, b: string) {\n return a.endsWith(b);\n}\n\nfunction notEndsWith(a: string, b: string) {\n return !a.endsWith(b);\n}\n\ncalculators.register('includes', includes);\ncalculators.register('notIncludes', notIncludes);\ncalculators.register('startsWith', startsWith);\ncalculators.register('notStartsWith', notStartsWith);\ncalculators.register('endsWith', endsWith);\ncalculators.register('notEndsWith', notEndsWith);\n\nfunction before(a: string, b: string) {\n return a < b;\n}\n\ncalculators.register('now', () => new Date());\n\n// TODO: add more common calculators\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
name: 'executions',
|
|
5
|
+
model: 'ExecutionModel',
|
|
6
|
+
title: '执行流程',
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
interface: 'linkTo',
|
|
10
|
+
type: 'belongsTo',
|
|
11
|
+
name: 'workflow',
|
|
12
|
+
title: '所属工作流'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'boolean',
|
|
16
|
+
name: 'useTransaction',
|
|
17
|
+
title: '使用事务',
|
|
18
|
+
defaultValue: false
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
interface: 'linkTo',
|
|
22
|
+
type: 'hasMany',
|
|
23
|
+
name: 'jobs',
|
|
24
|
+
title: '流程记录'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
interface: 'json',
|
|
28
|
+
type: 'jsonb',
|
|
29
|
+
name: 'context',
|
|
30
|
+
title: '上下文数据'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
interface: 'select',
|
|
34
|
+
type: 'integer',
|
|
35
|
+
name: 'status',
|
|
36
|
+
title: '状态'
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=executions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executions.js","sourceRoot":"","sources":["../../src/collections/executions.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,gBAAgB;IACvB,KAAK,EAAE,MAAM;IACb,MAAM,EAAE;QACN;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE,OAAO;SACf;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,MAAM;YACb,YAAY,EAAE,KAAK;SACpB;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,MAAM;SACd;QACD;YACE,SAAS,EAAE,MAAM;YACjB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,OAAO;SACf;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,IAAI;SACZ;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'executions',\n model: 'ExecutionModel',\n title: '执行流程',\n fields: [\n {\n interface: 'linkTo',\n type: 'belongsTo',\n name: 'workflow',\n title: '所属工作流'\n },\n {\n type: 'boolean',\n name: 'useTransaction',\n title: '使用事务',\n defaultValue: false\n },\n {\n interface: 'linkTo',\n type: 'hasMany',\n name: 'jobs',\n title: '流程记录'\n },\n {\n interface: 'json',\n type: 'jsonb',\n name: 'context',\n title: '上下文数据'\n },\n {\n interface: 'select',\n type: 'integer',\n name: 'status',\n title: '状态'\n }\n ]\n} as CollectionOptions;\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
name: 'flow_nodes',
|
|
5
|
+
// model: 'FlowNodeModel',
|
|
6
|
+
title: 'Workflow Nodes',
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
interface: 'string',
|
|
10
|
+
type: 'string',
|
|
11
|
+
name: 'title',
|
|
12
|
+
title: '名称'
|
|
13
|
+
},
|
|
14
|
+
// which workflow belongs to
|
|
15
|
+
{
|
|
16
|
+
interface: 'linkTo',
|
|
17
|
+
name: 'workflow',
|
|
18
|
+
type: 'belongsTo',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
interface: 'linkTo',
|
|
22
|
+
name: 'upstream',
|
|
23
|
+
type: 'belongsTo',
|
|
24
|
+
target: 'flow_nodes'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
interface: 'linkTo',
|
|
28
|
+
name: 'branches',
|
|
29
|
+
type: 'hasMany',
|
|
30
|
+
target: 'flow_nodes',
|
|
31
|
+
sourceKey: 'id',
|
|
32
|
+
foreignKey: 'upstreamId',
|
|
33
|
+
},
|
|
34
|
+
// only works when upstream node is branching type, such as condition and parallel.
|
|
35
|
+
// put here because the design of flow-links model is not really necessary for now.
|
|
36
|
+
// or it should be put into flow-links model.
|
|
37
|
+
{
|
|
38
|
+
interface: 'select',
|
|
39
|
+
name: 'branchIndex',
|
|
40
|
+
type: 'integer',
|
|
41
|
+
title: 'branch index'
|
|
42
|
+
},
|
|
43
|
+
// for reasons:
|
|
44
|
+
// 1. redirect type node to solve cycle flow.
|
|
45
|
+
// 2. recognize as real next node after branches.
|
|
46
|
+
{
|
|
47
|
+
interface: 'linkTo',
|
|
48
|
+
name: 'downstream',
|
|
49
|
+
type: 'belongsTo',
|
|
50
|
+
target: 'flow_nodes'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
interface: 'select',
|
|
54
|
+
type: 'string',
|
|
55
|
+
name: 'type',
|
|
56
|
+
title: '类型',
|
|
57
|
+
// TODO: data for test only now
|
|
58
|
+
dataSource: [
|
|
59
|
+
{ label: '数据处理', value: 'data' },
|
|
60
|
+
{ label: '数据查询', value: 'query' },
|
|
61
|
+
{ label: '等待人工输入', value: 'prompt' },
|
|
62
|
+
{ label: '条件判断', value: 'condition' },
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
interface: 'json',
|
|
67
|
+
type: 'jsonb',
|
|
68
|
+
name: 'config',
|
|
69
|
+
title: '配置',
|
|
70
|
+
defaultValue: {}
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=flow_nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow_nodes.js","sourceRoot":"","sources":["../../src/collections/flow_nodes.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,YAAY;IAClB,0BAA0B;IAC1B,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE;QACN;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,IAAI;SACZ;Q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default {\n name: 'flow_nodes',\n // model: 'FlowNodeModel',\n title: 'Workflow Nodes',\n fields: [\n {\n interface: 'string',\n type: 'string',\n name: 'title',\n title: '名称'\n },\n // which workflow belongs to\n {\n interface: 'linkTo',\n name: 'workflow',\n type: 'belongsTo',\n },\n {\n interface: 'linkTo',\n name: 'upstream',\n type: 'belongsTo',\n target: 'flow_nodes'\n },\n {\n interface: 'linkTo',\n name: 'branches',\n type: 'hasMany',\n target: 'flow_nodes',\n sourceKey: 'id',\n foreignKey: 'upstreamId',\n },\n // only works when upstream node is branching type, such as condition and parallel.\n // put here because the design of flow-links model is not really necessary for now.\n // or it should be put into flow-links model.\n {\n interface: 'select',\n name: 'branchIndex',\n type: 'integer',\n title: 'branch index'\n },\n // for reasons:\n // 1. redirect type node to solve cycle flow.\n // 2. recognize as real next node after branches.\n {\n interface: 'linkTo',\n name: 'downstream',\n type: 'belongsTo',\n target: 'flow_nodes'\n },\n {\n interface: 'select',\n type: 'string',\n name: 'type',\n title: '类型',\n // TODO: data for test only now\n dataSource: [\n { label: '数据处理', value: 'data' },\n { label: '数据查询', value: 'query' },\n { label: '等待人工输入', value: 'prompt' },\n { label: '条件判断', value: 'condition' },\n ]\n },\n {\n interface: 'json',\n type: 'jsonb',\n name: 'config',\n title: '配置',\n defaultValue: {}\n }\n ]\n} as CollectionOptions;\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
name: 'jobs',
|
|
5
|
+
title: '流程记录',
|
|
6
|
+
fields: [
|
|
7
|
+
{
|
|
8
|
+
interface: 'linkTo',
|
|
9
|
+
type: 'belongsTo',
|
|
10
|
+
name: 'execution',
|
|
11
|
+
title: '所属流程'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
interface: 'linkTo',
|
|
15
|
+
type: 'belongsTo',
|
|
16
|
+
name: 'node',
|
|
17
|
+
target: 'flow_nodes',
|
|
18
|
+
title: '所属节点'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
interface: 'linkTo',
|
|
22
|
+
type: 'belongsTo',
|
|
23
|
+
name: 'upstream',
|
|
24
|
+
target: 'jobs',
|
|
25
|
+
title: '上游记录'
|
|
26
|
+
},
|
|
27
|
+
// pending / resolved / rejected
|
|
28
|
+
{
|
|
29
|
+
interface: 'status',
|
|
30
|
+
type: 'integer',
|
|
31
|
+
name: 'status',
|
|
32
|
+
title: '处理状态'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
interface: 'json',
|
|
36
|
+
type: 'jsonb',
|
|
37
|
+
name: 'result',
|
|
38
|
+
title: '处理结果'
|
|
39
|
+
},
|
|
40
|
+
// TODO: possibly need node snapshot in case if node has been changed
|
|
41
|
+
// {
|
|
42
|
+
// interface: 'json',
|
|
43
|
+
// type: 'jsonb',
|
|
44
|
+
// name: 'nodeSnapshot',
|
|
45
|
+
// title: 'node snapshot'
|
|
46
|
+
// }
|
|
47
|
+
]
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=jobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../src/collections/jobs.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,MAAM;IACb,MAAM,EAAE;QACN;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,MAAM;SACd;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,YAAY;YACpB,KAAK,EAAE,MAAM;SACd;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,MAAM;SACd;QACD,gCAAgC;QAChC;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;SACd;QACD;YACE,SAAS,EAAE,MAAM;YACjB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;SACd;QACD,qEAAqE;QACrE,IAAI;QACJ,uBAAuB;QACvB,mBAAmB;QACnB,0BAA0B;QAC1B,2BAA2B;QAC3B,IAAI;KACL;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'jobs',\n title: '流程记录',\n fields: [\n {\n interface: 'linkTo',\n type: 'belongsTo',\n name: 'execution',\n title: '所属流程'\n },\n {\n interface: 'linkTo',\n type: 'belongsTo',\n name: 'node',\n target: 'flow_nodes',\n title: '所属节点'\n },\n {\n interface: 'linkTo',\n type: 'belongsTo',\n name: 'upstream',\n target: 'jobs',\n title: '上游记录'\n },\n // pending / resolved / rejected\n {\n interface: 'status',\n type: 'integer',\n name: 'status',\n title: '处理状态'\n },\n {\n interface: 'json',\n type: 'jsonb',\n name: 'result',\n title: '处理结果'\n },\n // TODO: possibly need node snapshot in case if node has been changed\n // {\n // interface: 'json',\n // type: 'jsonb',\n // name: 'nodeSnapshot',\n // title: 'node snapshot'\n // }\n ]\n} as CollectionOptions;\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
name: 'workflows',
|
|
5
|
+
model: 'WorkflowModel',
|
|
6
|
+
title: '自动化',
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
interface: 'string',
|
|
10
|
+
type: 'string',
|
|
11
|
+
name: 'title',
|
|
12
|
+
title: '自动化名称',
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
interface: 'boolean',
|
|
17
|
+
type: 'boolean',
|
|
18
|
+
name: 'enabled',
|
|
19
|
+
title: '启用'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
interface: 'textarea',
|
|
23
|
+
type: 'text',
|
|
24
|
+
name: 'description',
|
|
25
|
+
title: '描述'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
interface: 'select',
|
|
29
|
+
type: 'string',
|
|
30
|
+
title: '触发方式',
|
|
31
|
+
name: 'type',
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
interface: 'json',
|
|
36
|
+
type: 'jsonb',
|
|
37
|
+
title: '触发配置',
|
|
38
|
+
name: 'config',
|
|
39
|
+
required: true,
|
|
40
|
+
defaultValue: {}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
interface: 'boolean',
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
title: '使用事务',
|
|
46
|
+
name: 'useTransaction',
|
|
47
|
+
defaultValue: true
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
interface: 'linkTo',
|
|
51
|
+
type: 'hasMany',
|
|
52
|
+
name: 'nodes',
|
|
53
|
+
target: 'flow_nodes',
|
|
54
|
+
title: '流程节点'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
interface: 'linkTo',
|
|
58
|
+
type: 'hasMany',
|
|
59
|
+
name: 'executions',
|
|
60
|
+
target: 'executions',
|
|
61
|
+
title: '触发执行'
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=workflows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflows.js","sourceRoot":"","sources":["../../src/collections/workflows.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,eAAe;IACtB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE;QACN;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,IAAI;SACf;QACD;YACE,SAAS,EAAE,SAAS;YACpB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,IAAI;SACZ;QACD;YACE,SAAS,EAAE,UAAU;YACrB,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,aAAa;YACnB,KAAK,EAAE,IAAI;SACZ;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,IAAI;SACf;QACD;YACE,SAAS,EAAE,MAAM;YACjB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,EAAE;SACjB;QACD;YACE,SAAS,EAAE,SAAS;YACpB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,gBAAgB;YACtB,YAAY,EAAE,IAAI;SACnB;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,YAAY;YACpB,KAAK,EAAE,MAAM;SACd;QACD;YACE,SAAS,EAAE,QAAQ;YACnB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,YAAY;YACpB,KAAK,EAAE,MAAM;SACd;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'workflows',\n model: 'WorkflowModel',\n title: '自动化',\n fields: [\n {\n interface: 'string',\n type: 'string',\n name: 'title',\n title: '自动化名称',\n required: true\n },\n {\n interface: 'boolean',\n type: 'boolean',\n name: 'enabled',\n title: '启用'\n },\n {\n interface: 'textarea',\n type: 'text',\n name: 'description',\n title: '描述'\n },\n {\n interface: 'select',\n type: 'string',\n title: '触发方式',\n name: 'type',\n required: true\n },\n {\n interface: 'json',\n type: 'jsonb',\n title: '触发配置',\n name: 'config',\n required: true,\n defaultValue: {}\n },\n {\n interface: 'boolean',\n type: 'boolean',\n title: '使用事务',\n name: 'useTransaction',\n defaultValue: true\n },\n {\n interface: 'linkTo',\n type: 'hasMany',\n name: 'nodes',\n target: 'flow_nodes',\n title: '流程节点'\n },\n {\n interface: 'linkTo',\n type: 'hasMany',\n name: 'executions',\n target: 'executions',\n title: '触发执行'\n }\n ]\n} as CollectionOptions;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const EXECUTION_STATUS: {
|
|
2
|
+
STARTED: number;
|
|
3
|
+
RESOLVED: number;
|
|
4
|
+
REJECTED: number;
|
|
5
|
+
CANCELLED: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const JOB_STATUS: {
|
|
8
|
+
PENDING: number;
|
|
9
|
+
RESOLVED: number;
|
|
10
|
+
REJECTED: number;
|
|
11
|
+
CANCELLED: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const BRANCH_INDEX: {
|
|
14
|
+
DEFAULT: any;
|
|
15
|
+
ON_TRUE: number;
|
|
16
|
+
ON_FALSE: number;
|
|
17
|
+
};
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BRANCH_INDEX = exports.JOB_STATUS = exports.EXECUTION_STATUS = void 0;
|
|
4
|
+
exports.EXECUTION_STATUS = {
|
|
5
|
+
STARTED: 0,
|
|
6
|
+
RESOLVED: 1,
|
|
7
|
+
REJECTED: -1,
|
|
8
|
+
CANCELLED: -2
|
|
9
|
+
};
|
|
10
|
+
exports.JOB_STATUS = {
|
|
11
|
+
PENDING: 0,
|
|
12
|
+
RESOLVED: 1,
|
|
13
|
+
REJECTED: -1,
|
|
14
|
+
CANCELLED: -2
|
|
15
|
+
};
|
|
16
|
+
exports.BRANCH_INDEX = {
|
|
17
|
+
DEFAULT: null,
|
|
18
|
+
ON_TRUE: 1,
|
|
19
|
+
ON_FALSE: 0
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG;IAC9B,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC,CAAC;IACZ,SAAS,EAAE,CAAC,CAAC;CACd,CAAC;AAEW,QAAA,UAAU,GAAG;IACxB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC,CAAC;IACZ,SAAS,EAAE,CAAC,CAAC;CACd,CAAC;AAEW,QAAA,YAAY,GAAG;IAC1B,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;CACZ,CAAC","sourcesContent":["export const EXECUTION_STATUS = {\n STARTED: 0,\n RESOLVED: 1,\n REJECTED: -1,\n CANCELLED: -2\n};\n\nexport const JOB_STATUS = {\n PENDING: 0,\n RESOLVED: 1,\n REJECTED: -1,\n CANCELLED: -2\n};\n\nexport const BRANCH_INDEX = {\n DEFAULT: null,\n ON_TRUE: 1,\n ON_FALSE: 0\n};\n"]}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.default = void 0;
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./calculators"), exports);
|
|
19
|
+
__exportStar(require("./triggers"), exports);
|
|
20
|
+
__exportStar(require("./instructions"), exports);
|
|
21
|
+
var server_1 = require("./server");
|
|
22
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(server_1).default; } });
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,gDAA8B;AAC9B,6CAA2B;AAC3B,iDAA+B;AAE/B,mCAAmC;AAA1B,kHAAA,OAAO,OAAA","sourcesContent":["export * from './constants';\nexport * from './calculators';\nexport * from './triggers';\nexport * from './instructions';\n\nexport { default } from './server';\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const constants_1 = require("../constants");
|
|
13
|
+
const calculators_1 = require("../calculators");
|
|
14
|
+
// @calculation: {
|
|
15
|
+
// calculator: 'concat',
|
|
16
|
+
// operands: [
|
|
17
|
+
// {
|
|
18
|
+
// type: 'calculation',
|
|
19
|
+
// options: {
|
|
20
|
+
// calculator: 'add',
|
|
21
|
+
// operands: [{ value: 1 }, { value: 2 }]
|
|
22
|
+
// }
|
|
23
|
+
// },
|
|
24
|
+
// {
|
|
25
|
+
// type: 'constant',
|
|
26
|
+
// value: '{{$context.data.title}}'
|
|
27
|
+
// },
|
|
28
|
+
// {
|
|
29
|
+
// type: 'context',
|
|
30
|
+
// options: {
|
|
31
|
+
// path: 'data.title'
|
|
32
|
+
// }
|
|
33
|
+
// },
|
|
34
|
+
// {
|
|
35
|
+
// type: 'constant',
|
|
36
|
+
// value: 1
|
|
37
|
+
// }
|
|
38
|
+
// ]
|
|
39
|
+
// }
|
|
40
|
+
exports.default = {
|
|
41
|
+
run(prevJob, execution) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const { calculation } = this.config || {};
|
|
44
|
+
const result = calculation
|
|
45
|
+
? (0, calculators_1.calculate)({
|
|
46
|
+
type: '$calculation',
|
|
47
|
+
options: execution.getParsedValue(calculation)
|
|
48
|
+
}, prevJob, execution)
|
|
49
|
+
: null;
|
|
50
|
+
return {
|
|
51
|
+
result,
|
|
52
|
+
status: constants_1.JOB_STATUS.RESOLVED
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=calculation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculation.js","sourceRoot":"","sources":["../../src/instructions/calculation.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4CAA0C;AAE1C,gDAA2C;AAE3C,kBAAkB;AAClB,0BAA0B;AAC1B,gBAAgB;AAChB,QAAQ;AACR,6BAA6B;AAC7B,mBAAmB;AACnB,6BAA6B;AAC7B,iDAAiD;AACjD,UAAU;AACV,SAAS;AACT,QAAQ;AACR,0BAA0B;AAC1B,yCAAyC;AACzC,SAAS;AACT,QAAQ;AACR,yBAAyB;AACzB,mBAAmB;AACnB,6BAA6B;AAC7B,UAAU;AACV,SAAS;AACT,QAAQ;AACR,0BAA0B;AAC1B,iBAAiB;AACjB,QAAQ;AACR,MAAM;AACN,IAAI;AAEJ,kBAAe;IACP,GAAG,CAAsB,OAAO,EAAE,SAAS;;YAC/C,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;YAE1C,MAAM,MAAM,GAAG,WAAW;gBACxB,CAAC,CAAC,IAAA,uBAAS,EAAC;oBACV,IAAI,EAAE,cAAc;oBACpB,OAAO,EAAE,SAAS,CAAC,cAAc,CAAC,WAAW,CAAC;iBAC/C,EAAE,OAAO,EAAE,SAAS,CAAC;gBACtB,CAAC,CAAC,IAAI,CAAC;YAET,OAAO;gBACL,MAAM;gBACN,MAAM,EAAE,sBAAU,CAAC,QAAQ;aAC5B,CAAC;QACJ,CAAC;KAAA;CACF,CAAA","sourcesContent":["import { JOB_STATUS } from \"../constants\";\nimport FlowNodeModel from \"../models/FlowNode\";\nimport { calculate } from \"../calculators\";\n\n// @calculation: {\n// calculator: 'concat',\n// operands: [\n// {\n// type: 'calculation',\n// options: {\n// calculator: 'add',\n// operands: [{ value: 1 }, { value: 2 }]\n// }\n// },\n// {\n// type: 'constant',\n// value: '{{$context.data.title}}'\n// },\n// {\n// type: 'context',\n// options: {\n// path: 'data.title'\n// }\n// },\n// {\n// type: 'constant',\n// value: 1\n// }\n// ]\n// }\n\nexport default {\n async run(this: FlowNodeModel, prevJob, execution) {\n const { calculation } = this.config || {};\n\n const result = calculation\n ? calculate({\n type: '$calculation',\n options: execution.getParsedValue(calculation)\n }, prevJob, execution)\n : null;\n\n return {\n result,\n status: JOB_STATUS.RESOLVED\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
const calculators_1 = __importStar(require("../calculators"));
|
|
32
|
+
const constants_1 = require("../constants");
|
|
33
|
+
// @calculation: {
|
|
34
|
+
// not: false,
|
|
35
|
+
// group: {
|
|
36
|
+
// type: 'and',
|
|
37
|
+
// calculations: [
|
|
38
|
+
// {
|
|
39
|
+
// calculator: 'time.equal',
|
|
40
|
+
// operands: [{ value: '{{$context.time}}' }, { value: '{{$fn.now}}' }]
|
|
41
|
+
// },
|
|
42
|
+
// {
|
|
43
|
+
// calculator: 'value.equal',
|
|
44
|
+
// operands: [{ value: '{{$jobsMapByNodeId.213}}' }, { value: 1 }]
|
|
45
|
+
// },
|
|
46
|
+
// {
|
|
47
|
+
// group: {
|
|
48
|
+
// type: 'or',
|
|
49
|
+
// calculations: [
|
|
50
|
+
// {
|
|
51
|
+
// calculator: 'value.equal',
|
|
52
|
+
// operands: [{ value: '{{$jobsMapByNodeId.213}}' }, { value: 1 }]
|
|
53
|
+
// }
|
|
54
|
+
// ]
|
|
55
|
+
// }
|
|
56
|
+
// }
|
|
57
|
+
// ]
|
|
58
|
+
// }
|
|
59
|
+
// }
|
|
60
|
+
function logicCalculate(calculation, input, execution) {
|
|
61
|
+
if (!calculation) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
const { not, group } = calculation;
|
|
65
|
+
let result;
|
|
66
|
+
if (group) {
|
|
67
|
+
const method = group.type === 'and' ? 'every' : 'some';
|
|
68
|
+
result = group.calculations[method](item => logicCalculate(item, input, execution));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const args = calculation.operands.map(operand => (0, calculators_1.calculate)(operand, input, execution));
|
|
72
|
+
const fn = calculators_1.default.get(calculation.calculator);
|
|
73
|
+
if (!fn) {
|
|
74
|
+
throw new Error(`no calculator function registered for "${calculation.calculator}"`);
|
|
75
|
+
}
|
|
76
|
+
result = fn(...args);
|
|
77
|
+
}
|
|
78
|
+
return not ? !result : result;
|
|
79
|
+
}
|
|
80
|
+
exports.default = {
|
|
81
|
+
run(prevJob, execution) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
// TODO(optimize): loading of jobs could be reduced and turned into incrementally in execution
|
|
84
|
+
// const jobs = await execution.getJobs();
|
|
85
|
+
const { calculation, rejectOnFalse } = this.config || {};
|
|
86
|
+
const result = logicCalculate(calculation, prevJob, execution);
|
|
87
|
+
if (!result && rejectOnFalse) {
|
|
88
|
+
return {
|
|
89
|
+
status: constants_1.JOB_STATUS.REJECTED,
|
|
90
|
+
result
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const job = {
|
|
94
|
+
status: constants_1.JOB_STATUS.RESOLVED,
|
|
95
|
+
result,
|
|
96
|
+
// TODO(optimize): try unify the building of job
|
|
97
|
+
nodeId: this.id,
|
|
98
|
+
upstreamId: prevJob && prevJob.id || null
|
|
99
|
+
};
|
|
100
|
+
const branchNode = execution.nodes
|
|
101
|
+
.find(item => item.upstream === this && Boolean(item.branchIndex) === result);
|
|
102
|
+
if (!branchNode) {
|
|
103
|
+
return job;
|
|
104
|
+
}
|
|
105
|
+
const savedJob = yield execution.saveJob(job);
|
|
106
|
+
return execution.run(branchNode, savedJob);
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
resume(branchJob, execution) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
if (branchJob.status === constants_1.JOB_STATUS.RESOLVED) {
|
|
112
|
+
// return to continue this.downstream
|
|
113
|
+
return branchJob;
|
|
114
|
+
}
|
|
115
|
+
// pass control to upper scope by ending current scope
|
|
116
|
+
return execution.end(this, branchJob);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../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M,KAAK,sBAAU,CAAC,QAAQ,EAAE;gBAC5C,qCAAqC;gBACrC,OAAO,SAAS,CAAC;aAClB;YAED,sDAAsD;YACtD,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;KAAA;CACF,CAAC","sourcesContent":["import calculators, { calculate, Operand } from \"../calculators\";\nimport { JOB_STATUS } from \"../constants\";\n\ntype BaseCalculation = {\n not?: boolean;\n};\n\ntype SingleCalculation = BaseCalculation & {\n calculation: string;\n operands?: Operand[];\n};\n\ntype GroupCalculationOptions = {\n type: 'and' | 'or';\n calculations: Calculation[]\n};\n\ntype GroupCalculation = BaseCalculation & {\n group: GroupCalculationOptions\n};\n\n// TODO(type)\ntype Calculation = SingleCalculation | GroupCalculation;\n\n// @calculation: {\n// not: false,\n// group: {\n// type: 'and',\n// calculations: [\n// {\n// calculator: 'time.equal',\n// operands: [{ value: '{{$context.time}}' }, { value: '{{$fn.now}}' }]\n// },\n// {\n// calculator: 'value.equal',\n// operands: [{ value: '{{$jobsMapByNodeId.213}}' }, { value: 1 }]\n// },\n// {\n// group: {\n// type: 'or',\n// calculations: [\n// {\n// calculator: 'value.equal',\n// operands: [{ value: '{{$jobsMapByNodeId.213}}' }, { value: 1 }]\n// }\n// ]\n// }\n// }\n// ]\n// }\n// }\nfunction logicCalculate(calculation, input, execution) {\n if (!calculation) {\n return true;\n }\n\n const { not, group } = calculation;\n let result;\n if (group) {\n const method = group.type === 'and' ? 'every' : 'some';\n result = group.calculations[method](item => logicCalculate(item, input, execution));\n } else {\n const args = calculation.operands.map(operand => calculate(operand, input, execution));\n const fn = calculators.get(calculation.calculator);\n if (!fn) {\n throw new Error(`no calculator function registered for \"${calculation.calculator}\"`);\n }\n result = fn(...args);\n }\n\n return not ? !result : result;\n}\n\n\nexport default {\n async run(this, prevJob, execution) {\n // TODO(optimize): loading of jobs could be reduced and turned into incrementally in execution\n // const jobs = await execution.getJobs();\n const { calculation, rejectOnFalse } = this.config || {};\n const result = logicCalculate(calculation, prevJob, execution);\n\n if (!result && rejectOnFalse) {\n return {\n status: JOB_STATUS.REJECTED,\n result\n };\n }\n\n const job = {\n status: JOB_STATUS.RESOLVED,\n result,\n // TODO(optimize): try unify the building of job\n nodeId: this.id,\n upstreamId: prevJob && prevJob.id || null\n };\n\n const branchNode = execution.nodes\n .find(item => item.upstream === this && Boolean(item.branchIndex) === result);\n\n if (!branchNode) {\n return job;\n }\n\n const savedJob = await execution.saveJob(job);\n\n return execution.run(branchNode, savedJob);\n },\n\n async resume(this, branchJob, execution) {\n if (branchJob.status === JOB_STATUS.RESOLVED) {\n // return to continue this.downstream\n return branchJob;\n }\n\n // pass control to upper scope by ending current scope\n return execution.end(this, branchJob);\n }\n};\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const constants_1 = require("../constants");
|
|
13
|
+
exports.default = {
|
|
14
|
+
run(input, execution) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
const { collection, params = {} } = this.config;
|
|
17
|
+
const repo = this.constructor.database.getRepository(collection);
|
|
18
|
+
const options = execution.getParsedValue(params);
|
|
19
|
+
const result = yield repo.create(Object.assign(Object.assign({}, options), { transaction: execution.transaction }));
|
|
20
|
+
return {
|
|
21
|
+
result,
|
|
22
|
+
status: constants_1.JOB_STATUS.RESOLVED
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=create.js.map
|