@jam-nodes/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/execution/context.d.ts +116 -0
- package/dist/execution/context.d.ts.map +1 -0
- package/dist/execution/context.js +259 -0
- package/dist/execution/context.js.map +1 -0
- package/dist/execution/index.d.ts +2 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +2 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +2 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/node-registry.d.ts +93 -0
- package/dist/registry/node-registry.d.ts.map +1 -0
- package/dist/registry/node-registry.js +153 -0
- package/dist/registry/node-registry.js.map +1 -0
- package/dist/types/config.d.ts +45 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/node.d.ts +109 -0
- package/dist/types/node.d.ts.map +1 -0
- package/dist/types/node.js +2 -0
- package/dist/types/node.js.map +1 -0
- package/dist/utils/define-node.d.ts +55 -0
- package/dist/utils/define-node.d.ts.map +1 -0
- package/dist/utils/define-node.js +42 -0
- package/dist/utils/define-node.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { NodeExecutionContext } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Manages workflow variables and provides utilities for:
|
|
4
|
+
* - Storing node outputs as variables
|
|
5
|
+
* - Retrieving variable values
|
|
6
|
+
* - Interpolating variables into strings
|
|
7
|
+
* - JSONPath evaluation for nested data access
|
|
8
|
+
*/
|
|
9
|
+
export declare class ExecutionContext {
|
|
10
|
+
private variables;
|
|
11
|
+
constructor(initialVariables?: Record<string, unknown>);
|
|
12
|
+
/**
|
|
13
|
+
* Set a variable value
|
|
14
|
+
*/
|
|
15
|
+
setVariable(name: string, value: unknown): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get a variable value
|
|
18
|
+
*/
|
|
19
|
+
getVariable(name: string): unknown;
|
|
20
|
+
/**
|
|
21
|
+
* Get all variables as a plain object
|
|
22
|
+
*/
|
|
23
|
+
getAllVariables(): Record<string, unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a variable exists
|
|
26
|
+
*/
|
|
27
|
+
hasVariable(name: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Delete a variable
|
|
30
|
+
*/
|
|
31
|
+
deleteVariable(name: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Clear all variables
|
|
34
|
+
*/
|
|
35
|
+
clearAll(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Merge multiple variables at once
|
|
38
|
+
*/
|
|
39
|
+
mergeVariables(vars: Record<string, unknown>): void;
|
|
40
|
+
/**
|
|
41
|
+
* Evaluate a JSONPath expression against workflow variables
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Get first contact's email
|
|
45
|
+
* ctx.evaluateJsonPath('$.contacts[0].email')
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // Get all email subjects
|
|
49
|
+
* ctx.evaluateJsonPath('$.emailDrafts[*].subject')
|
|
50
|
+
*/
|
|
51
|
+
evaluateJsonPath(path: string): unknown;
|
|
52
|
+
/**
|
|
53
|
+
* Interpolate variables into a string template
|
|
54
|
+
*
|
|
55
|
+
* Supports:
|
|
56
|
+
* - Simple variables: "Hello {{name}}"
|
|
57
|
+
* - Nested access: "Email: {{contact.email}}"
|
|
58
|
+
* - JSONPath: "First email: {{$.contacts[0].email}}"
|
|
59
|
+
* - Direct value replacement: "{{contacts}}" returns the actual array
|
|
60
|
+
*
|
|
61
|
+
* @returns The interpolated value. If the entire string is a single variable
|
|
62
|
+
* reference, returns the actual value. Otherwise returns an interpolated string.
|
|
63
|
+
*/
|
|
64
|
+
interpolate(template: string): unknown;
|
|
65
|
+
/**
|
|
66
|
+
* Interpolate variables in an object recursively
|
|
67
|
+
*
|
|
68
|
+
* Processes all string values in the object and interpolates variables.
|
|
69
|
+
* Useful for interpolating variables in node settings.
|
|
70
|
+
*/
|
|
71
|
+
interpolateObject<T>(obj: T): T;
|
|
72
|
+
/**
|
|
73
|
+
* Resolve nested path like "contact.email" or "data[0].name"
|
|
74
|
+
*/
|
|
75
|
+
resolveNestedPath(path: string): unknown;
|
|
76
|
+
/**
|
|
77
|
+
* Format a value for string interpolation
|
|
78
|
+
*/
|
|
79
|
+
private formatValue;
|
|
80
|
+
/**
|
|
81
|
+
* Store a node's output as variables
|
|
82
|
+
*
|
|
83
|
+
* The output is stored under the node's ID and also merged into root variables
|
|
84
|
+
* if it's a plain object.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Node "search_contacts" returns { contacts: [...] }
|
|
88
|
+
* // Variables become: { search_contacts: { contacts: [...] }, contacts: [...] }
|
|
89
|
+
*/
|
|
90
|
+
storeNodeOutput(nodeId: string, output: unknown): void;
|
|
91
|
+
/**
|
|
92
|
+
* Get a node's output by node ID
|
|
93
|
+
*/
|
|
94
|
+
getNodeOutput<T = unknown>(nodeId: string): T | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Create a NodeExecutionContext for use with executors
|
|
97
|
+
*/
|
|
98
|
+
toNodeContext(userId: string, workflowExecutionId: string, campaignId?: string): NodeExecutionContext;
|
|
99
|
+
/**
|
|
100
|
+
* Export variables as JSON
|
|
101
|
+
*/
|
|
102
|
+
toJSON(): Record<string, unknown>;
|
|
103
|
+
/**
|
|
104
|
+
* Create ExecutionContext from JSON
|
|
105
|
+
*/
|
|
106
|
+
static fromJSON(json: Record<string, unknown>): ExecutionContext;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Create execution context from workflow input
|
|
110
|
+
*/
|
|
111
|
+
export declare function createExecutionContext(input?: Record<string, unknown>): ExecutionContext;
|
|
112
|
+
/**
|
|
113
|
+
* Prepare node input by interpolating variables from execution context
|
|
114
|
+
*/
|
|
115
|
+
export declare function prepareNodeInput<T extends Record<string, unknown>>(nodeSettings: T, context: ExecutionContext): T;
|
|
116
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAA0B;gBAE/B,gBAAgB,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAI1D;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAI/C;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC;;OAEG;IACH,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI1C;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIlC;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIlC;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAOnD;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAevC;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAoCtC;;;;;OAKG;IACH,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC;IAuB/B;;OAEG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IA2BxC;;OAEG;IACH,OAAO,CAAC,WAAW;IAwBnB;;;;;;;;;OASG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAYtD;;OAEG;IACH,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAIzD;;OAEG;IACH,aAAa,CACX,MAAM,EAAE,MAAM,EACd,mBAAmB,EAAE,MAAM,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,oBAAoB;IAUvB;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIjC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB;CAGjE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,gBAAgB,CAElB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,YAAY,EAAE,CAAC,EACf,OAAO,EAAE,gBAAgB,GACxB,CAAC,CAEH"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { JSONPath } from 'jsonpath-plus';
|
|
2
|
+
/**
|
|
3
|
+
* Manages workflow variables and provides utilities for:
|
|
4
|
+
* - Storing node outputs as variables
|
|
5
|
+
* - Retrieving variable values
|
|
6
|
+
* - Interpolating variables into strings
|
|
7
|
+
* - JSONPath evaluation for nested data access
|
|
8
|
+
*/
|
|
9
|
+
export class ExecutionContext {
|
|
10
|
+
variables;
|
|
11
|
+
constructor(initialVariables = {}) {
|
|
12
|
+
this.variables = { ...initialVariables };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Set a variable value
|
|
16
|
+
*/
|
|
17
|
+
setVariable(name, value) {
|
|
18
|
+
this.variables[name] = value;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get a variable value
|
|
22
|
+
*/
|
|
23
|
+
getVariable(name) {
|
|
24
|
+
return this.variables[name];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get all variables as a plain object
|
|
28
|
+
*/
|
|
29
|
+
getAllVariables() {
|
|
30
|
+
return { ...this.variables };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if a variable exists
|
|
34
|
+
*/
|
|
35
|
+
hasVariable(name) {
|
|
36
|
+
return name in this.variables;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Delete a variable
|
|
40
|
+
*/
|
|
41
|
+
deleteVariable(name) {
|
|
42
|
+
delete this.variables[name];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Clear all variables
|
|
46
|
+
*/
|
|
47
|
+
clearAll() {
|
|
48
|
+
this.variables = {};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Merge multiple variables at once
|
|
52
|
+
*/
|
|
53
|
+
mergeVariables(vars) {
|
|
54
|
+
this.variables = {
|
|
55
|
+
...this.variables,
|
|
56
|
+
...vars,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Evaluate a JSONPath expression against workflow variables
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // Get first contact's email
|
|
64
|
+
* ctx.evaluateJsonPath('$.contacts[0].email')
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Get all email subjects
|
|
68
|
+
* ctx.evaluateJsonPath('$.emailDrafts[*].subject')
|
|
69
|
+
*/
|
|
70
|
+
evaluateJsonPath(path) {
|
|
71
|
+
try {
|
|
72
|
+
const result = JSONPath({ path, json: this.variables });
|
|
73
|
+
// If path returns single value, unwrap array
|
|
74
|
+
if (Array.isArray(result) && result.length === 1) {
|
|
75
|
+
return result[0];
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Interpolate variables into a string template
|
|
85
|
+
*
|
|
86
|
+
* Supports:
|
|
87
|
+
* - Simple variables: "Hello {{name}}"
|
|
88
|
+
* - Nested access: "Email: {{contact.email}}"
|
|
89
|
+
* - JSONPath: "First email: {{$.contacts[0].email}}"
|
|
90
|
+
* - Direct value replacement: "{{contacts}}" returns the actual array
|
|
91
|
+
*
|
|
92
|
+
* @returns The interpolated value. If the entire string is a single variable
|
|
93
|
+
* reference, returns the actual value. Otherwise returns an interpolated string.
|
|
94
|
+
*/
|
|
95
|
+
interpolate(template) {
|
|
96
|
+
if (typeof template !== 'string') {
|
|
97
|
+
return template;
|
|
98
|
+
}
|
|
99
|
+
// Check if the entire string is just a single variable reference
|
|
100
|
+
const singleVarMatch = template.match(/^\{\{([^}]+)\}\}$/);
|
|
101
|
+
if (singleVarMatch) {
|
|
102
|
+
const expression = singleVarMatch[1].trim();
|
|
103
|
+
// Return the actual value for single variable references
|
|
104
|
+
if (expression.startsWith('$')) {
|
|
105
|
+
return this.evaluateJsonPath(expression);
|
|
106
|
+
}
|
|
107
|
+
return this.resolveNestedPath(expression);
|
|
108
|
+
}
|
|
109
|
+
// Match {{variable}} or {{$.jsonpath.expression}}
|
|
110
|
+
const regex = /\{\{([^}]+)\}\}/g;
|
|
111
|
+
return template.replace(regex, (match, expression) => {
|
|
112
|
+
const trimmed = expression.trim();
|
|
113
|
+
// Check if it's a JSONPath expression
|
|
114
|
+
if (trimmed.startsWith('$')) {
|
|
115
|
+
const result = this.evaluateJsonPath(trimmed);
|
|
116
|
+
return this.formatValue(result);
|
|
117
|
+
}
|
|
118
|
+
// Handle dot notation (e.g., contact.email)
|
|
119
|
+
const value = this.resolveNestedPath(trimmed);
|
|
120
|
+
return this.formatValue(value);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Interpolate variables in an object recursively
|
|
125
|
+
*
|
|
126
|
+
* Processes all string values in the object and interpolates variables.
|
|
127
|
+
* Useful for interpolating variables in node settings.
|
|
128
|
+
*/
|
|
129
|
+
interpolateObject(obj) {
|
|
130
|
+
// Check for string FIRST
|
|
131
|
+
if (typeof obj === 'string') {
|
|
132
|
+
return this.interpolate(obj);
|
|
133
|
+
}
|
|
134
|
+
// Then check for non-objects
|
|
135
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
136
|
+
return obj;
|
|
137
|
+
}
|
|
138
|
+
if (Array.isArray(obj)) {
|
|
139
|
+
return obj.map((item) => this.interpolateObject(item));
|
|
140
|
+
}
|
|
141
|
+
const result = {};
|
|
142
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
143
|
+
result[key] = this.interpolateObject(value);
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Resolve nested path like "contact.email" or "data[0].name"
|
|
149
|
+
*/
|
|
150
|
+
resolveNestedPath(path) {
|
|
151
|
+
const parts = path.split('.');
|
|
152
|
+
let current = this.variables;
|
|
153
|
+
for (const part of parts) {
|
|
154
|
+
if (current === null || current === undefined) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
// Handle array access like "contacts[0]"
|
|
158
|
+
const arrayMatch = part.match(/^(\w+)\[(\d+)\]$/);
|
|
159
|
+
if (arrayMatch) {
|
|
160
|
+
const [, key, index] = arrayMatch;
|
|
161
|
+
current = current[key];
|
|
162
|
+
if (Array.isArray(current)) {
|
|
163
|
+
current = current[parseInt(index, 10)];
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
current = current[part];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return current;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Format a value for string interpolation
|
|
177
|
+
*/
|
|
178
|
+
formatValue(value) {
|
|
179
|
+
if (value === null || value === undefined) {
|
|
180
|
+
return '';
|
|
181
|
+
}
|
|
182
|
+
if (typeof value === 'string') {
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
186
|
+
return String(value);
|
|
187
|
+
}
|
|
188
|
+
if (Array.isArray(value)) {
|
|
189
|
+
return value.map((v) => this.formatValue(v)).join(', ');
|
|
190
|
+
}
|
|
191
|
+
if (typeof value === 'object') {
|
|
192
|
+
return JSON.stringify(value);
|
|
193
|
+
}
|
|
194
|
+
return String(value);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Store a node's output as variables
|
|
198
|
+
*
|
|
199
|
+
* The output is stored under the node's ID and also merged into root variables
|
|
200
|
+
* if it's a plain object.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* // Node "search_contacts" returns { contacts: [...] }
|
|
204
|
+
* // Variables become: { search_contacts: { contacts: [...] }, contacts: [...] }
|
|
205
|
+
*/
|
|
206
|
+
storeNodeOutput(nodeId, output) {
|
|
207
|
+
// Store under node ID
|
|
208
|
+
this.setVariable(nodeId, output);
|
|
209
|
+
// If output is a plain object, merge keys into root
|
|
210
|
+
if (output && typeof output === 'object' && !Array.isArray(output)) {
|
|
211
|
+
for (const [key, value] of Object.entries(output)) {
|
|
212
|
+
this.setVariable(key, value);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get a node's output by node ID
|
|
218
|
+
*/
|
|
219
|
+
getNodeOutput(nodeId) {
|
|
220
|
+
return this.getVariable(nodeId);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Create a NodeExecutionContext for use with executors
|
|
224
|
+
*/
|
|
225
|
+
toNodeContext(userId, workflowExecutionId, campaignId) {
|
|
226
|
+
return {
|
|
227
|
+
userId,
|
|
228
|
+
workflowExecutionId,
|
|
229
|
+
campaignId,
|
|
230
|
+
variables: this.getAllVariables(),
|
|
231
|
+
resolveNestedPath: this.resolveNestedPath.bind(this),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Export variables as JSON
|
|
236
|
+
*/
|
|
237
|
+
toJSON() {
|
|
238
|
+
return this.getAllVariables();
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Create ExecutionContext from JSON
|
|
242
|
+
*/
|
|
243
|
+
static fromJSON(json) {
|
|
244
|
+
return new ExecutionContext(json);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Create execution context from workflow input
|
|
249
|
+
*/
|
|
250
|
+
export function createExecutionContext(input) {
|
|
251
|
+
return new ExecutionContext(input || {});
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Prepare node input by interpolating variables from execution context
|
|
255
|
+
*/
|
|
256
|
+
export function prepareNodeInput(nodeSettings, context) {
|
|
257
|
+
return context.interpolateObject(nodeSettings);
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IACnB,SAAS,CAA0B;IAE3C,YAAY,mBAA4C,EAAE;QACxD,IAAI,CAAC,SAAS,GAAG,EAAE,GAAG,gBAAgB,E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C;YACnE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBAClD,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,aAAa,CAAc,MAAc;QACvC,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAkB,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,aAAa,CACX,MAAc,EACd,mBAA2B,EAC3B,UAAmB;QAEnB,OAAO;YACL,MAAM;YACN,mBAAmB;YACnB,UAAU;YACV,SAAS,EAAE,IAAI,CAAC,eAAe,EAAE;YACjC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;SACrD,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAA6B;QAC3C,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAA+B;IAE/B,OAAO,IAAI,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,YAAe,EACf,OAAyB;IAEzB,OAAO,OAAO,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { NodeExecutionContext, NodeExecutionResult, NodeExecutor, NodeApprovalRequest, NodeCapabilities, NodeCategory, NodeMetadata, NodeDefinition, NodeApprovalConfig, NodeNotificationConfig, BaseNodeConfig, } from './types/index.js';
|
|
2
|
+
export { ExecutionContext, createExecutionContext, prepareNodeInput, } from './execution/index.js';
|
|
3
|
+
export { NodeRegistry, createRegistry } from './registry/index.js';
|
|
4
|
+
export { defineNode } from './utils/index.js';
|
|
5
|
+
export type { DefineNodeConfig } from './utils/index.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Execution context
|
|
2
|
+
export { ExecutionContext, createExecutionContext, prepareNodeInput, } from './execution/index.js';
|
|
3
|
+
// Registry
|
|
4
|
+
export { NodeRegistry, createRegistry } from './registry/index.js';
|
|
5
|
+
// Utilities
|
|
6
|
+
export { defineNode } from './utils/index.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,oBAAoB;AACpB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B,WAAW;AACX,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEnE,YAAY;AACZ,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { NodeDefinition, NodeMetadata, NodeExecutor, NodeCategory } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Registry for workflow nodes.
|
|
4
|
+
* Manages node definitions and provides lookup utilities.
|
|
5
|
+
*
|
|
6
|
+
* @template TNodeType - String union of valid node types
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const registry = new NodeRegistry<'conditional' | 'end' | 'custom'>();
|
|
11
|
+
*
|
|
12
|
+
* registry.register(conditionalNode);
|
|
13
|
+
* registry.register(endNode);
|
|
14
|
+
*
|
|
15
|
+
* const executor = registry.getExecutor('conditional');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class NodeRegistry<TNodeType extends string = string> {
|
|
19
|
+
private definitions;
|
|
20
|
+
private metadata;
|
|
21
|
+
/**
|
|
22
|
+
* Register a node definition
|
|
23
|
+
* @throws Error if node type is already registered
|
|
24
|
+
*/
|
|
25
|
+
register<TInput, TOutput>(definition: NodeDefinition<TInput, TOutput>): this;
|
|
26
|
+
/**
|
|
27
|
+
* Register multiple node definitions at once
|
|
28
|
+
*/
|
|
29
|
+
registerAll(definitions: NodeDefinition[]): this;
|
|
30
|
+
/**
|
|
31
|
+
* Unregister a node type
|
|
32
|
+
*/
|
|
33
|
+
unregister(type: TNodeType): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Check if a node type is registered
|
|
36
|
+
*/
|
|
37
|
+
has(type: TNodeType): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Get node definition (includes executor)
|
|
40
|
+
*/
|
|
41
|
+
getDefinition(type: TNodeType): NodeDefinition | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Get node metadata (client-safe, no executor)
|
|
44
|
+
*/
|
|
45
|
+
getMetadata(type: TNodeType): NodeMetadata | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Get node executor
|
|
48
|
+
*/
|
|
49
|
+
getExecutor(type: TNodeType): NodeExecutor | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Get all registered node types
|
|
52
|
+
*/
|
|
53
|
+
getNodeTypes(): TNodeType[];
|
|
54
|
+
/**
|
|
55
|
+
* Get all node definitions
|
|
56
|
+
*/
|
|
57
|
+
getAllDefinitions(): NodeDefinition[];
|
|
58
|
+
/**
|
|
59
|
+
* Get all metadata (for client-side rendering)
|
|
60
|
+
*/
|
|
61
|
+
getAllMetadata(): NodeMetadata[];
|
|
62
|
+
/**
|
|
63
|
+
* Get definitions by category
|
|
64
|
+
*/
|
|
65
|
+
getByCategory(category: NodeCategory): NodeDefinition[];
|
|
66
|
+
/**
|
|
67
|
+
* Get metadata by category
|
|
68
|
+
*/
|
|
69
|
+
getMetadataByCategory(category: NodeCategory): NodeMetadata[];
|
|
70
|
+
/**
|
|
71
|
+
* Validate input against node's input schema
|
|
72
|
+
* @throws ZodError if validation fails
|
|
73
|
+
*/
|
|
74
|
+
validateInput<TInput>(type: TNodeType, input: unknown): TInput;
|
|
75
|
+
/**
|
|
76
|
+
* Validate output against node's output schema
|
|
77
|
+
* @throws ZodError if validation fails
|
|
78
|
+
*/
|
|
79
|
+
validateOutput<TOutput>(type: TNodeType, output: unknown): TOutput;
|
|
80
|
+
/**
|
|
81
|
+
* Get count of registered nodes
|
|
82
|
+
*/
|
|
83
|
+
get size(): number;
|
|
84
|
+
/**
|
|
85
|
+
* Extract client-safe metadata from definition
|
|
86
|
+
*/
|
|
87
|
+
private extractMetadata;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create a new node registry
|
|
91
|
+
*/
|
|
92
|
+
export declare function createRegistry<TNodeType extends string = string>(): NodeRegistry<TNodeType>;
|
|
93
|
+
//# sourceMappingURL=node-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-registry.d.ts","sourceRoot":"","sources":["../../src/registry/node-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM;IACzD,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,QAAQ,CAAsC;IAEtD;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,EACtB,UAAU,EAAE,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,GAC1C,IAAI;IAcP;;OAEG;IACH,WAAW,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,IAAI;IAOhD;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO;IAMpC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO;IAI7B;;OAEG;IACH,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,GAAG,SAAS;IAI1D;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS;IAItD;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS;IAItD;;OAEG;IACH,YAAY,IAAI,SAAS,EAAE;IAI3B;;OAEG;IACH,iBAAiB,IAAI,cAAc,EAAE;IAIrC;;OAEG;IACH,cAAc,IAAI,YAAY,EAAE;IAIhC;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,YAAY,GAAG,cAAc,EAAE;IAIvD;;OAEG;IACH,qBAAqB,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY,EAAE;IAI7D;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM;IAQ9D;;;OAGG;IACH,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;IAQlE;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,OAAO,CAAC,eAAe;CAUxB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,SAAS,SAAS,MAAM,GAAG,MAAM,KAC9B,YAAY,CAAC,SAAS,CAAC,CAE3B"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for workflow nodes.
|
|
3
|
+
* Manages node definitions and provides lookup utilities.
|
|
4
|
+
*
|
|
5
|
+
* @template TNodeType - String union of valid node types
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const registry = new NodeRegistry<'conditional' | 'end' | 'custom'>();
|
|
10
|
+
*
|
|
11
|
+
* registry.register(conditionalNode);
|
|
12
|
+
* registry.register(endNode);
|
|
13
|
+
*
|
|
14
|
+
* const executor = registry.getExecutor('conditional');
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export class NodeRegistry {
|
|
18
|
+
definitions = new Map();
|
|
19
|
+
metadata = new Map();
|
|
20
|
+
/**
|
|
21
|
+
* Register a node definition
|
|
22
|
+
* @throws Error if node type is already registered
|
|
23
|
+
*/
|
|
24
|
+
register(definition) {
|
|
25
|
+
const type = definition.type;
|
|
26
|
+
if (this.definitions.has(type)) {
|
|
27
|
+
throw new Error(`Node type "${type}" is already registered`);
|
|
28
|
+
}
|
|
29
|
+
// Cast to unknown first to satisfy TypeScript's strict variance checks
|
|
30
|
+
this.definitions.set(type, definition);
|
|
31
|
+
this.metadata.set(type, this.extractMetadata(definition));
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Register multiple node definitions at once
|
|
36
|
+
*/
|
|
37
|
+
registerAll(definitions) {
|
|
38
|
+
for (const definition of definitions) {
|
|
39
|
+
this.register(definition);
|
|
40
|
+
}
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Unregister a node type
|
|
45
|
+
*/
|
|
46
|
+
unregister(type) {
|
|
47
|
+
const hadDefinition = this.definitions.delete(type);
|
|
48
|
+
this.metadata.delete(type);
|
|
49
|
+
return hadDefinition;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check if a node type is registered
|
|
53
|
+
*/
|
|
54
|
+
has(type) {
|
|
55
|
+
return this.definitions.has(type);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get node definition (includes executor)
|
|
59
|
+
*/
|
|
60
|
+
getDefinition(type) {
|
|
61
|
+
return this.definitions.get(type);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get node metadata (client-safe, no executor)
|
|
65
|
+
*/
|
|
66
|
+
getMetadata(type) {
|
|
67
|
+
return this.metadata.get(type);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get node executor
|
|
71
|
+
*/
|
|
72
|
+
getExecutor(type) {
|
|
73
|
+
return this.definitions.get(type)?.executor;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get all registered node types
|
|
77
|
+
*/
|
|
78
|
+
getNodeTypes() {
|
|
79
|
+
return Array.from(this.definitions.keys());
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get all node definitions
|
|
83
|
+
*/
|
|
84
|
+
getAllDefinitions() {
|
|
85
|
+
return Array.from(this.definitions.values());
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get all metadata (for client-side rendering)
|
|
89
|
+
*/
|
|
90
|
+
getAllMetadata() {
|
|
91
|
+
return Array.from(this.metadata.values());
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get definitions by category
|
|
95
|
+
*/
|
|
96
|
+
getByCategory(category) {
|
|
97
|
+
return this.getAllDefinitions().filter((def) => def.category === category);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get metadata by category
|
|
101
|
+
*/
|
|
102
|
+
getMetadataByCategory(category) {
|
|
103
|
+
return this.getAllMetadata().filter((meta) => meta.category === category);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Validate input against node's input schema
|
|
107
|
+
* @throws ZodError if validation fails
|
|
108
|
+
*/
|
|
109
|
+
validateInput(type, input) {
|
|
110
|
+
const definition = this.definitions.get(type);
|
|
111
|
+
if (!definition) {
|
|
112
|
+
throw new Error(`Unknown node type: ${type}`);
|
|
113
|
+
}
|
|
114
|
+
return definition.inputSchema.parse(input);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Validate output against node's output schema
|
|
118
|
+
* @throws ZodError if validation fails
|
|
119
|
+
*/
|
|
120
|
+
validateOutput(type, output) {
|
|
121
|
+
const definition = this.definitions.get(type);
|
|
122
|
+
if (!definition) {
|
|
123
|
+
throw new Error(`Unknown node type: ${type}`);
|
|
124
|
+
}
|
|
125
|
+
return definition.outputSchema.parse(output);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get count of registered nodes
|
|
129
|
+
*/
|
|
130
|
+
get size() {
|
|
131
|
+
return this.definitions.size;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Extract client-safe metadata from definition
|
|
135
|
+
*/
|
|
136
|
+
extractMetadata(definition) {
|
|
137
|
+
return {
|
|
138
|
+
type: definition.type,
|
|
139
|
+
name: definition.name,
|
|
140
|
+
description: definition.description,
|
|
141
|
+
category: definition.category,
|
|
142
|
+
estimatedDuration: definition.estimatedDuration,
|
|
143
|
+
capabilities: definition.capabilities,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Create a new node registry
|
|
149
|
+
*/
|
|
150
|
+
export function createRegistry() {
|
|
151
|
+
return new NodeRegistry();
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=node-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-registry.js","sourceRoot":"","sources":["../../src/registry/node-registry.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,YAAY;IACf,WAAW,GAAG,IAAI,GAAG,EAA6B,CAAC;IACnD,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEtD;;;OAGG;IACH,QAAQ,CACN,UAA2C;QAE3C,MAAM,IAAI,GAAG,UAAU,CAAC,IAAiB,CAAC;QAE1C,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,yBAAyB,CAAC,CAAC;QAC/D,CAAC;QAED,uEAAuE;QACvE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,UAA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AED;;OAEG;IACK,eAAe,CAAC,UAA0B;QAChD,OAAO;YACL,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,WAAW,EAAE,UAAU,CAAC,WAAW;YACnC,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,iBAAiB,EAAE,UAAU,CAAC,iBAAiB;YAC/C,YAAY,EAAE,UAAU,CAAC,YAAY;SACtC,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAG5B,OAAO,IAAI,YAAY,EAAa,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approval configuration for nodes.
|
|
3
|
+
* Any node can optionally require approval before/after execution.
|
|
4
|
+
*/
|
|
5
|
+
export interface NodeApprovalConfig {
|
|
6
|
+
/** Whether approval is required for this node */
|
|
7
|
+
required: boolean;
|
|
8
|
+
/** Whether to pause workflow execution until approved (default: true) */
|
|
9
|
+
pauseWorkflow?: boolean;
|
|
10
|
+
/** Timeout in minutes before auto-rejection (default: 1440 = 24h) */
|
|
11
|
+
timeoutMinutes?: number;
|
|
12
|
+
/** Type of approval for UI display */
|
|
13
|
+
approvalType?: string;
|
|
14
|
+
/** Optional message to display to approver */
|
|
15
|
+
message?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Notification configuration for nodes.
|
|
19
|
+
* Any node can optionally send notifications on completion/error.
|
|
20
|
+
*/
|
|
21
|
+
export interface NodeNotificationConfig {
|
|
22
|
+
/** Enable notifications for this node */
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
/** Channels to send notifications to */
|
|
25
|
+
channels?: Array<'chat' | 'email' | 'slack' | 'webhook'>;
|
|
26
|
+
/** Notification message template */
|
|
27
|
+
message?: string;
|
|
28
|
+
/** Priority level */
|
|
29
|
+
priority?: 'low' | 'medium' | 'high';
|
|
30
|
+
/** Notify on successful completion */
|
|
31
|
+
notifyOnComplete?: boolean;
|
|
32
|
+
/** Notify on error */
|
|
33
|
+
notifyOnError?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Base config that all nodes can optionally include.
|
|
37
|
+
* Provides approval and notification capabilities to any node type.
|
|
38
|
+
*/
|
|
39
|
+
export interface BaseNodeConfig {
|
|
40
|
+
/** Approval configuration */
|
|
41
|
+
approval?: NodeApprovalConfig;
|
|
42
|
+
/** Notification configuration */
|
|
43
|
+
notification?: NodeNotificationConfig;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,yEAAyE;IACzE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IACzD,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrC,sCAAsC;IACtC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,sBAAsB;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,iCAAiC;IACjC,YAAY,CAAC,EAAE,sBAAsB,CAAC;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { NodeExecutionContext, NodeExecutionResult, NodeExecutor, NodeApprovalRequest, NodeCapabilities, NodeCategory, NodeMetadata, NodeDefinition, } from './node.js';
|
|
2
|
+
export type { NodeApprovalConfig, NodeNotificationConfig, BaseNodeConfig, } from './config.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,WAAW,CAAC;AAEnB,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,GACf,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Base execution context passed to all node executors.
|
|
4
|
+
* Provides access to workflow state and utilities.
|
|
5
|
+
*/
|
|
6
|
+
export interface NodeExecutionContext {
|
|
7
|
+
/** User ID executing the workflow */
|
|
8
|
+
userId: string;
|
|
9
|
+
/** Optional campaign/project context */
|
|
10
|
+
campaignId?: string;
|
|
11
|
+
/** Unique identifier for this workflow execution */
|
|
12
|
+
workflowExecutionId: string;
|
|
13
|
+
/** Variables from previous node outputs */
|
|
14
|
+
variables: Record<string, unknown>;
|
|
15
|
+
/** Resolve nested path like "contact.email" or "data[0].name" */
|
|
16
|
+
resolveNestedPath: (path: string) => unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Approval request metadata returned by nodes that need user approval.
|
|
20
|
+
*/
|
|
21
|
+
export interface NodeApprovalRequest {
|
|
22
|
+
/** IDs of resources needing approval */
|
|
23
|
+
resourceIds: string[];
|
|
24
|
+
/** Type of resource for UI display */
|
|
25
|
+
resourceType: string;
|
|
26
|
+
/** Optional message to display to approver */
|
|
27
|
+
message?: string;
|
|
28
|
+
/** Component to use for displaying approval details */
|
|
29
|
+
detailComponent?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Result returned by node executors.
|
|
33
|
+
* @template TOutput - Type of the output data
|
|
34
|
+
*/
|
|
35
|
+
export interface NodeExecutionResult<TOutput = unknown> {
|
|
36
|
+
/** Whether execution succeeded */
|
|
37
|
+
success: boolean;
|
|
38
|
+
/** Output data on success */
|
|
39
|
+
output?: TOutput;
|
|
40
|
+
/** Error message on failure */
|
|
41
|
+
error?: string;
|
|
42
|
+
/** Next node ID for conditional branching */
|
|
43
|
+
nextNodeId?: string;
|
|
44
|
+
/** Approval request if node needs user approval */
|
|
45
|
+
needsApproval?: NodeApprovalRequest;
|
|
46
|
+
/** Notification to send to user */
|
|
47
|
+
notification?: {
|
|
48
|
+
title: string;
|
|
49
|
+
message: string;
|
|
50
|
+
data?: Record<string, unknown>;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Node executor function type.
|
|
55
|
+
* Async function that takes input and context, returns result.
|
|
56
|
+
* @template TInput - Input type (validated by inputSchema)
|
|
57
|
+
* @template TOutput - Output type (validated by outputSchema)
|
|
58
|
+
*/
|
|
59
|
+
export type NodeExecutor<TInput = unknown, TOutput = unknown> = (input: TInput, context: NodeExecutionContext) => Promise<NodeExecutionResult<TOutput>>;
|
|
60
|
+
/**
|
|
61
|
+
* Node capabilities for UI and runtime behavior.
|
|
62
|
+
*/
|
|
63
|
+
export interface NodeCapabilities {
|
|
64
|
+
/** Node supports data enrichment */
|
|
65
|
+
supportsEnrichment?: boolean;
|
|
66
|
+
/** Node supports bulk actions */
|
|
67
|
+
supportsBulkActions?: boolean;
|
|
68
|
+
/** Node supports approval workflow */
|
|
69
|
+
supportsApproval?: boolean;
|
|
70
|
+
/** Node can be re-run after completion */
|
|
71
|
+
supportsRerun?: boolean;
|
|
72
|
+
/** Node supports cancellation */
|
|
73
|
+
supportsCancel?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Node category for organization.
|
|
77
|
+
*/
|
|
78
|
+
export type NodeCategory = 'action' | 'logic' | 'integration' | 'transform';
|
|
79
|
+
/**
|
|
80
|
+
* Metadata about a node (safe for client-side use).
|
|
81
|
+
*/
|
|
82
|
+
export interface NodeMetadata {
|
|
83
|
+
/** Unique node type identifier */
|
|
84
|
+
type: string;
|
|
85
|
+
/** Display name */
|
|
86
|
+
name: string;
|
|
87
|
+
/** Description of what the node does */
|
|
88
|
+
description: string;
|
|
89
|
+
/** Category for grouping */
|
|
90
|
+
category: NodeCategory;
|
|
91
|
+
/** Estimated duration in seconds */
|
|
92
|
+
estimatedDuration?: number;
|
|
93
|
+
/** Node capabilities */
|
|
94
|
+
capabilities?: NodeCapabilities;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Complete node definition including executor.
|
|
98
|
+
* @template TInput - Input type
|
|
99
|
+
* @template TOutput - Output type
|
|
100
|
+
*/
|
|
101
|
+
export interface NodeDefinition<TInput = unknown, TOutput = unknown> extends NodeMetadata {
|
|
102
|
+
/** Zod schema for validating input */
|
|
103
|
+
inputSchema: z.ZodSchema<TInput>;
|
|
104
|
+
/** Zod schema for validating output */
|
|
105
|
+
outputSchema: z.ZodSchema<TOutput>;
|
|
106
|
+
/** Executor function */
|
|
107
|
+
executor: NodeExecutor<TInput, TOutput>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/types/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,iEAAiE;IACjE,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,wCAAwC;IACxC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,OAAO,GAAG,OAAO;IACpD,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+BAA+B;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,mCAAmC;IACnC,YAAY,CAAC,EAAE;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CA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CAAC;IACnC,wBAAwB;IACxB,QAAQ,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/types/node.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { NodeDefinition, NodeExecutor, NodeCapabilities, NodeCategory } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for defining a node
|
|
5
|
+
*/
|
|
6
|
+
export interface DefineNodeConfig<TInput, TOutput> {
|
|
7
|
+
/** Unique node type identifier */
|
|
8
|
+
type: string;
|
|
9
|
+
/** Display name */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Description of what the node does */
|
|
12
|
+
description: string;
|
|
13
|
+
/** Category for grouping */
|
|
14
|
+
category: NodeCategory;
|
|
15
|
+
/** Zod schema for validating input */
|
|
16
|
+
inputSchema: z.ZodSchema<TInput>;
|
|
17
|
+
/** Zod schema for validating output */
|
|
18
|
+
outputSchema: z.ZodSchema<TOutput>;
|
|
19
|
+
/** Executor function */
|
|
20
|
+
executor: NodeExecutor<TInput, TOutput>;
|
|
21
|
+
/** Estimated duration in seconds */
|
|
22
|
+
estimatedDuration?: number;
|
|
23
|
+
/** Node capabilities */
|
|
24
|
+
capabilities?: NodeCapabilities;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Type-safe helper for defining nodes.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { defineNode } from '@jam-nodes/core';
|
|
32
|
+
* import { z } from 'zod';
|
|
33
|
+
*
|
|
34
|
+
* export const myNode = defineNode({
|
|
35
|
+
* type: 'my_node',
|
|
36
|
+
* name: 'My Node',
|
|
37
|
+
* description: 'Does something useful',
|
|
38
|
+
* category: 'action',
|
|
39
|
+
* inputSchema: z.object({
|
|
40
|
+
* message: z.string(),
|
|
41
|
+
* }),
|
|
42
|
+
* outputSchema: z.object({
|
|
43
|
+
* result: z.string(),
|
|
44
|
+
* }),
|
|
45
|
+
* executor: async (input, context) => {
|
|
46
|
+
* return {
|
|
47
|
+
* success: true,
|
|
48
|
+
* output: { result: `Processed: ${input.message}` },
|
|
49
|
+
* };
|
|
50
|
+
* },
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function defineNode<TInput, TOutput>(config: DefineNodeConfig<TInput, TOutput>): NodeDefinition<TInput, TOutput>;
|
|
55
|
+
//# sourceMappingURL=define-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-node.d.ts","sourceRoot":"","sources":["../../src/utils/define-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,MAAM,EAAE,OAAO;IAC/C,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,QAAQ,EAAE,YAAY,CAAC;IACvB,sCAAsC;IACtC,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,uCAAuC;IACvC,YAAY,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACnC,wBAAwB;IACxB,QAAQ,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,oCAAoC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wBAAwB;IACxB,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EACxC,MAAM,EAAE,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,GACxC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAYjC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe helper for defining nodes.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { defineNode } from '@jam-nodes/core';
|
|
7
|
+
* import { z } from 'zod';
|
|
8
|
+
*
|
|
9
|
+
* export const myNode = defineNode({
|
|
10
|
+
* type: 'my_node',
|
|
11
|
+
* name: 'My Node',
|
|
12
|
+
* description: 'Does something useful',
|
|
13
|
+
* category: 'action',
|
|
14
|
+
* inputSchema: z.object({
|
|
15
|
+
* message: z.string(),
|
|
16
|
+
* }),
|
|
17
|
+
* outputSchema: z.object({
|
|
18
|
+
* result: z.string(),
|
|
19
|
+
* }),
|
|
20
|
+
* executor: async (input, context) => {
|
|
21
|
+
* return {
|
|
22
|
+
* success: true,
|
|
23
|
+
* output: { result: `Processed: ${input.message}` },
|
|
24
|
+
* };
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function defineNode(config) {
|
|
30
|
+
return {
|
|
31
|
+
type: config.type,
|
|
32
|
+
name: config.name,
|
|
33
|
+
description: config.description,
|
|
34
|
+
category: config.category,
|
|
35
|
+
inputSchema: config.inputSchema,
|
|
36
|
+
outputSchema: config.outputSchema,
|
|
37
|
+
executor: config.executor,
|
|
38
|
+
estimatedDuration: config.estimatedDuration,
|
|
39
|
+
capabilities: config.capabilities,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=define-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-node.js","sourceRoot":"","sources":["../../src/utils/define-node.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,UAAU,CACxB,MAAyC;IAEzC,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,YAAY,EAAE,MAAM,CAAC,YAAY;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jam-nodes/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Core framework for building workflow nodes with type-safe executors and Zod validation",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"clean": "rm -rf dist",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"prepublishOnly": "npm run build"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"zod": "^3.0.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"jsonpath-plus": "^10.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.7.0",
|
|
32
|
+
"zod": "^3.24.0"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"workflow",
|
|
36
|
+
"nodes",
|
|
37
|
+
"executor",
|
|
38
|
+
"zod",
|
|
39
|
+
"typescript"
|
|
40
|
+
],
|
|
41
|
+
"author": "Jam",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/wespreadjam/jam-nodes.git",
|
|
46
|
+
"directory": "packages/core"
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/wespreadjam/jam-nodes/issues"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/wespreadjam/jam-nodes/tree/main/packages/core#readme"
|
|
52
|
+
}
|