@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,31 +1,15 @@
|
|
|
1
|
-
{%
|
|
1
|
+
{% import "src/default/types/block.js.njk" as block with context %}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
{% call block.header() %}
|
|
4
|
+
{% endcall %}
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
{% call block.definition() %}
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{% include "src/default/macros/block-entry-args.js.njk" %}
|
|
8
|
+
const raise = {{context.transform.raise | safe}};
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
10
|
+
reject(new Error(raise?.message||raise||"Unknown error"));
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const raise = {{context.transform.raise | safe}};
|
|
12
|
+
{% endcall %}
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{% include "src/default/macros/block-signal.js.njk" %}
|
|
21
|
-
|
|
22
|
-
onError? onError(new Error(raise?.message||raise||"Unknown error")) : reject(new Error(raise?.message||raise||"Unknown error"));
|
|
23
|
-
|
|
24
|
-
{% include "src/default/macros/block-run-footer.js.njk" %}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Object.freeze(this);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
{% include "src/default/macros/block-footer.js.njk" %}
|
|
14
|
+
{% call block.footer()%}
|
|
15
|
+
{% endcall %}
|
|
@@ -1,94 +1,70 @@
|
|
|
1
|
-
{%
|
|
2
|
-
|
|
3
|
-
{%
|
|
4
|
-
|
|
5
|
-
{%
|
|
6
|
-
|
|
7
|
-
{%
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{%
|
|
12
|
-
{%
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
// Execute child block
|
|
49
|
-
await retryableBlock.run();
|
|
50
|
-
|
|
51
|
-
// Success! Break out of retry loop
|
|
52
|
-
break;
|
|
53
|
-
} catch (error) {
|
|
54
|
-
lastError = error;
|
|
55
|
-
|
|
56
|
-
// Last attempt failed - throw error
|
|
57
|
-
if (attempt === attempts) {
|
|
58
|
-
throw new Error(`Retry failed after ${attempts} attempts: ${error.message}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Wait before retry
|
|
62
|
-
await new Promise(resolve => setTimeout(resolve, currentDelay));
|
|
1
|
+
{% set resolve=true %}
|
|
2
|
+
|
|
3
|
+
{% import "src/default/types/block.js.njk" as block with context %}
|
|
4
|
+
|
|
5
|
+
{% call block.header() %}
|
|
6
|
+
{% for child in childs %}
|
|
7
|
+
{% if not child.definition.dynamic %}
|
|
8
|
+
// RETRYABLE CHILD: {{child.indexKey}}
|
|
9
|
+
import {{child.codeKey}} from "./{{child.codeKey}}.js";
|
|
10
|
+
{% endif %}
|
|
11
|
+
{% endfor %}
|
|
12
|
+
{% endcall %}
|
|
13
|
+
|
|
14
|
+
{% call block.definition() %}
|
|
15
|
+
// Retry configuration (always an object)
|
|
16
|
+
const attempts = {{ context.transform.retry.attempts }};
|
|
17
|
+
const initialDelay = {{ context.transform.retry.delay }};
|
|
18
|
+
const backoff = "{{ context.transform.retry.backoff }}";
|
|
19
|
+
const maxDelay = {% if context.transform.retry.maxDelay %}{{ context.transform.retry.maxDelay }}{% else %}null{% endif %};
|
|
20
|
+
|
|
21
|
+
{% if childs[0] %}
|
|
22
|
+
// Create child block instance
|
|
23
|
+
const retryableBlock = new {{childs[0].codeKey}}({
|
|
24
|
+
parent: _this,
|
|
25
|
+
engine: engine,
|
|
26
|
+
flow: flow
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Retry logic with backoff
|
|
30
|
+
let lastError;
|
|
31
|
+
let currentDelay = initialDelay;
|
|
32
|
+
|
|
33
|
+
for (let attempt = 1; attempt <= attempts; attempt++) {
|
|
34
|
+
try {
|
|
35
|
+
// Execute child block
|
|
36
|
+
await retryableBlock.run();
|
|
37
|
+
|
|
38
|
+
// Success! Break out of retry loop
|
|
39
|
+
break;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
lastError = error;
|
|
42
|
+
|
|
43
|
+
// Last attempt failed - throw error
|
|
44
|
+
if (attempt === attempts) {
|
|
45
|
+
throw new Error(`Retry failed after ${attempts} attempts: ${error.message}`);
|
|
46
|
+
}
|
|
63
47
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
currentDelay = currentDelay * 2;
|
|
67
|
-
} else if (backoff === 'linear') {
|
|
68
|
-
currentDelay = currentDelay + initialDelay;
|
|
69
|
-
}
|
|
70
|
-
// 'fixed' keeps currentDelay unchanged
|
|
48
|
+
// Wait before retry
|
|
49
|
+
await new Promise(resolve => setTimeout(resolve, currentDelay));
|
|
71
50
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
} catch (err) {
|
|
79
|
-
if (onError) {
|
|
80
|
-
return onError(err);
|
|
81
|
-
}
|
|
82
|
-
throw err;
|
|
51
|
+
// Calculate next delay based on backoff strategy
|
|
52
|
+
if (backoff === 'exponential') {
|
|
53
|
+
currentDelay = currentDelay * 2;
|
|
54
|
+
} else if (backoff === 'linear') {
|
|
55
|
+
currentDelay = currentDelay + initialDelay;
|
|
83
56
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
57
|
+
// 'fixed' keeps currentDelay unchanged
|
|
87
58
|
|
|
88
|
-
|
|
89
|
-
|
|
59
|
+
// Apply maxDelay cap if specified
|
|
60
|
+
if (maxDelay && currentDelay > maxDelay) {
|
|
61
|
+
currentDelay = maxDelay;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
90
64
|
}
|
|
91
|
-
}
|
|
65
|
+
{% endif %}
|
|
92
66
|
|
|
93
|
-
{%
|
|
67
|
+
{% endcall %}
|
|
94
68
|
|
|
69
|
+
{% call block.footer()%}
|
|
70
|
+
{% endcall %}
|
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
{%
|
|
1
|
+
{% import "src/default/types/block.js.njk" as block with context %}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
{% call block.header() %}
|
|
4
|
+
{% endcall %}
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
{% call block.definition() %}
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
{% include "src/default/macros/block-assign.js.njk" %}
|
|
9
|
+
|
|
10
|
+
{% include "src/default/macros/block-signal.js.njk" %}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
12
|
+
const value = {{context.transform.return | safe}};
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const value = {{context.transform.return | safe}};
|
|
14
|
+
flow.result={value: value};
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{% include "src/default/macros/block-signal.js.njk" %}
|
|
16
|
+
resolve({type:'return',value: value});
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
{% endcall %}
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{% include "src/default/macros/block-run-footer.js.njk" %}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
Object.freeze(this);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
{% include "src/default/macros/block-footer.js.njk" %}
|
|
20
|
+
{% call block.footer()%}
|
|
21
|
+
{% endcall %}
|
|
@@ -1,83 +1,66 @@
|
|
|
1
|
-
{%
|
|
2
|
-
|
|
3
|
-
{%
|
|
1
|
+
{% set resolve=true %}
|
|
2
|
+
|
|
3
|
+
{% import "src/default/types/block.js.njk" as block with context %}
|
|
4
|
+
|
|
5
|
+
{% call block.header() %}
|
|
6
|
+
{% for child in childs %}
|
|
7
|
+
{% if not child.definition.dynamic %}
|
|
8
|
+
// SCHEDULED CHILD: {{child.indexKey}}
|
|
9
|
+
import {{child.codeKey}} from "./{{child.codeKey}}.js";
|
|
10
|
+
{% endif %}
|
|
11
|
+
{% endfor %}
|
|
12
|
+
{% endcall %}
|
|
13
|
+
|
|
14
|
+
{% call block.definition() %}
|
|
15
|
+
// Import node-cron for scheduling
|
|
16
|
+
const cron = await import('node-cron');
|
|
17
|
+
|
|
18
|
+
// Schedule configuration
|
|
19
|
+
const cronExpression = {{ context.transform.schedule.cron | safe }};
|
|
20
|
+
const timezone = {{ context.transform.schedule.timezone | dump | safe }};
|
|
21
|
+
const enabled = {{ context.transform.schedule.enabled | dump | safe }};
|
|
22
|
+
|
|
23
|
+
// Check if schedule is enabled
|
|
24
|
+
if (!enabled) {
|
|
25
|
+
// Schedule is disabled, skip to next block
|
|
26
|
+
{% include "src/default/macros/block-next.js.njk" %}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
4
29
|
|
|
5
|
-
|
|
30
|
+
// Validate cron expression
|
|
31
|
+
if (!cron.validate(cronExpression)) {
|
|
32
|
+
reject(new Error(`Invalid cron expression: ${cronExpression}`));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
6
35
|
|
|
7
|
-
|
|
8
|
-
{% if
|
|
9
|
-
|
|
10
|
-
|
|
36
|
+
// Get child block (the scheduled task)
|
|
37
|
+
{% if childs[0] %}
|
|
38
|
+
const scheduledTask = new {{childs[0].codeKey}}({
|
|
39
|
+
parent: _this,
|
|
40
|
+
engine: engine,
|
|
41
|
+
flow: flow
|
|
42
|
+
});
|
|
11
43
|
{% endif %}
|
|
12
|
-
{% endfor %}
|
|
13
|
-
|
|
14
|
-
export default function Block(context){
|
|
15
|
-
|
|
16
|
-
{% include "src/default/macros/block-body-header.js.njk" %}
|
|
17
|
-
|
|
18
|
-
this.run= function (){
|
|
19
|
-
|
|
20
|
-
{% include "src/default/macros/block-entry-args.js.njk" %}
|
|
21
|
-
|
|
22
|
-
return new Promise(async (resolve,reject)=>{
|
|
23
|
-
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
24
|
-
|
|
25
|
-
{% include "src/default/macros/page.js.njk" %}
|
|
26
44
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const cronExpression = {{ context.transform.schedule.cron | safe }};
|
|
32
|
-
const timezone = {{ context.transform.schedule.timezone | dump | safe }};
|
|
33
|
-
const enabled = {{ context.transform.schedule.enabled | dump | safe }};
|
|
34
|
-
|
|
35
|
-
// Check if schedule is enabled
|
|
36
|
-
if (!enabled) {
|
|
37
|
-
// Schedule is disabled, skip to next block
|
|
38
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Validate cron expression
|
|
43
|
-
if (!cron.validate(cronExpression)) {
|
|
44
|
-
reject(new Error(`Invalid cron expression: ${cronExpression}`));
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Get child block (the scheduled task)
|
|
45
|
+
// Schedule the task with optional timezone
|
|
46
|
+
const scheduleOptions = timezone ? { timezone } : {};
|
|
47
|
+
const task = cron.schedule(cronExpression, async () => {
|
|
48
|
+
try {
|
|
49
49
|
{% if childs[0] %}
|
|
50
|
-
|
|
51
|
-
parent: _this,
|
|
52
|
-
engine: engine,
|
|
53
|
-
flow: flow
|
|
54
|
-
});
|
|
50
|
+
await scheduledTask.run();
|
|
55
51
|
{% endif %}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(`Scheduled task '{{indexKey}}' failed:`, error);
|
|
54
|
+
}
|
|
55
|
+
}, scheduleOptions);
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const task = cron.schedule(cronExpression, async () => {
|
|
60
|
-
try {
|
|
61
|
-
{% if childs[0] %}
|
|
62
|
-
await scheduledTask.run();
|
|
63
|
-
{% endif %}
|
|
64
|
-
} catch (error) {
|
|
65
|
-
console.error(`Scheduled task '{{indexKey}}' failed:`, error);
|
|
66
|
-
}
|
|
67
|
-
}, scheduleOptions);
|
|
57
|
+
// Start the scheduled task
|
|
58
|
+
task.start();
|
|
68
59
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Store task reference for potential cleanup
|
|
73
|
-
flow.set('{{indexKey}}_task', task);
|
|
74
|
-
|
|
75
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
76
|
-
|
|
77
|
-
{% include "src/default/macros/block-run-footer.js.njk" %}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
60
|
+
// Store task reference for potential cleanup
|
|
61
|
+
flow.set('{{indexKey}}_task', task);
|
|
81
62
|
|
|
82
|
-
{%
|
|
63
|
+
{% endcall %}
|
|
83
64
|
|
|
65
|
+
{% call block.footer()%}
|
|
66
|
+
{% endcall %}
|
|
@@ -1,37 +1,15 @@
|
|
|
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() %}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
13
|
-
|
|
14
|
-
{% include "src/default/macros/page.js.njk" %}
|
|
12
|
+
{% endcall %}
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{% endfor%}
|
|
19
|
-
|
|
20
|
-
{% if context.transform.return %}
|
|
21
|
-
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
22
|
-
{% elseif context.next and context.transform.wait!=='next'%}
|
|
23
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
24
|
-
{% elseif not context.next%}
|
|
25
|
-
resolve();
|
|
26
|
-
{% endif %}
|
|
27
|
-
|
|
28
|
-
{% if context.transform.signal==='next' %}
|
|
29
|
-
flow.continueForNext({key:'{{indexKey}}'});
|
|
30
|
-
{% endif %}
|
|
31
|
-
|
|
32
|
-
{% include "src/default/macros/block-run-footer.js.njk" %}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
{% include "src/default/macros/block-footer.js.njk" %}
|
|
14
|
+
{% call block.footer()%}
|
|
15
|
+
{% endcall %}
|
|
@@ -1,70 +1,47 @@
|
|
|
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
|
-
|
|
10
|
+
{% call block.definition() %}
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{% include "src/default/macros/block-entry-args.js.njk" %}
|
|
12
|
+
{% if context.next %}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
14
|
+
// NEXT : {{context.next.indexKey}}
|
|
15
|
+
{% if context.next.definition.dynamic %}
|
|
16
|
+
const { default: {{context.next.codeKey}} } = await import("./{{context.next.codeKey}}.js");
|
|
17
|
+
{% endif %}
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
let current=new {{context.next.codeKey}}({ parent:_this, engine, flow, caller:c , error });
|
|
20
|
+
let currentArgs=args;
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
{% if context.next.definition.dynamic %}
|
|
21
|
-
const { default: {{context.next.codeKey}} } = await import("./{{context.next.codeKey}}.js");
|
|
22
|
-
{% endif %}
|
|
23
|
-
|
|
24
|
-
let current=new {{context.next.codeKey}}({ parent:_this, engine, flow, caller:c ,onError, error });
|
|
25
|
-
let currentArgs=args;
|
|
26
|
-
|
|
27
|
-
do {
|
|
28
|
-
|
|
29
|
-
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
30
|
-
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
31
|
-
{% endif %}
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
const nextBlock= typeof currentArgs==='undefined'? await current.run()
|
|
35
|
-
: Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
|
|
36
|
-
|
|
37
|
-
if(nextBlock?.type==='return') return resolve(nextBlock);
|
|
38
|
-
else if(nextBlock?.type!=='block') break;
|
|
39
|
-
|
|
40
|
-
if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
|
|
41
|
-
return resolve(nextBlock);
|
|
42
|
-
|
|
43
|
-
current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, onError, error });
|
|
44
|
-
currentArgs=nextBlock.input;
|
|
45
|
-
} catch (err) {
|
|
46
|
-
if (onError) {
|
|
47
|
-
return onError(err);
|
|
48
|
-
}
|
|
49
|
-
throw err;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
} while(true);
|
|
22
|
+
do {
|
|
53
23
|
|
|
24
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
25
|
+
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
54
26
|
{% endif %}
|
|
55
27
|
|
|
28
|
+
const nextBlock= typeof currentArgs==='undefined'? await current.run()
|
|
29
|
+
: Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
|
|
30
|
+
|
|
31
|
+
if(nextBlock?.type==='return') return resolve(nextBlock);
|
|
32
|
+
else if(nextBlock?.type!=='block') break;
|
|
56
33
|
|
|
57
|
-
|
|
34
|
+
if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
|
|
35
|
+
return resolve(nextBlock);
|
|
58
36
|
|
|
59
|
-
{
|
|
37
|
+
current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, error });
|
|
38
|
+
currentArgs=nextBlock.input;
|
|
60
39
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{% include "src/default/macros/block-run-footer.js.njk" %}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
40
|
+
} while(true);
|
|
66
41
|
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
{% endif %}
|
|
43
|
+
|
|
44
|
+
{% endcall %}
|
|
69
45
|
|
|
70
|
-
{%
|
|
46
|
+
{% call block.footer()%}
|
|
47
|
+
{% endcall %}
|
|
@@ -1,86 +1,49 @@
|
|
|
1
|
-
{%
|
|
1
|
+
{% set assign=true %}
|
|
2
|
+
{% set signal=true %}
|
|
3
|
+
{% set resolve=true %}
|
|
2
4
|
|
|
3
|
-
{%
|
|
4
|
-
{% include "src/default/macros/block-next-header.js.njk" %}
|
|
5
|
-
{% endif %}
|
|
5
|
+
{% import "src/default/types/block.js.njk" as block with context %}
|
|
6
6
|
|
|
7
|
-
{%
|
|
7
|
+
{% call block.header() %}
|
|
8
8
|
|
|
9
|
-
{% for child in childs %}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{% endfor%}
|
|
9
|
+
{% for child in childs %}
|
|
10
|
+
{% if not child.definition.dynamic %}
|
|
11
|
+
// CHILD: {{child.indexKey}}
|
|
12
|
+
import {{child.codeKey}} from "./{{child.codeKey}}.js";
|
|
13
|
+
{% endif %}
|
|
14
|
+
{% endfor%}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
{% endcall %}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
{% call block.definition() %}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{%
|
|
27
|
-
|
|
28
|
-
{%
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{% else %}
|
|
36
|
-
{%if child.context.transform.condition %}
|
|
37
|
-
else if ({{child.context.transform.condition | safe}})
|
|
38
|
-
{% else %}
|
|
39
|
-
else
|
|
40
|
-
{% endif %}
|
|
41
|
-
{% endif %}
|
|
42
|
-
{
|
|
43
|
-
{% if child.definition.dynamic %}
|
|
44
|
-
// CHILD: {{child.indexKey}}
|
|
45
|
-
const { default: {{child.codeKey}} } = await import("./{{child.codeKey}}.js");
|
|
46
|
-
{% endif %}
|
|
47
|
-
|
|
48
|
-
const current=new {{child.codeKey}}({ parent:_this, engine, flow, caller:c, onError });
|
|
49
|
-
|
|
50
|
-
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
51
|
-
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
52
|
-
{% endif %}
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
return resolve(Array.isArray(args)? await current.run.apply(current,args) : await current.run.call(current,args));
|
|
56
|
-
} catch (err) {
|
|
57
|
-
if (onError) {
|
|
58
|
-
return onError(err);
|
|
59
|
-
}
|
|
60
|
-
throw err;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
{% endfor%}
|
|
64
|
-
|
|
65
|
-
{% include "src/default/macros/block-assign.js.njk" %}
|
|
20
|
+
{% for child in childs %}
|
|
21
|
+
{% if loop.first %}
|
|
22
|
+
if ({{child.context.transform.condition | safe}})
|
|
23
|
+
{% else %}
|
|
24
|
+
{%if child.context.transform.condition %}
|
|
25
|
+
else if ({{child.context.transform.condition | safe}})
|
|
26
|
+
{% else %}
|
|
27
|
+
else
|
|
28
|
+
{% endif %}
|
|
29
|
+
{% endif %}
|
|
30
|
+
{
|
|
31
|
+
{% if child.definition.dynamic %}
|
|
32
|
+
// CHILD: {{child.indexKey}}
|
|
33
|
+
const { default: {{child.codeKey}} } = await import("./{{child.codeKey}}.js");
|
|
34
|
+
{% endif %}
|
|
66
35
|
|
|
67
|
-
|
|
36
|
+
const current=new {{child.codeKey}}({ parent:_this, engine, flow, caller:c, error });
|
|
68
37
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
72
|
-
{% elseif context.next %}
|
|
73
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
74
|
-
{% else %}
|
|
75
|
-
resolve();
|
|
38
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
39
|
+
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
76
40
|
{% endif %}
|
|
77
|
-
{% endif %}
|
|
78
41
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
42
|
+
return resolve(Array.isArray(args)? await current.run.apply(current,args) : await current.run.call(current,args));
|
|
43
|
+
}
|
|
44
|
+
{% endfor%}
|
|
82
45
|
|
|
83
|
-
|
|
84
|
-
}
|
|
46
|
+
{% endcall %}
|
|
85
47
|
|
|
86
|
-
{%
|
|
48
|
+
{% call block.footer()%}
|
|
49
|
+
{% endcall %}
|