@tonytang99/integration-core 1.0.0 → 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.
Files changed (37) hide show
  1. package/dist/index.d.ts +6 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +10 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/pipeline/builder.d.ts +14 -0
  6. package/dist/pipeline/builder.d.ts.map +1 -0
  7. package/dist/pipeline/builder.js +98 -0
  8. package/dist/pipeline/builder.js.map +1 -0
  9. package/dist/pipeline/context.d.ts +43 -16
  10. package/dist/pipeline/context.d.ts.map +1 -1
  11. package/dist/pipeline/context.js +80 -7
  12. package/dist/pipeline/context.js.map +1 -1
  13. package/dist/pipeline/executor.d.ts +24 -0
  14. package/dist/pipeline/executor.d.ts.map +1 -0
  15. package/dist/pipeline/executor.js +136 -0
  16. package/dist/pipeline/executor.js.map +1 -0
  17. package/dist/pipeline/middleware.d.ts +26 -0
  18. package/dist/pipeline/middleware.d.ts.map +1 -0
  19. package/dist/pipeline/middleware.js +69 -0
  20. package/dist/pipeline/middleware.js.map +1 -0
  21. package/dist/pipeline/phase.d.ts +25 -3
  22. package/dist/pipeline/phase.d.ts.map +1 -1
  23. package/dist/pipeline/phase.js +33 -3
  24. package/dist/pipeline/phase.js.map +1 -1
  25. package/dist/registry/phase-registry.d.ts +24 -0
  26. package/dist/registry/phase-registry.d.ts.map +1 -0
  27. package/dist/registry/phase-registry.js +69 -0
  28. package/dist/registry/phase-registry.js.map +1 -0
  29. package/dist/slots/well-known-slots.d.ts +27 -0
  30. package/dist/slots/well-known-slots.d.ts.map +1 -0
  31. package/dist/slots/well-known-slots.js +31 -0
  32. package/dist/slots/well-known-slots.js.map +1 -0
  33. package/dist/types/common.d.ts +45 -0
  34. package/dist/types/common.d.ts.map +1 -0
  35. package/dist/types/common.js +11 -0
  36. package/dist/types/common.js.map +1 -0
  37. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ export * from './types/common';
1
2
  export * from './pipeline/context';
2
3
  export * from './pipeline/phase';
4
+ export * from './pipeline/builder';
5
+ export * from './pipeline/executor';
6
+ export * from './pipeline/middleware';
7
+ export * from './slots/well-known-slots';
8
+ export * from './registry/phase-registry';
3
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -14,6 +14,16 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Types
18
+ __exportStar(require("./types/common"), exports);
19
+ // Pipeline
17
20
  __exportStar(require("./pipeline/context"), exports);
18
21
  __exportStar(require("./pipeline/phase"), exports);
