@convex-dev/workos-authkit 0.1.6 → 0.2.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.
Files changed (35) hide show
  1. package/README.md +23 -0
  2. package/dist/client/index.d.ts +3 -0
  3. package/dist/client/index.d.ts.map +1 -1
  4. package/dist/client/index.js +24 -5
  5. package/dist/client/index.js.map +1 -1
  6. package/dist/component/_generated/api.d.ts +604 -6
  7. package/dist/component/_generated/api.d.ts.map +1 -1
  8. package/dist/component/_generated/api.js.map +1 -1
  9. package/dist/component/_generated/component.d.ts +18 -7
  10. package/dist/component/_generated/component.d.ts.map +1 -1
  11. package/dist/component/backfill.d.ts +60 -0
  12. package/dist/component/backfill.d.ts.map +1 -0
  13. package/dist/component/backfill.js +171 -0
  14. package/dist/component/backfill.js.map +1 -0
  15. package/dist/component/convex.config.d.ts.map +1 -1
  16. package/dist/component/convex.config.js +2 -0
  17. package/dist/component/convex.config.js.map +1 -1
  18. package/dist/component/lib.d.ts +27 -10
  19. package/dist/component/lib.d.ts.map +1 -1
  20. package/dist/component/lib.js +93 -80
  21. package/dist/component/lib.js.map +1 -1
  22. package/dist/component/schema.d.ts +7 -2
  23. package/dist/component/schema.d.ts.map +1 -1
  24. package/dist/component/schema.js +3 -0
  25. package/dist/component/schema.js.map +1 -1
  26. package/package.json +36 -34
  27. package/src/client/index.ts +24 -5
  28. package/src/component/_generated/api.ts +535 -6
  29. package/src/component/_generated/component.ts +25 -12
  30. package/src/component/backfill.test.ts +335 -0
  31. package/src/component/backfill.ts +217 -0
  32. package/src/component/convex.config.ts +2 -0
  33. package/src/component/lib.ts +103 -81
  34. package/src/component/schema.ts +3 -0
  35. package/src/test.ts +4 -0
@@ -8,6 +8,7 @@
8
8
  * @module
9
9
  */
10
10
 
11
+ import type * as backfill from "../backfill.js";
11
12
  import type * as lib from "../lib.js";
12
13
 
