@convex-dev/workpool 0.2.18-alpha.2 → 0.2.18

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/README.md CHANGED
@@ -12,9 +12,7 @@ This Convex component pools actions and mutations to restrict parallel requests.
12
12
  - An `onComplete` callback so you can build durable, reliable workflows. Called
13
13
  when the work is finished, whether it succeeded, failed, or was canceled.
14
14
 
15
- ## Use cases
16
-
17
- ### Separating and throttling async workloads
15
+ ## Separating and throttling async workloads
18
16
 
19
17
  Suppose you have some important async work, like sending verification emails,
20
18
  and some less important async work, like scraping data from an API. If all of
@@ -51,9 +49,9 @@ export const downloadLatestWeather = mutation({
51
49
  });
52
50
  ```
53
51
 
54
- ### Durable, reliable workflows meet workpool
52
+ ## Durable, reliable workflows
55
53
 
56
- #### Retry management
54
+ ### Retry management
57
55
 
58
56
  Imagine that the payment processor is a 3rd party API, and they temporarily have an
59
57
  outage. Now imagine you implement your own action retrying logic for your busy app.
@@ -65,7 +63,7 @@ Creating an upper bound on how much work will be done in parallel is a good way
65
63
  mitigate this risk. Actions that are currently backing off awaiting retry will not tie
66
64
  up a thread in the workpool.
67
65
 
68
- #### Completion handling
66
+ ### Completion handling
69
67
 
70
68
  By handing off asynchronous work, it will be guaranteed to run, and with retries
71
69
  you can account for temporary failures, while avoiding a "stampeding herd"
@@ -114,7 +112,7 @@ export const emailSent = internalMutation({
114
112
  error: result.kind === "failed" ? result.error : null,
115
113
  });
116
114
  if (result.kind === "failed") {
117
- await pool.enqueueAction(ctx, internal.email.checkResendStatus, context, {
115
+ await pool.enqueueAction(ctx, internal.email.checkStatus, { userId }, {
118
116
  retry: { maxAttempts: 10, initialBackoffMs: 250, base: 2 }, // custom
119
117
  onComplete: internal.email.handleEmailStatus,
120
118
  context: { emailLogId },
@@ -141,7 +139,7 @@ export const emailSent = pool.defineOnComplete<DataModel>({
141
139
  });
142
140
  ```
143
141
 
144
- #### Idempotency?
142
+ ### Idempotency
145
143
 
146
144
  Idempotent actions are actions that can be run multiple times safely. This typically
147
145
  means they don't cause any side effects that would be a problem if executed twice or more.
@@ -162,10 +160,10 @@ If you're creating complex workflows with many steps involving 3rd party APIs:
162
160
  1. You should ensure that each step is an idempotent Convex action.
163
161
  2. You should use this component to manage these actions so it all just works!
164
162
 
165
- ### Optimize OCC errors
163
+ ### Reducing database write conflicts (aka OCC errors)
166
164
 
167
165
  With limited parallelism, you can reduce
