@fnet/cli 0.3.15 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fnet/index.js +9 -9
- package/dist/fnode/{index.hd9ty41n.js → index.937tt8st.js} +1 -1
- package/dist/fnode/index.js +1 -1
- 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
|
@@ -1,74 +1,80 @@
|
|
|
1
|
+
{% set assign=true %}
|
|
2
|
+
{% set signal=true %}
|
|
3
|
+
{% set resolve=true %}
|
|
1
4
|
|
|
2
|
-
{%
|
|
5
|
+
{% import "src/default/types/block.js.njk" as block with context %}
|
|
3
6
|
|
|
4
|
-
{
|
|
7
|
+
{% call block.header() %}
|
|
8
|
+
{% for child in childs %}
|
|
9
|
+
{% if not child.definition.dynamic %}
|
|
10
|
+
// CHILD: {{child.indexKey}}
|
|
11
|
+
import {{child.codeKey}} from "./{{child.codeKey}}.js";
|
|
12
|
+
{% endif %}
|
|
13
|
+
{% endfor%}
|
|
14
|
+
{% endcall %}
|
|
5
15
|
|
|
6
|
-
{%
|
|
16
|
+
{% call block.definition() %}
|
|
17
|
+
|
|
18
|
+
try{
|
|
7
19
|
|
|
8
|
-
{%
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import {{child.codeKey}} from "./{{child.codeKey}}.js";
|
|
12
|
-
{% endif %}
|
|
13
|
-
{% endfor%}
|
|
20
|
+
{% if context.try.definition.dynamic %}
|
|
21
|
+
const { default: {{context.try.codeKey}} } = await import("./{{context.try.codeKey}}.js");
|
|
22
|
+
{% endif %}
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
let current=new {{context.try.codeKey}}({ parent:_this, engine, flow, caller:c, error });
|
|
25
|
+
let currentArgs=args;
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
do {
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
30
|
+
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
31
|
+
{% endif %}
|
|
22
32
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
33
|
+
const nextBlock= typeof currentArgs==='undefined'? await current.run()
|
|
34
|
+
: Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
if(nextBlock?.type==='return') return resolve(nextBlock);
|
|
37
|
+
else if(nextBlock?.type!=='block') break;
|
|
28
38
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
try{
|
|
32
|
-
|
|
33
|
-
const onError=error=>{
|
|
34
|
-
{% if context.except.definition.dynamic %}
|
|
35
|
-
const { default: {{context.except.codeKey}} } = await import("./{{context.except.codeKey}}.js");
|
|
36
|
-
{% endif %}
|
|
39
|
+
if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
|
|
40
|
+
return resolve(nextBlock);
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, error });
|
|
43
|
+
currentArgs=nextBlock.input;
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
} while(true);
|
|
46
|
+
}
|
|
47
|
+
catch(error){
|
|
48
|
+
|
|
49
|
+
{% if context.except.definition.dynamic %}
|
|
50
|
+
const { default: {{context.except.codeKey}} } = await import("./{{context.except.codeKey}}.js");
|
|
51
|
+
{% endif %}
|
|
52
|
+
|
|
53
|
+
let current=new {{context.except.codeKey}}({ parent:_this, engine, flow, caller:c , error });
|
|
54
|
+
let currentArgs=args;
|
|
43
55
|
|
|
44
|
-
|
|
45
|
-
};
|
|
56
|
+
do {
|
|
46
57
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const current=new {{context.try.codeKey}}({ parent:_this, engine, flow, caller:c ,onError, error });
|
|
58
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
59
|
+
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
60
|
+
{% endif %}
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{% endif %}
|
|
62
|
+
const nextBlock= typeof currentArgs==='undefined'? await current.run()
|
|
63
|
+
: Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
|
|
56
64
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
catch({{context.except.context.transform.as | safe}}){
|
|
60
|
-
throw new Error('Error must not reach here!');
|
|
61
|
-
}
|
|
65
|
+
if(nextBlock?.type==='return') return resolve(nextBlock);
|
|
66
|
+
else if(nextBlock?.type!=='block') break;
|
|
62
67
|
|
|
63
|
-
|
|
68
|
+
if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
|
|
69
|
+
return resolve(nextBlock);
|
|
64
70
|
|
|
65
|
-
|
|
71
|
+
current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, error });
|
|
72
|
+
currentArgs=nextBlock.input;
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
});
|
|
74
|
+
} while(true);
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
}
|
|
77
|
+
{% endcall %}
|
|
73
78
|
|
|
74
|
-
{%
|
|
79
|
+
{% call block.footer()%}
|
|
80
|
+
{% endcall %}
|
|
@@ -1,34 +1,14 @@
|
|
|
1
|
-
{%
|
|
1
|
+
{% set assign=true %}
|
|
2
|
+
{% set signal=true %}
|
|
3
|
+
{% set resolve=true %}
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
{% import "src/default/types/block.js.njk" as block with context %}
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
{% call block.header() %}
|
|
8
|
+
{% endcall %}
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{% include "src/default/macros/block-entry-args.js.njk" %}
|
|
10
|
+
{% call block.definition() %}
|
|
11
|
+
{% endcall %}
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{% include "src/default/macros/page.js.njk" %}
|
|
15
|
-
|
|
16
|
-
{% if context.next and context.transform.wait==='next' %}
|
|
17
|
-
flow.waitForNext({
|
|
18
|
-
key:'{{indexKey}}',
|
|
19
|
-
next: async () => {
|
|
20
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
{% endif %}
|
|
24
|
-
|
|
25
|
-
{% for assign in context.transform.assign %}
|
|
26
|
-
flow.set({{assign.key | safe}},{{assign.value | safe}});
|
|
27
|
-
{% endfor%}
|
|
28
|
-
|
|
29
|
-
{% include "src/default/macros/block-run-footer.js.njk" %}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
{% include "src/default/macros/block-footer.js.njk" %}
|
|
13
|
+
{% call block.footer()%}
|
|
14
|
+
{% endcall %}
|
|
@@ -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);
|