@wpkernel/pipeline 0.12.6-beta.3 → 1.1.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.
@@ -1,4 +1,3 @@
1
1
  export * from './runner';
2
- export { OFFICIAL_EXTENSION_BLUEPRINTS } from './official';
3
2
  export type { OfficialExtensionBlueprint, ExtensionBlueprint, ExtensionBehaviour, ExtensionFactorySignature, } from './official';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,YAAY,EACX,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,GACzB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAGzB,YAAY,EACX,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,GACzB,MAAM,YAAY,CAAC"}
@@ -1,38 +1,36 @@
1
1
  import { composeK as o, isPromiseLike as t, maybeAll as a, maybeThen as l, maybeTry as p, processSequentially as n } from "./async-utils.js";
2
2
  import { createPipelineExtension as c } from "./createExtension.js";
3
3
  import { compareHelpers as m, createDependencyGraph as x, createHelperId as f } from "./dependency-graph.js";
4
- import { createDefaultError as k, createErrorFactory as u } from "./error-factory.js";
5
- import { createHelper as b } from "./helper.js";
6
- import { handleExtensionRegisterResult as H, registerExtensionHook as I, registerHelper as P } from "./registration.js";
7
- import { createPipelineRollback as S, createRollbackErrorMetadata as T, runRollbackStack as g } from "./rollback.js";
8
- import { makePipeline as F } from "./makePipeline.js";
9
- import { executeHelpers as N } from "./execution-utils.js";
10
- import { OFFICIAL_EXTENSION_BLUEPRINTS as D } from "./extensions/official.js";
11
- import { commitExtensionResults as _, rollbackExtensionResults as q, runExtensionHooks as B } from "./extensions/runner.js";
4
+ import { createDefaultError as E, createErrorFactory as u } from "./error-factory.js";
5
+ import { createHelper as y } from "./helper.js";
6
+ import { handleExtensionRegisterResult as R, registerExtensionHook as d, registerHelper as P } from "./registration.js";
7
+ import { createPipelineRollback as h, createRollbackErrorMetadata as D, runRollbackStack as S } from "./rollback.js";
8
+ import { makePipeline as q } from "./makePipeline.js";
9
+ import { executeHelpers as F } from "./execution-utils.js";
10
+ import { commitExtensionResults as I, rollbackExtensionResults as K, runExtensionHooks as L } from "./extensions/runner.js";
12
11
  export {
13
- D as OFFICIAL_EXTENSION_BLUEPRINTS,
14
- _ as commitExtensionResults,
12
+ I as commitExtensionResults,
15
13
  m as compareHelpers,
16
14
  o as composeK,
17
- k as createDefaultError,
15
+ E as createDefaultError,
18
16
  x as createDependencyGraph,
19
17
  u as createErrorFactory,
20
- b as createHelper,
18
+ y as createHelper,
21
19
  f as createHelperId,
22
20
  c as createPipelineExtension,
23
- S as createPipelineRollback,
24
- T as createRollbackErrorMetadata,
25
- N as executeHelpers,
26
- H as handleExtensionRegisterResult,
21
+ h as createPipelineRollback,
22
+ D as createRollbackErrorMetadata,
23
+ F as executeHelpers,
24
+ R as handleExtensionRegisterResult,
27
25
  t as isPromiseLike,
28
- F as makePipeline,
26
+ q as makePipeline,
29
27
  a as maybeAll,
30
28
  l as maybeThen,
31
29
  p as maybeTry,
32
30
  n as processSequentially,
33
- I as registerExtensionHook,
31
+ d as registerExtensionHook,
34
32
  P as registerHelper,
35
- q as rollbackExtensionResults,
36
- B as runExtensionHooks,
37
- g as runRollbackStack
33
+ K as rollbackExtensionResults,
34
+ L as runExtensionHooks,
35
+ S as runRollbackStack
38
36
  };
