@maxdrellin/xenocline 0.0.3 → 0.0.5

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 (38) hide show
  1. package/dist/aggregator.js.map +1 -1
  2. package/dist/event/aggregator.js.map +1 -1
  3. package/dist/event/event.js.map +1 -1
  4. package/dist/event/handler.js.map +1 -1
  5. package/dist/event/node.js.map +1 -1
  6. package/dist/event/phase.js.map +1 -1
  7. package/dist/event/process.js.map +1 -1
  8. package/dist/event/transition.js.map +1 -1
  9. package/dist/execution/aggregator.js.map +1 -1
  10. package/dist/execution/event.js.map +1 -1
  11. package/dist/execution/next.js.map +1 -1
  12. package/dist/execution/node.js.map +1 -1
  13. package/dist/execution/phase.js.map +1 -1
  14. package/dist/execution/process.js.map +1 -1
  15. package/dist/input.js.map +1 -1
  16. package/dist/node/aggregatornode.js.map +1 -1
  17. package/dist/node/node.js.map +1 -1
  18. package/dist/node/phasenode.js.map +1 -1
  19. package/dist/phase.js.map +1 -1
  20. package/dist/process.js.map +1 -1
  21. package/dist/transition/beginning.js.map +1 -1
  22. package/dist/transition/connection.js.map +1 -1
  23. package/dist/transition/decision.js.map +1 -1
  24. package/dist/transition/next.js.map +1 -1
  25. package/dist/transition/termination.js.map +1 -1
  26. package/dist/transition/transition.js.map +1 -1
  27. package/dist/util/general.js.map +1 -1
  28. package/dist/utility/event/eventfilter.js.map +1 -1
  29. package/dist/utility/event/filteredhandler.js.map +1 -1
  30. package/dist/xenocline.cjs +1299 -0
  31. package/dist/xenocline.cjs.map +1 -0
  32. package/dist/xenocline.js +0 -0
  33. package/package.json +24 -26
  34. package/.doccident-setup.mjs +0 -36
  35. package/.kodrdriv/config.yaml +0 -10
  36. package/.kodrdriv/context/content.md +0 -26
  37. package/__mocks__/src/execution/event.js +0 -8
  38. package/eslint.config.mjs +0 -82
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xenocline.cjs","sources":["../src/util/general.ts","../src/aggregator.ts","../src/event/event.ts","../src/event/aggregator.ts","../src/transition/transition.ts","../src/transition/termination.ts","../src/transition/connection.ts","../src/transition/decision.ts","../src/transition/next.ts","../src/node/node.ts","../src/node/aggregatornode.ts","../src/transition/beginning.ts","../src/event/transition.ts","../src/event/handler.ts","../src/utility/event/eventfilter.ts","../src/utility/event/filteredhandler.ts","../src/execution/event.ts","../src/event/node.ts","../src/phase.ts","../src/node/phasenode.ts","../src/process.ts","../src/event/process.ts","../src/execution/aggregator.ts","../src/execution/next.ts","../src/event/phase.ts","../src/execution/phase.ts","../src/execution/node.ts","../src/input.ts","../src/execution/process.ts"],"sourcesContent":["export const clean = (obj: any) => {\n return Object.fromEntries(\n Object.entries(obj).filter(([_, v]) => v !== undefined)\n );\n}\n\n//Recursive implementation of jSON.stringify;\nexport const stringifyJSON = function (obj: any, visited: Set<any> = new Set()): string {\n const arrOfKeyVals: string[] = [];\n const arrVals: string[] = [];\n let objKeys: string[] = [];\n\n /*********CHECK FOR PRIMITIVE TYPES**********/\n if (typeof obj === 'number' || typeof obj === 'boolean' || obj === null)\n return '' + obj;\n else if (typeof obj === 'string')\n return '\"' + obj + '\"';\n\n /*********DETECT CIRCULAR REFERENCES**********/\n if (obj instanceof Object && visited.has(obj)) {\n return '\"(circular)\"';\n }\n\n /*********CHECK FOR ARRAY**********/\n else if (Array.isArray(obj)) {\n //check for empty array\n if (obj[0] === undefined)\n return '[]';\n else {\n // Add array to visited before processing its elements\n visited.add(obj);\n obj.forEach(function (el) {\n arrVals.push(stringifyJSON(el, visited));\n });\n return '[' + arrVals + ']';\n }\n }\n /*********CHECK FOR OBJECT**********/\n else if (obj instanceof Object) {\n // Add object to visited before processing its properties\n visited.add(obj);\n //get object keys\n objKeys = Object.keys(obj);\n //set key output;\n objKeys.forEach(function (key) {\n const keyOut = '\"' + key + '\":';\n const keyValOut = obj[key];\n //skip functions and undefined properties\n if (keyValOut instanceof Function || keyValOut === undefined)\n return; // Skip this entry entirely instead of pushing an empty string\n else if (typeof keyValOut === 'string')\n arrOfKeyVals.push(keyOut + '\"' + keyValOut + '\"');\n else if (typeof keyValOut === 'boolean' || typeof keyValOut === 'number' || keyValOut === null)\n arrOfKeyVals.push(keyOut + keyValOut);\n //check for nested objects, call recursively until no more objects\n else if (keyValOut instanceof Object) {\n arrOfKeyVals.push(keyOut + stringifyJSON(keyValOut, visited));\n }\n });\n return '{' + arrOfKeyVals + '}';\n }\n return '';\n};","import { clean } from \"./util/general\";\nimport { Context } from \"./context\";\nimport { Input } from \"./input\";\nimport { Output } from \"./output\";\n\n/**\n * Defines the possible outcomes of an aggregation operation.\n * It can either be 'Ready' with an output, or 'NotYetReady'.\n */\nexport type AggregationResult<U extends Output = Output> =\n | { status: 'Ready'; output: U }\n | { status: 'NotYetReady' };\n\nexport type AggregateMethod<U extends Output = Output, C extends Context = Context> = (\n input: Input,\n context: C\n) => Promise<Readonly<AggregationResult<U>>>;\n\n\nexport interface Aggregator<U extends Output = Output, C extends Context = Context> {\n name: string;\n aggregate: AggregateMethod<U, C>;\n}\n\nexport interface AggregatorOptions<U extends Output = Output, C extends Context = Context> {\n aggregate: AggregateMethod<U, C>;\n}\n\nexport const DEFAULT_AGGREGATOR_OPTIONS: AggregatorOptions<Output, Context> = {\n aggregate: async (input) => {\n return { status: 'Ready', output: input };\n }\n}\n\nexport const createAggregator = <U extends Output = Output, C extends Context = Context>(\n name: string,\n options?: Partial<AggregatorOptions<U, C>>\n): Readonly<Aggregator<U, C>> => {\n let aggregatorOptions: AggregatorOptions<U, C> = { ...DEFAULT_AGGREGATOR_OPTIONS } as unknown as AggregatorOptions<U, C>;\n if (options) {\n aggregatorOptions = { ...aggregatorOptions, ...clean(options) };\n }\n\n return { name, aggregate: aggregatorOptions.aggregate };\n}\n\nexport const isAggregator = <U extends Output = Output>(obj: any): obj is Aggregator<U> => {\n return obj !== undefined && obj !== null && typeof obj === 'object' && typeof obj.name === 'string' && typeof obj.aggregate === 'function';\n}\n\nexport const validateAggregator = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || []), 'Aggregator'];\n\n if (item === undefined || item === null) {\n errors.push({ coordinates: [...currentCoordinates], error: 'Aggregator is undefined or null.' });\n return errors;\n }\n\n if (item.name === undefined || typeof item.name !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Aggregator name is undefined or not a string.' });\n }\n\n currentCoordinates.push(`Aggregator: ${item.name}`);\n\n if (item.aggregate === undefined || typeof item.aggregate !== 'function') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Aggregator aggregate is undefined or not a function.' });\n }\n\n return errors;\n}","export type EventType = 'process' | 'phase' | 'transition' | 'execution' | 'aggregator';\n\nexport type EventStage = string;\n\n\nexport interface EventData {\n [key: string]: unknown;\n}\n\nexport interface Event<D extends EventData = EventData> {\n date: Date;\n type: string;\n stage: EventStage;\n sourceId: string;\n data?: D;\n}\n\nexport const createEvent = <D extends EventData>(type: string, sourceId: string, stage: EventStage, data?: D): Event<D> => {\n return {\n date: new Date(),\n type,\n stage,\n sourceId,\n data,\n };\n};\n\nexport const isEvent = (item: unknown): item is Event => {\n return item !== null && item !== undefined && typeof item === 'object' && 'date' in item && 'type' in item && 'sourceId' in item;\n};\n","import { createEvent, Event, EventData } from './event'; // Assuming a base Event interface exists\nimport { AggregationResult, Aggregator, Input, Output } from '../xenocline';\n\nexport type AggregatorEventStage = 'start' | 'aggregate' | 'ready' | 'defer';\n\nexport interface AggregatorEvent<A extends Aggregator = Aggregator, S extends AggregatorEventStage = AggregatorEventStage, D extends AggregatorEventData = AggregatorEventData> extends Event<D> {\n type: 'aggregator';\n stage: S;\n aggregator: A; // Optional payload for the aggregator event\n data?: D;\n}\n\nexport interface AggregatorEventData extends EventData {\n input?: Input;\n output?: Output;\n result?: Readonly<AggregationResult<Output>>;\n}\n\nexport function createAggregatorEvent<A extends Aggregator = Aggregator, S extends AggregatorEventStage = AggregatorEventStage, D extends AggregatorEventData = AggregatorEventData>(\n sourceId: string,\n stage: S,\n aggregator: A,\n data?: D\n): AggregatorEvent<A, S, D> {\n const event = createEvent('aggregator', sourceId, stage, data);\n return {\n ...event,\n aggregator,\n } as AggregatorEvent<A, S, D>;\n}\n\nexport function isAggregatorEvent<A extends Aggregator = Aggregator, S extends AggregatorEventStage = AggregatorEventStage, D extends AggregatorEventData = AggregatorEventData>(event: any): event is AggregatorEvent<A, S, D> {\n if (event === null || event === undefined || typeof event !== 'object') {\n return false;\n }\n\n const hasRequiredProperties = event.type === 'aggregator' &&\n 'stage' in event &&\n 'aggregator' in event &&\n typeof event.aggregator === 'object' &&\n event.aggregator !== null &&\n 'name' in event.aggregator;\n\n if (!hasRequiredProperties) {\n return false;\n }\n\n const aggregatorEvent = event as AggregatorEvent<A, S, D>;\n const isValidStage = ['start', 'aggregate', 'ready', 'defer'].includes(aggregatorEvent.stage);\n\n return isValidStage;\n}\n","export type TransitionType = 'connection' | 'decision' | 'termination' | 'beginning';\n\n/**\n * Base interface for transitions between nodes in a process.\n * It is primarily a marker interface that allows Connection,\n * Decision and Termination to share common generics.\n */\nexport interface Transition {\n id: string;\n type: TransitionType;\n}\n\nexport const createTransition = (type: TransitionType, id: string): Readonly<Transition> => {\n return {\n id,\n type,\n };\n};\n\nexport const isTransition = (item: any): item is Transition => {\n return item !== null && typeof item === 'object' && typeof item.id === 'string' && (item.type === 'connection' || item.type === 'decision' || item.type === 'termination' || item.type === 'beginning');\n};\n\nexport const validateTransition = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || []), 'Transition'];\n\n if (item === undefined || item === null) {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition is undefined or null.' });\n return errors;\n }\n\n if (typeof item !== 'object') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition is not an object.' });\n return errors;\n }\n\n if (item.id === undefined || typeof item.id !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition id is undefined or not a string.' });\n }\n\n if (item.type === undefined || typeof item.type !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition type is undefined or not a string.' });\n }\n\n if (item.type !== 'connection' && item.type !== 'decision' && item.type !== 'termination' && item.type !== 'beginning') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition type is not a valid type.' });\n }\n\n // We have an id, push to current coordinates\n currentCoordinates.push(`Transition: ${item.id}`);\n\n if (item.type === undefined || typeof item.type !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition type is undefined or not a string.' });\n }\n\n return errors;\n};","// 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","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\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 // 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 transform: TransformFunction<O, C>;\n}\n\nexport interface ConnectionOptions<O extends Output = Output, C extends Context = Context> {\n transform: TransformFunction<O, C>;\n}\n\nexport const DEFAULT_CONNECTION_OPTIONS: ConnectionOptions = {\n transform: async (output, context) => {\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","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};","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}","import { clean } from \"../util/general\";\nimport { Context } from \"../context\";\nimport { Output } from \"../output\";\nimport { isNext, Next, validateNext } from \"../transition/next\";\n\nexport interface Node<O extends Output = Output, C extends Context = Context> {\n id: string;\n type: 'aggregator' | 'phase';\n\n // The next step can be a direct termination, a list of connections, or a list of decisions,\n // all based on the output O of this aggregator node. Note that next can be undefined, when that happens \n // a termination transition is assumed.\n next?: Next<O, C>;\n}\n\nexport interface NodeOptions<O extends Output = Output, C extends Context = Context> {\n next?: Next<O, C>;\n}\n\nexport const DEFAULT_NODE_OPTIONS: NodeOptions<Output, Context> = {\n}\n\nexport const createNode = <O extends Output = Output, C extends Context = Context>(type: 'aggregator' | 'phase', id: string, options?: Partial<NodeOptions<O, C>>): Readonly<Node<O, C>> => {\n let nodeOptions: NodeOptions<O, C> = { ...DEFAULT_NODE_OPTIONS } as unknown as NodeOptions<O, C>;\n if (options) {\n nodeOptions = { ...nodeOptions, ...clean(options) };\n }\n\n return {\n id,\n type,\n next: nodeOptions.next,\n };\n};\n\nexport const isNode = (item: any): item is Node => {\n return item !== null && typeof item === 'object' && typeof item.id === 'string' && (item.type === 'aggregator' || item.type === 'phase') && (item.next === undefined || isNext(item.next));\n};\n\nexport const validateNode = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || []), 'Node'];\n\n\n if (item === undefined || item === null) {\n errors.push({ coordinates: [...currentCoordinates], error: 'Node is undefined or null.' });\n return errors;\n }\n\n if (typeof item !== 'object') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Node is not an object.' });\n return errors;\n }\n\n if (item.id === undefined || typeof item.id !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Node id is undefined or not a string.' });\n }\n\n if (item.type === undefined || typeof item.type !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Node type is undefined or not a string.' });\n }\n\n if (item.type !== 'aggregator' && item.type !== 'phase') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Node type is not a valid type.' });\n }\n\n currentCoordinates.push(`Node: ${item.id}`);\n\n if (item.next !== undefined) {\n errors.push(...validateNext(item.next, currentCoordinates));\n }\n\n return errors;\n}","import { Aggregator, validateAggregator } from '../aggregator';\nimport { Next } from '../transition/next';\nimport { Context } from '../context';\nimport { Output } from '../output';\nimport { createNode, isNode, Node, validateNode } from './node';\nimport { clean } from '../util/general';\n\n/**\n * Represents a node in the process that aggregates multiple inputs of type IA\n * into a single output of type O.\n *\n * @template O - The type of the output produced by this node's aggregate function. Must extend Output.\n * @template C - The type of the context object passed to the aggregate function. Must extend Context.\n */\nexport interface AggregatorNode<\n O extends Output = Output, // Output from the aggregate function\n C extends Context = Context, // Context object\n> extends Node<O, C> { // MODIFIED: Extends Node\n type: 'aggregator'; // Overrides Node.type\n // id: string; // Unique identifier for this aggregator node within the process - inherited from Node\n\n /**\n * The core aggregation logic for this node.\n * It takes an array of input items and a context, and returns a Promise resolving to the aggregated output.\n * @param input - An input item of type Input.\n * @param context - The context object.\n * @returns A Promise that resolves to the aggregated output of type O.\n */\n aggregator: Aggregator<O, C>;\n}\n\nexport interface AggregatorNodeOptions<O extends Output = Output, C extends Context = Context> {\n next?: Next<O, C>;\n}\n\nexport const DEFAULT_AGGREGATOR_NODE_OPTIONS: AggregatorNodeOptions<Output, Context> = {\n}\n\nexport const createAggregatorNode = <O extends Output = Output, C extends Context = Context>(\n id: string,\n aggregator: Aggregator<O, C>,\n options?: Partial<AggregatorNodeOptions<O, C>>\n): Readonly<AggregatorNode<O, C>> => {\n let aggregatorNodeOptions: AggregatorNodeOptions<O, C> = { ...DEFAULT_AGGREGATOR_NODE_OPTIONS } as unknown as AggregatorNodeOptions<O, C>;\n if (options) {\n aggregatorNodeOptions = { ...aggregatorNodeOptions, ...clean(options) };\n }\n\n return {\n ...createNode('aggregator', id, { next: aggregatorNodeOptions.next }),\n aggregator,\n } as AggregatorNode<O, C>;\n};\n\n\n/**\n * Type guard to check if an object is an AggregatorNode.\n *\n * @param obj - The object to check.\n * @returns True if the object is an AggregatorNode, false otherwise.\n */\nexport const isAggregatorNode = (obj: any): obj is AggregatorNode<any, any> => {\n if (!isNode(obj) || obj.type !== 'aggregator') {\n return false;\n }\n\n // At this point, obj is a Node with type 'aggregator'.\n // Now check for AggregatorNode specific properties.\n const potentialAggNode = obj as AggregatorNode<any, any>; // Cast to access specific props\n\n if (!(\n typeof potentialAggNode.aggregator === 'object' && potentialAggNode.aggregator !== null && typeof potentialAggNode.aggregator.aggregate === 'function'\n )) {\n return false;\n }\n\n return true; // Not Termination and not a recognized array type for 'next'\n};\n\nexport const validateAggregatorNode = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || []), 'AggregatorNode'];\n\n errors.push(...validateNode(item, currentCoordinates));\n\n currentCoordinates.push(`AggregatorNode: ${item.id}`);\n\n if (item.aggregator === undefined) {\n errors.push({ coordinates: [...currentCoordinates], error: 'aggregator is undefined.' });\n } else {\n errors.push(...validateAggregator(item.aggregator, currentCoordinates));\n }\n\n return errors;\n};","// 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(`Termination: ${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","import { Beginning, Connection, Context, Decision, Input, Output, Termination, Transition } from '../xenocline';\nimport { createEvent, EventData, type Event } from '../event/event';\n\nexport type TransitionEventStage = DecisionEventStage | ConnectionEventStage | TerminationEventStage | BeginningEventStage;\n\nexport type TransitionEventType = 'connection' | 'decision' | 'termination' | 'beginning';\n\n/**\n * Base event emitted for any transition.\n */\nexport interface TransitionEvent<T extends TransitionEventType, S extends TransitionEventStage, P extends Transition = Transition, D extends EventData = EventData> extends Event<D> {\n type: 'transition';\n transitionType: T;\n transition: P;\n stage: S;\n}\n\nexport const createTransitionEvent = <T extends TransitionEventType, S extends TransitionEventStage, P extends Transition, D extends EventData>(\n sourceId: string,\n transitionType: T,\n stage: S,\n transition: P,\n data?: D\n): Readonly<TransitionEvent<T, S, P, D>> => {\n const event = createEvent('transition', sourceId, stage, data);\n return {\n ...event,\n transitionType,\n transition,\n } as TransitionEvent<T, S, P, D>;\n};\n\n// Connection Types\nexport type ConnectionEventStage = 'start' | 'end' | 'transform';\n\nexport interface ConnectionEventData extends EventData {\n input?: Input;\n output?: Output;\n context?: Context;\n}\n\nexport type ConnectionEvent = TransitionEvent<'connection', ConnectionEventStage, Connection, ConnectionEventData>;\n\nexport const createConnectionEvent = (sourceId: string, stage: ConnectionEventStage, transition: Connection, data?: ConnectionEventData): Readonly<ConnectionEvent> => {\n return createTransitionEvent(sourceId, 'connection', stage, transition, data);\n};\n\nexport const isConnectionEvent = (item: any): item is ConnectionEvent => {\n return typeof item === 'object' && item !== null && item.type === 'transition' && item.transitionType === 'connection' && typeof item.transitionType === 'string';\n};\n\n// Decision Types\nexport type DecisionEventStage = 'start' | 'end' | 'decide';\n\nexport interface DecisionEventData extends EventData {\n output?: Output;\n result?: any;\n}\n\nexport type DecisionEvent = TransitionEvent<'decision', DecisionEventStage, Decision, DecisionEventData>;\n\nexport const createDecisionEvent = (sourceId: string, stage: DecisionEventStage, transition: Decision, data?: DecisionEventData): Readonly<DecisionEvent> =>\n createTransitionEvent<'decision', DecisionEventStage, Decision, DecisionEventData>(sourceId, 'decision', stage, transition, data);\n\nexport const isDecisionEvent = (item: any): item is DecisionEvent => {\n return typeof item === 'object' && item !== null && item.type === 'transition' && item.transitionType === 'decision' && typeof item.transitionType === 'string';\n};\n\n\n// Termination Types\nexport type TerminationEventStage = 'start' | 'terminate';\n\nexport interface TerminationEventData extends EventData {\n output?: Output;\n}\n\nexport type TerminationEvent = TransitionEvent<'termination', TerminationEventStage, Termination, TerminationEventData>;\n\nexport const createTerminationEvent = (sourceId: string, stage: TerminationEventStage, transition: Termination, data?: TerminationEventData): Readonly<TerminationEvent> => {\n return createTransitionEvent(sourceId, 'termination', stage, transition, data);\n};\n\nexport const isTerminationEvent = (item: any): item is TerminationEvent => {\n return typeof item === 'object' && item !== null && item.type === 'transition' && item.transitionType === 'termination' && typeof item.transitionType === 'string';\n};\n\n// Beginning Types\nexport type BeginningEventStage = 'start' | 'begin';\n\nexport interface BeginningEventData extends EventData {\n input?: Input;\n}\n\nexport type BeginningEvent = TransitionEvent<'beginning', BeginningEventStage, Beginning, BeginningEventData>;\n\nexport const createBeginningEvent = <I extends Input, C extends Context>(sourceId: string, stage: BeginningEventStage, transition: Beginning<I, C>, data?: BeginningEventData): Readonly<BeginningEvent> => {\n return createTransitionEvent(sourceId, 'beginning', stage, transition as Beginning<Input, Context>, data);\n};\n\nexport const isBeginningEvent = (item: any): item is BeginningEvent => {\n return typeof item === 'object' && item !== null && item.type === 'transition' && item.transitionType === 'beginning' && typeof item.transitionType === 'string';\n};\n","import { Context } from '../context';\nimport { Event } from './event';\n\nexport type HandleMethod<E extends Event = Event, C extends Context = Context> = (event: E, context: C) => Promise<void>;\n\nexport interface EventHandler<E extends Event = Event, C extends Context = Context> {\n handle: HandleMethod<E, C>;\n}\n\nexport const createEventHandler = <E extends Event = Event, C extends Context = Context>(handle: HandleMethod<E, C>): EventHandler<E, C> => {\n return {\n handle\n };\n};","import type { Event } from '../../event/event';\n\nexport interface EventFilter<E extends Event = Event> {\n type?: string[];\n stage?: string[];\n filter: (event: E) => boolean;\n}\n\nexport const createEventFilter = <E extends Event = Event>(\n type?: string[],\n stage?: string[]\n): EventFilter<E> => {\n const filterFn = (event: E): boolean => {\n const typeMatch = !type || type.includes(event.type);\n const stageMatch = !stage || stage.includes(event.stage);\n return typeMatch && stageMatch;\n };\n\n return {\n type,\n stage,\n filter: filterFn,\n };\n};\n","import type { Event } from '../../event/event';\nimport type { Context } from '../../context';\nimport { createEventHandler, EventHandler, HandleMethod } from '../../event/handler';\nimport type { EventFilter } from './eventfilter';\n\nexport interface FilteredHandler<E extends Event = Event, C extends Context = Context> extends EventHandler<E, C> {\n filter: EventFilter<E>;\n handler: EventHandler<E, C>;\n}\n\nexport const createFilteredHandler = <E extends Event = Event, C extends Context = Context>(\n filter: EventFilter<E>,\n options: { handler: EventHandler<E, C> } | { handle: HandleMethod<E, C> }\n): FilteredHandler<E, C> => {\n const handler: EventHandler<E, C> = 'handler' in options ? options.handler : createEventHandler<E, C>(options.handle);\n\n const handle: HandleMethod<E, C> = async (event, context) => {\n if (filter.filter(event)) {\n await handler.handle(event, context);\n }\n };\n\n return {\n filter,\n handler,\n handle,\n };\n};\n","import { Context } from '../context';\nimport { Event } from '../event'; // Assuming src/event.ts will export the base Event type\nimport { EventHandler } from '../event'; // Assuming src/event.ts will export EventHandler\n\n/**\n * Represents the state for managing event handlers.\n * Event handlers are expected to handle the base `Event` type and perform\n * specific event checking internally if needed (e.g., using type guards).\n */\nexport interface EventState<C extends Context> {\n /** Readonly array of registered event handlers. */\n readonly handlers: ReadonlyArray<EventHandler<Event, C>>;\n}\n\n/**\n * Creates an instance of EventState.\n * @param handlers An optional array of event handlers to initialize the state with.\n * These handlers should be of type `EventHandler<Event, C>`, meaning they\n * are prepared to receive any event and filter internally if necessary.\n * @returns A new, readonly EventState object.\n */\nexport const createEventState = <C extends Context>(\n handlers?: ReadonlyArray<EventHandler<Event, C>>\n): Readonly<EventState<C>> => {\n // Store a copy of the handlers array to ensure immutability of the provided array.\n return { handlers: handlers ? [...handlers] : [] };\n};\n\n/**\n * Dispatches an event to all registered handlers.\n * @param eventState The current event state containing the handlers.\n * @param event The event to dispatch. This can be any specific event type that extends `Event`.\n * @param context The current context to pass to the handlers.\n */\nexport const dispatchEvent = async <E extends Event, C extends Context>(\n eventState: Readonly<EventState<C>>,\n event: E,\n context: C\n): Promise<void> => {\n for (const handler of eventState.handlers) {\n // Each handler is EventHandler<Event, C>, so its `handle` method expects an `Event`.\n // Since `E` extends `Event`, passing `event` (of type `E`) is type-safe.\n await handler.handle(event, context);\n }\n};\n","import { createEvent, EventData, type Event } from '../event/event';\nimport { AggregatorNode, Input, Node, Output, PhaseNode } from '../xenocline';\n\nexport type NodeEventStage = AggregatorNodeEventStage | PhaseNodeEventStage;\n\n// For now, a generic 'node' type. This can be expanded if different types of nodes emit different events.\nexport type NodeEventType = 'aggregator' | 'phase';\n\n/**\n * Base event emitted for any node.\n */\nexport interface NodeEvent<T extends NodeEventType = NodeEventType, S extends NodeEventStage = NodeEventStage, N extends Node = Node, D extends EventData = EventData> extends Event<D> {\n type: 'node'; // Overrides the base Event type\n nodeType: T;\n node: N;\n stage: S;\n data?: D;\n}\n\nexport const createNodeEvent = <T extends NodeEventType, S extends NodeEventStage, N extends Node, D extends EventData>(sourceId: string, nodeType: T, stage: S, node: N, data?: D): Readonly<NodeEvent<T, S, N, D>> => {\n const event = createEvent('node', sourceId, stage, data);\n return {\n ...event,\n nodeType,\n node,\n } as NodeEvent<T, S, N, D>;\n};\n\nexport const isNodeEvent = (item: any): item is NodeEvent => {\n return item !== null && item !== undefined && typeof item === 'object' && item.type === 'node' && item.node !== null && item.node !== undefined && item.stage !== null && item.stage !== undefined;\n};\n\n// Aggregator Node Types\nexport type AggregatorNodeEventStage = 'start' | 'end';\n\nexport interface AggregatorEventData extends EventData {\n input?: Input;\n output?: Output;\n}\n\nexport interface AggregatorNodeEvent<A extends AggregatorNode = AggregatorNode> extends NodeEvent<'aggregator', AggregatorNodeEventStage, A, AggregatorEventData> {\n nodeType: 'aggregator';\n node: A;\n data?: AggregatorEventData;\n}\n\nexport const createAggregatorNodeEvent = <A extends AggregatorNode>(sourceId: string, stage: AggregatorNodeEventStage, aggregatorNode: A, data?: AggregatorEventData): AggregatorNodeEvent<A> => createNodeEvent(sourceId, 'aggregator', stage, aggregatorNode, data);\n\nexport const isAggregatorNodeEvent = (item: any): item is AggregatorNodeEvent => {\n return isNodeEvent(item) && item.nodeType === 'aggregator';\n};\n\n// Phase Node Types\nexport type PhaseNodeEventStage = 'start' | 'prepared' | 'processed' | 'end';\n\nexport interface PhaseEventData extends EventData {\n input?: Input;\n output?: Output;\n}\n\nexport interface PhaseNodeEvent<P extends PhaseNode = PhaseNode> extends NodeEvent<'phase', PhaseNodeEventStage, P, PhaseEventData> {\n nodeType: 'phase';\n node: P;\n data?: PhaseEventData;\n}\n\nexport const createPhaseNodeEvent = <P extends PhaseNode>(sourceId: string, stage: PhaseNodeEventStage, phaseNode: P, data?: PhaseEventData): PhaseNodeEvent<P> => createNodeEvent(sourceId, 'phase', stage, phaseNode, data);\n\nexport const isPhaseNodeEvent = (item: any): item is PhaseNodeEvent => {\n return isNodeEvent(item) && item.nodeType === 'phase';\n};\n\n","import { clean } from \"./util/general\";\nimport { Input } from \"./input\";\nimport { Output } from \"./output\";\n\nexport interface VerifyMethodResponse {\n verified: boolean;\n messages: string[];\n}\n\nexport type VerifyMethod<I extends Input = Input> = (input: I) => Promise<VerifyMethodResponse>;\n\nexport type ExecuteMethod<T extends Input = Input, U extends Output = Output> = (input: T) => Promise<U>;\n\nexport interface Phase<T extends Input = Input, U extends Output = Output> {\n name: string;\n verify?: VerifyMethod<T>;\n execute: (input: T) => Promise<U>;\n}\n\nexport interface PhaseOptions<T extends Input = Input, U extends Output = Output> {\n execute: ExecuteMethod<T, U>;\n verify?: VerifyMethod<T>;\n}\n\n\nexport const createPhase = <T extends Input = Input, U extends Output = Output>(\n name: string,\n options: Partial<PhaseOptions<T, U>>\n): Readonly<Phase<T, U>> => {\n\n const defaultOptions: PhaseOptions<T, U> = {\n execute: async (input: T) => {\n return input as unknown as U;\n }\n };\n\n const phaseOptions: PhaseOptions<T, U> = { ...defaultOptions, ...clean(options) };\n\n return {\n name,\n execute: phaseOptions.execute,\n verify: phaseOptions.verify,\n };\n}\n\nexport const isPhase = <T extends Input = Input, U extends Output = Output>(obj: any): obj is Phase<T, U> => {\n return obj !== undefined && obj !== null && typeof obj === 'object' && typeof obj.name === 'string' && typeof obj.execute === 'function';\n}\n\nexport const validatePhase = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || []), 'Phase'];\n\n if (item === undefined || item === null) {\n errors.push({ coordinates: [...currentCoordinates], error: 'Phase is undefined or null.' });\n return errors;\n }\n\n if (item.name === undefined || typeof item.name !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Phase name is undefined or not a string.' });\n }\n\n currentCoordinates.push(`Phase: ${item.name}`);\n\n if (item.execute === undefined || typeof item.execute !== 'function') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Phase execute is undefined or not a function.' });\n }\n\n return errors;\n}","import { Next } from '../transition/next';\nimport { Context } from '../context';\nimport { Input } from '../input';\nimport { Output } from '../output';\nimport { isPhase, Phase, validatePhase } from '../phase';\nimport { createNode, isNode, Node, validateNode } from './node';\nimport { clean } from '../util/general';\n\nexport type ProcessMethod<O extends Output = Output, C extends Context = Context> = (output: O, context: C) => Promise<[O, C]>;\nexport type PrepareMethod<I extends Input = Input, C extends Context = Context> = (input: I, context: C) => Promise<[I, C]>;\n\nexport interface PhaseNode<\n I extends Input = Input, // Input to this phase instance\n O extends Output = Output, // Output from this phase instance\n> extends Node {\n type: 'phase';\n phase: Phase<I, O>; // The actual phase instance\n\n // The prepare method is called before the phase is executed.\n // The input is the input for the phase, and the context is saved to the process context.\n prepare?: PrepareMethod;\n\n // The process method is called after the phase is executed, but before the next node is executed.\n // The output is the input for the next node, and the context is saved to the process context.\n process?: ProcessMethod;\n}\n\nexport interface PhaseNodeOptions<I extends Input = Input, O extends Output = Output, C extends Context = Context> {\n next?: Next<O, C>;\n prepare?: PrepareMethod<I, C>;\n process?: ProcessMethod<O, C>;\n}\n\nexport const DEFAULT_PHASE_NODE_OPTIONS: PhaseNodeOptions<Input, Output, Context> = {\n}\n\nexport const createPhaseNode = <I extends Input = Input, O extends Output = Output, C extends Context = Context>(\n id: string,\n phase: Phase<I, O>,\n options?: Partial<PhaseNodeOptions<I, O, C>>\n): Readonly<PhaseNode<I, O>> => {\n let phaseNodeOptions: PhaseNodeOptions<I, O, C> = { ...DEFAULT_PHASE_NODE_OPTIONS } as unknown as PhaseNodeOptions<I, O, C>;\n if (options) {\n phaseNodeOptions = { ...phaseNodeOptions, ...clean(options) };\n }\n\n return {\n ...createNode('phase', id, { next: phaseNodeOptions.next }),\n phase,\n prepare: phaseNodeOptions.prepare,\n process: phaseNodeOptions.process,\n } as PhaseNode<I, O>;\n};\n\nexport const isPhaseNode = (obj: any): obj is PhaseNode<any, any> => {\n if (!isNode(obj) || obj.type !== 'phase') {\n return false;\n }\n const potentialPhaseNode = obj as PhaseNode<any, any>;\n\n if (!(\n potentialPhaseNode.phase && typeof potentialPhaseNode.phase === 'object' && isPhase(potentialPhaseNode.phase)\n )) {\n return false;\n }\n\n return true;\n};\n\nexport const validatePhaseNode = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || []), 'PhaseNode'];\n\n errors.push(...validateNode(item, currentCoordinates));\n\n currentCoordinates.push(`PhaseNode: ${item.id}`);\n\n if (item.phase === undefined) {\n errors.push({ coordinates: [...currentCoordinates], error: 'phase is undefined.' });\n } else {\n errors.push(...validatePhase(item.phase, currentCoordinates));\n }\n\n return errors;\n};","//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}","import { createEvent, EventData, type Event } from './event'; // Assuming Event is in the same directory or adjust path\nimport type { Process } from '../process'; // Assuming Process is in '../process' or adjust path\nimport { Context } from 'vm';\n\nexport type ProcessEventStage = 'start' | 'end';\n\nexport interface ProcessEvent<\n Proc extends Process = Process,\n C extends Context = Context,\n> extends Event<ProcessEventData<C>> {\n type: 'process'; // Overrides the base Event type\n process: Proc; // The actual process instance or its identifier\n stage: ProcessEventStage;\n}\n\nexport interface ProcessEventData<C extends Context = Context> extends EventData {\n context?: C;\n}\n\nexport const createProcessEvent = <\n Proc extends Process,\n C extends Context = Context,\n>(sourceId: string, stage: ProcessEventStage, process: Proc, data?: ProcessEventData<C>): Readonly<ProcessEvent<Proc, C>> => {\n const event = createEvent('process', sourceId, stage, data);\n return {\n ...event,\n process,\n } as ProcessEvent<Proc, C>;\n};\n\nexport const isProcessEvent = (item: any): item is ProcessEvent => {\n return (\n item !== null &&\n item !== undefined &&\n typeof item === 'object' &&\n item.type === 'process' &&\n item.process !== null &&\n item.process !== undefined &&\n item.stage !== null &&\n item.stage !== undefined\n );\n};","import { Context } from 'vm';\nimport { createAggregatorEvent, EventState } from '../event';\nimport { Input } from '../input';\nimport { AggregatorNode } from '../node/aggregatornode';\nimport { Output } from '../output';\nimport { dispatchEvent } from './event';\n\nexport class Deferred<T> {\n promise: Promise<T>;\n resolve!: (value: T | PromiseLike<T>) => void;\n reject!: (reason?: any) => void;\n\n constructor() {\n this.promise = new Promise<T>((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\n\nexport interface AggregatorState {\n aggregatorDeferreds: Map<string, Deferred<Output>>;\n registerPendingAggregator: (nodeId: string) => Deferred<Output>;\n resolvePendingAggregator: (nodeId: string, output: Output) => void;\n getPendingAggregator: (nodeId: string) => Deferred<Output> | undefined;\n pendingAggregatorIds: () => string[];\n}\n\nexport function createAggregatorState(): AggregatorState {\n return {\n aggregatorDeferreds: new Map<string, Deferred<Output>>(),\n registerPendingAggregator(nodeId: string) {\n let deferred = this.aggregatorDeferreds.get(nodeId);\n if (!deferred) {\n deferred = new Deferred<Output>();\n this.aggregatorDeferreds.set(nodeId, deferred);\n }\n return deferred;\n },\n resolvePendingAggregator(nodeId: string, output: Output) {\n const deferred = this.aggregatorDeferreds.get(nodeId);\n if (deferred) {\n deferred.resolve(output);\n this.aggregatorDeferreds.delete(nodeId);\n }\n },\n getPendingAggregator(nodeId: string) {\n return this.aggregatorDeferreds.get(nodeId);\n },\n pendingAggregatorIds() {\n return Array.from(this.aggregatorDeferreds.keys());\n },\n };\n}\n\nexport async function executeAggregatorNode(\n nodeId: string,\n node: AggregatorNode,\n input: Input,\n state: AggregatorState & { context: Context, eventState: EventState<Context> }\n): Promise<Output> {\n\n dispatchEvent(\n state.eventState,\n createAggregatorEvent(nodeId, 'start', node.aggregator, { input }),\n state.context\n );\n\n let deferred = state.getPendingAggregator(nodeId);\n const aggregationResult = await node.aggregator.aggregate(input, state.context);\n\n dispatchEvent(state.eventState, createAggregatorEvent(nodeId, 'aggregate', node.aggregator, { input, result: aggregationResult }), state.context);\n\n if (aggregationResult.status === 'Ready') {\n const output = aggregationResult.output;\n\n dispatchEvent(state.eventState, createAggregatorEvent(nodeId, 'ready', node.aggregator, { output }), state.context);\n\n state.resolvePendingAggregator(nodeId, output);\n return output;\n }\n\n dispatchEvent(state.eventState, createAggregatorEvent(nodeId, 'defer', node.aggregator, { input, result: aggregationResult }), state.context);\n deferred = deferred ?? state.registerPendingAggregator(nodeId);\n return deferred.promise;\n}\n","import { executeNode } from './node';\nimport { ExecutionState } from './process';\nimport { Context } from '../context';\nimport { Input } from '../input';\nimport { Output } from '../output';\nimport { Connection, isConnection } from '../transition/connection';\nimport { Decision, isDecision } from '../transition/decision';\nimport { isTermination, Termination } from '../transition/termination';\nimport { dispatchEvent } from './event';\nimport { createConnectionEvent, createDecisionEvent, createTerminationEvent } from '../event';\n\n// Helper function to handle the next step in the process\nexport async function handleNextStep(\n nodeOutput: Output,\n nodeId: string,\n next: Termination | Connection[] | Decision[], // Can be Termination, Connection[], or Decision[] - will be narrowed down\n state: ExecutionState\n): Promise<void> {\n\n //console.log('[_HANDLE_NEXT_STEP_START]', { nodeId, nodeOutput, nextType: next && next.constructor ? next.constructor.name : typeof next, next });\n\n if (Array.isArray(next) && next.length > 0 && next.every(isDecision)) {\n const decisions = next as Decision<Output, Context>[];\n // console.log('[_HANDLE_NEXT_STEP_DECISIONS]', { nodeId, count: decisions.length, decisions });\n\n for (const decision of decisions) {\n // console.log('[_HANDLE_NEXT_STEP_DECISION_PROCESSING]', { nodeId, decisionId: decision.id, decision });\n await dispatchEvent(\n state.eventState,\n createDecisionEvent(nodeId, 'start', decision, { output: nodeOutput }),\n state.context\n );\n try {\n const decisionOutcome = await decision.decide(nodeOutput, state.context);\n await dispatchEvent(\n state.eventState,\n createDecisionEvent(nodeId, 'decide', decision, { output: nodeOutput, result: decisionOutcome }),\n state.context\n );\n // console.log('[_HANDLE_NEXT_STEP_DECISION_OUTCOME]', { nodeId, decisionId: decision.id, decisionOutcome });\n await handleNextStep(nodeOutput, decision.id, decisionOutcome, state); // outcome processed, decision.id is context for next step if it's an error source. The original nodeId is implicitly the source of this decision.\n await dispatchEvent(\n state.eventState,\n createDecisionEvent(nodeId, 'end', decision), // Fire 'end' event after successful processing\n state.context\n );\n } catch (decisionError: any) {\n // eslint-disable-next-line no-console\n console.error(`[_HANDLE_NEXT_STEP_DECISION_ERROR] Error in decision ${decision.id} from node ${nodeId}:`, { decisionError, nodeId, decisionId: decision.id });\n state.errors.push({ nodeId: decision.id, message: decisionError.message });\n // Note: 'end' event for this decision path is skipped due to error.\n }\n }\n } else if (Array.isArray(next) && next.length > 0 && next.every(isConnection)) {\n\n //console.log('[_HANDLE_NEXT_STEP_CONNECTIONS]', { nodeId, count: next.length, connections: next });\n const connections = next as Connection<Output, Context>[];\n const nextPhasePromises: Promise<Output>[] = [];\n for (const connection of connections) {\n\n let nextInput = nodeOutput as Input;\n let nextContext = state.context;\n\n await dispatchEvent(\n state.eventState,\n createConnectionEvent(nodeId, 'start', connection, { input: nextInput }),\n state.context\n );\n\n if (connection.transform) {\n\n //console.log('[_HANDLE_NEXT_STEP_CONNECTION_TRANSFORM_START]', { nodeId, targetNodeId: connection.targetNodeId });\n try {\n const context = state.context;\n [nextInput, nextContext] = await connection.transform(nodeOutput, context);\n await dispatchEvent(\n state.eventState,\n createConnectionEvent(nodeId, 'transform', connection, { input: nextInput, output: nodeOutput, context: nextContext }),\n state.context\n );\n state.context = nextContext;\n\n //console.log('[_HANDLE_NEXT_STEP_CONNECTION_TRANSFORM_SUCCESS]', { nodeId, targetNodeId: connection.targetNodeId, nextInput, nextContext });\n } catch (transformError: any) {\n // eslint-disable-next-line no-console\n console.error(`[_HANDLE_NEXT_STEP_CONNECTION_TRANSFORM_ERROR] Error in transform for connection from ${nodeId} to ${connection.targetNodeId}:`, { transformError, nodeId, targetNodeId: connection.targetNodeId });\n state.errors.push({ nodeId: connection.targetNodeId, message: transformError.message });\n // Note: 'end' event for this connection path is skipped due to error in transform\n continue;\n }\n }\n\n //console.log('[_HANDLE_NEXT_STEP_CONNECTION_EXECUTE_TARGET]', { nodeId, targetNodeId: connection.targetNodeId, nextInput });\n nextPhasePromises.push(executeNode(connection.targetNodeId, nextInput, state));\n await dispatchEvent(\n state.eventState,\n createConnectionEvent(nodeId, 'end', connection), // Fire 'end' event after initiating next step\n state.context\n );\n }\n // Optional: await Promise.all(nextPhasePromises); // Current design relies on executeProcess waiting on activeExecutions\n\n //console.log('[_HANDLE_NEXT_STEP_CONNECTIONS_PROMISES_PUSHED]', { nodeId, count: nextPhasePromises.length });\n } else if (isTermination(next)) {\n\n //console.log('[_HANDLE_NEXT_STEP_TERMINATION]', { nodeId, termination: next });\n const termination = next as Termination<Output, Context>;\n await dispatchEvent(\n state.eventState,\n createTerminationEvent(nodeId, 'start', termination, { output: nodeOutput }),\n state.context\n );\n const result: Output = nodeOutput;\n if (termination.terminate) {\n\n //console.log('[_HANDLE_NEXT_STEP_TERMINATION_CALLING_TERMINATE_FN]', { nodeId, terminationId: termination.id });\n termination.terminate(nodeOutput, state.context);\n await dispatchEvent(\n state.eventState,\n createTerminationEvent(nodeId, 'terminate', termination, { output: nodeOutput }),\n state.context\n );\n }\n\n state.results[termination.id] = result;\n } else if (Array.isArray(next) && next.length === 0) {\n // Empty array, potentially from a Decision that leads to no connections or an empty Connection array.\n // This could mean an implicit termination for this path or simply no further action from this branch.\n // If it's considered an end state for the path, store the result.\n\n const result: Output = nodeOutput;\n state.results[nodeId] = result; // Using nodeId as the key for this implicit termination\n } else {\n // If there is no next (e.g. next is undefined or null after a decision), or it's an unhandled type.\n // Consider this an end state and store the result with the nodeId\n\n //console.log('[_HANDLE_NEXT_STEP_NO_NEXT_OR_UNHANDLED]', { nodeId, next, nodeOutput });\n const result: Output = nodeOutput;\n state.results[nodeId] = result;\n }\n\n //console.log('[_HANDLE_NEXT_STEP_END]', { nodeId });\n}\n","import { Input, Output, Phase } from '../xenocline';\nimport { createEvent, Event, EventData } from './event';\n\nexport type PhaseEventStage = 'start' | 'execute';\n\nexport interface PhaseEvent<P extends Phase = Phase, S extends PhaseEventStage = PhaseEventStage, D extends EventData = EventData> extends Event<D> {\n type: 'phase';\n phase: P;\n stage: S;\n data?: D;\n}\n\nexport interface PhaseEventData extends EventData {\n input?: Input;\n output?: Output;\n}\n\nexport function createPhaseEvent<P extends Phase, S extends PhaseEventStage = PhaseEventStage, D extends EventData = EventData>(\n sourceId: string,\n stage: S,\n phase: P,\n data?: D\n): PhaseEvent<P, S, D> {\n const event = createEvent('phase', sourceId, stage, data);\n return {\n ...event,\n phase,\n } as PhaseEvent<P, S, D>;\n}\n\nexport function isPhaseEvent<P extends Phase>(event: any): event is PhaseEvent<P> {\n return (\n event !== null &&\n event !== undefined &&\n typeof event === 'object' &&\n event.type === 'phase' &&\n event.phase !== null &&\n event.phase !== undefined &&\n event.stage !== null &&\n event.stage !== undefined &&\n typeof event.stage === 'string' &&\n ['start', 'execute'].includes(event.stage)\n );\n\n}\n","import { createPhaseEvent } from '../event/phase';\nimport { Input } from '../input';\nimport { PhaseNode } from '../node/phasenode';\nimport { Output } from '../output';\nimport { dispatchEvent } from './event';\nimport { ExecutionState } from './process';\n\nexport async function executePhase(nodeId: string, node: PhaseNode, input: Input, state: ExecutionState): Promise<Output> {\n dispatchEvent(state.eventState, createPhaseEvent(nodeId, 'start', node.phase, { input }), state.context);\n\n if (node.phase.verify) {\n const verifyResponse = await node.phase.verify(input);\n if (!verifyResponse.verified) {\n throw new Error(verifyResponse.messages.join('\\n'));\n }\n }\n\n const output: Output = await node.phase.execute(input);\n\n dispatchEvent(state.eventState, createPhaseEvent(nodeId, 'execute', node.phase, { input, output }), state.context);\n return output;\n}","import { Context } from '../context';\nimport { createAggregatorNodeEvent, createPhaseNodeEvent } from '../event/node';\nimport { createDecisionEvent } from '../event/transition';\nimport { Input } from '../input';\nimport { AggregatorNode, isAggregatorNode } from '../node/aggregatornode';\nimport { isPhaseNode, PhaseNode } from '../node/phasenode';\nimport { Output } from '../output';\nimport { Connection } from '../transition/connection';\nimport { Decision, isDecision } from '../transition/decision';\nimport { Termination } from '../transition/termination';\nimport {\n executeAggregatorNode\n} from './aggregator';\nimport { dispatchEvent } from './event';\nimport { handleNextStep } from './next';\nimport { executePhase } from './phase';\nimport { ExecutionState } from './process';\n\nexport async function executeNode(\n nodeId: string,\n input: Input,\n state: ExecutionState\n): Promise<Output> {\n\n //console.log('[EXECUTE_NODE_RECURSIVE_START]', { nodeId, input, phaseResultsKeys: Object.keys(state.phaseResults), activeExecutionsKeys: Array.from(state.activeExecutions.keys()), aggregatorDeferredsKeys: Array.from(state.aggregatorDeferreds.keys()) });\n\n // 1. Check if result is already cached in phaseResults (final output, node fully completed)\n if (state.phaseResults[nodeId]) {\n\n //console.log('[EXECUTE_NODE_RECURSIVE_CACHE_HIT_PHASERESULTS]', { nodeId, result: state.phaseResults[nodeId] });\n return state.phaseResults[nodeId];\n }\n\n const node = state.process.phases[nodeId] as PhaseNode | AggregatorNode;\n if (!node) {\n const error = new Error(`Node with ID \"${nodeId}\" not found.`);\n\n //console.error('[EXECUTE_NODE_RECURSIVE_NODE_NOT_FOUND]', { nodeId, error });\n state.errors.push({ nodeId, message: error.message });\n throw error;\n }\n\n //console.log('[EXECUTE_NODE_RECURSIVE_NODE_FOUND]', { nodeId, nodeType: node.constructor.name, node });\n\n // 2. Handle active/pending executions\n // If it's an aggregator that has a deferred promise, it means it's pending.\n // We need to re-evaluate it with the current input. The IIFE below will handle this.\n if (state.activeExecutions.has(nodeId) && !isAggregatorNode(node)) {\n // For non-aggregators, if already active, return the promise.\n // Aggregators will fall through to the IIFE to allow input processing.\n // The IIFE itself handles returning a shared deferred promise if needed.\n\n //console.log('[EXECUTE_NODE_RECURSIVE_ACTIVE_EXECUTION_HIT_NON_AGGREGATOR]', { nodeId });\n return state.activeExecutions.get(nodeId)!;\n }\n // If it IS an aggregator and state.activeExecutions.has(nodeId),\n // it means its deferred.promise might be in activeExecutions from a previous input that made it pending.\n // The IIFE logic below will correctly retrieve this deferred (if it exists and is still relevant)\n // from state.aggregatorDeferreds.get(nodeId) and use its promise, or process the input.\n\n\n //console.log('[EXECUTE_NODE_RECURSIVE_CONTINUING_TO_EXECUTION_LOGIC]', { nodeId, isActive: state.activeExecutions.has(nodeId), isAggregator: isAggregatorNode(node), hasDeferred: state.aggregatorDeferreds.has(nodeId) });\n // If it's an aggregator and it's pending (has a deferred), we fall through to re-execute its logic within the IIFE.\n // If it's the first call to any node, we fall through.\n\n // 3. Mark as active and execute (or re-evaluate pending aggregator)\n const executionPromise = (async (): Promise<Output> => {\n\n //console.log('[EXECUTE_NODE_RECURSIVE_IIFE_START]', { nodeId, input });\n try {\n let output: Output;\n\n if (isAggregatorNode(node)) {\n\n dispatchEvent(\n state.eventState,\n createAggregatorNodeEvent(nodeId, 'start', node, { input }),\n state.context\n );\n\n output = await executeAggregatorNode(nodeId, node, input, state);\n } else if (isPhaseNode(node)) {\n\n dispatchEvent(state.eventState, createPhaseNodeEvent(nodeId, 'start', node, { input }), state.context);\n\n if (node.prepare) {\n const [preparedInput, preparedContext] = await node.prepare(input, state.context);\n input = preparedInput;\n state.context = preparedContext;\n }\n\n dispatchEvent(state.eventState, createPhaseNodeEvent(nodeId, 'prepared', node, { input }), state.context);\n\n\n output = await executePhase(nodeId, node, input, state);\n\n if (node.process) {\n const [processedOutput, processedContext] = await node.process(output, state.context);\n output = processedOutput;\n state.context = processedContext;\n }\n\n dispatchEvent(state.eventState, createPhaseNodeEvent(nodeId, 'processed', node, { input, output }), state.context);\n\n //console.log('[EXECUTE_NODE_RECURSIVE_PHASE_NODE_EXECUTE_END]', { nodeId, output });\n } else {\n const error = new Error(`Unknown or invalid node type for ID \"${nodeId}\". Expected PhaseNode or AggregatorNode.`);\n\n //console.error('[EXECUTE_NODE_RECURSIVE_UNKNOWN_NODE_TYPE]', { nodeId, node, error });\n throw error;\n }\n\n state.phaseResults[nodeId] = output; // Set final output once ready/executed\n\n //console.log('[EXECUTE_NODE_RECURSIVE_PHASE_RESULT_CACHED]', { nodeId, output });\n\n // 4. Handle next step\n if (node.next) {\n\n //console.log('[EXECUTE_NODE_RECURSIVE_HANDLING_NEXT_STEP]', { nodeId, nextType: node.next.constructor.name, next: node.next });\n if (Array.isArray(node.next) && node.next.length > 0 && node.next.every(isDecision)) {\n\n //console.log('[EXECUTE_NODE_RECURSIVE_DECISIONS_FOUND]', { nodeId, count: node.next.length, decisions: node.next });\n const decisions = node.next as Decision<Output, Context>[];\n const decisionExecutionPromises: Promise<void>[] = [];\n for (const decision of decisions) {\n\n dispatchEvent(state.eventState, createDecisionEvent(nodeId, 'start', decision, { output }), state.context);\n\n const decisionPromise = (async () => {\n\n //console.log('[EXECUTE_NODE_RECURSIVE_DECISION_EXECUTE_START]', { nodeId, decisionId: decision.id, output });\n try {\n const decisionOutcome = await decision.decide(output, state.context);\n dispatchEvent(state.eventState, createDecisionEvent(nodeId, 'decide', decision, { output, result: decisionOutcome }), state.context);\n\n //console.log('[EXECUTE_NODE_RECURSIVE_DECISION_OUTCOME]', { nodeId, decisionId: decision.id, decisionOutcome });\n await handleNextStep(output, decision.id, decisionOutcome, state);\n dispatchEvent(state.eventState, createDecisionEvent(nodeId, 'end', decision), state.context);\n } catch (decisionError: any) {\n // eslint-disable-next-line no-console\n console.error(`[_HANDLE_NEXT_STEP_DECISION_ERROR] Error in decision ${decision.id} for node ${nodeId}:`, { decisionError, nodeId, decisionId: decision.id });\n state.errors.push({ nodeId: decision.id, message: decisionError.message });\n }\n })();\n decisionExecutionPromises.push(decisionPromise);\n }\n\n //console.log('[EXECUTE_NODE_RECURSIVE_WAITING_FOR_DECISIONS]', { nodeId, count: decisionExecutionPromises.length });\n await Promise.all(decisionExecutionPromises);\n\n //console.log('[EXECUTE_NODE_RECURSIVE_DECISIONS_COMPLETE]', { nodeId });\n } else {\n\n //console.log('[EXECUTE_NODE_RECURSIVE_CALLING_HANDLE_NEXT_STEP_FOR_NON_DECISION]', { nodeId, next: node.next });\n await handleNextStep(output, nodeId, node.next as Termination<Output, Context> | Connection<Output, Context>[] | Decision<Output, Context>[], state);\n }\n } else {\n\n //console.log('[EXECUTE_NODE_RECURSIVE_NO_NEXT_NODE_IMPLICIT_TERMINATION]', { nodeId, output });\n const result: Output = output;\n state.results[nodeId] = result;\n }\n\n if (isPhaseNode(node)) {\n dispatchEvent(state.eventState, createPhaseNodeEvent(nodeId, 'end', node, { input, output }), state.context);\n } else {\n dispatchEvent(state.eventState, createAggregatorNodeEvent(nodeId, 'end', node, { input, output }), state.context);\n }\n\n //console.log('[EXECUTE_NODE_RECURSIVE_IIFE_RETURNING_OUTPUT]', { nodeId, output });\n return output;\n } catch (error: any) {\n // eslint-disable-next-line no-console\n console.error(`[EXECUTE_NODE_RECURSIVE_IIFE_ERROR] Error executing node ${nodeId}:`, { error, nodeId });\n state.errors.push({ nodeId, message: error.message });\n throw error;\n } finally {\n\n //console.log('[EXECUTE_NODE_RECURSIVE_IIFE_FINALLY]', { nodeId, hasAggregatorDeferred: state.aggregatorDeferreds.has(nodeId) });\n // If a node completed (not pending via deferred mechanism) or an error occurred.\n // An aggregator that is still pending (has a deferred) should keep its promise in activeExecutions.\n if (!state.aggregatorDeferreds.has(nodeId)) {\n\n //console.log('[EXECUTE_NODE_RECURSIVE_IIFE_FINALLY_DELETING_ACTIVE_EXECUTION]', { nodeId });\n state.activeExecutions.delete(nodeId);\n }\n }\n })();\n\n // Store the promise from the IIFE.\n // If it's an aggregator that went pending, executionPromise IS deferred.promise.\n // If it's an aggregator that became ready, executionPromise is a promise resolving to its output.\n // If it's a phase node, executionPromise is a promise resolving to its output.\n\n //console.log('[EXECUTE_NODE_RECURSIVE_SETTING_ACTIVE_EXECUTION]', { nodeId });\n state.activeExecutions.set(nodeId, executionPromise);\n\n //console.log('[EXECUTE_NODE_RECURSIVE_END_RETURNING_PROMISE]', { nodeId });\n return executionPromise;\n\n}\n\n","export interface Input {\n [key: string]: unknown;\n}\n\nexport const EMPTY_INPUT: Input = {};\n\nexport const isInput = (input: unknown): input is Input => {\n return typeof input === 'object' && input !== null && !Array.isArray(input);\n};\n\nexport const validateInput = (input: unknown): input is Input => {\n if (!isInput(input)) {\n throw new Error('Input must be an object');\n }\n return true;\n};\n","import { executeNode } from './node';\nimport { Context } from '../context';\nimport {\n AggregatorState,\n createAggregatorState\n} from './aggregator';\nimport { EMPTY_INPUT, Input } from '../input';\nimport { Output } from '../output';\nimport { Process, validateProcess } from '../process';\nimport { Beginning } from '../transition/beginning';\nimport { clean } from '../util/general';\nimport { Event, EventHandler, EventState, createBeginningEvent, createEventState, createProcessEvent } from '../event';\nimport { dispatchEvent } from './event';\n\nexport interface PhaseResults {\n [key: string]: Output;\n}\n\nexport interface ProcessResults {\n [key: string]: Output;\n}\n\ninterface ProcessExecutionError {\n message: string;\n details?: any;\n nodeId?: string;\n}\n\nexport interface ProcessExecutionOptions<I extends Input = Input, C extends Context = Context> {\n input: I;\n context: C;\n eventHandlers?: ReadonlyArray<EventHandler<Event, C>>;\n}\n\nexport const DEFAULT_PROCESS_EXECUTION_OPTIONS: ProcessExecutionOptions<Input, Context> = {\n input: EMPTY_INPUT,\n context: {} as Context,\n eventHandlers: [],\n}\n\nexport interface ExecutionState<C extends Context = Context> extends AggregatorState {\n process: Readonly<Process>;\n context: C;\n phaseResults: Record<string, Output>;\n results: Record<string, Output>;\n activeExecutions: Map<string, Promise<Output>>;\n errors: ProcessExecutionError[];\n readonly eventState: Readonly<EventState<C>>;\n}\n\nexport async function executeProcess<I extends Input = Input, O extends Output = Output, C extends Context = Context>(\n processInstance: Readonly<Process>,\n beginning: Beginning<I, C>,\n options?: Partial<ProcessExecutionOptions<I, C>>\n): Promise<[Record<string, O>, Record<string, O>, C]> {\n\n const processExecutionOptions: ProcessExecutionOptions<I, C> = {\n ...(DEFAULT_PROCESS_EXECUTION_OPTIONS as unknown as ProcessExecutionOptions<I, C>),\n ...clean(options || {}),\n };\n if (options && options.input) {\n processExecutionOptions.input = options.input;\n }\n if (options && options.eventHandlers) {\n processExecutionOptions.eventHandlers = options.eventHandlers;\n }\n\n const validationErrors = validateProcess(processInstance);\n if (validationErrors.length > 0) {\n const errorMessages = validationErrors.map(err => err.error).join('\\n');\n throw new Error(`Invalid process definition:\\n${errorMessages}`);\n }\n\n const eventState = createEventState<C>(processExecutionOptions.eventHandlers);\n\n const state: ExecutionState<C> = {\n process: processInstance,\n context: processExecutionOptions.context as C,\n results: {},\n phaseResults: {},\n activeExecutions: new Map<string, Promise<Output>>(),\n errors: [],\n ...createAggregatorState(),\n eventState: eventState,\n };\n\n dispatchEvent(\n state.eventState,\n createProcessEvent(processInstance.name, 'start', processInstance, { input: processExecutionOptions.input, context: state.context }),\n state.context\n );\n\n dispatchEvent(\n state.eventState,\n createBeginningEvent(beginning.id, 'start', beginning as Beginning<I, C>, { input: processExecutionOptions.input }),\n state.context\n );\n\n const initialInput = await beginning.begin(processExecutionOptions.input, state.context);\n dispatchEvent(\n state.eventState,\n createBeginningEvent(beginning.id, 'begin', beginning as Beginning<I, C>, { input: initialInput }),\n state.context\n );\n\n const initialNodeId = beginning.targetNodeId;\n\n if (!state.process.phases[initialNodeId]) {\n throw new Error(`Start phase ID \"${initialNodeId}\" not found in process phases.`);\n }\n\n try {\n await executeNode(initialNodeId, initialInput, state as unknown as ExecutionState<Context>);\n\n const allPromises = Array.from(state.activeExecutions.values());\n if (allPromises.length > 0) {\n await Promise.all(allPromises);\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n state.errors.push({ message: \"Critical error during process execution\", details: errorMessage, nodeId: initialNodeId });\n // eslint-disable-next-line no-console\n console.error(\"[EXECUTE_PROCESS_CRITICAL_ERROR]\", { processName: processInstance.name, error: errorMessage, collectedErrors: state.errors });\n }\n\n if (state.aggregatorDeferreds && state.aggregatorDeferreds.size > 0) {\n const pendingNodeIds = state.pendingAggregatorIds ? state.pendingAggregatorIds().join(', ') : 'unknown';\n // eslint-disable-next-line no-console\n console.warn(`[EXECUTE_PROCESS_PENDING_AGGREGATORS] Process execution may have pending aggregators: ${pendingNodeIds}.`, { processName: processInstance.name, pendingNodeIds });\n }\n\n dispatchEvent(\n state.eventState,\n createProcessEvent(processInstance.name, 'end', processInstance, { input: processExecutionOptions.input, context: state.context }),\n state.context\n );\n\n return [state.results as Record<string, O>, state.phaseResults as Record<string, O>, state.context];\n}\n\n\n"],"names":["clean","obj","Object","fromEntries","entries","filter","_","v","undefined","DEFAULT_AGGREGATOR_OPTIONS","aggregate","input","status","output","createAggregator","name","options","aggregatorOptions","isAggregator","createEvent","type","sourceId","stage","data","date","Date","createAggregatorEvent","aggregator","event","isAggregatorEvent","hasRequiredProperties","aggregatorEvent","isValidStage","includes","createTransition","id","isTransition","item","validateTransition","coordinates","errors","currentCoordinates","push","error","createTermination","defaultOptions","terminate","terminationOptions","isTermination","validateTermination","length","DEFAULT_CONNECTION_OPTIONS","transform","context","createConnection","targetNodeId","connectionOptions","isConnection","validateConnection","connectionBaseCoordinates","connectionSpecificErrorPath","createDecision","decide","isDecision","validateDecision","decisionBaseCoordinates","decisionSpecificErrorPath","isNext","Array","isArray","firstElement","every","el","validateDecisionOrConnectionArray","element","validateNext","DEFAULT_NODE_OPTIONS","createNode","nodeOptions","next","isNode","validateNode","DEFAULT_AGGREGATOR_NODE_OPTIONS","createAggregatorNode","aggregatorNodeOptions","isAggregatorNode","potentialAggNode","DEFAULT_BEGINNING_OPTIONS","begin","createBeginning","beginningOptions","isBeginning","createTransitionEvent","transitionType","transition","createConnectionEvent","isConnectionEvent","createDecisionEvent","isDecisionEvent","createTerminationEvent","isTerminationEvent","createBeginningEvent","isBeginningEvent","createEventHandler","handle","createEventFilter","filterFn","typeMatch","stageMatch","createFilteredHandler","handler","createEventState","handlers","dispatchEvent","eventState","createNodeEvent","nodeType","node","isNodeEvent","createAggregatorNodeEvent","aggregatorNode","isAggregatorNodeEvent","createPhaseNodeEvent","phaseNode","isPhaseNodeEvent","createPhase","execute","phaseOptions","verify","isPhase","DEFAULT_PHASE_NODE_OPTIONS","createPhaseNode","phase","phaseNodeOptions","prepare","process","isPhaseNode","potentialPhaseNode","createProcess","phases","processOptions","isProcess","validateProcess","processNameForPath","basePath","phaseId","prototype","hasOwnProperty","call","transitions","t","forEach","connection","index","createProcessEvent","isProcessEvent","Deferred","promise","resolve","reject","Promise","createAggregatorState","aggregatorDeferreds","Map","registerPendingAggregator","nodeId","deferred","get","set","resolvePendingAggregator","delete","getPendingAggregator","pendingAggregatorIds","from","keys","executeAggregatorNode","state","aggregationResult","result","handleNextStep","nodeOutput","decisions","decision","decisionOutcome","decisionError","console","decisionId","message","connections","nextPhasePromises","nextInput","nextContext","transformError","executeNode","termination","results","createPhaseEvent","executePhase","verifyResponse","verified","Error","messages","join","phaseResults","activeExecutions","has","executionPromise","preparedInput","preparedContext","processedOutput","processedContext","decisionExecutionPromises","decisionPromise","all","EMPTY_INPUT","DEFAULT_PROCESS_EXECUTION_OPTIONS","eventHandlers","executeProcess","processInstance","beginning","processExecutionOptions","validationErrors","errorMessages","map","err","initialInput","initialNodeId","allPromises","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AAA,CAAMd,mBAAmB,IAAIc,KAAAA,CAAMd,mBAAmB,CAACwE,IAAI,GAAG,CAAA,EAAG;QACjE,MAAMC,cAAAA,GAAiB3D,MAAMJ,oBAAoB,GAAGI,MAAMJ,oBAAoB,EAAA,CAAG8B,IAAI,CAAC,IAAA,CAAA,GAAQ,SAAA;;QAE9FjB,OAAAA,CAAQmD,IAAI,CAAC,CAAC,sFAAsF,EAAED,cAAAA,CAAe,CAAC,CAAC,EAAE;AAAEH,YAAAA,WAAAA,EAAad,gBAAgB3M,IAAI;AAAE4N,YAAAA;AAAe,SAAA,CAAA;AACjL,IAAA;IAEA1H,aAAAA,CACI+D,KAAAA,CAAM9D,UAAU,EAChBwC,kBAAAA,CAAmBgE,gBAAgB3M,IAAI,EAAE,OAAO2M,eAAAA,EAAiB;AAAE/M,QAAAA,KAAAA,EAAOiN,wBAAwBjN,KAAK;AAAE0C,QAAAA,OAAAA,EAAS2H,MAAM3H;AAAQ,KAAA,CAAA,EAChI2H,MAAM3H,OAAO,CAAA;IAGjB,OAAO;AAAC2H,QAAAA,KAAAA,CAAMmB,OAAO;AAAuBnB,QAAAA,KAAAA,CAAM2B,YAAY;AAAuB3B,QAAAA,KAAAA,CAAM3H;AAAQ,KAAA;AACvG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/xenocline.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@maxdrellin/xenocline",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Xenocline provides a streamlined, modular framework to manage and execute Processor Pipelines—sequences of computational steps or tasks executed systematically to process data or events. It allows developers to define, connect, and orchestrate individual processors into efficient workflows, supporting clear separation of concerns, scalability, and ease of maintenance.",
5
- "main": "dist/xenocline.js",
5
+ "main": "dist/xenocline.cjs",
6
+ "module": "dist/xenocline.js",
6
7
  "type": "module",
