@mastra/inngest 0.0.0-vnext-inngest-20250506123700 → 0.0.0-vnext-inngest-20250506132005
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/CHANGELOG.md +2 -2
- package/dist/_tsup-dts-rollup.d.cts +2 -2
- package/dist/_tsup-dts-rollup.d.ts +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +4 -4
- package/src/index.test.ts +278 -168
- package/src/index.ts +2 -2
package/src/index.test.ts
CHANGED
|
@@ -42,12 +42,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
42
42
|
|
|
43
43
|
describe('Basic Workflow Execution', () => {
|
|
44
44
|
it('should execute a single step workflow successfully', async ctx => {
|
|
45
|
-
const
|
|
45
|
+
const inngest = new Inngest({
|
|
46
46
|
id: 'mastra',
|
|
47
47
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
const { createWorkflow, createStep } = init(
|
|
50
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
51
51
|
const execute = vi.fn<any>().mockResolvedValue({ result: 'success' });
|
|
52
52
|
const step1 = createStep({
|
|
53
53
|
id: 'step1',
|
|
@@ -80,7 +80,7 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
80
80
|
{
|
|
81
81
|
path: '/inngest/api',
|
|
82
82
|
method: 'ALL',
|
|
83
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
83
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
84
84
|
},
|
|
85
85
|
],
|
|
86
86
|
},
|
|
@@ -107,12 +107,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
it('should execute multiple steps in parallel', async ctx => {
|
|
110
|
-
const
|
|
110
|
+
const inngest = new Inngest({
|
|
111
111
|
id: 'mastra',
|
|
112
112
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
const { createWorkflow, createStep } = init(
|
|
115
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
116
116
|
|
|
117
117
|
const step1Action = vi.fn().mockImplementation(async () => {
|
|
118
118
|
return { value: 'step1' };
|
|
@@ -157,14 +157,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
157
157
|
{
|
|
158
158
|
path: '/inngest/api',
|
|
159
159
|
method: 'ALL',
|
|
160
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
160
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
161
161
|
},
|
|
162
162
|
],
|
|
163
163
|
},
|
|
164
164
|
});
|
|
165
165
|
|
|
166
166
|
const app = await createHonoServer(mastra);
|
|
167
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
168
167
|
|
|
169
168
|
const srv = serve({
|
|
170
169
|
fetch: app.fetch,
|
|
@@ -187,12 +186,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
187
186
|
});
|
|
188
187
|
|
|
189
188
|
it('should execute steps sequentially', async ctx => {
|
|
190
|
-
const
|
|
189
|
+
const inngest = new Inngest({
|
|
191
190
|
id: 'mastra',
|
|
192
191
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
193
192
|
});
|
|
194
193
|
|
|
195
|
-
const { createWorkflow, createStep } = init(
|
|
194
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
196
195
|
|
|
197
196
|
const executionOrder: string[] = [];
|
|
198
197
|
|
|
@@ -241,14 +240,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
241
240
|
{
|
|
242
241
|
path: '/inngest/api',
|
|
243
242
|
method: 'ALL',
|
|
244
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
243
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
245
244
|
},
|
|
246
245
|
],
|
|
247
246
|
},
|
|
248
247
|
});
|
|
249
248
|
|
|
250
249
|
const app = await createHonoServer(mastra);
|
|
251
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
252
250
|
|
|
253
251
|
const srv = serve({
|
|
254
252
|
fetch: app.fetch,
|
|
@@ -272,12 +270,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
272
270
|
|
|
273
271
|
describe('Variable Resolution', () => {
|
|
274
272
|
it('should resolve trigger data', async ctx => {
|
|
275
|
-
const
|
|
273
|
+
const inngest = new Inngest({
|
|
276
274
|
id: 'mastra',
|
|
277
275
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
278
276
|
});
|
|
279
277
|
|
|
280
|
-
const { createWorkflow, createStep } = init(
|
|
278
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
281
279
|
|
|
282
280
|
const execute = vi.fn<any>().mockResolvedValue({ result: 'success' });
|
|
283
281
|
|
|
@@ -316,14 +314,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
316
314
|
{
|
|
317
315
|
path: '/inngest/api',
|
|
318
316
|
method: 'ALL',
|
|
319
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
317
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
320
318
|
},
|
|
321
319
|
],
|
|
322
320
|
},
|
|
323
321
|
});
|
|
324
322
|
|
|
325
323
|
const app = await createHonoServer(mastra);
|
|
326
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
327
324
|
|
|
328
325
|
const srv = serve({
|
|
329
326
|
fetch: app.fetch,
|
|
@@ -340,12 +337,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
340
337
|
});
|
|
341
338
|
|
|
342
339
|
it('should provide access to step results and trigger data via getStepResult helper', async ctx => {
|
|
343
|
-
const
|
|
340
|
+
const inngest = new Inngest({
|
|
344
341
|
id: 'mastra',
|
|
345
342
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
346
343
|
});
|
|
347
344
|
|
|
348
|
-
const { createWorkflow, createStep } = init(
|
|
345
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
349
346
|
|
|
350
347
|
const step1Action = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
351
348
|
// Test accessing trigger data with correct type
|
|
@@ -406,14 +403,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
406
403
|
{
|
|
407
404
|
path: '/inngest/api',
|
|
408
405
|
method: 'ALL',
|
|
409
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
406
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
410
407
|
},
|
|
411
408
|
],
|
|
412
409
|
},
|
|
413
410
|
});
|
|
414
411
|
|
|
415
412
|
const app = await createHonoServer(mastra);
|
|
416
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
417
413
|
|
|
418
414
|
const srv = serve({
|
|
419
415
|
fetch: app.fetch,
|
|
@@ -435,12 +431,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
435
431
|
});
|
|
436
432
|
|
|
437
433
|
it('should resolve trigger data from context', async ctx => {
|
|
438
|
-
const
|
|
434
|
+
const inngest = new Inngest({
|
|
439
435
|
id: 'mastra',
|
|
440
436
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
441
437
|
});
|
|
442
438
|
|
|
443
|
-
const { createWorkflow, createStep } = init(
|
|
439
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
444
440
|
|
|
445
441
|
const execute = vi.fn<any>().mockResolvedValue({ result: 'success' });
|
|
446
442
|
const triggerSchema = z.object({
|
|
@@ -476,14 +472,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
476
472
|
{
|
|
477
473
|
path: '/inngest/api',
|
|
478
474
|
method: 'ALL',
|
|
479
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
475
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
480
476
|
},
|
|
481
477
|
],
|
|
482
478
|
},
|
|
483
479
|
});
|
|
484
480
|
|
|
485
481
|
const app = await createHonoServer(mastra);
|
|
486
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
487
482
|
|
|
488
483
|
const srv = serve({
|
|
489
484
|
fetch: app.fetch,
|
|
@@ -503,12 +498,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
503
498
|
});
|
|
504
499
|
|
|
505
500
|
it('should resolve trigger data from getInitData', async ctx => {
|
|
506
|
-
const
|
|
501
|
+
const inngest = new Inngest({
|
|
507
502
|
id: 'mastra',
|
|
508
503
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
509
504
|
});
|
|
510
505
|
|
|
511
|
-
const { createWorkflow, createStep } = init(
|
|
506
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
512
507
|
|
|
513
508
|
const execute = vi.fn<any>().mockResolvedValue({ result: 'success' });
|
|
514
509
|
const triggerSchema = z.object({
|
|
@@ -554,14 +549,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
554
549
|
{
|
|
555
550
|
path: '/inngest/api',
|
|
556
551
|
method: 'ALL',
|
|
557
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
552
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
558
553
|
},
|
|
559
554
|
],
|
|
560
555
|
},
|
|
561
556
|
});
|
|
562
557
|
|
|
563
558
|
const app = await createHonoServer(mastra);
|
|
564
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
565
559
|
|
|
566
560
|
const srv = serve({
|
|
567
561
|
fetch: app.fetch,
|
|
@@ -583,12 +577,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
583
577
|
});
|
|
584
578
|
|
|
585
579
|
it('should resolve variables from previous steps', async ctx => {
|
|
586
|
-
const
|
|
580
|
+
const inngest = new Inngest({
|
|
587
581
|
id: 'mastra',
|
|
588
582
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
589
583
|
});
|
|
590
584
|
|
|
591
|
-
const { createWorkflow, createStep } = init(
|
|
585
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
592
586
|
|
|
593
587
|
const step1Action = vi.fn<any>().mockResolvedValue({
|
|
594
588
|
nested: { value: 'step1-data' },
|
|
@@ -639,14 +633,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
639
633
|
{
|
|
640
634
|
path: '/inngest/api',
|
|
641
635
|
method: 'ALL',
|
|
642
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
636
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
643
637
|
},
|
|
644
638
|
],
|
|
645
639
|
},
|
|
646
640
|
});
|
|
647
641
|
|
|
648
642
|
const app = await createHonoServer(mastra);
|
|
649
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
650
643
|
|
|
651
644
|
const srv = serve({
|
|
652
645
|
fetch: app.fetch,
|
|
@@ -670,12 +663,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
670
663
|
|
|
671
664
|
describe('Simple Conditions', () => {
|
|
672
665
|
it('should follow conditional chains', async ctx => {
|
|
673
|
-
const
|
|
666
|
+
const inngest = new Inngest({
|
|
674
667
|
id: 'mastra',
|
|
675
668
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
676
669
|
});
|
|
677
670
|
|
|
678
|
-
const { createWorkflow, createStep } = init(
|
|
671
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
679
672
|
|
|
680
673
|
const step1Action = vi.fn().mockImplementation(() => {
|
|
681
674
|
return Promise.resolve({ status: 'success' });
|
|
@@ -745,14 +738,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
745
738
|
{
|
|
746
739
|
path: '/inngest/api',
|
|
747
740
|
method: 'ALL',
|
|
748
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
741
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
749
742
|
},
|
|
750
743
|
],
|
|
751
744
|
},
|
|
752
745
|
});
|
|
753
746
|
|
|
754
747
|
const app = await createHonoServer(mastra);
|
|
755
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
756
748
|
|
|
757
749
|
const srv = serve({
|
|
758
750
|
fetch: app.fetch,
|
|
@@ -774,12 +766,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
774
766
|
});
|
|
775
767
|
|
|
776
768
|
it('should handle failing dependencies', async ctx => {
|
|
777
|
-
const
|
|
769
|
+
const inngest = new Inngest({
|
|
778
770
|
id: 'mastra',
|
|
779
771
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
780
772
|
});
|
|
781
773
|
|
|
782
|
-
const { createWorkflow, createStep } = init(
|
|
774
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
783
775
|
|
|
784
776
|
let err: Error | undefined;
|
|
785
777
|
const step1Action = vi.fn<any>().mockImplementation(() => {
|
|
@@ -824,14 +816,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
824
816
|
{
|
|
825
817
|
path: '/inngest/api',
|
|
826
818
|
method: 'ALL',
|
|
827
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
819
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
828
820
|
},
|
|
829
821
|
],
|
|
830
822
|
},
|
|
831
823
|
});
|
|
832
824
|
|
|
833
825
|
const app = await createHonoServer(mastra);
|
|
834
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
835
826
|
|
|
836
827
|
const srv = serve({
|
|
837
828
|
fetch: app.fetch,
|
|
@@ -857,12 +848,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
857
848
|
});
|
|
858
849
|
|
|
859
850
|
it('should support simple string conditions', async ctx => {
|
|
860
|
-
const
|
|
851
|
+
const inngest = new Inngest({
|
|
861
852
|
id: 'mastra',
|
|
862
853
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
863
854
|
});
|
|
864
855
|
|
|
865
|
-
const { createWorkflow, createStep } = init(
|
|
856
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
866
857
|
|
|
867
858
|
const step1Action = vi.fn<any>().mockResolvedValue({ status: 'success' });
|
|
868
859
|
const step2Action = vi.fn<any>().mockResolvedValue({ result: 'step2' });
|
|
@@ -932,14 +923,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
932
923
|
{
|
|
933
924
|
path: '/inngest/api',
|
|
934
925
|
method: 'ALL',
|
|
935
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
926
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
936
927
|
},
|
|
937
928
|
],
|
|
938
929
|
},
|
|
939
930
|
});
|
|
940
931
|
|
|
941
932
|
const app = await createHonoServer(mastra);
|
|
942
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
943
933
|
|
|
944
934
|
const srv = serve({
|
|
945
935
|
fetch: app.fetch,
|
|
@@ -961,12 +951,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
961
951
|
});
|
|
962
952
|
|
|
963
953
|
it('should support custom condition functions', async ctx => {
|
|
964
|
-
const
|
|
954
|
+
const inngest = new Inngest({
|
|
965
955
|
id: 'mastra',
|
|
966
956
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
967
957
|
});
|
|
968
958
|
|
|
969
|
-
const { createWorkflow, createStep } = init(
|
|
959
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
970
960
|
|
|
971
961
|
const step1Action = vi.fn<any>().mockResolvedValue({ count: 5 });
|
|
972
962
|
const step2Action = vi.fn<any>();
|
|
@@ -1018,14 +1008,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1018
1008
|
{
|
|
1019
1009
|
path: '/inngest/api',
|
|
1020
1010
|
method: 'ALL',
|
|
1021
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
1011
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
1022
1012
|
},
|
|
1023
1013
|
],
|
|
1024
1014
|
},
|
|
1025
1015
|
});
|
|
1026
1016
|
|
|
1027
1017
|
const app = await createHonoServer(mastra);
|
|
1028
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
1029
1018
|
|
|
1030
1019
|
const srv = serve({
|
|
1031
1020
|
fetch: app.fetch,
|
|
@@ -1050,12 +1039,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1050
1039
|
|
|
1051
1040
|
describe('Error Handling', () => {
|
|
1052
1041
|
it('should handle step execution errors', async ctx => {
|
|
1053
|
-
const
|
|
1042
|
+
const inngest = new Inngest({
|
|
1054
1043
|
id: 'mastra',
|
|
1055
1044
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
1056
1045
|
});
|
|
1057
1046
|
|
|
1058
|
-
const { createWorkflow, createStep } = init(
|
|
1047
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
1059
1048
|
|
|
1060
1049
|
const error = new Error('Step execution failed');
|
|
1061
1050
|
const failingAction = vi.fn<any>().mockRejectedValue(error);
|
|
@@ -1089,14 +1078,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1089
1078
|
{
|
|
1090
1079
|
path: '/inngest/api',
|
|
1091
1080
|
method: 'ALL',
|
|
1092
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
1081
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
1093
1082
|
},
|
|
1094
1083
|
],
|
|
1095
1084
|
},
|
|
1096
1085
|
});
|
|
1097
1086
|
|
|
1098
1087
|
const app = await createHonoServer(mastra);
|
|
1099
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
1100
1088
|
|
|
1101
1089
|
const srv = serve({
|
|
1102
1090
|
fetch: app.fetch,
|
|
@@ -1119,12 +1107,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1119
1107
|
});
|
|
1120
1108
|
|
|
1121
1109
|
it('should handle step execution errors within branches', async ctx => {
|
|
1122
|
-
const
|
|
1110
|
+
const inngest = new Inngest({
|
|
1123
1111
|
id: 'mastra',
|
|
1124
1112
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
1125
1113
|
});
|
|
1126
1114
|
|
|
1127
|
-
const { createWorkflow, createStep } = init(
|
|
1115
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
1128
1116
|
|
|
1129
1117
|
const error = new Error('Step execution failed');
|
|
1130
1118
|
const failingAction = vi.fn<any>().mockRejectedValue(error);
|
|
@@ -1176,14 +1164,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1176
1164
|
{
|
|
1177
1165
|
path: '/inngest/api',
|
|
1178
1166
|
method: 'ALL',
|
|
1179
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
1167
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
1180
1168
|
},
|
|
1181
1169
|
],
|
|
1182
1170
|
},
|
|
1183
1171
|
});
|
|
1184
1172
|
|
|
1185
1173
|
const app = await createHonoServer(mastra);
|
|
1186
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
1187
1174
|
|
|
1188
1175
|
const srv = serve({
|
|
1189
1176
|
fetch: app.fetch,
|
|
@@ -1208,12 +1195,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1208
1195
|
});
|
|
1209
1196
|
|
|
1210
1197
|
it('should handle step execution errors within nested workflows', async ctx => {
|
|
1211
|
-
const
|
|
1198
|
+
const inngest = new Inngest({
|
|
1212
1199
|
id: 'mastra',
|
|
1213
1200
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
1214
1201
|
});
|
|
1215
1202
|
|
|
1216
|
-
const { createWorkflow, createStep } = init(
|
|
1203
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
1217
1204
|
|
|
1218
1205
|
const error = new Error('Step execution failed');
|
|
1219
1206
|
const failingAction = vi.fn<any>().mockRejectedValue(error);
|
|
@@ -1268,10 +1255,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1268
1255
|
vnext_workflows: {
|
|
1269
1256
|
'main-workflow': mainWorkflow,
|
|
1270
1257
|
},
|
|
1258
|
+
server: {
|
|
1259
|
+
apiRoutes: [
|
|
1260
|
+
{
|
|
1261
|
+
path: '/inngest/api',
|
|
1262
|
+
method: 'ALL',
|
|
1263
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
1264
|
+
},
|
|
1265
|
+
],
|
|
1266
|
+
},
|
|
1271
1267
|
});
|
|
1272
1268
|
|
|
1273
1269
|
const app = await createHonoServer(mastra);
|
|
1274
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
1275
1270
|
|
|
1276
1271
|
const srv = serve({
|
|
1277
1272
|
fetch: app.fetch,
|
|
@@ -1295,12 +1290,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1295
1290
|
|
|
1296
1291
|
describe('Complex Conditions', () => {
|
|
1297
1292
|
it('should handle nested AND/OR conditions', async ctx => {
|
|
1298
|
-
const
|
|
1293
|
+
const inngest = new Inngest({
|
|
1299
1294
|
id: 'mastra',
|
|
1300
1295
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
1301
1296
|
});
|
|
1302
1297
|
|
|
1303
|
-
const { createWorkflow, createStep } = init(
|
|
1298
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
1304
1299
|
|
|
1305
1300
|
const step1Action = vi.fn<any>().mockResolvedValue({
|
|
1306
1301
|
status: 'partial',
|
|
@@ -1395,14 +1390,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1395
1390
|
{
|
|
1396
1391
|
path: '/inngest/api',
|
|
1397
1392
|
method: 'ALL',
|
|
1398
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
1393
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
1399
1394
|
},
|
|
1400
1395
|
],
|
|
1401
1396
|
},
|
|
1402
1397
|
});
|
|
1403
1398
|
|
|
1404
1399
|
const app = await createHonoServer(mastra);
|
|
1405
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
1406
1400
|
|
|
1407
1401
|
const srv = serve({
|
|
1408
1402
|
fetch: app.fetch,
|
|
@@ -1423,12 +1417,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1423
1417
|
|
|
1424
1418
|
describe('Loops', () => {
|
|
1425
1419
|
it('should run an until loop', async ctx => {
|
|
1426
|
-
const
|
|
1420
|
+
const inngest = new Inngest({
|
|
1427
1421
|
id: 'mastra',
|
|
1428
1422
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
1429
1423
|
});
|
|
1430
1424
|
|
|
1431
|
-
const { createWorkflow, createStep } = init(
|
|
1425
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
1432
1426
|
|
|
1433
1427
|
const increment = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
1434
1428
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -1495,10 +1489,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1495
1489
|
vnext_workflows: {
|
|
1496
1490
|
'test-workflow': counterWorkflow,
|
|
1497
1491
|
},
|
|
1492
|
+
server: {
|
|
1493
|
+
apiRoutes: [
|
|
1494
|
+
{
|
|
1495
|
+
path: '/inngest/api',
|
|
1496
|
+
method: 'ALL',
|
|
1497
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
1498
|
+
},
|
|
1499
|
+
],
|
|
1500
|
+
},
|
|
1498
1501
|
});
|
|
1499
1502
|
|
|
1500
1503
|
const app = await createHonoServer(mastra);
|
|
1501
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
1502
1504
|
|
|
1503
1505
|
const srv = serve({
|
|
1504
1506
|
fetch: app.fetch,
|
|
@@ -1520,12 +1522,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1520
1522
|
});
|
|
1521
1523
|
|
|
1522
1524
|
it('should run a while loop', async ctx => {
|
|
1523
|
-
const
|
|
1525
|
+
const inngest = new Inngest({
|
|
1524
1526
|
id: 'mastra',
|
|
1525
1527
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
1526
1528
|
});
|
|
1527
1529
|
|
|
1528
|
-
const { createWorkflow, createStep } = init(
|
|
1530
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
1529
1531
|
|
|
1530
1532
|
const increment = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
1531
1533
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -1592,10 +1594,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1592
1594
|
vnext_workflows: {
|
|
1593
1595
|
'test-workflow': counterWorkflow,
|
|
1594
1596
|
},
|
|
1597
|
+
server: {
|
|
1598
|
+
apiRoutes: [
|
|
1599
|
+
{
|
|
1600
|
+
path: '/inngest/api',
|
|
1601
|
+
method: 'ALL',
|
|
1602
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
1603
|
+
},
|
|
1604
|
+
],
|
|
1605
|
+
},
|
|
1595
1606
|
});
|
|
1596
1607
|
|
|
1597
1608
|
const app = await createHonoServer(mastra);
|
|
1598
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
1599
1609
|
|
|
1600
1610
|
const srv = serve({
|
|
1601
1611
|
fetch: app.fetch,
|
|
@@ -1619,12 +1629,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1619
1629
|
|
|
1620
1630
|
describe('foreach', () => {
|
|
1621
1631
|
it('should run a single item concurrency (default) for loop', async ctx => {
|
|
1622
|
-
const
|
|
1632
|
+
const inngest = new Inngest({
|
|
1623
1633
|
id: 'mastra',
|
|
1624
1634
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
1625
1635
|
});
|
|
1626
1636
|
|
|
1627
|
-
const { createWorkflow, createStep } = init(
|
|
1637
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
1628
1638
|
|
|
1629
1639
|
const startTime = Date.now();
|
|
1630
1640
|
const map = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
@@ -1675,10 +1685,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1675
1685
|
vnext_workflows: {
|
|
1676
1686
|
'test-workflow': counterWorkflow,
|
|
1677
1687
|
},
|
|
1688
|
+
server: {
|
|
1689
|
+
apiRoutes: [
|
|
1690
|
+
{
|
|
1691
|
+
path: '/inngest/api',
|
|
1692
|
+
method: 'ALL',
|
|
1693
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
1694
|
+
},
|
|
1695
|
+
],
|
|
1696
|
+
},
|
|
1678
1697
|
});
|
|
1679
1698
|
|
|
1680
1699
|
const app = await createHonoServer(mastra);
|
|
1681
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
1682
1700
|
|
|
1683
1701
|
const srv = serve({
|
|
1684
1702
|
fetch: app.fetch,
|
|
@@ -1706,12 +1724,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1706
1724
|
|
|
1707
1725
|
describe('if-else branching', () => {
|
|
1708
1726
|
it('should run the if-then branch', async ctx => {
|
|
1709
|
-
const
|
|
1727
|
+
const inngest = new Inngest({
|
|
1710
1728
|
id: 'mastra',
|
|
1711
1729
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
1712
1730
|
});
|
|
1713
1731
|
|
|
1714
|
-
const { createWorkflow, createStep } = init(
|
|
1732
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
1715
1733
|
|
|
1716
1734
|
const start = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
1717
1735
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -1822,10 +1840,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1822
1840
|
vnext_workflows: {
|
|
1823
1841
|
'test-workflow': counterWorkflow,
|
|
1824
1842
|
},
|
|
1843
|
+
server: {
|
|
1844
|
+
apiRoutes: [
|
|
1845
|
+
{
|
|
1846
|
+
path: '/inngest/api',
|
|
1847
|
+
method: 'ALL',
|
|
1848
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
1849
|
+
},
|
|
1850
|
+
],
|
|
1851
|
+
},
|
|
1825
1852
|
});
|
|
1826
1853
|
|
|
1827
1854
|
const app = await createHonoServer(mastra);
|
|
1828
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
1829
1855
|
|
|
1830
1856
|
const srv = serve({
|
|
1831
1857
|
fetch: app.fetch,
|
|
@@ -1848,12 +1874,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1848
1874
|
});
|
|
1849
1875
|
|
|
1850
1876
|
it('should run the else branch', async ctx => {
|
|
1851
|
-
const
|
|
1877
|
+
const inngest = new Inngest({
|
|
1852
1878
|
id: 'mastra',
|
|
1853
1879
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
1854
1880
|
});
|
|
1855
1881
|
|
|
1856
|
-
const { createWorkflow, createStep } = init(
|
|
1882
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
1857
1883
|
|
|
1858
1884
|
const start = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
1859
1885
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -1965,10 +1991,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1965
1991
|
vnext_workflows: {
|
|
1966
1992
|
'test-workflow': counterWorkflow,
|
|
1967
1993
|
},
|
|
1994
|
+
server: {
|
|
1995
|
+
apiRoutes: [
|
|
1996
|
+
{
|
|
1997
|
+
path: '/inngest/api',
|
|
1998
|
+
method: 'ALL',
|
|
1999
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
2000
|
+
},
|
|
2001
|
+
],
|
|
2002
|
+
},
|
|
1968
2003
|
});
|
|
1969
2004
|
|
|
1970
2005
|
const app = await createHonoServer(mastra);
|
|
1971
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
1972
2006
|
|
|
1973
2007
|
const srv = serve({
|
|
1974
2008
|
fetch: app.fetch,
|
|
@@ -1993,12 +2027,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
1993
2027
|
|
|
1994
2028
|
describe('Schema Validation', () => {
|
|
1995
2029
|
it.skip('should validate trigger data against schema', async ctx => {
|
|
1996
|
-
const
|
|
2030
|
+
const inngest = new Inngest({
|
|
1997
2031
|
id: 'mastra',
|
|
1998
2032
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
1999
2033
|
});
|
|
2000
2034
|
|
|
2001
|
-
const { createWorkflow, createStep } = init(
|
|
2035
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
2002
2036
|
|
|
2003
2037
|
const triggerSchema = z.object({
|
|
2004
2038
|
required: z.string(),
|
|
@@ -2054,12 +2088,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2054
2088
|
|
|
2055
2089
|
describe('multiple chains', () => {
|
|
2056
2090
|
it('should run multiple chains in parallel', async ctx => {
|
|
2057
|
-
const
|
|
2091
|
+
const inngest = new Inngest({
|
|
2058
2092
|
id: 'mastra',
|
|
2059
2093
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
2060
2094
|
});
|
|
2061
2095
|
|
|
2062
|
-
const { createWorkflow, createStep } = init(
|
|
2096
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
2063
2097
|
|
|
2064
2098
|
const step1 = createStep({
|
|
2065
2099
|
id: 'step1',
|
|
@@ -2136,14 +2170,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2136
2170
|
{
|
|
2137
2171
|
path: '/inngest/api',
|
|
2138
2172
|
method: 'ALL',
|
|
2139
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
2173
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
2140
2174
|
},
|
|
2141
2175
|
],
|
|
2142
2176
|
},
|
|
2143
2177
|
});
|
|
2144
2178
|
|
|
2145
2179
|
const app = await createHonoServer(mastra);
|
|
2146
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
2147
2180
|
|
|
2148
2181
|
const srv = serve({
|
|
2149
2182
|
fetch: app.fetch,
|
|
@@ -2163,12 +2196,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2163
2196
|
|
|
2164
2197
|
describe('Retry', () => {
|
|
2165
2198
|
it('should retry a step default 0 times', async ctx => {
|
|
2166
|
-
const
|
|
2199
|
+
const inngest = new Inngest({
|
|
2167
2200
|
id: 'mastra',
|
|
2168
2201
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
2169
2202
|
});
|
|
2170
2203
|
|
|
2171
|
-
const { createWorkflow, createStep } = init(
|
|
2204
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
2172
2205
|
|
|
2173
2206
|
const step1 = createStep({
|
|
2174
2207
|
id: 'step1',
|
|
@@ -2205,14 +2238,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2205
2238
|
{
|
|
2206
2239
|
path: '/inngest/api',
|
|
2207
2240
|
method: 'ALL',
|
|
2208
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
2241
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
2209
2242
|
},
|
|
2210
2243
|
],
|
|
2211
2244
|
},
|
|
2212
2245
|
});
|
|
2213
2246
|
|
|
2214
2247
|
const app = await createHonoServer(mastra);
|
|
2215
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
2216
2248
|
|
|
2217
2249
|
const srv = serve({
|
|
2218
2250
|
fetch: app.fetch,
|
|
@@ -2233,12 +2265,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2233
2265
|
|
|
2234
2266
|
// Need to fix so we can throw for inngest to recognize retries
|
|
2235
2267
|
it.skip('should retry a step with a custom retry config', async ctx => {
|
|
2236
|
-
const
|
|
2268
|
+
const inngest = new Inngest({
|
|
2237
2269
|
id: 'mastra',
|
|
2238
2270
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
2239
2271
|
});
|
|
2240
2272
|
|
|
2241
|
-
const { createWorkflow, createStep } = init(
|
|
2273
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
2242
2274
|
|
|
2243
2275
|
const step1 = createStep({
|
|
2244
2276
|
id: 'step1',
|
|
@@ -2269,7 +2301,7 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2269
2301
|
{
|
|
2270
2302
|
path: '/inngest/api',
|
|
2271
2303
|
method: 'ALL',
|
|
2272
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
2304
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
2273
2305
|
},
|
|
2274
2306
|
],
|
|
2275
2307
|
},
|
|
@@ -2289,12 +2321,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2289
2321
|
|
|
2290
2322
|
describe('Interoperability (Actions)', () => {
|
|
2291
2323
|
it('should be able to use all action types in a workflow', async ctx => {
|
|
2292
|
-
const
|
|
2324
|
+
const inngest = new Inngest({
|
|
2293
2325
|
id: 'mastra',
|
|
2294
2326
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
2295
2327
|
});
|
|
2296
2328
|
|
|
2297
|
-
const { createWorkflow, createStep } = init(
|
|
2329
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
2298
2330
|
|
|
2299
2331
|
const step1Action = vi.fn<any>().mockResolvedValue({ name: 'step1' });
|
|
2300
2332
|
|
|
@@ -2340,14 +2372,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2340
2372
|
{
|
|
2341
2373
|
path: '/inngest/api',
|
|
2342
2374
|
method: 'ALL',
|
|
2343
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
2375
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
2344
2376
|
},
|
|
2345
2377
|
],
|
|
2346
2378
|
},
|
|
2347
2379
|
});
|
|
2348
2380
|
|
|
2349
2381
|
const app = await createHonoServer(mastra);
|
|
2350
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
2351
2382
|
|
|
2352
2383
|
const srv = serve({
|
|
2353
2384
|
fetch: app.fetch,
|
|
@@ -2368,13 +2399,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2368
2399
|
|
|
2369
2400
|
describe('Watch', () => {
|
|
2370
2401
|
it('should watch workflow state changes and call onTransition', async ctx => {
|
|
2371
|
-
const
|
|
2402
|
+
const inngest = new Inngest({
|
|
2372
2403
|
id: 'mastra',
|
|
2373
2404
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
2374
2405
|
middleware: [realtimeMiddleware()],
|
|
2375
2406
|
});
|
|
2376
2407
|
|
|
2377
|
-
const { createWorkflow, createStep } = init(
|
|
2408
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
2378
2409
|
|
|
2379
2410
|
const step1Action = vi.fn<any>().mockResolvedValue({ result: 'success1' });
|
|
2380
2411
|
const step2Action = vi.fn<any>().mockResolvedValue({ result: 'success2' });
|
|
@@ -2414,14 +2445,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2414
2445
|
{
|
|
2415
2446
|
path: '/inngest/api',
|
|
2416
2447
|
method: 'ALL',
|
|
2417
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
2448
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
2418
2449
|
},
|
|
2419
2450
|
],
|
|
2420
2451
|
},
|
|
2421
2452
|
});
|
|
2422
2453
|
|
|
2423
2454
|
const app = await createHonoServer(mastra);
|
|
2424
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
2425
2455
|
|
|
2426
2456
|
const srv = serve({
|
|
2427
2457
|
fetch: app.fetch,
|
|
@@ -2557,13 +2587,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2557
2587
|
});
|
|
2558
2588
|
|
|
2559
2589
|
it('should unsubscribe from transitions when unwatch is called', async ctx => {
|
|
2560
|
-
const
|
|
2590
|
+
const inngest = new Inngest({
|
|
2561
2591
|
id: 'mastra',
|
|
2562
2592
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
2563
2593
|
middleware: [realtimeMiddleware()],
|
|
2564
2594
|
});
|
|
2565
2595
|
|
|
2566
|
-
const { createWorkflow, createStep } = init(
|
|
2596
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
2567
2597
|
|
|
2568
2598
|
const step1Action = vi.fn<any>().mockResolvedValue({ result: 'success1' });
|
|
2569
2599
|
const step2Action = vi.fn<any>().mockResolvedValue({ result: 'success2' });
|
|
@@ -2603,14 +2633,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2603
2633
|
{
|
|
2604
2634
|
path: '/inngest/api',
|
|
2605
2635
|
method: 'ALL',
|
|
2606
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
2636
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
2607
2637
|
},
|
|
2608
2638
|
],
|
|
2609
2639
|
},
|
|
2610
2640
|
});
|
|
2611
2641
|
|
|
2612
2642
|
const app = await createHonoServer(mastra);
|
|
2613
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
2614
2643
|
|
|
2615
2644
|
const srv = serve({
|
|
2616
2645
|
fetch: app.fetch,
|
|
@@ -2662,12 +2691,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2662
2691
|
}
|
|
2663
2692
|
});
|
|
2664
2693
|
it('should return the correct runId', async ctx => {
|
|
2665
|
-
const
|
|
2694
|
+
const inngest = new Inngest({
|
|
2666
2695
|
id: 'mastra',
|
|
2667
2696
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
2668
2697
|
});
|
|
2669
2698
|
|
|
2670
|
-
const { createWorkflow, createStep } = init(
|
|
2699
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
2671
2700
|
|
|
2672
2701
|
const workflow = createWorkflow({
|
|
2673
2702
|
id: 'test-workflow',
|
|
@@ -2684,13 +2713,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2684
2713
|
});
|
|
2685
2714
|
|
|
2686
2715
|
it('should handle basic suspend and resume flow', async ctx => {
|
|
2687
|
-
const
|
|
2716
|
+
const inngest = new Inngest({
|
|
2688
2717
|
id: 'mastra',
|
|
2689
2718
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
2690
2719
|
middleware: [realtimeMiddleware()],
|
|
2691
2720
|
});
|
|
2692
2721
|
|
|
2693
|
-
const { createWorkflow, createStep } = init(
|
|
2722
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
2694
2723
|
|
|
2695
2724
|
const getUserInputAction = vi.fn().mockResolvedValue({ userInput: 'test input' });
|
|
2696
2725
|
const promptAgentAction = vi
|
|
@@ -2779,10 +2808,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2779
2808
|
vnext_workflows: {
|
|
2780
2809
|
'test-workflow': promptEvalWorkflow,
|
|
2781
2810
|
},
|
|
2811
|
+
server: {
|
|
2812
|
+
apiRoutes: [
|
|
2813
|
+
{
|
|
2814
|
+
path: '/inngest/api',
|
|
2815
|
+
method: 'ALL',
|
|
2816
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
2817
|
+
},
|
|
2818
|
+
],
|
|
2819
|
+
},
|
|
2782
2820
|
});
|
|
2783
2821
|
|
|
2784
2822
|
const app = await createHonoServer(mastra);
|
|
2785
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
2786
2823
|
|
|
2787
2824
|
const srv = serve({
|
|
2788
2825
|
fetch: app.fetch,
|
|
@@ -2837,13 +2874,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2837
2874
|
});
|
|
2838
2875
|
|
|
2839
2876
|
it('should handle parallel steps with conditional suspend', async ctx => {
|
|
2840
|
-
const
|
|
2877
|
+
const inngest = new Inngest({
|
|
2841
2878
|
id: 'mastra',
|
|
2842
2879
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
2843
2880
|
middleware: [realtimeMiddleware()],
|
|
2844
2881
|
});
|
|
2845
2882
|
|
|
2846
|
-
const { createWorkflow, createStep } = init(
|
|
2883
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
2847
2884
|
|
|
2848
2885
|
const getUserInputAction = vi.fn().mockResolvedValue({ userInput: 'test input' });
|
|
2849
2886
|
const promptAgentAction = vi.fn().mockResolvedValue({ modelOutput: 'test output' });
|
|
@@ -2928,14 +2965,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2928
2965
|
{
|
|
2929
2966
|
path: '/inngest/api',
|
|
2930
2967
|
method: 'ALL',
|
|
2931
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
2968
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
2932
2969
|
},
|
|
2933
2970
|
],
|
|
2934
2971
|
},
|
|
2935
2972
|
});
|
|
2936
2973
|
|
|
2937
2974
|
const app = await createHonoServer(mastra);
|
|
2938
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
2939
2975
|
|
|
2940
2976
|
const srv = serve({
|
|
2941
2977
|
fetch: app.fetch,
|
|
@@ -2999,13 +3035,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
2999
3035
|
});
|
|
3000
3036
|
|
|
3001
3037
|
it('should handle complex workflow with multiple suspends', async ctx => {
|
|
3002
|
-
const
|
|
3038
|
+
const inngest = new Inngest({
|
|
3003
3039
|
id: 'mastra',
|
|
3004
3040
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
3005
3041
|
middleware: [realtimeMiddleware()],
|
|
3006
3042
|
});
|
|
3007
3043
|
|
|
3008
|
-
const { createWorkflow, createStep } = init(
|
|
3044
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
3009
3045
|
|
|
3010
3046
|
const getUserInputAction = vi.fn().mockResolvedValue({ userInput: 'test input' });
|
|
3011
3047
|
const promptAgentAction = vi.fn().mockResolvedValue({ modelOutput: 'test output' });
|
|
@@ -3133,14 +3169,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3133
3169
|
{
|
|
3134
3170
|
path: '/inngest/api',
|
|
3135
3171
|
method: 'ALL',
|
|
3136
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
3172
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
3137
3173
|
},
|
|
3138
3174
|
],
|
|
3139
3175
|
},
|
|
3140
3176
|
});
|
|
3141
3177
|
|
|
3142
3178
|
const app = await createHonoServer(mastra);
|
|
3143
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
3144
3179
|
|
|
3145
3180
|
const srv = serve({
|
|
3146
3181
|
fetch: app.fetch,
|
|
@@ -3229,12 +3264,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3229
3264
|
});
|
|
3230
3265
|
|
|
3231
3266
|
it('should handle basic suspend and resume flow with async await syntax', async ctx => {
|
|
3232
|
-
const
|
|
3267
|
+
const inngest = new Inngest({
|
|
3233
3268
|
id: 'mastra',
|
|
3234
3269
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
3235
3270
|
});
|
|
3236
3271
|
|
|
3237
|
-
const { createWorkflow, createStep } = init(
|
|
3272
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
3238
3273
|
const getUserInputAction = vi.fn().mockResolvedValue({ userInput: 'test input' });
|
|
3239
3274
|
const promptAgentAction = vi
|
|
3240
3275
|
.fn()
|
|
@@ -3325,10 +3360,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3325
3360
|
vnext_workflows: {
|
|
3326
3361
|
'test-workflow': promptEvalWorkflow,
|
|
3327
3362
|
},
|
|
3363
|
+
server: {
|
|
3364
|
+
apiRoutes: [
|
|
3365
|
+
{
|
|
3366
|
+
path: '/inngest/api',
|
|
3367
|
+
method: 'ALL',
|
|
3368
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
3369
|
+
},
|
|
3370
|
+
],
|
|
3371
|
+
},
|
|
3328
3372
|
});
|
|
3329
3373
|
|
|
3330
3374
|
const app = await createHonoServer(mastra);
|
|
3331
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
3332
3375
|
|
|
3333
3376
|
const srv = serve({
|
|
3334
3377
|
fetch: app.fetch,
|
|
@@ -3414,12 +3457,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3414
3457
|
|
|
3415
3458
|
describe('Accessing Mastra', () => {
|
|
3416
3459
|
it('should be able to access the deprecated mastra primitives', async ctx => {
|
|
3417
|
-
const
|
|
3460
|
+
const inngest = new Inngest({
|
|
3418
3461
|
id: 'mastra',
|
|
3419
3462
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
3420
3463
|
});
|
|
3421
3464
|
|
|
3422
|
-
const { createWorkflow, createStep } = init(
|
|
3465
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
3423
3466
|
let telemetry: Telemetry | undefined;
|
|
3424
3467
|
const step1 = createStep({
|
|
3425
3468
|
id: 'step1',
|
|
@@ -3448,14 +3491,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3448
3491
|
{
|
|
3449
3492
|
path: '/inngest/api',
|
|
3450
3493
|
method: 'ALL',
|
|
3451
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
3494
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
3452
3495
|
},
|
|
3453
3496
|
],
|
|
3454
3497
|
},
|
|
3455
3498
|
});
|
|
3456
3499
|
|
|
3457
3500
|
const app = await createHonoServer(mastra);
|
|
3458
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
3459
3501
|
|
|
3460
3502
|
const srv = serve({
|
|
3461
3503
|
fetch: app.fetch,
|
|
@@ -3476,12 +3518,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3476
3518
|
|
|
3477
3519
|
describe('Agent as step', () => {
|
|
3478
3520
|
it('should be able to use an agent as a step', async ctx => {
|
|
3479
|
-
const
|
|
3521
|
+
const inngest = new Inngest({
|
|
3480
3522
|
id: 'mastra',
|
|
3481
3523
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
3482
3524
|
});
|
|
3483
3525
|
|
|
3484
|
-
const { createWorkflow, createStep } = init(
|
|
3526
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
3485
3527
|
|
|
3486
3528
|
const workflow = createWorkflow({
|
|
3487
3529
|
id: 'test-workflow',
|
|
@@ -3554,14 +3596,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3554
3596
|
{
|
|
3555
3597
|
path: '/inngest/api',
|
|
3556
3598
|
method: 'ALL',
|
|
3557
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
3599
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
3558
3600
|
},
|
|
3559
3601
|
],
|
|
3560
3602
|
},
|
|
3561
3603
|
});
|
|
3562
3604
|
|
|
3563
3605
|
const app = await createHonoServer(mastra);
|
|
3564
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
3565
3606
|
|
|
3566
3607
|
const srv = serve({
|
|
3567
3608
|
fetch: app.fetch,
|
|
@@ -3588,12 +3629,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3588
3629
|
});
|
|
3589
3630
|
|
|
3590
3631
|
it('should be able to use an agent in parallel', async ctx => {
|
|
3591
|
-
const
|
|
3632
|
+
const inngest = new Inngest({
|
|
3592
3633
|
id: 'mastra',
|
|
3593
3634
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
3594
3635
|
});
|
|
3595
3636
|
|
|
3596
|
-
const { createWorkflow, createStep } = init(
|
|
3637
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
3597
3638
|
|
|
3598
3639
|
const execute = vi.fn<any>().mockResolvedValue({ result: 'success' });
|
|
3599
3640
|
const finalStep = createStep({
|
|
@@ -3693,14 +3734,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3693
3734
|
{
|
|
3694
3735
|
path: '/inngest/api',
|
|
3695
3736
|
method: 'ALL',
|
|
3696
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
3737
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
3697
3738
|
},
|
|
3698
3739
|
],
|
|
3699
3740
|
},
|
|
3700
3741
|
});
|
|
3701
3742
|
|
|
3702
3743
|
const app = await createHonoServer(mastra);
|
|
3703
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
3704
3744
|
|
|
3705
3745
|
const srv = serve({
|
|
3706
3746
|
fetch: app.fetch,
|
|
@@ -3735,12 +3775,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3735
3775
|
|
|
3736
3776
|
describe('Nested workflows', () => {
|
|
3737
3777
|
it('should be able to nest workflows', async ctx => {
|
|
3738
|
-
const
|
|
3778
|
+
const inngest = new Inngest({
|
|
3739
3779
|
id: 'mastra',
|
|
3740
3780
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
3741
3781
|
});
|
|
3742
3782
|
|
|
3743
|
-
const { createWorkflow, createStep } = init(
|
|
3783
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
3744
3784
|
|
|
3745
3785
|
const start = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
3746
3786
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -3834,10 +3874,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3834
3874
|
vnext_workflows: {
|
|
3835
3875
|
'test-workflow': counterWorkflow,
|
|
3836
3876
|
},
|
|
3877
|
+
server: {
|
|
3878
|
+
apiRoutes: [
|
|
3879
|
+
{
|
|
3880
|
+
path: '/inngest/api',
|
|
3881
|
+
method: 'ALL',
|
|
3882
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
3883
|
+
},
|
|
3884
|
+
],
|
|
3885
|
+
},
|
|
3837
3886
|
});
|
|
3838
3887
|
|
|
3839
3888
|
const app = await createHonoServer(mastra);
|
|
3840
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
3841
3889
|
|
|
3842
3890
|
const srv = serve({
|
|
3843
3891
|
fetch: app.fetch,
|
|
@@ -3871,12 +3919,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3871
3919
|
});
|
|
3872
3920
|
|
|
3873
3921
|
it('should be able to nest workflows with conditions', async ctx => {
|
|
3874
|
-
const
|
|
3922
|
+
const inngest = new Inngest({
|
|
3875
3923
|
id: 'mastra',
|
|
3876
3924
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
3877
3925
|
});
|
|
3878
3926
|
|
|
3879
|
-
const { createWorkflow, createStep } = init(
|
|
3927
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
3880
3928
|
|
|
3881
3929
|
const start = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
3882
3930
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -3980,10 +4028,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
3980
4028
|
vnext_workflows: {
|
|
3981
4029
|
'test-workflow': counterWorkflow,
|
|
3982
4030
|
},
|
|
4031
|
+
server: {
|
|
4032
|
+
apiRoutes: [
|
|
4033
|
+
{
|
|
4034
|
+
path: '/inngest/api',
|
|
4035
|
+
method: 'ALL',
|
|
4036
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
4037
|
+
},
|
|
4038
|
+
],
|
|
4039
|
+
},
|
|
3983
4040
|
});
|
|
3984
4041
|
|
|
3985
4042
|
const app = await createHonoServer(mastra);
|
|
3986
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
3987
4043
|
|
|
3988
4044
|
const srv = serve({
|
|
3989
4045
|
fetch: app.fetch,
|
|
@@ -4018,12 +4074,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4018
4074
|
|
|
4019
4075
|
describe('new if else branching syntax with nested workflows', () => {
|
|
4020
4076
|
it('should execute if-branch', async ctx => {
|
|
4021
|
-
const
|
|
4077
|
+
const inngest = new Inngest({
|
|
4022
4078
|
id: 'mastra',
|
|
4023
4079
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
4024
4080
|
});
|
|
4025
4081
|
|
|
4026
|
-
const { createWorkflow, createStep } = init(
|
|
4082
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
4027
4083
|
|
|
4028
4084
|
const start = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
4029
4085
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -4131,13 +4187,21 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4131
4187
|
vnext_workflows: {
|
|
4132
4188
|
'test-workflow': counterWorkflow,
|
|
4133
4189
|
},
|
|
4190
|
+
server: {
|
|
4191
|
+
apiRoutes: [
|
|
4192
|
+
{
|
|
4193
|
+
path: '/inngest/api',
|
|
4194
|
+
method: 'ALL',
|
|
4195
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
4196
|
+
},
|
|
4197
|
+
],
|
|
4198
|
+
},
|
|
4134
4199
|
});
|
|
4135
4200
|
|
|
4136
4201
|
const app = await createHonoServer(mastra);
|
|
4137
4202
|
app.use('*', async (ctx, next) => {
|
|
4138
4203
|
await next();
|
|
4139
4204
|
});
|
|
4140
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
4141
4205
|
|
|
4142
4206
|
const srv = serve({
|
|
4143
4207
|
fetch: app.fetch,
|
|
@@ -4171,12 +4235,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4171
4235
|
});
|
|
4172
4236
|
|
|
4173
4237
|
it('should execute else-branch', async ctx => {
|
|
4174
|
-
const
|
|
4238
|
+
const inngest = new Inngest({
|
|
4175
4239
|
id: 'mastra',
|
|
4176
4240
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
4177
4241
|
});
|
|
4178
4242
|
|
|
4179
|
-
const { createWorkflow, createStep } = init(
|
|
4243
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
4180
4244
|
|
|
4181
4245
|
const start = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
4182
4246
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -4284,13 +4348,21 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4284
4348
|
vnext_workflows: {
|
|
4285
4349
|
'test-workflow': counterWorkflow,
|
|
4286
4350
|
},
|
|
4351
|
+
server: {
|
|
4352
|
+
apiRoutes: [
|
|
4353
|
+
{
|
|
4354
|
+
path: '/inngest/api',
|
|
4355
|
+
method: 'ALL',
|
|
4356
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
4357
|
+
},
|
|
4358
|
+
],
|
|
4359
|
+
},
|
|
4287
4360
|
});
|
|
4288
4361
|
|
|
4289
4362
|
const app = await createHonoServer(mastra);
|
|
4290
4363
|
app.use('*', async (ctx, next) => {
|
|
4291
4364
|
await next();
|
|
4292
4365
|
});
|
|
4293
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
4294
4366
|
|
|
4295
4367
|
const srv = serve({
|
|
4296
4368
|
fetch: app.fetch,
|
|
@@ -4325,12 +4397,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4325
4397
|
});
|
|
4326
4398
|
|
|
4327
4399
|
it('should execute nested else and if-branch', async ctx => {
|
|
4328
|
-
const
|
|
4400
|
+
const inngest = new Inngest({
|
|
4329
4401
|
id: 'mastra',
|
|
4330
4402
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
4331
4403
|
});
|
|
4332
4404
|
|
|
4333
|
-
const { createWorkflow, createStep } = init(
|
|
4405
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
4334
4406
|
|
|
4335
4407
|
const start = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
4336
4408
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -4475,13 +4547,21 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4475
4547
|
vnext_workflows: {
|
|
4476
4548
|
'test-workflow': counterWorkflow,
|
|
4477
4549
|
},
|
|
4550
|
+
server: {
|
|
4551
|
+
apiRoutes: [
|
|
4552
|
+
{
|
|
4553
|
+
path: '/inngest/api',
|
|
4554
|
+
method: 'ALL',
|
|
4555
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
4556
|
+
},
|
|
4557
|
+
],
|
|
4558
|
+
},
|
|
4478
4559
|
});
|
|
4479
4560
|
|
|
4480
4561
|
const app = await createHonoServer(mastra);
|
|
4481
4562
|
app.use('*', async (ctx, next) => {
|
|
4482
4563
|
await next();
|
|
4483
4564
|
});
|
|
4484
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
4485
4565
|
|
|
4486
4566
|
const srv = serve({
|
|
4487
4567
|
fetch: app.fetch,
|
|
@@ -4518,12 +4598,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4518
4598
|
|
|
4519
4599
|
describe('suspending and resuming nested workflows', () => {
|
|
4520
4600
|
it('should be able to suspend nested workflow step', async ctx => {
|
|
4521
|
-
const
|
|
4601
|
+
const inngest = new Inngest({
|
|
4522
4602
|
id: 'mastra',
|
|
4523
4603
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
4524
4604
|
});
|
|
4525
4605
|
|
|
4526
|
-
const { createWorkflow, createStep } = init(
|
|
4606
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
4527
4607
|
|
|
4528
4608
|
const start = vi.fn().mockImplementation(async ({ inputData, resume }) => {
|
|
4529
4609
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -4625,10 +4705,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4625
4705
|
vnext_workflows: {
|
|
4626
4706
|
'test-workflow': counterWorkflow,
|
|
4627
4707
|
},
|
|
4708
|
+
server: {
|
|
4709
|
+
apiRoutes: [
|
|
4710
|
+
{
|
|
4711
|
+
path: '/inngest/api',
|
|
4712
|
+
method: 'ALL',
|
|
4713
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
4714
|
+
},
|
|
4715
|
+
],
|
|
4716
|
+
},
|
|
4628
4717
|
});
|
|
4629
4718
|
|
|
4630
4719
|
const app = await createHonoServer(mastra);
|
|
4631
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
4632
4720
|
|
|
4633
4721
|
const srv = serve({
|
|
4634
4722
|
fetch: app.fetch,
|
|
@@ -4669,12 +4757,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4669
4757
|
|
|
4670
4758
|
describe('Workflow results', () => {
|
|
4671
4759
|
it('should be able to spec out workflow result via variables', async ctx => {
|
|
4672
|
-
const
|
|
4760
|
+
const inngest = new Inngest({
|
|
4673
4761
|
id: 'mastra',
|
|
4674
4762
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
4675
4763
|
});
|
|
4676
4764
|
|
|
4677
|
-
const { createWorkflow, createStep } = init(
|
|
4765
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
4678
4766
|
|
|
4679
4767
|
const start = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
4680
4768
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -4767,6 +4855,15 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4767
4855
|
vnext_workflows: {
|
|
4768
4856
|
'test-workflow': counterWorkflow,
|
|
4769
4857
|
},
|
|
4858
|
+
server: {
|
|
4859
|
+
apiRoutes: [
|
|
4860
|
+
{
|
|
4861
|
+
path: '/inngest/api',
|
|
4862
|
+
method: 'ALL',
|
|
4863
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
4864
|
+
},
|
|
4865
|
+
],
|
|
4866
|
+
},
|
|
4770
4867
|
});
|
|
4771
4868
|
|
|
4772
4869
|
const app = await createHonoServer(mastra);
|
|
@@ -4774,7 +4871,6 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4774
4871
|
'middleware', ctx.req.method, ctx.req.url;
|
|
4775
4872
|
await next();
|
|
4776
4873
|
});
|
|
4777
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
4778
4874
|
|
|
4779
4875
|
const srv = serve({
|
|
4780
4876
|
fetch: app.fetch,
|
|
@@ -4808,12 +4904,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4808
4904
|
});
|
|
4809
4905
|
|
|
4810
4906
|
it('should be able to suspend nested workflow step in a nested workflow step', async ctx => {
|
|
4811
|
-
const
|
|
4907
|
+
const inngest = new Inngest({
|
|
4812
4908
|
id: 'mastra',
|
|
4813
4909
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
4814
4910
|
});
|
|
4815
4911
|
|
|
4816
|
-
const { createWorkflow, createStep } = init(
|
|
4912
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
4817
4913
|
|
|
4818
4914
|
const start = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
4819
4915
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -4946,10 +5042,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
4946
5042
|
vnext_workflows: {
|
|
4947
5043
|
'test-workflow': counterWorkflow,
|
|
4948
5044
|
},
|
|
5045
|
+
server: {
|
|
5046
|
+
apiRoutes: [
|
|
5047
|
+
{
|
|
5048
|
+
path: '/inngest/api',
|
|
5049
|
+
method: 'ALL',
|
|
5050
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
5051
|
+
},
|
|
5052
|
+
],
|
|
5053
|
+
},
|
|
4949
5054
|
});
|
|
4950
5055
|
|
|
4951
5056
|
const app = await createHonoServer(mastra);
|
|
4952
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
4953
5057
|
|
|
4954
5058
|
const srv = serve({
|
|
4955
5059
|
fetch: app.fetch,
|
|
@@ -5004,12 +5108,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
5004
5108
|
});
|
|
5005
5109
|
|
|
5006
5110
|
it('should be able clone workflows as steps', async ctx => {
|
|
5007
|
-
const
|
|
5111
|
+
const inngest = new Inngest({
|
|
5008
5112
|
id: 'mastra',
|
|
5009
5113
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
5010
5114
|
});
|
|
5011
5115
|
|
|
5012
|
-
const { createWorkflow, createStep, cloneStep, cloneWorkflow } = init(
|
|
5116
|
+
const { createWorkflow, createStep, cloneStep, cloneWorkflow } = init(inngest);
|
|
5013
5117
|
|
|
5014
5118
|
const start = vi.fn().mockImplementation(async ({ inputData }) => {
|
|
5015
5119
|
// Get the current value (either from trigger or previous increment)
|
|
@@ -5107,10 +5211,18 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
5107
5211
|
vnext_workflows: {
|
|
5108
5212
|
'test-workflow': counterWorkflow,
|
|
5109
5213
|
},
|
|
5214
|
+
server: {
|
|
5215
|
+
apiRoutes: [
|
|
5216
|
+
{
|
|
5217
|
+
path: '/inngest/api',
|
|
5218
|
+
method: 'ALL',
|
|
5219
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
5220
|
+
},
|
|
5221
|
+
],
|
|
5222
|
+
},
|
|
5110
5223
|
});
|
|
5111
5224
|
|
|
5112
5225
|
const app = await createHonoServer(mastra);
|
|
5113
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
5114
5226
|
|
|
5115
5227
|
const srv = serve({
|
|
5116
5228
|
fetch: app.fetch,
|
|
@@ -5146,12 +5258,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
5146
5258
|
|
|
5147
5259
|
describe('Accessing Mastra', () => {
|
|
5148
5260
|
it('should be able to access the deprecated mastra primitives', async ctx => {
|
|
5149
|
-
const
|
|
5261
|
+
const inngest = new Inngest({
|
|
5150
5262
|
id: 'mastra',
|
|
5151
5263
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
5152
5264
|
});
|
|
5153
5265
|
|
|
5154
|
-
const { createWorkflow, createStep } = init(
|
|
5266
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
5155
5267
|
|
|
5156
5268
|
let telemetry: Telemetry | undefined;
|
|
5157
5269
|
const step1 = createStep({
|
|
@@ -5181,14 +5293,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
5181
5293
|
{
|
|
5182
5294
|
path: '/inngest/api',
|
|
5183
5295
|
method: 'ALL',
|
|
5184
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
5296
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
5185
5297
|
},
|
|
5186
5298
|
],
|
|
5187
5299
|
},
|
|
5188
5300
|
});
|
|
5189
5301
|
|
|
5190
5302
|
const app = await createHonoServer(mastra);
|
|
5191
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
5192
5303
|
|
|
5193
5304
|
const srv = serve({
|
|
5194
5305
|
fetch: app.fetch,
|
|
@@ -5210,12 +5321,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
5210
5321
|
// TODO: can we support this on inngest?
|
|
5211
5322
|
describe.skip('Dependency Injection', () => {
|
|
5212
5323
|
it('should inject runtimeContext dependencies into steps during run', async ctx => {
|
|
5213
|
-
const
|
|
5324
|
+
const inngest = new Inngest({
|
|
5214
5325
|
id: 'mastra',
|
|
5215
5326
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
5216
5327
|
});
|
|
5217
5328
|
|
|
5218
|
-
const { createWorkflow, createStep } = init(
|
|
5329
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
5219
5330
|
|
|
5220
5331
|
const runtimeContext = new RuntimeContext();
|
|
5221
5332
|
const testValue = 'test-dependency';
|
|
@@ -5247,14 +5358,13 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
5247
5358
|
{
|
|
5248
5359
|
path: '/inngest/api',
|
|
5249
5360
|
method: 'ALL',
|
|
5250
|
-
createHandler: async ({ mastra }) => inngestServe({ mastra,
|
|
5361
|
+
createHandler: async ({ mastra }) => inngestServe({ mastra, inngest }),
|
|
5251
5362
|
},
|
|
5252
5363
|
],
|
|
5253
5364
|
},
|
|
5254
5365
|
});
|
|
5255
5366
|
|
|
5256
5367
|
const app = await createHonoServer(mastra);
|
|
5257
|
-
app.all('/inngest/api', inngestServe({ mastra, ingest }));
|
|
5258
5368
|
|
|
5259
5369
|
const srv = serve({
|
|
5260
5370
|
fetch: app.fetch,
|
|
@@ -5271,12 +5381,12 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
5271
5381
|
});
|
|
5272
5382
|
|
|
5273
5383
|
it('should inject runtimeContext dependencies into steps during resume', async ctx => {
|
|
5274
|
-
const
|
|
5384
|
+
const inngest = new Inngest({
|
|
5275
5385
|
id: 'mastra',
|
|
5276
5386
|
baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
|
|
5277
5387
|
});
|
|
5278
5388
|
|
|
5279
|
-
const { createWorkflow, createStep } = init(
|
|
5389
|
+
const { createWorkflow, createStep } = init(inngest);
|
|
5280
5390
|
|
|
5281
5391
|
const initialStorage = new DefaultStorage({
|
|
5282
5392
|
config: {
|
|
@@ -5335,4 +5445,4 @@ describe('MastraInngestWorkflow', ctx => {
|
|
|
5335
5445
|
expect(result?.steps.step1.output.injectedValue).toBe(testValue + '2');
|
|
5336
5446
|
});
|
|
5337
5447
|
});
|
|
5338
|
-
},
|
|
5448
|
+
}, 40e3);
|