@@ -0,0 +1,6 @@
1
+ import { PipelineDiagnostic, PipelineReporter, PipelineRunState, AgnosticPipelineOptions, ResumablePipeline } from './types';
2
+ import { AgnosticState } from './runner/types';
3
+ export declare function makeResumablePipeline<TRunOptions, TContext extends {
4
+ reporter: TReporter;
5
+ }, TReporter extends PipelineReporter = PipelineReporter, TUserState = unknown, TDiagnostic extends PipelineDiagnostic = PipelineDiagnostic, TRunResult = PipelineRunState<TUserState, TDiagnostic>>(options: AgnosticPipelineOptions<TRunOptions, TContext, TReporter, TUserState, TDiagnostic, TRunResult>): ResumablePipeline<TRunOptions, TRunResult, TContext, TReporter, AgnosticState<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>>;
6
+ //# sourceMappingURL=makeResumablePipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeResumablePipeline.d.ts","sourceRoot":"","sources":["../../src/core/makeResumablePipeline.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAKX,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAEhB,uBAAuB,EACvB,iBAAiB,EAEjB,MAAM,SAAS,CAAC;AAIjB,OAAO,KAAK,EAKX,aAAa,EACb,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,qBAAqB,CACpC,WAAW,EACX,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,GAAG,gBAAgB,EACrD,UAAU,GAAG,OAAO,EACpB,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,UAAU,GAAG,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,EAEtD,OAAO,EAAE,uBAAuB,CAC/B,WAAW,EACX,QAAQ,EACR,SAAS,EACT,UAAU,EACV,WAAW,EACX,UAAU,CACV,GACC,iBAAiB,CACnB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CACxE,CAkYA"}
@@ -0,0 +1,160 @@
1
+ import { maybeThen as u, isPromiseLike as g, maybeAll as C } from "./async-utils.js";
2
+ import { registerHelper as M, handleExtensionRegisterResult as w } from "./registration.js";
3
+ import { initAgnosticResumableRunner as P } from "./runner/index.js";
4
+ import { createAgnosticDiagnosticManager as S } from "./runner/diagnostics.js";
5
+ import { isPaused as b } from "./runner/stage-factories.js";
6
+ function O(n) {
7
+ const R = n.createError ?? ((e, r) => new Error(`[${e}] ${r} `)), l = /* @__PURE__ */ new Map(), h = (e) => (l.has(e) || l.set(e, []), l.get(e));
8
+ for (const e of n.helperKinds)
9
+ h(e);
10
+ const x = [], c = [], i = S({
11
+ onDiagnostic: (e) => {
12
+ n.onDiagnostic ? n.onDiagnostic(e) : e.reporter.warn?.(
13
+ "Pipeline diagnostic reported.",
14
+ e.diagnostic
15
+ );
16
+ },
17
+ createConflictDiagnostic: n.createConflictDiagnostic,
18
+ createMissingDependencyDiagnostic: n.createMissingDependencyDiagnostic,
19
+ createUnusedHelperDiagnostic: n.createUnusedHelperDiagnostic
20
+ }), p = (e) => {
21
+ const r = [];
22
+ for (const t of n.helperKinds)
23
+ r.push(e.makeHelperStage(t));
24
+ return r.push(e.finalizeResult), r;
25
+ }, E = {
26
+ options: {
27
+ createContext: n.createContext,
28
+ createState: (e) => n.createState ? n.createState(e) : {},
29
+ createError: R,
30
+ supportsPause: !0,
31
+ onExtensionRollbackError: (e) => {
32
+ n.onExtensionRollbackError && n.onExtensionRollbackError(e);
33
+ const r = {
34
+ ...e,
35
+ extensions: e.extensionKeys,
36
+ hookKeys: e.hookSequence,
37
+ errorName: e.errorMetadata?.name,
38
+ errorMessage: e.errorMetadata?.message,
39
+ errorStack: e.errorMetadata?.stack,
40
+ errorCause: e.errorMetadata?.cause,
41
+ ...e.errorMetadata
42
+ };
43
+ e.context.reporter.warn?.(
44
+ "Pipeline extension rollback failed.",
45
+ r
46
+ );
47
+ },
48
+ onHelperRollbackError: (e) => {
49
+ e.context.reporter.warn?.("Helper rollback failed", e);
50
+ },
51
+ providedKeys: n.providedKeys
52
+ },
53
+ helperRegistries: l,
54
+ diagnosticManager: i,
55
+ resolveRunResult: (e) => {
56
+ const {
57
+ userState: r,
58
+ diagnostics: t,
59
+ steps: s,
60
+ context: o,
61
+ options: a,
62
+ state: v
63
+ } = e;
64
+ return n.createRunResult ? n.createRunResult({
65
+ artifact: r,
66
+ diagnostics: t,
67
+ steps: s,
68
+ context: o,
69
+ options: a,
70
+ state: v
71
+ }) : {
72
+ artifact: r,
73
+ diagnostics: t,
74
+ steps: s
75
+ };
76
+ },
77
+ extensionHooks: x,
78
+ extensionLifecycles: n.extensions?.lifecycles,
79
+ stages: n.createStages ?? p
80
+ }, f = P(E), D = (e, r) => w(e, r, x), y = (e) => {
81
+ if (g(e)) {
82
+ const r = u(
83
+ e,
84
+ () => {
85
+ }
86
+ );
87
+ r.catch(() => {
88
+ }), c.push(r);
89
+ const t = () => {
90
+ const s = c.indexOf(r);
91
+ s !== -1 && c.splice(s, 1);
92
+ };
93
+ r.then(t, t);
94
+ }
95
+ return e;
96
+ }, m = () => {
97
+ if (c.length !== 0)
98
+ return u(
99
+ C([...c]),
100
+ () => {
101
+ }
102
+ );
103
+ }, d = (e) => (b(e) || i.endRun(), e), k = {
104
+ extensions: {
105
+ use(e) {
106
+ const r = e.register(k);
107
+ r && g(r) && Promise.resolve(r).catch(() => {
108
+ });
109
+ const t = u(
110
+ r,
111
+ (s) => D(e.key, s)
112
+ );
113
+ return y(t);
114
+ }
115
+ },
116
+ use(e) {
117
+ const r = e.kind, t = h(r);
118
+ M(
119
+ e,
120
+ r,
121
+ t,
122
+ r,
123
+ (s, o, a) => i.flagConflict(
124
+ s,
125
+ o,
126
+ r,
127
+ a
128
+ ),
129
+ R
130
+ );
131
+ },
132
+ run(e) {
133
+ try {
134
+ const r = () => {
135
+ const o = f.prepareContext(e);
136
+ return f.executeRun(o);
137
+ }, t = m(), s = u(t, () => r());
138
+ return g(s) ? Promise.resolve(s).then(d).catch((o) => {
139
+ throw i.endRun(), o;
140
+ }) : d(s);
141
+ } catch (r) {
142
+ throw i.endRun(), r;
143
+ }
144
+ },
145
+ resume(e, r) {
146
+ try {
147
+ const t = () => f.executeResume(e, r), s = m(), o = u(s, () => t());
148
+ return g(o) ? Promise.resolve(o).then(d).catch((a) => {
149
+ throw i.endRun(), a;
150
+ }) : d(o);
151
+ } catch (t) {
152
+ throw i.endRun(), t;
153
+ }
154
+ }
155
+ };
156
+ return k;
157
+ }
158
+ export {
159
+ O as makeResumablePipeline
160
+ };
@@ -1,5 +1,5 @@
1
- import { AgnosticRunContext, AgnosticRunnerDependencies } from './types';
2
- import { PipelineReporter, PipelineDiagnostic } from '../types';
1
+ import { AgnosticRunContext, AgnosticRunnerDependencies, AgnosticState } from './types';
2
+ import { PipelineReporter, PipelineDiagnostic, PipelinePauseSnapshot } from '../types';
3
3
  /**
4
4
  * Prepares the pipeline execution context.
5
5
  *
@@ -10,4 +10,7 @@ import { PipelineReporter, PipelineDiagnostic } from '../types';
10
10
  export declare const prepareContext: <TRunOptions, TUserState, TContext extends {
11
11
  reporter: TReporter;
12
12
  }, TReporter extends PipelineReporter, TDiagnostic extends PipelineDiagnostic, TRunResult>(dependencies: AgnosticRunnerDependencies<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>, runOptions: TRunOptions) => AgnosticRunContext<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>;
13
+ export declare const prepareResumeContext: <TRunOptions, TUserState, TContext extends {
14
+ reporter: TReporter;
15
+ }, TReporter extends PipelineReporter, TDiagnostic extends PipelineDiagnostic, TRunResult>(dependencies: AgnosticRunnerDependencies<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>, snapshot: PipelinePauseSnapshot<AgnosticState<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>>) => AgnosticRunContext<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>;
13
16
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/runner/context.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,kBAAkB,EAClB,0BAA0B,EAE1B,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACX,gBAAgB,EAChB,kBAAkB,EAElB,MAAM,UAAU,CAAC;AAIlB;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAC1B,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,EACD,YAAY,WAAW,KACrB,kBAAkB,CACpB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CA6HX,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/core/runner/context.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,kBAAkB,EAClB,0BAA0B,EAC1B,aAAa,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACX,gBAAgB,EAChB,kBAAkB,EAElB,qBAAqB,EACrB,MAAM,UAAU,CAAC;AAIlB;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAC1B,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,EACD,YAAY,WAAW,KACrB,kBAAkB,CACpB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CA6HX,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAChC,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,EACD,UAAU,qBAAqB,CAC9B,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CACxE,KACC,kBAAkB,CACpB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CAkDX,CAAC"}
@@ -1,57 +1,57 @@
1
- import { createDependencyGraph as M } from "../dependency-graph.js";
2
- import { initExtensionCoordinator as R } from "../internal/extension-coordinator.js";
3
- const E = (e, n) => {
4
- const o = e.options.createContext(n);
5
- e.diagnosticManager.prepareRun(), e.diagnosticManager.setReporter(o.reporter);
1
+ import { createDependencyGraph as x } from "../dependency-graph.js";
2
+ import { initExtensionCoordinator as f } from "../internal/extension-coordinator.js";
3
+ const M = (e, o) => {
4
+ const t = e.options.createContext(o);
5
+ e.diagnosticManager.prepareRun(), e.diagnosticManager.setReporter(t.reporter);
6
6
  const s = /* @__PURE__ */ new Map();
