@upstash/workflow 0.2.8 → 0.2.9

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/index.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  makeNotifyRequest,
11
11
  serve,
12
12
  triggerFirstInvocation
13
- } from "./chunk-BPUSHNSD.mjs";
13
+ } from "./chunk-IPXJZU3K.mjs";
14
14
 
15
15
  // src/client/index.ts
16
16
  import { Client as QStashClient } from "@upstash/qstash";
@@ -173,7 +173,8 @@ var Client = class {
173
173
  body,
174
174
  headers,
175
175
  workflowRunId,
176
- retries
176
+ retries,
177
+ flowControl
177
178
  }) {
178
179
  const finalWorkflowRunId = getWorkflowRunId(workflowRunId);
179
180
  const context = new WorkflowContext({
@@ -185,8 +186,9 @@ var Client = class {
185
186
  url,
186
187
  workflowRunId: finalWorkflowRunId,
187
188
  retries,
188
- telemetry: void 0
189
+ telemetry: void 0,
189
190
  // can't know workflow telemetry here
191
+ flowControl
190
192
  });
191
193
  const result = await triggerFirstInvocation({
192
194
  workflowContext: context,
@@ -200,35 +202,35 @@ var Client = class {
200
202
  }
201
203
  }
202
204
  /**
203
- * Fetches logs for workflow runs.
204
- *
205
- * @param workflowRunId - The ID of the workflow run to fetch logs for.
206
- * @param cursor - The cursor for pagination.
207
- * @param count - Number of runs to fetch. Default value is 10.
208
- * @param state - The state of the workflow run.
209
- * @param workflowUrl - The URL of the workflow. Should be an exact match.
210
- * @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.
211
- * @returns A promise that resolves to either a `WorkflowRunLog` or a `WorkflowRunResponse`.
212
- *
213
- * @example
214
- * Fetch logs for a specific workflow run:
215
- * ```typescript
216
- * const { runs } = await client.logs({ workflowRunId: '12345' });
217
- * const steps = runs[0].steps; // access steps
218
- * ```
219
- *
220
- * @example
221
- * Fetch logs with pagination:
222
- * ```typescript
223
- * const { runs, cursor } = await client.logs();
224
- * const steps = runs[0].steps // access steps
225
- *
226
- * const { runs: nextRuns, cursor: nextCursor } = await client.logs({ cursor, count: 2 });
227
- * ```
228
- */
205
+ * Fetches logs for workflow runs.
206
+ *
207
+ * @param workflowRunId - The ID of the workflow run to fetch logs for.
208
+ * @param cursor - The cursor for pagination.
209
+ * @param count - Number of runs to fetch. Default value is 10.
210
+ * @param state - The state of the workflow run.
211
+ * @param workflowUrl - The URL of the workflow. Should be an exact match.
212
+ * @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.
213
+ * @returns A promise that resolves to either a `WorkflowRunLog` or a `WorkflowRunResponse`.
214
+ *
215
+ * @example
216
+ * Fetch logs for a specific workflow run:
217
+ * ```typescript
218
+ * const { runs } = await client.logs({ workflowRunId: '12345' });
219
+ * const steps = runs[0].steps; // access steps
220
+ * ```
221
+ *
222
+ * @example
223
+ * Fetch logs with pagination:
224
+ * ```typescript
225
+ * const { runs, cursor } = await client.logs();
226
+ * const steps = runs[0].steps // access steps
227
+ *
228
+ * const { runs: nextRuns, cursor: nextCursor } = await client.logs({ cursor, count: 2 });
229
+ * ```
230
+ */
229
231
  async logs(params) {
230
232
  const { workflowRunId, cursor, count, state, workflowUrl, workflowCreatedAt } = params ?? {};
231
- const urlParams = new URLSearchParams({ "groupBy": "workflowRunId" });
233
+ const urlParams = new URLSearchParams({ groupBy: "workflowRunId" });
232
234
  if (workflowRunId) {
233
235
  urlParams.append("workflowRunId", workflowRunId);
234
236
  }
package/nextjs.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { NextApiHandler } from 'next';
2
- import { R as RouteFunction, k as PublicServeOptions } from './types-B62AnIU3.mjs';
1
+ import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
2
+ import { R as RouteFunction, k as PublicServeOptions, t as InvokableWorkflow } from './types-CYhDXnf8.mjs';
3
+ import { s as serveManyBase } from './serve-many-BVDpPsF-.mjs';
3
4
  import '@upstash/qstash';
4
5
  import 'zod';
5
6
  import 'ai';
@@ -14,11 +15,19 @@ import '@ai-sdk/openai';
14
15
  * @param options workflow options
15
16
  * @returns
16
17
  */
17
- declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: PublicServeOptions<TInitialPayload>) => {
18
+ declare const serve: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload>) => {
18
19
  POST: (request: Request) => Promise<Response>;
19
20
  };
20
- declare const servePagesRouter: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: PublicServeOptions<TInitialPayload>) => {
21
+ declare const createWorkflow: <TInitialPayload, TResult>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload> | undefined) => InvokableWorkflow<TInitialPayload, TResult>;
22
+ declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
23
+ POST: (request: Request) => Promise<any>;
24
+ };
25
+ declare const servePagesRouter: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload>) => {
21
26
  handler: NextApiHandler;
22
27
  };