22
+ __exportStar(require("./pipeline/builder"), exports);
23
+ __exportStar(require("./pipeline/executor"), exports);
24
+ __exportStar(require("./pipeline/middleware"), exports);
25
+ // Slots
26
+ __exportStar(require("./slots/well-known-slots"), exports);
27
+ // Registry
28
+ __exportStar(require("./registry/phase-registry"), exports);
19
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,iDAA+B;AAE/B,WAAW;AACX,qDAAmC;AACnC,mDAAiC;AACjC,qDAAmC;AACnC,sDAAoC;AACpC,wDAAsC;AAEtC,QAAQ;AACR,2DAAyC;AAEzC,WAAW;AACX,4DAA0C"}
@@ -0,0 +1,14 @@
1
+ import { Phase } from './phase';
2
+ import { Pipeline, ErrorHandler } from './executor';
3
+ import { ClientConfig } from '../types/common';
4
+ export declare class PipelineBuilder {
5
+ private phases;
6
+ private errorHandlers;
7
+ add(phase: Phase): this;
8
+ addIf(condition: boolean | ((config: ClientConfig) => boolean), phase: Phase): this;
9
+ addAll(...phases: Phase[]): this;
10
+ onError(phaseOrCode: string, handler: ErrorHandler): this;
11
+ build(): Pipeline;
12
+ private validate;
13
+ }
14
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/pipeline/builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAW,YAAY,EAAiB,MAAM,iBAAiB,CAAC;AAGvE,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,aAAa,CAAmC;IAExD,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAKvB,KAAK,CACH,SAAS,EAAE,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,EACxD,KAAK,EAAE,KAAK,GACX,IAAI;IASP,MAAM,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;IAKhC,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;IAKzD,KAAK,IAAI,QAAQ;IAWjB,OAAO,CAAC,QAAQ;CAmBjB"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PipelineBuilder = void 0;
4
+ const executor_1 = require("./executor");
5
+ class PipelineBuilder {
6
+ phases = [];
7
+ errorHandlers = new Map();
8
+ add(phase) {
9
+ this.phases.push(phase);
10
+ return this;
11
+ }
12
+ addIf(condition, phase) {
13
+ if (typeof condition === 'function') {
14
+ this.phases.push(new ConditionalPhase(phase, condition));
15
+ }
16
+ else if (condition) {
17
+ this.phases.push(phase);
18
+ }
19
+ return this;
20
+ }
21
+ addAll(...phases) {
22
+ this.phases.push(...phases);
23
+ return this;
24
+ }
25
+ onError(phaseOrCode, handler) {
26
+ this.errorHandlers.set(phaseOrCode, handler);
27
+ return this;
28
+ }
29
+ build() {
30
+ const errors = this.validate();
31
+ if (errors.length > 0) {
32
+ throw new Error(`Pipeline validation failed:\n${errors.join('\n')}`);
33
+ }
34
+ // In a real implementation, restore the topological sort here
35
+ // For now, we return the phases in added order
36
+ return new executor_1.Pipeline(this.phases, this.errorHandlers);
37
+ }
38
+ validate() {
39
+ const errors = [];
40
+ const produced = new Set();
41
+ for (const phase of this.phases) {
42
+ for (const req of phase.requires) {
43
+ // Cast to string for Set lookup
44
+ if (!produced.has(req)) {
45
+ // Warning: strict validation.
46
+ // If you inject slots via Context initial state, this might false-positive.
47
+ errors.push(`Phase "${phase.name}" requires slot "${req}" but no earlier phase produces it`);
48
+ }
49
+ }
50
+ for (const prod of phase.produces) {
51
+ produced.add(prod);
52
+ }
53
+ }
54
+ return errors;
55
+ }
56
+ }
57
+ exports.PipelineBuilder = PipelineBuilder;
58
+ /**
59
+ * Wraps a phase and checks a condition before executing.
60
+ * Proxies all metadata (name, description, tags) to the inner phase.
61
+ */
62
+ class ConditionalPhase {
63
+ inner;
64
+ condition;
65
+ constructor(inner, condition) {
66
+ this.inner = inner;
67
+ this.condition = condition;
68
+ }
69
+ // Required Metadata
70
+ get name() { return this.inner.name; }
71
+ get description() { return this.inner.description; }
72
+ get requires() { return this.inner.requires; }
73
+ get produces() { return this.inner.produces; }
74
+ // Optional Metadata
75
+ get optionalReads() { return this.inner.optionalReads; }
76
+ get dependsOn() { return this.inner.dependsOn; }
77
+ get tags() { return this.inner.tags; }
78
+ async execute(ctx) {
79
+ // Check condition dynamically at runtime
80
+ if (!this.condition(ctx.config)) {
81
+ return ctx; // Return context unchanged if skipped
82
+ }
83
+ return this.inner.execute(ctx);
84
+ }
85
+ async shouldSkip(ctx) {
86
+ // If the config condition fails, we definitely skip
87
+ if (!this.condition(ctx.config))
88
+ return true;
89
+ // Otherwise, check if the inner phase wants to skip
90
+ return this.inner.shouldSkip ? await this.inner.shouldSkip(ctx) : false;
91
+ }
92
+ async rollback(ctx, error) {
93
+ if (this.inner.rollback) {
94
+ await this.inner.rollback(ctx, error);
95
+ }
96
+ }
97
+ }
98
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/pipeline/builder.ts"],"names":[],"mappings":";;;AAEA,yCAAoD;AAIpD,MAAa,eAAe;IAClB,MAAM,GAAY,EAAE,CAAC;IACrB,aAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;IAExD,GAAG,CAAC,KAAY;QACd,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CACH,SAAwD,EACxD,KAAY;QAEZ,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;QAC3D,CAAC;aAAM,IAAI,SAAS,EAAE,CAAC;YACrB,IAAI,CAAC,MAA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AAC;YAAE,OAAO,IAAI,CAAC;QAE7C,oDAAoD;QACpD,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"}
@@ -1,21 +1,48 @@
1
- export type SlotKey = string & {
2
- readonly __brand: unique symbol;
3
- };
4
- export declare const createSlotKey: <T = unknown>(key: string) => SlotKey;
1
+ import { SlotKey, PipelineError, ClientConfig, ExecutionMetadata, PhaseExecution } from '../types/common';
2
+ export interface SerializedContext {
3
+ slots: Record<string, unknown>;
4
+ errors: readonly PipelineError[];
5
+ warnings: readonly string[];
6
+ metadata: ExecutionMetadata;
7
+ }
5
8
  export interface PipelineContext {
6
- readonly slots: Map<SlotKey, unknown>;
7
- readonly config: Record<string, unknown>;
8
- get<T>(key: SlotKey): T | undefined;
9
- require<T>(key: SlotKey): T;
10
- set<T>(key: SlotKey, value: T): PipelineContext;
9
+ readonly slots: ReadonlyMap<SlotKey<any>, unknown>;
10
+ readonly errors: readonly PipelineError[];
11
+ readonly warnings: readonly string[];
12
+ readonly metadata: ExecutionMetadata;
13
+ readonly config: ClientConfig;
14
+ get<T>(key: SlotKey<T>): T | undefined;
15
+ require<T>(key: SlotKey<T>): T;
16
+ has(key: SlotKey<any>): boolean;
17
+ set<T>(key: SlotKey<T>, value: T): PipelineContext;
18
+ delete(key: SlotKey<any>): PipelineContext;
19
+ addError(error: PipelineError): PipelineContext;
20
+ addWarning(message: string): PipelineContext;
21
+ updateMetadata(update: Partial<ExecutionMetadata>): PipelineContext;
22
+ startPhase(phaseName: string): PipelineContext;
23
+ completePhase(phaseName: string, status: PhaseExecution['status'], error?: PipelineError): PipelineContext;
24
+ toJSON(): SerializedContext;
25
+ clone(): PipelineContext;
11
26
  }