7
8
  "bin": {
8
- "Xenocline": "./dist/xenocline.js"
9
+ "xenocline": "./dist/xenocline.cjs"
9
10
  },
10
11
  "repository": {
11
12
  "type": "git",
@@ -13,8 +14,9 @@
13
14
  },
14
15
  "exports": {
15
16
  ".": {
17
+ "types": "./dist/xenocline.d.ts",
16
18
  "import": "./dist/xenocline.js",
17
- "types": "./dist/xenocline.d.ts"
19
+ "require": "./dist/xenocline.cjs"
18
20
  }
19
21
  },
20
22
  "keywords": [
@@ -28,37 +30,33 @@
28
30
  "@doccident/doccident": "^0.0.1"
29
31
  },
30
32
  "devDependencies": {
31
- "@babel/core": "^7.27.3",
33
+ "@babel/core": "^7.28.0",
32
34
  "@babel/plugin-transform-modules-commonjs": "^7.27.1",
33
- "@babel/plugin-transform-typescript": "^7.27.1",
35
+ "@babel/plugin-transform-typescript": "^7.28.0",
34
36
  "@babel/preset-typescript": "^7.27.1",
35
37
  "@eslint/eslintrc": "^3.3.1",
36
- "@eslint/js": "^9.27.0",
37
- "@jest/globals": "^29.7.0",
38
+ "@eslint/js": "^9.30.1",
39
+ "@jest/globals": "^30.0.4",
38
40
  "@rollup/plugin-replace": "^6.0.2",
39
- "@swc/core": "^1.11.29",
40
- "@types/jest": "^29.5.14",
41
- "@types/js-yaml": "^4.0.9",
42
- "@types/luxon": "^3.6.2",
43
- "@types/node": "^22.15.21",
44
- "@typescript-eslint/eslint-plugin": "^8.32.1",
45
- "@typescript-eslint/parser": "^8.32.1",
41
+ "@swc/core": "^1.12.11",
42
+ "@types/jest": "^30.0.0",
43
+ "@types/node": "^24.0.12",
44
+ "@typescript-eslint/eslint-plugin": "^8.36.0",
45
+ "@typescript-eslint/parser": "^8.36.0",
46
46
  "copyfiles": "^2.4.1",
47
- "eslint": "^9.27.0",
48
- "eslint-plugin-import": "^2.31.0",
49
- "globals": "^16.2.0",
50
- "jest": "^29.7.0",
51
- "rollup-plugin-preserve-shebang": "^1.0.1",
52
- "rollup-plugin-visualizer": "^5.14.0",
53
- "ts-jest": "^29.3.4",
47
+ "eslint": "^9.30.1",
48
+ "eslint-plugin-import": "^2.32.0",
49
+ "globals": "^16.3.0",
50
+ "jest": "^30.0.4",
51
+ "ts-jest": "^29.4.0",
54
52
  "typescript": "^5.8.3",
55
- "vite": "^6.3.5",
53
+ "vite": "^7.0.4",
56
54
  "vite-plugin-dts": "^4.5.4",
57
- "vite-plugin-node": "^5.0.1"
55
+ "vite-plugin-node": "^7.0.0"
58
56
  },
