@fnet/cli 0.3.14 → 0.4.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/dist/fnet/index.js +12 -12
- package/package.json +1 -1
- package/template/fnet/node/src/default/blocks/assign.js.njk +10 -48
- package/template/fnet/node/src/default/blocks/call.js.njk +110 -156
- package/template/fnet/node/src/default/blocks/for.js.njk +59 -95
- package/template/fnet/node/src/default/blocks/form.js.njk +21 -59
- package/template/fnet/node/src/default/blocks/http.js.njk +125 -147
- package/template/fnet/node/src/default/blocks/modules.js.njk +10 -52
- package/template/fnet/node/src/default/blocks/new.js.njk +40 -85
- package/template/fnet/node/src/default/blocks/next.js.njk +10 -32
- package/template/fnet/node/src/default/blocks/output.js.njk +10 -48
- package/template/fnet/node/src/default/blocks/parallel.js.njk +60 -106
- package/template/fnet/node/src/default/blocks/pipeline.js.njk +100 -137
- package/template/fnet/node/src/default/blocks/raise.js.njk +9 -25
- package/template/fnet/node/src/default/blocks/retry.js.njk +63 -87
- package/template/fnet/node/src/default/blocks/return.js.njk +13 -25
- package/template/fnet/node/src/default/blocks/schedule.js.njk +56 -73
- package/template/fnet/node/src/default/blocks/signal.js.njk +10 -32
- package/template/fnet/node/src/default/blocks/steps.js.njk +32 -55
- package/template/fnet/node/src/default/blocks/switch.js.njk +37 -74
- package/template/fnet/node/src/default/blocks/tryexcept.js.njk +58 -52
- package/template/fnet/node/src/default/blocks/wait.js.njk +10 -30
- package/template/fnet/node/src/default/macros/block-body-header.js.njk +1 -1
- package/template/fnet/node/src/default/macros/block-next.js.njk +0 -1
- package/template/fnet/node/src/default/types/block.js.njk +133 -0
- package/template/fnet/node/src/default/workflow.js.njk +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
{% macro header() %}
|
|
2
|
+
|
|
3
|
+
{% include "src/default/macros/block-header.js.njk" %}
|
|
4
|
+
|
|
5
|
+
{% include "src/default/macros/block-next-header.js.njk" %}
|
|
6
|
+
|
|
7
|
+
{% include "src/default/macros/block-modules-header.js.njk" %}
|
|
8
|
+
|
|
9
|
+
{{ caller() }}
|
|
10
|
+
|
|
11
|
+
{% endmacro %}
|
|
12
|
+
|
|
13
|
+
{% macro definition() %}
|
|
14
|
+
|
|
15
|
+
export default function Block(context){
|
|
16
|
+
|
|
17
|
+
{% include "src/default/macros/block-body-header.js.njk" %}
|
|
18
|
+
|
|
19
|
+
this.run= function (){
|
|
20
|
+
|
|
21
|
+
{% include "src/default/macros/block-entry-args.js.njk" %}
|
|
22
|
+
|
|
23
|
+
return new Promise((resolve,reject)=>{
|
|
24
|
+
|
|
25
|
+
(async () => {
|
|
26
|
+
try{
|
|
27
|
+
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
28
|
+
|
|
29
|
+
{% include "src/default/macros/page.js.njk" %}
|
|
30
|
+
|
|
31
|
+
{% include "src/default/macros/block-modules.js.njk" %}
|
|
32
|
+
|
|
33
|
+
{% if (context.next and context.transform.wait==='next') or waitForNext === true %}
|
|
34
|
+
flow.waitForNext({
|
|
35
|
+
key:'{{indexKey}}',
|
|
36
|
+
next: async () => {
|
|
37
|
+
{% if context.transform.return %}
|
|
38
|
+
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
39
|
+
{% elseif context.next %}
|
|
40
|
+
{% include "src/default/macros/block-next.js.njk" %}
|
|
41
|
+
{% else %}
|
|
42
|
+
resolve();
|
|
43
|
+
{% endif %}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
{% endif %}
|
|
47
|
+
|
|
48
|
+
{{ caller() }}
|
|
49
|
+
|
|
50
|
+
{% if result === true %}
|
|
51
|
+
{% for assign in context.transform.result %}
|
|
52
|
+
flow.set({{assign.key | safe}},{{assign.value | safe}});
|
|
53
|
+
{% endfor%}
|
|
54
|
+
{% endif %}
|
|
55
|
+
|
|
56
|
+
{% if assign === true %}
|
|
57
|
+
{% include "src/default/macros/block-assign.js.njk" %}
|
|
58
|
+
{% endif %}
|
|
59
|
+
|
|
60
|
+
{% if signal === true %}
|
|
61
|
+
{% include "src/default/macros/block-signal.js.njk" %}
|
|
62
|
+
{% endif %}
|
|
63
|
+
|
|
64
|
+
{% if resolve === true %}
|
|
65
|
+
{% if context.transform.return %}
|
|
66
|
+
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
67
|
+
{% elseif context.next and context.transform.wait!=='next'%}
|
|
68
|
+
{% include "src/default/macros/block-next.js.njk" %}
|
|
69
|
+
{% elseif not context.next%}
|
|
70
|
+
resolve();
|
|
71
|
+
{% endif %}
|
|
72
|
+
{% endif %}
|
|
73
|
+
|
|
74
|
+
{% include "src/default/macros/block-run-footer.js.njk" %}
|
|
75
|
+
}
|
|
76
|
+
catch(error){
|
|
77
|
+
reject(error);
|
|
78
|
+
}
|
|
79
|
+
})();
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Object.freeze(this);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
{% endmacro %}
|
|
87
|
+
|
|
88
|
+
{% macro footer() %}
|
|
89
|
+
{% include "src/default/macros/block-footer.js.njk" %}
|
|
90
|
+
{{ caller() }}
|
|
91
|
+
{% endmacro %}
|
|
92
|
+
|
|
93
|
+
{% macro runner({ step: null }) %}
|
|
94
|
+
{% if step.definition.dynamic %}
|
|
95
|
+
const { default: {{step.codeKey}} } = await import("./{{step.codeKey}}.js");
|
|
96
|
+
{% endif %}
|
|
97
|
+
|
|
98
|
+
let current=new {{step.codeKey}}({ parent:_this, engine, flow, caller:c, error });
|
|
99
|
+
let currentArgs=args;
|
|
100
|
+
|
|
101
|
+
do {
|
|
102
|
+
|
|
103
|
+
const nextBlock= typeof currentArgs==='undefined'? await current.run()
|
|
104
|
+
: Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
|
|
105
|
+
|
|
106
|
+
if(nextBlock?.type==='return') return resolve(nextBlock);
|
|
107
|
+
else if(nextBlock?.type!=='block') break;
|
|
108
|
+
|
|
109
|
+
if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
|
|
110
|
+
return resolve(nextBlock);
|
|
111
|
+
|
|
112
|
+
current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, error });
|
|
113
|
+
currentArgs=nextBlock.input;
|
|
114
|
+
|
|
115
|
+
} while(true);
|
|
116
|
+
{% endmacro %}
|
|
117
|
+
|
|
118
|
+
{# USAGE #}
|
|
119
|
+
{#
|
|
120
|
+
|
|
121
|
+
{% import "src/default/types/block.js.njk" as block with context %}
|
|
122
|
+
|
|
123
|
+
{% call block.header() %}
|
|
124
|
+
{% endcall %}
|
|
125
|
+
|
|
126
|
+
{% call block.definition() %}
|
|
127
|
+
|
|
128
|
+
{% endcall %}
|
|
129
|
+
|
|
130
|
+
{% call block.footer()%}
|
|
131
|
+
{% endcall %}
|
|
132
|
+
|
|
133
|
+
#}
|
|
@@ -99,7 +99,7 @@ export default class Workflow extends Object {
|
|
|
99
99
|
if(nextBlock.toType.ParentTypeId!==this.constructor.TypeId)
|
|
100
100
|
throw new Error('Unknown situation');
|
|
101
101
|
|
|
102
|
-
current=new nextBlock.toType({ parent:this, engine:this.engine, flow:this, caller:c,
|
|
102
|
+
current=new nextBlock.toType({ parent:this, engine:this.engine, flow:this, caller:c, error:nextBlock.error });
|
|
103
103
|
currentArgs=nextBlock.input;
|
|
104
104
|
|
|
105
105
|
} while(true);
|