12
27
  export declare class PipelineContextImpl implements PipelineContext {
13
- readonly slots: Map<SlotKey, unknown>;
14
- readonly config: Record<string, unknown>;
15
- constructor(slots: Map<SlotKey, unknown>, config: Record<string, unknown>);
16
- get<T>(key: SlotKey): T | undefined;
17
- require<T>(key: SlotKey): T;
18
- set<T>(key: SlotKey, value: T): PipelineContext;
28
+ readonly slots: ReadonlyMap<SlotKey<any>, unknown>;
29
+ readonly errors: readonly PipelineError[];
30
+ readonly warnings: readonly string[];
31
+ readonly metadata: ExecutionMetadata;
32
+ readonly config: ClientConfig;
33
+ constructor(slots: ReadonlyMap<SlotKey<any>, unknown>, errors: readonly PipelineError[], warnings: readonly string[], metadata: ExecutionMetadata, config: ClientConfig);
34
+ get<T>(key: SlotKey<T>): T | undefined;
35
+ require<T>(key: SlotKey<T>): T;
36
+ has(key: SlotKey<any>): boolean;
37
+ set<T>(key: SlotKey<T>, value: T): PipelineContext;
38
+ delete(key: SlotKey<any>): PipelineContext;
39
+ addError(error: PipelineError): PipelineContext;
40
+ addWarning(message: string): PipelineContext;
41
+ updateMetadata(update: Partial<ExecutionMetadata>): PipelineContext;
42
+ startPhase(phaseName: string): PipelineContext;
43
+ completePhase(phaseName: string, status: PhaseExecution['status'], error?: PipelineError): PipelineContext;
44
+ clone(): PipelineContext;
45
+ toJSON(): SerializedContext;
19
46
  }
20
- export declare function createContext(config: Record<string, unknown>): PipelineContext;
47
+ export declare function createContext(config: ClientConfig): PipelineContext;
21
48
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/pipeline/context.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,O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AG,eAAe;IAUnE,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe;IAe9C,aAAa,CACX,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,EAChC,KAAK,CAAC,EAAE,aAAa,GACpB,eAAe;IA6BlB,KAAK,IAAI,eAAe;IAUxB,MAAM,IAAI,iBAAiB;CAQ5B;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,CAcnE"}
@@ -1,14 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PipelineContextImpl = exports.createSlotKey = void 0;
3
+ exports.PipelineContextImpl = void 0;
4
4
  exports.createContext = createContext;
