@nocobase/plugin-workflow 0.11.1-alpha.4 → 0.11.1-alpha.5
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.
|
@@ -25,10 +25,10 @@ const calculators = new (_utils().Registry)();
|
|
|
25
25
|
// built-in functions
|
|
26
26
|
exports.calculators = calculators;
|
|
27
27
|
function equal(a, b) {
|
|
28
|
-
return a
|
|
28
|
+
return a == b;
|
|
29
29
|
}
|
|
30
30
|
function notEqual(a, b) {
|
|
31
|
-
return a
|
|
31
|
+
return a != b;
|
|
32
32
|
}
|
|
33
33
|
function gt(a, b) {
|
|
34
34
|
return a > b;
|
|
@@ -48,8 +48,8 @@ calculators.register('gt', gt);
|
|
|
48
48
|
calculators.register('gte', gte);
|
|
49
49
|
calculators.register('lt', lt);
|
|
50
50
|
calculators.register('lte', lte);
|
|
51
|
-
calculators.register('
|
|
52
|
-
calculators.register('
|
|
51
|
+
calculators.register('==', equal);
|
|
52
|
+
calculators.register('!=', notEqual);
|
|
53
53
|
calculators.register('>', gt);
|
|
54
54
|
calculators.register('>=', gte);
|
|
55
55
|
calculators.register('<', lt);
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流",
|
|
5
5
|
"description": "A powerful workflow plugin designed to support business process management and automation.",
|
|
6
6
|
"description.zh-CN": "工作流插件,为业务流程管理和自动化提供支持。",
|
|
7
|
-
"version": "0.11.1-alpha.
|
|
7
|
+
"version": "0.11.1-alpha.5",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./lib/server/index.js",
|
|
10
10
|
"files": [
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@ant-design/icons": "^5.1.4",
|
|
30
|
-
"@formily/antd-v5": "1.1.0
|
|
31
|
-
"@formily/core": "2.2.
|
|
32
|
-
"@formily/react": "2.2.
|
|
30
|
+
"@formily/antd-v5": "^1.1.0",
|
|
31
|
+
"@formily/core": "^2.2.27",
|
|
32
|
+
"@formily/react": "^2.2.27",
|
|
33
33
|
"@nocobase/actions": "0.11.0-alpha.1",
|
|
34
34
|
"@nocobase/client": "0.11.0-alpha.1",
|
|
35
35
|
"@nocobase/database": "0.11.0-alpha.1",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"winston": "^3.8.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@nocobase/test": "0.11.1-alpha.
|
|
51
|
+
"@nocobase/test": "0.11.1-alpha.5",
|
|
52
52
|
"@types/ejs": "^3.1.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "1dcfd15a7d95a40b0a2f60e1de19ec574066fb20"
|
|
55
55
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Application } from '@nocobase/server';
|
|
2
1
|
import Database from '@nocobase/database';
|
|
2
|
+
import { Application } from '@nocobase/server';
|
|
3
3
|
import { getApp, sleep } from '..';
|
|
4
|
-
import {
|
|
4
|
+
import { BRANCH_INDEX, EXECUTION_STATUS } from '../../constants';
|
|
5
5
|
|
|
6
6
|
describe('workflow > instructions > condition', () => {
|
|
7
7
|
let app: Application;
|
|
@@ -243,51 +243,150 @@ describe('workflow > instructions > condition', () => {
|
|
|
243
243
|
});
|
|
244
244
|
|
|
245
245
|
describe('engines', () => {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
246
|
+
describe('basic', () => {
|
|
247
|
+
it('default as basic', async () => {
|
|
248
|
+
const n1 = await workflow.createNode({
|
|
249
|
+
title: 'condition',
|
|
250
|
+
type: 'condition',
|
|
251
|
+
config: {
|
|
252
|
+
calculation: {
|
|
253
|
+
calculator: 'equal',
|
|
254
|
+
operands: [1, '{{$context.data.read}}'],
|
|
255
|
+
},
|
|
254
256
|
},
|
|
255
|
-
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
const post = await PostRepo.create({ values: { read: 1 } });
|
|
260
|
+
|
|
261
|
+
await sleep(500);
|
|
262
|
+
|
|
263
|
+
const [execution] = await workflow.getExecutions();
|
|
264
|
+
expect(execution.status).toEqual(EXECUTION_STATUS.RESOLVED);
|
|
265
|
+
|
|
266
|
+
const [job] = await execution.getJobs();
|
|
267
|
+
expect(job.result).toEqual(true);
|
|
256
268
|
});
|
|
257
269
|
|
|
258
|
-
|
|
270
|
+
it('equal: 0 != null', async () => {
|
|
271
|
+
const n1 = await workflow.createNode({
|
|
272
|
+
title: 'condition',
|
|
273
|
+
type: 'condition',
|
|
274
|
+
config: {
|
|
275
|
+
engine: 'basic',
|
|
276
|
+
calculation: {
|
|
277
|
+
calculator: 'equal',
|
|
278
|
+
operands: [0, '{{$context.data.title}}'],
|
|
279
|
+
},
|
|
280
|
+
rejectOnFalse: false,
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const post = await PostRepo.create({ values: {} });
|
|
259
285
|
|
|
260
|
-
|
|
286
|
+
await sleep(500);
|
|
261
287
|
|
|
262
|
-
|
|
263
|
-
|
|
288
|
+
const [execution] = await workflow.getExecutions();
|
|
289
|
+
expect(execution.status).toEqual(EXECUTION_STATUS.RESOLVED);
|
|
264
290
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
291
|
+
const [job] = await execution.getJobs();
|
|
292
|
+
expect(job.result).toEqual(false);
|
|
293
|
+
});
|
|
268
294
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
295
|
+
it('equal: 0 == false', async () => {
|
|
296
|
+
const n1 = await workflow.createNode({
|
|
297
|
+
title: 'condition',
|
|
298
|
+
type: 'condition',
|
|
299
|
+
config: {
|
|
300
|
+
engine: 'basic',
|
|
301
|
+
calculation: {
|
|
302
|
+
calculator: 'equal',
|
|
303
|
+
operands: [false, '{{$context.data.read}}'],
|
|
304
|
+
},
|
|
278
305
|
},
|
|
279
|
-
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
const post = await PostRepo.create({ values: {} });
|
|
309
|
+
|
|
310
|
+
await sleep(500);
|
|
311
|
+
|
|
312
|
+
const [execution] = await workflow.getExecutions();
|
|
313
|
+
expect(execution.status).toEqual(EXECUTION_STATUS.RESOLVED);
|
|
314
|
+
|
|
315
|
+
const [job] = await execution.getJobs();
|
|
316
|
+
expect(job.result).toEqual(true);
|
|
280
317
|
});
|
|
281
318
|
|
|
282
|
-
|
|
319
|
+
it('equal: number == number', async () => {
|
|
320
|
+
const n1 = await workflow.createNode({
|
|
321
|
+
title: 'condition',
|
|
322
|
+
type: 'condition',
|
|
323
|
+
config: {
|
|
324
|
+
engine: 'basic',
|
|
325
|
+
calculation: {
|
|
326
|
+
calculator: 'equal',
|
|
327
|
+
operands: [1, '{{$context.data.read}}'],
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
});
|
|
283
331
|
|
|
284
|
-
|
|
332
|
+
const post = await PostRepo.create({ values: { read: 1 } });
|
|
285
333
|
|
|
286
|
-
|
|
287
|
-
expect(execution.status).toEqual(EXECUTION_STATUS.RESOLVED);
|
|
334
|
+
await sleep(500);
|
|
288
335
|
|
|
289
|
-
|
|
290
|
-
|
|
336
|
+
const [execution] = await workflow.getExecutions();
|
|
337
|
+
expect(execution.status).toEqual(EXECUTION_STATUS.RESOLVED);
|
|
338
|
+
|
|
339
|
+
const [job] = await execution.getJobs();
|
|
340
|
+
expect(job.result).toEqual(true);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('equal: string == number', async () => {
|
|
344
|
+
const n1 = await workflow.createNode({
|
|
345
|
+
title: 'condition',
|
|
346
|
+
type: 'condition',
|
|
347
|
+
config: {
|
|
348
|
+
engine: 'basic',
|
|
349
|
+
calculation: {
|
|
350
|
+
calculator: 'equal',
|
|
351
|
+
operands: ['1', '{{$context.data.read}}'],
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
const post = await PostRepo.create({ values: { read: 1 } });
|
|
357
|
+
|
|
358
|
+
await sleep(500);
|
|
359
|
+
|
|
360
|
+
const [execution] = await workflow.getExecutions();
|
|
361
|
+
expect(execution.status).toEqual(EXECUTION_STATUS.RESOLVED);
|
|
362
|
+
|
|
363
|
+
const [job] = await execution.getJobs();
|
|
364
|
+
expect(job.result).toEqual(true);
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it('equal: undefined == null', async () => {
|
|
368
|
+
const n1 = await workflow.createNode({
|
|
369
|
+
title: 'condition',
|
|
370
|
+
type: 'condition',
|
|
371
|
+
config: {
|
|
372
|
+
engine: 'basic',
|
|
373
|
+
calculation: {
|
|
374
|
+
calculator: 'equal',
|
|
375
|
+
operands: ['{{$context.data.category.id}}', null],
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
const post = await PostRepo.create({ values: {} });
|
|
381
|
+
|
|
382
|
+
await sleep(500);
|
|
383
|
+
|
|
384
|
+
const [execution] = await workflow.getExecutions();
|
|
385
|
+
expect(execution.status).toEqual(EXECUTION_STATUS.RESOLVED);
|
|
386
|
+
|
|
387
|
+
const [job] = await execution.getJobs();
|
|
388
|
+
expect(job.result).toEqual(true);
|
|
389
|
+
});
|
|
291
390
|
});
|
|
292
391
|
|
|
293
392
|
it('math.js', async () => {
|
|
@@ -11,11 +11,11 @@ export const calculators = new Registry<Comparer>();
|
|
|
11
11
|
|
|
12
12
|
// built-in functions
|
|
13
13
|
function equal(a, b) {
|
|
14
|
-
return a
|
|
14
|
+
return a == b;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function notEqual(a, b) {
|
|
18
|
-
return a
|
|
18
|
+
return a != b;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function gt(a, b) {
|
|
@@ -41,8 +41,8 @@ calculators.register('gte', gte);
|
|
|
41
41
|
calculators.register('lt', lt);
|
|
42
42
|
calculators.register('lte', lte);
|
|
43
43
|
|
|
44
|
-
calculators.register('
|
|
45
|
-
calculators.register('
|
|
44
|
+
calculators.register('==', equal);
|
|
45
|
+
calculators.register('!=', notEqual);
|
|
46
46
|
calculators.register('>', gt);
|
|
47
47
|
calculators.register('>=', gte);
|
|
48
48
|
calculators.register('<', lt);
|