@wpkernel/pipeline 0.12.2-beta.0 → 0.12.3-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/async-utils.d.ts +14 -0
- package/dist/async-utils.d.ts.map +1 -1
- package/dist/async-utils.js +18 -17
- package/dist/createExtension.d.ts +7 -1
- package/dist/createExtension.d.ts.map +1 -1
- package/dist/createExtension.js +0 -4
- package/dist/createPipeline.js +0 -4
- package/dist/dependency-graph.d.ts +6 -0
- package/dist/dependency-graph.d.ts.map +1 -1
- package/dist/dependency-graph.js +73 -69
- package/dist/error-factory.d.ts +1 -1
- package/dist/error-factory.js +0 -4
- package/dist/executor.js +0 -4
- package/dist/extensions/index.js +0 -4
- package/dist/extensions/official.js +0 -4
- package/dist/extensions.d.ts.map +1 -1
- package/dist/extensions.js +61 -66
- package/dist/helper.d.ts +27 -16
- package/dist/helper.d.ts.map +1 -1
- package/dist/helper.js +0 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -25
- package/dist/internal/diagnostic-manager.js +0 -4
- package/dist/internal/extension-coordinator.js +0 -4
- package/dist/internal/helper-execution.js +0 -4
- 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.d.ts +1 -1
- package/dist/internal/pipeline-runner.d.ts.map +1 -1
- package/dist/internal/pipeline-runner.js +329 -247
- package/dist/internal/pipeline-runner.types.d.ts +89 -1
- package/dist/internal/pipeline-runner.types.d.ts.map +1 -1
- package/dist/registration.js +0 -4
- 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 +36 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,261 +1,343 @@
|
|
|
1
|
-
import { maybeThen as
|
|
2
|
-
import { createDependencyGraph as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
1
|
+
import { maybeThen as b, composeK as j } from "../async-utils.js";
|
|
2
|
+
import { createDependencyGraph as x } from "../dependency-graph.js";
|
|
3
|
+
import { buildExecutionSnapshot as u, assertAllHelpersExecuted as E } from "./helper-execution.js";
|
|
4
|
+
import { initExtensionCoordinator as I } from "./extension-coordinator.js";
|
|
5
|
+
import { isHalt as g, makeFinalizeResultStage as J, makeCommitStage as Q, makeHelperStageFactory as W, makeAfterFragmentsStage as X, makeFinalizeFragmentsStage as Y, runRollbackToHalt as Z } from "./pipeline-program-utils.js";
|
|
6
|
+
const h = "after-fragments";
|
|
7
|
+
function ar(o) {
|
|
8
|
+
const p = (r) => ({
|
|
9
|
+
__halt: !0,
|
|
10
|
+
error: r
|
|
11
|
+
}), k = (r) => {
|
|
12
|
+
const t = o.options.createBuildOptions(r), n = o.options.createContext(r);
|
|
13
|
+
o.diagnosticManager.setReporter(n.reporter);
|
|
14
|
+
const l = o.options.createFragmentState({
|
|
15
|
+
options: r,
|
|
16
|
+
context: n,
|
|
17
|
+
buildOptions: t
|
|
18
|
+
}), c = x(
|
|
19
|
+
o.fragmentEntries,
|
|
20
|
+
{
|
|
21
|
+
providedKeys: o.options.fragmentProvidedKeys,
|
|
22
|
+
onMissingDependency: ({ dependant: e, dependencyKey: i }) => {
|
|
23
|
+
const a = e.helper;
|
|
24
|
+
o.diagnosticManager.flagMissingDependency(
|
|
25
|
+
a,
|
|
26
|
+
i,
|
|
27
|
+
o.fragmentKind
|
|
28
|
+
), o.diagnosticManager.flagUnusedHelper(
|
|
29
|
+
a,
|
|
30
|
+
o.fragmentKind,
|
|
31
|
+
`could not execute because dependency "${i}" was not found`,
|
|
32
|
+
a.dependsOn
|
|
72
33
|
);
|
|
73
34
|
},
|
|
74
|
-
onUnresolvedHelpers: ({ unresolved:
|
|
75
|
-
for (const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
35
|
+
onUnresolvedHelpers: ({ unresolved: e }) => {
|
|
36
|
+
for (const i of e) {
|
|
37
|
+
const a = i.helper;
|
|
38
|
+
o.diagnosticManager.flagUnusedHelper(
|
|
39
|
+
a,
|
|
40
|
+
o.fragmentKind,
|
|
80
41
|
"could not execute because its dependencies never resolved",
|
|
81
|
-
|
|
42
|
+
a.dependsOn
|
|
82
43
|
);
|
|
83
44
|
}
|
|
84
45
|
}
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
});
|
|
46
|
+
},
|
|
47
|
+
o.createError
|
|
48
|
+
).order, s = [], m = (e) => {
|
|
49
|
+
const i = e.helper;
|
|
50
|
+
s.push({
|
|
51
|
+
id: e.id,
|
|
52
|
+
index: s.length,
|
|
53
|
+
key: i.key,
|
|
54
|
+
kind: i.kind,
|
|
55
|
+
mode: i.mode,
|
|
56
|
+
priority: i.priority,
|
|
57
|
+
dependsOn: i.dependsOn,
|
|
58
|
+
origin: i.origin
|
|
107
59
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
}
|
|
60
|
+
}, f = {
|
|
61
|
+
providedKeys: o.options.builderProvidedKeys,
|
|
62
|
+
onMissingDependency: ({ dependant: e, dependencyKey: i }) => {
|
|
63
|
+
const a = e.helper;
|
|
64
|
+
o.diagnosticManager.flagMissingDependency(
|
|
65
|
+
a,
|
|
66
|
+
i,
|
|
67
|
+
o.builderKind
|
|
68
|
+
), o.diagnosticManager.flagUnusedHelper(
|
|
69
|
+
a,
|
|
70
|
+
o.builderKind,
|
|
71
|
+
`could not execute because dependency "${i}" was not found`,
|
|
72
|
+
a.dependsOn
|
|
194
73
|
);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
-
});
|
|
74
|
+
},
|
|
75
|
+
onUnresolvedHelpers: ({ unresolved: e }) => {
|
|
76
|
+
for (const i of e) {
|
|
77
|
+
const a = i.helper;
|
|
78
|
+
o.diagnosticManager.flagUnusedHelper(
|
|
79
|
+
a,
|
|
80
|
+
o.builderKind,
|
|
81
|
+
"could not execute because its dependencies never resolved",
|
|
82
|
+
a.dependsOn
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, N = o.options.createExtensionHookOptions ?? ((e) => ({
|
|
87
|
+
context: e.context,
|
|
88
|
+
options: e.options,
|
|
89
|
+
artifact: e.artifact,
|
|
90
|
+
lifecycle: e.lifecycle
|
|
91
|
+
})), $ = (e, i) => N({
|
|
92
|
+
context: n,
|
|
93
|
+
options: r,
|
|
94
|
+
buildOptions: t,
|
|
95
|
+
artifact: e,
|
|
96
|
+
lifecycle: i
|
|
97
|
+
}), q = o.options.onExtensionRollbackError ?? ((e) => {
|
|
98
|
+
const { reporter: i } = e.context, a = i.warn;
|
|
99
|
+
typeof a == "function" && a.call(i, "Pipeline extension rollback failed.", {
|
|
100
|
+
error: e.error,
|
|
101
|
+
errorName: e.errorMetadata.name,
|
|
102
|
+
errorMessage: e.errorMetadata.message,
|
|
103
|
+
errorStack: e.errorMetadata.stack,
|
|
104
|
+
errorCause: e.errorMetadata.cause,
|
|
105
|
+
extensions: e.extensionKeys,
|
|
106
|
+
hookKeys: e.hookSequence
|
|
255
107
|
});
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
runOptions: r,
|
|
111
|
+
buildOptions: t,
|
|
112
|
+
context: n,
|
|
113
|
+
draft: l,
|
|
114
|
+
fragmentOrder: c,
|
|
115
|
+
steps: s,
|
|
116
|
+
pushStep: m,
|
|
117
|
+
builderGraphOptions: f,
|
|
118
|
+
buildHookOptions: $,
|
|
119
|
+
handleRollbackError: q
|
|
120
|
+
};
|
|
121
|
+
}, R = (r, t, n) => {
|
|
122
|
+
o.diagnosticManager.reviewUnusedHelpers(
|
|
123
|
+
r.fragmentEntries,
|
|
124
|
+
t,
|
|
125
|
+
o.fragmentKind
|
|
126
|
+
);
|
|
127
|
+
const l = u(
|
|
128
|
+
r.fragmentEntries,
|
|
129
|
+
t,
|
|
130
|
+
o.fragmentKind
|
|
131
|
+
);
|
|
132
|
+
return E(
|
|
133
|
+
r.fragmentEntries,
|
|
134
|
+
l,
|
|
135
|
+
o.fragmentKind,
|
|
136
|
+
o.diagnosticManager.describeHelper,
|
|
137
|
+
o.createError
|
|
138
|
+
), {
|
|
139
|
+
...r,
|
|
140
|
+
fragmentVisited: t,
|
|
141
|
+
fragmentExecution: l,
|
|
142
|
+
fragmentRollbacks: n
|
|
143
|
+
};
|
|
144
|
+
}, H = (r, t, n) => {
|
|
145
|
+
o.diagnosticManager.reviewUnusedHelpers(
|
|
146
|
+
r.builderEntries,
|
|
147
|
+
t,
|
|
148
|
+
o.builderKind
|
|
149
|
+
);
|
|
150
|
+
const l = u(
|
|
151
|
+
r.builderEntries,
|
|
152
|
+
t,
|
|
153
|
+
o.builderKind
|
|
154
|
+
);
|
|
155
|
+
return E(
|
|
156
|
+
r.builderEntries,
|
|
157
|
+
l,
|
|
158
|
+
o.builderKind,
|
|
159
|
+
o.diagnosticManager.describeHelper,
|
|
160
|
+
o.createError
|
|
161
|
+
), {
|
|
162
|
+
...r,
|
|
163
|
+
builderVisited: t,
|
|
164
|
+
builderExecution: l,
|
|
165
|
+
builderRollbacks: n
|
|
166
|
+
};
|
|
167
|
+
}, O = (r, t) => o.options.createFragmentArgs({
|
|
168
|
+
helper: t.helper,
|
|
169
|
+
options: r.runOptions,
|
|
170
|
+
context: r.context,
|
|
171
|
+
buildOptions: r.buildOptions,
|
|
172
|
+
draft: r.draft
|
|
173
|
+
}), y = (r, t) => o.options.createBuilderArgs({
|
|
174
|
+
helper: t.helper,
|
|
175
|
+
options: r.runOptions,
|
|
176
|
+
context: r.context,
|
|
177
|
+
buildOptions: r.buildOptions,
|
|
178
|
+
artifact: r.artifact
|
|
179
|
+
}), M = (r) => (t) => O(r, t), F = (r) => (t) => y(r, t), K = (r) => r.fragmentRollbacks, S = (r) => r.builderRollbacks ?? [], d = (r) => ({
|
|
180
|
+
context: r.context,
|
|
181
|
+
extensionCoordinator: r.extensionCoordinator,
|
|
182
|
+
extensionState: r.extensionState
|
|
183
|
+
}), A = (r) => r.fragmentExecution ?? u(
|
|
184
|
+
r.fragmentEntries,
|
|
185
|
+
r.fragmentVisited,
|
|
186
|
+
o.fragmentKind
|
|
187
|
+
), P = (r) => {
|
|
188
|
+
const { extensionCoordinator: t, extensionState: n } = r;
|
|
189
|
+
if (!(!t || !n))
|
|
190
|
+
return t.commit(n);
|
|
191
|
+
}, v = (r) => ({
|
|
192
|
+
context: r.context,
|
|
193
|
+
rollbackContext: d(r),
|
|
194
|
+
helperRollbacks: r.builderRollbacks ?? [],
|
|
195
|
+
onHelperRollbackError: o.options.onHelperRollbackError
|
|
196
|
+
}), w = (r, t) => Z(
|
|
197
|
+
{
|
|
198
|
+
rollbackPlan: v(r),
|
|
199
|
+
halt: p
|
|
200
|
+
},
|
|
201
|
+
t
|
|
202
|
+
), B = (r) => (t) => {
|
|
203
|
+
const n = I(
|
|
204
|
+
({ error: c, extensionKeys: s, hookSequence: m, errorMetadata: f }) => r.handleRollbackError({
|
|
205
|
+
error: c,
|
|
206
|
+
extensionKeys: s,
|
|
207
|
+
hookSequence: m,
|
|
208
|
+
errorMetadata: f,
|
|
209
|
+
context: t.context
|
|
210
|
+
})
|
|
211
|
+
), l = n.runLifecycle(
|
|
212
|
+
h,
|
|
213
|
+
{
|
|
214
|
+
hooks: o.extensionHooks,
|
|
215
|
+
hookOptions: r.buildHookOptions(
|
|
216
|
+
t.artifact,
|
|
217
|
+
h
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
return b(
|
|
222
|
+
l,
|
|
223
|
+
(c) => ({
|
|
224
|
+
...t,
|
|
225
|
+
artifact: c.artifact,
|
|
226
|
+
extensionCoordinator: n,
|
|
227
|
+
extensionState: c
|
|
228
|
+
})
|
|
229
|
+
);
|
|
230
|
+
}, U = (r) => r.helpers ?? {
|
|
231
|
+
fragments: r.fragmentExecution ?? u(
|
|
232
|
+
r.fragmentEntries,
|
|
233
|
+
r.fragmentVisited,
|
|
234
|
+
o.fragmentKind
|
|
235
|
+
),
|
|
236
|
+
builders: r.builderExecution ?? u(
|
|
237
|
+
r.builderEntries,
|
|
238
|
+
r.builderVisited,
|
|
239
|
+
o.builderKind
|
|
240
|
+
)
|
|
241
|
+
}, z = (r) => ({
|
|
242
|
+
...r,
|
|
243
|
+
helpers: U(r),
|
|
244
|
+
diagnostics: [
|
|
245
|
+
...o.diagnosticManager.readDiagnostics()
|
|
246
|
+
]
|
|
247
|
+
}), D = Y({
|
|
248
|
+
isHalt: g,
|
|
249
|
+
snapshotFragments: A,
|
|
250
|
+
applyArtifact: (r, t) => ({
|
|
251
|
+
...r,
|
|
252
|
+
artifact: o.options.finalizeFragmentState({
|
|
253
|
+
draft: r.draft,
|
|
254
|
+
options: r.runOptions,
|
|
255
|
+
context: r.context,
|
|
256
|
+
buildOptions: r.buildOptions,
|
|
257
|
+
helpers: {
|
|
258
|
+
fragments: t
|
|
259
|
+
}
|
|
260
|
+
}),
|
|
261
|
+
fragmentExecution: t
|
|
262
|
+
})
|
|
263
|
+
}), T = (r) => X({
|
|
264
|
+
isHalt: g,
|
|
265
|
+
execute: B(r)
|
|
266
|
+
}), G = Q({
|
|
267
|
+
isHalt: g,
|
|
268
|
+
commit: P,
|
|
269
|
+
rollbackToHalt: w
|
|
270
|
+
}), V = J({
|
|
271
|
+
isHalt: g,
|
|
272
|
+
finalize: z
|
|
273
|
+
}), _ = {
|
|
274
|
+
getOrder: (r) => r.fragmentOrder,
|
|
275
|
+
makeArgs: M,
|
|
276
|
+
onVisited: (r, t, n) => R(r, t, n),
|
|
277
|
+
readRollbacks: K
|
|
278
|
+
}, C = {
|
|
279
|
+
getOrder: (r) => r.builderOrder,
|
|
280
|
+
makeArgs: F,
|
|
281
|
+
onVisited: (r, t, n) => H(r, t, n),
|
|
282
|
+
readRollbacks: S
|
|
283
|
+
}, L = (r) => {
|
|
284
|
+
const t = W({
|
|
285
|
+
pushStep: r.pushStep,
|
|
286
|
+
toRollbackContext: d,
|
|
287
|
+
halt: p,
|
|
288
|
+
isHalt: g,
|
|
289
|
+
onHelperRollbackError: o.options.onHelperRollbackError
|
|
290
|
+
}), n = t(_), l = t(C), c = [
|
|
291
|
+
V,
|
|
292
|
+
G,
|
|
293
|
+
l,
|
|
294
|
+
T(r),
|
|
295
|
+
D,
|
|
296
|
+
n
|
|
297
|
+
];
|
|
298
|
+
return j(...c);
|
|
299
|
+
};
|
|
300
|
+
return {
|
|
301
|
+
prepareContext: k,
|
|
302
|
+
executeRun: (r) => {
|
|
303
|
+
const t = x(
|
|
304
|
+
o.builderEntries,
|
|
305
|
+
r.builderGraphOptions,
|
|
306
|
+
o.createError
|
|
307
|
+
).order, n = {
|
|
308
|
+
context: r.context,
|
|
309
|
+
reporter: r.context.reporter,
|
|
310
|
+
runOptions: r.runOptions,
|
|
311
|
+
buildOptions: r.buildOptions,
|
|
312
|
+
fragmentEntries: o.fragmentEntries,
|
|
313
|
+
builderEntries: o.builderEntries,
|
|
314
|
+
fragmentOrder: r.fragmentOrder,
|
|
315
|
+
builderOrder: t,
|
|
316
|
+
fragmentVisited: /* @__PURE__ */ new Set(),
|
|
317
|
+
builderVisited: /* @__PURE__ */ new Set(),
|
|
318
|
+
draft: r.draft,
|
|
319
|
+
artifact: null,
|
|
320
|
+
steps: r.steps,
|
|
321
|
+
diagnostics: [],
|
|
322
|
+
fragmentRollbacks: [],
|
|
323
|
+
builderRollbacks: []
|
|
324
|
+
}, l = L(r), c = (s) => {
|
|
325
|
+
if (g(s))
|
|
326
|
+
throw s.error ?? new Error("Pipeline halted");
|
|
327
|
+
return o.resolveRunResult({
|
|
328
|
+
artifact: s.artifact,
|
|
329
|
+
diagnostics: s.diagnostics,
|
|
330
|
+
steps: s.steps,
|
|
331
|
+
context: s.context,
|
|
332
|
+
buildOptions: s.buildOptions,
|
|
333
|
+
options: s.runOptions,
|
|
334
|
+
helpers: s.helpers
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
return b(l(n), c);
|
|
256
338
|
}
|
|
257
339
|
};
|
|
258
340
|
}
|
|
259
341
|
export {
|
|
260
|
-
|
|
342
|
+
ar as initPipelineRunner
|
|
261
343
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CreateDependencyGraphOptions, RegisteredHelper } from '../dependency-graph';
|
|
2
2
|
import { ErrorFactory } from '../error-factory';
|
|
3
|
-
import { CreatePipelineOptions, Helper, HelperApplyOptions, HelperKind, MaybePromise, PipelineDiagnostic, PipelineExecutionMetadata, PipelineExtensionHookOptions, PipelineExtensionLifecycle, PipelineExtensionRollbackErrorMetadata, PipelineReporter, PipelineStep } from '../types';
|
|
3
|
+
import { CreatePipelineOptions, Helper, HelperApplyOptions, HelperExecutionSnapshot, HelperKind, MaybePromise, PipelineDiagnostic, PipelineExecutionMetadata, PipelineExtensionHookOptions, PipelineExtensionLifecycle, PipelineExtensionRollbackErrorMetadata, PipelineReporter, PipelineStep } from '../types';
|
|
4
|
+
import { PipelineRollback } from '../rollback';
|
|
5
|
+
import { ExtensionCoordinator, ExtensionLifecycleState } from './extension-coordinator.types';
|
|
4
6
|
import { DiagnosticManager } from './diagnostic-manager.types';
|
|
5
7
|
import { ExtensionHookEntry } from '../extensions';
|
|
6
8
|
/**
|
|
@@ -75,5 +77,91 @@ export interface PipelineRunner<TRunOptions, TBuildOptions, TContext extends {
|
|
|
75
77
|
helperArgs: HelperApplyOptions<unknown, unknown, unknown>;
|
|
76
78
|
};
|
|
77
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Closed-world state threaded through composed pipeline programs. While the implementation still
|
|
82
|
+
* mutates some nested values (e.g. `steps`), every program returns a new state value to keep the
|
|
83
|
+
* orchestrator closed under composition.
|
|
84
|
+
*
|
|
85
|
+
* @category Pipeline
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
export interface PipelineState<TRunOptions, TBuildOptions, TContext extends {
|
|
89
|
+
reporter: TReporter;
|
|
90
|
+
}, TReporter extends PipelineReporter, TDraft, TArtifact, TDiagnostic extends PipelineDiagnostic, 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>> {
|
|
91
|
+
readonly context: TContext;
|
|
92
|
+
readonly reporter: TReporter;
|
|
93
|
+
readonly runOptions: TRunOptions;
|
|
94
|
+
readonly buildOptions: TBuildOptions;
|
|
95
|
+
readonly fragmentEntries: RegisteredHelper<TFragmentHelper>[];
|
|
96
|
+
readonly builderEntries: RegisteredHelper<TBuilderHelper>[];
|
|
97
|
+
readonly fragmentOrder: RegisteredHelper<TFragmentHelper>[];
|
|
98
|
+
readonly builderOrder: RegisteredHelper<TBuilderHelper>[];
|
|
99
|
+
readonly fragmentVisited: Set<string>;
|
|
100
|
+
readonly builderVisited: Set<string>;
|
|
101
|
+
readonly draft: TDraft;
|
|
102
|
+
readonly artifact: TArtifact | null;
|
|
103
|
+
readonly steps: PipelineStep[];
|
|
104
|
+
readonly diagnostics: TDiagnostic[];
|
|
105
|
+
readonly fragmentExecution?: HelperExecutionSnapshot<TFragmentKind>;
|
|
106
|
+
readonly builderExecution?: HelperExecutionSnapshot<TBuilderKind>;
|
|
107
|
+
readonly helpers?: PipelineExecutionMetadata<TFragmentKind, TBuilderKind>;
|
|
108
|
+
readonly fragmentRollbacks?: Array<{
|
|
109
|
+
readonly helper: TFragmentHelper;
|
|
110
|
+
readonly rollback: PipelineRollback;
|
|
111
|
+
}>;
|
|
112
|
+
readonly builderRollbacks?: Array<{
|
|
113
|
+
readonly helper: TBuilderHelper;
|
|
114
|
+
readonly rollback: PipelineRollback;
|
|
115
|
+
}>;
|
|
116
|
+
readonly extensionCoordinator?: ExtensionCoordinator<TContext, TRunOptions, TArtifact>;
|
|
117
|
+
readonly extensionState?: ExtensionLifecycleState<TContext, TRunOptions, TArtifact>;
|
|
118
|
+
}
|
|
78
119
|
export type { ExtensionHookEntry };
|
|
120
|
+
export type RollbackCapableCoordinator<TContext, TOptions, TArtifact> = {
|
|
121
|
+
createRollbackHandler: <TResult>(state: ExtensionLifecycleState<TContext, TOptions, TArtifact>) => (error: unknown) => MaybePromise<TResult>;
|
|
122
|
+
};
|
|
123
|
+
export type RollbackEntry<THelper> = {
|
|
124
|
+
readonly helper: THelper;
|
|
125
|
+
readonly rollback: PipelineRollback;
|
|
126
|
+
};
|
|
127
|
+
export type Halt<TRunResult> = {
|
|
128
|
+
readonly __halt: true;
|
|
129
|
+
readonly error?: unknown;
|
|
130
|
+
readonly result?: TRunResult;
|
|
131
|
+
};
|
|
132
|
+
export type RollbackContext<TContext, TOptions, TArtifact> = {
|
|
133
|
+
readonly context: TContext;
|
|
134
|
+
readonly extensionCoordinator?: RollbackCapableCoordinator<TContext, TOptions, TArtifact>;
|
|
135
|
+
readonly extensionState?: ExtensionLifecycleState<TContext, TOptions, TArtifact>;
|
|
136
|
+
};
|
|
137
|
+
export type HelperInvokeOptions<THelper, TInput, TOutput, TContext, TReporter extends PipelineReporter> = {
|
|
138
|
+
readonly helper: THelper;
|
|
139
|
+
readonly args: HelperApplyOptions<TContext, TInput, TOutput, TReporter>;
|
|
140
|
+
readonly next: () => MaybePromise<void>;
|
|
141
|
+
};
|
|
142
|
+
export type StageEnv<TState, TRunResult, TContext, TOptions, TArtifact, TReporter extends PipelineReporter> = {
|
|
143
|
+
pushStep: (entry: RegisteredHelper<unknown>) => void;
|
|
144
|
+
toRollbackContext: (state: TState) => RollbackContext<TContext, TOptions, TArtifact>;
|
|
145
|
+
halt: (error?: unknown) => Halt<TRunResult>;
|
|
146
|
+
isHalt: (value: unknown) => value is Halt<TRunResult>;
|
|
147
|
+
onHelperRollbackError?: (options: {
|
|
148
|
+
readonly error: unknown;
|
|
149
|
+
readonly helper: Helper<TContext, unknown, unknown, TReporter, HelperKind>;
|
|
150
|
+
readonly errorMetadata: PipelineExtensionRollbackErrorMetadata;
|
|
151
|
+
readonly context: TContext;
|
|
152
|
+
}) => void;
|
|
153
|
+
};
|
|
154
|
+
export type HelperRollbackPlan<TContext, TOptions, TArtifact, THelper extends {
|
|
155
|
+
key: string;
|
|
156
|
+
}> = {
|
|
157
|
+
readonly context: TContext;
|
|
158
|
+
readonly rollbackContext: RollbackContext<TContext, TOptions, TArtifact>;
|
|
159
|
+
readonly helperRollbacks: readonly RollbackEntry<THelper>[];
|
|
160
|
+
readonly onHelperRollbackError?: (options: {
|
|
161
|
+
readonly error: unknown;
|
|
162
|
+
readonly helper: THelper;
|
|
163
|
+
readonly errorMetadata: PipelineExtensionRollbackErrorMetadata;
|
|
164
|
+
readonly context: TContext;
|
|
165
|
+
}) => void;
|
|
166
|
+
};
|
|
79
167
|
//# sourceMappingURL=pipeline-runner.types.d.ts.map
|