13
14
  import type {
@@ -18,6 +19,7 @@ import type {
18
19
  import { anyApi, componentsGeneric } from "convex/server";
19
20
 
20
21
  const fullApi: ApiFromModules<{
22
+ backfill: typeof backfill;
21
23
  lib: typeof lib;
22
24
  }> = anyApi as any;
23
25
 
@@ -49,13 +51,24 @@ export const internal: FilterApi<
49
51
 
50
52
  export const components = componentsGeneric() as unknown as {
51
53
  eventWorkpool: {
54
+ config: {
55
+ update: FunctionReference<
56
+ "mutation",
57
+ "internal",
58
+ {
59
+ logLevel?: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
60
+ maxParallelism?: number;
61
+ },
62
+ any
63
+ >;
64
+ };
52
65
  lib: {
53
66
  cancel: FunctionReference<
54
67
  "mutation",
55
68
  "internal",
56
69
  {
57
70
  id: string;
58
- logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
71
+ logLevel?: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
59
72
  },
60
73
  any
61
74
  >;
@@ -65,7 +78,7 @@ export const components = componentsGeneric() as unknown as {
65
78
  {
66
79
  before?: number;
67
80
  limit?: number;
68
- logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
81
+ logLevel?: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
69
82
  },
70
83
  any
71
84
  >;
@@ -74,8 +87,8 @@ export const components = componentsGeneric() as unknown as {
74
87
  "internal",
75
88
  {
76
89
  config: {
77
- logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
78
- maxParallelism: number;
90
+ logLevel?: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
91
+ maxParallelism?: number;
79
92
  };
80
93
  fnArgs: any;
81
94
  fnHandle: string;
@@ -96,8 +109,8 @@ export const components = componentsGeneric() as unknown as {
96
109
  "internal",
97
110
  {
98
111
  config: {
99
- logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
100
- maxParallelism: number;
112
+ logLevel?: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
113
+ maxParallelism?: number;
101
114
  };
102
115
  items: Array<{
103
116
  fnArgs: any;
@@ -135,4 +148,520 @@ export const components = componentsGeneric() as unknown as {
135
148
  >;
136
149
  };
137
150
  };
151
+ backfillWorkflow: {
152
+ event: {
153
+ create: FunctionReference<
154
+ "mutation",
155
+ "internal",
156
+ { name: string; workflowId: string },
157
+ string
158
+ >;
159
+ send: FunctionReference<
160
+ "mutation",
161
+ "internal",
162
+ {
163
+ eventId?: string;
164
+ name?: string;
165
+ result:
166
+ | { kind: "success"; returnValue: any }
167
+ | { error: string; kind: "failed" }
168
+ | { kind: "canceled" };
169
+ workflowId?: string;
170
+ workpoolOptions?: {
171
+ defaultRetryBehavior?: {
172
+ base: number;
173
+ initialBackoffMs: number;
174
+ maxAttempts: number;
175
+ };
176
+ logLevel?: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
177
+ maxParallelism?: number;
178
+ retryActionsByDefault?: boolean;
179
+ };
180
+ },
181
+ string
182
+ >;
183
+ };
184
+ journal: {
185
+ load: FunctionReference<
186
+ "query",
187
+ "internal",
188
+ { shortCircuit?: boolean; workflowId: string },
189
+ {
190
+ blocked?: boolean;
191
+ journalEntries: Array<{
192
+ _creationTime: number;
193
+ _id: string;
194
+ step:
195
+ | {
196
+ args: any;
197
+ argsSize: number;
198
+ completedAt?: number;
199
+ functionType: "query" | "mutation" | "action";
200
+ handle: string;
201
+ inProgress: boolean;
202
+ kind?: "function";
203
+ name: string;
204
+ runResult?:
205
+ | { kind: "success"; returnValue: any }
206
+ | { error: string; kind: "failed" }
207
+ | { kind: "canceled" };
208
+ startedAt: number;
209
+ workId?: string;
210
+ }
211
+ | {
212
+ args: any;
213
+ argsSize: number;
214
+ completedAt?: number;
215
+ handle: string;
216
+ inProgress: boolean;
217
+ kind: "workflow";
218
+ name: string;
219
+ runResult?:
220
+ | { kind: "success"; returnValue: any }
221
+ | { error: string; kind: "failed" }
222
+ | { kind: "canceled" };
223
+ startedAt: number;
224
+ workflowId?: string;
225
+ }
226
+ | {
227
+ args: { eventId?: string };
228
+ argsSize: number;
229
+ completedAt?: number;
230
+ eventId?: string;
231
+ inProgress: boolean;
232
+ kind: "event";
233
+ name: string;
234
+ runResult?:
235
+ | { kind: "success"; returnValue: any }
236
+ | { error: string; kind: "failed" }
237
+ | { kind: "canceled" };
238
+ startedAt: number;
239
+ }
240
+ | {
241
+ args: any;
242
+ argsSize: number;
243
+ completedAt?: number;
244
+ inProgress: boolean;
245
+ kind: "sleep";
246
+ name: string;
247
+ runResult?:
248
+ | { kind: "success"; returnValue: any }
249
+ | { error: string; kind: "failed" }
250
+ | { kind: "canceled" };
251
+ startedAt: number;
252
+ workId?: string;
253
+ };
254
+ stepNumber: number;
255
+ workflowId: string;
256
+ }>;
257
+ logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
258
+ ok: boolean;
259
+ workflow: {
260
+ _creationTime: number;
261
+ _id: string;
262
+ args: any;
263
+ generationNumber: number;
264
+ logLevel?: any;
265
+ name?: string;
266
+ onComplete?: { context?: any; fnHandle: string };
267
+ runResult?:
268
+ | { kind: "success"; returnValue: any }
269
+ | { error: string; kind: "failed" }
270
+ | { kind: "canceled" };
271
+ startedAt?: any;
272
+ state?: any;
273
+ workflowHandle: string;
274
+ };
275
+ }
276
+ >;
277
+ startSteps: FunctionReference<
278
+ "mutation",
279
+ "internal",
280
+ {
281
+ generationNumber: number;
282
+ steps: Array<{
283
+ retry?:
284
+ | boolean
285
+ | { base: number; initialBackoffMs: number; maxAttempts: number };
286
+ schedulerOptions?: { runAt?: number } | { runAfter?: number };
287
+ step:
288
+ | {
289
+ args: any;
290
+ argsSize: number;
291
+ completedAt?: number;
292
+ functionType: "query" | "mutation" | "action";
293
+ handle: string;
294
+ inProgress: boolean;
295
+ kind?: "function";
296
+ name: string;
297
+ runResult?:
298
+ | { kind: "success"; returnValue: any }
299
+ | { error: string; kind: "failed" }
300
+ | { kind: "canceled" };
301
+ startedAt: number;
302
+ workId?: string;
303
+ }
304
+ | {
305
+ args: any;
306
+ argsSize: number;
307
+ completedAt?: number;
308
+ handle: string;
309
+ inProgress: boolean;
310
+ kind: "workflow";
311
+ name: string;
312
+ runResult?:
313
+ | { kind: "success"; returnValue: any }
314
+ | { error: string; kind: "failed" }
315
+ | { kind: "canceled" };
316
+ startedAt: number;
317
+ workflowId?: string;
318
+ }
319
+ | {
320
+ args: { eventId?: string };
321
+ argsSize: number;
322
+ completedAt?: number;
323
+ eventId?: string;
324
+ inProgress: boolean;
325
+ kind: "event";
326
+ name: string;
327
+ runResult?:
328
+ | { kind: "success"; returnValue: any }
329
+ | { error: string; kind: "failed" }
330
+ | { kind: "canceled" };
331
+ startedAt: number;
332
+ }
333
+ | {
334
+ args: any;
335
+ argsSize: number;
336
+ completedAt?: number;
337
+ inProgress: boolean;
338
+ kind: "sleep";
339
+ name: string;
340
+ runResult?:
341
+ | { kind: "success"; returnValue: any }
342
+ | { error: string; kind: "failed" }
343
+ | { kind: "canceled" };
344
+ startedAt: number;
345
+ workId?: string;
346
+ };
347
+ }>;
348
+ workflowId: string;
349
+ workpoolOptions?: {
350
+ defaultRetryBehavior?: {
351
+ base: number;
352
+ initialBackoffMs: number;
353
+ maxAttempts: number;
354
+ };
355
+ logLevel?: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
356
+ maxParallelism?: number;
357
+ retryActionsByDefault?: boolean;
358
+ };
359
+ },
360
+ Array<{
361
+ _creationTime: number;
362
+ _id: string;
363
+ step:
364
+ | {
365
+ args: any;
366
+ argsSize: number;
367
+ completedAt?: number;
368
+ functionType: "query" | "mutation" | "action";
369
+ handle: string;
370
+ inProgress: boolean;
371
+ kind?: "function";
372
+ name: string;
373
+ runResult?:
374
+ | { kind: "success"; returnValue: any }
375
+ | { error: string; kind: "failed" }
376
+ | { kind: "canceled" };
377
+ startedAt: number;
378
+ workId?: string;
379
+ }
380
+ | {
381
+ args: any;
382
+ argsSize: number;
383
+ completedAt?: number;
384
+ handle: string;
385
+ inProgress: boolean;
386
+ kind: "workflow";
387
+ name: string;
388
+ runResult?:
389
+ | { kind: "success"; returnValue: any }
390
+ | { error: string; kind: "failed" }
391
+ | { kind: "canceled" };
392
+ startedAt: number;
393
+ workflowId?: string;
394
+ }
395
+ | {
396
+ args: { eventId?: string };
397
+ argsSize: number;
398
+ completedAt?: number;
399
+ eventId?: string;
400
+ inProgress: boolean;
401
+ kind: "event";
402
+ name: string;
403
+ runResult?:
404
+ | { kind: "success"; returnValue: any }
405
+ | { error: string; kind: "failed" }
406
+ | { kind: "canceled" };
407
+ startedAt: number;
408
+ }
409
+ | {
410
+ args: any;
411
+ argsSize: number;
412
+ completedAt?: number;
413
+ inProgress: boolean;
414
+ kind: "sleep";
415
+ name: string;
416
+ runResult?:
417
+ | { kind: "success"; returnValue: any }
418
+ | { error: string; kind: "failed" }
419
+ | { kind: "canceled" };
420
+ startedAt: number;
421
+ workId?: string;
422
+ };
423
+ stepNumber: number;
424
+ workflowId: string;
425
+ }>
426
+ >;
427
+ };
428
+ workflow: {
429
+ cancel: FunctionReference<
430
+ "mutation",
431
+ "internal",
432
+ { workflowId: string },
433
+ null
434
+ >;
435
+ cleanup: FunctionReference<
436
+ "mutation",
437
+ "internal",
438
+ { force?: boolean; workflowId: string },
439
+ boolean
440
+ >;
441
+ complete: FunctionReference<
442
+ "mutation",
443
+ "internal",
444
+ {
445
+ generationNumber: number;
446
+ runResult:
447
+ | { kind: "success"; returnValue: any }
448
+ | { error: string; kind: "failed" }
449
+ | { kind: "canceled" };
450
+ workflowId: string;
451
+ },
452
+ null
453
+ >;
454
+ create: FunctionReference<
455
+ "mutation",
456
+ "internal",
457
+ {
458
+ maxParallelism?: number;
459
+ onComplete?: { context?: any; fnHandle: string };
460
+ startAsync?: boolean;
461
+ workflowArgs: any;
462
+ workflowHandle: string;
463
+ workflowName: string;
464
+ },
465
+ string
466
+ >;
467
+ getStatus: FunctionReference<
468
+ "query",
469
+ "internal",
470
+ { workflowId: string },
471
+ {
472
+ inProgress: Array<{
473
+ _creationTime: number;
474
+ _id: string;
475
+ step:
476
+ | {
477
+ args: any;
478
+ argsSize: number;
479
+ completedAt?: number;
480
+ functionType: "query" | "mutation" | "action";
481
+ handle: string;
482
+ inProgress: boolean;
483
+ kind?: "function";
484
+ name: string;
485
+ runResult?:
486
+ | { kind: "success"; returnValue: any }
487
+ | { error: string; kind: "failed" }
488
+ | { kind: "canceled" };
489
+ startedAt: number;
490
+ workId?: string;
491
+ }
492
+ | {
493
+ args: any;
494
+ argsSize: number;
495
+ completedAt?: number;
496
+ handle: string;
497
+ inProgress: boolean;
498
+ kind: "workflow";
499
+ name: string;
500
+ runResult?:
501
+ | { kind: "success"; returnValue: any }
502
+ | { error: string; kind: "failed" }
503
+ | { kind: "canceled" };
504
+ startedAt: number;
505
+ workflowId?: string;
506
+ }
507
+ | {
508
+ args: { eventId?: string };
509
+ argsSize: number;
510
+ completedAt?: number;
511
+ eventId?: string;
512
+ inProgress: boolean;
513
+ kind: "event";
514
+ name: string;
515
+ runResult?:
516
+ | { kind: "success"; returnValue: any }
517
+ | { error: string; kind: "failed" }
518
+ | { kind: "canceled" };
519
+ startedAt: number;
520
+ }
521
+ | {
522
+ args: any;
523
+ argsSize: number;
524
+ completedAt?: number;
525
+ inProgress: boolean;
526
+ kind: "sleep";
527
+ name: string;
528
+ runResult?:
529
+ | { kind: "success"; returnValue: any }
530
+ | { error: string; kind: "failed" }
531
+ | { kind: "canceled" };
532
+ startedAt: number;
533
+ workId?: string;
534
+ };
535
+ stepNumber: number;
536
+ workflowId: string;
537
+ }>;
538
+ logLevel: "DEBUG" | "TRACE" | "INFO" | "REPORT" | "WARN" | "ERROR";
539
+ workflow: {
540
+ _creationTime: number;
541
+ _id: string;
542
+ args: any;
543
+ generationNumber: number;
544
+ logLevel?: any;
545
+ name?: string;
546
+ onComplete?: { context?: any; fnHandle: string };
547
+ runResult?:
548
+ | { kind: "success"; returnValue: any }
549
+ | { error: string; kind: "failed" }
550
+ | { kind: "canceled" };
551
+ startedAt?: any;
552
+ state?: any;
553
+ workflowHandle: string;
554
+ };
555
+ }
556
+ >;
557
+ list: FunctionReference<
558
+ "query",
559
+ "internal",
560
+ {
561
+ order: "asc" | "desc";
562
+ paginationOpts: {
563
+ cursor: string | null;
564
+ endCursor?: string | null;
565
+ id?: number;
566
+ maximumBytesRead?: number;
567
+ maximumRowsRead?: number;
568
+ numItems: number;
569
+ };
570
+ },
571
+ {
572
+ continueCursor: string;
573
+ isDone: boolean;
574
+ page: Array<{
575
+ args: any;
576
+ context?: any;
577
+ name?: string;
578
+ runResult?:
579
+ | { kind: "success"; returnValue: any }
580
+ | { error: string; kind: "failed" }
581
+ | { kind: "canceled" };
582
+ workflowId: string;
583
+ }>;
584
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null;
585
+ splitCursor?: string | null;
586
+ }
587
+ >;
588
+ listByName: FunctionReference<
589
+ "query",
590
+ "internal",
591
+ {
592
+ name: string;
593
+ order: "asc" | "desc";
594
+ paginationOpts: {
595
+ cursor: string | null;
596
+ endCursor?: string | null;
597
+ id?: number;
598
+ maximumBytesRead?: number;
599
+ maximumRowsRead?: number;
600
+ numItems: number;
601
+ };
602
+ },
603
+ {
604
+ continueCursor: string;
605
+ isDone: boolean;
606
+ page: Array<{
607
+ args: any;
608
+ context?: any;
609
+ name?: string;
610
+ runResult?:
611
+ | { kind: "success"; returnValue: any }
612
+ | { error: string; kind: "failed" }
613
+ | { kind: "canceled" };
614
+ workflowId: string;
615
+ }>;
616
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null;
617
+ splitCursor?: string | null;
618
+ }
619
+ >;
620
+ listSteps: FunctionReference<
621
+ "query",
622
+ "internal",
623
+ {
624
+ order: "asc" | "desc";
625
+ paginationOpts: {
626
+ cursor: string | null;
627
+ endCursor?: string | null;
628
+ id?: number;
629
+ maximumBytesRead?: number;
630
+ maximumRowsRead?: number;
631
+ numItems: number;
632
+ };
633
+ workflowId: string;
634
+ },
635
+ {
636
+ continueCursor: string;
637
+ isDone: boolean;
638
+ page: Array<{
639
+ args: any;
640
+ completedAt?: number;
641
+ eventId?: string;
642
+ kind: "function" | "workflow" | "event" | "sleep";
643
+ name: string;
644
+ nestedWorkflowId?: string;
645
+ runResult?:
646
+ | { kind: "success"; returnValue: any }
647
+ | { error: string; kind: "failed" }
648
+ | { kind: "canceled" };
649
+ startedAt: number;
650
+ stepId: string;
651
+ stepNumber: number;
652
+ workId?: string;
653
+ workflowId: string;
654
+ }>;
655
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null;
656
+ splitCursor?: string | null;
657
+ }
658
+ >;
659
+ restart: FunctionReference<
660
+ "mutation",
661
+ "internal",
662
+ { from?: number | string; startAsync?: boolean; workflowId: string },
663
+ null
664
+ >;
665
+ };
666
+ };
138
667
  };
@@ -23,22 +23,16 @@ import type { FunctionReference } from "convex/server";
23
23
  */
24
24
  export type ComponentApi<Name extends string | undefined = string | undefined> =
25
25
  {
26
- lib: {
27
- enqueueWebhookEvent: FunctionReference<
26
+ backfill: {
27
+ startBackfill: FunctionReference<
28
28
  "mutation",
29
29
  "internal",
30
- {
31
- apiKey: string;
32
- event: string;
33
- eventId: string;
34
- eventTypes?: Array<string>;
35
- logLevel?: "DEBUG";
36
- onEventHandle?: string;
37
- updatedAt?: string;
38
- },
39
- any,
30
+ { apiKey: string; logLevel?: "DEBUG"; onEventHandle?: string },
31
+ null,
40
32
  Name
41
33
  >;
34
+ };
35
+ lib: {
42
36
  getAuthUser: FunctionReference<
43
37
  "query",
44
38
  "internal",
@@ -59,5 +53,24 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
59
53
  } | null,
60
54
  Name
61
55
  >;
56
+ onWebhookEvent: FunctionReference<
57
+ "mutation",
58
+ "internal",
59
+ {
60
+ apiKey: string;
61
+ event: {
62
+ context?: Record<string, any>;
63
+ createdAt: string;
64
+ data: Record<string, any>;
65
+ event: string;
66
+ id: string;
67
+ };
68
+ eventTypes?: Array<string>;
69
+ logLevel?: "DEBUG";
70
+ onEventHandle?: string;
71
+ },
72
+ null,
73
+ Name
74
+ >;
62
75
  };
63
76
  };