@girverket/xenocline 0.0.9

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 (112) hide show
  1. package/LICENSE.md +66 -0
  2. package/README.md +739 -0
  3. package/dist/aggregator.d.ts +53 -0
  4. package/dist/aggregator.js +31 -0
  5. package/dist/aggregator.js.map +1 -0
  6. package/dist/constants.d.ts +2 -0
  7. package/dist/context.d.ts +3 -0
  8. package/dist/event/aggregator.d.ts +16 -0
  9. package/dist/event/aggregator.js +29 -0
  10. package/dist/event/aggregator.js.map +1 -0
  11. package/dist/event/event.d.ts +14 -0
  12. package/dist/event/event.js +12 -0
  13. package/dist/event/event.js.map +1 -0
  14. package/dist/event/handler.d.ts +7 -0
  15. package/dist/event/handler.js +8 -0
  16. package/dist/event/handler.js.map +1 -0
  17. package/dist/event/node.d.ts +40 -0
  18. package/dist/event/node.js +24 -0
  19. package/dist/event/node.js.map +1 -0
  20. package/dist/event/phase.d.ts +15 -0
  21. package/dist/event/phase.js +12 -0
  22. package/dist/event/phase.js.map +1 -0
  23. package/dist/event/process.d.ts +14 -0
  24. package/dist/event/process.js +15 -0
  25. package/dist/event/process.js.map +1 -0
  26. package/dist/event/transition.d.ts +45 -0
  27. package/dist/event/transition.js +35 -0
  28. package/dist/event/transition.js.map +1 -0
  29. package/dist/event.d.ts +30 -0
  30. package/dist/execution/aggregator.d.ts +23 -0
  31. package/dist/execution/aggregator.js +81 -0
  32. package/dist/execution/aggregator.js.map +1 -0
  33. package/dist/execution/event.d.ts +26 -0
  34. package/dist/execution/event.js +29 -0
  35. package/dist/execution/event.js.map +1 -0
  36. package/dist/execution/next.d.ts +7 -0
  37. package/dist/execution/next.js +137 -0
  38. package/dist/execution/next.js.map +1 -0
  39. package/dist/execution/node.d.ts +4 -0
  40. package/dist/execution/node.js +194 -0
  41. package/dist/execution/node.js.map +1 -0
  42. package/dist/execution/phase.d.ts +5 -0
  43. package/dist/execution/phase.js +23 -0
  44. package/dist/execution/phase.js.map +1 -0
  45. package/dist/execution/process.d.ts +35 -0
  46. package/dist/execution/process.js +115 -0
  47. package/dist/execution/process.js.map +1 -0
  48. package/dist/input.d.ts +6 -0
  49. package/dist/input.js +4 -0
  50. package/dist/input.js.map +1 -0
  51. package/dist/logger.d.ts +12 -0
  52. package/dist/node/aggregatornode.d.ts +40 -0
  53. package/dist/node/aggregatornode.js +41 -0
  54. package/dist/node/aggregatornode.js.map +1 -0
  55. package/dist/node/node.d.ts +18 -0
  56. package/dist/node/node.js +80 -0
  57. package/dist/node/node.js.map +1 -0
  58. package/dist/node/phasenode.d.ts +49 -0
  59. package/dist/node/phasenode.js +37 -0
  60. package/dist/node/phasenode.js.map +1 -0
  61. package/dist/output.d.ts +6 -0
  62. package/dist/phase.d.ts +23 -0
  63. package/dist/phase.js +24 -0
  64. package/dist/phase.js.map +1 -0
  65. package/dist/process.d.ts +15 -0
  66. package/dist/process.js +106 -0
  67. package/dist/process.js.map +1 -0
  68. package/dist/transition/beginning.d.ts +19 -0
  69. package/dist/transition/beginning.js +31 -0
  70. package/dist/transition/beginning.js.map +1 -0
  71. package/dist/transition/connection.d.ts +55 -0
  72. package/dist/transition/connection.js +90 -0
  73. package/dist/transition/connection.js.map +1 -0
  74. package/dist/transition/decision.d.ts +20 -0
  75. package/dist/transition/decision.js +47 -0
  76. package/dist/transition/decision.js.map +1 -0
  77. package/dist/transition/next.d.ts +13 -0
  78. package/dist/transition/next.js +81 -0
  79. package/dist/transition/next.js.map +1 -0
  80. package/dist/transition/termination.d.ts +17 -0
  81. package/dist/transition/termination.js +50 -0
  82. package/dist/transition/termination.js.map +1 -0
  83. package/dist/transition/transition.d.ts +16 -0
  84. package/dist/transition/transition.js +72 -0
  85. package/dist/transition/transition.js.map +1 -0
  86. package/dist/util/general.d.ts +4 -0
  87. package/dist/util/general.js +6 -0
  88. package/dist/util/general.js.map +1 -0
  89. package/dist/utility/event/eventfilter.d.ts +7 -0
  90. package/dist/utility/event/eventfilter.js +15 -0
  91. package/dist/utility/event/eventfilter.js.map +1 -0
  92. package/dist/utility/event/filteredhandler.d.ts +13 -0
  93. package/dist/utility/event/filteredhandler.js +18 -0
  94. package/dist/utility/event/filteredhandler.js.map +1 -0
  95. package/dist/utility/event/logginghandler.d.ts +12 -0
  96. package/dist/xenocline.cjs +1362 -0
  97. package/dist/xenocline.cjs.map +1 -0
  98. package/dist/xenocline.d.ts +72 -0
  99. package/dist/xenocline.js +21 -0
  100. package/dist/xenocline.js.map +1 -0
  101. package/output/kodrdriv/260109-2305-commit-message.md +3 -0
  102. package/output/kodrdriv/260109-2307-release-notes.md +28 -0
  103. package/output/kodrdriv/260109-2318-commit-message.md +6 -0
  104. package/output/kodrdriv/260109-2321-release-notes.md +39 -0
  105. package/output/kodrdriv/RELEASE_NOTES.md +37 -0
  106. package/output/kodrdriv/RELEASE_TITLE.md +1 -0
  107. package/output/kodrdriv/agentic-reflection-commit-2026-01-10T07-05-39-771Z.md +52 -0
  108. package/output/kodrdriv/agentic-reflection-commit-2026-01-10T07-18-31-315Z.md +55 -0
  109. package/output/kodrdriv/agentic-reflection-release-2026-01-10T07-07-33-739Z.md +257 -0
  110. package/output/kodrdriv/agentic-reflection-release-2026-01-10T07-21-54-717Z.md +394 -0
  111. package/package.json +69 -0
  112. package/scripts/pre-commit-hook.sh +53 -0
