convex-batch-processor 0.5.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/LICENSE +21 -0
- package/README.md +395 -0
- package/dist/client/index.d.ts +212 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +78 -0
- package/dist/client/index.js.map +1 -0
- package/dist/component/_generated/api.d.ts +34 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +80 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +4 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/lib.d.ts +351 -0
- package/dist/component/lib.d.ts.map +1 -0
- package/dist/component/lib.js +879 -0
- package/dist/component/lib.js.map +1 -0
- package/dist/component/schema.d.ts +118 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +61 -0
- package/dist/component/schema.js.map +1 -0
- package/package.json +63 -0
- package/src/client/index.test.ts +123 -0
- package/src/client/index.ts +336 -0
- package/src/component/_generated/api.ts +50 -0
- package/src/component/_generated/component.ts +140 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/convex.config.ts +4 -0
- package/src/component/lib.ts +1082 -0
- package/src/component/schema.ts +70 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type FunctionReference,
|
|
3
|
+
type GenericMutationCtx,
|
|
4
|
+
type GenericQueryCtx,
|
|
5
|
+
createFunctionHandle,
|
|
6
|
+
} from "convex/server";
|
|
7
|
+
|
|
8
|
+
export type BatchStatus = "accumulating" | "flushing" | "completed";
|
|
9
|
+
export type JobStatus = "pending" | "running" | "paused" | "completed" | "failed";
|
|
10
|
+
|
|
11
|
+
// User-facing config interfaces (accept FunctionReference)
|
|
12
|
+
export interface BatchConfig<T = unknown> {
|
|
13
|
+
maxBatchSize: number;
|
|
14
|
+
flushIntervalMs: number;
|
|
15
|
+
processBatch: FunctionReference<"action", "internal", { items: T[] }>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface IteratorConfig<T = unknown> {
|
|
19
|
+
batchSize: number;
|
|
20
|
+
delayBetweenBatchesMs?: number;
|
|
21
|
+
getNextBatch: FunctionReference<
|
|
22
|
+
"query",
|
|
23
|
+
"internal",
|
|
24
|
+
{ cursor: string | undefined; batchSize: number }
|
|
25
|
+
>;
|
|
26
|
+
processBatch: FunctionReference<"action", "internal", { items: T[] }>;
|
|
27
|
+
onComplete?: FunctionReference<"mutation", "internal", { jobId: string; processedCount: number }>;
|
|
28
|
+
maxRetries?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Internal config interfaces (use string handles for component API)
|
|
32
|
+
interface InternalBatchConfig {
|
|
33
|
+
maxBatchSize: number;
|
|
34
|
+
flushIntervalMs: number;
|
|
35
|
+
processBatchHandle: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface InternalIteratorConfig {
|
|
39
|
+
batchSize: number;
|
|
40
|
+
delayBetweenBatchesMs?: number;
|
|
41
|
+
getNextBatchHandle: string;
|
|
42
|
+
processBatchHandle: string;
|
|
43
|
+
onCompleteHandle?: string;
|
|
44
|
+
maxRetries?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface BatchResult {
|
|
48
|
+
batchId: string;
|
|
49
|
+
itemCount: number;
|
|
50
|
+
flushed: boolean;
|
|
51
|
+
status: BatchStatus;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface FlushResult {
|
|
55
|
+
batchId: string;
|
|
56
|
+
itemCount: number;
|
|
57
|
+
flushed: boolean;
|
|
58
|
+
status?: BatchStatus;
|
|
59
|
+
reason?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface BatchStatusResult {
|
|
63
|
+
batchId: string; // Client's original ID
|
|
64
|
+
batches: Array<{
|
|
65
|
+
status: "accumulating" | "flushing";
|
|
66
|
+
itemCount: number;
|
|
67
|
+
createdAt: number;
|
|
68
|
+
lastUpdatedAt: number;
|
|
69
|
+
}>;
|
|
70
|
+
config: {
|
|
71
|
+
maxBatchSize: number;
|
|
72
|
+
flushIntervalMs: number;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface BatchListItem {
|
|
77
|
+
batchId: string;
|
|
78
|
+
baseBatchId: string;
|
|
79
|
+
sequence: number;
|
|
80
|
+
itemCount: number;
|
|
81
|
+
status: BatchStatus;
|
|
82
|
+
createdAt: number;
|
|
83
|
+
lastUpdatedAt: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface JobResult {
|
|
87
|
+
jobId: string;
|
|
88
|
+
status: JobStatus;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface JobStatusResult {
|
|
92
|
+
jobId: string;
|
|
93
|
+
status: JobStatus;
|
|
94
|
+
processedCount: number;
|
|
95
|
+
cursor?: string;
|
|
96
|
+
retryCount: number;
|
|
97
|
+
errorMessage?: string;
|
|
98
|
+
createdAt: number;
|
|
99
|
+
lastRunAt?: number;
|
|
100
|
+
config: {
|
|
101
|
+
batchSize: number;
|
|
102
|
+
delayBetweenBatchesMs: number;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface JobListItem {
|
|
107
|
+
jobId: string;
|
|
108
|
+
status: JobStatus;
|
|
109
|
+
processedCount: number;
|
|
110
|
+
createdAt: number;
|
|
111
|
+
lastRunAt?: number;
|
|
112
|
+
errorMessage?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface FlushHistoryItem {
|
|
116
|
+
batchId: string;
|
|
117
|
+
itemCount: number;
|
|
118
|
+
flushedAt: number;
|
|
119
|
+
durationMs: number;
|
|
120
|
+
success: boolean;
|
|
121
|
+
errorMessage?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface BatchProcessorAPI {
|
|
125
|
+
lib: {
|
|
126
|
+
addItems: FunctionReference<
|
|
127
|
+
"mutation",
|
|
128
|
+
"internal",
|
|
129
|
+
{ batchId: string; items: unknown[]; config: InternalBatchConfig },
|
|
130
|
+
BatchResult
|
|
131
|
+
>;
|
|
132
|
+
flushBatch: FunctionReference<"mutation", "internal", { batchId: string }, FlushResult>;
|
|
133
|
+
getBatchStatus: FunctionReference<
|
|
134
|
+
"query",
|
|
135
|
+
"internal",
|
|
136
|
+
{ batchId: string },
|
|
137
|
+
BatchStatusResult | null
|
|
138
|
+
>;
|
|
139
|
+
getFlushHistory: FunctionReference<
|
|
140
|
+
"query",
|
|
141
|
+
"internal",
|
|
142
|
+
{ batchId: string; limit?: number },
|
|
143
|
+
FlushHistoryItem[]
|
|
144
|
+
>;
|
|
145
|
+
getAllBatchesForBaseId: FunctionReference<
|
|
146
|
+
"query",
|
|
147
|
+
"internal",
|
|
148
|
+
{ baseBatchId: string },
|
|
149
|
+
BatchListItem[]
|
|
150
|
+
>;
|
|
151
|
+
deleteBatch: FunctionReference<
|
|
152
|
+
"mutation",
|
|
153
|
+
"internal",
|
|
154
|
+
{ batchId: string },
|
|
155
|
+
{ deleted: boolean; reason?: string }
|
|
156
|
+
>;
|
|
157
|
+
startIteratorJob: FunctionReference<
|
|
158
|
+
"mutation",
|
|
159
|
+
"internal",
|
|
160
|
+
{ jobId: string; config: InternalIteratorConfig },
|
|
161
|
+
JobResult
|
|
162
|
+
>;
|
|
163
|
+
pauseIteratorJob: FunctionReference<"mutation", "internal", { jobId: string }, JobResult>;
|
|
164
|
+
resumeIteratorJob: FunctionReference<"mutation", "internal", { jobId: string }, JobResult>;
|
|
165
|
+
cancelIteratorJob: FunctionReference<
|
|
166
|
+
"mutation",
|
|
167
|
+
"internal",
|
|
168
|
+
{ jobId: string },
|
|
169
|
+
JobResult & { reason?: string }
|
|
170
|
+
>;
|
|
171
|
+
getIteratorJobStatus: FunctionReference<
|
|
172
|
+
"query",
|
|
173
|
+
"internal",
|
|
174
|
+
{ jobId: string },
|
|
175
|
+
JobStatusResult | null
|
|
176
|
+
>;
|
|
177
|
+
listIteratorJobs: FunctionReference<
|
|
178
|
+
"query",
|
|
179
|
+
"internal",
|
|
180
|
+
{ status?: JobStatus; limit?: number },
|
|
181
|
+
JobListItem[]
|
|
182
|
+
>;
|
|
183
|
+
deleteIteratorJob: FunctionReference<
|
|
184
|
+
"mutation",
|
|
185
|
+
"internal",
|
|
186
|
+
{ jobId: string },
|
|
187
|
+
{ deleted: boolean; reason?: string }
|
|
188
|
+
>;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export class BatchProcessor<T = unknown> {
|
|
193
|
+
private component: BatchProcessorAPI;
|
|
194
|
+
private config?: BatchConfig<T>;
|
|
195
|
+
private processBatchHandle: string | null = null;
|
|
196
|
+
|
|
197
|
+
constructor(component: BatchProcessorAPI, config?: BatchConfig<T>) {
|
|
198
|
+
this.component = component;
|
|
199
|
+
this.config = config;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async addItems(ctx: GenericMutationCtx<any>, batchId: string, items: T[]): Promise<BatchResult> {
|
|
203
|
+
if (!this.config) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
"BatchProcessor config with processBatch is required to use addItems. Pass config to the constructor.",
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (!this.processBatchHandle) {
|
|
210
|
+
this.processBatchHandle = await createFunctionHandle(this.config.processBatch);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const internalConfig: InternalBatchConfig = {
|
|
214
|
+
maxBatchSize: this.config.maxBatchSize,
|
|
215
|
+
flushIntervalMs: this.config.flushIntervalMs,
|
|
216
|
+
processBatchHandle: this.processBatchHandle,
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
return await ctx.runMutation(this.component.lib.addItems, {
|
|
220
|
+
batchId,
|
|
221
|
+
items,
|
|
222
|
+
config: internalConfig,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async flush(ctx: GenericMutationCtx<any>, batchId: string): Promise<FlushResult> {
|
|
227
|
+
return await ctx.runMutation(this.component.lib.flushBatch, { batchId });
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async getBatchStatus(
|
|
231
|
+
ctx: GenericQueryCtx<any>,
|
|
232
|
+
batchId: string,
|
|
233
|
+
): Promise<BatchStatusResult | null> {
|
|
234
|
+
return await ctx.runQuery(this.component.lib.getBatchStatus, { batchId });
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
async getFlushHistory(
|
|
238
|
+
ctx: GenericQueryCtx<any>,
|
|
239
|
+
batchId: string,
|
|
240
|
+
limit?: number,
|
|
241
|
+
): Promise<FlushHistoryItem[]> {
|
|
242
|
+
return await ctx.runQuery(this.component.lib.getFlushHistory, { batchId, limit });
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
async getAllBatchesForBaseId(
|
|
246
|
+
ctx: GenericQueryCtx<any>,
|
|
247
|
+
baseBatchId: string,
|
|
248
|
+
): Promise<BatchListItem[]> {
|
|
249
|
+
return await ctx.runQuery(this.component.lib.getAllBatchesForBaseId, { baseBatchId });
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
async deleteBatch(
|
|
253
|
+
ctx: GenericMutationCtx<any>,
|
|
254
|
+
batchId: string,
|
|
255
|
+
): Promise<{ deleted: boolean; reason?: string }> {
|
|
256
|
+
return await ctx.runMutation(this.component.lib.deleteBatch, { batchId });
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async startIterator<T>(
|
|
260
|
+
ctx: GenericMutationCtx<any>,
|
|
261
|
+
jobId: string,
|
|
262
|
+
config: IteratorConfig<T>,
|
|
263
|
+
): Promise<JobResult> {
|
|
264
|
+
const internalConfig: InternalIteratorConfig = {
|
|
265
|
+
batchSize: config.batchSize,
|
|
266
|
+
delayBetweenBatchesMs: config.delayBetweenBatchesMs,
|
|
267
|
+
getNextBatchHandle: await createFunctionHandle(config.getNextBatch),
|
|
268
|
+
processBatchHandle: await createFunctionHandle(config.processBatch),
|
|
269
|
+
onCompleteHandle: config.onComplete
|
|
270
|
+
? await createFunctionHandle(config.onComplete)
|
|
271
|
+
: undefined,
|
|
272
|
+
maxRetries: config.maxRetries,
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
return await ctx.runMutation(this.component.lib.startIteratorJob, {
|
|
276
|
+
jobId,
|
|
277
|
+
config: internalConfig,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
async pauseIterator(ctx: GenericMutationCtx<any>, jobId: string): Promise<JobResult> {
|
|
282
|
+
return await ctx.runMutation(this.component.lib.pauseIteratorJob, { jobId });
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async resumeIterator(ctx: GenericMutationCtx<any>, jobId: string): Promise<JobResult> {
|
|
286
|
+
return await ctx.runMutation(this.component.lib.resumeIteratorJob, { jobId });
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
async cancelIterator(
|
|
290
|
+
ctx: GenericMutationCtx<any>,
|
|
291
|
+
jobId: string,
|
|
292
|
+
): Promise<JobResult & { reason?: string }> {
|
|
293
|
+
return await ctx.runMutation(this.component.lib.cancelIteratorJob, { jobId });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
async getIteratorStatus(
|
|
297
|
+
ctx: GenericQueryCtx<any>,
|
|
298
|
+
jobId: string,
|
|
299
|
+
): Promise<JobStatusResult | null> {
|
|
300
|
+
return await ctx.runQuery(this.component.lib.getIteratorJobStatus, { jobId });
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
async listIteratorJobs(
|
|
304
|
+
ctx: GenericQueryCtx<any>,
|
|
305
|
+
options?: { status?: JobStatus; limit?: number },
|
|
306
|
+
): Promise<JobListItem[]> {
|
|
307
|
+
return await ctx.runQuery(this.component.lib.listIteratorJobs, options ?? {});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
async deleteIteratorJob(
|
|
311
|
+
ctx: GenericMutationCtx<any>,
|
|
312
|
+
jobId: string,
|
|
313
|
+
): Promise<{ deleted: boolean; reason?: string }> {
|
|
314
|
+
return await ctx.runMutation(this.component.lib.deleteIteratorJob, { jobId });
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface GetNextBatchResult<T = unknown> {
|
|
319
|
+
items: T[];
|
|
320
|
+
cursor: string | undefined;
|
|
321
|
+
done: boolean;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export interface GetNextBatchArgs {
|
|
325
|
+
cursor: string | undefined;
|
|
326
|
+
batchSize: number;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface ProcessBatchArgs<T = unknown> {
|
|
330
|
+
items: T[];
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export interface OnCompleteArgs {
|
|
334
|
+
jobId: string;
|
|
335
|
+
processedCount: number;
|
|
336
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type * as lib from "../lib.js";
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
ApiFromModules,
|
|
15
|
+
FilterApi,
|
|
16
|
+
FunctionReference,
|
|
17
|
+
} from "convex/server";
|
|
18
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
19
|
+
|
|
20
|
+
const fullApi: ApiFromModules<{
|
|
21
|
+
lib: typeof lib;
|
|
22
|
+
}> = anyApi as any;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
26
|
+
*
|
|
27
|
+
* Usage:
|
|
28
|
+
* ```js
|
|
29
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export const api: FilterApi<
|
|
33
|
+
typeof fullApi,
|
|
34
|
+
FunctionReference<any, "public">
|
|
35
|
+
> = anyApi as any;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
39
|
+
*
|
|
40
|
+
* Usage:
|
|
41
|
+
* ```js
|
|
42
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export const internal: FilterApi<
|
|
46
|
+
typeof fullApi,
|
|
47
|
+
FunctionReference<any, "internal">
|
|
48
|
+
> = anyApi as any;
|
|
49
|
+
|
|
50
|
+
export const components = componentsGeneric() as unknown as {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `ComponentApi` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { FunctionReference } from "convex/server";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A utility for referencing a Convex component's exposed API.
|
|
15
|
+
*
|
|
16
|
+
* Useful when expecting a parameter like `components.myComponent`.
|
|
17
|
+
* Usage:
|
|
18
|
+
* ```ts
|
|
19
|
+
* async function myFunction(ctx: QueryCtx, component: ComponentApi) {
|
|
20
|
+
* return ctx.runQuery(component.someFile.someQuery, { ...args });
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
25
|
+
{
|
|
26
|
+
lib: {
|
|
27
|
+
addItems: FunctionReference<
|
|
28
|
+
"mutation",
|
|
29
|
+
"internal",
|
|
30
|
+
{
|
|
31
|
+
batchId: string;
|
|
32
|
+
config: {
|
|
33
|
+
flushIntervalMs: number;
|
|
34
|
+
maxBatchSize: number;
|
|
35
|
+
processBatchHandle: string;
|
|
36
|
+
};
|
|
37
|
+
items: Array<any>;
|
|
38
|
+
},
|
|
39
|
+
any,
|
|
40
|
+
Name
|
|
41
|
+
>;
|
|
42
|
+
cancelIteratorJob: FunctionReference<
|
|
43
|
+
"mutation",
|
|
44
|
+
"internal",
|
|
45
|
+
{ jobId: string },
|
|
46
|
+
any,
|
|
47
|
+
Name
|
|
48
|
+
>;
|
|
49
|
+
deleteBatch: FunctionReference<
|
|
50
|
+
"mutation",
|
|
51
|
+
"internal",
|
|
52
|
+
{ batchId: string },
|
|
53
|
+
any,
|
|
54
|
+
Name
|
|
55
|
+
>;
|
|
56
|
+
deleteIteratorJob: FunctionReference<
|
|
57
|
+
"mutation",
|
|
58
|
+
"internal",
|
|
59
|
+
{ jobId: string },
|
|
60
|
+
any,
|
|
61
|
+
Name
|
|
62
|
+
>;
|
|
63
|
+
flushBatch: FunctionReference<
|
|
64
|
+
"mutation",
|
|
65
|
+
"internal",
|
|
66
|
+
{ batchId: string },
|
|
67
|
+
any,
|
|
68
|
+
Name
|
|
69
|
+
>;
|
|
70
|
+
getAllBatchesForBaseId: FunctionReference<
|
|
71
|
+
"query",
|
|
72
|
+
"internal",
|
|
73
|
+
{ baseBatchId: string },
|
|
74
|
+
any,
|
|
75
|
+
Name
|
|
76
|
+
>;
|
|
77
|
+
getBatchStatus: FunctionReference<
|
|
78
|
+
"query",
|
|
79
|
+
"internal",
|
|
80
|
+
{ batchId: string },
|
|
81
|
+
any,
|
|
82
|
+
Name
|
|
83
|
+
>;
|
|
84
|
+
getFlushHistory: FunctionReference<
|
|
85
|
+
"query",
|
|
86
|
+
"internal",
|
|
87
|
+
{ batchId: string; limit?: number },
|
|
88
|
+
any,
|
|
89
|
+
Name
|
|
90
|
+
>;
|
|
91
|
+
getIteratorJobStatus: FunctionReference<
|
|
92
|
+
"query",
|
|
93
|
+
"internal",
|
|
94
|
+
{ jobId: string },
|
|
95
|
+
any,
|
|
96
|
+
Name
|
|
97
|
+
>;
|
|
98
|
+
listIteratorJobs: FunctionReference<
|
|
99
|
+
"query",
|
|
100
|
+
"internal",
|
|
101
|
+
{
|
|
102
|
+
limit?: number;
|
|
103
|
+
status?: "pending" | "running" | "paused" | "completed" | "failed";
|
|
104
|
+
},
|
|
105
|
+
any,
|
|
106
|
+
Name
|
|
107
|
+
>;
|
|
108
|
+
pauseIteratorJob: FunctionReference<
|
|
109
|
+
"mutation",
|
|
110
|
+
"internal",
|
|
111
|
+
{ jobId: string },
|
|
112
|
+
any,
|
|
113
|
+
Name
|
|
114
|
+
>;
|
|
115
|
+
resumeIteratorJob: FunctionReference<
|
|
116
|
+
"mutation",
|
|
117
|
+
"internal",
|
|
118
|
+
{ jobId: string },
|
|
119
|
+
any,
|
|
120
|
+
Name
|
|
121
|
+
>;
|
|
122
|
+
startIteratorJob: FunctionReference<
|
|
123
|
+
"mutation",
|
|
124
|
+
"internal",
|
|
125
|
+
{
|
|
126
|
+
config: {
|
|
127
|
+
batchSize: number;
|
|
128
|
+
delayBetweenBatchesMs?: number;
|
|
129
|
+
getNextBatchHandle: string;
|
|
130
|
+
maxRetries?: number;
|
|
131
|
+
onCompleteHandle?: string;
|
|
132
|
+
processBatchHandle: string;
|
|
133
|
+
};
|
|
134
|
+
jobId: string;
|
|
135
|
+
},
|
|
136
|
+
any,
|
|
137
|
+
Name
|
|
138
|
+
>;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated data model types.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
DataModelFromSchemaDefinition,
|
|
13
|
+
DocumentByName,
|
|
14
|
+
TableNamesInDataModel,
|
|
15
|
+
SystemTableNames,
|
|
16
|
+
} from "convex/server";
|
|
17
|
+
import type { GenericId } from "convex/values";
|
|
18
|
+
import schema from "../schema.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The names of all of your Convex tables.
|
|
22
|
+
*/
|
|
23
|
+
export type TableNames = TableNamesInDataModel<DataModel>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The type of a document stored in Convex.
|
|
27
|
+
*
|
|
28
|
+
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
29
|
+
*/
|
|
30
|
+
export type Doc<TableName extends TableNames> = DocumentByName<
|
|
31
|
+
DataModel,
|
|
32
|
+
TableName
|
|
33
|
+
>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* An identifier for a document in Convex.
|
|
37
|
+
*
|
|
38
|
+
* Convex documents are uniquely identified by their `Id`, which is accessible
|
|
39
|
+
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
|
|
40
|
+
*
|
|
41
|
+
* Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
|
|
42
|
+
*
|
|
43
|
+
* IDs are just strings at runtime, but this type can be used to distinguish them from other
|
|
44
|
+
* strings when type checking.
|
|
45
|
+
*
|
|
46
|
+
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
47
|
+
*/
|
|
48
|
+
export type Id<TableName extends TableNames | SystemTableNames> =
|
|
49
|
+
GenericId<TableName>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A type describing your Convex data model.
|
|
53
|
+
*
|
|
54
|
+
* This type includes information about what tables you have, the type of
|
|
55
|
+
* documents stored in those tables, and the indexes defined on them.
|
|
56
|
+
*
|
|
57
|
+
* This type is used to parameterize methods like `queryGeneric` and
|
|
58
|
+
* `mutationGeneric` to make them type-safe.
|
|
59
|
+
*/
|
|
60
|
+
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
|