@wpkernel/pipeline 0.12.1-beta.0 → 0.12.1-beta.3
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 +15 -0
- package/dist/createExtension.d.ts +4 -3
- package/dist/createExtension.d.ts.map +1 -1
- package/dist/createExtension.js +20 -11
- package/dist/createPipeline.d.ts +28 -188
- package/dist/createPipeline.d.ts.map +1 -1
- package/dist/createPipeline.js +81 -402
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +8 -0
- package/dist/extensions/official.d.ts +73 -0
- package/dist/extensions/official.d.ts.map +1 -0
- package/dist/extensions/official.js +111 -0
- package/dist/extensions.d.ts +6 -2
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +50 -45
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -16
- package/dist/internal/diagnostic-manager.d.ts +29 -0
- package/dist/internal/diagnostic-manager.d.ts.map +1 -0
- package/dist/internal/diagnostic-manager.js +94 -0
- package/dist/internal/diagnostic-manager.types.d.ts +70 -0
- package/dist/internal/diagnostic-manager.types.d.ts.map +1 -0
- package/dist/internal/extension-coordinator.d.ts +21 -0
- package/dist/internal/extension-coordinator.d.ts.map +1 -0
- package/dist/internal/extension-coordinator.js +55 -0
- package/dist/internal/extension-coordinator.types.d.ts +42 -0
- package/dist/internal/extension-coordinator.types.d.ts.map +1 -0
- package/dist/internal/helper-execution.d.ts +32 -0
- package/dist/internal/helper-execution.d.ts.map +1 -0
- package/dist/internal/helper-execution.js +37 -0
- package/dist/internal/pipeline-runner.d.ts +18 -0
- package/dist/internal/pipeline-runner.d.ts.map +1 -0
- package/dist/internal/pipeline-runner.js +261 -0
- package/dist/internal/pipeline-runner.types.d.ts +79 -0
- package/dist/internal/pipeline-runner.types.d.ts.map +1 -0
- package/dist/registration.d.ts +3 -2
- package/dist/registration.d.ts.map +1 -1
- package/dist/registration.js +38 -27
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { commitExtensionResults as m, rollbackExtensionResults as d, runExtensionHooks as f, createRollbackErrorMetadata as s } from "../extensions.js";
|
|
2
|
+
import { maybeThen as i } from "../async-utils.js";
|
|
3
|
+
/**
|
|
4
|
+
* @wpkernel/pipeline
|
|
5
|
+
* @license EUPL-1.2
|
|
6
|
+
*/
|
|
7
|
+
function R(n) {
|
|
8
|
+
return {
|
|
9
|
+
runLifecycle: (t, { hooks: o, hookOptions: r }) => {
|
|
10
|
+
const c = o.filter(
|
|
11
|
+
(e) => e.lifecycle === t
|
|
12
|
+
), a = f(
|
|
13
|
+
o,
|
|
14
|
+
t,
|
|
15
|
+
r,
|
|
16
|
+
({ error: e, extensionKeys: l, hookSequence: u }) => n({
|
|
17
|
+
error: e,
|
|
18
|
+
extensionKeys: l,
|
|
19
|
+
hookSequence: u,
|
|
20
|
+
errorMetadata: s(e),
|
|
21
|
+
hookOptions: r
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
return i(
|
|
25
|
+
a,
|
|
26
|
+
(e) => ({
|
|
27
|
+
artifact: e.artifact,
|
|
28
|
+
results: e.results,
|
|
29
|
+
hooks: c
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
},
|
|
33
|
+
createRollbackHandler: (t) => (o) => i(
|
|
34
|
+
d(
|
|
35
|
+
t.results,
|
|
36
|
+
t.hooks,
|
|
37
|
+
({ error: r, extensionKeys: c, hookSequence: a }) => n({
|
|
38
|
+
error: r,
|
|
39
|
+
extensionKeys: c,
|
|
40
|
+
hookSequence: a,
|
|
41
|
+
errorMetadata: s(r),
|
|
42
|
+
hookOptions: void 0
|
|
43
|
+
})
|
|
44
|
+
),
|
|
45
|
+
() => {
|
|
46
|
+
throw o;
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
commit: (t) => m(t.results),
|
|
50
|
+
handleRollbackError: n
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
R as initExtensionCoordinator
|
|
55
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MaybePromise, PipelineExtensionHookOptions, PipelineExtensionRollbackErrorMetadata } from '../types';
|
|
2
|
+
import { ExtensionHookEntry, ExtensionHookExecution, RollbackErrorArgs } from '../extensions';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the state returned after executing a specific extension lifecycle.
|
|
5
|
+
*
|
|
6
|
+
* @category Pipeline
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export interface ExtensionLifecycleState<TContext, TOptions, TArtifact> {
|
|
10
|
+
readonly artifact: TArtifact;
|
|
11
|
+
readonly results: ExtensionHookExecution<TContext, TOptions, TArtifact>[];
|
|
12
|
+
readonly hooks: readonly ExtensionHookEntry<TContext, TOptions, TArtifact>[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Handles extension execution, rollback, and commit using the primitives exposed by the
|
|
16
|
+
* `extensions` module. Delegating this coordination to a dedicated utility keeps the pipeline
|
|
17
|
+
* runner focused on dependency graph orchestration and helper execution.
|
|
18
|
+
*
|
|
19
|
+
* @category Pipeline
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Payload supplied to rollback error handlers when an extension lifecycle fails.
|
|
24
|
+
*
|
|
25
|
+
* @category Pipeline
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export interface ExtensionRollbackEvent<TContext, TOptions, TArtifact> extends RollbackErrorArgs {
|
|
29
|
+
readonly errorMetadata: PipelineExtensionRollbackErrorMetadata;
|
|
30
|
+
readonly hookOptions?: PipelineExtensionHookOptions<TContext, TOptions, TArtifact>;
|
|
31
|
+
}
|
|
32
|
+
export interface ExtensionCoordinator<TContext, TOptions, TArtifact> {
|
|
33
|
+
readonly runLifecycle: (lifecycle: ExtensionHookEntry<TContext, TOptions, TArtifact>['lifecycle'], options: {
|
|
34
|
+
readonly hooks: readonly ExtensionHookEntry<TContext, TOptions, TArtifact>[];
|
|
35
|
+
readonly hookOptions: PipelineExtensionHookOptions<TContext, TOptions, TArtifact>;
|
|
36
|
+
}) => MaybePromise<ExtensionLifecycleState<TContext, TOptions, TArtifact>>;
|
|
37
|
+
readonly createRollbackHandler: <TResult>(state: ExtensionLifecycleState<TContext, TOptions, TArtifact>) => (error: unknown) => MaybePromise<TResult>;
|
|
38
|
+
readonly commit: (state: ExtensionLifecycleState<TContext, TOptions, TArtifact>) => MaybePromise<void>;
|
|
39
|
+
readonly handleRollbackError: (args: ExtensionRollbackEvent<TContext, TOptions, TArtifact>) => void;
|
|
40
|
+
}
|
|
41
|
+
export type { ExtensionHookEntry, ExtensionHookExecution, RollbackErrorArgs };
|
|
42
|
+
//# sourceMappingURL=extension-coordinator.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-coordinator.types.d.ts","sourceRoot":"","sources":["../../src/internal/extension-coordinator.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,YAAY,EACZ,4BAA4B,EAC5B,sCAAsC,EACtC,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS;IACrE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC;IAC1E,QAAQ,CAAC,KAAK,EAAE,SAAS,kBAAkB,CAC1C,QAAQ,EACR,QAAQ,EACR,SAAS,CACT,EAAE,CAAC;CACJ;AAED;;;;;;;GAOG;AACH;;;;;GAKG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0,0 +1,32 @@
|
|
|
1
|
+
import { RegisteredHelper } from '../dependency-graph';
|
|
2
|
+
import { ErrorFactory } from '../error-factory';
|
|
3
|
+
import { HelperDescriptor, HelperExecutionSnapshot, HelperKind } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a snapshot summarising helper execution for a specific stage.
|
|
6
|
+
*
|
|
7
|
+
* @param entries
|
|
8
|
+
* @param visited
|
|
9
|
+
* @param kind
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const snapshot = buildExecutionSnapshot(fragmentEntries, visited, 'fragment');
|
|
13
|
+
* console.log(snapshot.executed.length);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @category Pipeline
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildExecutionSnapshot<THelper extends HelperDescriptor<TKind>, TKind extends HelperKind>(entries: RegisteredHelper<THelper>[], visited: Set<string>, kind: TKind): HelperExecutionSnapshot<TKind>;
|
|
20
|
+
/**
|
|
21
|
+
* Throws when required helpers in a stage were never executed.
|
|
22
|
+
*
|
|
23
|
+
* @param entries
|
|
24
|
+
* @param snapshot
|
|
25
|
+
* @param kind
|
|
26
|
+
* @param describeHelper
|
|
27
|
+
* @param createError
|
|
28
|
+
* @category Pipeline
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export declare function assertAllHelpersExecuted<THelper extends HelperDescriptor<TKind>, TKind extends HelperKind>(entries: RegisteredHelper<THelper>[], snapshot: HelperExecutionSnapshot<TKind>, kind: TKind, describeHelper: (kind: HelperKind, helper: HelperDescriptor) => string, createError: ErrorFactory): void;
|
|
32
|
+
//# sourceMappingURL=helper-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper-execution.d.ts","sourceRoot":"","sources":["../../src/internal/helper-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EACX,gBAAgB,EAChB,uBAAuB,EACvB,UAAU,EACV,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,SAAS,gBAAgB,CAAC,KAAK,CAAC,EACvC,KAAK,SAAS,UAAU,EAExB,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,EACpC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,IAAI,EAAE,KAAK,GACT,uBAAuB,CAAC,KAAK,CAAC,CAsBhC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,SAAS,gBAAgB,CAAC,KAAK,CAAC,EACvC,KAAK,SAAS,UAAU,EAExB,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,EACpC,QAAQ,EAAE,uBAAuB,CAAC,KAAK,CAAC,EACxC,IAAI,EAAE,KAAK,EACX,cAAc,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,KAAK,MAAM,EACtE,WAAW,EAAE,YAAY,GACvB,IAAI,CAuBN"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @wpkernel/pipeline
|
|
3
|
+
* @license EUPL-1.2
|
|
4
|
+
*/
|
|
5
|
+
function c(o, n, l) {
|
|
6
|
+
const s = [], t = [], i = [];
|
|
7
|
+
for (const r of o) {
|
|
8
|
+
const e = r.helper.key;
|
|
9
|
+
s.push(e), n.has(r.id) ? t.push(e) : i.push(e);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
kind: l,
|
|
13
|
+
registered: s,
|
|
14
|
+
executed: t,
|
|
15
|
+
missing: i
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function u(o, n, l, s, t) {
|
|
19
|
+
if (n.missing.length === 0)
|
|
20
|
+
return;
|
|
21
|
+
const i = o.filter(
|
|
22
|
+
(e) => n.missing.includes(e.helper.key) && !e.helper.optional
|
|
23
|
+
);
|
|
24
|
+
if (i.length === 0)
|
|
25
|
+
return;
|
|
26
|
+
const r = i.map(
|
|
27
|
+
(e) => s(l, e.helper)
|
|
28
|
+
);
|
|
29
|
+
throw t(
|
|
30
|
+
"ValidationError",
|
|
31
|
+
`Pipeline finalisation aborted because ${r.join(", ")} did not execute.`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
u as assertAllHelpersExecuted,
|
|
36
|
+
c as buildExecutionSnapshot
|
|
37
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Helper, HelperKind, PipelineReporter, PipelineDiagnostic } from '../types';
|
|
2
|
+
import { PipelineRunner, PipelineRunnerDependencies } from './pipeline-runner.types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the orchestrator responsible for executing pipeline runs.
|
|
5
|
+
*
|
|
6
|
+
* The runner wires together dependency graph resolution, helper execution, and the official
|
|
7
|
+
* extension framework via the {@link initExtensionCoordinator}. By extracting this logic, the
|
|
8
|
+
* public {@link createPipeline} entry point remains focused on registration while the runner keeps
|
|
9
|
+
* lifecycle sequencing isolated and testable.
|
|
10
|
+
*
|
|
11
|
+
* @param dependencies
|
|
12
|
+
* @category Pipeline
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function initPipelineRunner<TRunOptions, TBuildOptions, TContext extends {
|
|
16
|
+
reporter: TReporter;
|
|
17
|
+
}, TReporter extends PipelineReporter, TDraft, TArtifact, TDiagnostic extends PipelineDiagnostic, TRunResult, TFragmentInput, TFragmentOutput, TBuilderInput, TBuilderOutput, TFragmentKind extends HelperKind, TBuilderKind extends HelperKind, TFragmentHelper extends Helper<TContext, TFragmentInput, TFragmentOutput, TReporter, TFragmentKind>, TBuilderHelper extends Helper<TContext, TBuilderInput, TBuilderOutput, TReporter, TBuilderKind>>(dependencies: PipelineRunnerDependencies<TRunOptions, TBuildOptions, TContext, TReporter, TDraft, TArtifact, TDiagnostic, TRunResult, TFragmentInput, TFragmentOutput, TBuilderInput, TBuilderOutput, TFragmentKind, TBuilderKind, TFragmentHelper, TBuilderHelper>): PipelineRunner<TRunOptions, TBuildOptions, TContext, TReporter, TDraft, TArtifact, TDiagnostic, TRunResult, TFragmentInput, TFragmentOutput, TBuilderInput, TBuilderOutput, TFragmentKind, TBuilderKind, TFragmentHelper, TBuilderHelper>;
|
|
18
|
+
//# sourceMappingURL=pipeline-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-runner.d.ts","sourceRoot":"","sources":["../../src/internal/pipeline-runner.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAGX,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAMlB,MAAM,UAAU,CAAC;AAMlB,OAAO,KAAK,EAEX,cAAc,EACd,0BAA0B,EAC1B,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CACjC,WAAW,EACX,aAAa,EACb,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,MAAM,EACN,SAAS,EACT,WAAW,SAAS,kBAAkB,EACtC,UAAU,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,aAAa,SAAS,UAAU,EAChC,YAAY,SAAS,UAAU,EAC/B,eAAe,SAAS,MAAM,CAC7B,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,EAED,YAAY,EAAE,0BAA0B,CACvC,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,cAAc,CAChB,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,CA8ZA"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { maybeThen as x, maybeTry as F } from "../async-utils.js";
|
|
2
|
+
import { createDependencyGraph as U } from "../dependency-graph.js";
|
|
3
|
+
import { executeHelpers as C } from "../executor.js";
|
|
4
|
+
import { buildExecutionSnapshot as v, assertAllHelpersExecuted as A } from "./helper-execution.js";
|
|
5
|
+
import { initExtensionCoordinator as B } from "./extension-coordinator.js";
|
|
6
|
+
/**
|
|
7
|
+
* @wpkernel/pipeline
|
|
8
|
+
* @license EUPL-1.2
|
|
9
|
+
*/
|
|
10
|
+
function j(r) {
|
|
11
|
+
return {
|
|
12
|
+
prepareContext: (s) => {
|
|
13
|
+
const a = r.options.createBuildOptions(s), n = r.options.createContext(s);
|
|
14
|
+
r.diagnosticManager.setReporter(n.reporter);
|
|
15
|
+
const l = r.options.createFragmentState({
|
|
16
|
+
options: s,
|
|
17
|
+
context: n,
|
|
18
|
+
buildOptions: a
|
|
19
|
+
}), m = U(
|
|
20
|
+
r.fragmentEntries,
|
|
21
|
+
{
|
|
22
|
+
onMissingDependency: ({ dependant: t, dependencyKey: e }) => {
|
|
23
|
+
const o = t.helper;
|
|
24
|
+
r.diagnosticManager.flagMissingDependency(
|
|
25
|
+
o,
|
|
26
|
+
e,
|
|
27
|
+
r.fragmentKind
|
|
28
|
+
), r.diagnosticManager.flagUnusedHelper(
|
|
29
|
+
o,
|
|
30
|
+
r.fragmentKind,
|
|
31
|
+
`could not execute because dependency "${e}" was not found`,
|
|
32
|
+
o.dependsOn
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
onUnresolvedHelpers: ({ unresolved: t }) => {
|
|
36
|
+
for (const e of t) {
|
|
37
|
+
const o = e.helper;
|
|
38
|
+
r.diagnosticManager.flagUnusedHelper(
|
|
39
|
+
o,
|
|
40
|
+
r.fragmentKind,
|
|
41
|
+
"could not execute because its dependencies never resolved",
|
|
42
|
+
o.dependsOn
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
r.createError
|
|
48
|
+
).order, c = [], b = (t) => {
|
|
49
|
+
const e = t.helper;
|
|
50
|
+
c.push({
|
|
51
|
+
id: t.id,
|
|
52
|
+
index: c.length,
|
|
53
|
+
key: e.key,
|
|
54
|
+
kind: e.kind,
|
|
55
|
+
mode: e.mode,
|
|
56
|
+
priority: e.priority,
|
|
57
|
+
dependsOn: e.dependsOn,
|
|
58
|
+
origin: e.origin
|
|
59
|
+
});
|
|
60
|
+
}, p = {
|
|
61
|
+
onMissingDependency: ({ dependant: t, dependencyKey: e }) => {
|
|
62
|
+
const o = t.helper;
|
|
63
|
+
r.diagnosticManager.flagMissingDependency(
|
|
64
|
+
o,
|
|
65
|
+
e,
|
|
66
|
+
r.builderKind
|
|
67
|
+
), r.diagnosticManager.flagUnusedHelper(
|
|
68
|
+
o,
|
|
69
|
+
r.builderKind,
|
|
70
|
+
`could not execute because dependency "${e}" was not found`,
|
|
71
|
+
o.dependsOn
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
onUnresolvedHelpers: ({ unresolved: t }) => {
|
|
75
|
+
for (const e of t) {
|
|
76
|
+
const o = e.helper;
|
|
77
|
+
r.diagnosticManager.flagUnusedHelper(
|
|
78
|
+
o,
|
|
79
|
+
r.builderKind,
|
|
80
|
+
"could not execute because its dependencies never resolved",
|
|
81
|
+
o.dependsOn
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, E = r.options.createExtensionHookOptions ?? ((t) => ({
|
|
86
|
+
context: t.context,
|
|
87
|
+
options: t.options,
|
|
88
|
+
artifact: t.artifact,
|
|
89
|
+
lifecycle: t.lifecycle
|
|
90
|
+
})), y = (t, e) => E({
|
|
91
|
+
context: n,
|
|
92
|
+
options: s,
|
|
93
|
+
buildOptions: a,
|
|
94
|
+
artifact: t,
|
|
95
|
+
lifecycle: e
|
|
96
|
+
}), M = r.options.onExtensionRollbackError ?? ((t) => {
|
|
97
|
+
const { reporter: e } = t.context, o = e.warn;
|
|
98
|
+
typeof o == "function" && o.call(e, "Pipeline extension rollback failed.", {
|
|
99
|
+
error: t.error,
|
|
100
|
+
errorName: t.errorMetadata.name,
|
|
101
|
+
errorMessage: t.errorMetadata.message,
|
|
102
|
+
errorStack: t.errorMetadata.stack,
|
|
103
|
+
errorCause: t.errorMetadata.cause,
|
|
104
|
+
extensions: t.extensionKeys,
|
|
105
|
+
hookKeys: t.hookSequence
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
runOptions: s,
|
|
110
|
+
buildOptions: a,
|
|
111
|
+
context: n,
|
|
112
|
+
draft: l,
|
|
113
|
+
fragmentOrder: m,
|
|
114
|
+
steps: c,
|
|
115
|
+
pushStep: b,
|
|
116
|
+
builderGraphOptions: p,
|
|
117
|
+
buildHookOptions: y,
|
|
118
|
+
handleRollbackError: M
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
executeRun: (s) => {
|
|
122
|
+
const {
|
|
123
|
+
runOptions: a,
|
|
124
|
+
buildOptions: n,
|
|
125
|
+
context: l,
|
|
126
|
+
draft: m,
|
|
127
|
+
fragmentOrder: c,
|
|
128
|
+
steps: b,
|
|
129
|
+
pushStep: p,
|
|
130
|
+
builderGraphOptions: E,
|
|
131
|
+
buildHookOptions: y,
|
|
132
|
+
handleRollbackError: M
|
|
133
|
+
} = s;
|
|
134
|
+
let t = v(
|
|
135
|
+
r.builderEntries,
|
|
136
|
+
/* @__PURE__ */ new Set(),
|
|
137
|
+
r.builderKind
|
|
138
|
+
);
|
|
139
|
+
const e = C(
|
|
140
|
+
c,
|
|
141
|
+
(o) => r.options.createFragmentArgs({
|
|
142
|
+
helper: o.helper,
|
|
143
|
+
options: a,
|
|
144
|
+
context: l,
|
|
145
|
+
buildOptions: n,
|
|
146
|
+
draft: m
|
|
147
|
+
}),
|
|
148
|
+
(o, g, u) => o.apply(g, u),
|
|
149
|
+
(o) => p(o)
|
|
150
|
+
);
|
|
151
|
+
return x(e, (o) => {
|
|
152
|
+
r.diagnosticManager.reviewUnusedHelpers(
|
|
153
|
+
r.fragmentEntries,
|
|
154
|
+
o,
|
|
155
|
+
r.fragmentKind
|
|
156
|
+
);
|
|
157
|
+
const g = v(
|
|
158
|
+
r.fragmentEntries,
|
|
159
|
+
o,
|
|
160
|
+
r.fragmentKind
|
|
161
|
+
);
|
|
162
|
+
A(
|
|
163
|
+
r.fragmentEntries,
|
|
164
|
+
g,
|
|
165
|
+
r.fragmentKind,
|
|
166
|
+
r.diagnosticManager.describeHelper,
|
|
167
|
+
r.createError
|
|
168
|
+
);
|
|
169
|
+
let u = r.options.finalizeFragmentState({
|
|
170
|
+
draft: m,
|
|
171
|
+
options: a,
|
|
172
|
+
context: l,
|
|
173
|
+
buildOptions: n,
|
|
174
|
+
helpers: { fragments: g }
|
|
175
|
+
});
|
|
176
|
+
const D = U(
|
|
177
|
+
r.builderEntries,
|
|
178
|
+
E,
|
|
179
|
+
r.createError
|
|
180
|
+
).order, H = B(
|
|
181
|
+
({ error: f, extensionKeys: h, hookSequence: R, errorMetadata: K }) => M({
|
|
182
|
+
error: f,
|
|
183
|
+
extensionKeys: h,
|
|
184
|
+
hookSequence: R,
|
|
185
|
+
errorMetadata: K,
|
|
186
|
+
context: l
|
|
187
|
+
})
|
|
188
|
+
), w = "after-fragments", O = H.runLifecycle(
|
|
189
|
+
w,
|
|
190
|
+
{
|
|
191
|
+
hooks: r.extensionHooks,
|
|
192
|
+
hookOptions: y(u, w)
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
return x(O, (f) => {
|
|
196
|
+
u = f.artifact;
|
|
197
|
+
const h = () => H.createRollbackHandler(
|
|
198
|
+
f
|
|
199
|
+
), R = h(), K = (i) => {
|
|
200
|
+
r.diagnosticManager.reviewUnusedHelpers(
|
|
201
|
+
r.builderEntries,
|
|
202
|
+
i,
|
|
203
|
+
r.builderKind
|
|
204
|
+
);
|
|
205
|
+
const d = v(
|
|
206
|
+
r.builderEntries,
|
|
207
|
+
i,
|
|
208
|
+
r.builderKind
|
|
209
|
+
);
|
|
210
|
+
A(
|
|
211
|
+
r.builderEntries,
|
|
212
|
+
d,
|
|
213
|
+
r.builderKind,
|
|
214
|
+
r.diagnosticManager.describeHelper,
|
|
215
|
+
r.createError
|
|
216
|
+
), t = d;
|
|
217
|
+
const k = () => r.resolveRunResult({
|
|
218
|
+
artifact: u,
|
|
219
|
+
diagnostics: [
|
|
220
|
+
...r.diagnosticManager.readDiagnostics()
|
|
221
|
+
],
|
|
222
|
+
steps: b,
|
|
223
|
+
context: l,
|
|
224
|
+
buildOptions: n,
|
|
225
|
+
options: a,
|
|
226
|
+
helpers: {
|
|
227
|
+
fragments: g,
|
|
228
|
+
builders: t
|
|
229
|
+
}
|
|
230
|
+
}), S = h();
|
|
231
|
+
return x(
|
|
232
|
+
F(
|
|
233
|
+
() => H.commit(f),
|
|
234
|
+
S
|
|
235
|
+
),
|
|
236
|
+
k
|
|
237
|
+
);
|
|
238
|
+
};
|
|
239
|
+
return F(() => x(
|
|
240
|
+
C(
|
|
241
|
+
D,
|
|
242
|
+
(i) => r.options.createBuilderArgs({
|
|
243
|
+
helper: i.helper,
|
|
244
|
+
options: a,
|
|
245
|
+
context: l,
|
|
246
|
+
buildOptions: n,
|
|
247
|
+
artifact: u
|
|
248
|
+
}),
|
|
249
|
+
(i, d, k) => i.apply(d, k),
|
|
250
|
+
(i) => p(i)
|
|
251
|
+
),
|
|
252
|
+
K
|
|
253
|
+
), R);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
export {
|
|
260
|
+
j as initPipelineRunner
|
|
261
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { CreateDependencyGraphOptions, RegisteredHelper } from '../dependency-graph';
|
|
2
|
+
import { ErrorFactory } from '../error-factory';
|
|
3
|
+
import { CreatePipelineOptions, Helper, HelperApplyOptions, HelperKind, MaybePromise, PipelineDiagnostic, PipelineExecutionMetadata, PipelineExtensionHookOptions, PipelineExtensionLifecycle, PipelineExtensionRollbackErrorMetadata, PipelineReporter, PipelineStep } from '../types';
|
|
4
|
+
import { DiagnosticManager } from './diagnostic-manager.types';
|
|
5
|
+
import { ExtensionHookEntry } from '../extensions';
|
|
6
|
+
/**
|
|
7
|
+
* Mutable state captured while preparing a pipeline run. This mirrors the context consumed by
|
|
8
|
+
* {@link executeHelpers} and downstream extension orchestration.
|
|
9
|
+
*
|
|
10
|
+
* @category Pipeline
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export interface PipelineRunContext<TRunOptions, TBuildOptions, TContext, TDraft, TArtifact, TFragmentHelper, TBuilderHelper> {
|
|
14
|
+
readonly runOptions: TRunOptions;
|
|
15
|
+
readonly buildOptions: TBuildOptions;
|
|
16
|
+
readonly context: TContext;
|
|
17
|
+
readonly draft: TDraft;
|
|
18
|
+
readonly fragmentOrder: RegisteredHelper<TFragmentHelper>[];
|
|
19
|
+
readonly steps: PipelineStep[];
|
|
20
|
+
readonly pushStep: (entry: RegisteredHelper<unknown>) => void;
|
|
21
|
+
readonly builderGraphOptions: CreateDependencyGraphOptions<TBuilderHelper>;
|
|
22
|
+
readonly buildHookOptions: (artifact: TArtifact, lifecycle: PipelineExtensionLifecycle) => PipelineExtensionHookOptions<TContext, TRunOptions, TArtifact>;
|
|
23
|
+
readonly handleRollbackError: (options: {
|
|
24
|
+
readonly error: unknown;
|
|
25
|
+
readonly extensionKeys: readonly string[];
|
|
26
|
+
readonly hookSequence: readonly string[];
|
|
27
|
+
readonly errorMetadata: PipelineExtensionRollbackErrorMetadata;
|
|
28
|
+
readonly context: TContext;
|
|
29
|
+
}) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Dependency bundle consumed by {@link initPipelineRunner}. Splitting the type into a dedicated
|
|
33
|
+
* module improves cognitive load in the implementation file and keeps the generics re-usable for
|
|
34
|
+
* test doubles.
|
|
35
|
+
*
|
|
36
|
+
* @category Pipeline
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export interface PipelineRunnerDependencies<TRunOptions, TBuildOptions, TContext extends {
|
|
40
|
+
reporter: TReporter;
|
|
41
|
+
}, TReporter extends PipelineReporter, TDraft, TArtifact, TDiagnostic extends PipelineDiagnostic, TRunResult, TFragmentInput, TFragmentOutput, TBuilderInput, TBuilderOutput, TFragmentKind extends HelperKind, TBuilderKind extends HelperKind, TFragmentHelper extends Helper<TContext, TFragmentInput, TFragmentOutput, TReporter, TFragmentKind>, TBuilderHelper extends Helper<TContext, TBuilderInput, TBuilderOutput, TReporter, TBuilderKind>> {
|
|
42
|
+
readonly options: CreatePipelineOptions<TRunOptions, TBuildOptions, TContext, TReporter, TDraft, TArtifact, TDiagnostic, TRunResult, TFragmentInput, TFragmentOutput, TBuilderInput, TBuilderOutput, TFragmentKind, TBuilderKind, TFragmentHelper, TBuilderHelper>;
|
|
43
|
+
readonly fragmentEntries: RegisteredHelper<TFragmentHelper>[];
|
|
44
|
+
readonly builderEntries: RegisteredHelper<TBuilderHelper>[];
|
|
45
|
+
readonly fragmentKind: TFragmentKind;
|
|
46
|
+
readonly builderKind: TBuilderKind;
|
|
47
|
+
readonly diagnosticManager: DiagnosticManager<TRunOptions, TBuildOptions, TContext, TReporter, TDraft, TArtifact, TDiagnostic, TRunResult, TFragmentInput, TFragmentOutput, TBuilderInput, TBuilderOutput, TFragmentKind, TBuilderKind, TFragmentHelper, TBuilderHelper>;
|
|
48
|
+
readonly createError: ErrorFactory;
|
|
49
|
+
readonly resolveRunResult: (state: {
|
|
50
|
+
readonly artifact: TArtifact;
|
|
51
|
+
readonly diagnostics: readonly TDiagnostic[];
|
|
52
|
+
readonly steps: readonly PipelineStep[];
|
|
53
|
+
readonly context: TContext;
|
|
54
|
+
readonly buildOptions: TBuildOptions;
|
|
55
|
+
readonly options: TRunOptions;
|
|
56
|
+
readonly helpers: PipelineExecutionMetadata<TFragmentKind, TBuilderKind>;
|
|
57
|
+
}) => TRunResult;
|
|
58
|
+
readonly extensionHooks: ExtensionHookEntry<TContext, TRunOptions, TArtifact>[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Public surface returned by {@link initPipelineRunner}. Downstream consumers receive a helper to
|
|
62
|
+
* prepare the context (building dependency graphs, instantiating drafts) and an executor that runs
|
|
63
|
+
* the prepared context through fragments, extensions, and builders.
|
|
64
|
+
*
|
|
65
|
+
* @category Pipeline
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export interface PipelineRunner<TRunOptions, TBuildOptions, TContext extends {
|
|
69
|
+
reporter: TReporter;
|
|
70
|
+
}, TReporter extends PipelineReporter, TDraft, TArtifact, TDiagnostic extends PipelineDiagnostic, TRunResult, TFragmentInput, TFragmentOutput, TBuilderInput, TBuilderOutput, TFragmentKind extends HelperKind, TBuilderKind extends HelperKind, TFragmentHelper extends Helper<TContext, TFragmentInput, TFragmentOutput, TReporter, TFragmentKind>, TBuilderHelper extends Helper<TContext, TBuilderInput, TBuilderOutput, TReporter, TBuilderKind>> {
|
|
71
|
+
readonly prepareContext: (runOptions: TRunOptions) => PipelineRunContext<TRunOptions, TBuildOptions, TContext, TDraft, TArtifact, TFragmentHelper, TBuilderHelper>;
|
|
72
|
+
readonly executeRun: (context: PipelineRunContext<TRunOptions, TBuildOptions, TContext, TDraft, TArtifact, TFragmentHelper, TBuilderHelper>) => MaybePromise<TRunResult>;
|
|
73
|
+
readonly __types?: {
|
|
74
|
+
diagnostic: TDiagnostic;
|
|
75
|
+
helperArgs: HelperApplyOptions<unknown, unknown, unknown>;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export type { ExtensionHookEntry };
|
|
79
|
+
//# sourceMappingURL=pipeline-runner.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-runner.types.d.ts","sourceRoot":"","sources":["../../src/internal/pipeline-runner.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,4BAA4B,EAC5B,gBAAgB,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EACX,qBAAqB,EACrB,MAAM,EACN,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,yBAAyB,EACzB,4BAA4B,EAC5B,0BAA0B,EAC1B,sCAAsC,EACtC,gBAAgB,EAChB,YAAY,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB,CAClC,WAAW,EACX,aAAa,EACb,QAAQ,EACR,MAAM,EACN,SAAS,EACT,eAAe,EACf,cAAc;IAEd,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,gBAAgB,CAAC,eAAe,CAAC,EAAE,CAAC;IAC5D,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAA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AS,SAAS,gBAAgB,EAClC,MAAM,EACN,SAAS,EACT,WAAW,SAAS,kBAAkB,EACtC,UAAU,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,aAAa,SAAS,UAAU,EAChC,YAAY,SAAS,UAAU,EAC/B,eAAe,SAAS,MAAM,CAC7B,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;IAED,QAAQ,CAAC,cAAc,EAAE,CACxB,UAAU,EAAE,WAAW,KACnB,kBAAkB,CACtB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,MAAM,EACN,SAAS,EACT,eAAe,EACf,cAAc,CACd,CAAC;IACF,QAAQ,CAAC,UAAU,EAAE,CACpB,OAAO,EAAE,kBAAkB,CAC1B,WAAW,EACX,aAAa,EACb,QAAQ,EACR,MAAM,EACN,SAAS,EACT,eAAe,EACf,cAAc,CACd,KACG,YAAY,CAAC,UAAU,CAAC,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE;QAClB,UAAU,EAAE,WAAW,CAAC;QACxB,UAAU,EAAE,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;KAC1D,CAAC;CACF;AAED,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/registration.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Helper, HelperKind, PipelineExtensionHook, PipelineReporter } from './types';
|
|
1
|
+
import { Helper, HelperKind, PipelineExtensionHook, PipelineExtensionLifecycle, PipelineReporter } from './types';
|
|
2
2
|
import { RegisteredHelper } from './dependency-graph';
|
|
3
3
|
import { ExtensionHookEntry } from './extensions';
|
|
4
4
|
import { ErrorFactory } from './error-factory';
|
|
@@ -22,11 +22,12 @@ export declare function registerHelper<TContext, TInput, TOutput, TReporter exte
|
|
|
22
22
|
* @param key - Optional unique key for the hook
|
|
23
23
|
* @param hook - The extension hook function
|
|
24
24
|
* @param extensionHooks - The array of registered extension hooks
|
|
25
|
+
* @param lifecycle
|
|
25
26
|
* @returns The resolved key used for registration
|
|
26
27
|
*
|
|
27
28
|
* @internal
|
|
28
29
|
*/
|
|
29
|
-
export declare function registerExtensionHook<TContext, TOptions, TArtifact>(key: string | undefined, hook: PipelineExtensionHook<TContext, TOptions, TArtifact>, extensionHooks: ExtensionHookEntry<TContext, TOptions, TArtifact>[]): string;
|
|
30
|
+
export declare function registerExtensionHook<TContext, TOptions, TArtifact>(key: string | undefined, hook: PipelineExtensionHook<TContext, TOptions, TArtifact>, extensionHooks: ExtensionHookEntry<TContext, TOptions, TArtifact>[], lifecycle?: PipelineExtensionLifecycle): string;
|
|
30
31
|
/**
|
|
31
32
|
* Handles the result of an extension's register() method.
|
|
32
33
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../src/registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EACN,UAAU,EACV,qBAAqB,
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../src/registration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,MAAM,EACN,UAAU,EACV,qBAAqB,EAErB,0BAA0B,EAC1B,gBAAgB,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC7B,QAAQ,EACR,MAAM,EACN,OAAO,EACP,SAAS,SAAS,gBAAgB,EAClC,KAAK,SAAS,UAAU,EACxB,OAAO,SAAS,MAAM,CACrB,QAAQ,EACR,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,CACL,GAAG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,EAEvD,MAAM,EAAE,OAAO,EACf,YAAY,EAAE,UAAU,EACxB,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,EACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,EACzE,WAAW,EAAE,YAAY,GACvB,IAAI,CA6BN;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAClE,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,IAAI,EAAE,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,EAC1D,cAAc,EAAE,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,EACnE,SAAS,GAAE,0BAA8C,GACvD,MAAM,CASR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAC1E,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,MAAM,EAAE,OAAO,EACf,cAAc,EAAE,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,GACjE,OAAO,CAqCT"}
|
package/dist/registration.js
CHANGED
|
@@ -1,50 +1,61 @@
|
|
|
1
|
-
import { createHelperId as
|
|
1
|
+
import { createHelperId as a } from "./dependency-graph.js";
|
|
2
2
|
/**
|
|
3
3
|
* @wpkernel/pipeline
|
|
4
4
|
* @license EUPL-1.2
|
|
5
5
|
*/
|
|
6
|
-
function
|
|
7
|
-
if (e.kind !==
|
|
8
|
-
throw
|
|
6
|
+
function p(e, i, o, t, r, d) {
|
|
7
|
+
if (e.kind !== i)
|
|
8
|
+
throw d(
|
|
9
9
|
"ValidationError",
|
|
10
|
-
`Attempted to register helper "${e.key}" as ${
|
|
10
|
+
`Attempted to register helper "${e.key}" as ${t} but received kind "${e.kind}".`
|
|
11
11
|
);
|
|
12
12
|
if (e.mode === "override") {
|
|
13
|
-
const
|
|
13
|
+
const c = o.find(
|
|
14
14
|
(n) => n.helper.key === e.key && n.helper.mode === "override"
|
|
15
15
|
);
|
|
16
|
-
if (
|
|
16
|
+
if (c) {
|
|
17
17
|
const n = `Multiple overrides registered for helper "${e.key}".`;
|
|
18
|
-
throw
|
|
18
|
+
throw r(e, c.helper, n), d("ValidationError", n);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const f = o.length;
|
|
22
|
+
o.push({
|
|
23
23
|
helper: e,
|
|
24
|
-
id:
|
|
25
|
-
index:
|
|
24
|
+
id: a(e, f),
|
|
25
|
+
index: f
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const
|
|
30
|
-
return
|
|
31
|
-
key:
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
function g(e, i, o, t = "after-fragments") {
|
|
29
|
+
const r = e ?? `pipeline.extension#${o.length + 1}`;
|
|
30
|
+
return o.push({
|
|
31
|
+
key: r,
|
|
32
|
+
lifecycle: t,
|
|
33
|
+
hook: i
|
|
34
|
+
}), r;
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
-
if (typeof
|
|
37
|
-
|
|
36
|
+
function s(e, i, o) {
|
|
37
|
+
if (typeof i == "function") {
|
|
38
|
+
g(
|
|
38
39
|
e,
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
i,
|
|
41
|
+
o
|
|
41
42
|
);
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
+
if (i && typeof i == "object" && "hook" in i && typeof i.hook == "function") {
|
|
46
|
+
const t = i;
|
|
47
|
+
g(
|
|
48
|
+
e,
|
|
49
|
+
t.hook,
|
|
50
|
+
o,
|
|
51
|
+
t.lifecycle
|
|
52
|
+
);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
return i;
|
|
45
56
|
}
|
|
46
57
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
s as handleExtensionRegisterResult,
|
|
59
|
+
g as registerExtensionHook,
|
|
60
|
+
p as registerHelper
|
|
50
61
|
};
|