@wpkernel/pipeline 0.12.3-beta.0 → 0.12.5-beta.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 +71 -88
- package/dist/async-utils.d.ts +14 -0
- package/dist/async-utils.d.ts.map +1 -1
- package/dist/async-utils.js +18 -13
- package/dist/createExtension.d.ts +7 -1
- package/dist/createExtension.d.ts.map +1 -1
- package/dist/createPipeline.d.ts.map +1 -1
- package/dist/createPipeline.js +6 -119
- package/dist/dependency-graph.d.ts +6 -0
- package/dist/dependency-graph.d.ts.map +1 -1
- package/dist/dependency-graph.js +73 -65
- package/dist/error-factory.d.ts +1 -1
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +61 -62
- package/dist/helper.d.ts +27 -16
- package/dist/helper.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -21
- package/dist/internal/pipeline-program-utils.d.ts +127 -0
- package/dist/internal/pipeline-program-utils.d.ts.map +1 -0
- package/dist/internal/pipeline-program-utils.js +161 -0
- package/dist/internal/pipeline-runner.types.d.ts +117 -1
- package/dist/internal/pipeline-runner.types.d.ts.map +1 -1
- package/dist/internal/runner/context.d.ts +6 -0
- package/dist/internal/runner/context.d.ts.map +1 -0
- package/dist/internal/runner/context.js +169 -0
- package/dist/internal/runner/execution.d.ts +6 -0
- package/dist/internal/runner/execution.d.ts.map +1 -0
- package/dist/internal/runner/execution.js +40 -0
- package/dist/internal/{pipeline-runner.d.ts → runner/index.d.ts} +3 -8
- package/dist/internal/runner/index.d.ts.map +1 -0
- package/dist/internal/runner/index.js +11 -0
- package/dist/internal/runner/program.d.ts +8 -0
- package/dist/internal/runner/program.d.ts.map +1 -0
- package/dist/internal/runner/program.js +294 -0
- package/dist/makePipeline.d.ts +20 -0
- package/dist/makePipeline.d.ts.map +1 -0
- package/dist/makePipeline.js +139 -0
- package/dist/registration.d.ts.map +1 -1
- package/dist/registration.js +17 -15
- package/dist/rollback.d.ts +94 -0
- package/dist/rollback.d.ts.map +1 -0
- package/dist/rollback.js +46 -0
- package/dist/types.d.ts +37 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/internal/pipeline-runner.d.ts.map +0 -1
- package/dist/internal/pipeline-runner.js +0 -257
package/README.md
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
# @wpkernel/pipeline
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> A type-safe, dependency-aware workflow engine for orchestrating complex generation tasks.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
`@wpkernel/pipeline`
|
|
8
|
-
`@wpkernel/core` so CLI builders, PHP bridges, and external projects can compose helpers,
|
|
9
|
-
validate dependencies, and execute deterministic plans. The runtime enforces a three-phase
|
|
10
|
-
model (fragments → builders → extensions) and provides rich diagnostics when helpers clash or
|
|
11
|
-
dependencies are missing.
|
|
7
|
+
`@wpkernel/pipeline` is a generic orchestration engine that turns sets of decoupled "helpers" into deterministic, topologically sorted execution plans.
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
While it powers WPKernel's code generation (assembling fragments into artifacts), the core is completely agnostic. You can use it to build:
|
|
14
10
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
11
|
+
- **ETL Pipelines**: Extract, Transform, and Load stages with shared state.
|
|
12
|
+
- **Build Systems**: Compile, Bundle, and Minify steps with precise ordering.
|
|
13
|
+
- **Code Generators**: The standard "Fragment → Builder" pattern.
|
|
14
|
+
|
|
15
|
+
It guarantees:
|
|
16
|
+
|
|
17
|
+
- **Deterministic Ordering**: Topologically sorts helpers based on `dependsOn`.
|
|
18
|
+
- **Cycle Detection**: Fails fast if dependencies form a loop.
|
|
19
|
+
- **Atomic Rollbacks**: Extensions provide transactional `commit` and `rollback` hooks.
|
|
20
|
+
- **Type Safety**: Full TypeScript support for custom contexts, options, and artifacts.
|
|
18
21
|
|
|
19
22
|
## Installation
|
|
20
23
|
|
|
@@ -24,101 +27,81 @@ pnpm add @wpkernel/pipeline
|
|
|
24
27
|
|
|
25
28
|
The package ships pure TypeScript and has no runtime dependencies.
|
|
26
29
|
|
|
27
|
-
##
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### 1. Define Your World
|
|
33
|
+
|
|
34
|
+
The pipeline is generic. You define the "Stages" and "State" relevant to your domain.
|
|
28
35
|
|
|
29
36
|
```ts
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
const pipeline =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
finalizeFragmentState: ({ draft }) => draft,
|
|
45
|
-
createBuilderArgs: ({ context, artifact }) => ({
|
|
46
|
-
context,
|
|
47
|
-
input: artifact,
|
|
48
|
-
output: { result: '' },
|
|
49
|
-
reporter: context.reporter,
|
|
50
|
-
}),
|
|
37
|
+
import { makePipeline } from '@wpkernel/pipeline';
|
|
38
|
+
|
|
39
|
+
const pipeline = makePipeline({
|
|
40
|
+
// Define the "Stages" of your pipeline
|
|
41
|
+
stages: (deps) => [
|
|
42
|
+
deps.makeLifecycleStage('extract'),
|
|
43
|
+
deps.makeLifecycleStage('transform'),
|
|
44
|
+
deps.makeLifecycleStage('load'),
|
|
45
|
+
deps.commitStage,
|
|
46
|
+
deps.finalizeResult,
|
|
47
|
+
],
|
|
48
|
+
// Define how to create your context and state
|
|
49
|
+
createContext: (ops) => ({ db: ops.db }),
|
|
50
|
+
// ... logic for resolving args for your helpers ...
|
|
51
51
|
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Register Helpers
|
|
55
|
+
|
|
56
|
+
Helpers are the atomic units of work. They can be anything - functions, objects, or complex services.
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
const result = await pipeline.run({ reporter: console });
|
|
75
|
-
console.log(result.artifact.result); // "item1, item2"
|
|
58
|
+
```ts
|
|
59
|
+
// "Extract" helper
|
|
60
|
+
pipeline.use({
|
|
61
|
+
kind: 'extract',
|
|
62
|
+
key: 'users',
|
|
63
|
+
apply: async ({ context }) => {
|
|
64
|
+
return context.db.query('SELECT * FROM users');
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// "Transform" helper (depends on generic extract logic)
|
|
69
|
+
pipeline.use({
|
|
70
|
+
kind: 'transform',
|
|
71
|
+
key: 'clean-users',
|
|
72
|
+
dependsOn: ['users'],
|
|
73
|
+
apply: ({ input }) => {
|
|
74
|
+
return input.map((u) => ({ ...u, name: u.name.trim() }));
|
|
75
|
+
},
|
|
76
|
+
});
|
|
76
77
|
```
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
### 3. Run It
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
helpers produce artefacts, and extension hooks commit or roll back side-effects.
|
|
82
|
-
- **Deterministic ordering** – helpers declare `dependsOn` relationships; the runtime performs
|
|
83
|
-
topological sorting, cycle detection, and unused-helper diagnostics.
|
|
84
|
-
- **Extension system** – register hooks via `createPipelineExtension()` to manage commits,
|
|
85
|
-
rollbacks, and shared setup/teardown logic.
|
|
86
|
-
- **Typed contracts** – helper descriptors, execution metadata, and diagnostics surfaces are
|
|
87
|
-
fully typed for TypeScript consumers.
|
|
81
|
+
The pipeline resolves the graph, executes the content, and manages the lifecycle.
|
|
88
82
|
|
|
89
|
-
|
|
83
|
+
```ts
|
|
84
|
+
const result = await pipeline.run({ db: myDatabase });
|
|
85
|
+
```
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
being promoted to standalone packages. The directory ships a README that documents authoring
|
|
93
|
-
guidelines and an [`official.ts`](./src/extensions/official.ts) catalogue describing the
|
|
94
|
-
blueprints for:
|
|
87
|
+
## Concepts
|
|
95
88
|
|
|
96
|
-
|
|
97
|
-
- a deterministic concurrency scheduler;
|
|
98
|
-
- additional integration blueprints for telemetry and runtime adapters.
|
|
89
|
+
### Agnostic Helper Kinds
|
|
99
90
|
|
|
100
|
-
|
|
101
|
-
contracts and helper annotations each extension expects while we finalise their
|
|
102
|
-
implementations.
|
|
91
|
+
You are not limited to fixed roles. Define any `kind` of helper (e.g., `'validator'`, `'compiler'`, `'notifier'`) and map them to execution stages.
|
|
103
92
|
|
|
104
|
-
|
|
93
|
+
### Dependency Graph
|
|
105
94
|
|
|
106
|
-
|
|
107
|
-
- `@wpkernel/core` (resource/action orchestration)
|
|
108
|
-
- `@wpkernel/php-json-ast` (codemod and builder stacks)
|
|
109
|
-
- External tooling that requires deterministic job orchestration
|
|
95
|
+
Pipeline creates a dependency graph for _each_ kind of helper. If `Helper B` depends on `Helper A`, the runner ensures `A` executes before `B` (and passes `A`'s output to `B` if configured).
|
|
110
96
|
|
|
111
|
-
|
|
97
|
+
### Extensions & Lifecycles
|
|
112
98
|
|
|
113
|
-
|
|
114
|
-
missing dependencies, and rollback metadata. Execution snapshots describe which helpers ran,
|
|
115
|
-
which were skipped, and what extensions committed.
|
|
99
|
+
Extensions wrap the execution with hooks like `prepare`, `onSuccess`, and `rollback`. They are crucial for ensuring atomic operations - if any stage fails, the pipeline automatically triggers the rollback chain for all executed extensions.
|
|
116
100
|
|
|
117
|
-
##
|
|
101
|
+
## Documentation
|
|
118
102
|
|
|
119
|
-
|
|
120
|
-
API
|
|
121
|
-
reflect new capabilities that PHP bridges or the CLI can adopt.
|
|
103
|
+
- [Architecture Guide](../../docs/packages/pipeline/architecture.md): Deep dive into the runner's internals and DAG resolution.
|
|
104
|
+
- [API Reference](../../docs/api/@wpkernel/pipeline/README.md): Generated TSDoc for all interfaces.
|
|
122
105
|
|
|
123
106
|
## License
|
|
124
107
|
|
package/dist/async-utils.d.ts
CHANGED
|
@@ -48,4 +48,18 @@ export declare function maybeTry<T>(run: () => MaybePromise<T>, onError: (error:
|
|
|
48
48
|
* @internal
|
|
49
49
|
*/
|
|
50
50
|
export declare function processSequentially<T>(items: readonly T[], handler: (item: T, index: number) => MaybePromise<void>, direction?: 'forward' | 'reverse'): MaybePromise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* A small abstraction representing a state transformer that may be async.
|
|
53
|
+
*
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export type Program<S> = (state: S) => MaybePromise<S>;
|
|
57
|
+
/**
|
|
58
|
+
* Right-to-left composition for {@link Program} functions that short-circuits
|
|
59
|
+
* on promises while preserving synchronous execution when possible.
|
|
60
|
+
*
|
|
61
|
+
* @param {...any} fns
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export declare const composeK: <S>(...fns: Program<S>[]) => Program<S>;
|
|
51
65
|
//# sourceMappingURL=async-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-utils.d.ts","sourceRoot":"","sources":["../src/async-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC,CAS3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EACnC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EACtB,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,YAAY,CAAC,OAAO,CAAC,GAC9C,YAAY,CAAC,OAAO,CAAC,CAMvB;AAED;;;;;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SAAS,CAAC,EAAE,EACnB,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC,IAAI,CAAC,EACvD,SAAS,GAAE,SAAS,GAAG,SAAqB,GAC1C,YAAY,CAAC,IAAI,CAAC,CAgCpB;AAED;;;;GAIG;AAEH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC;AACvD;;;;;;GAMG;AAEH,eAAO,MAAM,QAAQ,GACnB,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,KAAG,OAAO,CAAC,CAAC,CAKlC,CAAC"}
|
package/dist/async-utils.js
CHANGED
|
@@ -1,35 +1,40 @@
|
|
|
1
1
|
function c(t) {
|
|
2
2
|
return (typeof t != "object" || t === null) && typeof t != "function" ? !1 : typeof t.then == "function";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function m(t, e) {
|
|
5
5
|
return c(t) ? Promise.resolve(t).then(e) : e(t);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function l(t, e) {
|
|
8
8
|
try {
|
|
9
9
|
const r = t();
|
|
10
|
-
return c(r) ? Promise.resolve(r).catch((
|
|
10
|
+
return c(r) ? Promise.resolve(r).catch((n) => e(n)) : r;
|
|
11
11
|
} catch (r) {
|
|
12
12
|
return e(r);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
function p(t, e, r = "forward") {
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
16
|
+
const n = t.length;
|
|
17
|
+
if (n === 0)
|
|
18
18
|
return;
|
|
19
|
-
const
|
|
20
|
-
for (let
|
|
21
|
-
const y = t[
|
|
19
|
+
const h = (o) => r === "forward" ? o < n : o >= 0, f = (o) => r === "forward" ? o + 1 : o - 1, u = (o) => {
|
|
20
|
+
for (let s = o; h(s); s = f(s)) {
|
|
21
|
+
const y = t[s], i = e(y, s);
|
|
22
22
|
if (c(i))
|
|
23
23
|
return Promise.resolve(i).then(
|
|
24
|
-
() => u(f(
|
|
24
|
+
() => u(f(s))
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
return u(
|
|
27
|
+
}, a = r === "forward" ? 0 : n - 1;
|
|
28
|
+
return u(a);
|
|
29
29
|
}
|
|
30
|
+
const w = (...t) => (e) => t.reduceRight(
|
|
31
|
+
(r, n) => m(r, n),
|
|
32
|
+
e
|
|
33
|
+
);
|
|
30
34
|
export {
|
|
35
|
+
w as composeK,
|
|
31
36
|
c as isPromiseLike,
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
m as maybeThen,
|
|
38
|
+
l as maybeTry,
|
|
34
39
|
p as processSequentially
|
|
35
40
|
};
|
|
@@ -2,7 +2,13 @@ import { MaybePromise, PipelineExtension, PipelineExtensionHook, PipelineExtensi
|
|
|
2
2
|
interface CreatePipelineExtensionBaseOptions {
|
|
3
3
|
readonly key?: string;
|
|
4
4
|
}
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Options for creating a pipeline extension using the dynamic register pattern.
|
|
7
|
+
*
|
|
8
|
+
* @category Pipeline
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export interface CreatePipelineExtensionWithRegister<TPipeline, TContext, TOptions, TArtifact> extends CreatePipelineExtensionBaseOptions {
|
|
6
12
|
readonly register: (pipeline: TPipeline) => MaybePromise<void | PipelineExtensionHook<TContext, TOptions, TArtifact> | PipelineExtensionHookRegistration<TContext, TOptions, TArtifact>>;
|
|
7
13
|
}
|
|
8
14
|
interface CreatePipelineExtensionWithSetup<TPipeline, TContext, TOptions, TArtifact> extends CreatePipelineExtensionBaseOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExtension.d.ts","sourceRoot":"","sources":["../src/createExtension.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,YAAY,EACZ,iBAAiB,EACjB,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AAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,CACR,GACD,gCAAgC,CAChC,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,CACR,CAAC;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoJG;AACH,wBAAgB,uBAAuB,CACtC,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EAET,OAAO,EAAE,8BAA8B,CACtC,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,CACT,GACC,iBAAiB,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAoD7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPipeline.d.ts","sourceRoot":"","sources":["../src/createPipeline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createPipeline.d.ts","sourceRoot":"","sources":["../src/createPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,qBAAqB,EACrB,MAAM,EACN,UAAU,EACV,QAAQ,EACR,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,wBAAgB,cAAc,CAC7B,WAAW,EACX,aAAa,EACb,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,GAAG,gBAAgB,EACrD,MAAM,GAAG,OAAO,EAChB,SAAS,GAAG,OAAO,EACnB,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,UAAU,GAAG,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,EACrD,cAAc,GAAG,OAAO,EACxB,eAAe,GAAG,OAAO,EACzB,aAAa,GAAG,OAAO,EACvB,cAAc,GAAG,OAAO,EACxB,aAAa,SAAS,UAAU,GAAG,UAAU,EAC7C,YAAY,SAAS,UAAU,GAAG,SAAS,EAC3C,eAAe,SAAS,MAAM,CAC7B,QAAQ,EACR,cAAc,EACd,eAAe,EACf,SAAS,EACT,aAAa,CACb,GAAG,MAAM,CACT,QAAQ,EACR,cAAc,EACd,eAAe,EACf,SAAS,EACT,aAAa,CACb,EACD,cAAc,SAAS,MAAM,CAC5B,QAAQ,EACR,aAAa,EACb,cAAc,EACd,SAAS,EACT,YAAY,CACZ,GAAG,MAAM,CACT,QAAQ,EACR,aAAa,EACb,cAAc,EACd,SAAS,EACT,YAAY,CACZ,EAED,OAAO,EAAE,qBAAqB,CAC7B,WAAW,EACX,aAAa,EACb,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,WAAW,EACX,UAAU,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACZ,eAAe,EACf,cAAc,CACd,GACC,QAAQ,CACV,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,SAAS,EACT,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,cAAc,CACd,CAsCA"}
|
package/dist/createPipeline.js
CHANGED
|
@@ -1,122 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const i = r.fragmentKind ?? "fragment", s = r.builderKind ?? "builder", a = r.createError ?? ((e, n) => new Error(`[${e}] ${n}`)), l = [], d = [], f = [], o = [], u = V({
|
|
7
|
-
options: r,
|
|
8
|
-
fragmentKind: i,
|
|
9
|
-
builderKind: s
|
|
10
|
-
}), k = r.createRunResult ?? ((e) => ({
|
|
11
|
-
artifact: e.artifact,
|
|
12
|
-
diagnostics: e.diagnostics,
|
|
13
|
-
steps: e.steps
|
|
14
|
-
})), { prepareContext: K, executeRun: P } = $({
|
|
15
|
-
options: r,
|
|
16
|
-
fragmentEntries: l,
|
|
17
|
-
builderEntries: d,
|
|
18
|
-
fragmentKind: i,
|
|
19
|
-
builderKind: s,
|
|
20
|
-
diagnosticManager: u,
|
|
21
|
-
createError: a,
|
|
22
|
-
resolveRunResult: k,
|
|
23
|
-
extensionHooks: f
|
|
24
|
-
}), g = i, m = s, p = (e) => v(
|
|
25
|
-
e,
|
|
26
|
-
i,
|
|
27
|
-
l,
|
|
28
|
-
g,
|
|
29
|
-
(n, t, c) => u.flagConflict(
|
|
30
|
-
n,
|
|
31
|
-
t,
|
|
32
|
-
g,
|
|
33
|
-
c
|
|
34
|
-
),
|
|
35
|
-
a
|
|
36
|
-
), R = (e) => v(
|
|
37
|
-
e,
|
|
38
|
-
s,
|
|
39
|
-
d,
|
|
40
|
-
m,
|
|
41
|
-
(n, t, c) => u.flagConflict(
|
|
42
|
-
n,
|
|
43
|
-
t,
|
|
44
|
-
m,
|
|
45
|
-
c
|
|
46
|
-
),
|
|
47
|
-
a
|
|
48
|
-
), C = (e, n) => w(e, n, f), H = (e) => {
|
|
49
|
-
if (e && h(e)) {
|
|
50
|
-
Promise.resolve(e).catch(() => {
|
|
51
|
-
});
|
|
52
|
-
const n = Promise.resolve(e).then(() => {
|
|
53
|
-
});
|
|
54
|
-
n.catch(() => {
|
|
55
|
-
}), o.push(n), n.finally(() => {
|
|
56
|
-
const t = o.indexOf(n);
|
|
57
|
-
t !== -1 && o.splice(t, 1);
|
|
58
|
-
}).catch(() => {
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return e;
|
|
62
|
-
}, b = () => {
|
|
63
|
-
if (o.length !== 0)
|
|
64
|
-
return Promise.all([...o]).then(
|
|
65
|
-
() => {
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
}, x = {
|
|
69
|
-
fragmentKind: i,
|
|
70
|
-
builderKind: s,
|
|
71
|
-
ir: {
|
|
72
|
-
use(e) {
|
|
73
|
-
p(e);
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
builders: {
|
|
77
|
-
use(e) {
|
|
78
|
-
R(e);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
extensions: {
|
|
82
|
-
use(e) {
|
|
83
|
-
const n = e.register(x);
|
|
84
|
-
n && h(n) && Promise.resolve(n).catch(() => {
|
|
85
|
-
});
|
|
86
|
-
const t = E(
|
|
87
|
-
n,
|
|
88
|
-
(c) => C(e.key, c)
|
|
89
|
-
);
|
|
90
|
-
return H(t);
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
use(e) {
|
|
94
|
-
if (e.kind === i) {
|
|
95
|
-
p(e);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (e.kind === s) {
|
|
99
|
-
R(e);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
throw a(
|
|
103
|
-
"ValidationError",
|
|
104
|
-
`Unsupported helper kind "${e.kind}".`
|
|
105
|
-
);
|
|
106
|
-
},
|
|
107
|
-
run(e) {
|
|
108
|
-
const n = () => {
|
|
109
|
-
const t = K(e);
|
|
110
|
-
return P(t);
|
|
111
|
-
};
|
|
112
|
-
return E(
|
|
113
|
-
b(),
|
|
114
|
-
() => n()
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
return x;
|
|
1
|
+
import { makePipeline as i } from "./makePipeline.js";
|
|
2
|
+
function n(e) {
|
|
3
|
+
return i(
|
|
4
|
+
e
|
|
5
|
+
);
|
|
119
6
|
}
|
|
120
7
|
export {
|
|
121
|
-
|
|
8
|
+
n as createPipeline
|
|
122
9
|
};
|
|
@@ -28,6 +28,12 @@ export interface CreateDependencyGraphOptions<THelper> {
|
|
|
28
28
|
readonly onUnresolvedHelpers?: (options: {
|
|
29
29
|
readonly unresolved: RegisteredHelper<THelper>[];
|
|
30
30
|
}) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Optional set of helper keys that are considered “already satisfied”.
|
|
33
|
+
* Useful when a pipeline run intentionally omits certain helpers (e.g. IR
|
|
34
|
+
* fragments) but builders still declare them as dependencies.
|
|
35
|
+
*/
|
|
36
|
+
readonly providedKeys?: readonly string[];
|
|
31
37
|
}
|
|
32
38
|
/**
|
|
33
39
|
* Creates a unique identifier for a registered helper.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependency-graph.d.ts","sourceRoot":"","sources":["../src/dependency-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,OAAO;IACxC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAaD;;;;GAIG;AACH,MAAM,WAAW,sBAAsB,CAAC,OAAO;IAC9C,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC9C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B,CAAC,OAAO;IACpD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAC9B,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC,KAClC,IAAI,CAAC;IACV,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,OAAO,EAAE;QACxC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;KACjD,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"dependency-graph.d.ts","sourceRoot":"","sources":["../src/dependency-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,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,EACpC,OAAO,EAAE,4BAA4B,CAAC,OAAO,CAAC,GAAG,SAAS,EAC1D,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,KAAK,GACnD;IACF,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;IACnC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACpC,CAgBA"}
|
package/dist/dependency-graph.js
CHANGED
|
@@ -1,101 +1,109 @@
|
|
|
1
|
-
function
|
|
1
|
+
function M(n, e) {
|
|
2
2
|
return `${n.kind}:${n.key}#${e}`;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function u(n, e) {
|
|
5
5
|
return n.helper.priority !== e.helper.priority ? e.helper.priority - n.helper.priority : n.helper.key !== e.helper.key ? n.helper.key.localeCompare(e.helper.key) : n.index - e.index;
|
|
6
6
|
}
|
|
7
7
|
function y(n) {
|
|
8
|
-
const e = /* @__PURE__ */ new Map(),
|
|
9
|
-
for (const
|
|
10
|
-
e.set(
|
|
11
|
-
return { adjacency: e, indegree:
|
|
8
|
+
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
9
|
+
for (const o of n)
|
|
10
|
+
e.set(o.id, /* @__PURE__ */ new Set()), t.set(o.id, 0), r.set(o.id, o);
|
|
11
|
+
return { adjacency: e, indegree: t, entryById: r };
|
|
12
12
|
}
|
|
13
13
|
function a(n, e) {
|
|
14
|
-
const
|
|
14
|
+
const t = [];
|
|
15
15
|
for (const r of n)
|
|
16
|
-
for (const
|
|
16
|
+
for (const o of r.helper.dependsOn)
|
|
17
17
|
h(
|
|
18
18
|
n,
|
|
19
19
|
e,
|
|
20
|
-
|
|
20
|
+
o,
|
|
21
21
|
r.id
|
|
22
|
-
) ||
|
|
22
|
+
) || t.push({
|
|
23
23
|
dependant: r,
|
|
24
|
-
dependencyKey:
|
|
24
|
+
dependencyKey: o
|
|
25
25
|
});
|
|
26
|
-
return
|
|
26
|
+
return t;
|
|
27
27
|
}
|
|
28
|
-
function h(n, e,
|
|
29
|
-
const
|
|
30
|
-
({ helper:
|
|
28
|
+
function h(n, e, t, r) {
|
|
29
|
+
const o = n.filter(
|
|
30
|
+
({ helper: s }) => s.key === t
|
|
31
31
|
);
|
|
32
|
-
if (
|
|
32
|
+
if (o.length === 0)
|
|
33
33
|
return !1;
|
|
34
|
-
for (const
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
34
|
+
for (const s of o) {
|
|
35
|
+
const c = e.adjacency.get(s.id);
|
|
36
|
+
if (!c)
|
|
37
37
|
continue;
|
|
38
|
-
|
|
38
|
+
c.add(r);
|
|
39
39
|
const i = e.indegree.get(r) ?? 0;
|
|
40
40
|
e.indegree.set(r, i + 1);
|
|
41
41
|
}
|
|
42
42
|
return !0;
|
|
43
43
|
}
|
|
44
44
|
function g(n, e) {
|
|
45
|
-
const
|
|
45
|
+
const t = n.filter(
|
|
46
46
|
(i) => (e.indegree.get(i.id) ?? 0) === 0
|
|
47
47
|
);
|
|
48
|
-
|
|
49
|
-
const r = [],
|
|
50
|
-
for (;
|
|
51
|
-
const i =
|
|
48
|
+
t.sort(u);
|
|
49
|
+
const r = [], o = new Map(e.indegree), s = /* @__PURE__ */ new Set();
|
|
50
|
+
for (; t.length > 0; ) {
|
|
51
|
+
const i = t.shift();
|
|
52
52
|
if (!i)
|
|
53
53
|
break;
|
|
54
|
-
r.push(i),
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
for (const
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
54
|
+
r.push(i), s.add(i.id);
|
|
55
|
+
const p = e.adjacency.get(i.id);
|
|
56
|
+
if (p)
|
|
57
|
+
for (const d of p) {
|
|
58
|
+
const l = (o.get(d) ?? 0) - 1;
|
|
59
|
+
if (o.set(d, l), l !== 0)
|
|
60
60
|
continue;
|
|
61
|
-
const
|
|
62
|
-
|
|
61
|
+
const f = e.entryById.get(d);
|
|
62
|
+
f && (t.push(f), t.sort(u));
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
return { ordered: r, unresolved:
|
|
65
|
+
const c = n.filter((i) => !s.has(i.id));
|
|
66
|
+
return { ordered: r, unresolved: c };
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const u = Array.from(i.entries()).map(
|
|
79
|
-
([s, p]) => `"${s}" → [${p.map((l) => `"${l}"`).join(", ")}]`
|
|
80
|
-
).join(", ");
|
|
81
|
-
throw o(
|
|
82
|
-
"ValidationError",
|
|
83
|
-
`Helpers depend on unknown helpers: ${u}.`
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
const { ordered: c, unresolved: d } = g(n, r);
|
|
87
|
-
if (d.length > 0) {
|
|
88
|
-
e?.onUnresolvedHelpers?.({ unresolved: d });
|
|
89
|
-
const i = d.map((u) => u.helper.key);
|
|
90
|
-
throw o(
|
|
91
|
-
"ValidationError",
|
|
92
|
-
`Detected unresolved pipeline helpers: ${i.join(", ")}.`
|
|
93
|
-
);
|
|
68
|
+
function k(n, e, t) {
|
|
69
|
+
if (n.length === 0)
|
|
70
|
+
return;
|
|
71
|
+
if (e?.onMissingDependency)
|
|
72
|
+
for (const s of n)
|
|
73
|
+
e.onMissingDependency(s);
|
|
74
|
+
const r = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const s of n) {
|
|
76
|
+
const c = s.dependant.helper.key, i = r.get(c) ?? [];
|
|
77
|
+
i.push(s.dependencyKey), r.set(c, i);
|
|
94
78
|
}
|
|
95
|
-
|
|
79
|
+
const o = Array.from(r.entries()).map(
|
|
80
|
+
([s, c]) => `"${s}" → [${c.map((i) => `"${i}"`).join(", ")}]`
|
|
81
|
+
).join(", ");
|
|
82
|
+
throw t(
|
|
83
|
+
"ValidationError",
|
|
84
|
+
`Helpers depend on unknown helpers: ${o}.`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
function w(n, e, t) {
|
|
88
|
+
if (n.length === 0)
|
|
89
|
+
return;
|
|
90
|
+
e?.onUnresolvedHelpers && e.onUnresolvedHelpers({ unresolved: n });
|
|
91
|
+
const r = n.map((o) => o.helper.key);
|
|
92
|
+
throw t(
|
|
93
|
+
"ValidationError",
|
|
94
|
+
`Detected unresolved pipeline helpers: ${r.join(", ")}.`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
function j(n, e, t) {
|
|
98
|
+
const r = y(n), o = a(n, r), s = new Set(e?.providedKeys ?? []), c = o.filter(
|
|
99
|
+
(d) => !s.has(d.dependencyKey)
|
|
100
|
+
);
|
|
101
|
+
k(c, e, t);
|
|
102
|
+
const { ordered: i, unresolved: p } = g(n, r);
|
|
103
|
+
return w(p, e, t), { order: i, adjacency: r.adjacency };
|
|
96
104
|
}
|
|
97
105
|
export {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
106
|
+
u as compareHelpers,
|
|
107
|
+
j as createDependencyGraph,
|
|
108
|
+
M as createHelperId
|
|
101
109
|
};
|
package/dist/error-factory.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare function createDefaultError(code: string, message: string): Error
|
|
|
24
24
|
/**
|
|
25
25
|
* Creates an error factory that wraps a custom error class.
|
|
26
26
|
*
|
|
27
|
-
* @param
|
|
27
|
+
* @param create - A function that creates an Error instance based on a code and message.
|
|
28
28
|
* @param create
|
|
29
29
|
* @returns An error factory function
|
|
30
30
|
*
|