5
- const createSlotKey = (key) => key;
6
- exports.createSlotKey = createSlotKey;
7
5
  class PipelineContextImpl {
8
6
  slots;
7
+ errors;
8
+ warnings;
9
+ metadata;
9
10
  config;
10
- constructor(slots, config) {
11
+ constructor(slots, errors, warnings, metadata, config) {
11
12
  this.slots = slots;
13
+ this.errors = errors;
14
+ this.warnings = warnings;
15
+ this.metadata = metadata;
12
16
  this.config = config;
13
17
  }
14
18
  get(key) {
@@ -17,18 +21,87 @@ class PipelineContextImpl {
17
21
  require(key) {
18
22
  const value = this.get(key);
19
23
  if (value === undefined) {
20
- throw new Error(`Required slot "${key}" not found`);
24
+ throw new Error(`Required slot "${key}" is not present in context`);
21
25
  }
22
26
  return value;
23
27
  }
28
+ has(key) {
29
+ return this.slots.has(key);
30
+ }
24
31
  set(key, value) {
25
32
  const newSlots = new Map(this.slots);
26
33
  newSlots.set(key, value);
27
- return new PipelineContextImpl(newSlots, this.config);
34
+ return new PipelineContextImpl(newSlots, this.errors, this.warnings, this.metadata, this.config);
35
+ }
36
+ delete(key) {
37
+ const newSlots = new Map(this.slots);
38
+ newSlots.delete(key);
39
+ return new PipelineContextImpl(newSlots, this.errors, this.warnings, this.metadata, this.config);
40
+ }
41
+ addError(error) {
42
+ return new PipelineContextImpl(this.slots, [...this.errors, error], this.warnings, this.metadata, this.config);
43
+ }
44
+ addWarning(message) {
45
+ return new PipelineContextImpl(this.slots, this.errors, [...this.warnings, message], this.metadata, this.config);
46
+ }
47
+ updateMetadata(update) {
48
+ return new PipelineContextImpl(this.slots, this.errors, this.warnings, { ...this.metadata, ...update }, this.config);
49
+ }
50
+ startPhase(phaseName) {
51
+ const execution = {
52
+ phaseName,
53
+ startedAt: new Date(),
54
+ status: 'running',
55
+ slotsRead: [],
56
+ slotsWritten: [],
57
+ };
58
+ return this.updateMetadata({
59
+ currentPhase: phaseName,
60
+ phaseHistory: [...this.metadata.phaseHistory, execution],
61
+ });
62
+ }
63
+ completePhase(phaseName, status, error) {
64
+ const history = [...this.metadata.phaseHistory];
65
+ const currentPhaseIndex = history.findIndex(h => h.phaseName === phaseName && h.status === 'running');
66
+ if (currentPhaseIndex === -1) {
67
+ // Graceful handling if phase wasn't tracked as running
68
+ return this;
69
+ }
70
+ const currentPhase = history[currentPhaseIndex];
71
+ const completedAt = new Date();
72
+ const duration = completedAt.getTime() - currentPhase.startedAt.getTime();
73
+ history[currentPhaseIndex] = {
74
+ ...currentPhase,
75
+ completedAt,
76
+ duration,
77
+ status,
78
+ error,
79
+ };
80
+ return this.updateMetadata({
81
+ currentPhase: undefined,
82
+ phaseHistory: history,
83
+ });
84
+ }
85
+ clone() {
86
+ return new PipelineContextImpl(new Map(this.slots), [...this.errors], [...this.warnings], { ...this.metadata, phaseHistory: [...this.metadata.phaseHistory] }, this.config);
87
+ }
88
+ toJSON() {
89
+ return {
90
+ slots: Object.fromEntries(this.slots),
91
+ errors: this.errors,
92
+ warnings: this.warnings,
93
+ metadata: this.metadata,
94
+ };
28
95
  }
29
96
  }
30
97
  exports.PipelineContextImpl = PipelineContextImpl;
31
98
  function createContext(config) {
32
- return new PipelineContextImpl(new Map(), config);
99
+ return new PipelineContextImpl(new Map(), [], [], {
100
+ pipelineId: config.clientId,
101
+ executionId: `exec_${Date.now()}`,
102
+ traceId: `trace_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`,
103
+ startedAt: new Date(),
104
+ phaseHistory: [],
105
+ }, config);
33
106
  }
34
107
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/pipeline/context.ts"],"names":[],"mappings":";;;AAsCA,sCAEC;AAtCM,MAAM,aAAa,GAAG,CAAc,GAAW,EAAW,EAAE,CAAC,GAAc,CAAC;AAAtE,QAAA,aAAa,iBAAyD;AAWnF,MAAa,mBAAmB;IAEZ;IACA;IAFlB,YACkB,KAA4B,EAC5B,MAA+B;QAD/B,UAAK,GAAL,KAAK,CAAuB;QAC5B,WAAM,GAAN,MAAM,CAAyB;IAC9C,CAAC;IAEJ,GAAG,CAAI,GAAY;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAkB,CAAC;IAC9C,CAAC;IAED,OAAO,CAAI,GAAY;QACrB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAI,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,aAAa,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,GAAG,CAAI,GAAY,EAAE,KAAQ;QAC3B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,IAAI,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;CACF;AAvBD,kDAuBC;AAED,SAAgB,aAAa,CAAC,MAA+B;IAC3D,OAAO,IAAI,mBAAmB,CAAC,IAAI,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC"}
1
+ {"version":3,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CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;CACF;AAjJD,kDAiJC;AAED,SAAgB,aAAa,CAAC,MAAoB;IAChD,OAAO,IAAI,mBAAmB,CAC5B,IAAI,GAAG,EAAE,EACT,EAAE,EACF,EAAE,EACF;QACE,UAAU,EAAE,MAAM,CAAC,QAAQ;QAC3B,WAAW,EAAE,QAAQ,IAAI,CAAC,GAAG,EAAE,EAAE;QACjC,OAAO,EAAE,SAAS,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACxE,SAAS,EAAE,IAAI,IAAI,EAAE;QACrB,YAAY,EAAE,EAAE;KACjB,EACD,MAAM,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { Phase } from './phase';
2
+ import { PipelineContext } from './context';
3
+ import { PipelineError } from '../types/common';
4
+ export interface PipelineResult {
5
+ success: boolean;
6
+ skipped?: boolean;
7
+ reason?: string;
8
+ error?: PipelineError;
9
+ context: PipelineContext;
10
+ executedPhases: string[];
11
+ duration: number;
12
+ }
13
+ export type ErrorHandler = (ctx: PipelineContext, error: PipelineError) => Promise<'continue' | 'halt' | 'retry'>;
14
+ export declare class Pipeline {
15
+ private phases;
16
+ private errorHandlers;
17
+ constructor(phases: Phase[], errorHandlers: Map<string, ErrorHandler>);
18
+ execute(initialCtx: PipelineContext): Promise<PipelineResult>;
19
+ private validateRequirements;
20
+ private handleError;
21
+ private rollback;
22
+ private toPipelineError;
23
+ }
24
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/pipeline/executor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AAExE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,CACzB,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,aAAa,KACjB,OAAO,CAAC,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAe5C,qBAAa,QAAQ;IAEjB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,aAAa;gBADb,MAAM,EAAE,KAAK,EAAE,EACf,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC;IAG5C,OAAO,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IAqEnE,OAAO,CAAC,oBAAoB;YAad,WAAW;YAaX,QAAQ;IAgBtB,OAAO,CAAC,eAAe;CAmBxB"}
@@ -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":"executor.js","sourceRoot":"","sources":["../../src/pipeline/executor.ts"],"names":[],"mappings":";;;AAGA,4CAAwE;AAiBxE,wCAAwC;AACxC,MAAM,UAAW,SAAQ,KAAK;IAEnB;IACA;IAEA;IAJT,YACS,KAAa,EACb,IAAY,EACnB,OAAe,EACR,WAAoB;QAE3B,KAAK,CAAC,OAAO,CAAC,CAAC;QALR,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QAEZ,gBAAW,GAAX,WAAW,CAAS;QAG3B,IA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IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;YAC1D,IAAI,KAAK,EAAE,QAAQ,EAAE,CAAC;gBACpB,IAAI,CAAC;oBACH,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;gBACvC,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO,CAAC,KAAK,CAAC,uBAAuB,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,KAAc,EAAE,SAAiB;QACvD,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;YAChC,OAAO;gBACL,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B,CAAC;QACJ,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,eAAe;YACrB,OAAO;YACP,WAAW,EAAE,KAAK;YAClB,KAAK,EAAE,KAAK;YACZ,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC;IACJ,CAAC;CACF;AAxID,4BAwIC"}
@@ -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":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;AAExE,MAAM,MAAM,eAAe,GAAG,CAC5B,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC,eAAe,CAAC,CAAC;AAE9B,qBAAa,eAAgB,YAAW,KAAK;IAG/B,OAAO,CAAC,KAAK;IAFzB,OAAO,CAAC,WAAW,CAAyB;gBAExB,KAAK,EAAE,KAAK;IAGhC,IAAI,IAAI,WAA8B;IACtC,IAAI,WAAW,WAAqC;IACpD,IAAI,QAAQ,wCAAkC;IAC9C,IAAI,QAAQ,wCAAkC;IAC9C,IAAI,aAAa,oDAAuC;IACxD,IAAI,SAAS,yBAAmC;IAChD,IAAI,IAAI,yBAA8B;IAEtC,GAAG,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI;IAMtC,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAQtE,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAO/D,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAgBvD,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlD,QAAQ,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAK1E;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,CAExD;AAGD,wBAAgB,kBAAkB,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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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
- protected fail(code: string, message: string): never;
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 +1 @@
1
- {"version":3,"file":"phase.d.ts","sourceRoot":"","sources":["../../src/pipeline/phase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAErD,MAAM,WAAW,KAAK;IACpB,QAAQ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I,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe;CAGvE;AAED,qBAAa,UAAW,SAAQ,KAAM,YAAW,aAAa;aAE1C,KAAK,EAAE,MAAM;aACb,IAAI,EAAE,MAAM;aAEZ,WAAW,EAAE,OAAO;aACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;aAC9B,KAAK,CAAC,EAAE,KAAK;gBALb,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM,EACC,WAAW,EAAE,OAAO,EACpB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA,EAC9B,KAAK,CAAC,EAAE,KAAK,YAAA;CAMhC"}
@@ -1,10 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BasePhase = void 0;
3
+ exports.PhaseError = exports.BasePhase = void 0;
4
4
  class BasePhase {
5
- fail(code, message) {
6
- throw new Error(`[${this.name}] ${code}: ${message}`);
5
+ optionalReads;
6
+ dependsOn;
7
+ tags;
8
+ async shouldSkip(ctx) {
9
+ return false;
10
+ }
11
+ async rollback(ctx, error) {
12
+ // Default: no rollback action
13
+ }
14
+ fail(code, message, recoverable = false, data) {
15
+ throw new PhaseError(this.name, code, message, recoverable, data);
16
+ }
17
+ warn(ctx, message) {
18
+ return ctx.addWarning(`[${this.name}] ${message}`);
7
19
  }
8
20
  }
9
21
  exports.BasePhase = BasePhase;
22
+ class PhaseError extends Error {
23
+ phase;
24
+ code;
25
+ recoverable;
26
+ data;
27
+ cause;
28
+ constructor(phase, code, message, recoverable, data, cause) {
29
+ super(message);
30
+ this.phase = phase;
31
+ this.code = code;
32
+ this.recoverable = recoverable;
33
+ this.data = data;
34
+ this.cause = cause;
35
+ this.name = 'PhaseError';
36
+ Object.setPrototypeOf(this, PhaseError.prototype);
37
+ }
38
+ }
39
+ exports.PhaseError = PhaseError;
10
40
  //# sourceMappingURL=phase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"phase.js","sourceRoot":"","sources":["../../src/pipeline/phase.ts"],"names":[],"mappings":";;;AAWA,MAAsB,SAAS;IAQnB,IAAI,CAAC,IAAY,EAAE,OAAe;QAC1C,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;CACF;AAXD,8BAWC"}
1
+ {"version":3,"file":"phase.js","sourceRoot":"","sources":["../../src/pipeline/phase.ts"],"names":[],"mappings":";;;AAsBA,MAAsB,SAAS;IAMpB,aAAa,CAAa;IAC1B,SAAS,CAAY;IACrB,IAAI,CAAY;IAIzB,KAAK,CAAC,UAAU,CAAE,GAAoB;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK,CAAC,QAAQ,CAAE,GAAoB,EAAE,KAAoB;QACxD,8BAA8B;IAChC,CAAC;IAES,IAAI,CACZ,IAAY,EACZ,OAAe,EACf,WAAW,GAAG,KAAK,EACnB,IAA8B;QAE9B,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;IAES,IAAI,CAAC,GAAoB,EAAE,OAAe;QAClD,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;CACF;AAhCD,8BAgCC;AAED,MAAa,UAAW,SAAQ,KAAK;IAEjB;IACA;IAEA;IACA;IACA;IANlB,YACkB,KAAa,EACb,IAAY,EAC5B,OAAe,EACC,WAAoB,EACpB,IAA8B,EAC9B,KAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAPC,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QAEZ,gBAAW,GAAX,WAAW,CAAS;QACpB,SAAI,GAAJ,IAAI,CAA0B;QAC9B,UAAK,GAAL,KAAK,CAAQ;QAG7B,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAbD,gCAaC"}
@@ -0,0 +1,24 @@
1
+ import { Phase, PhaseContract } from '../pipeline/phase';
2
+ export type PhaseFactory = (config?: Record<string, unknown>) => Phase;
3
+ export declare class PhaseRegistry {
4
+ private phases;
5
+ private tagIndex;
6
+ private metadata;
7
+ register(name: string, factory: PhaseFactory, metadata?: PhaseMetadata): this;
8
+ get(name: string, config?: Record<string, unknown>): Phase;
9
+ has(name: string): boolean;
10
+ findByTags(...tags: string[]): Phase[];
11
+ list(): string[];
12
+ listByTag(tag: string): string[];
13
+ describe(name: string): PhaseContract & PhaseMetadata | undefined;
14
+ describeAll(): Array<PhaseContract & PhaseMetadata>;
15
+ }
16
+ export interface PhaseMetadata {
17
+ tags?: string[];
18
+ category?: string;
19
+ author?: string;
20
+ version?: string;
21
+ deprecated?: boolean;
22
+ deprecationMessage?: string;
23
+ }
24
+ //# sourceMappingURL=phase-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase-registry.d.ts","sourceRoot":"","sources":["../../src/registry/phase-registry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,KAAK,CAAC;AAEvE,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,QAAQ,CAAoC;IAEpD,QAAQ,CACN,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,YAAY,EACrB,QAAQ,GAAE,aAAkB,GAC3B,IAAI;IAeP,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK;IAQ1D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,UAAU,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE;IAWtC,IAAI,IAAI,MAAM,EAAE;IAIhB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE;IAIhC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,SAAS;IAmBjE,WAAW,IAAI,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC;CAGpD;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ // ============================================================================
3
+ // packages/core/src/registry/phase-registry.ts
4
+ // ============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PhaseRegistry = void 0;
7
+ class PhaseRegistry {
8
+ phases = new Map();
9
+ tagIndex = new Map();
10
+ metadata = new Map();
11
+ register(name, factory, metadata = {}) {
12
+ this.phases.set(name, factory);
13
+ this.metadata.set(name, metadata);
14
+ // Index by tags
15
+ for (const tag of metadata.tags ?? []) {
16
+ if (!this.tagIndex.has(tag)) {
17
+ this.tagIndex.set(tag, new Set());
18
+ }
19
+ this.tagIndex.get(tag).add(name);
20
+ }
21
+ return this;
22
+ }
23
+ get(name, config) {
24
+ const factory = this.phases.get(name);
25
+ if (!factory) {
26
+ throw new Error(`Phase "${name}" not found in registry`);
27
+ }
28
+ return factory(config);
29
+ }
30
+ has(name) {
31
+ return this.phases.has(name);
32
+ }
33
+ findByTags(...tags) {
34
+ if (tags.length === 0)
35
+ return [];
36
+ const matchingSets = tags.map(t => this.tagIndex.get(t) ?? new Set());
37
+ const intersection = matchingSets.reduce((acc, set) => new Set([...acc].filter(x => set.has(x))));
38
+ return [...intersection].map(name => this.get(name));
39
+ }
40
+ list() {
41
+ return [...this.phases.keys()];
42
+ }
43
+ listByTag(tag) {
44
+ return [...(this.tagIndex.get(tag) ?? [])];
45
+ }
46
+ describe(name) {
47
+ const factory = this.phases.get(name);
48
+ const metadata = this.metadata.get(name);
49
+ if (!factory)
50
+ return undefined;
51
+ // Create instance to read contract
52
+ const instance = factory({});
53
+ return {
54
+ name: instance.name,
55
+ description: instance.description,
56
+ requires: instance.requires,
57
+ produces: instance.produces,
58
+ optionalReads: instance.optionalReads,
59
+ dependsOn: instance.dependsOn,
60
+ tags: instance.tags,
61
+ ...metadata,
62
+ };
63
+ }
64
+ describeAll() {
65
+ return this.list().map(name => this.describe(name)).filter(Boolean);
66
+ }
67
+ }
68
+ exports.PhaseRegistry = PhaseRegistry;
69
+ //# sourceMappingURL=phase-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase-registry.js","sourceRoot":"","sources":["../../src/registry/phase-registry.ts"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,+CAA+C;AAC/C,+EAA+E;;;AAM/E,MAAa,aAAa;IAChB,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;IACzC,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC1C,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEpD,QAAQ,CACN,IAAY,EACZ,OAAqB,EACrB,WAA0B,EAAE;QAE5B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE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;IACvE,CAAC;CACF;AA7ED,sCA6EC"}
@@ -0,0 +1,27 @@
1
+ export interface ValidationIssue {
2
+ field: string;
3
+ code: string;
4
+ message: string;
5
+ severity: 'error' | 'warning';
6
+ }
7
+ export interface SourceMetadata {
8
+ system: string;
9
+ originalId: string;
10
+ fetchedAt: Date;
11
+ version?: string;
12
+ }
13
+ /**
14
+ * Core Infrastructure Slots
15
+ */
16
+ export declare const CoreSlots: {
17
+ readonly SOURCE_RAW: import("../types/common").SlotKey<unknown>;
18
+ readonly SOURCE_METADATA: import("../types/common").SlotKey<SourceMetadata>;
19
+ readonly TARGET_PAYLOAD: import("../types/common").SlotKey<unknown>;
20
+ readonly TARGET_RESPONSE: import("../types/common").SlotKey<unknown>;
21
+ readonly CONTROL_SHOULD_HALT: import("../types/common").SlotKey<boolean>;
22
+ readonly CONTROL_HALT_REASON: import("../types/common").SlotKey<string>;
23
+ readonly CONTROL_DRY_RUN: import("../types/common").SlotKey<boolean>;
24
+ readonly PROCESSING_BATCH_ID: import("../types/common").SlotKey<string>;
25
+ readonly VALIDATION_ISSUES: import("../types/common").SlotKey<ValidationIssue[]>;
26
+ };
27
+ //# sourceMappingURL=well-known-slots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"well-known-slots.d.ts","sourceRoot":"","sources":["../../src/slots/well-known-slots.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;CA0BZ,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoreSlots = void 0;
4
+ const common_1 = require("../types/common");
5
+ /**
6
+ * Core Infrastructure Slots
7
+ */
8
+ exports.CoreSlots = {
9
+ // ─────────────────────────────────────
10
+ // GENERIC SOURCE DATA
11
+ // ─────────────────────────────────────
12
+ SOURCE_RAW: (0, common_1.createSlotKey)('source.raw'),
13
+ SOURCE_METADATA: (0, common_1.createSlotKey)('source.metadata'),
14
+ // ─────────────────────────────────────
15
+ // GENERIC TARGET DATA
16
+ // ─────────────────────────────────────
17
+ TARGET_PAYLOAD: (0, common_1.createSlotKey)('target.payload'),
18
+ TARGET_RESPONSE: (0, common_1.createSlotKey)('target.response'),
19
+ // ─────────────────────────────────────
20
+ // CONTROL FLOW & META
21
+ // ─────────────────────────────────────
22
+ CONTROL_SHOULD_HALT: (0, common_1.createSlotKey)('control.shouldHalt'),
23
+ CONTROL_HALT_REASON: (0, common_1.createSlotKey)('control.haltReason'),
24
+ CONTROL_DRY_RUN: (0, common_1.createSlotKey)('control.dryRun'),
25
+ PROCESSING_BATCH_ID: (0, common_1.createSlotKey)('processing.batchId'),
26
+ // ─────────────────────────────────────
27
+ // VALIDATION
28
+ // ─────────────────────────────────────
29
+ VALIDATION_ISSUES: (0, common_1.createSlotKey)('validation.issues'),
30
+ };
31
+ //# sourceMappingURL=well-known-slots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"well-known-slots.js","sourceRoot":"","sources":["../../src/slots/well-known-slots.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAiBhD;;GAEG;AACU,QAAA,SAAS,GAAG;IACvB,wCAAwC;IACxC,sBAAsB;IACtB,wCAAwC;IACxC,UAAU,EAAE,IAAA,sBAAa,EAAU,YAAY,CAAC;IAChD,eAAe,EAAE,IAAA,sBAAa,EAAiB,iBAAiB,CAAC;IAEjE,wCAAwC;IACxC,sBAAsB;IACtB,wCAAwC;IACxC,cAAc,EAAE,IAAA,sBAAa,EAAU,gBAAgB,CAAC;IACxD,eAAe,EAAE,IAAA,sBAAa,EAAU,iBAAiB,CAAC;IAE1D,wCAAwC;IACxC,sBAAsB;IACtB,wCAAwC;IACxC,mBAAmB,EAAE,IAAA,sBAAa,EAAU,oBAAoB,CAAC;IACjE,mBAAmB,EAAE,IAAA,sBAAa,EAAS,oBAAoB,CAAC;IAChE,eAAe,EAAE,IAAA,sBAAa,EAAU,gBAAgB,CAAC;IAEzD,mBAAmB,EAAE,IAAA,sBAAa,EAAS,oBAAoB,CAAC;IAEhE,wCAAwC;IACxC,aAAa;IACb,wCAAwC;IACxC,iBAAiB,EAAE,IAAA,sBAAa,EAAoB,mBAAmB,CAAC;CAChE,CAAC"}
@@ -0,0 +1,45 @@
1
+ export type SlotKey<T = unknown> = string & {
2
+ __brand: 'SlotKey';
3
+ __type: T;
4
+ };
5
+ /**
6
+ * Creates a typed slot key.
7
+ * Usage: const MY_SLOT = createSlotKey<MyType>('my-slot');
8
+ */
9
+ export declare const createSlotKey: <T = unknown>(key: string) => SlotKey<T>;
10
+ export interface ClientConfig {
11
+ clientId: string;
12
+ environment: 'dev' | 'staging' | 'prod';
13
+ features?: Record<string, boolean>;
14
+ settings?: Record<string, unknown>;
15
+ }
16
+ export interface PipelineError {
17
+ phase: string;
18
+ code: string;
19
+ message: string;
20
+ recoverable: boolean;
21
+ data?: Record<string, unknown>;
22
+ cause?: unknown;
23
+ stack?: string;
24
+ timestamp?: Date;
25
+ }
26
+ export interface PhaseExecution {
27
+ phaseName: string;
28
+ startedAt: Date;
29
+ completedAt?: Date;
30
+ duration?: number;
31
+ status: 'running' | 'completed' | 'skipped' | 'failed';
32
+ error?: PipelineError;
33
+ slotsRead: string[];
34
+ slotsWritten: string[];
35
+ }
36
+ export interface ExecutionMetadata {
37
+ pipelineId: string;
38
+ executionId: string;
39
+ traceId: string;
40
+ startedAt: Date;
41
+ phaseHistory: PhaseExecution[];
42
+ currentPhase?: string;
43
+ [key: string]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EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // packages/core/src/types/common.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createSlotKey = void 0;
5
+ /**
6
+ * Creates a typed slot key.
7
+ * Usage: const MY_SLOT = createSlotKey<MyType>('my-slot');
8
+ */
9
+ const createSlotKey = (key) => key;
10
+ exports.createSlotKey = createSlotKey;
11
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;AAYpC;;;GAGG;AACI,MAAM,aAAa,GAAG,CAAc,GAAW,EAAc,EAAE,CACpE,GAA4B,CAAC;AADlB,QAAA,aAAa,iBACK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonytang99/integration-core",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Core pipeline framework for integration platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",