@upstash/workflow 0.2.8 → 0.2.10-hono-generics
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 +8 -3
- package/astro.d.ts +8 -3
- package/astro.js +393 -82
- package/astro.mjs +36 -8
- package/{chunk-BPUSHNSD.mjs → chunk-IPXJZU3K.mjs} +1226 -943
- package/cloudflare.d.mts +9 -4
- package/cloudflare.d.ts +9 -4
- package/cloudflare.js +392 -88
- package/cloudflare.mjs +35 -14
- package/express.d.mts +7 -3
- package/express.d.ts +7 -3
- package/express.js +400 -92
- package/express.mjs +43 -18
- package/h3.d.mts +9 -7
- package/h3.d.ts +9 -7
- package/h3.js +397 -95
- package/h3.mjs +40 -21
- package/hono.d.mts +10 -4
- package/hono.d.ts +10 -4
- package/hono.js +391 -90
- package/hono.mjs +34 -16
- package/index.d.mts +47 -33
- package/index.d.ts +47 -33
- package/index.js +315 -92
- package/index.mjs +32 -30
- package/nextjs.d.mts +14 -5
- package/nextjs.d.ts +14 -5
- package/nextjs.js +408 -77
- package/nextjs.mjs +63 -17
- package/package.json +1 -1
- package/serve-many-BVDpPsF-.d.mts +13 -0
- package/serve-many-e4zufyXN.d.ts +13 -0
- package/solidjs.d.mts +3 -3
- package/solidjs.d.ts +3 -3
- package/solidjs.js +289 -71
- package/solidjs.mjs +7 -10
- package/svelte.d.mts +13 -6
- package/svelte.d.ts +13 -6
- package/svelte.js +391 -88
- package/svelte.mjs +34 -14
- package/{types-B62AnIU3.d.mts → types-CYhDXnf8.d.mts} +74 -8
- package/{types-B62AnIU3.d.ts → types-CYhDXnf8.d.ts} +74 -8
package/hono.mjs
CHANGED
|
@@ -1,30 +1,48 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SDK_TELEMETRY,
|
|
3
|
-
serveBase
|
|
4
|
-
|
|
3
|
+
serveBase,
|
|
4
|
+
serveManyBase
|
|
5
|
+
} from "./chunk-IPXJZU3K.mjs";
|
|
5
6
|
|
|
6
7
|
// platforms/hono.ts
|
|
8
|
+
var telemetry = {
|
|
9
|
+
sdk: SDK_TELEMETRY,
|
|
10
|
+
framework: "hono"
|
|
11
|
+
};
|
|
7
12
|
var serve = (routeFunction, options) => {
|
|
8
13
|
const handler = async (context) => {
|
|
9
14
|
const environment = context.env;
|
|
10
15
|
const request = context.req.raw;
|
|
11
|
-
const { handler: serveHandler } = serveBase(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
// when hono is used without cf workers, it sends a DebugHTTPServer
|
|
19
|
-
// object in `context.env`. don't pass env if this is the case:
|
|
20
|
-
env: "QSTASH_TOKEN" in environment ? environment : void 0,
|
|
21
|
-
...options
|
|
22
|
-
}
|
|
23
|
-
);
|
|
16
|
+
const { handler: serveHandler } = serveBase(routeFunction, telemetry, {
|
|
17
|
+
// when hono is used without cf workers, it sends a DebugHTTPServer
|
|
18
|
+
// object in `context.env`. don't pass env if this is the case:
|
|
19
|
+
env: "QSTASH_TOKEN" in environment ? environment : void 0,
|
|
20
|
+
...options
|
|
21
|
+
});
|
|
24
22
|
return await serveHandler(request);
|
|
25
23
|
};
|
|
26
24
|
return handler;
|
|
27
25
|
};
|
|
26
|
+
var createWorkflow = (...params) => {
|
|
27
|
+
const [routeFunction, options = {}] = params;
|
|
28
|
+
return {
|
|
29
|
+
routeFunction,
|
|
30
|
+
options,
|
|
31
|
+
workflowId: void 0
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
var serveMany = (workflows, options) => {
|
|
35
|
+
return serveManyBase({
|
|
36
|
+
workflows,
|
|
37
|
+
getUrl(params) {
|
|
38
|
+
return params.req.url;
|
|
39
|
+
},
|
|
40
|
+
serveMethod: (...params) => serve(...params),
|
|
41
|
+
options
|
|
42
|
+
}).handler;
|
|
43
|
+
};
|
|
28
44
|
export {
|
|
29
|
-
|
|
45
|
+
createWorkflow,
|
|
46
|
+
serve,
|
|
47
|
+
serveMany
|
|
30
48
|
};
|
package/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter, c as Step } from './types-
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse, r as CallSettings, D as Duration, l as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, L as LogLevel, p as NotifyStepResponse, P as ParallelCallState, k as PublicServeOptions, m as RequiredExceptFields, j as StepFunction, h as StepTypes, i as SyncStepFunction,
|
|
3
|
-
import { HTTPMethods, State, Client as Client$1, QstashError } from '@upstash/qstash';
|
|
1
|
+
import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter, c as Step } from './types-CYhDXnf8.mjs';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, r as CallSettings, D as Duration, l as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, t as InvokableWorkflow, s as InvokeStepResponse, I as InvokeWorkflowRequest, L as LazyInvokeStepParams, u as LogLevel, p as NotifyStepResponse, P as ParallelCallState, k as PublicServeOptions, m as RequiredExceptFields, j as StepFunction, h as StepTypes, i as SyncStepFunction, q as WaitEventOptions, n as WaitRequest, o as WaitStepResponse, f as WorkflowClient, e as WorkflowContext, w as WorkflowLogger, v as WorkflowLoggerOptions, g as WorkflowReceiver, d as WorkflowTool } from './types-CYhDXnf8.mjs';
|
|
3
|
+
import { HTTPMethods, State, FlowControl, Client as Client$1, QstashError } from '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'ai';
|
|
6
6
|
import '@ai-sdk/openai';
|
|
@@ -9,13 +9,26 @@ import '@ai-sdk/openai';
|
|
|
9
9
|
* Creates an async method that handles incoming requests and runs the provided
|
|
10
10
|
* route function as a workflow.
|
|
11
11
|
*
|
|
12
|
+
* Not exported in the package. Instead, used in framework specific serve implementations.
|
|
13
|
+
*
|
|
14
|
+
* Only difference from regular serve is the `useJSONContent` parameter.
|
|
15
|
+
*
|
|
12
16
|
* @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
|
|
13
17
|
* @param options - Options including the client, onFinish callback, and initialPayloadParser.
|
|
14
18
|
* @returns An async method that consumes incoming requests and runs the workflow.
|
|
15
19
|
*/
|
|
16
|
-
declare const
|
|
20
|
+
declare const serveBase: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, telemetry?: Telemetry, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => {
|
|
17
21
|
handler: (request: TRequest) => Promise<TResponse>;
|
|
18
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Creates an async method that handles incoming requests and runs the provided
|
|
25
|
+
* route function as a workflow.
|
|
26
|
+
*
|
|
27
|
+
* @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
|
|
28
|
+
* @param options - Options including the client, onFinish callback, and initialPayloadParser.
|
|
29
|
+
* @returns An async method that consumes incoming requests and runs the workflow.
|
|
30
|
+
*/
|
|
31
|
+
declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: Omit<WorkflowServeOptions<TResponse, TInitialPayload>, "useJSONContent" | "schema" | "initialPayloadParser"> & ExclusiveValidationOptions<TInitialPayload>) => ReturnType<typeof serveBase<TInitialPayload, TRequest, TResponse, TResult>>;
|
|
19
32
|
|
|
20
33
|
type BaseStepLog = {
|
|
21
34
|
/**
|
|
@@ -81,7 +94,7 @@ type CallUrlGroup = {
|
|
|
81
94
|
callHeaders: Record<string, string[]>;
|
|
82
95
|
/**
|
|
83
96
|
* Body sent in context.call
|
|
84
|
-
|
|
97
|
+
*/
|
|
85
98
|
callBody: unknown;
|
|
86
99
|
};
|
|
87
100
|
type CallResponseStatusGroup = {
|
|
@@ -382,42 +395,43 @@ declare class Client {
|
|
|
382
395
|
* the workflow, `retries` option of the `serve` will be used.
|
|
383
396
|
* @returns workflow run id
|
|
384
397
|
*/
|
|
385
|
-
trigger({ url, body, headers, workflowRunId, retries, }: {
|
|
398
|
+
trigger({ url, body, headers, workflowRunId, retries, flowControl, }: {
|
|
386
399
|
url: string;
|
|
387
400
|
body?: unknown;
|
|
388
401
|
headers?: Record<string, string>;
|
|
389
402
|
workflowRunId?: string;
|
|
390
403
|
retries?: number;
|
|
404
|
+
flowControl?: FlowControl;
|
|
391
405
|
}): Promise<{
|
|
392
406
|
workflowRunId: string;
|
|
393
407
|
}>;
|
|
394
408
|
/**
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
409
|
+
* Fetches logs for workflow runs.
|
|
410
|
+
*
|
|
411
|
+
* @param workflowRunId - The ID of the workflow run to fetch logs for.
|
|
412
|
+
* @param cursor - The cursor for pagination.
|
|
413
|
+
* @param count - Number of runs to fetch. Default value is 10.
|
|
414
|
+
* @param state - The state of the workflow run.
|
|
415
|
+
* @param workflowUrl - The URL of the workflow. Should be an exact match.
|
|
416
|
+
* @param workflowCreatedAt - The creation time of the workflow. If you have two workflow runs with the same URL, you can use this to filter them.
|
|
417
|
+
* @returns A promise that resolves to either a `WorkflowRunLog` or a `WorkflowRunResponse`.
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* Fetch logs for a specific workflow run:
|
|
421
|
+
* ```typescript
|
|
422
|
+
* const { runs } = await client.logs({ workflowRunId: '12345' });
|
|
423
|
+
* const steps = runs[0].steps; // access steps
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* Fetch logs with pagination:
|
|
428
|
+
* ```typescript
|
|
429
|
+
* const { runs, cursor } = await client.logs();
|
|
430
|
+
* const steps = runs[0].steps // access steps
|
|
431
|
+
*
|
|
432
|
+
* const { runs: nextRuns, cursor: nextCursor } = await client.logs({ cursor, count: 2 });
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
421
435
|
logs(params?: {
|
|
422
436
|
workflowRunId?: WorkflowRunLog["workflowRunId"];
|
|
423
437
|
cursor?: string;
|
|
@@ -454,4 +468,4 @@ declare class WorkflowAbort extends Error {
|
|
|
454
468
|
constructor(stepName: string, stepInfo?: Step, cancelWorkflow?: boolean);
|
|
455
469
|
}
|
|
456
470
|
|
|
457
|
-
export { Client, ExclusiveValidationOptions, NotifyResponse, RawStep, RouteFunction, Step, type StepLog, StepType, Waiter, WorkflowAbort, WorkflowError, type WorkflowRunLog, type WorkflowRunLogs, WorkflowServeOptions, serve };
|
|
471
|
+
export { Client, ExclusiveValidationOptions, NotifyResponse, RawStep, RouteFunction, Step, type StepLog, StepType, Telemetry, Waiter, WorkflowAbort, WorkflowError, type WorkflowRunLog, type WorkflowRunLogs, WorkflowServeOptions, serve };
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter, c as Step } from './types-
|
|
2
|
-
export { A as AsyncStepFunction, C as CallResponse, r as CallSettings, D as Duration, l as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, L as LogLevel, p as NotifyStepResponse, P as ParallelCallState, k as PublicServeOptions, m as RequiredExceptFields, j as StepFunction, h as StepTypes, i as SyncStepFunction,
|
|
3
|
-
import { HTTPMethods, State, Client as Client$1, QstashError } from '@upstash/qstash';
|
|
1
|
+
import { R as RouteFunction, W as WorkflowServeOptions, E as ExclusiveValidationOptions, T as Telemetry, S as StepType, a as RawStep, N as NotifyResponse, b as Waiter, c as Step } from './types-CYhDXnf8.js';
|
|
2
|
+
export { A as AsyncStepFunction, C as CallResponse, r as CallSettings, D as Duration, l as FailureFunctionPayload, F as FinishCondition, H as HeaderParams, t as InvokableWorkflow, s as InvokeStepResponse, I as InvokeWorkflowRequest, L as LazyInvokeStepParams, u as LogLevel, p as NotifyStepResponse, P as ParallelCallState, k as PublicServeOptions, m as RequiredExceptFields, j as StepFunction, h as StepTypes, i as SyncStepFunction, q as WaitEventOptions, n as WaitRequest, o as WaitStepResponse, f as WorkflowClient, e as WorkflowContext, w as WorkflowLogger, v as WorkflowLoggerOptions, g as WorkflowReceiver, d as WorkflowTool } from './types-CYhDXnf8.js';
|
|
3
|
+
import { HTTPMethods, State, FlowControl, Client as Client$1, QstashError } from '@upstash/qstash';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'ai';
|
|
6
6
|
import '@ai-sdk/openai';
|
|
@@ -9,13 +9,26 @@ import '@ai-sdk/openai';
|
|
|
9
9
|
* Creates an async method that handles incoming requests and runs the provided
|
|
10
10
|
* route function as a workflow.
|
|
11
11
|
*
|
|
12
|
+
* Not exported in the package. Instead, used in framework specific serve implementations.
|
|
13
|
+
*
|
|
14
|
+
* Only difference from regular serve is the `useJSONContent` parameter.
|
|
15
|
+
*
|
|
12
16
|
* @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
|
|
13
17
|
* @param options - Options including the client, onFinish callback, and initialPayloadParser.
|
|
14
18
|
* @returns An async method that consumes incoming requests and runs the workflow.
|
|
15
19
|
*/
|
|
16
|
-
declare const
|
|
20
|
+
declare const serveBase: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, telemetry?: Telemetry, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => {
|
|
17
21
|
handler: (request: TRequest) => Promise<TResponse>;
|
|
18
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Creates an async method that handles incoming requests and runs the provided
|
|
25
|
+
* route function as a workflow.
|
|
26
|
+
*
|
|
27
|
+
* @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
|
|
28
|
+
* @param options - Options including the client, onFinish callback, and initialPayloadParser.
|
|
29
|
+
* @returns An async method that consumes incoming requests and runs the workflow.
|
|
30
|
+
*/
|
|
31
|
+
declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: Omit<WorkflowServeOptions<TResponse, TInitialPayload>, "useJSONContent" | "schema" | "initialPayloadParser"> & ExclusiveValidationOptions<TInitialPayload>) => ReturnType<typeof serveBase<TInitialPayload, TRequest, TResponse, TResult>>;
|
|
19
32
|
|
|
20
33
|
type BaseStepLog = {
|
|
21
34
|
/**
|
|
@@ -81,7 +94,7 @@ type CallUrlGroup = {
|
|
|
81
94
|
callHeaders: Record<string, string[]>;
|
|
82
95
|
/**
|
|
83
96
|
* Body sent in context.call
|
|
84
|
-
|
|
97
|
+
*/
|
|
85
98
|
callBody: unknown;
|
|
86
99
|
};
|
|
87
100
|
type CallResponseStatusGroup = {
|
|
@@ -382,42 +395,43 @@ declare class Client {
|
|
|
382
395
|
* the workflow, `retries` option of the `serve` will be used.
|
|
383
396
|
* @returns workflow run id
|
|
384
397
|
*/
|
|
385
|
-
trigger({ url, body, headers, workflowRunId, retries, }: {
|
|
398
|
+
trigger({ url, body, headers, workflowRunId, retries, flowControl, }: {
|
|
386
399
|
url: string;
|
|
387
400
|
body?: unknown;
|
|
388
401
|
headers?: Record<string, string>;
|
|
389
402
|
workflowRunId?: string;
|
|
390
403
|
retries?: number;
|
|
404
|
+
flowControl?: FlowControl;
|
|
391
405
|
}): Promise<{
|
|
392
406
|
workflowRunId: string;
|
|
393
407
|
}>;
|
|
394
408
|
/**
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
409
|
+
* Fetches logs for workflow runs.
|
|
410
|
+
*
|
|
411
|
+
* @param workflowRunId - The ID of the workflow run to fetch logs for.
|
|
412
|
+
* @param cursor - The cursor for pagination.
|
|
413
|
+
* @param count - Number of runs to fetch. Default value is 10.
|
|
414
|
+
* @param state - The state of the workflow run.
|
|
415
|
+
* @param workflowUrl - The URL of the workflow. Should be an exact match.
|
|
416
|
+
* @param workflowCreatedAt - The creation time of the workflow. If you have two workflow runs with the same URL, you can use this to filter them.
|
|
417
|
+
* @returns A promise that resolves to either a `WorkflowRunLog` or a `WorkflowRunResponse`.
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* Fetch logs for a specific workflow run:
|
|
421
|
+
* ```typescript
|
|
422
|
+
* const { runs } = await client.logs({ workflowRunId: '12345' });
|
|
423
|
+
* const steps = runs[0].steps; // access steps
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* Fetch logs with pagination:
|
|
428
|
+
* ```typescript
|
|
429
|
+
* const { runs, cursor } = await client.logs();
|
|
430
|
+
* const steps = runs[0].steps // access steps
|
|
431
|
+
*
|
|
432
|
+
* const { runs: nextRuns, cursor: nextCursor } = await client.logs({ cursor, count: 2 });
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
421
435
|
logs(params?: {
|
|
422
436
|
workflowRunId?: WorkflowRunLog["workflowRunId"];
|
|
423
437
|
cursor?: string;
|
|
@@ -454,4 +468,4 @@ declare class WorkflowAbort extends Error {
|
|
|
454
468
|
constructor(stepName: string, stepInfo?: Step, cancelWorkflow?: boolean);
|
|
455
469
|
}
|
|
456
470
|
|
|
457
|
-
export { Client, ExclusiveValidationOptions, NotifyResponse, RawStep, RouteFunction, Step, type StepLog, StepType, Waiter, WorkflowAbort, WorkflowError, type WorkflowRunLog, type WorkflowRunLogs, WorkflowServeOptions, serve };
|
|
471
|
+
export { Client, ExclusiveValidationOptions, NotifyResponse, RawStep, RouteFunction, Step, type StepLog, StepType, Telemetry, Waiter, WorkflowAbort, WorkflowError, type WorkflowRunLog, type WorkflowRunLogs, WorkflowServeOptions, serve };
|