@hostwebhook/node-sdk 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/code-runner.d.ts +20 -0
- package/dist/code-runner.js +138 -0
- package/dist/contratos.d.ts +121 -0
- package/dist/contratos.js +24 -0
- package/dist/dto/output-node.dto.d.ts +19 -0
- package/dist/dto/output-node.dto.js +96 -0
- package/dist/ensure-meta.d.ts +22 -0
- package/dist/ensure-meta.js +35 -0
- package/dist/execute-with-iteration.d.ts +18 -0
- package/dist/execute-with-iteration.js +66 -0
- package/dist/filter-utils.d.ts +22 -0
- package/dist/filter-utils.js +178 -0
- package/dist/handler-helpers.d.ts +21 -0
- package/dist/handler-helpers.js +53 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +73 -0
- package/dist/log-metadata.d.ts +191 -0
- package/dist/log-metadata.js +375 -0
- package/dist/node-dispatch.registry.d.ts +32 -0
- package/dist/node-dispatch.registry.js +45 -0
- package/dist/node-executors.d.ts +299 -0
- package/dist/node-executors.js +555 -0
- package/dist/node-lifecycle.d.ts +399 -0
- package/dist/node-lifecycle.js +782 -0
- package/dist/normalize-nodes.d.ts +18 -0
- package/dist/normalize-nodes.js +22 -0
- package/dist/output-node-ref.schema.d.ts +82 -0
- package/dist/output-node-ref.schema.js +90 -0
- package/dist/output-webhook-scope.d.ts +36 -0
- package/dist/output-webhook-scope.js +42 -0
- package/dist/payload-preview.d.ts +10 -0
- package/dist/payload-preview.js +39 -0
- package/dist/pipeline.constants.d.ts +29 -0
- package/dist/pipeline.constants.js +51 -0
- package/dist/pre-request-pool.d.ts +58 -0
- package/dist/pre-request-pool.js +308 -0
- package/dist/pre-request-runner-source.d.ts +28 -0
- package/dist/pre-request-runner-source.js +411 -0
- package/dist/regex-de-inquilino.d.ts +15 -0
- package/dist/regex-de-inquilino.js +98 -0
- package/dist/request-context.d.ts +18 -0
- package/dist/request-context.js +34 -0
- package/dist/retry-transient.d.ts +54 -0
- package/dist/retry-transient.js +67 -0
- package/dist/retry-utils.d.ts +17 -0
- package/dist/retry-utils.js +23 -0
- package/dist/schema-validator-utils.d.ts +9 -0
- package/dist/schema-validator-utils.js +140 -0
- package/dist/ssrf-guard.d.ts +202 -0
- package/dist/ssrf-guard.js +917 -0
- package/dist/swallow.d.ts +52 -0
- package/dist/swallow.js +55 -0
- package/dist/template-render.d.ts +33 -0
- package/dist/template-render.js +43 -0
- package/dist/try-parse.d.ts +41 -0
- package/dist/try-parse.js +69 -0
- package/dist/workspace-payloads.d.ts +66 -0
- package/dist/workspace-payloads.js +496 -0
- package/package.json +35 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared node execution functions.
|
|
3
|
+
*
|
|
4
|
+
* Both pipeline-run.service.ts (Run Pipeline / test) and event-pipeline.service.ts
|
|
5
|
+
* (real events) call these functions so that "how to execute node type X" lives in
|
|
6
|
+
* exactly ONE place. Callers still own Delivery records, child events, telemetry,
|
|
7
|
+
* and output-routing — only core execution logic is here.
|
|
8
|
+
*/
|
|
9
|
+
export interface NodeExecutionResult {
|
|
10
|
+
statusCode: number;
|
|
11
|
+
responseBody: string;
|
|
12
|
+
latencyMs: number;
|
|
13
|
+
/** Parsed output payload for downstream nodes (avoids callers re-parsing responseBody) */
|
|
14
|
+
outputPayload?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface ITransformService {
|
|
17
|
+
executeSingle(entity: any, payload: Record<string, unknown>, context?: {
|
|
18
|
+
headers?: Record<string, string>;
|
|
19
|
+
meta?: Record<string, string>;
|
|
20
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
21
|
+
}): Promise<NodeExecutionResult>;
|
|
22
|
+
}
|
|
23
|
+
export interface IHttpActionService {
|
|
24
|
+
executeSingle(entity: any, payload: Record<string, unknown>, opts?: {
|
|
25
|
+
eventMeta?: Record<string, string>;
|
|
26
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
27
|
+
}): Promise<NodeExecutionResult>;
|
|
28
|
+
}
|
|
29
|
+
export interface IEmailActionService {
|
|
30
|
+
executeSingle(entity: any, payload: Record<string, unknown>): Promise<NodeExecutionResult>;
|
|
31
|
+
}
|
|
32
|
+
export interface ISheetsActionService {
|
|
33
|
+
executeForEvent(entity: any, payload: Record<string, unknown>, opts?: {
|
|
34
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
35
|
+
}): Promise<any>;
|
|
36
|
+
}
|
|
37
|
+
export interface ICalendarActionService {
|
|
38
|
+
executeForEvent(entity: any, payload: Record<string, unknown>, opts?: {
|
|
39
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
40
|
+
}): Promise<any>;
|
|
41
|
+
}
|
|
42
|
+
export interface IDocsActionService {
|
|
43
|
+
executeForEvent(entity: any, payload: Record<string, unknown>, opts?: {
|
|
44
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
45
|
+
}): Promise<any>;
|
|
46
|
+
}
|
|
47
|
+
export interface IFirecrawlActionService {
|
|
48
|
+
executeSingle(entity: any, payload: Record<string, unknown>, opts?: {
|
|
49
|
+
eventMeta?: Record<string, string>;
|
|
50
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
51
|
+
}): Promise<any>;
|
|
52
|
+
}
|
|
53
|
+
export interface IMarkdownNodeService {
|
|
54
|
+
executeForEvent(entity: any, payload: Record<string, unknown>, opts?: {
|
|
55
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
56
|
+
}): Promise<any>;
|
|
57
|
+
}
|
|
58
|
+
export interface IAiNodeService {
|
|
59
|
+
executeForEvent(entity: any, payload: Record<string, unknown>, opts?: {
|
|
60
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
61
|
+
eventMeta?: Record<string, string>;
|
|
62
|
+
}): Promise<any>;
|
|
63
|
+
}
|
|
64
|
+
export interface IMongoActionService {
|
|
65
|
+
executeForEvent(entity: any, ctx: {
|
|
66
|
+
payload: Record<string, unknown>;
|
|
67
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
68
|
+
}): Promise<{
|
|
69
|
+
result?: any;
|
|
70
|
+
latencyMs: number;
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
export interface IAggregatorService {
|
|
74
|
+
processBatchPayload(entity: any, payload: Record<string, unknown>): NodeExecutionResult | Promise<NodeExecutionResult>;
|
|
75
|
+
}
|
|
76
|
+
export interface ILimitNodeService {
|
|
77
|
+
executeForEvent(entity: any, payload: Record<string, unknown>): {
|
|
78
|
+
statusCode: number;
|
|
79
|
+
responseBody: string;
|
|
80
|
+
latencyMs: number;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export interface ICacheService {
|
|
84
|
+
processEvent(entity: any, payload: Record<string, unknown>): {
|
|
85
|
+
action: string;
|
|
86
|
+
outputPayload: Record<string, unknown> | null;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export interface IRateLimiterService {
|
|
90
|
+
checkRate(entity: any): {
|
|
91
|
+
allowed: boolean;
|
|
92
|
+
delayMs: number;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export interface IDriveActionService {
|
|
96
|
+
executeForEvent(entity: any, payload: Record<string, unknown>, opts?: {
|
|
97
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
98
|
+
eventMeta?: Record<string, string>;
|
|
99
|
+
}): Promise<any>;
|
|
100
|
+
}
|
|
101
|
+
export interface IVectorStoreNodeService {
|
|
102
|
+
executeForEvent(entity: any, payload: Record<string, unknown> & {
|
|
103
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
104
|
+
eventMeta?: Record<string, string>;
|
|
105
|
+
}): Promise<any>;
|
|
106
|
+
}
|
|
107
|
+
export interface IFileTransformNodeService {
|
|
108
|
+
executeForEvent(entity: any, payload: Record<string, unknown>, opts?: {
|
|
109
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
110
|
+
}): Promise<any>;
|
|
111
|
+
}
|
|
112
|
+
export interface IPostgresActionService {
|
|
113
|
+
executeForEvent(entity: any, payload: Record<string, unknown> & {
|
|
114
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
115
|
+
eventMeta?: Record<string, string>;
|
|
116
|
+
}): Promise<any>;
|
|
117
|
+
}
|
|
118
|
+
export interface INotificationActionService {
|
|
119
|
+
sendForEvent(entity: any, ctx: any, payload: Record<string, unknown>): Promise<{
|
|
120
|
+
success: boolean;
|
|
121
|
+
error?: string;
|
|
122
|
+
statusCode?: number;
|
|
123
|
+
}>;
|
|
124
|
+
}
|
|
125
|
+
export interface NodeExecutorServices {
|
|
126
|
+
transform?: ITransformService;
|
|
127
|
+
httpAction?: IHttpActionService;
|
|
128
|
+
emailAction?: IEmailActionService;
|
|
129
|
+
sheetsAction?: ISheetsActionService;
|
|
130
|
+
calendarAction?: ICalendarActionService;
|
|
131
|
+
docsAction?: IDocsActionService;
|
|
132
|
+
firecrawlAction?: IFirecrawlActionService;
|
|
133
|
+
mongoAction?: IMongoActionService;
|
|
134
|
+
aggregator?: IAggregatorService;
|
|
135
|
+
cache?: ICacheService;
|
|
136
|
+
rateLimiter?: IRateLimiterService;
|
|
137
|
+
notificationAction?: INotificationActionService;
|
|
138
|
+
markdown?: IMarkdownNodeService;
|
|
139
|
+
ai?: IAiNodeService;
|
|
140
|
+
driveAction?: IDriveActionService;
|
|
141
|
+
vectorStore?: IVectorStoreNodeService;
|
|
142
|
+
fileTransform?: IFileTransformNodeService;
|
|
143
|
+
postgresAction?: IPostgresActionService;
|
|
144
|
+
limit?: ILimitNodeService;
|
|
145
|
+
}
|
|
146
|
+
export interface FilterExecutionResult extends Omit<NodeExecutionResult, 'outputPayload'> {
|
|
147
|
+
outputPayload: Record<string, unknown>;
|
|
148
|
+
passed: boolean;
|
|
149
|
+
totalItems: number;
|
|
150
|
+
passedItems: number;
|
|
151
|
+
}
|
|
152
|
+
export declare function executeFilter(entity: any, payload: Record<string, unknown>, context?: ExecutorContext): FilterExecutionResult;
|
|
153
|
+
export declare function executeTransform(svc: ITransformService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
154
|
+
export declare function executeHttpAction(svc: IHttpActionService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
155
|
+
export declare function executeEmailAction(svc: IEmailActionService, entity: any, payload: Record<string, unknown>): Promise<NodeExecutionResult>;
|
|
156
|
+
export declare function executeSheetsAction(svc: ISheetsActionService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
157
|
+
export declare function executeDriveAction(svc: IDriveActionService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
158
|
+
export declare function executeVectorStoreNode(svc: IVectorStoreNodeService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
159
|
+
export declare function executeFileTransformNode(svc: IFileTransformNodeService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
160
|
+
export declare function executePostgresAction(svc: IPostgresActionService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
161
|
+
export declare function executeCalendarAction(svc: ICalendarActionService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
162
|
+
export declare function executeDocsAction(svc: IDocsActionService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
163
|
+
export declare function executeMarkdownNode(svc: IMarkdownNodeService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
164
|
+
export declare function executeAiNode(svc: IAiNodeService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
165
|
+
export declare function executeMongoAction(svc: IMongoActionService, entity: any, payload: Record<string, unknown>, context?: ExecutorContext): Promise<NodeExecutionResult>;
|
|
166
|
+
export declare function executeAggregator(svc: IAggregatorService, entity: any, payload: Record<string, unknown>): Promise<NodeExecutionResult>;
|
|
167
|
+
export declare function executeCache(svc: ICacheService, entity: any, payload: Record<string, unknown>): NodeExecutionResult;
|
|
168
|
+
export declare function executeRateLimiter(svc: IRateLimiterService, entity: any): NodeExecutionResult;
|
|
169
|
+
export declare function executeConditional(entity: any, payload: Record<string, unknown>, context?: ExecutorContext): NodeExecutionResult & {
|
|
170
|
+
matchedBranch: any | null;
|
|
171
|
+
};
|
|
172
|
+
export declare function executeSchemaValidator(entity: any, payload: Record<string, unknown>): NodeExecutionResult;
|
|
173
|
+
export declare function executeNotificationAction(svc: INotificationActionService, entity: any, payload: Record<string, unknown>, notifCtx?: any): Promise<NodeExecutionResult>;
|
|
174
|
+
export interface SplitExecutionResult extends NodeExecutionResult {
|
|
175
|
+
splitOutputs: Array<{
|
|
176
|
+
name: string;
|
|
177
|
+
field: string;
|
|
178
|
+
payload: unknown;
|
|
179
|
+
}>;
|
|
180
|
+
remainder: Record<string, unknown> | null;
|
|
181
|
+
}
|
|
182
|
+
export declare function executeSplit(entity: any, payload: Record<string, unknown>): SplitExecutionResult;
|
|
183
|
+
export interface CodeExecutionResult extends NodeExecutionResult {
|
|
184
|
+
logs: string[];
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Ejecutar el nodo de código.
|
|
188
|
+
*
|
|
189
|
+
* ## Por qué esto ya no corre aquí dentro
|
|
190
|
+
*
|
|
191
|
+
* Antes iba a `renderTemplate(..., { mode: 'code' })`, o sea a `node:vm` con
|
|
192
|
+
* una lista negra sobre el texto fuente. `vm` no es una frontera y una lista
|
|
193
|
+
* de expresiones regulares sobre el fuente no es un control: la concatenación
|
|
194
|
+
* de cadenas la cruza sin despeinarse, y el contexto se sembraba con los
|
|
195
|
+
* intrínsecos del propio realm, así que `Math.constructor.constructor` era el
|
|
196
|
+
* `Function` de la casa.
|
|
197
|
+
*
|
|
198
|
+
* Con eso, un `return Math["constr"+"uctor"]…("return this")()["proc"+"ess"].env`
|
|
199
|
+
* devolvía `process.env` — es decir `MONGO_URI` y `API_SECRET`, que es la
|
|
200
|
+
* entrada del PBKDF2 con el que se descifran las credenciales guardadas de
|
|
201
|
+
* TODOS los inquilinos. Y cambiando la pieza final, ejecución de comandos.
|
|
202
|
+
*
|
|
203
|
+
* Ahora corre en el mismo hijo desechable que los scripts pre-request: entorno
|
|
204
|
+
* vacío, sin ficheros ni spawn donde el runtime lo soporte, muerto tras cada
|
|
205
|
+
* ejecución. Salirse del vm sigue siendo fácil; lo que cambia es que ya no
|
|
206
|
+
* lleva a ningún sitio.
|
|
207
|
+
*
|
|
208
|
+
* El contrato hacia fuera no cambia — mismos códigos, mismo `outputPayload`,
|
|
209
|
+
* mismos logs— salvo que ahora es asíncrono, que es lo que cuesta un proceso.
|
|
210
|
+
*/
|
|
211
|
+
export declare function executeCode(entity: any, payload: Record<string, unknown>, workspacePayloads?: Record<string, Record<string, unknown>>): Promise<CodeExecutionResult>;
|
|
212
|
+
/**
|
|
213
|
+
* Execute any node type. Used by pipeline-run.service.ts.
|
|
214
|
+
* event-pipeline.service.ts calls the individual functions directly
|
|
215
|
+
* because it needs more control over pre/post processing.
|
|
216
|
+
*
|
|
217
|
+
* Handles _meta iteration: if the incoming payload has
|
|
218
|
+
* _meta.iterable + _meta.iterateField, each item is executed
|
|
219
|
+
* individually and results are aggregated — matching the behaviour
|
|
220
|
+
* of executeWithIteration used by individual test webhooks.
|
|
221
|
+
*
|
|
222
|
+
* filter and aggregator handle _meta internally and receive the
|
|
223
|
+
* full payload (with _meta) — they are excluded from iteration.
|
|
224
|
+
*/
|
|
225
|
+
export interface ExecutorContext {
|
|
226
|
+
workspacePayloads?: Record<string, Record<string, unknown>>;
|
|
227
|
+
/** Event headers — used by transform's applyTransform for {{headers.x}} interpolation */
|
|
228
|
+
headers?: Record<string, string>;
|
|
229
|
+
/** Event-level metadata (eventId, webhookId, receivedAt) — used by transform */
|
|
230
|
+
eventMeta?: Record<string, string>;
|
|
231
|
+
/** Notification context — used by notification action */
|
|
232
|
+
notifCtx?: any;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Loop fan-out: turn the iterable field into one payload per item, each
|
|
236
|
+
* stamped with its position. The loop node owns its own iteration and
|
|
237
|
+
* LoopState, which is why it has no registered handler — the caller drives
|
|
238
|
+
* the iterations from this list.
|
|
239
|
+
*/
|
|
240
|
+
export declare function executeLoopFanOut(entity: any, payload: Record<string, unknown>): NodeExecutionResult;
|
|
241
|
+
/**
|
|
242
|
+
* The seven node types that do NOT call `registerNodeHandler`, and what
|
|
243
|
+
* Run Pipeline does for each. Everything else executes through its
|
|
244
|
+
* registered handler — the same object prod runs — so the two cycles
|
|
245
|
+
* cannot drift.
|
|
246
|
+
*
|
|
247
|
+
* This list is deliberately explicit rather than a `default:` arm. A
|
|
248
|
+
* `default` silently absorbs any node type nobody wired up, which is
|
|
249
|
+
* exactly how the Limit node came to return 15 of 15 items in Run
|
|
250
|
+
* Pipeline while prod limited correctly. A missing entry here is a
|
|
251
|
+
* loud `undefined`, and `architecture.spec.ts` asserts the set matches
|
|
252
|
+
* the types that actually lack a handler.
|
|
253
|
+
*/
|
|
254
|
+
export declare const HANDLERLESS_NODE_TYPES: {
|
|
255
|
+
/** Annotation — never executes. */
|
|
256
|
+
readonly stickyNote: {
|
|
257
|
+
readonly run: "passthrough";
|
|
258
|
+
readonly telemetrySource: "sticky_note";
|
|
259
|
+
};
|
|
260
|
+
readonly webhook: {
|
|
261
|
+
readonly run: "passthrough";
|
|
262
|
+
readonly telemetrySource: "entry_webhook";
|
|
263
|
+
};
|
|
264
|
+
readonly scheduledWorkflow: {
|
|
265
|
+
readonly run: "passthrough";
|
|
266
|
+
readonly telemetrySource: "scheduled_webhook";
|
|
267
|
+
};
|
|
268
|
+
readonly voiceAgent: {
|
|
269
|
+
readonly run: "passthrough";
|
|
270
|
+
readonly telemetrySource: "voice_agent";
|
|
271
|
+
};
|
|
272
|
+
/** Queue-based: prod enqueues, Run Pipeline has nothing to wait on. */
|
|
273
|
+
readonly delay: {
|
|
274
|
+
readonly run: "passthrough";
|
|
275
|
+
readonly telemetrySource: "delay_node";
|
|
276
|
+
};
|
|
277
|
+
/** Waits on a human. Run Pipeline cannot block on a click. */
|
|
278
|
+
readonly approval: {
|
|
279
|
+
readonly run: "passthrough";
|
|
280
|
+
readonly telemetrySource: "approval_node";
|
|
281
|
+
};
|
|
282
|
+
/** pipeline-run.service collects the inputs itself and merges them. */
|
|
283
|
+
readonly merge: {
|
|
284
|
+
readonly run: "passthrough";
|
|
285
|
+
readonly telemetrySource: "merge_node";
|
|
286
|
+
};
|
|
287
|
+
/** Owns its own iteration + LoopState; pipeline-run drives it directly. */
|
|
288
|
+
readonly loop: {
|
|
289
|
+
readonly run: "custom";
|
|
290
|
+
readonly telemetrySource: "loop_node";
|
|
291
|
+
};
|
|
292
|
+
/** Counter lives in Redis; prod dispatches it from event-pipeline. */
|
|
293
|
+
readonly rateLimiter: {
|
|
294
|
+
readonly run: "custom";
|
|
295
|
+
readonly telemetrySource: "rate_limiter_node";
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
export type HandlerlessNodeType = keyof typeof HANDLERLESS_NODE_TYPES;
|
|
299
|
+
export declare function isHandlerless(nodeType: string): nodeType is HandlerlessNodeType;
|