@teamkeel/functions-runtime 0.429.1 → 0.430.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/index.cjs +303 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +138 -3
- package/dist/index.d.ts +138 -3
- package/dist/index.js +302 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -266,6 +266,111 @@ declare class Task$1 {
|
|
|
266
266
|
cancel(): Promise<Task$1>;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
+
/**
|
|
270
|
+
* FlowsAPI provides methods for starting and managing flows via the HTTP API.
|
|
271
|
+
*/
|
|
272
|
+
declare class FlowsAPI {
|
|
273
|
+
/**
|
|
274
|
+
* @param {string} flowName The name of the flow
|
|
275
|
+
* @param {Object|null} identity Optional identity object for authentication
|
|
276
|
+
* @param {string|null} authToken Optional auth token for authentication
|
|
277
|
+
*/
|
|
278
|
+
constructor(flowName: string, identity?: Object | null, authToken?: string | null);
|
|
279
|
+
_flowName: string;
|
|
280
|
+
_identity: Object | null;
|
|
281
|
+
_authToken: string | null;
|
|
282
|
+
/**
|
|
283
|
+
* Returns a new FlowsAPI instance that will use the given identity for authentication.
|
|
284
|
+
* @param {Object} identity The identity object
|
|
285
|
+
* @returns {FlowsAPI} A new FlowsAPI instance with the identity set
|
|
286
|
+
*/
|
|
287
|
+
withIdentity(identity: Object): FlowsAPI;
|
|
288
|
+
/**
|
|
289
|
+
* Returns a new FlowsAPI instance that will use the given auth token for authentication.
|
|
290
|
+
* @param {string} token The auth token to use
|
|
291
|
+
* @returns {FlowsAPI} A new FlowsAPI instance with the auth token set
|
|
292
|
+
*/
|
|
293
|
+
withAuthToken(token: string): FlowsAPI;
|
|
294
|
+
/**
|
|
295
|
+
* Starts a new flow run with the given inputs.
|
|
296
|
+
* @param {Object} inputs The flow input data
|
|
297
|
+
* @returns {Promise<FlowRun>} The created flow run
|
|
298
|
+
*/
|
|
299
|
+
start(inputs?: Object): Promise<FlowRun$1>;
|
|
300
|
+
/**
|
|
301
|
+
* Gets a flow run by ID.
|
|
302
|
+
* @param {string} runId The flow run ID
|
|
303
|
+
* @returns {Promise<FlowRun>} The flow run
|
|
304
|
+
*/
|
|
305
|
+
get(runId: string): Promise<FlowRun$1>;
|
|
306
|
+
/**
|
|
307
|
+
* Lists flow runs for this flow.
|
|
308
|
+
* @param {Object} options Optional pagination options
|
|
309
|
+
* @param {number} options.limit Maximum number of runs to return
|
|
310
|
+
* @param {number} options.offset Offset for pagination
|
|
311
|
+
* @returns {Promise<{results: FlowRun[], pageInfo: Object}>} List of flow runs with pagination info
|
|
312
|
+
*/
|
|
313
|
+
list(options?: {
|
|
314
|
+
limit: number;
|
|
315
|
+
offset: number;
|
|
316
|
+
}): Promise<{
|
|
317
|
+
results: FlowRun$1[];
|
|
318
|
+
pageInfo: Object;
|
|
319
|
+
}>;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* FlowRun represents a flow run instance with action methods.
|
|
323
|
+
*/
|
|
324
|
+
declare class FlowRun$1 {
|
|
325
|
+
/**
|
|
326
|
+
* @param {Object} data The flow run data from the API
|
|
327
|
+
* @param {string} flowName The name of the flow
|
|
328
|
+
* @param {Object|null} identity Optional identity object for authentication
|
|
329
|
+
* @param {string|null} authToken Optional auth token for authentication
|
|
330
|
+
*/
|
|
331
|
+
constructor(data: Object, flowName: string, identity?: Object | null, authToken?: string | null);
|
|
332
|
+
id: any;
|
|
333
|
+
name: any;
|
|
334
|
+
status: any;
|
|
335
|
+
inputs: any;
|
|
336
|
+
outputs: any;
|
|
337
|
+
steps: any;
|
|
338
|
+
pendingStep: any;
|
|
339
|
+
createdAt: Date | undefined;
|
|
340
|
+
updatedAt: Date | undefined;
|
|
341
|
+
completedAt: Date | undefined;
|
|
342
|
+
_flowName: string;
|
|
343
|
+
_identity: Object | null;
|
|
344
|
+
_authToken: string | null;
|
|
345
|
+
/**
|
|
346
|
+
* Returns a new FlowRun instance that will use the given identity for authentication.
|
|
347
|
+
* @param {Object} identity The identity object
|
|
348
|
+
* @returns {FlowRun} A new FlowRun instance with the identity set
|
|
349
|
+
*/
|
|
350
|
+
withIdentity(identity: Object): FlowRun$1;
|
|
351
|
+
/**
|
|
352
|
+
* Returns a new FlowRun instance that will use the given auth token for authentication.
|
|
353
|
+
* @param {string} token The auth token to use
|
|
354
|
+
* @returns {FlowRun} A new FlowRun instance with the auth token set
|
|
355
|
+
*/
|
|
356
|
+
withAuthToken(token: string): FlowRun$1;
|
|
357
|
+
/**
|
|
358
|
+
* Converts the flow run back to API data format for creating new instances.
|
|
359
|
+
* @returns {Object} The flow run data in API format
|
|
360
|
+
*/
|
|
361
|
+
_toApiData(): Object;
|
|
362
|
+
/**
|
|
363
|
+
* Refreshes the flow run state from the API.
|
|
364
|
+
* @returns {Promise<FlowRun>} The updated flow run
|
|
365
|
+
*/
|
|
366
|
+
refresh(): Promise<FlowRun$1>;
|
|
367
|
+
/**
|
|
368
|
+
* Cancels the flow run.
|
|
369
|
+
* @returns {Promise<FlowRun>} The updated flow run
|
|
370
|
+
*/
|
|
371
|
+
cancel(): Promise<FlowRun$1>;
|
|
372
|
+
}
|
|
373
|
+
|
|
269
374
|
interface RequestHeadersMap {
|
|
270
375
|
[key: string]: string;
|
|
271
376
|
}
|
|
@@ -1127,7 +1232,7 @@ interface FlowContext<C extends FlowConfig, E, S, Id, I, H extends NullableHardw
|
|
|
1127
1232
|
ui: UI<C, H>;
|
|
1128
1233
|
complete: Complete<C, I>;
|
|
1129
1234
|
env: E;
|
|
1130
|
-
now: Date;
|
|
1235
|
+
now(): Date;
|
|
1131
1236
|
secrets: S;
|
|
1132
1237
|
identity: Id;
|
|
1133
1238
|
}
|
|
@@ -1203,7 +1308,7 @@ type StageConfigObject = {
|
|
|
1203
1308
|
type StageConfig = string | StageConfigObject;
|
|
1204
1309
|
declare function createFlowContext<C extends FlowConfig, E, S, Id, I, H extends NullableHardware>(runId: string, data: any, action: string | null, callback: string | null, element: string | null, spanId: string, ctx: {
|
|
1205
1310
|
env: E;
|
|
1206
|
-
now: Date;
|
|
1311
|
+
now: () => Date;
|
|
1207
1312
|
secrets: S;
|
|
1208
1313
|
identity: Id;
|
|
1209
1314
|
}): FlowContext<C, E, S, Id, I, H>;
|
|
@@ -1391,5 +1496,35 @@ type Task = {
|
|
|
1391
1496
|
type TaskCreateOptions = {
|
|
1392
1497
|
deferredUntil?: Date;
|
|
1393
1498
|
};
|
|
1499
|
+
type FlowRunStatus = "PENDING" | "RUNNING" | "COMPLETED" | "FAILED" | "CANCELLED";
|
|
1500
|
+
type FlowRunStep = {
|
|
1501
|
+
id: string;
|
|
1502
|
+
name?: string;
|
|
1503
|
+
status?: string;
|
|
1504
|
+
data?: any;
|
|
1505
|
+
};
|
|
1506
|
+
type FlowRun = {
|
|
1507
|
+
id: string;
|
|
1508
|
+
name: string;
|
|
1509
|
+
status: FlowRunStatus;
|
|
1510
|
+
inputs?: any;
|
|
1511
|
+
outputs?: any;
|
|
1512
|
+
steps?: FlowRunStep[];
|
|
1513
|
+
pendingStep?: FlowRunStep;
|
|
1514
|
+
createdAt?: Date;
|
|
1515
|
+
updatedAt?: Date;
|
|
1516
|
+
completedAt?: Date;
|
|
1517
|
+
};
|
|
1518
|
+
type FlowListOptions = {
|
|
1519
|
+
limit?: number;
|
|
1520
|
+
offset?: number;
|
|
1521
|
+
};
|
|
1522
|
+
type FlowListResult = {
|
|
1523
|
+
results: FlowRun[];
|
|
1524
|
+
pageInfo: {
|
|
1525
|
+
totalCount: number;
|
|
1526
|
+
hasNextPage: boolean;
|
|
1527
|
+
};
|
|
1528
|
+
};
|
|
1394
1529
|
|
|
1395
|
-
export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FuncWithConfig, type FunctionConfig, type Hardware, type IDWhereCondition, InlineFile, ModelAPI, NonRetriableError, type NullableHardware, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type Printer, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type Task, TaskAPI, type TaskCreateOptions, type TaskStatus, type TimestampQueryInput, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
|
|
1530
|
+
export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FlowListOptions, type FlowListResult, type FlowRun, type FlowRunStatus, type FlowRunStep, FlowsAPI, type FuncWithConfig, type FunctionConfig, type Hardware, type IDWhereCondition, InlineFile, ModelAPI, NonRetriableError, type NullableHardware, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type Printer, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type Task, TaskAPI, type TaskCreateOptions, type TaskStatus, type TimestampQueryInput, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
|
package/dist/index.d.ts
CHANGED
|
@@ -266,6 +266,111 @@ declare class Task$1 {
|
|
|
266
266
|
cancel(): Promise<Task$1>;
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
+
/**
|
|
270
|
+
* FlowsAPI provides methods for starting and managing flows via the HTTP API.
|
|
271
|
+
*/
|
|
272
|
+
declare class FlowsAPI {
|
|
273
|
+
/**
|
|
274
|
+
* @param {string} flowName The name of the flow
|
|
275
|
+
* @param {Object|null} identity Optional identity object for authentication
|
|
276
|
+
* @param {string|null} authToken Optional auth token for authentication
|
|
277
|
+
*/
|
|
278
|
+
constructor(flowName: string, identity?: Object | null, authToken?: string | null);
|
|
279
|
+
_flowName: string;
|
|
280
|
+
_identity: Object | null;
|
|
281
|
+
_authToken: string | null;
|
|
282
|
+
/**
|
|
283
|
+
* Returns a new FlowsAPI instance that will use the given identity for authentication.
|
|
284
|
+
* @param {Object} identity The identity object
|
|
285
|
+
* @returns {FlowsAPI} A new FlowsAPI instance with the identity set
|
|
286
|
+
*/
|
|
287
|
+
withIdentity(identity: Object): FlowsAPI;
|
|
288
|
+
/**
|
|
289
|
+
* Returns a new FlowsAPI instance that will use the given auth token for authentication.
|
|
290
|
+
* @param {string} token The auth token to use
|
|
291
|
+
* @returns {FlowsAPI} A new FlowsAPI instance with the auth token set
|
|
292
|
+
*/
|
|
293
|
+
withAuthToken(token: string): FlowsAPI;
|
|
294
|
+
/**
|
|
295
|
+
* Starts a new flow run with the given inputs.
|
|
296
|
+
* @param {Object} inputs The flow input data
|
|
297
|
+
* @returns {Promise<FlowRun>} The created flow run
|
|
298
|
+
*/
|
|
299
|
+
start(inputs?: Object): Promise<FlowRun$1>;
|
|
300
|
+
/**
|
|
301
|
+
* Gets a flow run by ID.
|
|
302
|
+
* @param {string} runId The flow run ID
|
|
303
|
+
* @returns {Promise<FlowRun>} The flow run
|
|
304
|
+
*/
|
|
305
|
+
get(runId: string): Promise<FlowRun$1>;
|
|
306
|
+
/**
|
|
307
|
+
* Lists flow runs for this flow.
|
|
308
|
+
* @param {Object} options Optional pagination options
|
|
309
|
+
* @param {number} options.limit Maximum number of runs to return
|
|
310
|
+
* @param {number} options.offset Offset for pagination
|
|
311
|
+
* @returns {Promise<{results: FlowRun[], pageInfo: Object}>} List of flow runs with pagination info
|
|
312
|
+
*/
|
|
313
|
+
list(options?: {
|
|
314
|
+
limit: number;
|
|
315
|
+
offset: number;
|
|
316
|
+
}): Promise<{
|
|
317
|
+
results: FlowRun$1[];
|
|
318
|
+
pageInfo: Object;
|
|
319
|
+
}>;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* FlowRun represents a flow run instance with action methods.
|
|
323
|
+
*/
|
|
324
|
+
declare class FlowRun$1 {
|
|
325
|
+
/**
|
|
326
|
+
* @param {Object} data The flow run data from the API
|
|
327
|
+
* @param {string} flowName The name of the flow
|
|
328
|
+
* @param {Object|null} identity Optional identity object for authentication
|
|
329
|
+
* @param {string|null} authToken Optional auth token for authentication
|
|
330
|
+
*/
|
|
331
|
+
constructor(data: Object, flowName: string, identity?: Object | null, authToken?: string | null);
|
|
332
|
+
id: any;
|
|
333
|
+
name: any;
|
|
334
|
+
status: any;
|
|
335
|
+
inputs: any;
|
|
336
|
+
outputs: any;
|
|
337
|
+
steps: any;
|
|
338
|
+
pendingStep: any;
|
|
339
|
+
createdAt: Date | undefined;
|
|
340
|
+
updatedAt: Date | undefined;
|
|
341
|
+
completedAt: Date | undefined;
|
|
342
|
+
_flowName: string;
|
|
343
|
+
_identity: Object | null;
|
|
344
|
+
_authToken: string | null;
|
|
345
|
+
/**
|
|
346
|
+
* Returns a new FlowRun instance that will use the given identity for authentication.
|
|
347
|
+
* @param {Object} identity The identity object
|
|
348
|
+
* @returns {FlowRun} A new FlowRun instance with the identity set
|
|
349
|
+
*/
|
|
350
|
+
withIdentity(identity: Object): FlowRun$1;
|
|
351
|
+
/**
|
|
352
|
+
* Returns a new FlowRun instance that will use the given auth token for authentication.
|
|
353
|
+
* @param {string} token The auth token to use
|
|
354
|
+
* @returns {FlowRun} A new FlowRun instance with the auth token set
|
|
355
|
+
*/
|
|
356
|
+
withAuthToken(token: string): FlowRun$1;
|
|
357
|
+
/**
|
|
358
|
+
* Converts the flow run back to API data format for creating new instances.
|
|
359
|
+
* @returns {Object} The flow run data in API format
|
|
360
|
+
*/
|
|
361
|
+
_toApiData(): Object;
|
|
362
|
+
/**
|
|
363
|
+
* Refreshes the flow run state from the API.
|
|
364
|
+
* @returns {Promise<FlowRun>} The updated flow run
|
|
365
|
+
*/
|
|
366
|
+
refresh(): Promise<FlowRun$1>;
|
|
367
|
+
/**
|
|
368
|
+
* Cancels the flow run.
|
|
369
|
+
* @returns {Promise<FlowRun>} The updated flow run
|
|
370
|
+
*/
|
|
371
|
+
cancel(): Promise<FlowRun$1>;
|
|
372
|
+
}
|
|
373
|
+
|
|
269
374
|
interface RequestHeadersMap {
|
|
270
375
|
[key: string]: string;
|
|
271
376
|
}
|
|
@@ -1127,7 +1232,7 @@ interface FlowContext<C extends FlowConfig, E, S, Id, I, H extends NullableHardw
|
|
|
1127
1232
|
ui: UI<C, H>;
|
|
1128
1233
|
complete: Complete<C, I>;
|
|
1129
1234
|
env: E;
|
|
1130
|
-
now: Date;
|
|
1235
|
+
now(): Date;
|
|
1131
1236
|
secrets: S;
|
|
1132
1237
|
identity: Id;
|
|
1133
1238
|
}
|
|
@@ -1203,7 +1308,7 @@ type StageConfigObject = {
|
|
|
1203
1308
|
type StageConfig = string | StageConfigObject;
|
|
1204
1309
|
declare function createFlowContext<C extends FlowConfig, E, S, Id, I, H extends NullableHardware>(runId: string, data: any, action: string | null, callback: string | null, element: string | null, spanId: string, ctx: {
|
|
1205
1310
|
env: E;
|
|
1206
|
-
now: Date;
|
|
1311
|
+
now: () => Date;
|
|
1207
1312
|
secrets: S;
|
|
1208
1313
|
identity: Id;
|
|
1209
1314
|
}): FlowContext<C, E, S, Id, I, H>;
|
|
@@ -1391,5 +1496,35 @@ type Task = {
|
|
|
1391
1496
|
type TaskCreateOptions = {
|
|
1392
1497
|
deferredUntil?: Date;
|
|
1393
1498
|
};
|
|
1499
|
+
type FlowRunStatus = "PENDING" | "RUNNING" | "COMPLETED" | "FAILED" | "CANCELLED";
|
|
1500
|
+
type FlowRunStep = {
|
|
1501
|
+
id: string;
|
|
1502
|
+
name?: string;
|
|
1503
|
+
status?: string;
|
|
1504
|
+
data?: any;
|
|
1505
|
+
};
|
|
1506
|
+
type FlowRun = {
|
|
1507
|
+
id: string;
|
|
1508
|
+
name: string;
|
|
1509
|
+
status: FlowRunStatus;
|
|
1510
|
+
inputs?: any;
|
|
1511
|
+
outputs?: any;
|
|
1512
|
+
steps?: FlowRunStep[];
|
|
1513
|
+
pendingStep?: FlowRunStep;
|
|
1514
|
+
createdAt?: Date;
|
|
1515
|
+
updatedAt?: Date;
|
|
1516
|
+
completedAt?: Date;
|
|
1517
|
+
};
|
|
1518
|
+
type FlowListOptions = {
|
|
1519
|
+
limit?: number;
|
|
1520
|
+
offset?: number;
|
|
1521
|
+
};
|
|
1522
|
+
type FlowListResult = {
|
|
1523
|
+
results: FlowRun[];
|
|
1524
|
+
pageInfo: {
|
|
1525
|
+
totalCount: number;
|
|
1526
|
+
hasNextPage: boolean;
|
|
1527
|
+
};
|
|
1528
|
+
};
|
|
1394
1529
|
|
|
1395
|
-
export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FuncWithConfig, type FunctionConfig, type Hardware, type IDWhereCondition, InlineFile, ModelAPI, NonRetriableError, type NullableHardware, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type Printer, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type Task, TaskAPI, type TaskCreateOptions, type TaskStatus, type TimestampQueryInput, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
|
|
1530
|
+
export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, type ExtractStageKeys, File, type FlowConfig, type FlowConfigAPI, type FlowContext, type FlowFunction, type FlowListOptions, type FlowListResult, type FlowRun, type FlowRunStatus, type FlowRunStep, FlowsAPI, type FuncWithConfig, type FunctionConfig, type Hardware, type IDWhereCondition, InlineFile, ModelAPI, NonRetriableError, type NullableHardware, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type Printer, type RelativeDateString, RequestHeaders, type Response, RetryBackoffExponential, RetryBackoffLinear, RetryConstant, STEP_STATUS, STEP_TYPE, type SortDirection, type Step, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type Task, TaskAPI, type TaskCreateOptions, type TaskStatus, type TimestampQueryInput, type UI, type UIApiResponses, checkBuiltInPermissions, createFlowContext, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
|
package/dist/index.js
CHANGED
|
@@ -1030,8 +1030,12 @@ var opMapping = {
|
|
|
1030
1030
|
onOrBefore: { op: "<=" },
|
|
1031
1031
|
after: { op: ">" },
|
|
1032
1032
|
onOrAfter: { op: ">=" },
|
|
1033
|
-
equals: {
|
|
1034
|
-
|
|
1033
|
+
equals: {
|
|
1034
|
+
op: /* @__PURE__ */ __name((v) => v === null || Array.isArray(v) ? sql2`is not distinct from` : "=", "op")
|
|
1035
|
+
},
|
|
1036
|
+
notEquals: {
|
|
1037
|
+
op: /* @__PURE__ */ __name((v) => v === null || Array.isArray(v) ? sql2`is distinct from` : "!=", "op")
|
|
1038
|
+
},
|
|
1035
1039
|
equalsRelative: {
|
|
1036
1040
|
op: sql2`BETWEEN`,
|
|
1037
1041
|
value: /* @__PURE__ */ __name((v) => sql2`${sql2.raw(
|
|
@@ -1086,7 +1090,8 @@ function applyWhereConditions(context6, qb, where = {}) {
|
|
|
1086
1090
|
}
|
|
1087
1091
|
const fieldName = `${context6.tableAlias()}.${snakeCase(key)}`;
|
|
1088
1092
|
if (Object.prototype.toString.call(v) !== "[object Object]") {
|
|
1089
|
-
|
|
1093
|
+
const operator = v === null || Array.isArray(v) ? sql2`is not distinct from` : "=";
|
|
1094
|
+
qb = qb.where(fieldName, operator, sql2`${v}`);
|
|
1090
1095
|
continue;
|
|
1091
1096
|
}
|
|
1092
1097
|
for (const op of Object.keys(v)) {
|
|
@@ -1103,9 +1108,10 @@ function applyWhereConditions(context6, qb, where = {}) {
|
|
|
1103
1108
|
);
|
|
1104
1109
|
}
|
|
1105
1110
|
} else {
|
|
1111
|
+
const operator = typeof mapping.op === "function" ? mapping.op(v[op]) : mapping.op;
|
|
1106
1112
|
qb = qb.where(
|
|
1107
1113
|
fieldName,
|
|
1108
|
-
|
|
1114
|
+
operator,
|
|
1109
1115
|
mapping.value ? mapping.value(v[op]) : sql2`${v[op]}`
|
|
1110
1116
|
);
|
|
1111
1117
|
}
|
|
@@ -2038,6 +2044,294 @@ var TaskAPI = class _TaskAPI {
|
|
|
2038
2044
|
}
|
|
2039
2045
|
};
|
|
2040
2046
|
|
|
2047
|
+
// src/FlowsAPI.js
|
|
2048
|
+
import jwt2 from "jsonwebtoken";
|
|
2049
|
+
function buildHeaders2(identity, authToken) {
|
|
2050
|
+
const headers = { "Content-Type": "application/json" };
|
|
2051
|
+
if (identity !== null) {
|
|
2052
|
+
const base64pk = process.env.KEEL_PRIVATE_KEY;
|
|
2053
|
+
let privateKey = void 0;
|
|
2054
|
+
if (base64pk) {
|
|
2055
|
+
privateKey = Buffer.from(base64pk, "base64").toString("utf8");
|
|
2056
|
+
}
|
|
2057
|
+
headers["Authorization"] = "Bearer " + jwt2.sign({}, privateKey, {
|
|
2058
|
+
algorithm: privateKey ? "RS256" : "none",
|
|
2059
|
+
expiresIn: 60 * 60 * 24,
|
|
2060
|
+
subject: identity.id,
|
|
2061
|
+
issuer: "https://keel.so"
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2064
|
+
if (authToken !== null) {
|
|
2065
|
+
headers["Authorization"] = "Bearer " + authToken;
|
|
2066
|
+
}
|
|
2067
|
+
return headers;
|
|
2068
|
+
}
|
|
2069
|
+
__name(buildHeaders2, "buildHeaders");
|
|
2070
|
+
function getApiUrl2() {
|
|
2071
|
+
const apiUrl = process.env.KEEL_API_URL;
|
|
2072
|
+
if (!apiUrl) {
|
|
2073
|
+
throw new Error("KEEL_API_URL environment variable is not set");
|
|
2074
|
+
}
|
|
2075
|
+
return apiUrl;
|
|
2076
|
+
}
|
|
2077
|
+
__name(getApiUrl2, "getApiUrl");
|
|
2078
|
+
var FlowRun = class _FlowRun {
|
|
2079
|
+
static {
|
|
2080
|
+
__name(this, "FlowRun");
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* @param {Object} data The flow run data from the API
|
|
2084
|
+
* @param {string} flowName The name of the flow
|
|
2085
|
+
* @param {Object|null} identity Optional identity object for authentication
|
|
2086
|
+
* @param {string|null} authToken Optional auth token for authentication
|
|
2087
|
+
*/
|
|
2088
|
+
constructor(data, flowName, identity = null, authToken = null) {
|
|
2089
|
+
this.id = data.id;
|
|
2090
|
+
this.name = data.name;
|
|
2091
|
+
this.status = data.status;
|
|
2092
|
+
this.inputs = data.inputs;
|
|
2093
|
+
this.outputs = data.outputs;
|
|
2094
|
+
this.steps = data.steps;
|
|
2095
|
+
this.pendingStep = data.pendingStep;
|
|
2096
|
+
this.createdAt = data.createdAt ? new Date(data.createdAt) : void 0;
|
|
2097
|
+
this.updatedAt = data.updatedAt ? new Date(data.updatedAt) : void 0;
|
|
2098
|
+
this.completedAt = data.completedAt ? new Date(data.completedAt) : void 0;
|
|
2099
|
+
this._flowName = flowName;
|
|
2100
|
+
this._identity = identity;
|
|
2101
|
+
this._authToken = authToken;
|
|
2102
|
+
}
|
|
2103
|
+
/**
|
|
2104
|
+
* Returns a new FlowRun instance that will use the given identity for authentication.
|
|
2105
|
+
* @param {Object} identity The identity object
|
|
2106
|
+
* @returns {FlowRun} A new FlowRun instance with the identity set
|
|
2107
|
+
*/
|
|
2108
|
+
withIdentity(identity) {
|
|
2109
|
+
const data = this._toApiData();
|
|
2110
|
+
return new _FlowRun(data, this._flowName, identity, null);
|
|
2111
|
+
}
|
|
2112
|
+
/**
|
|
2113
|
+
* Returns a new FlowRun instance that will use the given auth token for authentication.
|
|
2114
|
+
* @param {string} token The auth token to use
|
|
2115
|
+
* @returns {FlowRun} A new FlowRun instance with the auth token set
|
|
2116
|
+
*/
|
|
2117
|
+
withAuthToken(token) {
|
|
2118
|
+
const data = this._toApiData();
|
|
2119
|
+
return new _FlowRun(data, this._flowName, null, token);
|
|
2120
|
+
}
|
|
2121
|
+
/**
|
|
2122
|
+
* Converts the flow run back to API data format for creating new instances.
|
|
2123
|
+
* @returns {Object} The flow run data in API format
|
|
2124
|
+
*/
|
|
2125
|
+
_toApiData() {
|
|
2126
|
+
return {
|
|
2127
|
+
id: this.id,
|
|
2128
|
+
name: this.name,
|
|
2129
|
+
status: this.status,
|
|
2130
|
+
inputs: this.inputs,
|
|
2131
|
+
outputs: this.outputs,
|
|
2132
|
+
steps: this.steps,
|
|
2133
|
+
pendingStep: this.pendingStep,
|
|
2134
|
+
createdAt: this.createdAt?.toISOString(),
|
|
2135
|
+
updatedAt: this.updatedAt?.toISOString(),
|
|
2136
|
+
completedAt: this.completedAt?.toISOString()
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* Refreshes the flow run state from the API.
|
|
2141
|
+
* @returns {Promise<FlowRun>} The updated flow run
|
|
2142
|
+
*/
|
|
2143
|
+
async refresh() {
|
|
2144
|
+
const name = spanNameForModelAPI(this._flowName, "refresh");
|
|
2145
|
+
return withSpan(name, async () => {
|
|
2146
|
+
const apiUrl = getApiUrl2();
|
|
2147
|
+
const url = `${apiUrl}/flows/json/${this._flowName}/${this.id}`;
|
|
2148
|
+
const response = await fetch(url, {
|
|
2149
|
+
method: "GET",
|
|
2150
|
+
headers: buildHeaders2(this._identity, this._authToken)
|
|
2151
|
+
});
|
|
2152
|
+
if (!response.ok) {
|
|
2153
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
2154
|
+
throw new Error(
|
|
2155
|
+
`Failed to refresh flow run: ${response.status} ${response.statusText} - ${errorBody.message || JSON.stringify(errorBody)}`
|
|
2156
|
+
);
|
|
2157
|
+
}
|
|
2158
|
+
const result = await response.json();
|
|
2159
|
+
return new _FlowRun(
|
|
2160
|
+
result,
|
|
2161
|
+
this._flowName,
|
|
2162
|
+
this._identity,
|
|
2163
|
+
this._authToken
|
|
2164
|
+
);
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
/**
|
|
2168
|
+
* Cancels the flow run.
|
|
2169
|
+
* @returns {Promise<FlowRun>} The updated flow run
|
|
2170
|
+
*/
|
|
2171
|
+
async cancel() {
|
|
2172
|
+
const name = spanNameForModelAPI(this._flowName, "cancel");
|
|
2173
|
+
return withSpan(name, async () => {
|
|
2174
|
+
const apiUrl = getApiUrl2();
|
|
2175
|
+
const url = `${apiUrl}/flows/json/${this._flowName}/${this.id}/cancel`;
|
|
2176
|
+
const response = await fetch(url, {
|
|
2177
|
+
method: "POST",
|
|
2178
|
+
headers: buildHeaders2(this._identity, this._authToken)
|
|
2179
|
+
});
|
|
2180
|
+
if (!response.ok) {
|
|
2181
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
2182
|
+
throw new Error(
|
|
2183
|
+
`Failed to cancel flow run: ${response.status} ${response.statusText} - ${errorBody.message || JSON.stringify(errorBody)}`
|
|
2184
|
+
);
|
|
2185
|
+
}
|
|
2186
|
+
const result = await response.json();
|
|
2187
|
+
return new _FlowRun(
|
|
2188
|
+
result,
|
|
2189
|
+
this._flowName,
|
|
2190
|
+
this._identity,
|
|
2191
|
+
this._authToken
|
|
2192
|
+
);
|
|
2193
|
+
});
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2196
|
+
var FlowsAPI = class _FlowsAPI {
|
|
2197
|
+
static {
|
|
2198
|
+
__name(this, "FlowsAPI");
|
|
2199
|
+
}
|
|
2200
|
+
/**
|
|
2201
|
+
* @param {string} flowName The name of the flow
|
|
2202
|
+
* @param {Object|null} identity Optional identity object for authentication
|
|
2203
|
+
* @param {string|null} authToken Optional auth token for authentication
|
|
2204
|
+
*/
|
|
2205
|
+
constructor(flowName, identity = null, authToken = null) {
|
|
2206
|
+
this._flowName = flowName;
|
|
2207
|
+
this._identity = identity;
|
|
2208
|
+
this._authToken = authToken;
|
|
2209
|
+
}
|
|
2210
|
+
/**
|
|
2211
|
+
* Returns a new FlowsAPI instance that will use the given identity for authentication.
|
|
2212
|
+
* @param {Object} identity The identity object
|
|
2213
|
+
* @returns {FlowsAPI} A new FlowsAPI instance with the identity set
|
|
2214
|
+
*/
|
|
2215
|
+
withIdentity(identity) {
|
|
2216
|
+
return new _FlowsAPI(this._flowName, identity, null);
|
|
2217
|
+
}
|
|
2218
|
+
/**
|
|
2219
|
+
* Returns a new FlowsAPI instance that will use the given auth token for authentication.
|
|
2220
|
+
* @param {string} token The auth token to use
|
|
2221
|
+
* @returns {FlowsAPI} A new FlowsAPI instance with the auth token set
|
|
2222
|
+
*/
|
|
2223
|
+
withAuthToken(token) {
|
|
2224
|
+
return new _FlowsAPI(this._flowName, null, token);
|
|
2225
|
+
}
|
|
2226
|
+
/**
|
|
2227
|
+
* Starts a new flow run with the given inputs.
|
|
2228
|
+
* @param {Object} inputs The flow input data
|
|
2229
|
+
* @returns {Promise<FlowRun>} The created flow run
|
|
2230
|
+
*/
|
|
2231
|
+
async start(inputs = {}) {
|
|
2232
|
+
const name = spanNameForModelAPI(this._flowName, "start");
|
|
2233
|
+
return withSpan(name, async () => {
|
|
2234
|
+
const apiUrl = getApiUrl2();
|
|
2235
|
+
const url = `${apiUrl}/flows/json/${this._flowName}`;
|
|
2236
|
+
const response = await fetch(url, {
|
|
2237
|
+
method: "POST",
|
|
2238
|
+
headers: buildHeaders2(this._identity, this._authToken),
|
|
2239
|
+
body: JSON.stringify(inputs)
|
|
2240
|
+
});
|
|
2241
|
+
if (!response.ok) {
|
|
2242
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
2243
|
+
throw new Error(
|
|
2244
|
+
`Failed to start flow: ${response.status} ${response.statusText} - ${errorBody.message || JSON.stringify(errorBody)}`
|
|
2245
|
+
);
|
|
2246
|
+
}
|
|
2247
|
+
const result = await response.json();
|
|
2248
|
+
return new FlowRun(
|
|
2249
|
+
result,
|
|
2250
|
+
this._flowName,
|
|
2251
|
+
this._identity,
|
|
2252
|
+
this._authToken
|
|
2253
|
+
);
|
|
2254
|
+
});
|
|
2255
|
+
}
|
|
2256
|
+
/**
|
|
2257
|
+
* Gets a flow run by ID.
|
|
2258
|
+
* @param {string} runId The flow run ID
|
|
2259
|
+
* @returns {Promise<FlowRun>} The flow run
|
|
2260
|
+
*/
|
|
2261
|
+
async get(runId) {
|
|
2262
|
+
const name = spanNameForModelAPI(this._flowName, "get");
|
|
2263
|
+
return withSpan(name, async () => {
|
|
2264
|
+
const apiUrl = getApiUrl2();
|
|
2265
|
+
const url = `${apiUrl}/flows/json/${this._flowName}/${runId}`;
|
|
2266
|
+
const response = await fetch(url, {
|
|
2267
|
+
method: "GET",
|
|
2268
|
+
headers: buildHeaders2(this._identity, this._authToken)
|
|
2269
|
+
});
|
|
2270
|
+
if (!response.ok) {
|
|
2271
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
2272
|
+
throw new Error(
|
|
2273
|
+
`Failed to get flow run: ${response.status} ${response.statusText} - ${errorBody.message || JSON.stringify(errorBody)}`
|
|
2274
|
+
);
|
|
2275
|
+
}
|
|
2276
|
+
const result = await response.json();
|
|
2277
|
+
return new FlowRun(
|
|
2278
|
+
result,
|
|
2279
|
+
this._flowName,
|
|
2280
|
+
this._identity,
|
|
2281
|
+
this._authToken
|
|
2282
|
+
);
|
|
2283
|
+
});
|
|
2284
|
+
}
|
|
2285
|
+
/**
|
|
2286
|
+
* Lists flow runs for this flow.
|
|
2287
|
+
* @param {Object} options Optional pagination options
|
|
2288
|
+
* @param {number} options.limit Maximum number of runs to return
|
|
2289
|
+
* @param {number} options.offset Offset for pagination
|
|
2290
|
+
* @returns {Promise<{results: FlowRun[], pageInfo: Object}>} List of flow runs with pagination info
|
|
2291
|
+
*/
|
|
2292
|
+
async list(options = {}) {
|
|
2293
|
+
const name = spanNameForModelAPI(this._flowName, "list");
|
|
2294
|
+
return withSpan(name, async () => {
|
|
2295
|
+
const apiUrl = getApiUrl2();
|
|
2296
|
+
const params = new URLSearchParams();
|
|
2297
|
+
if (options.limit) params.set("limit", options.limit.toString());
|
|
2298
|
+
if (options.offset) params.set("offset", options.offset.toString());
|
|
2299
|
+
const url = `${apiUrl}/flows/json/${this._flowName}${params.toString() ? "?" + params.toString() : ""}`;
|
|
2300
|
+
const response = await fetch(url, {
|
|
2301
|
+
method: "GET",
|
|
2302
|
+
headers: buildHeaders2(this._identity, this._authToken)
|
|
2303
|
+
});
|
|
2304
|
+
if (!response.ok) {
|
|
2305
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
2306
|
+
throw new Error(
|
|
2307
|
+
`Failed to list flow runs: ${response.status} ${response.statusText} - ${errorBody.message || JSON.stringify(errorBody)}`
|
|
2308
|
+
);
|
|
2309
|
+
}
|
|
2310
|
+
const result = await response.json();
|
|
2311
|
+
if (Array.isArray(result)) {
|
|
2312
|
+
return {
|
|
2313
|
+
results: result.map(
|
|
2314
|
+
(run) => new FlowRun(run, this._flowName, this._identity, this._authToken)
|
|
2315
|
+
),
|
|
2316
|
+
pageInfo: {
|
|
2317
|
+
totalCount: result.length,
|
|
2318
|
+
hasNextPage: false
|
|
2319
|
+
}
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2322
|
+
return {
|
|
2323
|
+
results: (result.results || []).map(
|
|
2324
|
+
(run) => new FlowRun(run, this._flowName, this._identity, this._authToken)
|
|
2325
|
+
),
|
|
2326
|
+
pageInfo: result.pageInfo || {
|
|
2327
|
+
totalCount: (result.results || []).length,
|
|
2328
|
+
hasNextPage: false
|
|
2329
|
+
}
|
|
2330
|
+
};
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
};
|
|
2334
|
+
|
|
2041
2335
|
// src/RequestHeaders.ts
|
|
2042
2336
|
var RequestHeaders = class {
|
|
2043
2337
|
/**
|
|
@@ -2215,6 +2509,9 @@ __name(tryExecuteFunction, "tryExecuteFunction");
|
|
|
2215
2509
|
// src/handleRequest.js
|
|
2216
2510
|
import * as opentelemetry2 from "@opentelemetry/api";
|
|
2217
2511
|
async function handleRequest(request, config) {
|
|
2512
|
+
if (request.method === "__ping") {
|
|
2513
|
+
return createJSONRPCSuccessResponse(request.id, { status: "ok" });
|
|
2514
|
+
}
|
|
2218
2515
|
const activeContext = opentelemetry2.propagation.extract(
|
|
2219
2516
|
opentelemetry2.context.active(),
|
|
2220
2517
|
request.meta?.tracing
|
|
@@ -3837,6 +4134,7 @@ export {
|
|
|
3837
4134
|
Duration,
|
|
3838
4135
|
ErrorPresets,
|
|
3839
4136
|
File,
|
|
4137
|
+
FlowsAPI,
|
|
3840
4138
|
InlineFile,
|
|
3841
4139
|
KSUID2 as KSUID,
|
|
3842
4140
|
ModelAPI,
|