@mastra/inngest 0.11.3 → 0.11.4-alpha.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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/inngest@0.11.3-alpha.3 build /home/runner/work/mastra/mastra/workflows/inngest
2
+ > @mastra/inngest@0.11.4-alpha.0 build /home/runner/work/mastra/mastra/workflows/inngest
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.5.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 8648ms
9
+ TSC ⚡️ Build success in 8329ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/workflows/inngest/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/workflows/inngest/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 6783ms
16
+ DTS ⚡️ Build success in 6005ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
20
  ESM dist/index.js 37.03 KB
21
- ESM ⚡️ Build success in 287ms
21
+ ESM ⚡️ Build success in 257ms
22
22
  CJS dist/index.cjs 37.25 KB
23
- CJS ⚡️ Build success in 287ms
23
+ CJS ⚡️ Build success in 256ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mastra/inngest
2
2
 
3
+ ## 0.11.4-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 0b56518: Ensure removed runtimeContext values are not saved in snapshot
8
+ - Updated dependencies [0b56518]
9
+ - Updated dependencies [2ba5b76]
10
+ - Updated dependencies [c3a30de]
11
+ - Updated dependencies [cf3a184]
12
+ - Updated dependencies [d6bfd60]
13
+ - @mastra/core@0.10.15-alpha.1
14
+
3
15
  ## 0.11.3
4
16
 
5
17
  ### Patch Changes
@@ -184,6 +184,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
184
184
  workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
185
185
  result?: Record<string, any>;
186
186
  error?: string | Error;
187
+ runtimeContext: RuntimeContext;
187
188
  }): Promise<void>;
188
189
  executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, }: {
189
190
  workflowId: string;
@@ -184,6 +184,7 @@ export declare class InngestExecutionEngine extends DefaultExecutionEngine {
184
184
  workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
185
185
  result?: Record<string, any>;
186
186
  error?: string | Error;
187
+ runtimeContext: RuntimeContext;
187
188
  }): Promise<void>;