168
- [OCC errors](https://docs.convex.dev/error#1)
166
+ [write conflicts](https://docs.convex.dev/error#1)
169
167
  from mutations that read and write the same data.
170
168
 
171
169
  Consider this action that calls a mutation to increment a singleton counter.
@@ -199,7 +197,44 @@ Effectively, Workpool runs async functions similar to
199
197
  `ctx.scheduler.runAfter(0, ...)`, but it limits the number of functions that
200
198
  can run in parallel.
201
199
 
202
- ## Pre-requisite: Convex
200
+ ## Reactive status of asynchronous work
201
+
202
+ The workpool stores the status of each function in the database, and thanks to
203
+ Convex's reactive queries, you can read it in a query to power a reactive UI.
204
+
205
+ By default, it will keep the status for 1 day but you can change this with
206
+ the `statusTtl` option to `Workpool`.
207
+
208
+ To keep the status forever, set `statusTtl: Number.POSITIVE_INFINITY`.
209
+
210
+ You can read the status of a function by calling `pool.status(id)`.
211
+
212
+ ```ts
213
+ import { vWorkIdValidator } from "@convex-dev/workpool";
214
+ import { query } from "./_generated/server";
215
+
216
+ export const getStatus = query({
217
+ args: { id: vWorkIdValidator },
218
+ handler: async (ctx, args) => {
219
+ const status = await pool.status(args.id);
220
+ return status;
221
+ },
222
+ });
223
+ ```
224
+
225
+ The status will be one of:
226
+
227
+ - `{ kind: "pending"; previousAttempts: number }`: The function has not started yet.
228
+ - `{ kind: "running"; previousAttempts: number }`: The function is currently running.
229
+ - `{ kind: "finished" }`: The function has succeeded, failed, or been canceled.
230
+
231
+ To get the result of your function, you can either write to the database from
232
+ within your function, call or schedule another function from there, or use the
233
+ `onComplete` handler to respond to the job result.
234
+
235
+ ## Get started
236
+
237
+ ### Pre-requisite: Convex
203
238
 
204
239
  You'll need an existing Convex project to use the component.
205
240
  Convex is a hosted backend platform, including a database, serverless functions,
@@ -207,7 +242,7 @@ and a ton more you can learn about [here](https://docs.convex.dev/get-started).
207
242
 
208
243
  Run `npm create convex` or follow any of the [quickstarts](https://docs.convex.dev/home) to set one up.
209
244
 
210
- ## Installation
245
+ ### Install the component
211
246
 
212
247
  See [`example/`](./example/convex/) for a working demo.
213
248
 
@@ -231,49 +266,7 @@ app.use(workpool, { name: "scrapeWorkpool" });
231
266
  export default app;
232
267
  ```
233
268
 
234
- ## Usage
235
-
236
- ```ts
237
- import { components } from "./_generated/api";
238
- import { Workpool } from "@convex-dev/workpool";
239
-
240
- const pool = new Workpool(components.emailWorkpool, { maxParallelism: 10 });
241
- ```
242
-
243
- Then you have the following interface on `pool`:
244
-
245
- ```ts
246
- import { vWorkIdValidator } from "@convex-dev/workpool";
247
-
248
- export const myMutation = mutation({
249
- args: {},
250
- handler: async (ctx, args) => {
251
- // Schedule functions to run in the background.
252
- const id = await pool.enqueueMutation(ctx, internal.foo.bar, args);
253
- // Or for an action:
254
- const id = await pool.enqueueAction(ctx, internal.foo.baz, args);
255
- },
256
- });
257
-
258
- export const getStatus = query({
259
- args: { id: vWorkIdValidator },
260
- handler: async (ctx, args) => {
261
- // Is it done yet? Did it succeed or fail?
262
- const status = await pool.status(args.id);
263
- return status;
264
- },
265
- });
266
-
267
- export const cancelWork = mutation({
268
- args: { id: vWorkIdValidator },
269
- handler: async (ctx, args) => {
270
- // You can cancel the work, if it hasn't finished yet.
271
- await pool.cancel(ctx, args.id);
272
- },
273
- });
274
- ```
275
-
276
- See more example usage in [example.ts](./example/convex/example.ts).
269
+ See example usage in [example.ts](./example/convex/example.ts).
277
270
 
278
271
  ### Configuring the Workpool
279
272
 
@@ -326,39 +319,49 @@ If you're running into issues with too many concurrent functions, there are
326
319
  alternatives to Workpool:
327
320
 
328
321
  - Try combining multiple mutations into a single mutation, with batching or
329
- debouncing.
322
+ debouncing. See the next section for enqueueing multiple actions at once.
330
323
  - Call plain TypeScript functions if possible.
331
324
  - In particular, an action calling `ctx.runAction` has more overhead than just
332
325
  calling the action's handler directly.
333
326
 
334
327
  See [best practices](https://docs.convex.dev/production/best-practices) for more.
335
328
 
336
- ## Reading function status
329
+ ### Batching
337
330
 
338
- The workpool stores the status of each function in the database, so you can
339
- read it even after the function has finished.
340
- By default, it will keep the status for 1 day but you can change this with
341
- the `statusTtl` option to `Workpool`.
331
+ If you're enqueuing a lot of work, you can use `enqueueActionBatch` to enqueue
332
+ a batch of actions at once, or the equivalents for queries or mutations.
342
333
 
343
- To keep the status forever, set `statusTtl: Number.POSITIVE_INFINITY`.
334
+ This helps in two ways:
344
335
 
345
- You can read the status of a function by calling `pool.status(id)`.
346
-
347
- The status will be one of:
336
+ 1. It reduces the number of calls to the component, which reduces overhead
337
+ as each component call runs in a fresh container (for strong isolation).
338
+ 2. When called from an action, it reduces the number of mutations that might
339
+ conflict with each other, especially if they were being called in parallel.
348
340
 
349
- - `{ kind: "pending"; previousAttempts: number }`: The function has not started yet.
350
- - `{ kind: "running"; previousAttempts: number }`: The function is currently running.
351
- - `{ kind: "finished" }`: The function has succeeded, failed, or been canceled.
341
+ ```ts
342
+ await pool.enqueueActionBatch(ctx, internal.weather.scrape, [
343
+ { city: "New York" },
344
+ { city: "Los Angeles" },
345
+ { city: "Chicago" },
346
+ ]);
347
+ ```
352
348
 
353
- To get the result of your function, you can either write to the database from
354
- within your function, call or schedule another function from there, or use the
355
- `onComplete` handler to respond to the job result.
356
349
 
357
350
  ## Canceling work
358
351
 
359
352
  You can cancel work by calling `pool.cancel(id)` or all of them with
360
353
  `pool.cancelAll()`.
361
354
 
355
+ ```ts
356
+ export const cancelWork = mutation({
357
+ args: { id: vWorkIdValidator },
358
+ handler: async (ctx, args) => {
359
+ // You can cancel the work, if it hasn't finished yet.
360
+ await pool.cancel(ctx, args.id);
361
+ },
362
+ });
363
+ ```
364
+
362
365
  This will avoid starting or retrying, but will not stop in-progress work.
363
366
 
364
367
  ## Monitoring the workpool
@@ -1,4 +1,4 @@
1
- import { DefaultFunctionArgs, FunctionReference, FunctionVisibility, GenericDataModel, GenericMutationCtx, RegisteredMutation } from "convex/server";
1
+ import { DefaultFunctionArgs, FunctionReference, FunctionType, FunctionVisibility, GenericDataModel, GenericMutationCtx, RegisteredMutation } from "convex/server";
2
2
  import { Infer, Validator, VAny, VString } from "convex/values";
3
3
  import { Mounts } from "../component/_generated/api.js";
4
4
  import { type LogLevel } from "../component/logging.js";
@@ -16,7 +16,7 @@ export {
16
16
  vWorkIdValidator as workIdValidator,
17
17
  /** @deprecated Use `vResultValidator` instead. */
18
18
  vResultValidator as resultValidator, };
19
- /** @deprecated Use `vOnCompleteArgs(<your-context-validator>)` instead. */
19
+ /** Equivalent to `vOnCompleteArgs(<your-context-validator>)`. */
20
20
  export declare const vOnComplete: import("convex/values").VObject<{
21
21
  context: any;
22
22
  workId: WorkId;
@@ -31,7 +31,7 @@ export declare const vOnComplete: import("convex/values").VObject<{
31
31
  };
32
32
  }, {
33
33
  workId: VString<WorkId, "required">;
34
- context: VAny<any, "required", string> | VAny<any, "optional", string>;
34
+ context: VAny<any, "required", string>;
35
35
  result: import("convex/values").VUnion<{
36
36
  kind: "success";
37
37
  returnValue: any;
@@ -61,8 +61,9 @@ export declare const vOnComplete: import("convex/values").VObject<{
61
61
  /** @deprecated Use `vOnCompleteArgs()` instead. */
62
62
  export declare const vOnCompleteValidator: typeof vOnCompleteArgs;
63
63
  export declare const DEFAULT_RETRY_BEHAVIOR: RetryBehavior;
64
+ export type WorkpoolComponent = UseApi<Mounts>;
64
65
  export declare class Workpool {
65
- private component;
66
+ component: WorkpoolComponent;
66
67
  options: WorkpoolOptions;
67
68
  /**
68
69
  * Initializes a Workpool.
@@ -75,8 +76,7 @@ export declare class Workpool {
75
76
  * `./_generated/api.ts`.
76
77
  * @param options - The {@link WorkpoolOptions} for the Workpool.
77
78
  */
78
- constructor(component: UseApi<Mounts>, // UseApi<api> for jump to definition
79
- options: WorkpoolOptions);
79
+ constructor(component: WorkpoolComponent, options: WorkpoolOptions);
80
80
  /**
81
81
  * Enqueues an action to be run.
82
82
  *
@@ -87,7 +87,20 @@ export declare class Workpool {
87
87
  * onComplete handling, and scheduling via `runAt` or `runAfter`.
88
88
  * @returns The ID of the work that was enqueued.
89
89
  */
90
- enqueueAction<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"action", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: RetryOption & CallbackOptions & SchedulerOptions & NameOption): Promise<WorkId>;
90
+ enqueueAction<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"action", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: RetryOption & EnqueueOptions): Promise<WorkId>;
91
+ /**
92
+ * Enqueues a batch of actions to be run.
93
+ * Each action will be run independently, and the onComplete handler will
94
+ * be called for each action.
95
+ *
96
+ * @param ctx - The mutation or action ctx that can call ctx.runMutation.
97
+ * @param fn - The action to run, like `internal.example.myAction`.
98
+ * @param argsArray - The arguments to pass to the action.
99
+ * @param options - The options for the actions to specify retry behavior,
100
+ * onComplete handling, and scheduling via `runAt` or `runAfter`.
101
+ * @returns The IDs of the work that was enqueued.
102
+ */
103
+ enqueueActionBatch<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"action", FunctionVisibility, Args, ReturnType>, argsArray: Array<Args>, options?: RetryOption & EnqueueOptions): Promise<WorkId[]>;
91
104
  /**
92
105
  * Enqueues a mutation to be run.
93
106
  *
@@ -101,8 +114,44 @@ export declare class Workpool {
101
114
  * @param options - The options for the mutation to specify onComplete handling
102
115
  * and scheduling via `runAt` or `runAfter`.
103
116
  */
104
- enqueueMutation<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"mutation", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: CallbackOptions & SchedulerOptions & NameOption): Promise<WorkId>;
105
- enqueueQuery<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"query", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: CallbackOptions & SchedulerOptions & NameOption): Promise<WorkId>;
117
+ enqueueMutation<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"mutation", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: EnqueueOptions): Promise<WorkId>;
118
+ /**
119
+ * Enqueues a batch of mutations to be run.
120
+ * Each mutation will be run independently, and the onComplete handler will
121
+ * be called for each mutation.
122
+ *
123
+ * @param ctx - The mutation or action context that can call ctx.runMutation.
124
+ * @param fn - The mutation to run, like `internal.example.myMutation`.
125
+ * @param argsArray - The arguments to pass to the mutations.
126
+ * @param options - The options for the mutations to specify onComplete handling
127
+ * and scheduling via `runAt` or `runAfter`.
128
+ */
129
+ enqueueMutationBatch<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"mutation", FunctionVisibility, Args, ReturnType>, argsArray: Array<Args>, options?: EnqueueOptions): Promise<WorkId[]>;
130
+ /**
131
+ * Enqueues a query to be run.
132
+ * Usually not what you want, but it can be useful during workflows.
133
+ * The query is run in a mutation and the result is returned to the caller,
134
+ * so it can conflict if other mutations are writing the value.
135
+ *
136
+ * @param ctx - The mutation or action context that can call ctx.runMutation.
137
+ * @param fn - The query to run, like `internal.example.myQuery`.
138
+ * @param fnArgs - The arguments to pass to the query.
139
+ * @param options - The options for the query to specify onComplete handling
140
+ * and scheduling via `runAt` or `runAfter`.
141
+ */
142
+ enqueueQuery<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"query", FunctionVisibility, Args, ReturnType>, fnArgs: Args, options?: EnqueueOptions): Promise<WorkId>;
143
+ /**
144
+ * Enqueues a batch of queries to be run.
145
+ * Each query will be run independently, and the onComplete handler will
146
+ * be called for each query.
147
+ *
148
+ * @param ctx - The mutation or action context that can call ctx.runMutation.
149
+ * @param fn - The query to run, like `internal.example.myQuery`.
150
+ * @param argsArray - The arguments to pass to the queries.
151
+ * @param options - The options for the queries to specify onComplete handling
152
+ * and scheduling via `runAt` or `runAfter`.
153
+ */
154
+ enqueueQueryBatch<Args extends DefaultFunctionArgs, ReturnType>(ctx: RunMutationCtx, fn: FunctionReference<"query", FunctionVisibility, Args, ReturnType>, argsArray: Array<Args>, options?: EnqueueOptions): Promise<WorkId[]>;
106
155
  /**
107
156
  * Cancels a work item. If it's already started, it will be allowed to finish
108
157
  * but will not be retried.
@@ -128,6 +177,14 @@ export declare class Workpool {
128
177
  * - `{ state: "finished" }`
129
178
  */
130
179
  status(ctx: RunQueryCtx, id: WorkId): Promise<Status>;
180
+ /**
181
+ * Gets the status of a batch of work items.
182
+ *
183
+ * @param ctx - The query context that can call ctx.runQuery.
184
+ * @param ids - The IDs of the work to get the status of.
185
+ * @returns The status of the work items.
186
+ */
187
+ statusBatch(ctx: RunQueryCtx, ids: WorkId[]): Promise<Status[]>;
131
188
  /**
132
189
  * Defines a mutation that will be run after a work item completes.
133
190
  * You can pass this to a call to enqueue* like so:
@@ -170,9 +227,9 @@ export declare class Workpool {
170
227
  * @param context - The context validator. If not provided, it will be `v.any()`.
171
228
  * @returns The validator for the onComplete mutation.
172
229
  */
173
- export declare function vOnCompleteArgs<V extends Validator<any, "required", any> = VAny>(context?: V): import("convex/values").VObject<import("convex/server").Expand<{ [Property in (VAny<any, "optional", string> | V)["isOptional"] extends "optional" ? "context" : never]?: Exclude<Infer<{
230
+ export declare function vOnCompleteArgs<V extends Validator<any, "required", any> = VAny>(context?: V): import("convex/values").VObject<import("convex/server").Expand<{ [Property in V["isOptional"] extends "optional" ? "context" : never]?: Exclude<Infer<{
174
231
  workId: VString<WorkId, "required">;
175
- context: VAny<any, "optional", string> | V;
232
+ context: V;
176
233
  result: import("convex/values").VUnion<{
177
234
  kind: "success";
178
235
  returnValue: any;
@@ -198,9 +255,9 @@ export declare function vOnCompleteArgs<V extends Validator<any, "required", any
198
255
  }, {
199
256
  kind: import("convex/values").VLiteral<"canceled", "required">;
200
257
  }, "required", "kind">], "required", "kind" | "returnValue" | `returnValue.${string}` | "error">;
201
- }[Property]>, undefined> | undefined; } & { [Property_1 in Exclude<"context", (VAny<any, "optional", string> | V)["isOptional"] extends "optional" ? "context" : never> | Exclude<"workId", (VAny<any, "optional", string> | V)["isOptional"] extends "optional" ? "context" : never> | Exclude<"result", (VAny<any, "optional", string> | V)["isOptional"] extends "optional" ? "context" : never>]: Infer<{
258
+ }[Property]>, undefined> | undefined; } & { [Property_1 in Exclude<"context", V["isOptional"] extends "optional" ? "context" : never> | Exclude<"workId", V["isOptional"] extends "optional" ? "context" : never> | Exclude<"result", V["isOptional"] extends "optional" ? "context" : never>]: Infer<{
202
259
  workId: VString<WorkId, "required">;
203
- context: VAny<any, "optional", string> | V;
260
+ context: V;
204
261
  result: import("convex/values").VUnion<{
205
262
  kind: "success";
206
263
  returnValue: any;
@@ -228,7 +285,7 @@ export declare function vOnCompleteArgs<V extends Validator<any, "required", any
228
285
  }, "required", "kind">], "required", "kind" | "returnValue" | `returnValue.${string}` | "error">;
229
286
  }[Property_1]>; }>, {
230
287
  workId: VString<WorkId, "required">;
231
- context: VAny<any, "optional", string> | V;
288
+ context: V;
232
289
  result: import("convex/values").VUnion<{
233
290
  kind: "success";
234
291
  returnValue: any;
@@ -254,15 +311,7 @@ export declare function vOnCompleteArgs<V extends Validator<any, "required", any
254
311
  }, {
255
312
  kind: import("convex/values").VLiteral<"canceled", "required">;
256
313
  }, "required", "kind">], "required", "kind" | "returnValue" | `returnValue.${string}` | "error">;
257
- }, "required", "context" | "workId" | "result" | `context.${(VAny<any, "optional", string> | V)["fieldPaths"]}` | "result.kind" | "result.returnValue" | `result.returnValue.${string}` | "result.error">;
258
- export type NameOption = {
259
- /**
260
- * The name of the function. By default, if you pass in api.foo.bar.baz,
261
- * it will use "foo/bar:baz" as the name. If you pass in a function handle,
262
- * it will use the function handle directly.
263
- */
264
- name?: string;
265
- };
314
+ }, "required", "context" | "workId" | "result" | `context.${V["fieldPaths"]}` | "result.kind" | "result.returnValue" | `result.returnValue.${string}` | "result.error">;
266
315
  export type RetryOption = {
267
316
  /** Whether to retry the action if it fails.
268
317
  * If true, it will use the default retry behavior.
@@ -298,22 +347,13 @@ export type WorkpoolRetryOptions = {
298
347
  */
299
348
  retryActionsByDefault?: boolean;
300
349
  };
301
- export type SchedulerOptions = {
302
- /**
303
- * The time (ms since epoch) to run the action at.
304
- * If not provided, the action will be run as soon as possible.
305
- * Note: this is advisory only. It may run later.
306
- */
307
- runAt?: number;
308
- } | {
350
+ export type EnqueueOptions = {
309
351
  /**
310
- * The number of milliseconds to run the action after.
311
- * If not provided, the action will be run as soon as possible.
312
- * Note: this is advisory only. It may run later.
352
+ * The name of the function. By default, if you pass in api.foo.bar.baz,
353
+ * it will use "foo/bar:baz" as the name. If you pass in a function handle,
354
+ * it will use the function handle directly.
313
355
  */
314
- runAfter?: number;
315
- };
316
- export type CallbackOptions = {
356
+ name?: string;
317
357
  /**
318
358
  * A mutation to run after the function succeeds, fails, or is canceled.
319
359
  * The context type is for your use, feel free to provide a validator for it.
@@ -343,7 +383,21 @@ export type CallbackOptions = {
343
383
  * Useful for passing data from the enqueue site to the onComplete site.
344
384
  */
345
385
  context?: unknown;
346
- };
386
+ } & ({
387
+ /**
388
+ * The time (ms since epoch) to run the action at.
389
+ * If not provided, the action will be run as soon as possible.
390
+ * Note: this is advisory only. It may run later.
391
+ */
392
+ runAt?: number;
393
+ } | {
394
+ /**
395
+ * The number of milliseconds to run the action after.
396
+ * If not provided, the action will be run as soon as possible.
397
+ * Note: this is advisory only. It may run later.
398
+ */
399
+ runAfter?: number;
400
+ });
347
401
  export type OnCompleteArgs = {
348
402
  /**
349
403
  * The ID of the work that completed.
@@ -359,4 +413,14 @@ export type OnCompleteArgs = {
359
413
  */
360
414
  result: RunResult;
361
415
  };
416
+ export declare function enqueueBatch<FnType extends FunctionType, Args extends DefaultFunctionArgs, ReturnType>(component: UseApi<Mounts>, ctx: RunMutationCtx, fnType: FnType, fn: FunctionReference<FnType, FunctionVisibility, Args, ReturnType>, fnArgsArray: Array<Args>, options: EnqueueOptions & {
417
+ retryBehavior?: RetryBehavior;
418
+ maxParallelism?: number;
419
+ logLevel?: LogLevel;
420
+ }): Promise<WorkId[]>;
421
+ export declare function enqueue<FnType extends FunctionType, Args extends DefaultFunctionArgs, ReturnType>(component: UseApi<Mounts>, ctx: RunMutationCtx, fnType: FnType, fn: FunctionReference<FnType, FunctionVisibility, Args, ReturnType>, fnArgs: Args, options: EnqueueOptions & {
422
+ retryBehavior?: RetryBehavior;
423
+ maxParallelism?: number;
424
+ logLevel?: LogLevel;
425
+ }): Promise<WorkId>;
362
426
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EAEnB,iBAAiB,EAEjB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAElB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAK,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAIL,gBAAgB,EAChB,KAAK,aAAa,EAClB,SAAS,EAET,MAAM,EACP,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,cAAc,EACd,WAAW,EAEX,MAAM,EACP,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,CAAC;AAChE,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,w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