59
57
  "scripts": {
60
- "build": "tsc --noEmit && vite build && copyfiles -u 1 \"src/**/*.md\" dist && copyfiles -u 1 \"src/**/*.yaml\" dist",
61
- "start": "node dist/Xenocline.js",
58
+ "build": "vite build && copyfiles -u 1 \"src/**/*.md\" dist && copyfiles -u 1 \"src/**/*.yaml\" dist",
59
+ "start": "node dist/xenocline.cjs",
62
60
  "dev": "vite",
63
61
  "watch": "vite build --watch",
64
62
  "test": "pnpm run test:coverage && pnpm run test:readme",
@@ -1,36 +0,0 @@
1
- /* eslint-disable no-console */
2
- import { transform } from '@babel/core';
3
- // eslint-disable-next-line import/extensions
4
- import * as Xenocline from './dist/xenocline.js';
5
-
6
- export default {
7
- "globals": {
8
- "exports": {
9
- "Xenocline": Xenocline
10
- },
11
- "console": {
12
- "log": console.log,
13
- "error": console.error,
14
- "warn": console.warn,
15
- "info": console.info,
16
- "debug": console.debug
17
- }
18
- },
19
- "require": {
20
- '@maxdrellin/xenocline': Xenocline
21
- },
22
- transformCode: (code) => {
23
- // transform the code using @bable/preset-typescript
24
- const transformedCode = transform(code, {
25
- filename: 'test.ts',
26
- presets: ['@babel/preset-typescript'],
27
- plugins: [
28
- '@babel/plugin-transform-typescript',
29
- '@babel/plugin-transform-modules-commonjs'
30
- ],
31
- comments: true // Preserve comments
32
- })?.code;
33
-
34
- return transformedCode;
35
- }
36
- }
@@ -1,10 +0,0 @@
1
- verbose: false
2
- model: gpt-4o
3
- contextDirectories:
4
- - .gitcarve/context
5
- commit:
6
- cached: true
7
- sendit: true
8
- release:
9
- from: main
10
- to: HEAD
@@ -1,26 +0,0 @@
1
- Xenocline, as a library focused on creating a system to execute a **Processor Pipeline**, can be described as follows:
2
-
3
- **Xenocline** provides a streamlined, modular framework to manage and execute **Processor Pipelines**—sequences of computational steps or tasks executed systematically to process data or events. It allows developers to define, connect, and orchestrate individual processors into efficient workflows, supporting clear separation of concerns, scalability, and ease of maintenance.
4
-
5
- ### Core Concepts:
6
-
7
- 1. **Processor**:
8
- Individual computational unit responsible for a specific, well-defined operation (e.g., parsing data, validating inputs, transforming records).
9
-
10
- 2. **Pipeline**:
11
- A structured sequence or graph of processors, allowing data or events to flow through multiple processing stages seamlessly.
12
-
13
- 3. **Execution Engine**:
14
- Manages the lifecycle of processors within a pipeline, coordinating initialization, execution order, concurrency, error handling, and resource management.
15
-
16
- 4. **Pipeline Definition**:
17
- Clear, configurable declarations for how processors interact, ensuring pipelines are easy to define, understand, modify, and debug.
18
-
19
- ### Why Xenocline?
20
-
21
- * **Modularity**: Easy plug-and-play processors to extend or modify pipeline behavior.
22
- * **Robustness**: Handles complex execution scenarios with built-in error handling and resource management.
23
- * **Scalability**: Designed for high performance, enabling parallel execution and efficient handling of large-scale processing.
24
- * **Developer-friendly**: Clean, intuitive APIs for building and managing pipelines.
25
-
26
- This architecture makes **Xenocline** ideal for applications like data transformation, event handling, ETL (Extract, Transform, Load) processes, middleware orchestration, and automation workflows—anywhere a structured pipeline execution model is advantageous.
@@ -1,8 +0,0 @@
1
- // Manual mock for src/execution/event
2
- import { jest } from '@jest/globals';
3
-
4
- const dispatchEvent = jest.fn();
5
-
6
- module.exports = {
7
- dispatchEvent
8
- };
package/eslint.config.mjs DELETED
@@ -1,82 +0,0 @@
1
- import { defineConfig, globalIgnores } from "eslint/config";
2
- import typescriptEslint from "@typescript-eslint/eslint-plugin";
3
- import importPlugin from "eslint-plugin-import";
4
- import globals from "globals";
5
- import tsParser from "@typescript-eslint/parser";
6
- import path from "node:path";
7
- import { fileURLToPath } from "node:url";
8
- import js from "@eslint/js";
9
- import { FlatCompat } from "@eslint/eslintrc";
10
-
11
- const __filename = fileURLToPath(import.meta.url);
12
- const __dirname = path.dirname(__filename);
13
- const compat = new FlatCompat({
14
- baseDirectory: __dirname,
15
- recommendedConfig: js.configs.recommended,
16
- allConfig: js.configs.all
17
- });
18
-
19
- export default defineConfig([
20
- globalIgnores([
21
- "dist/**",
22
- "node_modules/**",
23
- "**/*.test.ts",
24
- ]),
25
- {
26
- extends: compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
27
-
28
- plugins: {
29
- "@typescript-eslint": typescriptEslint,
30
- "import": importPlugin,
31
- },
32
-
33
- languageOptions: {
34
- globals: {
35
- ...globals.node,
36
- },
37
-
38
- parser: tsParser,
39
- ecmaVersion: "latest",
40
- sourceType: "module",
41
- },
42
-
43
- rules: {
44
- "@typescript-eslint/no-explicit-any": "off",
45
- "@typescript-eslint/explicit-function-return-type": "off",
46
-
47
- "@typescript-eslint/no-unused-vars": ["warn", {
48
- argsIgnorePattern: "^_",
49
- }],
50
-
51
- indent: ["error", 4, {
52
- SwitchCase: 1,
53
- }],
54
-
55
- "import/extensions": ["error", "never", {
56
- ignorePackages: true,
57
- pattern: {
58
- "js": "never",
59
- "ts": "never",
60
- "d": "always"
61
- }
62
- }],
63
-
64
- "import/no-extraneous-dependencies": ["error", {
65
- devDependencies: true,
66
- optionalDependencies: false,
67
- peerDependencies: false,
68
- }],
69
-
70
- "no-console": ["error"],
71
-
72
- "no-restricted-imports": ["error", {
73
- paths: ["dayjs", "fs", "moment-timezone"],
74
- patterns: [
75
- {
76
- group: ["src/**"],
77
- message: "Use absolute imports instead of relative imports"
78
- }
79
- ]
80
- }]
81
- },
82
- }]);