@db-lyon/flowkit 0.13.0 → 0.14.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/README.md +387 -386
- package/dist/.tsbuildinfo +1 -1
- package/dist/guard/index.d.ts +7 -0
- package/dist/guard/index.d.ts.map +1 -0
- package/dist/guard/index.js +5 -0
- package/dist/guard/index.js.map +1 -0
- package/dist/guard/pipeline.d.ts +22 -0
- package/dist/guard/pipeline.d.ts.map +1 -0
- package/dist/guard/pipeline.js +45 -0
- package/dist/guard/pipeline.js.map +1 -0
- package/dist/guard/registry.d.ts +20 -0
- package/dist/guard/registry.d.ts.map +1 -0
- package/dist/guard/registry.js +33 -0
- package/dist/guard/registry.js.map +1 -0
- package/dist/guard/task-guards.d.ts +89 -0
- package/dist/guard/task-guards.d.ts.map +1 -0
- package/dist/guard/task-guards.js +83 -0
- package/dist/guard/task-guards.js.map +1 -0
- package/dist/guard/types.d.ts +49 -0
- package/dist/guard/types.d.ts.map +1 -0
- package/dist/guard/types.js +38 -0
- package/dist/guard/types.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/docs/ai-agents.md +368 -368
- package/docs/api-reference.md +568 -458
- package/docs/configuration.md +347 -347
- package/docs/custom-tasks.md +258 -258
- package/docs/guards.md +133 -0
- package/package.json +54 -53
- package/dist/flow/references.d.ts +0 -39
- package/dist/flow/references.d.ts.map +0 -1
- package/dist/flow/references.js +0 -102
- package/dist/flow/references.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,53 +1,54 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@db-lyon/flowkit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "YAML-configured task and flow orchestration engine",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": "./dist/index.js",
|
|
10
|
-
"./config": "./dist/config/index.js",
|
|
11
|
-
"./task": "./dist/task/index.js",
|
|
12
|
-
"./flow": "./dist/flow/index.js",
|
|
13
|
-
"./dag": "./dist/dag/index.js"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"test
|
|
24
|
-
"test:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"@types/
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@db-lyon/flowkit",
|
|
3
|
+
"version": "0.14.0",
|
|
4
|
+
"description": "YAML-configured task and flow orchestration engine",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js",
|
|
10
|
+
"./config": "./dist/config/index.js",
|
|
11
|
+
"./task": "./dist/task/index.js",
|
|
12
|
+
"./flow": "./dist/flow/index.js",
|
|
13
|
+
"./dag": "./dist/dag/index.js",
|
|
14
|
+
"./guard": "./dist/guard/index.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"/dist",
|
|
18
|
+
"/docs"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -b",
|
|
22
|
+
"prepublishOnly": "tsc -b",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:package-api": "npm run build && tsc -p test/tsconfig.public-api.json",
|
|
25
|
+
"test:watch": "vitest"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"task",
|
|
29
|
+
"flow",
|
|
30
|
+
"orchestration",
|
|
31
|
+
"yaml",
|
|
32
|
+
"pipeline",
|
|
33
|
+
"engine"
|
|
34
|
+
],
|
|
35
|
+
"author": "David Lyon",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/db-lyon/flowkit.git"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"js-yaml": "^4",
|
|
43
|
+
"zod": "^3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/js-yaml": "^4",
|
|
47
|
+
"@types/node": "^20",
|
|
48
|
+
"typescript": "^5",
|
|
49
|
+
"vitest": "^2"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=20"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reference resolution for flow option values.
|
|
3
|
-
*
|
|
4
|
-
* Option values may contain `${<namespace>.<path>}` references:
|
|
5
|
-
*
|
|
6
|
-
* ${steps.<id>.<path>} → value from a previously completed step
|
|
7
|
-
* ${error.<path>} → error info, only inside on_failure / finally hooks
|
|
8
|
-
* ${<ns>.<path>} → value from a host-supplied namespace in `namespaces`
|
|
9
|
-
* (e.g. ${project.package.namespace}, ${org.username},
|
|
10
|
-
* ${env.HOME}) — the resolver is namespace-extensible,
|
|
11
|
-
* symmetric with the pluggable `conditionEvaluator`.
|
|
12
|
-
*
|
|
13
|
-
* For `steps`, `<id>` is a step number ("3") or a task name ("level.place_actor");
|
|
14
|
-
* task names match the most recently completed step with that name, longest-prefix
|
|
15
|
-
* wins. A reference filling the entire string yields the raw value (preserving
|
|
16
|
-
* object/array/number types); embedded references are stringified. A reference to
|
|
17
|
-
* an UNREGISTERED namespace is left untouched (so non-reference `${...}` survives).
|
|
18
|
-
*/
|
|
19
|
-
export interface ReferenceableStep {
|
|
20
|
-
stepNumber: number;
|
|
21
|
-
name: string;
|
|
22
|
-
result?: {
|
|
23
|
-
data?: unknown;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export interface ReferenceContext {
|
|
27
|
-
steps: ReferenceableStep[];
|
|
28
|
-
/** Present inside on_failure / finally hooks. */
|
|
29
|
-
error?: {
|
|
30
|
-
message: string;
|
|
31
|
-
name: string;
|
|
32
|
-
stack?: string;
|
|
33
|
-
step?: string;
|
|
34
|
-
};
|
|
35
|
-
/** Host-supplied reference namespaces, e.g. { project, org, env }. */
|
|
36
|
-
namespaces?: Record<string, unknown>;
|
|
37
|
-
}
|
|
38
|
-
export declare function resolveReferences<T>(value: T, ctx: ReferenceContext): T;
|
|
39
|
-
//# sourceMappingURL=references.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../../src/flow/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,iDAAiD;IACjD,KAAK,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzE,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAQD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,gBAAgB,GAAG,CAAC,CAcvE"}
|
package/dist/flow/references.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reference resolution for flow option values.
|
|
3
|
-
*
|
|
4
|
-
* Option values may contain `${<namespace>.<path>}` references:
|
|
5
|
-
*
|
|
6
|
-
* ${steps.<id>.<path>} → value from a previously completed step
|
|
7
|
-
* ${error.<path>} → error info, only inside on_failure / finally hooks
|
|
8
|
-
* ${<ns>.<path>} → value from a host-supplied namespace in `namespaces`
|
|
9
|
-
* (e.g. ${project.package.namespace}, ${org.username},
|
|
10
|
-
* ${env.HOME}) — the resolver is namespace-extensible,
|
|
11
|
-
* symmetric with the pluggable `conditionEvaluator`.
|
|
12
|
-
*
|
|
13
|
-
* For `steps`, `<id>` is a step number ("3") or a task name ("level.place_actor");
|
|
14
|
-
* task names match the most recently completed step with that name, longest-prefix
|
|
15
|
-
* wins. A reference filling the entire string yields the raw value (preserving
|
|
16
|
-
* object/array/number types); embedded references are stringified. A reference to
|
|
17
|
-
* an UNREGISTERED namespace is left untouched (so non-reference `${...}` survives).
|
|
18
|
-
*/
|
|
19
|
-
/** Returned by resolveRef when the namespace is unregistered — leave the text literal. */
|
|
20
|
-
const LITERAL = Symbol('literal');
|
|
21
|
-
const WHOLE_VALUE = /^\$\{(\w+)\.([^}]+)\}$/;
|
|
22
|
-
const EMBEDDED = /\$\{(\w+)\.([^}]+)\}/g;
|
|
23
|
-
export function resolveReferences(value, ctx) {
|
|
24
|
-
if (value == null)
|
|
25
|
-
return value;
|
|
26
|
-
if (typeof value === 'string')
|
|
27
|
-
return resolveString(value, ctx);
|
|
28
|
-
if (Array.isArray(value)) {
|
|
29
|
-
return value.map((v) => resolveReferences(v, ctx));
|
|
30
|
-
}
|
|
31
|
-
if (typeof value === 'object') {
|
|
32
|
-
const out = {};
|
|
33
|
-
for (const [k, v] of Object.entries(value)) {
|
|
34
|
-
out[k] = resolveReferences(v, ctx);
|
|
35
|
-
}
|
|
36
|
-
return out;
|
|
37
|
-
}
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
function resolveString(str, ctx) {
|
|
41
|
-
const whole = str.match(WHOLE_VALUE);
|
|
42
|
-
if (whole) {
|
|
43
|
-
const v = resolveRef(whole[1], whole[2], ctx);
|
|
44
|
-
return v === LITERAL ? str : v;
|
|
45
|
-
}
|
|
46
|
-
if (!str.includes('${'))
|
|
47
|
-
return str;
|
|
48
|
-
return str.replace(EMBEDDED, (match, ns, ref) => {
|
|
49
|
-
const v = resolveRef(ns, ref, ctx);
|
|
50
|
-
if (v === LITERAL)
|
|
51
|
-
return match; // unregistered namespace — leave untouched
|
|
52
|
-
if (v == null)
|
|
53
|
-
return '';
|
|
54
|
-
if (typeof v === 'object')
|
|
55
|
-
return JSON.stringify(v);
|
|
56
|
-
return String(v);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function resolveRef(namespace, ref, ctx) {
|
|
60
|
-
if (namespace === 'error') {
|
|
61
|
-
if (!ctx.error) {
|
|
62
|
-
throw new Error(`\${error.${ref}} referenced outside on_failure/finally — error context not available`);
|
|
63
|
-
}
|
|
64
|
-
return getPath(ctx.error, ref.split('.'));
|
|
65
|
-
}
|
|
66
|
-
if (namespace === 'steps') {
|
|
67
|
-
const segments = ref.split('.');
|
|
68
|
-
for (let i = segments.length; i >= 1; i--) {
|
|
69
|
-
const idCandidate = segments.slice(0, i).join('.');
|
|
70
|
-
const match = findStep(idCandidate, ctx.steps);
|
|
71
|
-
if (match)
|
|
72
|
-
return getPath(match.result?.data, segments.slice(i));
|
|
73
|
-
}
|
|
74
|
-
throw new Error(`Unresolvable step reference: \${steps.${ref}} — no completed step matches "${segments[0]}"`);
|
|
75
|
-
}
|
|
76
|
-
// Host-supplied namespace (project / org / env / ...). Missing path → undefined.
|
|
77
|
-
if (ctx.namespaces && namespace in ctx.namespaces) {
|
|
78
|
-
return getPath(ctx.namespaces[namespace], ref.split('.'));
|
|
79
|
-
}
|
|
80
|
-
// Unregistered namespace — not a reference we own; leave it literal.
|
|
81
|
-
return LITERAL;
|
|
82
|
-
}
|
|
83
|
-
function findStep(id, steps) {
|
|
84
|
-
if (/^\d+$/.test(id)) {
|
|
85
|
-
return steps.find((s) => String(s.stepNumber) === id);
|
|
86
|
-
}
|
|
87
|
-
for (let i = steps.length - 1; i >= 0; i--) {
|
|
88
|
-
if (steps[i].name === id)
|
|
89
|
-
return steps[i];
|
|
90
|
-
}
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
function getPath(obj, segments) {
|
|
94
|
-
let cur = obj;
|
|
95
|
-
for (const seg of segments) {
|
|
96
|
-
if (cur == null || typeof cur !== 'object')
|
|
97
|
-
return undefined;
|
|
98
|
-
cur = cur[seg];
|
|
99
|
-
}
|
|
100
|
-
return cur;
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=references.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"references.js","sourceRoot":"","sources":["../../src/flow/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAgBH,0FAA0F;AAC1F,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAElC,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAC7C,MAAM,QAAQ,GAAG,uBAAuB,CAAC;AAEzC,MAAM,UAAU,iBAAiB,CAAI,KAAQ,EAAE,GAAqB;IAClE,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,aAAa,CAAC,KAAK,EAAE,GAAG,CAAM,CAAC;IACrE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB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