@upstash/workflow 0.2.8-rc-invoke → 0.2.8
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/astro.d.mts +3 -8
- package/astro.d.ts +3 -8
- package/astro.js +75 -239
- package/astro.mjs +7 -33
- package/{chunk-IWAW7GIG.mjs → chunk-BPUSHNSD.mjs} +171 -195
- package/cloudflare.d.mts +4 -9
- package/cloudflare.d.ts +4 -9
- package/cloudflare.js +81 -242
- package/cloudflare.mjs +13 -36
- package/express.d.mts +3 -7
- package/express.d.ts +3 -7
- package/express.js +78 -249
- package/express.mjs +10 -41
- package/h3.d.mts +7 -9
- package/h3.d.ts +7 -9
- package/h3.js +88 -250
- package/h3.mjs +20 -44
- package/hono.d.mts +4 -10
- package/hono.d.ts +4 -10
- package/hono.js +83 -241
- package/hono.mjs +15 -35
- package/index.d.mts +267 -18
- package/index.d.ts +267 -18
- package/index.js +133 -102
- package/index.mjs +56 -1
- package/nextjs.d.mts +5 -14
- package/nextjs.d.ts +5 -14
- package/nextjs.js +62 -250
- package/nextjs.mjs +16 -64
- package/package.json +1 -1
- package/solidjs.d.mts +3 -3
- package/solidjs.d.ts +3 -3
- package/solidjs.js +56 -108
- package/solidjs.mjs +10 -7
- package/svelte.d.mts +4 -12
- package/svelte.d.ts +4 -12
- package/svelte.js +81 -241
- package/svelte.mjs +13 -35
- package/{types-C7Y7WUQd.d.mts → types-B62AnIU3.d.mts} +59 -33
- package/{types-C7Y7WUQd.d.ts → types-B62AnIU3.d.ts} +59 -33
- package/chunk-LCZMBGEM.mjs +0 -95
- package/serve-many-BlBvXfBS.d.mts +0 -10
- package/serve-many-Dw-UUnH6.d.ts +0 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublishRequest, Client, Receiver, HTTPMethods as HTTPMethods$1 } from '@upstash/qstash';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { ZodType, z } from 'zod';
|
|
3
3
|
import * as ai from 'ai';
|
|
4
4
|
import { CoreTool, generateText } from 'ai';
|
|
5
5
|
import * as _ai_sdk_openai from '@ai-sdk/openai';
|
|
@@ -33,11 +33,6 @@ declare abstract class BaseLazyStep<TResult = unknown> {
|
|
|
33
33
|
*/
|
|
34
34
|
abstract getResultStep(concurrent: number, stepId: number): Promise<Step<TResult>>;
|
|
35
35
|
}
|
|
36
|
-
type LazyInvokeStepParams<TInitiaPayload, TResult> = {
|
|
37
|
-
workflow: Pick<InvokableWorkflow<TInitiaPayload, TResult, unknown[]>, "callback" | "workflowId">;
|
|
38
|
-
body: TInitiaPayload;
|
|
39
|
-
workflowRunId?: string;
|
|
40
|
-
} & Pick<CallSettings, "retries" | "headers">;
|
|
41
36
|
|
|
42
37
|
declare const LOG_LEVELS: readonly ["DEBUG", "INFO", "SUBMIT", "WARN", "ERROR"];
|
|
43
38
|
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
@@ -408,6 +403,60 @@ declare const createWorkflowOpenAI: (context: WorkflowContext, config?: {
|
|
|
408
403
|
baseURL?: string;
|
|
409
404
|
apiKey?: string;
|
|
410
405
|
}) => _ai_sdk_openai.OpenAIProvider;
|
|
406
|
+
declare class WorkflowTool<TSchema extends ZodType = ZodType> implements LangchainTool {
|
|
407
|
+
/**
|
|
408
|
+
* description of the tool
|
|
409
|
+
*/
|
|
410
|
+
readonly description: string;
|
|
411
|
+
/**
|
|
412
|
+
* schema of the tool
|
|
413
|
+
*/
|
|
414
|
+
readonly schema: TSchema;
|
|
415
|
+
/**
|
|
416
|
+
* function to invoke the tool
|
|
417
|
+
*/
|
|
418
|
+
readonly invoke: (params: z.infer<TSchema>) => any;
|
|
419
|
+
/**
|
|
420
|
+
* whether the invoke method of the tool is to be wrapped with `context.run`
|
|
421
|
+
*/
|
|
422
|
+
readonly executeAsStep: boolean;
|
|
423
|
+
/**
|
|
424
|
+
*
|
|
425
|
+
* @param description description of the tool
|
|
426
|
+
* @param schema schema of the tool
|
|
427
|
+
* @param invoke function to invoke the tool
|
|
428
|
+
* @param executeAsStep whether the invoke method of the tool is to be wrapped with `context.run`
|
|
429
|
+
*/
|
|
430
|
+
constructor(params: {
|
|
431
|
+
/**
|
|
432
|
+
* description of the tool
|
|
433
|
+
*/
|
|
434
|
+
description: string;
|
|
435
|
+
/**
|
|
436
|
+
* schema of the tool
|
|
437
|
+
*/
|
|
438
|
+
schema: TSchema;
|
|
439
|
+
/**
|
|
440
|
+
* invoke function to invoke the tool
|
|
441
|
+
*/
|
|
442
|
+
invoke: (params: z.infer<TSchema>) => any;
|
|
443
|
+
/**
|
|
444
|
+
* whether the invoke method is to be wrapped with `context.run`.
|
|
445
|
+
*
|
|
446
|
+
* When you pass a LangChain, AI SDK tool or a WorkflowTool to your agent,
|
|
447
|
+
* the execute/invoke method of the tool is wrapped with `context.run` by default.
|
|
448
|
+
*
|
|
449
|
+
* This option allows you to disable this behavior.
|
|
450
|
+
*
|
|
451
|
+
* You may want to disable wrapping with context.run if you want to run context.run,
|
|
452
|
+
* context.call or any other workflow step yourself in the execute/invoke method
|
|
453
|
+
* of the tool.
|
|
454
|
+
*
|
|
455
|
+
* @default true
|
|
456
|
+
*/
|
|
457
|
+
executeAsStep?: boolean;
|
|
458
|
+
});
|
|
459
|
+
}
|
|
411
460
|
|
|
412
461
|
type AISDKTool = CoreTool;
|
|
413
462
|
type LangchainTool = {
|
|
@@ -417,7 +466,7 @@ type LangchainTool = {
|
|
|
417
466
|
};
|
|
418
467
|
type GenerateTextParams = Parameters<typeof generateText>[0];
|
|
419
468
|
type Model = GenerateTextParams["model"];
|
|
420
|
-
type AgentParameters<TTool extends AISDKTool | LangchainTool = AISDKTool> = {
|
|
469
|
+
type AgentParameters<TTool extends AISDKTool | LangchainTool | WorkflowTool = AISDKTool> = {
|
|
421
470
|
/**
|
|
422
471
|
* number of times the agent can call the LLM at most. If
|
|
423
472
|
* the agent abruptly stops execution after calling tools, you may need
|
|
@@ -922,11 +971,6 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
922
971
|
* @returns notify response which has event id, event data and list of waiters which were notified
|
|
923
972
|
*/
|
|
924
973
|
notify(stepName: string, eventId: string, eventData: unknown): Promise<NotifyStepResponse>;
|
|
925
|
-
invoke<TInitialPayload, TResult>(stepName: string, settings: LazyInvokeStepParams<TInitialPayload, TResult>): Promise<{
|
|
926
|
-
body: any;
|
|
927
|
-
isCanceled?: boolean;
|
|
928
|
-
isFailed?: boolean;
|
|
929
|
-
}>;
|
|
930
974
|
/**
|
|
931
975
|
* Cancel the current workflow run
|
|
932
976
|
*
|
|
@@ -962,7 +1006,7 @@ type WorkflowClient = {
|
|
|
962
1006
|
type WorkflowReceiver = {
|
|
963
1007
|
verify: InstanceType<typeof Receiver>["verify"];
|
|
964
1008
|
};
|
|
965
|
-
declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call", "Wait", "Notify"
|
|
1009
|
+
declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call", "Wait", "Notify"];
|
|
966
1010
|
type StepType = (typeof StepTypes)[number];
|
|
967
1011
|
type ThirdPartyCallFields<TBody = unknown> = {
|
|
968
1012
|
/**
|
|
@@ -1045,7 +1089,7 @@ type SyncStepFunction<TResult> = () => TResult;
|
|
|
1045
1089
|
type AsyncStepFunction<TResult> = () => Promise<TResult>;
|
|
1046
1090
|
type StepFunction<TResult> = AsyncStepFunction<TResult> | SyncStepFunction<TResult>;
|
|
1047
1091
|
type ParallelCallState = "first" | "partial" | "discard" | "last";
|
|
1048
|
-
type RouteFunction<TInitialPayload
|
|
1092
|
+
type RouteFunction<TInitialPayload> = (context: WorkflowContext<TInitialPayload>) => Promise<void>;
|
|
1049
1093
|
type FinishCondition = "success" | "duplicate-step" | "fromCallback" | "auth-fail" | "failure-callback" | "workflow-already-ended";
|
|
1050
1094
|
type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload = unknown> = ValidationOptions<TInitialPayload> & {
|
|
1051
1095
|
/**
|
|
@@ -1322,23 +1366,5 @@ type HeaderParams = {
|
|
|
1322
1366
|
*/
|
|
1323
1367
|
callTimeout?: never;
|
|
1324
1368
|
});
|
|
1325
|
-
type InvokeWorkflowRequest = {
|
|
1326
|
-
workflowUrl: string;
|
|
1327
|
-
workflowRunId: string;
|
|
1328
|
-
headers: Record<string, string[]>;
|
|
1329
|
-
step: Step;
|
|
1330
|
-
body: string;
|
|
1331
|
-
};
|
|
1332
|
-
type InvokeStepResponse<TBody> = {
|
|
1333
|
-
body: TBody;
|
|
1334
|
-
isCanceled?: boolean;
|
|
1335
|
-
isFailed?: boolean;
|
|
1336
|
-
};
|
|
1337
|
-
type InvokeCallback<TInitiaPayload, TResult> = (settings: LazyInvokeStepParams<TInitiaPayload, TResult>, invokeStep: Step, context: WorkflowContext) => Promise<TResult>;
|
|
1338
|
-
type InvokableWorkflow<TInitialPayload, TResult, THandlerParams extends unknown[]> = {
|
|
1339
|
-
handler: (...args: THandlerParams) => any;
|
|
1340
|
-
callback: InvokeCallback<TInitialPayload, TResult>;
|
|
1341
|
-
workflowId?: string;
|
|
1342
|
-
};
|
|
1343
1369
|
|
|
1344
|
-
export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type
|
|
1370
|
+
export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type LogLevel as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, type Step as c, WorkflowTool as d, WorkflowContext as e, type WorkflowClient as f, type WorkflowReceiver as g, StepTypes as h, type SyncStepFunction as i, type StepFunction as j, type PublicServeOptions as k, type FailureFunctionPayload as l, type RequiredExceptFields as m, type WaitRequest as n, type WaitStepResponse as o, type NotifyStepResponse as p, type WaitEventOptions as q, type CallSettings as r, type WorkflowLoggerOptions as s, WorkflowLogger as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublishRequest, Client, Receiver, HTTPMethods as HTTPMethods$1 } from '@upstash/qstash';
|
|
2
|
-
import { z } from 'zod';
|
|
2
|
+
import { ZodType, z } from 'zod';
|
|
3
3
|
import * as ai from 'ai';
|
|
4
4
|
import { CoreTool, generateText } from 'ai';
|
|
5
5
|
import * as _ai_sdk_openai from '@ai-sdk/openai';
|
|
@@ -33,11 +33,6 @@ declare abstract class BaseLazyStep<TResult = unknown> {
|
|
|
33
33
|
*/
|
|
34
34
|
abstract getResultStep(concurrent: number, stepId: number): Promise<Step<TResult>>;
|
|
35
35
|
}
|
|
36
|
-
type LazyInvokeStepParams<TInitiaPayload, TResult> = {
|
|
37
|
-
workflow: Pick<InvokableWorkflow<TInitiaPayload, TResult, unknown[]>, "callback" | "workflowId">;
|
|
38
|
-
body: TInitiaPayload;
|
|
39
|
-
workflowRunId?: string;
|
|
40
|
-
} & Pick<CallSettings, "retries" | "headers">;
|
|
41
36
|
|
|
42
37
|
declare const LOG_LEVELS: readonly ["DEBUG", "INFO", "SUBMIT", "WARN", "ERROR"];
|
|
43
38
|
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
@@ -408,6 +403,60 @@ declare const createWorkflowOpenAI: (context: WorkflowContext, config?: {
|
|
|
408
403
|
baseURL?: string;
|
|
409
404
|
apiKey?: string;
|
|
410
405
|
}) => _ai_sdk_openai.OpenAIProvider;
|
|
406
|
+
declare class WorkflowTool<TSchema extends ZodType = ZodType> implements LangchainTool {
|
|
407
|
+
/**
|
|
408
|
+
* description of the tool
|
|
409
|
+
*/
|
|
410
|
+
readonly description: string;
|
|
411
|
+
/**
|
|
412
|
+
* schema of the tool
|
|
413
|
+
*/
|
|
414
|
+
readonly schema: TSchema;
|
|
415
|
+
/**
|
|
416
|
+
* function to invoke the tool
|
|
417
|
+
*/
|
|
418
|
+
readonly invoke: (params: z.infer<TSchema>) => any;
|
|
419
|
+
/**
|
|
420
|
+
* whether the invoke method of the tool is to be wrapped with `context.run`
|
|
421
|
+
*/
|
|
422
|
+
readonly executeAsStep: boolean;
|
|
423
|
+
/**
|
|
424
|
+
*
|
|
425
|
+
* @param description description of the tool
|
|
426
|
+
* @param schema schema of the tool
|
|
427
|
+
* @param invoke function to invoke the tool
|
|
428
|
+
* @param executeAsStep whether the invoke method of the tool is to be wrapped with `context.run`
|
|
429
|
+
*/
|
|
430
|
+
constructor(params: {
|
|
431
|
+
/**
|
|
432
|
+
* description of the tool
|
|
433
|
+
*/
|
|
434
|
+
description: string;
|
|
435
|
+
/**
|
|
436
|
+
* schema of the tool
|
|
437
|
+
*/
|
|
438
|
+
schema: TSchema;
|
|
439
|
+
/**
|
|
440
|
+
* invoke function to invoke the tool
|
|
441
|
+
*/
|
|
442
|
+
invoke: (params: z.infer<TSchema>) => any;
|
|
443
|
+
/**
|
|
444
|
+
* whether the invoke method is to be wrapped with `context.run`.
|
|
445
|
+
*
|
|
446
|
+
* When you pass a LangChain, AI SDK tool or a WorkflowTool to your agent,
|
|
447
|
+
* the execute/invoke method of the tool is wrapped with `context.run` by default.
|
|
448
|
+
*
|
|
449
|
+
* This option allows you to disable this behavior.
|
|
450
|
+
*
|
|
451
|
+
* You may want to disable wrapping with context.run if you want to run context.run,
|
|
452
|
+
* context.call or any other workflow step yourself in the execute/invoke method
|
|
453
|
+
* of the tool.
|
|
454
|
+
*
|
|
455
|
+
* @default true
|
|
456
|
+
*/
|
|
457
|
+
executeAsStep?: boolean;
|
|
458
|
+
});
|
|
459
|
+
}
|
|
411
460
|
|
|
412
461
|
type AISDKTool = CoreTool;
|
|
413
462
|
type LangchainTool = {
|
|
@@ -417,7 +466,7 @@ type LangchainTool = {
|
|
|
417
466
|
};
|
|
418
467
|
type GenerateTextParams = Parameters<typeof generateText>[0];
|
|
419
468
|
type Model = GenerateTextParams["model"];
|
|
420
|
-
type AgentParameters<TTool extends AISDKTool | LangchainTool = AISDKTool> = {
|
|
469
|
+
type AgentParameters<TTool extends AISDKTool | LangchainTool | WorkflowTool = AISDKTool> = {
|
|
421
470
|
/**
|
|
422
471
|
* number of times the agent can call the LLM at most. If
|
|
423
472
|
* the agent abruptly stops execution after calling tools, you may need
|
|
@@ -922,11 +971,6 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
922
971
|
* @returns notify response which has event id, event data and list of waiters which were notified
|
|
923
972
|
*/
|
|
924
973
|
notify(stepName: string, eventId: string, eventData: unknown): Promise<NotifyStepResponse>;
|
|
925
|
-
invoke<TInitialPayload, TResult>(stepName: string, settings: LazyInvokeStepParams<TInitialPayload, TResult>): Promise<{
|
|
926
|
-
body: any;
|
|
927
|
-
isCanceled?: boolean;
|
|
928
|
-
isFailed?: boolean;
|
|
929
|
-
}>;
|
|
930
974
|
/**
|
|
931
975
|
* Cancel the current workflow run
|
|
932
976
|
*
|
|
@@ -962,7 +1006,7 @@ type WorkflowClient = {
|
|
|
962
1006
|
type WorkflowReceiver = {
|
|
963
1007
|
verify: InstanceType<typeof Receiver>["verify"];
|
|
964
1008
|
};
|
|
965
|
-
declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call", "Wait", "Notify"
|
|
1009
|
+
declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call", "Wait", "Notify"];
|
|
966
1010
|
type StepType = (typeof StepTypes)[number];
|
|
967
1011
|
type ThirdPartyCallFields<TBody = unknown> = {
|
|
968
1012
|
/**
|
|
@@ -1045,7 +1089,7 @@ type SyncStepFunction<TResult> = () => TResult;
|
|
|
1045
1089
|
type AsyncStepFunction<TResult> = () => Promise<TResult>;
|
|
1046
1090
|
type StepFunction<TResult> = AsyncStepFunction<TResult> | SyncStepFunction<TResult>;
|
|
1047
1091
|
type ParallelCallState = "first" | "partial" | "discard" | "last";
|
|
1048
|
-
type RouteFunction<TInitialPayload
|
|
1092
|
+
type RouteFunction<TInitialPayload> = (context: WorkflowContext<TInitialPayload>) => Promise<void>;
|
|
1049
1093
|
type FinishCondition = "success" | "duplicate-step" | "fromCallback" | "auth-fail" | "failure-callback" | "workflow-already-ended";
|
|
1050
1094
|
type WorkflowServeOptions<TResponse extends Response = Response, TInitialPayload = unknown> = ValidationOptions<TInitialPayload> & {
|
|
1051
1095
|
/**
|
|
@@ -1322,23 +1366,5 @@ type HeaderParams = {
|
|
|
1322
1366
|
*/
|
|
1323
1367
|
callTimeout?: never;
|
|
1324
1368
|
});
|
|
1325
|
-
type InvokeWorkflowRequest = {
|
|
1326
|
-
workflowUrl: string;
|
|
1327
|
-
workflowRunId: string;
|
|
1328
|
-
headers: Record<string, string[]>;
|
|
1329
|
-
step: Step;
|
|
1330
|
-
body: string;
|
|
1331
|
-
};
|
|
1332
|
-
type InvokeStepResponse<TBody> = {
|
|
1333
|
-
body: TBody;
|
|
1334
|
-
isCanceled?: boolean;
|
|
1335
|
-
isFailed?: boolean;
|
|
1336
|
-
};
|
|
1337
|
-
type InvokeCallback<TInitiaPayload, TResult> = (settings: LazyInvokeStepParams<TInitiaPayload, TResult>, invokeStep: Step, context: WorkflowContext) => Promise<TResult>;
|
|
1338
|
-
type InvokableWorkflow<TInitialPayload, TResult, THandlerParams extends unknown[]> = {
|
|
1339
|
-
handler: (...args: THandlerParams) => any;
|
|
1340
|
-
callback: InvokeCallback<TInitialPayload, TResult>;
|
|
1341
|
-
workflowId?: string;
|
|
1342
|
-
};
|
|
1343
1369
|
|
|
1344
|
-
export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type
|
|
1370
|
+
export { type AsyncStepFunction as A, type CallResponse as C, type Duration as D, type ExclusiveValidationOptions as E, type FinishCondition as F, type HeaderParams as H, type LogLevel as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type StepType as S, type Telemetry as T, type WorkflowServeOptions as W, type RawStep as a, type Waiter as b, type Step as c, WorkflowTool as d, WorkflowContext as e, type WorkflowClient as f, type WorkflowReceiver as g, StepTypes as h, type SyncStepFunction as i, type StepFunction as j, type PublicServeOptions as k, type FailureFunctionPayload as l, type RequiredExceptFields as m, type WaitRequest as n, type WaitStepResponse as o, type NotifyStepResponse as p, type WaitEventOptions as q, type CallSettings as r, type WorkflowLoggerOptions as s, WorkflowLogger as t };
|
package/chunk-LCZMBGEM.mjs
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WorkflowError,
|
|
3
|
-
getHeaders,
|
|
4
|
-
getWorkflowRunId
|
|
5
|
-
} from "./chunk-IWAW7GIG.mjs";
|
|
6
|
-
|
|
7
|
-
// src/serve/serve-many.ts
|
|
8
|
-
var serveManyBase = ({
|
|
9
|
-
workflows,
|
|
10
|
-
getWorkflowId
|
|
11
|
-
}) => {
|
|
12
|
-
const workflowIds = [];
|
|
13
|
-
const workflowMap = Object.fromEntries(
|
|
14
|
-
Object.entries(workflows).map((workflow) => {
|
|
15
|
-
const workflowId = workflow[0];
|
|
16
|
-
if (workflowIds.includes(workflowId)) {
|
|
17
|
-
throw new WorkflowError(
|
|
18
|
-
`Duplicate workflow name found: '${workflowId}'. Please set different workflow names in serveMany.`
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
if (workflowId.includes("/")) {
|
|
22
|
-
throw new WorkflowError(
|
|
23
|
-
`Invalid workflow name found: '${workflowId}'. Workflow name cannot contain '/'.`
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
workflowIds.push(workflowId);
|
|
27
|
-
workflow[1].workflowId = workflowId;
|
|
28
|
-
return [workflowId, workflow[1].handler];
|
|
29
|
-
})
|
|
30
|
-
);
|
|
31
|
-
return {
|
|
32
|
-
handler: async (...params) => {
|
|
33
|
-
const pickedWorkflowId = getWorkflowId(...params);
|
|
34
|
-
if (!pickedWorkflowId) {
|
|
35
|
-
throw new WorkflowError(`Unexpected request in serveMany. workflowId not set. Please update the URL of your request.`);
|
|
36
|
-
}
|
|
37
|
-
const workflow = workflowMap[pickedWorkflowId];
|
|
38
|
-
if (!workflow) {
|
|
39
|
-
throw new WorkflowError(`No workflows in serveMany found for '${pickedWorkflowId}'. Please update the URL of your request.`);
|
|
40
|
-
}
|
|
41
|
-
return await workflow(...params);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
var createInvokeCallback = (telemetry) => {
|
|
46
|
-
const invokeCallback = async (settings, invokeStep, context) => {
|
|
47
|
-
const { body, workflow, headers = {}, workflowRunId = getWorkflowRunId(), retries } = settings;
|
|
48
|
-
const { workflowId } = workflow;
|
|
49
|
-
if (!workflowId) {
|
|
50
|
-
throw new WorkflowError("You can only invoke workflow which has a workflowId");
|
|
51
|
-
}
|
|
52
|
-
const { headers: invokerHeaders } = getHeaders({
|
|
53
|
-
initHeaderValue: "false",
|
|
54
|
-
workflowRunId: context.workflowRunId,
|
|
55
|
-
workflowUrl: context.url,
|
|
56
|
-
userHeaders: context.headers,
|
|
57
|
-
failureUrl: context.failureUrl,
|
|
58
|
-
retries: context.retries,
|
|
59
|
-
telemetry
|
|
60
|
-
});
|
|
61
|
-
invokerHeaders["Upstash-Workflow-Runid"] = context.workflowRunId;
|
|
62
|
-
const newUrl = context.url.replace(/[^/]+$/, workflowId);
|
|
63
|
-
const { headers: triggerHeaders } = getHeaders({
|
|
64
|
-
initHeaderValue: "true",
|
|
65
|
-
workflowRunId,
|
|
66
|
-
workflowUrl: newUrl,
|
|
67
|
-
userHeaders: new Headers(headers),
|
|
68
|
-
retries,
|
|
69
|
-
telemetry
|
|
70
|
-
});
|
|
71
|
-
triggerHeaders["Upstash-Workflow-Invoke"] = "true";
|
|
72
|
-
const request = {
|
|
73
|
-
body: JSON.stringify(body),
|
|
74
|
-
headers: Object.fromEntries(
|
|
75
|
-
Object.entries(invokerHeaders).map((pairs) => [pairs[0], [pairs[1]]])
|
|
76
|
-
),
|
|
77
|
-
workflowRunId,
|
|
78
|
-
workflowUrl: context.url,
|
|
79
|
-
step: invokeStep
|
|
80
|
-
};
|
|
81
|
-
await context.qstashClient.publish({
|
|
82
|
-
headers: triggerHeaders,
|
|
83
|
-
method: "POST",
|
|
84
|
-
body: JSON.stringify(request),
|
|
85
|
-
url: newUrl
|
|
86
|
-
});
|
|
87
|
-
return void 0;
|
|
88
|
-
};
|
|
89
|
-
return invokeCallback;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export {
|
|
93
|
-
serveManyBase,
|
|
94
|
-
createInvokeCallback
|
|
95
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { t as InvokableWorkflow } from './types-C7Y7WUQd.mjs';
|
|
2
|
-
|
|
3
|
-
declare const serveManyBase: <TServe extends (...params: any[]) => any, THandlerParams extends Parameters<TServe> = Parameters<TServe>, TInvokableWorkflow extends InvokableWorkflow<any, any, THandlerParams> = InvokableWorkflow<any, any, THandlerParams>>({ workflows, getWorkflowId, }: {
|
|
4
|
-
workflows: Record<string, TInvokableWorkflow>;
|
|
5
|
-
getWorkflowId: (...params: THandlerParams) => string;
|
|
6
|
-
}) => {
|
|
7
|
-
handler: (...params: THandlerParams) => Promise<any>;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { serveManyBase as s };
|
package/serve-many-Dw-UUnH6.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { t as InvokableWorkflow } from './types-C7Y7WUQd.js';
|
|
2
|
-
|
|
3
|
-
declare const serveManyBase: <TServe extends (...params: any[]) => any, THandlerParams extends Parameters<TServe> = Parameters<TServe>, TInvokableWorkflow extends InvokableWorkflow<any, any, THandlerParams> = InvokableWorkflow<any, any, THandlerParams>>({ workflows, getWorkflowId, }: {
|
|
4
|
-
workflows: Record<string, TInvokableWorkflow>;
|
|
5
|
-
getWorkflowId: (...params: THandlerParams) => string;
|
|
6
|
-
}) => {
|
|
7
|
-
handler: (...params: THandlerParams) => Promise<any>;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { serveManyBase as s };
|