@tonytang99/integration-core 1.0.0 → 1.2.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/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/pipeline/builder.d.ts +83 -0
- package/dist/pipeline/builder.d.ts.map +1 -0
- package/dist/pipeline/builder.js +210 -0
- package/dist/pipeline/builder.js.map +1 -0
- package/dist/pipeline/context.d.ts +43 -16
- package/dist/pipeline/context.d.ts.map +1 -1
- package/dist/pipeline/context.js +80 -7
- package/dist/pipeline/context.js.map +1 -1
- package/dist/pipeline/executor.d.ts +24 -0
- package/dist/pipeline/executor.d.ts.map +1 -0
- package/dist/pipeline/executor.js +136 -0
- package/dist/pipeline/executor.js.map +1 -0
- package/dist/pipeline/iterators.d.ts +74 -0
- package/dist/pipeline/iterators.d.ts.map +1 -0
- package/dist/pipeline/iterators.js +244 -0
- package/dist/pipeline/iterators.js.map +1 -0
- package/dist/pipeline/middleware.d.ts +26 -0
- package/dist/pipeline/middleware.d.ts.map +1 -0
- package/dist/pipeline/middleware.js +69 -0
- package/dist/pipeline/middleware.js.map +1 -0
- package/dist/pipeline/phase.d.ts +25 -3
- package/dist/pipeline/phase.d.ts.map +1 -1
- package/dist/pipeline/phase.js +33 -3
- package/dist/pipeline/phase.js.map +1 -1
- package/dist/pipeline/retry.d.ts +57 -0
- package/dist/pipeline/retry.d.ts.map +1 -0
- package/dist/pipeline/retry.js +139 -0
- package/dist/pipeline/retry.js.map +1 -0
- package/dist/registry/phase-registry.d.ts +24 -0
- package/dist/registry/phase-registry.d.ts.map +1 -0
- package/dist/registry/phase-registry.js +69 -0
- package/dist/registry/phase-registry.js.map +1 -0
- package/dist/slots/well-known-slots.d.ts +27 -0
- package/dist/slots/well-known-slots.d.ts.map +1 -0
- package/dist/slots/well-known-slots.js +31 -0
- package/dist/slots/well-known-slots.js.map +1 -0
- package/dist/types/common.d.ts +45 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +11 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/errors.d.ts +62 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +262 -0
- package/dist/types/errors.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pipeline = void 0;
|
|
4
|
+
const common_1 = require("../types/common");
|
|
5
|
+
// Error class for explicit phase errors
|
|
6
|
+
class PhaseError extends Error {
|
|
7
|
+
phase;
|
|
8
|
+
code;
|
|
9
|
+
recoverable;
|
|
10
|
+
constructor(phase, code, message, recoverable) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.phase = phase;
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.recoverable = recoverable;
|
|
15
|
+
this.name = 'PhaseError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
class Pipeline {
|
|
19
|
+
phases;
|
|
20
|
+
errorHandlers;
|
|
21
|
+
constructor(phases, errorHandlers) {
|
|
22
|
+
this.phases = phases;
|
|
23
|
+
this.errorHandlers = errorHandlers;
|
|
24
|
+
}
|
|
25
|
+
async execute(initialCtx) {
|
|
26
|
+
const startTime = Date.now();
|
|
27
|
+
let ctx = initialCtx;
|
|
28
|
+
const executed = [];
|
|
29
|
+
for (let i = 0; i < this.phases.length; i++) {
|
|
30
|
+
const phase = this.phases[i];
|
|
31
|
+
ctx = ctx.startPhase(phase.name);
|
|
32
|
+
try {
|
|
33
|
+
if (phase.shouldSkip && await phase.shouldSkip(ctx)) {
|
|
34
|
+
ctx = ctx.completePhase(phase.name, 'skipped');
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
this.validateRequirements(ctx, phase);
|
|
38
|
+
// Execute
|
|
39
|
+
ctx = await phase.execute(ctx);
|
|
40
|
+
executed.push(phase.name);
|
|
41
|
+
ctx = ctx.completePhase(phase.name, 'completed');
|
|
42
|
+
// Check for halt signal
|
|
43
|
+
const haltKey = (0, common_1.createSlotKey)('control.shouldHalt');
|
|
44
|
+
const reasonKey = (0, common_1.createSlotKey)('control.haltReason');
|
|
45
|
+
if (ctx.has(haltKey)) {
|
|
46
|
+
return {
|
|
47
|
+
success: true,
|
|
48
|
+
skipped: true,
|
|
49
|
+
reason: ctx.get(reasonKey) ?? 'Pipeline halted',
|
|
50
|
+
context: ctx,
|
|
51
|
+
executedPhases: executed,
|
|
52
|
+
duration: Date.now() - startTime,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const pipelineError = this.toPipelineError(error, phase.name);
|
|
58
|
+
ctx = ctx.addError(pipelineError);
|
|
59
|
+
ctx = ctx.completePhase(phase.name, 'failed', pipelineError);
|
|
60
|
+
const decision = await this.handleError(ctx, pipelineError);
|
|
61
|
+
if (decision === 'halt') {
|
|
62
|
+
await this.rollback(ctx, executed);
|
|
63
|
+
return {
|
|
64
|
+
success: false,
|
|
65
|
+
error: pipelineError,
|
|
66
|
+
context: ctx,
|
|
67
|
+
executedPhases: executed,
|
|
68
|
+
duration: Date.now() - startTime,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
else if (decision === 'retry') {
|
|
72
|
+
i--; // Simple retry
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
success: true,
|
|
79
|
+
context: ctx,
|
|
80
|
+
executedPhases: executed,
|
|
81
|
+
duration: Date.now() - startTime,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
validateRequirements(ctx, phase) {
|
|
85
|
+
for (const req of phase.requires) {
|
|
86
|
+
if (!ctx.has(req)) {
|
|
87
|
+
throw new PhaseError(phase.name, 'MISSING_REQUIREMENT', `Required slot "${String(req)}" is not present`, false);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async handleError(ctx, error) {
|
|
92
|
+
const phaseHandler = this.errorHandlers.get(error.phase);
|
|
93
|
+
if (phaseHandler)
|
|
94
|
+
return phaseHandler(ctx, error);
|
|
95
|
+
const codeHandler = this.errorHandlers.get(error.code);
|
|
96
|
+
if (codeHandler)
|
|
97
|
+
return codeHandler(ctx, error);
|
|
98
|
+
return error.recoverable ? 'continue' : 'halt';
|
|
99
|
+
}
|
|
100
|
+
async rollback(ctx, executed) {
|
|
101
|
+
const lastError = ctx.errors[ctx.errors.length - 1];
|
|
102
|
+
const reverseExecuted = [...executed].reverse();
|
|
103
|
+
for (const phaseName of reverseExecuted) {
|
|
104
|
+
const phase = this.phases.find(p => p.name === phaseName);
|
|
105
|
+
if (phase?.rollback) {
|
|
106
|
+
try {
|
|
107
|
+
await phase.rollback(ctx, lastError);
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
console.error(`Rollback failed for ${phaseName}`, e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
toPipelineError(error, phaseName) {
|
|
116
|
+
if (error instanceof PhaseError) {
|
|
117
|
+
return {
|
|
118
|
+
phase: error.phase,
|
|
119
|
+
code: error.code,
|
|
120
|
+
message: error.message,
|
|
121
|
+
recoverable: error.recoverable
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
125
|
+
return {
|
|
126
|
+
phase: phaseName,
|
|
127
|
+
code: 'UNKNOWN_ERROR',
|
|
128
|
+
message,
|
|
129
|
+
recoverable: false,
|
|
130
|
+
cause: error,
|
|
131
|
+
timestamp: new Date()
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.Pipeline = Pipeline;
|
|
136
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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KAAK;YACZ,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC;IACJ,CAAC;CACF;AAxID,4BAwIC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Phase } from './phase';
|
|
2
|
+
import { PipelineContext } from './context';
|
|
3
|
+
import { SlotKey, PipelineError } from '../types/common';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for MapPhase iteration
|
|
6
|
+
*/
|
|
7
|
+
export interface MapPhaseConfig<TInput, TOutput> {
|
|
8
|
+
/** Slot containing the input array to iterate over */
|
|
9
|
+
inputSlot: SlotKey<TInput[]>;
|
|
10
|
+
/** Slot where results array will be stored */
|
|
11
|
+
outputSlot: SlotKey<TOutput[]>;
|
|
12
|
+
/** Slot for current item during iteration (available to sub-phases) */
|
|
13
|
+
itemSlot: SlotKey<TInput>;
|
|
14
|
+
/** Slot for result of current iteration (set by sub-phases) */
|
|
15
|
+
resultSlot: SlotKey<TOutput>;
|
|
16
|
+
/** Phases to execute for each item */
|
|
17
|
+
phases: Phase[];
|
|
18
|
+
/** Max concurrent executions (default: 1 for sequential) */
|
|
19
|
+
concurrency?: number;
|
|
20
|
+
/** Continue processing remaining items if one fails (default: false) */
|
|
21
|
+
continueOnError?: boolean;
|
|
22
|
+
/** Callback for progress updates */
|
|
23
|
+
onProgress?: (completed: number, total: number, item: TInput) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Phase that iterates over a collection, executing sub-phases for each item.
|
|
27
|
+
* Similar to AWS Step Functions Map state.
|
|
28
|
+
*/
|
|
29
|
+
export declare class MapPhase<TInput, TOutput> implements Phase {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly description: string;
|
|
32
|
+
private readonly config;
|
|
33
|
+
constructor(name: string, config: MapPhaseConfig<TInput, TOutput>);
|
|
34
|
+
get requires(): SlotKey<unknown>[];
|
|
35
|
+
get produces(): SlotKey<unknown>[];
|
|
36
|
+
get optionalReads(): SlotKey<unknown>[] | undefined;
|
|
37
|
+
execute(ctx: PipelineContext): Promise<PipelineContext>;
|
|
38
|
+
private processItem;
|
|
39
|
+
private toPipelineError;
|
|
40
|
+
private isPipelineError;
|
|
41
|
+
private chunk;
|
|
42
|
+
shouldSkip(ctx: PipelineContext): Promise<boolean>;
|
|
43
|
+
rollback(ctx: PipelineContext, error: PipelineError): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for ForEachPhase (side-effect iteration without collecting results)
|
|
47
|
+
*/
|
|
48
|
+
export interface ForEachPhaseConfig<TInput> {
|
|
49
|
+
/** Slot containing the input array to iterate over */
|
|
50
|
+
inputSlot: SlotKey<TInput[]>;
|
|
51
|
+
/** Slot for current item during iteration */
|
|
52
|
+
itemSlot: SlotKey<TInput>;
|
|
53
|
+
/** Phases to execute for each item */
|
|
54
|
+
phases: Phase[];
|
|
55
|
+
/** Continue processing remaining items if one fails */
|
|
56
|
+
continueOnError?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Phase that iterates over a collection for side effects (no result collection).
|
|
60
|
+
* Useful for operations like "notify each user" or "delete each file".
|
|
61
|
+
*/
|
|
62
|
+
export declare class ForEachPhase<TInput> implements Phase {
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly description: string;
|
|
65
|
+
private readonly config;
|
|
66
|
+
constructor(name: string, config: ForEachPhaseConfig<TInput>);
|
|
67
|
+
get requires(): SlotKey<unknown>[];
|
|
68
|
+
get produces(): SlotKey<unknown>[];
|
|
69
|
+
execute(ctx: PipelineContext): Promise<PipelineContext>;
|
|
70
|
+
private toPipelineError;
|
|
71
|
+
shouldSkip(ctx: PipelineContext): Promise<boolean>;
|
|
72
|
+
rollback(ctx: PipelineContext, error: PipelineError): Promise<void>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=iterators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterators.d.ts","sourceRoot":"","sources":["../../src/pipeline/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,QAAQ,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAO1E"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ForEachPhase = exports.MapPhase = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Phase that iterates over a collection, executing sub-phases for each item.
|
|
6
|
+
* Similar to AWS Step Functions Map state.
|
|
7
|
+
*/
|
|
8
|
+
class MapPhase {
|
|
9
|
+
name;
|
|
10
|
+
description;
|
|
11
|
+
config;
|
|
12
|
+
constructor(name, config) {
|
|
13
|
+
this.name = `map:${name}`;
|
|
14
|
+
this.description = `Iterates over collection and executes phases for each item`;
|
|
15
|
+
this.config = {
|
|
16
|
+
inputSlot: config.inputSlot,
|
|
17
|
+
outputSlot: config.outputSlot,
|
|
18
|
+
itemSlot: config.itemSlot,
|
|
19
|
+
resultSlot: config.resultSlot,
|
|
20
|
+
phases: config.phases,
|
|
21
|
+
concurrency: config.concurrency ?? 1,
|
|
22
|
+
continueOnError: config.continueOnError ?? false,
|
|
23
|
+
onProgress: config.onProgress,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
get requires() {
|
|
27
|
+
// We require the input slot
|
|
28
|
+
return [this.config.inputSlot];
|
|
29
|
+
}
|
|
30
|
+
get produces() {
|
|
31
|
+
// We produce the output slot
|
|
32
|
+
return [this.config.outputSlot];
|
|
33
|
+
}
|
|
34
|
+
get optionalReads() {
|
|
35
|
+
// Collect optional reads from all sub-phases
|
|
36
|
+
const allOptional = new Set();
|
|
37
|
+
for (const phase of this.config.phases) {
|
|
38
|
+
phase.optionalReads?.forEach(slot => allOptional.add(slot));
|
|
39
|
+
}
|
|
40
|
+
return allOptional.size > 0 ? Array.from(allOptional) : undefined;
|
|
41
|
+
}
|
|
42
|
+
async execute(ctx) {
|
|
43
|
+
const items = ctx.require(this.config.inputSlot);
|
|
44
|
+
if (items.length === 0) {
|
|
45
|
+
return ctx.set(this.config.outputSlot, []);
|
|
46
|
+
}
|
|
47
|
+
const results = [];
|
|
48
|
+
const errors = [];
|
|
49
|
+
if (this.config.concurrency === 1) {
|
|
50
|
+
// Sequential execution
|
|
51
|
+
for (let i = 0; i < items.length; i++) {
|
|
52
|
+
const result = await this.processItem(ctx, items[i], i);
|
|
53
|
+
results.push(result);
|
|
54
|
+
if (!result.success) {
|
|
55
|
+
errors.push(result.error);
|
|
56
|
+
if (!this.config.continueOnError) {
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
this.config.onProgress?.(i + 1, items.length, items[i]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Parallel execution with concurrency limit
|
|
65
|
+
const batches = this.chunk(items, this.config.concurrency);
|
|
66
|
+
let completedCount = 0;
|
|
67
|
+
for (const batch of batches) {
|
|
68
|
+
const batchPromises = batch.map((item, batchIndex) => {
|
|
69
|
+
const globalIndex = completedCount + batchIndex;
|
|
70
|
+
return this.processItem(ctx, item, globalIndex);
|
|
71
|
+
});
|
|
72
|
+
const batchResults = await Promise.all(batchPromises);
|
|
73
|
+
for (const result of batchResults) {
|
|
74
|
+
results.push(result);
|
|
75
|
+
if (!result.success) {
|
|
76
|
+
errors.push(result.error);
|
|
77
|
+
}
|
|
78
|
+
completedCount++;
|
|
79
|
+
this.config.onProgress?.(completedCount, items.length, items[result.index]);
|
|
80
|
+
}
|
|
81
|
+
// Check if we should stop due to errors
|
|
82
|
+
if (errors.length > 0 && !this.config.continueOnError) {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Collect successful results in order
|
|
88
|
+
const successfulResults = results
|
|
89
|
+
.filter(r => r.success)
|
|
90
|
+
.sort((a, b) => a.index - b.index)
|
|
91
|
+
.map(r => r.result);
|
|
92
|
+
// Add any errors to context
|
|
93
|
+
let resultCtx = ctx;
|
|
94
|
+
for (const error of errors) {
|
|
95
|
+
resultCtx = resultCtx.addError(error);
|
|
96
|
+
}
|
|
97
|
+
// If we have errors and didn't continue, throw the first one
|
|
98
|
+
if (errors.length > 0 && !this.config.continueOnError) {
|
|
99
|
+
throw errors[0];
|
|
100
|
+
}
|
|
101
|
+
return resultCtx.set(this.config.outputSlot, successfulResults);
|
|
102
|
+
}
|
|
103
|
+
async processItem(ctx, item, index) {
|
|
104
|
+
try {
|
|
105
|
+
// Create iteration context with current item
|
|
106
|
+
let iterCtx = ctx.set(this.config.itemSlot, item);
|
|
107
|
+
// Execute all phases for this item
|
|
108
|
+
for (const phase of this.config.phases) {
|
|
109
|
+
iterCtx = await phase.execute(iterCtx);
|
|
110
|
+
}
|
|
111
|
+
// Get the result from the result slot
|
|
112
|
+
const result = iterCtx.require(this.config.resultSlot);
|
|
113
|
+
return {
|
|
114
|
+
success: true,
|
|
115
|
+
result,
|
|
116
|
+
index,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
error: this.toPipelineError(error, index),
|
|
123
|
+
index,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
toPipelineError(error, index) {
|
|
128
|
+
if (this.isPipelineError(error)) {
|
|
129
|
+
return {
|
|
130
|
+
...error,
|
|
131
|
+
data: { ...error.data, iterationIndex: index },
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const err = error;
|
|
135
|
+
return {
|
|
136
|
+
phase: this.name,
|
|
137
|
+
code: 'ITERATION_ERROR',
|
|
138
|
+
message: `Error processing item at index ${index}: ${err?.message ?? String(error)}`,
|
|
139
|
+
recoverable: false,
|
|
140
|
+
data: { iterationIndex: index },
|
|
141
|
+
stack: err?.stack,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
isPipelineError(error) {
|
|
145
|
+
return (typeof error === 'object' &&
|
|
146
|
+
error !== null &&
|
|
147
|
+
'phase' in error &&
|
|
148
|
+
'code' in error &&
|
|
149
|
+
'message' in error);
|
|
150
|
+
}
|
|
151
|
+
chunk(array, size) {
|
|
152
|
+
const chunks = [];
|
|
153
|
+
for (let i = 0; i < array.length; i += size) {
|
|
154
|
+
chunks.push(array.slice(i, i + size));
|
|
155
|
+
}
|
|
156
|
+
return chunks;
|
|
157
|
+
}
|
|
158
|
+
async shouldSkip(ctx) {
|
|
159
|
+
// Skip if input array is empty
|
|
160
|
+
const items = ctx.get(this.config.inputSlot);
|
|
161
|
+
return !items || items.length === 0;
|
|
162
|
+
}
|
|
163
|
+
async rollback(ctx, error) {
|
|
164
|
+
// Rollback all sub-phases
|
|
165
|
+
for (const phase of this.config.phases) {
|
|
166
|
+
if (phase.rollback) {
|
|
167
|
+
await phase.rollback(ctx, error);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.MapPhase = MapPhase;
|
|
173
|
+
/**
|
|
174
|
+
* Phase that iterates over a collection for side effects (no result collection).
|
|
175
|
+
* Useful for operations like "notify each user" or "delete each file".
|
|
176
|
+
*/
|
|
177
|
+
class ForEachPhase {
|
|
178
|
+
name;
|
|
179
|
+
description;
|
|
180
|
+
config;
|
|
181
|
+
constructor(name, config) {
|
|
182
|
+
this.name = `forEach:${name}`;
|
|
183
|
+
this.description = `Executes phases for each item in collection`;
|
|
184
|
+
this.config = {
|
|
185
|
+
inputSlot: config.inputSlot,
|
|
186
|
+
itemSlot: config.itemSlot,
|
|
187
|
+
phases: config.phases,
|
|
188
|
+
continueOnError: config.continueOnError ?? false,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
get requires() {
|
|
192
|
+
return [this.config.inputSlot];
|
|
193
|
+
}
|
|
194
|
+
get produces() {
|
|
195
|
+
return []; // ForEach doesn't produce output, just side effects
|
|
196
|
+
}
|
|
197
|
+
async execute(ctx) {
|
|
198
|
+
const items = ctx.require(this.config.inputSlot);
|
|
199
|
+
let resultCtx = ctx;
|
|
200
|
+
for (const item of items) {
|
|
201
|
+
try {
|
|
202
|
+
let iterCtx = resultCtx.set(this.config.itemSlot, item);
|
|
203
|
+
for (const phase of this.config.phases) {
|
|
204
|
+
iterCtx = await phase.execute(iterCtx);
|
|
205
|
+
}
|
|
206
|
+
resultCtx = iterCtx;
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
if (!this.config.continueOnError) {
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
212
|
+
// Add error and continue
|
|
213
|
+
const pipelineError = this.toPipelineError(error);
|
|
214
|
+
resultCtx = resultCtx.addError(pipelineError);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return resultCtx;
|
|
218
|
+
}
|
|
219
|
+
toPipelineError(error) {
|
|
220
|
+
if (typeof error === 'object' && error !== null && 'phase' in error) {
|
|
221
|
+
return error;
|
|
222
|
+
}
|
|
223
|
+
const err = error;
|
|
224
|
+
return {
|
|
225
|
+
phase: this.name,
|
|
226
|
+
code: 'ITERATION_ERROR',
|
|
227
|
+
message: err?.message ?? String(error),
|
|
228
|
+
recoverable: false,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
async shouldSkip(ctx) {
|
|
232
|
+
const items = ctx.get(this.config.inputSlot);
|
|
233
|
+
return !items || items.length === 0;
|
|
234
|
+
}
|
|
235
|
+
async rollback(ctx, error) {
|
|
236
|
+
for (const phase of this.config.phases) {
|
|
237
|
+
if (phase.rollback) {
|
|
238
|
+
await phase.rollback(ctx, error);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
exports.ForEachPhase = ForEachPhase;
|
|
244
|
+
//# sourceMappingURL=iterators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterators.js","sourceRoot":"","sources":["../../src/pipeline/iterators.ts"],"names":[],"mappings":";;;AAqCA;;;GA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AC,QAAQ,EAAE,CAAC;gBACnB,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA3ED,oCA2EC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Phase } from './phase';
|
|
2
|
+
import { PipelineContext } from './context';
|
|
3
|
+
import { PipelineError } from '../types/common';
|
|
4
|
+
export type NextFn = (ctx: PipelineContext) => Promise<PipelineContext>;
|
|
5
|
+
export type PhaseMiddleware = (ctx: PipelineContext, next: NextFn) => Promise<PipelineContext>;
|
|
6
|
+
export declare class ComposablePhase implements Phase {
|
|
7
|
+
private inner;
|
|
8
|
+
private middlewares;
|
|
9
|
+
constructor(inner: Phase);
|
|
10
|
+
get name(): string;
|
|
11
|
+
get description(): string;
|
|
12
|
+
get requires(): import("../types/common").SlotKey[];
|
|
13
|
+
get produces(): import("../types/common").SlotKey[];
|
|
14
|
+
get optionalReads(): import("../types/common").SlotKey[] | undefined;
|
|
15
|
+
get dependsOn(): string[] | undefined;
|
|
16
|
+
get tags(): string[] | undefined;
|
|
17
|
+
use(middleware: PhaseMiddleware): this;
|
|
18
|
+
before(hook: (ctx: PipelineContext) => Promise<PipelineContext>): this;
|
|
19
|
+
after(hook: (ctx: PipelineContext) => Promise<PipelineContext>): this;
|
|
20
|
+
execute(ctx: PipelineContext): Promise<PipelineContext>;
|
|
21
|
+
shouldSkip(ctx: PipelineContext): Promise<boolean>;
|
|
22
|
+
rollback(ctx: PipelineContext, error: PipelineError): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export declare function composable(phase: Phase): ComposablePhase;
|
|
25
|
+
export declare function composeMiddlewares(...middlewares: PhaseMiddleware[]): PhaseMiddleware;
|
|
26
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/pipeline/middleware.ts"],"names":[],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CAAC,GAAG,WAAW,EAAE,eAAe,EAAE,GAAG,eAAe,CAQrF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComposablePhase = void 0;
|
|
4
|
+
exports.composable = composable;
|
|
5
|
+
exports.composeMiddlewares = composeMiddlewares;
|
|
6
|
+
class ComposablePhase {
|
|
7
|
+
inner;
|
|
8
|
+
middlewares = [];
|
|
9
|
+
constructor(inner) {
|
|
10
|
+
this.inner = inner;
|
|
11
|
+
}
|
|
12
|
+
// Delegate metadata to inner phase
|
|
13
|
+
get name() { return this.inner.name; }
|
|
14
|
+
get description() { return this.inner.description; }
|
|
15
|
+
get requires() { return this.inner.requires; }
|
|
16
|
+
get produces() { return this.inner.produces; }
|
|
17
|
+
get optionalReads() { return this.inner.optionalReads; }
|
|
18
|
+
get dependsOn() { return this.inner.dependsOn; }
|
|
19
|
+
get tags() { return this.inner.tags; }
|
|
20
|
+
use(middleware) {
|
|
21
|
+
this.middlewares.push(middleware);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
// Syntactic sugar for "Before" middleware
|
|
25
|
+
before(hook) {
|
|
26
|
+
return this.use(async (ctx, next) => {
|
|
27
|
+
const modified = await hook(ctx);
|
|
28
|
+
return next(modified);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
// Syntactic sugar for "After" middleware
|
|
32
|
+
after(hook) {
|
|
33
|
+
return this.use(async (ctx, next) => {
|
|
34
|
+
const result = await next(ctx);
|
|
35
|
+
return hook(result);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async execute(ctx) {
|
|
39
|
+
// 1. The innermost function is the actual phase execution
|
|
40
|
+
const executeInner = (c) => this.inner.execute(c);
|
|
41
|
+
// 2. Reduce the middlewares into a single execution function
|
|
42
|
+
// explicit generic <NextFn> fixes the type inference error
|
|
43
|
+
const chain = this.middlewares.reduceRight((next, middleware) => (c) => middleware(c, next), executeInner);
|
|
44
|
+
// 3. Execute the chain
|
|
45
|
+
return chain(ctx);
|
|
46
|
+
}
|
|
47
|
+
// Delegate optional methods
|
|
48
|
+
async shouldSkip(ctx) {
|
|
49
|
+
return this.inner.shouldSkip ? await this.inner.shouldSkip(ctx) : false;
|
|
50
|
+
}
|
|
51
|
+
async rollback(ctx, error) {
|
|
52
|
+
if (this.inner.rollback) {
|
|
53
|
+
await this.inner.rollback(ctx, error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ComposablePhase = ComposablePhase;
|
|
58
|
+
// Factory function
|
|
59
|
+
function composable(phase) {
|
|
60
|
+
return new ComposablePhase(phase);
|
|
61
|
+
}
|
|
62
|
+
// Utility to combine multiple middlewares into one
|
|
63
|
+
function composeMiddlewares(...middlewares) {
|
|
64
|
+
return async (ctx, next) => {
|
|
65
|
+
const chain = middlewares.reduceRight((nextFn, middleware) => (c) => middleware(c, nextFn), next);
|
|
66
|
+
return chain(ctx);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/pipeline/middleware.ts"],"names":[],"mappings":";;;AA8EA,gCAEC;AAGD,gDAQC;AA5ED,MAAa,eAAe;IAGN;IAFZ,WAAW,GAAsB,EAAE,CAAC;IAE5C,YAAoB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;IAAG,CAAC;IAEpC,mCAAmC;IACnC,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,IAAI,WAAW,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IACpD,IAAI,QAAQ,KAAK,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,IAAI,QAAQ,KA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,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,EAChD,YAAY,CACb,CAAC;QAEF,uBAAuB;QACvB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,4BAA4B;IAC5B,KAAK,CAAC,UAAU,CAAC,GAAoB;QACnC,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAoB,EAAE,KAAoB;QACvD,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF;AA5DD,0CA4DC;AAED,mBAAmB;AACnB,SAAgB,UAAU,CAAC,KAAY;IACrC,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,mDAAmD;AACnD,SAAgB,kBAAkB,CAAC,GAAG,WAA8B;IAClE,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACzB,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CACnC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,EACpD,IAAI,CACL,CAAC;QACF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/pipeline/phase.d.ts
CHANGED
|
@@ -1,17 +1,39 @@
|
|
|
1
|
-
import { PipelineContext
|
|
2
|
-
|
|
1
|
+
import { PipelineContext } from './context';
|
|
2
|
+
import { SlotKey, PipelineError } from '../types/common';
|
|
3
|
+
export interface PhaseContract {
|
|
3
4
|
readonly name: string;
|
|
4
5
|
readonly description: string;
|
|
5
6
|
readonly requires: SlotKey[];
|
|
6
7
|
readonly produces: SlotKey[];
|
|
8
|
+
readonly optionalReads?: SlotKey[];
|
|
9
|
+
readonly dependsOn?: string[];
|
|
10
|
+
readonly tags?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface Phase extends PhaseContract {
|
|
7
13
|
execute(ctx: PipelineContext): Promise<PipelineContext>;
|
|
14
|
+
shouldSkip?(ctx: PipelineContext): Promise<boolean>;
|
|
15
|
+
rollback?(ctx: PipelineContext, error: PipelineError): Promise<void>;
|
|
8
16
|
}
|
|
9
17
|
export declare abstract class BasePhase implements Phase {
|
|
10
18
|
abstract readonly name: string;
|
|
11
19
|
abstract readonly description: string;
|
|
12
20
|
abstract readonly requires: SlotKey[];
|
|
13
21
|
abstract readonly produces: SlotKey[];
|
|
22
|
+
readonly optionalReads?: SlotKey[];
|
|
23
|
+
readonly dependsOn?: string[];
|
|
24
|
+
readonly tags?: string[];
|
|
14
25
|
abstract execute(ctx: PipelineContext): Promise<PipelineContext>;
|
|
15
|
-
|
|
26
|
+
shouldSkip?(ctx: PipelineContext): Promise<boolean>;
|
|
27
|
+
rollback?(ctx: PipelineContext, error: PipelineError): Promise<void>;
|
|
28
|
+
protected fail(code: string, message: string, recoverable?: boolean, data?: Record<string, unknown>): never;
|
|
29
|
+
protected warn(ctx: PipelineContext, message: string): PipelineContext;
|
|
30
|
+
}
|
|
31
|
+
export declare class PhaseError extends Error implements PipelineError {
|
|
32
|
+
readonly phase: string;
|
|
33
|
+
readonly code: string;
|
|
34
|
+
readonly recoverable: boolean;
|
|
35
|
+
readonly data?: Record<string, unknown> | undefined;
|
|
36
|
+
readonly cause?: Error | undefined;
|
|
37
|
+
constructor(phase: string, code: string, message: string, recoverable: boolean, data?: Record<string, unknown> | undefined, cause?: Error | undefined);
|
|
16
38
|
}
|
|
17
39
|
//# sourceMappingURL=phase.d.ts.map
|
|
@@ -1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