@@ -0,0 +1,106 @@
1
+ import { validateNode } from './node/node.js';
2
+ import { isConnection } from './transition/connection.js';
3
+ import { clean } from './util/general.js';
4
+
5
+ //import * as ClassifyPhase from './phases/classify';
6
+ // import * as TranscribePhase from './phases/transcribe';
7
+ // import * as ComposePhase from './phases/compose';
8
+ // import * as CompletePhase from './phases/complete';
9
+ const createProcess = (name, options)=>{
10
+ const defaultOptions = {
11
+ phases: {}
12
+ };
13
+ const processOptions = {
14
+ ...defaultOptions,
15
+ ...clean(options)
16
+ };
17
+ // Removed: const eventState = createEventState<C>(processOptions.eventHandlers);
18
+ return {
19
+ name,
20
+ phases: processOptions.phases
21
+ };
22
+ };
23
+ const isProcess = (obj)=>{
24
+ return obj !== undefined && obj !== null && typeof obj === 'object' && typeof obj.name === 'string' && typeof obj.phases === 'object';
25
+ };
26
+ const validateProcess = (item, coordinates)=>{
27
+ const errors = [];
28
+ const currentCoordinates = [
29
+ ...[],
30
+ 'Process'
31
+ ];
32
+ if (item === undefined || item === null) {
33
+ errors.push({
34
+ coordinates: [
35
+ ...currentCoordinates
36
+ ],
37
+ error: 'Process is undefined or null.'
38
+ });
39
+ return errors;
40
+ }
41
+ if (item.name === undefined || typeof item.name !== 'string') {
42
+ errors.push({
43
+ coordinates: [
44
+ ...currentCoordinates
45
+ ],
46
+ error: 'Process name is undefined or not a string.'
47
+ });
48
+ }
49
+ const processNameForPath = typeof item.name === 'string' ? item.name : 'UnnamedProcess';
50
+ const basePath = [
51
+ ...currentCoordinates,
52
+ `name:${processNameForPath}`
53
+ ];
54
+ if (item.phases === undefined || typeof item.phases !== 'object') {
55
+ errors.push({
56
+ coordinates: [
57
+ ...basePath,
58
+ 'phases'
59
+ ],
60
+ error: 'Process phases is undefined or not an object.'
61
+ });
62
+ } else {
63
+ for(const phaseId in item.phases){
64
+ const node = item.phases[phaseId];
65
+ if (Object.prototype.hasOwnProperty.call(item.phases, phaseId)) {
66
+ errors.push(...validateNode(node, [
67
+ ...basePath,
68
+ 'phases',
69
+ phaseId
70
+ ]));
71
+ }
72
+ }
73
+ for(const phaseId in item.phases){
74
+ if (Object.prototype.hasOwnProperty.call(item.phases, phaseId)) {
75
+ const node = item.phases[phaseId];
76
+ if (node && typeof node === 'object' && node.next) {
77
+ if (Array.isArray(node.next)) {
78
+ const transitions = node.next;
79
+ if (transitions.length > 0 && transitions.every((t)=>isConnection(t))) {
80
+ transitions.forEach((connection, index)=>{
81
+ if (connection && typeof connection.targetNodeId === 'string') {
82
+ if (!(connection.targetNodeId in item.phases)) {
83
+ errors.push({
84
+ coordinates: [
85
+ ...basePath,
86
+ 'phases',
87
+ phaseId,
88
+ 'next',
89
+ connection.id || `connection-at-index-${index}`
90
+ ],
91
+ error: `Node "${phaseId}" has a connection to non-existent targetNodeId "${connection.targetNodeId}".`
92
+ });
93
+ }
94
+ } else if (!connection || connection.targetNodeId === undefined) ;
95
+ });
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ return errors;
103
+ };
104
+
105
+ export { createProcess, isProcess, validateProcess };
106
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sources":["../src/process.ts"],"sourcesContent":["//import * as ClassifyPhase from './phases/classify';\n// import * as TranscribePhase from './phases/transcribe';\n// import * as ComposePhase from './phases/compose';\n// import * as CompletePhase from './phases/complete';\nimport { AggregatorNode } from './node/aggregatornode';\nimport { validateNode } from './node/node';\nimport { PhaseNode } from './node/phasenode';\nimport { Connection, isConnection } from './transition/connection';\nimport { clean } from './util/general';\n// Removed: import { Phase } from './phase';\n// Removed: import { Event, EventHandler, EventState, createEventState } from './event';\n\nexport interface ProcessOptions {\n phases: Record<string, PhaseNode | AggregatorNode>;\n // Removed: eventHandlers?: ReadonlyArray<EventHandler<Event, C>>;\n}\n\nexport interface Process {\n name: string;\n phases: Record<string, PhaseNode | AggregatorNode>;\n // Removed: readonly eventState: Readonly<EventState<C>>;\n}\n\nexport const createProcess = (\n name: string,\n options: Partial<ProcessOptions>\n): Readonly<Process> => {\n const defaultOptions: ProcessOptions = {\n phases: {},\n // Removed: eventHandlers: [],\n };\n\n const processOptions: ProcessOptions = { ...defaultOptions, ...clean(options) };\n\n // Removed: const eventState = createEventState<C>(processOptions.eventHandlers);\n\n return {\n name,\n phases: processOptions.phases,\n // Removed: eventState\n };\n}\n\nexport const isProcess = (obj: any): obj is Process => {\n return obj !== undefined && obj !== null && typeof obj === 'object' && typeof obj.name === 'string' && typeof obj.phases === 'object';\n}\n\nexport const validateProcess = (\n item: any,\n coordinates?: string[]\n): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || []), 'Process'];\n\n if (item === undefined || item === null) {\n errors.push({ coordinates: [...currentCoordinates], error: 'Process is undefined or null.' });\n return errors;\n }\n\n if (item.name === undefined || typeof item.name !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Process name is undefined or not a string.' });\n }\n\n const processNameForPath = typeof item.name === 'string' ? item.name : 'UnnamedProcess';\n const basePath = [...currentCoordinates, `name:${processNameForPath}`];\n\n if (item.phases === undefined || typeof item.phases !== 'object') {\n errors.push({ coordinates: [...basePath, 'phases'], error: 'Process phases is undefined or not an object.' });\n } else {\n for (const phaseId in item.phases) {\n const node = item.phases[phaseId];\n if (Object.prototype.hasOwnProperty.call(item.phases, phaseId)) {\n errors.push(...validateNode(node, [...basePath, 'phases', phaseId]));\n }\n }\n\n for (const phaseId in item.phases) {\n if (Object.prototype.hasOwnProperty.call(item.phases, phaseId)) {\n const node = item.phases[phaseId];\n if (node && typeof node === 'object' && node.next) {\n if (Array.isArray(node.next)) {\n const transitions = node.next as any[];\n if (transitions.length > 0 && transitions.every(t => isConnection(t))) {\n (transitions as Connection[]).forEach((connection, index) => {\n if (connection && typeof connection.targetNodeId === 'string') {\n if (!(connection.targetNodeId in item.phases)) {\n errors.push({\n coordinates: [...basePath, 'phases', phaseId, 'next', connection.id || `connection-at-index-${index}`],\n error: `Node \"${phaseId}\" has a connection to non-existent targetNodeId \"${connection.targetNodeId}\".`\n });\n }\n } else if (!connection || connection.targetNodeId === undefined) {\n // This case should ideally be caught by validateConnection within validateNode's call to validateNext\n // but adding a fallback or note if connection structure itself is broken at this stage.\n // errors.push({\n // coordinates: [...basePath, 'phases', phaseId, 'next', `connection-at-index-${index}`],\n // error: `Connection at index ${index} for node \"${phaseId}\" is malformed or missing targetNodeId.`\n // });\n }\n });\n }\n }\n }\n }\n }\n }\n\n return errors;\n}"],"names":["createProcess","name","options","defaultOptions","phases","processOptions","clean","isProcess","obj","undefined","validateProcess","item","coordinates","errors","currentCoordinates","push","error","processNameForPath","basePath","phaseId","node","Object","prototype","hasOwnProperty","call","validateNode","next","Array","isArray","transitions","length","every","t","isConnection","forEach","connection","index","targetNodeId","id"],"mappings":";;;;AAAA;AACA;AACA;AACA;AAoBO,MAAMA,aAAAA,GAAgB,CACzBC,IAAAA,EACAC,OAAAA,GAAAA;AAEA,IAAA,MAAMC,cAAAA,GAAiC;AACnCC,QAAAA,MAAAA,EAAQ;AAEZ,KAAA;AAEA,IAAA,MAAMC,cAAAA,GAAiC;AAAE,QAAA,GAAGF,cAAc;AAAE,QAAA,GAAGG,MAAMJ,OAAAA;AAAS,KAAA;;IAI9E,OAAO;AACHD,QAAAA,IAAAA;AACAG,QAAAA,MAAAA,EAAQC,eAAeD;AAE3B,KAAA;AACJ;AAEO,MAAMG,YAAY,CAACC,GAAAA,GAAAA;AACtB,IAAA,OAAOA,GAAAA,KAAQC,SAAAA,IAAaD,GAAAA,KAAQ,IAAA,IAAQ,OAAOA,GAAAA,KAAQ,QAAA,IAAY,OAAOA,GAAAA,CAAIP,IAAI,KAAK,QAAA,IAAY,OAAOO,GAAAA,CAAIJ,MAAM,KAAK,QAAA;AACjI;AAEO,MAAMM,eAAAA,GAAkB,CAC3BC,IAAAA,EACAC,WAAAA,GAAAA;AAEA,IAAA,MAAMC,SAA0D,EAAE;AAClE,IAAA,MAAMC,kBAAAA,GAAqB;AAAKF,QAAAA,GAAe,EAAE;AAAG,QAAA;AAAU,KAAA;IAE9D,IAAID,IAAAA,KAASF,SAAAA,IAAaE,IAAAA,KAAS,IAAA,EAAM;AACrCE,QAAAA,MAAAA,CAAOE,IAAI,CAAC;YAAEH,WAAAA,EAAa;AAAIE,gBAAAA,GAAAA;AAAmB,aAAA;YAAEE,KAAAA,EAAO;AAAgC,SAAA,CAAA;QAC3F,OAAOH,MAAAA;AACX,IAAA;IAEA,IAAIF,IAAAA,CAAKV,IAAI,KAAKQ,SAAAA,IAAa,OAAOE,IAAAA,CAAKV,IAAI,KAAK,QAAA,EAAU;AAC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AACJ,oBAAA;AACJ,gBAAA;AACJ,YAAA;AACJ,QAAA;AACJ,IAAA;IAEA,OAAOI,MAAAA;AACX;;;;"}
@@ -0,0 +1,19 @@
1
+ import { Context } from '../context';
2
+ import { Input } from '../input';
3
+ import { Transition } from './transition';
4
+ export type BeginFunction<I extends Input = Input, C extends Context = Context> = (input: I, context: C) => Promise<Input>;
5
+ export interface Beginning<I extends Input = Input, C extends Context = Context> extends Transition {
6
+ type: 'beginning';
7
+ targetNodeId: string;
8
+ begin: BeginFunction<I, C>;
9
+ }
10
+ export interface BeginningOptions<I extends Input = Input, C extends Context = Context> {
11
+ begin: BeginFunction<I, C>;
12
+ }
13
+ export declare const DEFAULT_BEGINNING_OPTIONS: BeginningOptions<Input, Context>;
14
+ export declare const createBeginning: <I extends Input = Input, C extends Context = Context>(id: string, targetNodeId: string, options?: Partial<BeginningOptions<I, C>>) => Readonly<Beginning<I, C>>;
15
+ export declare const isBeginning: <I extends Input = Input, C extends Context = Context>(item: any) => item is Beginning<I, C>;
16
+ export declare const validateBeginning: (item: any, coordinates?: string[]) => Array<{
17
+ coordinates: string[];
18
+ error: string;
19
+ }>;
@@ -0,0 +1,31 @@
1
+ import { clean } from '../util/general.js';
2
+ import { createTransition, isTransition } from './transition.js';
3
+
4
+ // NEW: Termination type extending Transition
5
+ const DEFAULT_BEGINNING_OPTIONS = {
6
+ begin: async (input)=>{
7
+ return input;
8
+ }
9
+ };
10
+ const createBeginning = (id, targetNodeId, options)=>{
11
+ let beginningOptions = {
12
+ ...DEFAULT_BEGINNING_OPTIONS
13
+ };
14
+ if (options) {
15
+ beginningOptions = {
16
+ ...beginningOptions,
17
+ ...clean(options)
18
+ };
19
+ }
20
+ return {
21
+ ...createTransition('beginning', id),
22
+ targetNodeId,
23
+ begin: beginningOptions.begin
24
+ };
25
+ };
26
+ const isBeginning = (item)=>{
27
+ return isTransition(item) && item.type === 'beginning' && (item.begin === undefined || typeof item.begin === 'function');
28
+ };
29
+
30
+ export { DEFAULT_BEGINNING_OPTIONS, createBeginning, isBeginning };
31
+ //# sourceMappingURL=beginning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"beginning.js","sources":["../../src/transition/beginning.ts"],"sourcesContent":["// NEW: Termination type extending Transition\n/**\n * Represents a termination point in the process flow, consuming a phase's output.\n */\n\nimport { clean } from '../util/general';\nimport { Context } from '../context';\nimport { Input } from '../input';\nimport { createTransition, isTransition, Transition, validateTransition } from './transition';\n\nexport type BeginFunction<I extends Input = Input, C extends Context = Context> = (input: I, context: C) => Promise<Input>;\n\nexport interface Beginning<\n I extends Input = Input,\n C extends Context = Context,\n> extends Transition {\n type: 'beginning';\n targetNodeId: string;\n // Currently, Termination is a marker type.\n // Future properties could include:\n // reason?: string; // To describe why termination occurred\n begin: BeginFunction<I, C>; // A function to execute upon beginning\n}\n\nexport interface BeginningOptions<I extends Input = Input, C extends Context = Context> {\n begin: BeginFunction<I, C>;\n}\n\nexport const DEFAULT_BEGINNING_OPTIONS: BeginningOptions<Input, Context> = {\n begin: async (input) => {\n return input;\n }\n};\n\nexport const createBeginning = <I extends Input = Input, C extends Context = Context>(\n id: string,\n targetNodeId: string,\n options?: Partial<BeginningOptions<I, C>>\n): Readonly<Beginning<I, C>> => {\n let beginningOptions: BeginningOptions<I, C> = { ...DEFAULT_BEGINNING_OPTIONS };\n if (options) {\n beginningOptions = { ...beginningOptions, ...clean(options) };\n }\n\n return {\n ...createTransition('beginning', id),\n targetNodeId,\n begin: beginningOptions.begin,\n } as Beginning<I, C>;\n};\n\nexport const isBeginning = <I extends Input = Input, C extends Context = Context>(item: any): item is Beginning<I, C> => {\n return isTransition(item) &&\n item.type === 'beginning' &&\n ((item as Beginning<I, C>).begin === undefined || typeof (item as Beginning<I, C>).begin === 'function');\n};\n\nexport const validateBeginning = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || []), 'Beginning'];\n\n errors.push(...validateTransition(item, currentCoordinates));\n\n if (errors.length === 0) {\n currentCoordinates.push(`Beginning: ${item.id}`);\n\n if (item.begin !== undefined && typeof item.begin !== 'function') {\n errors.push({ coordinates: [...currentCoordinates], error: 'begin is not a function.' });\n }\n }\n\n return errors;\n};\n"],"names":["DEFAULT_BEGINNING_OPTIONS","begin","input","createBeginning","id","targetNodeId","options","beginningOptions","clean","createTransition","isBeginning","item","isTransition","type","undefined"],"mappings":";;;AAAA;MA4BaA,yBAAAA,GAA8D;AACvEC,IAAAA,KAAAA,EAAO,OAAOC,KAAAA,GAAAA;QACV,OAAOA,KAAAA;AACX,IAAA;AACJ;AAEO,MAAMC,eAAAA,GAAkB,CAC3BC,EAAAA,EACAC,YAAAA,EACAC,OAAAA,GAAAA;AAEA,IAAA,IAAIC,gBAAAA,GAA2C;AAAE,QAAA,GAAGP;AAA0B,KAAA;AAC9E,IAAA,IAAIM,OAAAA,EAAS;QACTC,gBAAAA,GAAmB;AAAE,YAAA,GAAGA,gBAAgB;AAAE,YAAA,GAAGC,MAAMF,OAAAA;AAAS,SAAA;AAChE,IAAA;IAEA,OAAO;QACH,GAAGG,gBAAAA,CAAiB,aAAaL,EAAAA,CAAG;AACpCC,QAAAA,YAAAA;AACAJ,QAAAA,KAAAA,EAAOM,iBAAiBN;AAC5B,KAAA;AACJ;AAEO,MAAMS,cAAc,CAAuDC,IAAAA,GAAAA;AAC9E,IAAA,OAAOC,aAAaD,IAAAA,CAAAA,IAChBA,IAAAA,CAAKE,IAAI,KAAK,gBACZF,IAAAA,CAAyBV,KAAK,KAAKa,SAAAA,IAAa,OAAO,IAACH,CAAyBV,KAAK,KAAK,UAAS,CAAA;AAC9G;;;;"}
@@ -0,0 +1,55 @@
1
+ import { Input } from '../input';
2
+ import { Context } from '../context';
3
+ import { Output } from '../output';
4
+ import { Transition } from './transition';
5
+ /**
6
+ * Transform function for connections between nodes.
7
+ * Takes the output from the source node and the current context,
8
+ * and returns the input for the target node along with an updated context.
9
+ *
10
+ * CONCURRENCY WARNING: In parallel execution scenarios (fan-out from one node
11
+ * to multiple target nodes), each connection's transform receives the same
12
+ * source context. Context mutations from one connection may be overwritten
13
+ * by another. The last transform to complete will have its context changes
14
+ * reflected in the process state.
15
+ *
16
+ * Best practice: Minimize context mutations in transforms, or use unique
17
+ * context keys per connection path to avoid conflicts.
18
+ */
19
+ export type TransformFunction<O extends Output = Output, C extends Context = Context> = (output: O, context: C) => Promise<[Input, C]>;
20
+ export interface Connection<O extends Output = Output, C extends Context = Context> extends Transition {
21
+ type: 'connection';
22
+ targetNodeId: string;
23
+ /**
24
+ * Optional function to transform the output of the current phase
25
+ * to the input of the target phase.
26
+ * If not provided, the output is assumed to be compatible directly.
27
+ *
28
+ * See TransformFunction documentation for concurrency considerations.
29
+ */
30
+ transform: TransformFunction<O, C>;
31
+ }
32
+ export interface ConnectionOptions<O extends Output = Output, C extends Context = Context> {
33
+ transform: TransformFunction<O, C>;
34
+ }
35
+ /**
36
+ * Default connection options with a pass-through transform.
37
+ * WARNING: The default transform uses a type assertion (output as Input) which provides
38
+ * no runtime validation. Users should provide their own transform function if the output
39
+ * type does not structurally match the expected input type of the target node.
40
+ * The type assertion is used here to maintain backward compatibility and allow simple
41
+ * pass-through scenarios where Output and Input have compatible shapes.
42
+ */
43
+ export declare const DEFAULT_CONNECTION_OPTIONS: ConnectionOptions;
44
+ export declare const createConnection: <O extends Output = Output, C extends Context = Context>(id: string, targetNodeId: string, options?: Partial<ConnectionOptions<O, C>>) => Readonly<Connection<O, C>>;
45
+ export declare const isConnection: <O extends Output = Output, C extends Context = Context>(item: any) => item is Connection<O, C>;
46
+ export declare const validateConnection: (item: any, coordinates?: string[]) => Array<{
47
+ coordinates: string[];
48
+ error: string;
49
+ }>;
50
+ /**
51
+ * Event emitted specifically for connection transitions.
52
+ */
53
+ export interface ConnectionEvent extends TransitionEvent {
54
+ transitionType: 'connection';
55
+ }
@@ -0,0 +1,90 @@
1
+ import { createTransition, isTransition, validateTransition } from './transition.js';
2
+ import { clean } from '../util/general.js';
3
+
4
+ /**
5
+ * Default connection options with a pass-through transform.
6
+ * WARNING: The default transform uses a type assertion (output as Input) which provides
7
+ * no runtime validation. Users should provide their own transform function if the output
8
+ * type does not structurally match the expected input type of the target node.
9
+ * The type assertion is used here to maintain backward compatibility and allow simple
10
+ * pass-through scenarios where Output and Input have compatible shapes.
11
+ */ const DEFAULT_CONNECTION_OPTIONS = {
12
+ transform: async (output, context)=>{
13
+ // Type assertion used here - Output and Input are both extensible objects
14
+ // so this is safe for pass-through scenarios, but users should validate
15
+ // or transform data if types don't align
16
+ return [
17
+ output,
18
+ context
19
+ ];
20
+ }
21
+ };
22
+ const createConnection = (id, targetNodeId, options)=>{
23
+ let connectionOptions = {
24
+ ...DEFAULT_CONNECTION_OPTIONS
25
+ };
26
+ if (options) {
27
+ connectionOptions = {
28
+ ...connectionOptions,
29
+ ...clean(options)
30
+ };
31
+ }
32
+ return {
33
+ ...createTransition('connection', id),
34
+ targetNodeId,
35
+ transform: connectionOptions.transform
36
+ };
37
+ };
38
+ const isConnection = (item)=>{
39
+ return isTransition(item) && item.type === 'connection' && item.targetNodeId !== undefined;
40
+ };
41
+ const validateConnection = (item, coordinates)=>{
42
+ const errors = [];
43
+ const connectionBaseCoordinates = [
44
+ ...coordinates || [],
45
+ 'Connection'
46
+ ];
47
+ errors.push(...validateTransition(item, coordinates));
48
+ if (errors.length === 0) {
49
+ if (item && typeof item === 'object') {
50
+ const connectionSpecificErrorPath = [
51
+ ...connectionBaseCoordinates,
52
+ `Connection: ${item.id}`
53
+ ];
54
+ if (item.type === 'connection') {
55
+ if (typeof item.targetNodeId !== 'string') {
56
+ errors.push({
57
+ coordinates: connectionSpecificErrorPath,
58
+ error: 'Property "targetNodeId" must be a string when type is "connection".'
59
+ });
60
+ }
61
+ // transform is optional, but if present, must be a function.
62
+ if (item.transform !== undefined && typeof item.transform !== 'function') {
63
+ errors.push({
64
+ coordinates: connectionSpecificErrorPath,
65
+ error: 'Optional property "transform" must be a function if present.'
66
+ });
67
+ }
68
+ } else {
69
+ // If type is not 'connection', but these properties exist and are malformed.
70
+ // This primarily helps catch if a non-connection object has these fields incorrectly defined.
71
+ if (item.targetNodeId !== undefined && typeof item.targetNodeId !== 'string') {
72
+ errors.push({
73
+ coordinates: connectionSpecificErrorPath,
74
+ error: 'Property "targetNodeId" is present but is not a string.'
75
+ });
76
+ }
77
+ if (item.transform !== undefined && typeof item.transform !== 'function') {
78
+ errors.push({
79
+ coordinates: connectionSpecificErrorPath,
80
+ error: 'Property "transform" is present but is not a function.'
81
+ });
82
+ }
83
+ }
84
+ }
85
+ }
86
+ return errors;
87
+ };
88
+
89
+ export { DEFAULT_CONNECTION_OPTIONS, createConnection, isConnection, validateConnection };
90
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","sources":["../../src/transition/connection.ts"],"sourcesContent":["import { Input } from '../input';\nimport { Context } from '../context';\nimport { Output } from '../output';\nimport { createTransition, isTransition, Transition, validateTransition } from './transition';\nimport { clean } from '../util/general';\n\n/**\n * Transform function for connections between nodes.\n * Takes the output from the source node and the current context,\n * and returns the input for the target node along with an updated context.\n *\n * CONCURRENCY WARNING: In parallel execution scenarios (fan-out from one node\n * to multiple target nodes), each connection's transform receives the same\n * source context. Context mutations from one connection may be overwritten\n * by another. The last transform to complete will have its context changes\n * reflected in the process state.\n *\n * Best practice: Minimize context mutations in transforms, or use unique\n * context keys per connection path to avoid conflicts.\n */\nexport type TransformFunction<O extends Output = Output, C extends Context = Context> = (output: O, context: C) => Promise<[Input, C]>;\n\n// MODIFIED: Connection to extend Transition\nexport interface Connection<\n O extends Output = Output,\n C extends Context = Context,\n> extends Transition {\n type: 'connection';\n targetNodeId: string; // ID of the target PhaseNode in the process's phases collection\n /**\n * Optional function to transform the output of the current phase\n * to the input of the target phase.\n * If not provided, the output is assumed to be compatible directly.\n *\n * See TransformFunction documentation for concurrency considerations.\n */\n transform: TransformFunction<O, C>;\n}\n\nexport interface ConnectionOptions<O extends Output = Output, C extends Context = Context> {\n transform: TransformFunction<O, C>;\n}\n\n/**\n * Default connection options with a pass-through transform.\n * WARNING: The default transform uses a type assertion (output as Input) which provides\n * no runtime validation. Users should provide their own transform function if the output\n * type does not structurally match the expected input type of the target node.\n * The type assertion is used here to maintain backward compatibility and allow simple\n * pass-through scenarios where Output and Input have compatible shapes.\n */\nexport const DEFAULT_CONNECTION_OPTIONS: ConnectionOptions = {\n transform: async (output, context) => {\n // Type assertion used here - Output and Input are both extensible objects\n // so this is safe for pass-through scenarios, but users should validate\n // or transform data if types don't align\n return [output as Input, context];\n }\n};\n\nexport const createConnection = <O extends Output = Output, C extends Context = Context>(\n id: string,\n targetNodeId: string,\n options?: Partial<ConnectionOptions<O, C>>\n): Readonly<Connection<O, C>> => {\n\n let connectionOptions: ConnectionOptions<O, C> = { ...DEFAULT_CONNECTION_OPTIONS } as unknown as ConnectionOptions<O, C>;\n\n if (options) {\n connectionOptions = { ...connectionOptions, ...clean(options) };\n }\n\n return {\n ...createTransition('connection', id),\n targetNodeId,\n transform: connectionOptions.transform,\n } as Connection<O, C>;\n};\n\nexport const isConnection = <O extends Output = Output, C extends Context = Context>(item: any): item is Connection<O, C> => {\n return isTransition(item) && item.type === 'connection' && (item as Connection<O, C>).targetNodeId !== undefined;\n};\n\nexport const validateConnection = (\n item: any,\n coordinates?: string[]\n): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const connectionBaseCoordinates = [...(coordinates || []), 'Connection'];\n\n errors.push(...validateTransition(item, coordinates));\n\n if (errors.length === 0) {\n if (item && typeof item === 'object') {\n const connectionSpecificErrorPath = [...connectionBaseCoordinates, `Connection: ${item.id}`];\n\n if (item.type === 'connection') {\n if (typeof item.targetNodeId !== 'string') {\n errors.push({ coordinates: connectionSpecificErrorPath, error: 'Property \"targetNodeId\" must be a string when type is \"connection\".' });\n }\n // transform is optional, but if present, must be a function.\n if (item.transform !== undefined && typeof item.transform !== 'function') {\n errors.push({ coordinates: connectionSpecificErrorPath, error: 'Optional property \"transform\" must be a function if present.' });\n }\n } else {\n // If type is not 'connection', but these properties exist and are malformed.\n // This primarily helps catch if a non-connection object has these fields incorrectly defined.\n if (item.targetNodeId !== undefined && typeof item.targetNodeId !== 'string') {\n errors.push({ coordinates: connectionSpecificErrorPath, error: 'Property \"targetNodeId\" is present but is not a string.' });\n }\n if (item.transform !== undefined && typeof item.transform !== 'function') {\n errors.push({ coordinates: connectionSpecificErrorPath, error: 'Property \"transform\" is present but is not a function.' });\n }\n }\n }\n }\n return errors;\n};\n\n/**\n * Event emitted specifically for connection transitions.\n */\nexport interface ConnectionEvent extends TransitionEvent {\n transitionType: 'connection';\n}\n"],"names":["DEFAULT_CONNECTION_OPTIONS","transform","output","context","createConnection","id","targetNodeId","options","connectionOptions","clean","createTransition","isConnection","item","isTransition","type","undefined","validateConnection","coordinates","errors","connectionBaseCoordinates","push","validateTransition","length","connectionSpecificErrorPath","error"],"mappings":";;;AA2CA;;;;;;;UAQaA,0BAAAA,GAAgD;AACzDC,IAAAA,SAAAA,EAAW,OAAOC,MAAAA,EAAQC,OAAAA,GAAAA;;;;QAItB,OAAO;AAACD,YAAAA,MAAAA;AAAiBC,YAAAA;AAAQ,SAAA;AACrC,IAAA;AACJ;AAEO,MAAMC,gBAAAA,GAAmB,CAC5BC,EAAAA,EACAC,YAAAA,EACAC,OAAAA,GAAAA;AAGA,IAAA,IAAIC,iBAAAA,GAA6C;AAAE,QAAA,GAAGR;AAA2B,KAAA;AAEjF,IAAA,IAAIO,OAAAA,EAAS;QACTC,iBAAAA,GAAoB;AAAE,YAAA,GAAGA,iBAAiB;AAAE,YAAA,GAAGC,MAAMF,OAAAA;AAAS,SAAA;AAClE,IAAA;IAEA,OAAO;QACH,GAAGG,gBAAAA,CAAiB,cAAcL,EAAAA,CAAG;AACrCC,QAAAA,YAAAA;AACAL,QAAAA,SAAAA,EAAWO,kBAAkBP;AACjC,KAAA;A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AA,CAAKN,YAAY,KAAKS,SAAAA,IAAa,OAAOH,IAAAA,CAAKN,YAAY,KAAK,QAAA,EAAU;AAC1EY,oBAAAA,MAAAA,CAAOE,IAAI,CAAC;wBAAEH,WAAAA,EAAaM,2BAAAA;wBAA6BC,KAAAA,EAAO;AAA0D,qBAAA,CAAA;AAC7H,gBAAA;gBACA,IAAIZ,IAAAA,CAAKX,SAAS,KAAKc,SAAAA,IAAa,OAAOH,IAAAA,CAAKX,SAAS,KAAK,UAAA,EAAY;AACtEiB,oBAAAA,MAAAA,CAAOE,IAAI,CAAC;wBAAEH,WAAAA,EAAaM,2BAAAA;wBAA6BC,KAAAA,EAAO;AAAyD,qBAAA,CAAA;AAC5H,gBAAA;AACJ,YAAA;AACJ,QAAA;AACJ,IAAA;IACA,OAAON,MAAAA;AACX;;;;"}
@@ -0,0 +1,20 @@
1
+ import { Termination } from '../xenocline';
2
+ import { Context } from '../context';
3
+ import { Output } from '../output';
4
+ import { Connection } from './connection';
5
+ import { Transition } from './transition';
6
+ export type DecideFunction<O extends Output = Output, C extends Context = Context> = (output: O, context: C) => Promise<Termination<O, C> | Connection<O, C>[]>;
7
+ /**
8
+ * Represents a decision point in the process flow, taking a phase's output and context
9
+ * to determine the next step.
10
+ */
11
+ export interface Decision<O extends Output = Output, C extends Context = Context> extends Transition {
12
+ type: 'decision';
13
+ decide: DecideFunction<O, C>;
14
+ }
15
+ export declare const createDecision: <O extends Output = Output, C extends Context = Context>(id: string, decide: DecideFunction<O, C>) => Readonly<Decision<O, C>>;
16
+ export declare const isDecision: <O extends Output = Output, C extends Context = Context>(item: any) => item is Decision<O, C>;
17
+ export declare const validateDecision: (item: any, coordinates?: string[]) => Array<{
18
+ coordinates: string[];
19
+ error: string;
20
+ }>;
@@ -0,0 +1,47 @@
1
+ import { createTransition, isTransition, validateTransition } from './transition.js';
2
+
3
+ const createDecision = (id, decide)=>{
4
+ return {
5
+ ...createTransition('decision', id),
6
+ decide
7
+ };
8
+ };
9
+ const isDecision = (item)=>{
10
+ return isTransition(item) && item.type === 'decision' && typeof item.decide === 'function';
11
+ };
12
+ const validateDecision = (item, coordinates)=>{
13
+ const errors = [];
14
+ const decisionBaseCoordinates = [
15
+ ...coordinates || [],
16
+ 'Decision'
17
+ ];
18
+ errors.push(...validateTransition(item, coordinates));
19
+ if (errors.length === 0) {
20
+ if (item && typeof item === 'object') {
21
+ const decisionSpecificErrorPath = [
22
+ ...decisionBaseCoordinates,
23
+ `Decision: ${item.id}`
24
+ ];
25
+ if (item.type === 'decision') {
26
+ if (typeof item.decide !== 'function') {
27
+ errors.push({
28
+ coordinates: decisionSpecificErrorPath,
29
+ error: 'Property "decide" must be a function when type is "decision".'
30
+ });
31
+ }
32
+ } else {
33
+ // If type is not 'decision', but 'decide' property exists and is malformed.
34
+ if (item.decide !== undefined && typeof item.decide !== 'function') {
35
+ errors.push({
36
+ coordinates: decisionSpecificErrorPath,
37
+ error: 'Property "decide" is present but is not a function.'
38
+ });
39
+ }
40
+ }
41
+ }
42
+ }
43
+ return errors;
44
+ };
45
+
46
+ export { createDecision, isDecision, validateDecision };
47
+ //# sourceMappingURL=decision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.js","sources":["../../src/transition/decision.ts"],"sourcesContent":["import { Termination } from '../xenocline';\nimport { Context } from '../context';\nimport { Output } from '../output';\nimport { Connection } from './connection';\nimport { createTransition, isTransition, Transition, validateTransition } from './transition';\n\nexport type DecideFunction<O extends Output = Output, C extends Context = Context> = (output: O, context: C) => Promise<Termination<O, C> | Connection<O, C>[]>;\n\n/**\n * Represents a decision point in the process flow, taking a phase's output and context\n * to determine the next step.\n */\nexport interface Decision<\n O extends Output = Output,\n C extends Context = Context,\n> extends Transition {\n type: 'decision';\n decide: DecideFunction<O, C>;\n}\n\n\nexport const createDecision = <O extends Output = Output, C extends Context = Context>(\n id: string,\n decide: DecideFunction<O, C>\n): Readonly<Decision<O, C>> => {\n\n return {\n ...createTransition('decision', id),\n decide,\n } as Decision<O, C>;\n};\n\nexport const isDecision = <O extends Output = Output, C extends Context = Context>(item: any): item is Decision<O, C> => {\n return isTransition(item) && item.type === 'decision' && typeof (item as Decision<O, C>).decide === 'function';\n};\n\nexport const validateDecision = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const decisionBaseCoordinates = [...(coordinates || []), 'Decision'];\n\n errors.push(...validateTransition(item, coordinates));\n\n if (errors.length === 0) {\n if (item && typeof item === 'object') {\n const decisionSpecificErrorPath = [...decisionBaseCoordinates, `Decision: ${item.id}`];\n\n if (item.type === 'decision') {\n if (typeof item.decide !== 'function') {\n errors.push({ coordinates: decisionSpecificErrorPath, error: 'Property \"decide\" must be a function when type is \"decision\".' });\n }\n } else {\n // If type is not 'decision', but 'decide' property exists and is malformed.\n if (item.decide !== undefined && typeof item.decide !== 'function') {\n errors.push({ coordinates: decisionSpecificErrorPath, error: 'Property \"decide\" is present but is not a function.' });\n }\n }\n }\n }\n return errors;\n};"],"names":["createDecision","id","decide","createTransition","isDecision","item","isTransition","type","validateDecision","coordinates","errors","decisionBaseCoordinates","push","validateTransition","length","decisionSpecificErrorPath","error","undefined"],"mappings":";;AAqBO,MAAMA,cAAAA,GAAiB,CAC1BC,EAAAA,EACAC,MAAAA,GAAAA;IAGA,OAAO;QACH,GAAGC,gBAAAA,CAAiB,YAAYF,EAAAA,CAAG;AACnCC,QAAAA;AACJ,KAAA;AACJ;AAEO,MAAME,aAAa,CAAyDC,IAAAA,GAAAA;IAC/E,OAAOC,YAAAA,CAAaD,IAAAA,CAAAA,IAASA,IAAAA,CAAKE,IAAI,KAAK,cAAc,OAAQF,IAAAA,CAAwBH,MAAM,KAAK,UAAA;AACxG;AAEO,MAAMM,gBAAAA,GAAmB,CAACH,IAAAA,EAAWI,WAAAA,GAAAA;AACxC,IAAA,MAAMC,SAA0D,EAAE;AAClE,IAAA,MAAMC,uBAAAA,GAA0B;AAAKF,QAAAA,GAAAA,WAAAA,IAAe,EAAE;AAAG,QAAA;AAAW,KAAA;IAEpEC,MAAAA,CAAOE,IAAI,CAAA,GAAIC,kBAAAA,CAAmBR,IAAAA,EAAMI,WAAAA,CAAAA,CAAAA;IAExC,IAAIC,MAAAA,CAAOI,MAAM,KAAK,CAAA,EAAG;QACrB,IAAIT,IAAAA,IAAQ,OAAOA,IAAAA,KAAS,QAAA,EAAU;AAClC,YAAA,MAAMU,yBAAAA,GAA4B;AAAIJ,gBAAAA,GAAAA,uBAAAA;AAAyB,gBAAA,CAAC,UAAU,EAAEN,IAAAA,CAAKJ,EAAE,CAAA;AAAG,aAAA;YAEtF,IAAII,IAAAA,CAAKE,IAAI,KAAK,UAAA,EAAY;AAC1B,gBAAA,IAAI,OAAOF,IAAAA,CAAKH,MAAM,KAAK,UAAA,EAAY;AACnCQ,oBAAAA,MAAAA,CAAOE,IAAI,CAAC;wBAAEH,WAAAA,EAAaM,yBAAAA;wBAA2BC,KAAAA,EAAO;AAAgE,qBAAA,CAAA;AACjI,gBAAA;YACJ,CAAA,MAAO;;gBAEH,IAAIX,IAAAA,CAAKH,MAAM,KAAKe,SAAAA,IAAa,OAAOZ,IAAAA,CAAKH,MAAM,KAAK,UAAA,EAAY;AAChEQ,oBAAAA,MAAAA,CAAOE,IAAI,CAAC;wBAAEH,WAAAA,EAAaM,yBAAAA;wBAA2BC,KAAAA,EAAO;AAAsD,qBAAA,CAAA;AACvH,gBAAA;AACJ,YAAA;AACJ,QAAA;AACJ,IAAA;IACA,OAAON,MAAAA;AACX;;;;"}
@@ -0,0 +1,13 @@
1
+ import { Output } from '../output';
2
+ import { Context } from '../context';
3
+ import { Termination } from './termination';
4
+ import { Connection } from './connection';
5
+ import { Decision } from './decision';
6
+ type NonEmptyArray<T> = [T, ...T[]];
7
+ export type Next<O extends Output = Output, C extends Context = Context> = Termination<O, C> | Readonly<NonEmptyArray<Connection<O, C>>> | Readonly<NonEmptyArray<Decision<O, C>>>;
8
+ export declare const isNext: <O extends Output = Output, C extends Context = Context>(item: any) => item is Next<O, C>;
9
+ export declare const validateNext: (item: any, coordinates?: string[]) => Array<{
10
+ coordinates: string[];
11
+ error: string;
12
+ }>;
13
+ export {};
@@ -0,0 +1,81 @@
1
+ import { validateTermination, isTermination } from './termination.js';
2
+ import { isConnection, validateConnection } from './connection.js';
3
+ import { isDecision, validateDecision } from './decision.js';
4
+
5
+ const isNext = (item)=>{
6
+ if (isTermination(item)) {
7
+ return true;
8
+ }
9
+ if (!Array.isArray(item)) {
10
+ return false;
11
+ }
12
+ if (item.length === 0) {
13
+ return true;
14
+ }
15
+ const firstElement = item[0];
16
+ if (isConnection(firstElement)) {
17
+ return item.every((el)=>isConnection(el));
18
+ }
19
+ if (isDecision(firstElement)) {
20
+ return item.every((el)=>isDecision(el));
21
+ }
22
+ return false;
23
+ };
24
+ const validateDecisionOrConnectionArray = (item, coordinates)=>{
25
+ const errors = [];
26
+ const currentCoordinates = [
27
+ ...coordinates || []
28
+ ];
29
+ if (item.length === 0) {
30
+ errors.push({
31
+ coordinates: [
32
+ ...currentCoordinates
33
+ ],
34
+ error: 'Next Array is empty.'
35
+ });
36
+ return errors;
37
+ }
38
+ const firstElement = item[0];
39
+ if (isConnection(firstElement)) {
40
+ for (const element of item){
41
+ errors.push(...validateConnection(element, currentCoordinates));
42
+ }
43
+ } else if (isDecision(firstElement)) {
44
+ for (const element of item){
45
+ errors.push(...validateDecision(element, currentCoordinates));
46
+ }
47
+ } else {
48
+ errors.push({
49
+ coordinates: [
50
+ ...currentCoordinates
51
+ ],
52
+ error: 'Next Array contains invalid element types. Expected all Connections or all Decisions.'
53
+ });
54
+ }
55
+ return errors;
56
+ };
57
+ const validateNext = (item, coordinates)=>{
58
+ const errors = [];
59
+ const currentCoordinates = [
60
+ ...coordinates || [],
61
+ 'Next'
62
+ ];
63
+ if (item === undefined || item === null) {
64
+ errors.push({
65
+ coordinates: [
66
+ ...currentCoordinates
67
+ ],
68
+ error: 'Next is undefined or null.'
69
+ });
70
+ return errors;
71
+ }
72
+ if (Array.isArray(item)) {
73
+ errors.push(...validateDecisionOrConnectionArray(item, currentCoordinates));
74
+ } else {
75
+ errors.push(...validateTermination(item, currentCoordinates));
76
+ }
77
+ return errors;
78
+ };
79
+
80
+ export { isNext, validateNext };
81
+ //# sourceMappingURL=next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"next.js","sources":["../../src/transition/next.ts"],"sourcesContent":["import { Output } from '../output';\nimport { Context } from '../context';\nimport { isTermination, Termination, validateTermination } from './termination';\nimport { Connection, isConnection, validateConnection } from './connection';\nimport { Decision, isDecision, validateDecision } from './decision';\n\ntype NonEmptyArray<T> = [T, ...T[]];\n\nexport type Next<O extends Output = Output, C extends Context = Context> = Termination<O, C> | Readonly<NonEmptyArray<Connection<O, C>>> | Readonly<NonEmptyArray<Decision<O, C>>>;\n\nexport const isNext = <O extends Output = Output, C extends Context = Context>(item: any): item is Next<O, C> => {\n if (isTermination<O, C>(item)) {\n return true;\n }\n\n if (!Array.isArray(item)) {\n return false;\n }\n\n if (item.length === 0) {\n return true;\n }\n\n const firstElement = item[0];\n if (isConnection<O, C>(firstElement)) {\n return item.every((el: any) => isConnection<O, C>(el));\n }\n if (isDecision<O, C>(firstElement)) {\n return item.every((el: any) => isDecision<O, C>(el));\n }\n\n return false;\n};\n\nconst validateDecisionOrConnectionArray = <O extends Output = Output, C extends Context = Context>(item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || [])];\n\n if (item.length === 0) {\n errors.push({ coordinates: [...currentCoordinates], error: 'Next Array is empty.' });\n return errors;\n }\n\n const firstElement = item[0];\n if (isConnection<O, C>(firstElement)) {\n for (const element of item) {\n errors.push(...validateConnection(element, currentCoordinates));\n }\n } else if (isDecision<O, C>(firstElement)) {\n for (const element of item) {\n errors.push(...validateDecision(element, currentCoordinates));\n }\n } else {\n errors.push({ coordinates: [...currentCoordinates], error: 'Next Array contains invalid element types. Expected all Connections or all Decisions.' });\n }\n\n return errors;\n}\n\nexport const validateNext = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n\n const currentCoordinates = [...(coordinates || []), 'Next'];\n\n if (item === undefined || item === null) {\n errors.push({ coordinates: [...currentCoordinates], error: 'Next is undefined or null.' });\n return errors;\n }\n\n if (Array.isArray(item)) {\n errors.push(...validateDecisionOrConnectionArray(item, currentCoordinates));\n } else {\n errors.push(...validateTermination(item, currentCoordinates));\n }\n\n return errors;\n}"],"names":["isNext","item","isTermination","Array","isArray","length","firstElement","isConnection","every","el","isDecision","validateDecisionOrConnectionArray","coordinates","errors","currentCoordinates","push","error","element","validateConnection","validateDecision","validateNext","undefined","validateTermination"],"mappings":";;;;AAUO,MAAMA,SAAS,CAAyDC,IAAAA,GAAAA;AAC3E,IAAA,IAAIC,cAAoBD,IAAAA,CAAAA,EAAO;QAC3B,OAAO,IAAA;AACX,IAAA;AAEA,IAAA,IAAI,CAACE,KAAAA,CAAMC,OAAO,CAACH,IAAAA,CAAAA,EAAO;QACtB,OAAO,KAAA;AACX,IAAA;IAEA,IAAIA,IAAAA,CAAKI,MAAM,KAAK,CAAA,EAAG;QACnB,OAAO,IAAA;AACX,IAAA;IAEA,MAAMC,YAAAA,GAAeL,IAAI,CAAC,CAAA,CAAE;AAC5B,IAAA,IAAIM,aAAmBD,YAAAA,CAAAA,EAAe;AAClC,QAAA,OAAOL,IAAAA,CAAKO,KAAK,CAAC,CAACC,KAAYF,YAAAA,CAAmBE,EAAAA,CAAAA,CAAAA;AACtD,IAAA;AACA,IAAA,IAAIC,WAAiBJ,YAAAA,CAAAA,EAAe;AAChC,QAAA,OAAOL,IAAAA,CAAKO,KAAK,CAAC,CAACC,KAAYC,UAAAA,CAAiBD,EAAAA,CAAAA,CAAAA;AACpD,IAAA;IAEA,OAAO,KAAA;AACX;AAEA,MAAME,iCAAAA,GAAoC,CAAyDV,IA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KAASoB,SAAAA,IAAapB,IAAAA,KAAS,IAAA,EAAM;AACrCY,QAAAA,MAAAA,CAAOE,IAAI,CAAC;YAAEH,WAAAA,EAAa;AAAIE,gBAAAA,GAAAA;AAAmB,aAAA;YAAEE,KAAAA,EAAO;AAA6B,SAAA,CAAA;QACxF,OAAOH,MAAAA;AACX,IAAA;IAEA,IAAIV,KAAAA,CAAMC,OAAO,CAACH,IAAAA,CAAAA,EAAO;QACrBY,MAAAA,CAAOE,IAAI,CAAA,GAAIJ,iCAAAA,CAAkCV,IAAAA,EAAMa,kBAAAA,CAAAA,CAAAA;IAC3D,CAAA,MAAO;QACHD,MAAAA,CAAOE,IAAI,CAAA,GAAIO,mBAAAA,CAAoBrB,IAAAA,EAAMa,kBAAAA,CAAAA,CAAAA;AAC7C,IAAA;IAEA,OAAOD,MAAAA;AACX;;;;"}
@@ -0,0 +1,17 @@
1
+ import { Context } from '../context';
2
+ import { Output } from '../output';
3
+ import { Transition } from './transition';
4
+ export type TerminateFunction<O extends Output = Output, C extends Context = Context> = (output: O, context: C) => Promise<Output>;
5
+ export interface Termination<O extends Output = Output, C extends Context = Context> extends Transition {
6
+ type: 'termination';
7
+ terminate: TerminateFunction<O, C>;
8
+ }
9
+ export interface TerminationOptions<O extends Output = Output, C extends Context = Context> {
10
+ terminate: TerminateFunction<O, C>;
11
+ }
12
+ export declare const createTermination: <O extends Output = Output, C extends Context = Context>(id: string, options?: Partial<TerminationOptions<O, C>>) => Readonly<Termination<O, C>>;
13
+ export declare const isTermination: <O extends Output = Output, C extends Context = Context>(item: any) => item is Termination<O, C>;
14
+ export declare const validateTermination: (item: any, coordinates?: string[]) => Array<{
15
+ coordinates: string[];
16
+ error: string;
17
+ }>;
@@ -0,0 +1,50 @@
1
+ import { clean } from '../util/general.js';
2
+ import { createTransition, isTransition, validateTransition } from './transition.js';
3
+
4
+ // NEW: Termination type extending Transition
5
+ const createTermination = (id, options)=>{
6
+ const defaultOptions = {
7
+ terminate: async (output)=>{
8
+ return output;
9
+ }
10
+ };
11
+ let terminationOptions = {
12
+ ...defaultOptions
13
+ };
14
+ if (options) {
15
+ terminationOptions = {
16
+ ...terminationOptions,
17
+ ...clean(options)
18
+ };
19
+ }
20
+ return {
21
+ ...createTransition('termination', id),
22
+ terminate: terminationOptions.terminate
23
+ };
24
+ };
25
+ const isTermination = (item)=>{
26
+ return isTransition(item) && item.type === 'termination' && (item.terminate === undefined || typeof item.terminate === 'function');
27
+ };
28
+ const validateTermination = (item, coordinates)=>{
29
+ const errors = [];
30
+ const currentCoordinates = [
31
+ ...coordinates || [],
32
+ 'Termination'
33
+ ];
34
+ errors.push(...validateTransition(item, currentCoordinates));
35
+ if (errors.length === 0) {
36
+ currentCoordinates.push(`Termination: ${item.id}`);
37
+ if (item.terminate !== undefined && typeof item.terminate !== 'function') {
38
+ errors.push({
39
+ coordinates: [
40
+ ...currentCoordinates
41
+ ],
42
+ error: 'terminate is not a function.'
43
+ });
44
+ }
45
+ }
46
+ return errors;
47
+ };
48
+
49
+ export { createTermination, isTermination, validateTermination };
50
+ //# sourceMappingURL=termination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"termination.js","sources":["../../src/transition/termination.ts"],"sourcesContent":["// NEW: Termination type extending Transition\n/**\n * Represents a termination point in the process flow, consuming a phase's output.\n */\n\nimport { clean } from '../util/general';\nimport { Context } from '../context';\nimport { Output } from '../output';\nimport { createTransition, isTransition, Transition, validateTransition } from './transition';\n\nexport type TerminateFunction<O extends Output = Output, C extends Context = Context> = (output: O, context: C) => Promise<Output>;\n\nexport interface Termination<\n O extends Output = Output,\n C extends Context = Context,\n> extends Transition {\n type: 'termination';\n // Currently, Termination is a marker type.\n // Future properties could include:\n // reason?: string; // To describe why termination occurred\n terminate: TerminateFunction<O, C>; // A function to execute upon termination\n}\n\nexport interface TerminationOptions<O extends Output = Output, C extends Context = Context> {\n terminate: TerminateFunction<O, C>;\n}\n\nexport const createTermination = <O extends Output = Output, C extends Context = Context>(\n id: string,\n options?: Partial<TerminationOptions<O, C>>\n): Readonly<Termination<O, C>> => {\n\n const defaultOptions: TerminationOptions<O, C> = {\n terminate: async (output) => {\n return output;\n }\n };\n\n let terminationOptions: TerminationOptions<O, C> = { ...defaultOptions };\n if (options) {\n terminationOptions = { ...terminationOptions, ...clean(options) };\n }\n\n return {\n ...createTransition('termination', id),\n terminate: terminationOptions.terminate,\n } as Termination<O, C>;\n};\n\nexport const isTermination = <O extends Output = Output, C extends Context = Context>(item: any): item is Termination<O, C> => {\n return isTransition(item) &&\n item.type === 'termination' &&\n ((item as Termination<O, C>).terminate === undefined || typeof (item as Termination<O, C>).terminate === 'function');\n};\n\nexport const validateTermination = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || []), 'Termination'];\n\n errors.push(...validateTransition(item, currentCoordinates));\n\n if (errors.length === 0) {\n currentCoordinates.push(`Termination: ${item.id}`);\n\n if (item.terminate !== undefined && typeof item.terminate !== 'function') {\n errors.push({ coordinates: [...currentCoordinates], error: 'terminate is not a function.' });\n }\n }\n\n return errors;\n};\n"],"names":["createTermination","id","options","defaultOptions","terminate","output","terminationOptions","clean","createTransition","isTermination","item","isTransition","type","undefined","validateTermination","coordinates","errors","currentCoordinates","push","validateTransition","length","error"],"mappings":";;;AAAA;AA2BO,MAAMA,iBAAAA,GAAoB,CAC7BC,EAAAA,EACAC,OAAAA,GAAAA;AAGA,IAAA,MAAMC,cAAAA,GAA2C;AAC7CC,QAAAA,SAAAA,EAAW,OAAOC,MAAAA,GAAAA;YACd,OAAOA,MAAAA;AACX,QAAA;AACJ,KAAA;AAEA,IAAA,IAAIC,kBAAAA,GAA+C;AAAE,QAAA,GAAGH;AAAe,KAAA;AACvE,IAAA,IAAID,OAAAA,EAAS;QACTI,kBAAAA,GAAqB;AAAE,YAAA,GAAGA,kBAAkB;AAAE,YAAA,GAAGC,MAAML,OAAAA;AAAS,SAAA;AACpE,I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