188
189
  executeConditional({ workflowId, runId, entry, prevOutput, prevStep, stepResults, serializedStepGraph, resume, executionContext, emitter, abortController, runtimeContext, }: {
189
190
  workflowId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/inngest",
3
- "version": "0.11.3",
3
+ "version": "0.11.4-alpha.0",
4
4
  "description": "Mastra Inngest integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,17 +31,17 @@
31
31
  "@microsoft/api-extractor": "^7.52.8",
32
32
  "@types/node": "^20.19.0",
33
33
  "ai": "^4.3.16",
34
- "eslint": "^9.29.0",
34
+ "eslint": "^9.30.1",
35
35
  "execa": "^9.6.0",
36
36
  "get-port": "7.1.0",
37
37
  "hono": "^4.8.4",
38
38
  "tsup": "^8.5.0",
39
39
  "typescript": "^5.8.3",
40
40
  "vitest": "^3.2.4",
41
- "@internal/lint": "0.0.18",
41
+ "@mastra/core": "0.10.15-alpha.1",
42
42
  "@mastra/libsql": "0.11.0",
43
- "@mastra/core": "0.10.11",
44
- "@mastra/deployer": "0.10.11"
43
+ "@internal/lint": "0.0.19",
44
+ "@mastra/deployer": "0.10.15-alpha.1"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@mastra/core": ">=0.10.11-0 <0.11.0-0"
package/src/index.test.ts CHANGED
@@ -6219,6 +6219,176 @@ describe('MastraInngestWorkflow', () => {
6219
6219
  // @ts-ignore
6220
6220
  expect(result?.steps.step1.output.injectedValue).toBe(testValue + '2');
6221
6221
  });
6222
+
6223
+ it('should have access to runtimeContext from before suspension during workflow resume', async ctx => {
6224
+ const inngest = new Inngest({
6225
+ id: 'mastra',
6226
+ baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
6227
+ });
6228
+
6229
+ const { createWorkflow, createStep } = init(inngest);
6230
+
6231
+ const testValue = 'test-dependency';
6232
+ const resumeStep = createStep({
6233
+ id: 'resume',
6234
+ inputSchema: z.object({ value: z.number() }),
6235
+ outputSchema: z.object({ value: z.number() }),
6236
+ resumeSchema: z.object({ value: z.number() }),
6237
+ suspendSchema: z.object({ message: z.string() }),
6238
+ execute: async ({ inputData, resumeData, suspend }) => {
6239
+ const finalValue = (resumeData?.value ?? 0) + inputData.value;
6240
+
6241
+ if (!resumeData?.value || finalValue < 10) {
6242
+ return await suspend({
6243
+ message: `Please provide additional information. now value is ${inputData.value}`,
6244
+ });
6245
+ }
6246
+
6247
+ return { value: finalValue };
6248
+ },
6249
+ });
6250
+
6251
+ const incrementStep = createStep({
6252
+ id: 'increment',
6253
+ inputSchema: z.object({
6254
+ value: z.number(),
6255
+ }),
6256
+ outputSchema: z.object({
6257
+ value: z.number(),
6258
+ }),
6259
+ execute: async ({ inputData, runtimeContext }) => {
6260
+ runtimeContext.set('testKey', testValue);
6261
+ return {
6262
+ value: inputData.value + 1,
6263
+ };
6264
+ },
6265
+ });
6266
+
6267
+ const incrementWorkflow = createWorkflow({
6268
+ id: 'increment-workflow',
6269
+ inputSchema: z.object({ value: z.number() }),
6270
+ outputSchema: z.object({ value: z.number() }),
6271
+ })
6272
+ .then(incrementStep)
6273
+ .then(resumeStep)
6274
+ .then(
6275
+ createStep({
6276
+ id: 'final',
6277
+ inputSchema: z.object({ value: z.number() }),
6278
+ outputSchema: z.object({ value: z.number() }),
6279
+ execute: async ({ inputData, runtimeContext }) => {
6280
+ const testKey = runtimeContext.get('testKey');
6281
+ expect(testKey).toBe(testValue);
6282
+ return { value: inputData.value };
6283
+ },
6284
+ }),
6285
+ )
6286
+ .commit();
6287
+
6288
+ new Mastra({
6289
+ logger: false,
6290
+ storage: testStorage,
6291
+ workflows: { incrementWorkflow },
6292
+ });
6293
+
6294
+ const run = await incrementWorkflow.createRunAsync();
6295
+ const result = await run.start({ inputData: { value: 0 } });
6296
+ expect(result.status).toBe('suspended');
6297
+
6298
+ const resumeResult = await run.resume({
6299
+ resumeData: { value: 21 },
6300
+ step: ['resume'],
6301
+ });
6302
+
6303
+ expect(resumeResult.status).toBe('success');
6304
+ });
6305
+
6306
+ it('should not show removed runtimeContext values in subsequent steps', async ctx => {
6307
+ const inngest = new Inngest({
6308
+ id: 'mastra',
6309
+ baseUrl: `http://localhost:${(ctx as any).inngestPort}`,
6310
+ });
6311
+
6312
+ const { createWorkflow, createStep } = init(inngest);
6313
+ const testValue = 'test-dependency';
6314
+ const resumeStep = createStep({
6315
+ id: 'resume',
6316
+ inputSchema: z.object({ value: z.number() }),
6317
+ outputSchema: z.object({ value: z.number() }),
6318
+ resumeSchema: z.object({ value: z.number() }),
6319
+ suspendSchema: z.object({ message: z.string() }),
6320
+ execute: async ({ inputData, resumeData, suspend, runtimeContext }) => {
6321
+ const finalValue = (resumeData?.value ?? 0) + inputData.value;
6322
+
6323
+ if (!resumeData?.value || finalValue < 10) {
6324
+ return await suspend({
6325
+ message: `Please provide additional information. now value is ${inputData.value}`,
6326
+ });
6327
+ }
6328
+
6329
+ const testKey = runtimeContext.get('testKey');
6330
+ expect(testKey).toBe(testValue);
6331
+
6332
+ runtimeContext.delete('testKey');
6333
+
6334
+ return { value: finalValue };
6335
+ },
6336
+ });
6337
+
6338
+ const incrementStep = createStep({
6339
+ id: 'increment',
6340
+ inputSchema: z.object({
6341
+ value: z.number(),
6342
+ }),
6343
+ outputSchema: z.object({
6344
+ value: z.number(),
6345
+ }),
6346
+ execute: async ({ inputData, runtimeContext }) => {
6347
+ runtimeContext.set('testKey', testValue);
6348
+ return {
6349
+ value: inputData.value + 1,
6350
+ };
6351
+ },
6352
+ });
6353
+
6354
+ const incrementWorkflow = createWorkflow({
6355
+ id: 'increment-workflow',
6356
+ inputSchema: z.object({ value: z.number() }),
6357
+ outputSchema: z.object({ value: z.number() }),
6358
+ })
6359
+ .then(incrementStep)
6360
+ .then(resumeStep)
6361
+ .then(
6362
+ createStep({
6363
+ id: 'final',
6364
+ inputSchema: z.object({ value: z.number() }),
6365
+ outputSchema: z.object({ value: z.number() }),
6366
+ execute: async ({ inputData, runtimeContext }) => {
6367
+ const testKey = runtimeContext.get('testKey');
6368
+ expect(testKey).toBeUndefined();
6369
+ return { value: inputData.value };
6370
+ },
6371
+ }),
6372
+ )
6373
+ .commit();
6374
+
6375
+ new Mastra({
6376
+ logger: false,
6377
+ storage: testStorage,
6378
+ workflows: { incrementWorkflow },
6379
+ });
6380
+
6381
+ const run = await incrementWorkflow.createRunAsync();
6382
+ const result = await run.start({ inputData: { value: 0 } });
6383
+ expect(result.status).toBe('suspended');
6384
+
6385
+ const resumeResult = await run.resume({
6386
+ resumeData: { value: 21 },
6387
+ step: ['resume'],
6388
+ });
6389
+
6390
+ expect(resumeResult.status).toBe('success');
6391
+ });
6222
6392
  });
6223
6393
 
6224
6394
  describe('Access to inngest step primitives', () => {
package/src/index.ts CHANGED
@@ -1575,6 +1575,7 @@ export class InngestExecutionEngine extends DefaultExecutionEngine {
1575
1575
  workflowStatus: 'success' | 'failed' | 'suspended' | 'running';
1576
1576
  result?: Record<string, any>;
1577
1577
  error?: string | Error;
1578
+ runtimeContext: RuntimeContext;
1578
1579
  }) {
1579
1580
  await this.inngestStep.run(
1580
1581
  `workflow.${workflowId}.run.${runId}.path.${JSON.stringify(executionContext.executionPath)}.stepUpdate`,