28
+ declare const createWorkflowPagesRouter: <TInitialPayload, TResult>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload> | undefined) => InvokableWorkflow<TInitialPayload, TResult>;
29
+ declare const serveManyPagesRouter: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
30
+ handler: (req: NextApiRequest, res: NextApiResponse<any>) => Promise<any>;
31
+ };
23
32
 
24
- export { serve, servePagesRouter };
33
+ export { createWorkflow, createWorkflowPagesRouter, serve, serveMany, serveManyPagesRouter, servePagesRouter };
package/nextjs.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { NextApiHandler } from 'next';
2
- import { R as RouteFunction, k as PublicServeOptions } from './types-B62AnIU3.js';
1
+ import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
2
+ import { R as RouteFunction, k as PublicServeOptions, t as InvokableWorkflow } from './types-CYhDXnf8.js';
3
+ import { s as serveManyBase } from './serve-many-e4zufyXN.js';
3
4
  import '@upstash/qstash';
4
5
  import 'zod';
5
6
  import 'ai';
@@ -14,11 +15,19 @@ import '@ai-sdk/openai';
14
15
  * @param options workflow options
15
16
  * @returns
16
17
  */
17
- declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: PublicServeOptions<TInitialPayload>) => {
18
+ declare const serve: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload>) => {
18
19
  POST: (request: Request) => Promise<Response>;
19
20
  };
20
- declare const servePagesRouter: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: PublicServeOptions<TInitialPayload>) => {
21
+ declare const createWorkflow: <TInitialPayload, TResult>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload> | undefined) => InvokableWorkflow<TInitialPayload, TResult>;
22
+ declare const serveMany: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
23
+ POST: (request: Request) => Promise<any>;
24
+ };
25
+ declare const servePagesRouter: <TInitialPayload = unknown, TResult = unknown>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload>) => {
21
26
  handler: NextApiHandler;
22
27
  };
28
+ declare const createWorkflowPagesRouter: <TInitialPayload, TResult>(routeFunction: RouteFunction<TInitialPayload, TResult>, options?: PublicServeOptions<TInitialPayload> | undefined) => InvokableWorkflow<TInitialPayload, TResult>;
29
+ declare const serveManyPagesRouter: (workflows: Parameters<typeof serveManyBase>[0]["workflows"], options?: Parameters<typeof serveManyBase>[0]["options"]) => {
30
+ handler: (req: NextApiRequest, res: NextApiResponse<any>) => Promise<any>;
31
+ };
23
32
 
24
- export { serve, servePagesRouter };
33
+ export { createWorkflow, createWorkflowPagesRouter, serve, serveMany, serveManyPagesRouter, servePagesRouter };