@maxdrellin/xenocline 0.0.1 → 0.0.3

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.
@@ -0,0 +1,36 @@
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
+ }
@@ -26,7 +26,7 @@ export interface AggregatorNodeEvent<A extends AggregatorNode = AggregatorNode>
26
26
  }
27
27
  export declare const createAggregatorNodeEvent: <A extends AggregatorNode>(sourceId: string, stage: AggregatorNodeEventStage, aggregatorNode: A, data?: AggregatorEventData) => AggregatorNodeEvent<A>;
28
28
  export declare const isAggregatorNodeEvent: (item: any) => item is AggregatorNodeEvent;
29
- export type PhaseNodeEventStage = 'start' | 'end';
29
+ export type PhaseNodeEventStage = 'start' | 'prepared' | 'processed' | 'end';
30
30
  export interface PhaseEventData extends EventData {
31
31
  input?: Input;
32
32
  output?: Output;
@@ -1,12 +1,12 @@
1
- import { executeAggregatorNode } from './aggregator.js';
2
- import { handleNextStep } from './next.js';
1
+ import { createAggregatorNodeEvent, createPhaseNodeEvent } from '../event/node.js';
2
+ import { createDecisionEvent } from '../event/transition.js';
3
3
  import { isAggregatorNode } from '../node/aggregatornode.js';
4
4
  import { isPhaseNode } from '../node/phasenode.js';
5
5
  import { isDecision } from '../transition/decision.js';
6
- import { createDecisionEvent } from '../event/transition.js';
6
+ import { executeAggregatorNode } from './aggregator.js';
7
7
  import { dispatchEvent } from './event.js';
8
- import { createAggregatorNodeEvent, createPhaseNodeEvent } from '../event/node.js';
9
- import { createPhaseEvent } from '../event/phase.js';
8
+ import { handleNextStep } from './next.js';
9
+ import { executePhase } from './phase.js';
10
10
 
11
11
  async function executeNode(nodeId, input, state) {
12
12
  //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()) });
@@ -57,11 +57,21 @@ async function executeNode(nodeId, input, state) {
57
57
  dispatchEvent(state.eventState, createPhaseNodeEvent(nodeId, 'start', node, {
58
58
  input
59
59
  }), state.context);
60
- dispatchEvent(state.eventState, createPhaseEvent(nodeId, 'start', node.phase, {
60
+ if (node.prepare) {
61
+ const [preparedInput, preparedContext] = await node.prepare(input, state.context);
62
+ input = preparedInput;
63
+ state.context = preparedContext;
64
+ }
65
+ dispatchEvent(state.eventState, createPhaseNodeEvent(nodeId, 'prepared', node, {
61
66
  input
62
67
  }), state.context);
63
- output = await node.phase.execute(input);
64
- dispatchEvent(state.eventState, createPhaseEvent(nodeId, 'execute', node.phase, {
68
+ output = await executePhase(nodeId, node, input, state);
69
+ if (node.process) {
70
+ const [processedOutput, processedContext] = await node.process(output, state.context);
71
+ output = processedOutput;
72
+ state.context = processedContext;
73
+ }
74
+ dispatchEvent(state.eventState, createPhaseNodeEvent(nodeId, 'processed', node, {
65
75
  input,
66
76
  output
67
77
  }), state.context);
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"node.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,5 @@
1
+ import { Input } from '../input';
2
+ import { PhaseNode } from '../node/phasenode';
3
+ import { Output } from '../output';
4
+ import { ExecutionState } from './process';
5
+ export declare function executePhase(nodeId: string, node: PhaseNode, input: Input, state: ExecutionState): Promise<Output>;
@@ -0,0 +1,23 @@
1
+ import { createPhaseEvent } from '../event/phase.js';
2
+ import { dispatchEvent } from './event.js';
3
+
4
+ async function executePhase(nodeId, node, input, state) {
5
+ dispatchEvent(state.eventState, createPhaseEvent(nodeId, 'start', node.phase, {
6
+ input
7
+ }), state.context);
8
+ if (node.phase.verify) {
9
+ const verifyResponse = await node.phase.verify(input);
10
+ if (!verifyResponse.verified) {
11
+ throw new Error(verifyResponse.messages.join('\n'));
12
+ }
13
+ }
14
+ const output = await node.phase.execute(input);
15
+ dispatchEvent(state.eventState, createPhaseEvent(nodeId, 'execute', node.phase, {
16
+ input,
17
+ output
18
+ }), state.context);
19
+ return output;
20
+ }
21
+
22
+ export { executePhase };
23
+ //# sourceMappingURL=phase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phase.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,16 +4,22 @@ import { Input } from '../input';
4
4
  import { Output } from '../output';
5
5
  import { Phase } from '../phase';
6
6
  import { Node } from './node';
7
+ export type ProcessMethod<O extends Output = Output, C extends Context = Context> = (output: O, context: C) => Promise<[O, C]>;
8
+ export type PrepareMethod<I extends Input = Input, C extends Context = Context> = (input: I, context: C) => Promise<[I, C]>;
7
9
  export interface PhaseNode<I extends Input = Input, // Input to this phase instance
8
10
  O extends Output = Output> extends Node {
9
11
  type: 'phase';
10
12
  phase: Phase<I, O>;
13
+ prepare?: PrepareMethod;
14
+ process?: ProcessMethod;
11
15
  }
12
- export interface PhaseNodeOptions<O extends Output = Output, C extends Context = Context> {
16
+ export interface PhaseNodeOptions<I extends Input = Input, O extends Output = Output, C extends Context = Context> {
13
17
  next?: Next<O, C>;
18
+ prepare?: PrepareMethod<I, C>;
19
+ process?: ProcessMethod<O, C>;
14
20
  }
15
- export declare const DEFAULT_PHASE_NODE_OPTIONS: PhaseNodeOptions<Output, Context>;
16
- export declare const createPhaseNode: <I extends Input = Input, O extends Output = Output, C extends Context = Context>(id: string, phase: Phase<I, O>, options?: Partial<PhaseNodeOptions<O, C>>) => Readonly<PhaseNode<I, O>>;
21
+ export declare const DEFAULT_PHASE_NODE_OPTIONS: PhaseNodeOptions<Input, Output, Context>;
22
+ export declare const createPhaseNode: <I extends Input = Input, O extends Output = Output, C extends Context = Context>(id: string, phase: Phase<I, O>, options?: Partial<PhaseNodeOptions<I, O, C>>) => Readonly<PhaseNode<I, O>>;
17
23
  export declare const isPhaseNode: (obj: any) => obj is PhaseNode<any, any>;
18
24
  export declare const validatePhaseNode: (item: any, coordinates?: string[]) => Array<{
19
25
  coordinates: string[];
@@ -17,7 +17,9 @@ const createPhaseNode = (id, phase, options)=>{
17
17
  ...createNode('phase', id, {
18
18
  next: phaseNodeOptions.next
19
19
  }),
20
- phase
20
+ phase,
21
+ prepare: phaseNodeOptions.prepare,
22
+ process: phaseNodeOptions.process
21
23
  };
22
24
  };
23
25
  const isPhaseNode = (obj)=>{
@@ -1 +1 @@
1
- {"version":3,"file":"phasenode.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"phasenode.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/phase.d.ts CHANGED
@@ -1,12 +1,19 @@
1
1
  import { Input } from './input';
2
2
  import { Output } from './output';
3
+ export interface VerifyMethodResponse {
4
+ verified: boolean;
5
+ messages: string[];
6
+ }
7
+ export type VerifyMethod<I extends Input = Input> = (input: I) => Promise<VerifyMethodResponse>;
3
8
  export type ExecuteMethod<T extends Input = Input, U extends Output = Output> = (input: T) => Promise<U>;
4
9
  export interface Phase<T extends Input = Input, U extends Output = Output> {
5
10
  name: string;
11
+ verify?: VerifyMethod<T>;
6
12
  execute: (input: T) => Promise<U>;
7
13
  }
8
14
  export interface PhaseOptions<T extends Input = Input, U extends Output = Output> {
9
15
  execute: ExecuteMethod<T, U>;
16
+ verify?: VerifyMethod<T>;
10
17
  }
11
18
  export declare const createPhase: <T extends Input = Input, U extends Output = Output>(name: string, options: Partial<PhaseOptions<T, U>>) => Readonly<Phase<T, U>>;
12
19
  export declare const isPhase: <T extends Input = Input, U extends Output = Output>(obj: any) => obj is Phase<T, U>;
package/dist/phase.js CHANGED
@@ -12,7 +12,8 @@ const createPhase = (name, options)=>{
12
12
  };
13
13
  return {
14
14
  name,
15
- execute: phaseOptions.execute
15
+ execute: phaseOptions.execute,
16
+ verify: phaseOptions.verify
16
17
  };
17
18
  };
18
19
  const isPhase = (obj)=>{
package/dist/phase.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"phase.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"phase.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -58,10 +58,10 @@ export type { Input } from './input';
58
58
  export type { Node } from './node/node';
59
59
  export type { NodeEvent, NodeEventStage, AggregatorNodeEvent, PhaseNodeEvent } from './event/node';
60
60
  export type { Output } from './output';
61
- export type { Phase } from './phase';
61
+ export type { Phase, VerifyMethod, VerifyMethodResponse, ExecuteMethod } from './phase';
62
62
  export type { PhaseEvent } from './event/phase';
63
63
  export type { PhaseEventStage } from './event/phase';
64
- export type { PhaseNode } from './node/phasenode';
64
+ export type { PhaseNode, PrepareMethod, ProcessMethod } from './node/phasenode';
65
65
  export type { PhaseResults } from './execution/process';
66
66
  export type { Process } from './process';
67
67
  export type { ProcessEvent } from './event/process';
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@maxdrellin/xenocline",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
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.js",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "Xenocline": "./dist/xenocline.js"
@@ -13,8 +13,8 @@
13
13
  },
14
14
  "exports": {
15
15
  ".": {
16
- "import": "./dist/Xenocline.js",
17
- "types": "./dist/Xenocline.d.ts"
16
+ "import": "./dist/xenocline.js",
17
+ "types": "./dist/xenocline.d.ts"
18
18
  }
19
19
  },
20
20
  "keywords": [
@@ -28,7 +28,7 @@
28
28
  "@doccident/doccident": "^0.0.1"
29
29
  },
30
30
  "devDependencies": {
31
- "@babel/core": "^7.27.1",
31
+ "@babel/core": "^7.27.3",
32
32
  "@babel/plugin-transform-modules-commonjs": "^7.27.1",
33
33
  "@babel/plugin-transform-typescript": "^7.27.1",
34
34
  "@babel/preset-typescript": "^7.27.1",
@@ -36,17 +36,17 @@
36
36
  "@eslint/js": "^9.27.0",
37
37
  "@jest/globals": "^29.7.0",
38
38
  "@rollup/plugin-replace": "^6.0.2",
39
- "@swc/core": "^1.11.24",
39
+ "@swc/core": "^1.11.29",
40
40
  "@types/jest": "^29.5.14",
41
41
  "@types/js-yaml": "^4.0.9",
42
42
  "@types/luxon": "^3.6.2",
43
- "@types/node": "^22.15.19",
43
+ "@types/node": "^22.15.21",
44
44
  "@typescript-eslint/eslint-plugin": "^8.32.1",
45
45
  "@typescript-eslint/parser": "^8.32.1",
46
46
  "copyfiles": "^2.4.1",
47
47
  "eslint": "^9.27.0",
48
48
  "eslint-plugin-import": "^2.31.0",
49
- "globals": "^16.1.0",
49
+ "globals": "^16.2.0",
50
50
  "jest": "^29.7.0",
51
51
  "rollup-plugin-preserve-shebang": "^1.0.1",
52
52
  "rollup-plugin-visualizer": "^5.14.0",
@@ -61,7 +61,7 @@
61
61
  "start": "node dist/Xenocline.js",
62
62
  "dev": "vite",
63
63
  "watch": "vite build --watch",
64
- "test": "pnpm run test:coverage",
64
+ "test": "pnpm run test:coverage && pnpm run test:readme",
65
65
  "test:coverage": "jest --coverage",
66
66
  "test:readme": "doccident -c .doccident-setup.mjs README.md",
67
67
  "lint": "eslint . --ext .ts",