7
- for (const [r, i] of e.helperRegistries) {
8
- const f = M(
9
- i,
7
+ for (const [r, h] of e.helperRegistries) {
8
+ const d = x(
9
+ h,
10
10
  {
11
- onMissingDependency: (t) => {
11
+ onMissingDependency: (a) => {
12
12
  e.diagnosticManager.flagMissingDependency(
13
- t.dependant.helper,
14
- t.dependencyKey,
13
+ a.dependant.helper,
14
+ a.dependencyKey,
15
15
  r
16
16
  ), e.diagnosticManager.flagUnusedHelper(
17
- t.dependant.helper,
17
+ a.dependant.helper,
18
18
  r,
19
19
  "has missing dependencies",
20
- t.dependant.helper.dependsOn ?? []
20
+ a.dependant.helper.dependsOn ?? []
21
21
  );
22
22
  },
23
- onUnresolvedHelpers: ({ unresolved: t }) => {
24
- for (const l of t)
23
+ onUnresolvedHelpers: ({ unresolved: a }) => {
24
+ for (const R of a)
25
25
  e.diagnosticManager.flagUnusedHelper(
26
- l.helper,
26
+ R.helper,
27
27
  r,
28
28
  "has unresolved dependencies (possible cycle)",
29
- l.helper.dependsOn ?? []
29
+ R.helper.dependsOn ?? []
30
30
  );
31
31
  },
32
32
  providedKeys: e.options.providedKeys?.[r]
33
33
  },
34
34
  e.options.createError
35
35
  );
36
- s.set(r, f.order);
36
+ s.set(r, d.order);
37
37
  }
38
- const c = e.options.createState({
39
- context: o,
40
- options: n
41
- }), a = [], g = (r) => a.push(r), p = (r) => {
38
+ const i = e.options.createState({
39
+ context: t,
40
+ options: o
41
+ }), p = [], c = (r) => p.push(r), l = (r) => {
42
42
  e.options.onExtensionRollbackError && e.options.onExtensionRollbackError(r);
43
- }, h = (r, i) => ({
44
- context: o,
45
- options: n,
43
+ }, n = (r, h) => ({
44
+ context: t,
45
+ options: o,
46
46
  artifact: r.userState,
47
47
  // Extension expects UserState
48
- lifecycle: i
49
- }), d = {
50
- context: o,
51
- reporter: o.reporter,
52
- runOptions: n,
53
- userState: c,
54
- steps: a,
48
+ lifecycle: h
49
+ }), g = {
50
+ context: t,
51
+ reporter: t.reporter,
52
+ runOptions: o,
53
+ userState: i,
54
+ steps: p,
55
55
  diagnostics: e.diagnosticManager.getDiagnostics(),
56
56
  // Live reference
57
57
  // AgnosticState definition has diagnostics: TDiagnostic[]. Programs read it from here.
@@ -62,25 +62,48 @@ const E = (e, n) => {
62
62
  // Runtime maps
63
63
  helperExecution: /* @__PURE__ */ new Map(),
64
64
  helperRollbacks: /* @__PURE__ */ new Map(),
65
- extensionCoordinator: R(
66
- (r) => p({
65
+ extensionCoordinator: f(
66
+ (r) => l({
67
67
  ...r,
68
- context: o
68
+ context: t
69
69
  })
70
70
  )
71
71
  };
72
72
  return {
73
- runOptions: n,
74
- context: o,
75
- state: d,
76
- steps: a,
77
- pushStep: g,
73
+ runOptions: o,
74
+ context: t,
75
+ state: g,
76
+ steps: p,
77
+ pushStep: c,
78
78
  helperRegistries: e.helperRegistries,
79
79
  helperOrders: s,
80
- buildHookOptions: h,
81
- handleRollbackError: p
80
+ buildHookOptions: n,
81
+ handleRollbackError: l
82
+ };
83
+ }, b = (e, o) => {
84
+ const t = o.state, s = t.context;
85
+ e.diagnosticManager.setReporter(s.reporter);
86
+ const i = t.steps, p = (n) => i.push(n), c = (n) => {
87
+ e.options.onExtensionRollbackError && e.options.onExtensionRollbackError(n);
88
+ }, l = (n, g) => ({
89
+ context: s,
90
+ options: t.runOptions,
91
+ artifact: n.userState,
92
+ lifecycle: g
93
+ });
94
+ return {
95
+ runOptions: t.runOptions,
96
+ context: s,
97
+ state: t,
98
+ steps: i,
99
+ pushStep: p,
100
+ helperRegistries: t.helperRegistries,
101
+ helperOrders: t.helperOrders ?? /* @__PURE__ */ new Map(),
102
+ buildHookOptions: l,
103
+ handleRollbackError: c
82
104
  };
83
105
  };
84
106
  export {
85
- E as prepareContext
107
+ M as prepareContext,
108
+ b as prepareResumeContext
86
109
  };
@@ -1,6 +1,12 @@
1
- import { AgnosticRunContext, AgnosticRunnerDependencies } from './types';
2
- import { PipelineReporter, PipelineDiagnostic, MaybePromise } from '../types';
1
+ import { AgnosticRunContext, AgnosticRunnerDependencies, AgnosticState } from './types';
2
+ import { PipelineReporter, PipelineDiagnostic, MaybePromise, PipelinePauseSnapshot, PipelinePaused } from '../types';
3
3
  export declare const executeRun: <TRunOptions, TUserState, TContext extends {
4
4
  reporter: TReporter;
5
5
  }, TReporter extends PipelineReporter, TDiagnostic extends PipelineDiagnostic, TRunResult>(dependencies: AgnosticRunnerDependencies<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>, runContext: AgnosticRunContext<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>) => MaybePromise<TRunResult>;
6
+ export declare const executeRunWithPause: <TRunOptions, TUserState, TContext extends {
7
+ reporter: TReporter;
8
+ }, TReporter extends PipelineReporter, TDiagnostic extends PipelineDiagnostic, TRunResult>(dependencies: AgnosticRunnerDependencies<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>, runContext: AgnosticRunContext<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>) => MaybePromise<TRunResult | PipelinePaused<AgnosticState<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>>>;
9
+ export declare const executeResume: <TRunOptions, TUserState, TContext extends {
10
+ reporter: TReporter;
11
+ }, TReporter extends PipelineReporter, TDiagnostic extends PipelineDiagnostic, TRunResult>(dependencies: AgnosticRunnerDependencies<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>, snapshot: PipelinePauseSnapshot<AgnosticState<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>>, resumeInput?: unknown) => MaybePromise<TRunResult | PipelinePaused<AgnosticState<TRunOptions, TUserState, TContext, TReporter, TDiagnostic>>>;
6
12
  //# sourceMappingURL=execution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/core/runner/execution.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,kBAAkB,EAClB,0BAA0B,EAM1B,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACX,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,MAAM,UAAU,CAAC;AAalB,eAAO,MAAM,UAAU,GACtB,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,EACD,YAAY,kBAAkB,CAC7B,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CACX,KACC,YAAY,CAAC,UAAU,CAkHzB,CAAC"}
1
+ {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../../src/core/runner/execution.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,kBAAkB,EAClB,0BAA0B,EAC1B,aAAa,EAOb,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACX,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,MAAM,UAAU,CAAC;AAyMlB,eAAO,MAAM,UAAU,GACtB,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,EACD,YAAY,kBAAkB,CAC7B,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CACX,KACC,YAAY,CAAC,UAAU,CA2EzB,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC/B,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,EACD,YAAY,kBAAkB,CAC7B,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CACX,KACC,YAAY,CACZ,UAAU,GACV,cAAc,CACd,aAAa,CACZ,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CACX,CACA,CAqCH,CAAC;AAEF,eAAO,MAAM,aAAa,GACzB,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,EACD,UAAU,qBAAqB,CAC9B,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CACxE,EACD,cAAc,OAAO,KACnB,YAAY,CACZ,UAAU,GACV,cAAc,CACd,aAAa,CACZ,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,CACX,CACA,CAgCH,CAAC"}
@@ -1,66 +1,136 @@
1
- import { maybeThen as i } from "../async-utils.js";
2
- import { createAgnosticProgram as f } from "./program.js";
3
- const s = (o) => ({
4
- kind: o,
1
+ import { maybeThen as m, isPromiseLike as y } from "../async-utils.js";
2
+ import { createAgnosticStages as R, createAgnosticProgram as P } from "./program.js";
3
+ import { isHalt as c, isPaused as f } from "./stage-factories.js";
4
+ import { prepareResumeContext as l } from "./context.js";
5
+ const S = (e) => ({
6
+ kind: e,
5
7
  registered: [],
6
8
  executed: [],
7
9
  missing: []
8
- }), h = (o, e) => {
10
+ }), k = (e, t) => ({
11
+ ...e,
12
+ stageIndex: t
13
+ }), x = (e, t) => {
14
+ const i = t.extensionStack ?? [], s = i.length === 0 && t.extensionCoordinator && t.extensionState ? () => t.extensionCoordinator.commit(t.extensionState) : void 0, n = s ? s() : i.reduce(
15
+ (a, {
16
+ coordinator: o,
17
+ state: r
18
+ }) => m(a, () => o.commit(r)),
19
+ void 0
20
+ );
21
+ return m(
22
+ n,
23
+ () => e.resolveRunResult({
24
+ diagnostics: t.diagnostics,
25
+ steps: t.steps,
26
+ context: t.context,
27
+ userState: t.userState,
28
+ options: t.runOptions,
29
+ helpers: {
30
+ fragments: S("dummy-fragment"),
31
+ builders: S("dummy-builder")
32
+ },
33
+ state: t
34
+ })
35
+ );
36
+ }, h = (e, t, i) => {
37
+ const s = (n, a) => {
38
+ let o = n;
39
+ for (let r = a; r < e.length; r += 1) {
40
+ const p = e[r];
41
+ if (!p)
42
+ return o;
43
+ const b = k(o, r), u = p(b);
44
+ if (y(u))
45
+ return Promise.resolve(u).then((g) => c(g) || f(g) ? g : s(
46
+ g,
47
+ r + 1
48
+ ));
49
+ if (c(u) || f(u))
50
+ return u;
51
+ o = u;
52
+ }
53
+ return o;
54
+ };
55
+ return s(t, i);
56
+ }, O = (e, t) => {
9
57
  const {
10
- runOptions: m,
11
- context: c
12
- } = e, n = e.state;
13
- if (!o.stages)
14
- return o.resolveRunResult({
58
+ runOptions: i,
59
+ context: s
60
+ } = t, n = t.state;
61
+ if (!e.stages)
62
+ return e.resolveRunResult({
15
63
  diagnostics: [],
16
64
  steps: [],
17
- context: c,
65
+ context: s,
18
66
  userState: n.userState,
19
- options: m,
67
+ options: i,
20
68
  helpers: {
21
- builders: s("dummy-builder")
69
+ builders: S("dummy-builder")
22
70
  },
23
71
  state: n
24
72
  });
25
- const p = f(o, e);
26
- return i(
27
- p(n),
28
- (t) => {
29
- if (t && typeof t == "object" && "__halt" in t) {
30
- if (t.error)
31
- throw t.error;
32
- return t.result;
73
+ const a = P(e, t);
74
+ return m(
75
+ a(n),
76
+ (o) => {
77
+ if (c(o)) {
78
+ if (o.error)
79
+ throw o.error;
80
+ return o.result;
33
81
  }
34
- const r = t.extensionStack ?? [], a = r.length === 0 && t.extensionCoordinator && t.extensionState ? () => t.extensionCoordinator.commit(
35
- t.extensionState
36
- ) : void 0, g = a ? a() : r.reduce(
37
- (d, {
38
- coordinator: x,
39
- state: S
40
- }) => i(
41
- d,
42
- () => x.commit(S)
43
- ),
44
- void 0
45
- );
46
- return i(
47
- g,
48
- () => o.resolveRunResult({
49
- diagnostics: t.diagnostics,
50
- steps: t.steps,
51
- context: t.context,
52
- userState: t.userState,
53
- options: t.runOptions,
54
- helpers: {
55
- fragments: s("dummy-fragment"),
56
- builders: s("dummy-builder")
57
- },
58
- state: t
59
- })
60
- );
82
+ if (f(o))
83
+ throw new Error(
84
+ "Pipeline paused during executeRun. Use makeResumablePipeline to enable pause/resume."
85
+ );
86
+ return x(e, o);
61
87
  }
62
88
  );
89
+ }, A = (e, t) => {
90
+ const { runOptions: i, context: s } = t, n = t.state;
91
+ if (!e.stages)
92
+ return e.resolveRunResult({
93
+ diagnostics: [],
94
+ steps: [],
95
+ context: s,
96
+ userState: n.userState,
97
+ options: i,
98
+ helpers: {
99
+ builders: S("dummy-builder")
100
+ },
101
+ state: n
102
+ });
103
+ const a = R(e, t), o = h(a, n, 0);
104
+ return m(o, (r) => {
105
+ if (c(r)) {
106
+ if (r.error)
107
+ throw r.error;
108
+ return r.result;
109
+ }
110
+ return f(r) ? r : x(e, r);
111
+ });
112
+ }, E = (e, t, i) => {
113
+ if (!e.stages)
114
+ return x(e, t.state);
115
+ const s = l(e, t), n = {
116
+ ...s.state,
117
+ resumeInput: i
118
+ }, a = R(e, s), o = h(
119
+ a,
120
+ n,
121
+ t.stageIndex
122
+ );
123
+ return m(o, (r) => {
124
+ if (c(r)) {
125
+ if (r.error)
126
+ throw r.error;
127
+ return r.result;
128
+ }
129
+ return f(r) ? r : x(e, r);
130
+ });
63
131
  };
64
132
  export {
65
- h as executeRun
133
+ E as executeResume,
134
+ O as executeRun,
135
+ A as executeRunWithPause
66
136
  };
@@ -1,4 +1,4 @@
1
- import { AgnosticRunner, AgnosticRunnerDependencies } from './types';
1
+ import { AgnosticResumableRunner, AgnosticRunner, AgnosticRunnerDependencies } from './types';
2
2
  import { PipelineReporter, PipelineDiagnostic } from '../types';
3
3
  /**
4
4
  * Initializes an agnostic pipeline runner.
@@ -11,4 +11,7 @@ import { PipelineReporter, PipelineDiagnostic } from '../types';
11
11
  export declare const initAgnosticRunner: <TRunOptions, TUserState, TContext extends {
12
12
  reporter: TReporter;
13
13
  }, TReporter extends PipelineReporter, TDiagnostic extends PipelineDiagnostic, TRunResult>(dependencies: AgnosticRunnerDependencies<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>) => AgnosticRunner<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>;
14
+ export declare const initAgnosticResumableRunner: <TRunOptions, TUserState, TContext extends {
15
+ reporter: TReporter;
16
+ }, TReporter extends PipelineReporter, TDiagnostic extends PipelineDiagnostic, TRunResult>(dependencies: AgnosticRunnerDependencies<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>) => AgnosticResumableRunner<TRunOptions, TUserState, TContext, TReporter, TDiagnostic, TRunResult>;
14
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/runner/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAC9B,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,KACC,cAAc,CAChB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CAOV,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/runner/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,uBAAuB,EACvB,cAAc,EACd,0BAA0B,EAC1B,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAErE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAC9B,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,KACC,cAAc,CAChB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CAOV,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACvC,WAAW,EACX,UAAU,EACV,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,kBAAkB,EACtC,UAAU,EAEV,cAAc,0BAA0B,CACvC,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CACV,KACC,uBAAuB,CACzB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,UAAU,CASV,CAAC"}