@fnet/cli 0.133.0 → 0.133.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/fbin/index.js +14 -1
- package/dist/fnet/index.0jcm9pn5.js +1 -0
- package/dist/fnet/index.2084z2ed.js +2 -0
- package/dist/fnet/index.33f1ggpr.js +1 -0
- package/dist/fnet/index.3exge2js.js +1 -0
- package/dist/fnet/index.3kfx538h.js +1 -0
- package/dist/fnet/index.490y87nc.js +1 -0
- package/dist/fnet/index.4g9yezkq.js +1 -0
- package/dist/fnet/index.4jkat7r4.js +1 -0
- package/dist/fnet/index.7crx8ky1.js +1 -0
- package/dist/fnet/index.7vw06nrn.js +1 -0
- package/dist/fnet/index.9567fa9x.js +1 -0
- package/dist/fnet/index.gh75wt1m.js +1 -0
- package/dist/fnet/index.hzsfswvp.js +1 -0
- package/dist/fnet/index.jgpc3grc.js +1 -0
- package/dist/fnet/index.js +19 -1
- package/dist/fnet/index.p0zb7e1b.js +1 -0
- package/dist/fnet/index.r19p3bpa.js +2 -0
- package/dist/fnet/index.r82rtnmz.js +1 -0
- package/dist/fnet/index.s662t98v.js +1 -0
- package/dist/fnet/index.w74dpnpn.js +1 -0
- package/dist/fnet/index.xeaw5xa9.js +1 -0
- package/dist/fnet/index.zm4kesg6.js +1 -0
- package/dist/fnode/index.05n3mvs9.js +2 -0
- package/dist/fnode/index.2hc9tbyx.js +1 -0
- package/dist/fnode/index.2pnjg6dc.js +1 -0
- package/dist/fnode/index.9qgtmxq3.js +2 -0
- package/dist/fnode/index.b1q7y05p.js +1 -0
- package/dist/fnode/index.bhapgrs7.js +1 -0
- package/dist/fnode/index.cvxrf34y.js +2 -0
- package/dist/fnode/index.dp9wyahp.js +1 -0
- package/dist/fnode/index.eqxmcpdc.js +1 -0
- package/dist/fnode/index.f2tb0x3t.js +1 -0
- package/dist/fnode/index.fbzv6wwf.js +1 -0
- package/dist/fnode/index.gazd9raq.js +1 -0
- package/dist/fnode/index.hv4s25f0.js +3 -0
- package/dist/fnode/index.j5z7dtsx.js +1 -0
- package/dist/fnode/index.js +9 -1
- package/dist/fnode/index.kb4e4bxf.js +1 -0
- package/dist/fnode/index.qn0schqp.js +1 -0
- package/dist/fnode/index.rht29phd.js +1 -0
- package/dist/fnode/index.rzsfmek6.js +3 -0
- package/dist/fnode/index.s0nk6cv8.js +4 -0
- package/dist/fnode/index.s66v6wt4.js +1 -0
- package/dist/fnode/index.sv7v0y60.js +1 -0
- package/dist/fnode/index.tgkhgnrp.js +1 -0
- package/dist/fnode/index.vq706f75.js +1 -0
- package/dist/fnode/index.y8pvdcny.js +1 -0
- package/dist/fnode/index.z4vz93ww.js +1 -0
- package/dist/frun/index.js +1 -1
- package/dist/fservice/index.js +18 -1
- package/dist/fservice/index.q01yvaz0.js +2 -0
- package/package.json +21 -18
- package/readme.md +62 -15
- package/template/fnet/core/object.js +10 -10
- package/template/fnet/node/package.json.njk +6 -3
- package/template/fnet/node/src/cli/index.js.njk +5 -315
- package/template/fnet/node/src/cli/index.js.v1.njk +318 -0
- package/template/fnet/node/src/cli/v2/core/args-parser.njk +10 -0
- package/template/fnet/node/src/cli/v2/core/imports.njk +31 -0
- package/template/fnet/node/src/cli/v2/core/run-wrapper.njk +25 -0
- package/template/fnet/node/src/cli/v2/index.js.njk +184 -0
- package/template/fnet/node/src/cli/v2/modes/default/extend.njk +11 -0
- package/template/fnet/node/src/cli/v2/modes/default/standard.njk +20 -0
- package/template/fnet/node/src/cli/v2/modes/http/builtin.njk +66 -0
- package/template/fnet/node/src/cli/v2/modes/http/imports.njk +9 -0
- package/template/fnet/node/src/cli/v2/modes/http/index.njk +12 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/imports.njk +33 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/index.njk +30 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/server-setup.njk +15 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/tool-handlers.njk +46 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/transport-http.njk +222 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/transport-stdio.njk +9 -0
- package/template/fnet/node/src/cli/v2/modes/pipeline/imports.njk +9 -0
- package/template/fnet/node/src/cli/v2/modes/pipeline/index.njk +113 -0
- package/template/fnet/node/src/cli/v2/modes/webhook/imports.njk +9 -0
- package/template/fnet/node/src/cli/v2/modes/webhook/index.njk +127 -0
- package/template/fnet/node/src/cli/v2/modes/websocket/imports.njk +15 -0
- package/template/fnet/node/src/cli/v2/modes/websocket/index.njk +104 -0
- 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 +58 -74
- package/template/fnet/node/src/default/blocks/form.js.njk +21 -59
- package/template/fnet/node/src/default/blocks/http.js.njk +135 -0
- 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 +64 -0
- package/template/fnet/node/src/default/blocks/pipeline.js.njk +109 -0
- package/template/fnet/node/src/default/blocks/raise.js.njk +9 -25
- package/template/fnet/node/src/default/blocks/retry.js.njk +70 -0
- package/template/fnet/node/src/default/blocks/return.js.njk +13 -25
- package/template/fnet/node/src/default/blocks/schedule.js.njk +66 -0
- package/template/fnet/node/src/default/blocks/signal.js.njk +10 -32
- package/template/fnet/node/src/default/blocks/steps.js.njk +32 -48
- package/template/fnet/node/src/default/blocks/switch.js.njk +37 -67
- 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/input.args.js.njk +5 -2
- package/template/fnet/node/src/default/macros/block-body-header.js.njk +1 -1
- package/template/fnet/node/src/default/macros/block-header.js.njk +0 -3
- package/template/fnet/node/src/default/macros/block-next.js.njk +1 -1
- package/template/fnet/node/src/default/macros/block-run-footer.js.njk +1 -1
- package/template/fnet/node/src/default/macros/block-run-header.js.njk +14 -2
- package/template/fnet/node/src/default/macros/page.js.njk +1 -1
- package/template/fnet/node/src/default/types/block.js.njk +133 -0
- package/template/fnet/node/src/default/workflow.js.njk +8 -6
- package/template/fnode/node/package.json.njk +5 -4
- package/template/fnode/node/src/cli/index.js.njk +3 -397
- package/template/fnode/node/src/cli/index.js.v1.njk +464 -0
- package/template/fnode/node/src/cli/v2/core/args-parser.njk +10 -0
- package/template/fnode/node/src/cli/v2/core/imports.njk +29 -0
- package/template/fnode/node/src/cli/v2/core/run-wrapper.njk +25 -0
- package/template/fnode/node/src/cli/v2/index.js.njk +184 -0
- package/template/fnode/node/src/cli/v2/modes/default/extend.njk +11 -0
- package/template/fnode/node/src/cli/v2/modes/default/standard.njk +19 -0
- package/template/fnode/node/src/cli/v2/modes/http/builtin.njk +61 -0
- package/template/fnode/node/src/cli/v2/modes/http/imports.njk +9 -0
- package/template/fnode/node/src/cli/v2/modes/http/index.njk +12 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/imports.njk +33 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/index.njk +30 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/server-setup.njk +15 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/tool-handlers.njk +41 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/transport-http.njk +212 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/transport-stdio.njk +9 -0
- package/template/fnode/node/src/cli/v2/modes/pipeline/imports.njk +9 -0
- package/template/fnode/node/src/cli/v2/modes/pipeline/index.njk +103 -0
- package/template/fnode/node/src/cli/v2/modes/webhook/imports.njk +9 -0
- package/template/fnode/node/src/cli/v2/modes/webhook/index.njk +122 -0
- package/template/fnode/node/src/cli/v2/modes/websocket/imports.njk +15 -0
- package/template/fnode/node/src/cli/v2/modes/websocket/index.njk +99 -0
- package/template/fnode/node/src/default/input.args.js.njk +6 -2
- package/dist/fnet/index.-SGbq2cI.js +0 -1
- package/dist/fnet/index.B5XE4ChJ.js +0 -1
- package/dist/fnet/index.Bft2w7m3.js +0 -1
- package/dist/fnet/index.BuYxdKtK.js +0 -1
- package/dist/fnet/index.C0YpfQ5j.js +0 -1
- package/dist/fnet/index.C2S9JYhS.js +0 -1
- package/dist/fnet/index.C7saWH6d.js +0 -1
- package/dist/fnet/index.CDct_kkF.js +0 -1
- package/dist/fnet/index.CMC8mlye.js +0 -1
- package/dist/fnet/index.CmMM-Ek9.js +0 -1
- package/dist/fnet/index.CuMyez3E.js +0 -1
- package/dist/fnet/index.CzAV0S36.js +0 -1
- package/dist/fnet/index.D2N9YZmA.js +0 -1
- package/dist/fnet/index.D3p7pncT.js +0 -1
- package/dist/fnet/index.DG8TqL-1.js +0 -1
- package/dist/fnet/index.DI3yyTtl.js +0 -1
- package/dist/fnet/index.DOYkqsYT.js +0 -1
- package/dist/fnet/index.DWpw12No.js +0 -1
- package/dist/fnet/index.DrwlOzAe.js +0 -1
- package/dist/fnet/index.Q-CYRcna.js +0 -1
- package/dist/fnet/index.W6RYgypK.js +0 -1
- package/dist/fnet/index.xd8c7XMr.js +0 -1
- package/dist/fnode/index.-SGbq2cI.js +0 -1
- package/dist/fnode/index.B5XE4ChJ.js +0 -1
- package/dist/fnode/index.B8gal9up.js +0 -1
- package/dist/fnode/index.BU1440aO.js +0 -1
- package/dist/fnode/index.BcGYSPne.js +0 -1
- package/dist/fnode/index.Bft2w7m3.js +0 -1
- package/dist/fnode/index.BuYxdKtK.js +0 -1
- package/dist/fnode/index.C2S9JYhS.js +0 -1
- package/dist/fnode/index.C7saWH6d.js +0 -1
- package/dist/fnode/index.CDct_kkF.js +0 -1
- package/dist/fnode/index.CMC8mlye.js +0 -1
- package/dist/fnode/index.CmMM-Ek9.js +0 -1
- package/dist/fnode/index.CuMyez3E.js +0 -1
- package/dist/fnode/index.CzAV0S36.js +0 -1
- package/dist/fnode/index.D2N9YZmA.js +0 -1
- package/dist/fnode/index.D3p7pncT.js +0 -1
- package/dist/fnode/index.DG8TqL-1.js +0 -1
- package/dist/fnode/index.DI3yyTtl.js +0 -1
- package/dist/fnode/index.DWpw12No.js +0 -1
- package/dist/fnode/index.DrwlOzAe.js +0 -1
- package/dist/fnode/index.N_a5FdgA.js +0 -1
- package/dist/fnode/index.Q-CYRcna.js +0 -1
- package/dist/fnode/index.UNoFg95r.js +0 -1
- package/dist/fnode/index.W6RYgypK.js +0 -1
- package/dist/fnode/index.xd8c7XMr.js +0 -1
- package/template/fnet/core/print.js +0 -1
- package/template/fnet/node/src/default/macros/workflow-header.js.njk +0 -7
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{% set assign=true %}
|
|
2
|
+
{% set signal=true %}
|
|
3
|
+
{% set resolve=true %}
|
|
4
|
+
{% set result=true %}
|
|
5
|
+
|
|
6
|
+
{% import "src/default/types/block.js.njk" as block with context %}
|
|
7
|
+
|
|
8
|
+
{% call block.header() %}
|
|
9
|
+
{% endcall %}
|
|
10
|
+
|
|
11
|
+
{% call block.definition() %}
|
|
12
|
+
// PIPELINE EXECUTION
|
|
13
|
+
const { spawn } = await import('child_process');
|
|
14
|
+
|
|
15
|
+
const pipelineBinary = '{{ context.transform.binaryName }}';
|
|
16
|
+
{% if context.transform.args %}
|
|
17
|
+
const pipelineArgs = {{ context.transform.args | safe }};
|
|
18
|
+
{% else %}
|
|
19
|
+
const pipelineArgs = [];
|
|
20
|
+
{% endif %}
|
|
21
|
+
|
|
22
|
+
{% if context.transform.input %}
|
|
23
|
+
const pipelineInput = {{ context.transform.input | safe }};
|
|
24
|
+
{% else %}
|
|
25
|
+
const pipelineInput = null;
|
|
26
|
+
{% endif %}
|
|
27
|
+
|
|
28
|
+
const pipelineFormat = '{{ context.transform.format }}';
|
|
29
|
+
|
|
30
|
+
{% if context.transform.env %}
|
|
31
|
+
const pipelineEnv = {{ context.transform.env | safe }};
|
|
32
|
+
{% else %}
|
|
33
|
+
const pipelineEnv = {};
|
|
34
|
+
{% endif %}
|
|
35
|
+
|
|
36
|
+
{% if context.transform.cwd %}
|
|
37
|
+
const pipelineCwd = {{ context.transform.cwd | safe }};
|
|
38
|
+
{% else %}
|
|
39
|
+
const pipelineCwd = undefined;
|
|
40
|
+
{% endif %}
|
|
41
|
+
|
|
42
|
+
const result = await new Promise((pipelineResolve, pipelineReject) => {
|
|
43
|
+
const spawnOptions = {
|
|
44
|
+
env: { ...process.env, ...pipelineEnv },
|
|
45
|
+
stdio: ['pipe', 'pipe', 'pipe'] // stdin, stdout, stderr as pipes (don't inherit parent)
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (pipelineCwd) {
|
|
49
|
+
spawnOptions.cwd = pipelineCwd;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const proc = spawn(pipelineBinary, pipelineArgs, spawnOptions);
|
|
53
|
+
|
|
54
|
+
let stdout = '';
|
|
55
|
+
let stderr = '';
|
|
56
|
+
|
|
57
|
+
proc.stdout.on('data', (data) => {
|
|
58
|
+
stdout += data.toString();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
proc.stderr.on('data', (data) => {
|
|
62
|
+
stderr += data.toString();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
proc.on('error', (error) => {
|
|
66
|
+
pipelineReject(new Error(`Failed to execute pipeline '${pipelineBinary}': ${error.message}`));
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
proc.on('close', (code) => {
|
|
70
|
+
if (code !== 0) {
|
|
71
|
+
pipelineReject(new Error(`Pipeline '${pipelineBinary}' exited with code ${code}: ${stderr}`));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Parse output based on format
|
|
76
|
+
if (pipelineFormat === 'text') {
|
|
77
|
+
// Text format: return as-is
|
|
78
|
+
pipelineResolve(stdout.trim());
|
|
79
|
+
} else {
|
|
80
|
+
// JSON format (default): parse
|
|
81
|
+
try {
|
|
82
|
+
const result = JSON.parse(stdout.trim());
|
|
83
|
+
pipelineResolve(result);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
pipelineReject(new Error(`Failed to parse pipeline output as JSON: ${error.message}`));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Write input based on type (auto-detect)
|
|
91
|
+
if (pipelineInput !== null && pipelineInput !== undefined) {
|
|
92
|
+
if (typeof pipelineInput === 'object') {
|
|
93
|
+
// Object/Array → JSON
|
|
94
|
+
proc.stdin.write(JSON.stringify(pipelineInput) + '\n');
|
|
95
|
+
} else if (typeof pipelineInput === 'string') {
|
|
96
|
+
// String → as-is (text)
|
|
97
|
+
proc.stdin.write(pipelineInput + '\n');
|
|
98
|
+
} else {
|
|
99
|
+
// Other types → JSON
|
|
100
|
+
proc.stdin.write(JSON.stringify(pipelineInput) + '\n');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
proc.stdin.end();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
{% endcall %}
|
|
107
|
+
|
|
108
|
+
{% call block.footer()%}
|
|
109
|
+
{% endcall %}
|
|
@@ -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 %}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
}
|
|
47
|
+
|
|
48
|
+
// Wait before retry
|
|
49
|
+
await new Promise(resolve => setTimeout(resolve, currentDelay));
|
|
50
|
+
|
|
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;
|
|
56
|
+
}
|
|
57
|
+
// 'fixed' keeps currentDelay unchanged
|
|
58
|
+
|
|
59
|
+
// Apply maxDelay cap if specified
|
|
60
|
+
if (maxDelay && currentDelay > maxDelay) {
|
|
61
|
+
currentDelay = maxDelay;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
{% endif %}
|
|
66
|
+
|
|
67
|
+
{% endcall %}
|
|
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
|
-
|
|
16
|
+
resolve({type:'return',value: value});
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{% include "src/default/macros/block-signal.js.njk" %}
|
|
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 %}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
}
|
|
29
|
+
|
|
30
|
+
// Validate cron expression
|
|
31
|
+
if (!cron.validate(cronExpression)) {
|
|
32
|
+
reject(new Error(`Invalid cron expression: ${cronExpression}`));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
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
|
+
});
|
|
43
|
+
{% endif %}
|
|
44
|
+
|
|
45
|
+
// Schedule the task with optional timezone
|
|
46
|
+
const scheduleOptions = timezone ? { timezone } : {};
|
|
47
|
+
const task = cron.schedule(cronExpression, async () => {
|
|
48
|
+
try {
|
|
49
|
+
{% if childs[0] %}
|
|
50
|
+
await scheduledTask.run();
|
|
51
|
+
{% endif %}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(`Scheduled task '{{indexKey}}' failed:`, error);
|
|
54
|
+
}
|
|
55
|
+
}, scheduleOptions);
|
|
56
|
+
|
|
57
|
+
// Start the scheduled task
|
|
58
|
+
task.start();
|
|
59
|
+
|
|
60
|
+
// Store task reference for potential cleanup
|
|
61
|
+
flow.set('{{indexKey}}_task', task);
|
|
62
|
+
|
|
63
|
+
{% endcall %}
|
|
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,63 +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
|
-
const nextBlock= typeof currentArgs==='undefined'? await current.run()
|
|
34
|
-
: Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
|
|
35
|
-
|
|
36
|
-
if(nextBlock?.type==='return') return resolve(nextBlock);
|
|
37
|
-
else if(nextBlock?.type!=='block') break;
|
|
38
|
-
|
|
39
|
-
if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
|
|
40
|
-
return resolve(nextBlock);
|
|
41
|
-
|
|
42
|
-
current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, onError, error });
|
|
43
|
-
currentArgs=nextBlock.input;
|
|
44
|
-
|
|
45
|
-
} while(true);
|
|
22
|
+
do {
|
|
46
23
|
|
|
24
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
25
|
+
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
47
26
|
{% endif %}
|
|
48
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;
|
|
49
33
|
|
|
50
|
-
|
|
34
|
+
if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
|
|
35
|
+
return resolve(nextBlock);
|
|
51
36
|
|
|
52
|
-
{
|
|
37
|
+
current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, error });
|
|
38
|
+
currentArgs=nextBlock.input;
|
|
53
39
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{% include "src/default/macros/block-run-footer.js.njk" %}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
40
|
+
} while(true);
|
|
59
41
|
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
{% endif %}
|
|
43
|
+
|
|
44
|
+
{% endcall %}
|
|
62
45
|
|
|
63
|
-
{%
|
|
46
|
+
{% call block.footer()%}
|
|
47
|
+
{% endcall %}
|
|
@@ -1,79 +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
|
-
return resolve(Array.isArray(args)? await current.run.apply(current,args) : await current.run.call(current,args));
|
|
55
|
-
}
|
|
56
|
-
{% endfor%}
|
|
57
|
-
|
|
58
|
-
{% 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 %}
|
|
59
35
|
|
|
60
|
-
|
|
36
|
+
const current=new {{child.codeKey}}({ parent:_this, engine, flow, caller:c, error });
|
|
61
37
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
65
|
-
{% elseif context.next %}
|
|
66
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
67
|
-
{% else %}
|
|
68
|
-
resolve();
|
|
38
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
39
|
+
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
69
40
|
{% endif %}
|
|
70
|
-
{% endif %}
|
|
71
41
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
42
|
+
return resolve(Array.isArray(args)? await current.run.apply(current,args) : await current.run.call(current,args));
|
|
43
|
+
}
|
|
44
|
+
{% endfor%}
|
|
75
45
|
|
|
76
|
-
|
|
77
|
-
}
|
|
46
|
+
{% endcall %}
|
|
78
47
|
|
|
79
|
-
{%
|
|
48
|
+
{% call block.footer()%}
|
|
49
|
+
{% endcall %}
|