@mastra/inngest 0.0.0-vnext-inngest-20250508121018 → 0.0.0-vnext-inngest-20250508131921

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mastra/inngest
2
2
 
3
- ## 0.0.0-vnext-inngest-20250508121018
3
+ ## 0.0.0-vnext-inngest-20250508131921
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -9,4 +9,4 @@
9
9
  - Updated dependencies [b5d2de0]
10
10
  - Updated dependencies [644f8ad]
11
11
  - Updated dependencies [70dbf51]
12
- - @mastra/core@0.0.0-vnext-inngest-20250508121018
12
+ - @mastra/core@0.0.0-vnext-inngest-20250508131921
@@ -22,6 +22,8 @@ import type { Span } from '@opentelemetry/api';
22
22
  import type { StepFlowEntry } from '@mastra/core/workflows/vNext';
23
23
  import type { StepResult } from '@mastra/core/workflows/vNext';
24
24
  import type { WorkflowResult } from '@mastra/core/workflows/vNext';
25
+ import type { WorkflowRun } from '@mastra/core';
26
+ import { WorkflowRuns } from '@mastra/core';
25
27
  import type { z } from 'zod';
26
28
 
27
29
  declare function cloneWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TSteps extends NewStep<string, any, any, any, any>[] = NewStep<string, any, any, any, any>[]>(workflow: InngestWorkflow<TSteps, string, TInput, TOutput>, opts: {
@@ -147,6 +149,14 @@ export declare class InngestWorkflow<TSteps extends NewStep<string, any, any>[]
147
149
  inngest: Inngest;
148
150
  private function;
149
151
  constructor(params: NewWorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>, inngest: Inngest);
152
+ getWorkflowRuns(args?: {
153
+ fromDate?: Date;
154
+ toDate?: Date;
155
+ limit?: number;
156
+ offset?: number;
157
+ resourceId?: string;
158
+ }): Promise<WorkflowRuns>;
159
+ getWorkflowRunById(runId: string): Promise<WorkflowRun | null>;
150
160
  __registerMastra(mastra: Mastra): void;
151
161
  createRun(options?: {
152
162
  runId?: string;
@@ -22,6 +22,8 @@ import type { Span } from '@opentelemetry/api';
22
22
  import type { StepFlowEntry } from '@mastra/core/workflows/vNext';
23
23
  import type { StepResult } from '@mastra/core/workflows/vNext';
24
24
  import type { WorkflowResult } from '@mastra/core/workflows/vNext';
25
+ import type { WorkflowRun } from '@mastra/core';
26
+ import { WorkflowRuns } from '@mastra/core';
25
27
  import type { z } from 'zod';
26
28
 
27
29
  declare function cloneWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TSteps extends NewStep<string, any, any, any, any>[] = NewStep<string, any, any, any, any>[]>(workflow: InngestWorkflow<TSteps, string, TInput, TOutput>, opts: {
@@ -147,6 +149,14 @@ export declare class InngestWorkflow<TSteps extends NewStep<string, any, any>[]
147
149
  inngest: Inngest;
148
150
  private function;
149
151
  constructor(params: NewWorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>, inngest: Inngest);
152
+ getWorkflowRuns(args?: {
153
+ fromDate?: Date;
154
+ toDate?: Date;
155
+ limit?: number;
156
+ offset?: number;
157
+ resourceId?: string;
158
+ }): Promise<WorkflowRuns>;
159
+ getWorkflowRunById(runId: string): Promise<WorkflowRun | null>;
150
160
  __registerMastra(mastra: Mastra): void;
151
161
  createRun(options?: {
152
162
  runId?: string;
package/dist/index.cjs CHANGED
@@ -146,6 +146,23 @@ var InngestWorkflow = class _InngestWorkflow extends vNext.NewWorkflow {
146
146
  this.#mastra = params.mastra;
147
147
  this.inngest = inngest;
148
148
  }
149
+ async getWorkflowRuns(args) {
150
+ const storage = this.#mastra?.getStorage();
151
+ if (!storage) {
152
+ this.logger.debug("Cannot get workflow runs. Mastra engine is not initialized");
153
+ return { runs: [], total: 0 };
154
+ }
155
+ return storage.getWorkflowRuns({ workflowName: this.id, ...args ?? {} });
156
+ }
157
+ async getWorkflowRunById(runId) {
158
+ const storage = this.#mastra?.getStorage();
159
+ if (!storage) {
160
+ this.logger.debug("Cannot get workflow runs. Mastra engine is not initialized");
161
+ return null;
162
+ }
163
+ const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
164
+ return run ?? (this.runs.get(runId) ? { ...this.runs.get(runId), workflowName: this.id } : null);
165
+ }
149
166
  __registerMastra(mastra) {
150
167
  this.#mastra = mastra;
151
168
  this.executionEngine.__registerMastra(mastra);
@@ -166,17 +183,19 @@ var InngestWorkflow = class _InngestWorkflow extends vNext.NewWorkflow {
166
183
  }
167
184
  createRun(options) {
168
185
  const runIdToUse = options?.runId || crypto.randomUUID();
169
- const run = new InngestRun(
186
+ const run = this.runs.get(runIdToUse) ?? new InngestRun(
170
187
  {
171
188
  workflowId: this.id,
172
189
  runId: runIdToUse,
173
190
  executionEngine: this.executionEngine,
174
191
  executionGraph: this.executionGraph,
175
192
  mastra: this.#mastra,
176
- retryConfig: this.retryConfig
193
+ retryConfig: this.retryConfig,
194
+ cleanup: () => this.runs.delete(runIdToUse)
177
195
  },
178
196
  this.inngest
179
197
  );
198
+ this.runs.set(runIdToUse, run);
180
199
  return run;
181
200
  }
182
201
  getFunction() {
package/dist/index.js CHANGED
@@ -144,6 +144,23 @@ var InngestWorkflow = class _InngestWorkflow extends NewWorkflow {
144
144
  this.#mastra = params.mastra;
145
145
  this.inngest = inngest;
146
146
  }
147
+ async getWorkflowRuns(args) {
148
+ const storage = this.#mastra?.getStorage();
149
+ if (!storage) {
150
+ this.logger.debug("Cannot get workflow runs. Mastra engine is not initialized");
151
+ return { runs: [], total: 0 };
152
+ }
153
+ return storage.getWorkflowRuns({ workflowName: this.id, ...args ?? {} });
154
+ }
155
+ async getWorkflowRunById(runId) {
156
+ const storage = this.#mastra?.getStorage();
157
+ if (!storage) {
158
+ this.logger.debug("Cannot get workflow runs. Mastra engine is not initialized");
159
+ return null;
160
+ }
161
+ const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
162
+ return run ?? (this.runs.get(runId) ? { ...this.runs.get(runId), workflowName: this.id } : null);
163
+ }
147
164
  __registerMastra(mastra) {
148
165
  this.#mastra = mastra;
149
166
  this.executionEngine.__registerMastra(mastra);
@@ -164,17 +181,19 @@ var InngestWorkflow = class _InngestWorkflow extends NewWorkflow {
164
181
  }
165
182
  createRun(options) {
166
183
  const runIdToUse = options?.runId || randomUUID();
167
- const run = new InngestRun(
184
+ const run = this.runs.get(runIdToUse) ?? new InngestRun(
168
185
  {
169
186
  workflowId: this.id,
170
187
  runId: runIdToUse,
171
188
  executionEngine: this.executionEngine,
172
189
  executionGraph: this.executionGraph,
173
190
  mastra: this.#mastra,
174
- retryConfig: this.retryConfig
191
+ retryConfig: this.retryConfig,
192
+ cleanup: () => this.runs.delete(runIdToUse)
175
193
  },
176
194
  this.inngest
177
195
  );
196
+ this.runs.set(runIdToUse, run);
178
197
  return run;
179
198
  }
180
199
  getFunction() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/inngest",
3
- "version": "0.0.0-vnext-inngest-20250508121018",
3
+ "version": "0.0.0-vnext-inngest-20250508131921",
4
4
  "description": "Mastra Inngest integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "inngest": "^3.35.1",
24
24
  "zod": "^3.24.2",
25
25
  "@opentelemetry/api": "^1.9.0",
26
- "@mastra/core": "0.0.0-vnext-inngest-20250508121018"
26
+ "@mastra/core": "0.0.0-vnext-inngest-20250508131921"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@ai-sdk/openai": "^1.2.1",
@@ -38,8 +38,8 @@
38
38
  "tsup": "^8.4.0",
39
39
  "typescript": "^5.8.2",
40
40
  "vitest": "^2.1.9",
41
- "@internal/lint": "0.0.0-vnext-inngest-20250508121018",
42
- "@mastra/deployer": "0.0.0-vnext-inngest-20250508121018"
41
+ "@internal/lint": "0.0.0-vnext-inngest-20250508131921",
42
+ "@mastra/deployer": "0.0.0-vnext-inngest-20250508131921"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from 'crypto';
2
2
  import { subscribe } from '@inngest/realtime';
3
- import type { Mastra } from '@mastra/core';
3
+ import type { Mastra, WorkflowRun } from '@mastra/core';
4
4
  import { RuntimeContext } from '@mastra/core/di';
5
5
  import { NewWorkflow, createStep, Run, DefaultExecutionEngine, cloneStep } from '@mastra/core/workflows/vNext';
6
6
  import type {
@@ -213,6 +213,36 @@ export class InngestWorkflow<
213
213
  this.inngest = inngest;
214
214
  }
215
215
 
216
+ async getWorkflowRuns(args?: {
217
+ fromDate?: Date;
218
+ toDate?: Date;
219
+ limit?: number;
220
+ offset?: number;
221
+ resourceId?: string;
222
+ }) {
223
+ const storage = this.#mastra?.getStorage();
224
+ if (!storage) {
225
+ this.logger.debug('Cannot get workflow runs. Mastra engine is not initialized');
226
+ return { runs: [], total: 0 };
227
+ }
228
+
229
+ return storage.getWorkflowRuns({ workflowName: this.id, ...(args ?? {}) });
230
+ }
231
+
232
+ async getWorkflowRunById(runId: string): Promise<WorkflowRun | null> {
233
+ const storage = this.#mastra?.getStorage();
234
+ if (!storage) {
235
+ this.logger.debug('Cannot get workflow runs. Mastra engine is not initialized');
236
+ return null;
237
+ }
238
+ const run = await storage.getWorkflowRunById({ runId, workflowName: this.id });
239
+
240
+ return (
241
+ run ??
242
+ (this.runs.get(runId) ? ({ ...this.runs.get(runId), workflowName: this.id } as unknown as WorkflowRun) : null)
243
+ );
244
+ }
245
+
216
246
  __registerMastra(mastra: Mastra) {
217
247
  this.#mastra = mastra;
218
248
  this.executionEngine.__registerMastra(mastra);
@@ -240,18 +270,22 @@ export class InngestWorkflow<
240
270
  const runIdToUse = options?.runId || randomUUID();
241
271
 
242
272
  // Return a new Run instance with object parameters
243
- const run: Run<TSteps, TInput, TOutput> = new InngestRun(
244
- {
245
- workflowId: this.id,
246
- runId: runIdToUse,
247
- executionEngine: this.executionEngine,
248
- executionGraph: this.executionGraph,
249
- mastra: this.#mastra,
250
- retryConfig: this.retryConfig,
251
- },
252
- this.inngest,
253
- );
273
+ const run: Run<TSteps, TInput, TOutput> =
274
+ this.runs.get(runIdToUse) ??
275
+ new InngestRun(
276
+ {
277
+ workflowId: this.id,
278
+ runId: runIdToUse,
279
+ executionEngine: this.executionEngine,
280
+ executionGraph: this.executionGraph,
281
+ mastra: this.#mastra,
282
+ retryConfig: this.retryConfig,
283
+ cleanup: () => this.runs.delete(runIdToUse),
284
+ },
285
+ this.inngest,
286
+ );
254
287
 
288
+ this.runs.set(runIdToUse, run);
255
289
  return run;
256
290
  }
257
291