@mastra/temporal 0.4.18-alpha.4 → 0.4.18-alpha.5
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/dist/index.cjs +27 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -15
- package/dist/index.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/temporal-workflow-runtime.mjs +54 -33
- package/dist/transforms/temporal-workflow-runtime.d.mts +16 -1
- package/dist/transforms/temporal-workflow-runtime.d.mts.map +1 -1
- package/dist/transforms/workflows.d.ts.map +1 -1
- package/dist/worker.cjs +13 -6
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +13 -6
- package/dist/worker.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_utils = require("./utils-BVE1AkTt.cjs");
|
|
3
3
|
let _mastra_core_workflows = require("@mastra/core/workflows");
|
|
4
4
|
// src/run.ts
|
|
5
|
+
function toStepResults(input, { steps, stepMeta }) {
|
|
6
|
+
if (!stepMeta) return {};
|
|
7
|
+
const records = { input };
|
|
8
|
+
for (const [stepId, times] of Object.entries(stepMeta)) records[stepId] = {
|
|
9
|
+
status: "success",
|
|
10
|
+
output: steps[stepId],
|
|
11
|
+
...times
|
|
12
|
+
};
|
|
13
|
+
return records;
|
|
14
|
+
}
|
|
5
15
|
var TemporalRun = class extends _mastra_core_workflows.Run {
|
|
6
16
|
client;
|
|
7
17
|
taskQueue;
|
|
@@ -15,25 +25,27 @@ var TemporalRun = class extends _mastra_core_workflows.Run {
|
|
|
15
25
|
const initialState = await this._validateInitialState(args.initialState);
|
|
16
26
|
await this._validateRequestContext(args.requestContext);
|
|
17
27
|
try {
|
|
28
|
+
const result = await (await this.client.workflow.start(require_utils.toWorkflowType(this.workflowId), {
|
|
29
|
+
taskQueue: this.taskQueue,
|
|
30
|
+
workflowId: this.runId,
|
|
31
|
+
args: [{
|
|
32
|
+
inputData: input,
|
|
33
|
+
initialState,
|
|
34
|
+
requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},
|
|
35
|
+
runId: this.runId,
|
|
36
|
+
resourceId: this.resourceId,
|
|
37
|
+
outputOptions: args.outputOptions,
|
|
38
|
+
tracingOptions: args.tracingOptions,
|
|
39
|
+
perStep: args.perStep,
|
|
40
|
+
recordStepMeta: true
|
|
41
|
+
}]
|
|
42
|
+
})).result();
|
|
18
43
|
return {
|
|
19
44
|
status: "success",
|
|
20
45
|
input,
|
|
21
|
-
result:
|
|
22
|
-
taskQueue: this.taskQueue,
|
|
23
|
-
workflowId: this.runId,
|
|
24
|
-
args: [{
|
|
25
|
-
inputData: input,
|
|
26
|
-
initialState,
|
|
27
|
-
requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},
|
|
28
|
-
runId: this.runId,
|
|
29
|
-
resourceId: this.resourceId,
|
|
30
|
-
outputOptions: args.outputOptions,
|
|
31
|
-
tracingOptions: args.tracingOptions,
|
|
32
|
-
perStep: args.perStep
|
|
33
|
-
}]
|
|
34
|
-
})).result()).result,
|
|
46
|
+
result: result.result,
|
|
35
47
|
state: initialState,
|
|
36
|
-
steps:
|
|
48
|
+
steps: toStepResults(input, result)
|
|
37
49
|
};
|
|
38
50
|
} catch (error) {
|
|
39
51
|
return {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["Run","toWorkflowType","Workflow"],"sources":["../src/run.ts","../src/workflow.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { WorkflowExecutionResult } from './transforms/temporal-workflow-runtime';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n const result = (await handle.result()) as WorkflowExecutionResult;\n\n return {\n status: 'success',\n input: input as TInput,\n result: result.result as TOutput,\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async cancel() {\n await this.client.workflow.getHandle(this.runId).cancel();\n await super.cancel();\n }\n\n private unsupported(method: string): never {\n throw new Error(`@mastra/temporal does not support ${method}() yet. Use start() or startAsync() instead.`);\n }\n\n override stream(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['stream']>\n ): never {\n return this.unsupported('stream');\n }\n\n override streamLegacy(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['streamLegacy']>\n ): never {\n return this.unsupported('streamLegacy');\n }\n\n override resumeStream(..._args: unknown[]): never {\n return this.unsupported('resumeStream');\n }\n\n override resume(..._args: unknown[]): never {\n return this.unsupported('resume');\n }\n\n override resumeAsync(..._args: unknown[]): never {\n return this.unsupported('resumeAsync');\n }\n\n override restart(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['restart']>\n ): never {\n return this.unsupported('restart');\n }\n\n override timeTravel(..._args: unknown[]): never {\n return this.unsupported('timeTravel');\n }\n\n override timeTravelStream(..._args: unknown[]): never {\n return this.unsupported('timeTravelStream');\n }\n\n async startAsync(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { ActivityOptions } from '@temporalio/workflow';\nimport { TemporalRun } from './run';\nimport type { TemporalEngineType } from './types';\n\nexport type TemporalWorkflowParams = {\n client: Client;\n taskQueue: string;\n startToCloseTimeout?: string;\n retry?: ActivityOptions['retry'];\n};\n\nexport class TemporalWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TPrevSchema = TInput,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Workflow<TemporalEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext> {\n private readonly temporalClient: Client;\n readonly taskQueue: string;\n readonly startToCloseTimeout: string;\n\n constructor(\n params: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporalParams: TemporalWorkflowParams,\n ) {\n super(params);\n\n this.engineType = 'temporal';\n this.temporalClient = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n this.startToCloseTimeout = temporalParams.startToCloseTimeout ?? '1 minute';\n }\n\n async createRun(options?: { runId?: string; resourceId?: string; disableScorers?: boolean }) {\n const runId = options?.runId ?? crypto.randomUUID();\n const run = new TemporalRun<TSteps, TState, TInput, TOutput, TRequestContext>(\n {\n workflowId: this.id,\n runId,\n resourceId: options?.resourceId,\n stateSchema: this.stateSchema,\n inputSchema: this.inputSchema,\n requestContextSchema: this.requestContextSchema,\n executionEngine: this.executionEngine,\n executionGraph: this.executionGraph,\n mastra: this.mastra,\n retryConfig: this.retryConfig,\n serializedStepGraph: this.serializedStepGraph,\n disableScorers: options?.disableScorers,\n tracingPolicy: this.options.tracingPolicy,\n workflowSteps: this.steps,\n validateInputs: this.options.validateInputs,\n workflowEngineType: this.engineType,\n cleanup: undefined,\n },\n {\n client: this.temporalClient,\n taskQueue: this.taskQueue,\n },\n );\n\n this.runs.set(runId, run);\n return run;\n }\n}\n\nexport function createWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n>(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporal: TemporalWorkflowParams,\n) {\n return new TemporalWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TInput, TRequestContext>(config, temporal);\n}\n\nexport function init(temporalParams: TemporalWorkflowParams) {\n return {\n createWorkflow: <\n TWorkflowId extends string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TSteps extends Step[] = Step[],\n TRequestContext extends Record<string, any> | unknown = unknown,\n >(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n ) => createWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TRequestContext>(config, temporalParams),\n createStep,\n };\n}\n"],"mappings":";;;;AAcA,IAAa,cAAb,cAcUA,uBAAAA,IAA0E;CAClF;CACA;CAEA,YACE,QACA,gBAIA;EACA,MAAM,MAAM;EAEZ,KAAK,SAAS,eAAe;EAC7B,KAAK,YAAY,eAAe;CAClC;CAEA,MAAM,MAAM,OAA8D,CAAC,GAAG;EAC5E,MAAM,QAAQ,MAAM,KAAK,eAAe,KAAK,SAAS;EACtD,MAAM,eAAe,MAAM,KAAK,sBAAsB,KAAK,YAAY;EACvE,MAAM,KAAK,wBAAwB,KAAK,cAAqD;EAE7F,IAAI;GAmBF,OAAO;IACL,QAAQ;IACD;IACP,SAAQ,OALY,MAhBD,KAAK,OAAO,SAAS,MAAMC,cAAAA,eAAe,KAAK,UAAU,GAAG;KAC/E,WAAW,KAAK;KAChB,YAAY,KAAK;KACjB,MAAM,CACJ;MACE,WAAW;MACX;MACA,gBAAgB,KAAK,iBAAiB,OAAO,YAAY,KAAK,eAAe,QAAQ,CAAC,IAAI,C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,QAAQ,cAAc;EACzG,YAAA,uBAAA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Run","toWorkflowType","Workflow"],"sources":["../src/run.ts","../src/workflow.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { WorkflowExecutionResult } from './transforms/temporal-workflow-runtime';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\n// Builds Mastra step records from the Temporal result. Iterates `stepMeta` rather than `steps`\n// because a step that returned undefined has no key in `steps` once serialized. A result without\n// `stepMeta` came from a Worker that predates it, so `steps` stays empty instead of guessing times.\nfunction toStepResults(input: unknown, { steps, stepMeta }: WorkflowExecutionResult): Record<string, unknown> {\n if (!stepMeta) {\n return {};\n }\n\n const records: Record<string, unknown> = { input };\n for (const [stepId, times] of Object.entries(stepMeta)) {\n records[stepId] = { status: 'success', output: steps[stepId], ...times };\n }\n return records;\n}\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n recordStepMeta: true,\n },\n ],\n });\n const result = (await handle.result()) as WorkflowExecutionResult;\n\n return {\n status: 'success',\n input: input as TInput,\n result: result.result as TOutput,\n state: initialState,\n steps: toStepResults(input, result),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async cancel() {\n await this.client.workflow.getHandle(this.runId).cancel();\n await super.cancel();\n }\n\n private unsupported(method: string): never {\n throw new Error(`@mastra/temporal does not support ${method}() yet. Use start() or startAsync() instead.`);\n }\n\n override stream(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['stream']>\n ): never {\n return this.unsupported('stream');\n }\n\n override streamLegacy(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['streamLegacy']>\n ): never {\n return this.unsupported('streamLegacy');\n }\n\n override resumeStream(..._args: unknown[]): never {\n return this.unsupported('resumeStream');\n }\n\n override resume(..._args: unknown[]): never {\n return this.unsupported('resume');\n }\n\n override resumeAsync(..._args: unknown[]): never {\n return this.unsupported('resumeAsync');\n }\n\n override restart(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['restart']>\n ): never {\n return this.unsupported('restart');\n }\n\n override timeTravel(..._args: unknown[]): never {\n return this.unsupported('timeTravel');\n }\n\n override timeTravelStream(..._args: unknown[]): never {\n return this.unsupported('timeTravelStream');\n }\n\n async startAsync(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { ActivityOptions } from '@temporalio/workflow';\nimport { TemporalRun } from './run';\nimport type { TemporalEngineType } from './types';\n\nexport type TemporalWorkflowParams = {\n client: Client;\n taskQueue: string;\n startToCloseTimeout?: string;\n retry?: ActivityOptions['retry'];\n};\n\nexport class TemporalWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TPrevSchema = TInput,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Workflow<TemporalEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext> {\n private readonly temporalClient: Client;\n readonly taskQueue: string;\n readonly startToCloseTimeout: string;\n\n constructor(\n params: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporalParams: TemporalWorkflowParams,\n ) {\n super(params);\n\n this.engineType = 'temporal';\n this.temporalClient = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n this.startToCloseTimeout = temporalParams.startToCloseTimeout ?? '1 minute';\n }\n\n async createRun(options?: { runId?: string; resourceId?: string; disableScorers?: boolean }) {\n const runId = options?.runId ?? crypto.randomUUID();\n const run = new TemporalRun<TSteps, TState, TInput, TOutput, TRequestContext>(\n {\n workflowId: this.id,\n runId,\n resourceId: options?.resourceId,\n stateSchema: this.stateSchema,\n inputSchema: this.inputSchema,\n requestContextSchema: this.requestContextSchema,\n executionEngine: this.executionEngine,\n executionGraph: this.executionGraph,\n mastra: this.mastra,\n retryConfig: this.retryConfig,\n serializedStepGraph: this.serializedStepGraph,\n disableScorers: options?.disableScorers,\n tracingPolicy: this.options.tracingPolicy,\n workflowSteps: this.steps,\n validateInputs: this.options.validateInputs,\n workflowEngineType: this.engineType,\n cleanup: undefined,\n },\n {\n client: this.temporalClient,\n taskQueue: this.taskQueue,\n },\n );\n\n this.runs.set(runId, run);\n return run;\n }\n}\n\nexport function createWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n>(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporal: TemporalWorkflowParams,\n) {\n return new TemporalWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TInput, TRequestContext>(config, temporal);\n}\n\nexport function init(temporalParams: TemporalWorkflowParams) {\n return {\n createWorkflow: <\n TWorkflowId extends string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TSteps extends Step[] = Step[],\n TRequestContext extends Record<string, any> | unknown = unknown,\n >(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n ) => createWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TRequestContext>(config, temporalParams),\n createStep,\n };\n}\n"],"mappings":";;;;AAWA,SAAS,cAAc,OAAgB,EAAE,OAAO,YAA8D;CAC5G,IAAI,CAAC,UACH,OAAO,CAAC;CAGV,MAAM,UAAmC,EAAE,MAAM;CACjD,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,QAAQ,GACnD,QAAQ,UAAU;EAAE,QAAQ;EAAW,QAAQ,MAAM;EAAS,GAAG;CAAM;CAEzE,OAAO;AACT;AAQA,IAAa,cAAb,cAcUA,uBAAAA,IAA0E;CAClF;CACA;CAEA,YACE,QACA,gBAIA;EACA,MAAM,MAAM;EAEZ,KAAK,SAAS,eAAe;EAC7B,KAAK,YAAY,eAAe;CAClC;CAEA,MAAM,MAAM,OAA8D,CAAC,GAAG;EAC5E,MAAM,QAAQ,MAAM,KAAK,eAAe,KAAK,SAAS;EACtD,MAAM,eAAe,MAAM,KAAK,sBAAsB,KAAK,YAAY;EACvE,MAAM,KAAK,wBAAwB,KAAK,cAAqD;EAE7F,IAAI;GAkBF,MAAM,SAAU,OAAM,MAjBD,KAAK,OAAO,SAAS,MAAMC,cAAAA,eAAe,KAAK,UAAU,GAAG;IAC/E,WAAW,KAAK;IAChB,YAAY,KAAK;IACjB,MAAM,CACJ;KACE,WAAW;KACX;KACA,gBAAgB,KAAK,iBAAiB,OAAO,YAAY,KAAK,eAAe,QAAQ,CAAC,IAAI,CAAC;KAC3F,OAAO,KAAK;KACZ,YAAY,KAAK;KACjB,eAAe,KAAK;KACpB,gBAAgB,KAAK;KACrB,SAAS,KAAK;KACd,gBAAgB;IAClB,CACF;GACF,CAAC,EAAA,CAC4B,OAAO;GAEpC,OAAO;IACL,QAAQ;IACD;IACP,QAAQ,OAAO;IACf,OAAO;IACP,OAAO,cAAc,OAAO,MAAM;GACpC;EACF,SAAS,OAAO;GACd,OAAO;IACL,QAAQ;IACD;IACP,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;IACpB,gBAAgB,KAAK;IACrB,SAAS,KAAK;GAChB,CACF;EACF,CAAC;EAED,OAAO,EAAE,OAAO,KAAK,MAAM;CAC7B;AACF;;AChKA,IAAa,mBAAb,cAgBUC,uBAAAA,SAAyG;CACjH;CACA;CACA;CAEA,YACE,QACA,gBACA;EACA,MAAM,MAAM;EAEZ,KAAK,aAAa;EAClB,KAAK,iBAAiB,eAAe;EACrC,KAAK,YAAY,eAAe;EAChC,KAAK,sBAAsB,eAAe,uBAAuB;CACnE;CAEA,MAAM,UAAU,SAA6E;EAC3F,MAAM,QAAQ,SAAS,SAAS,OAAO,WAAW;EAClD,MAAM,MAAM,IAAI,YACd;GACE,YAAY,KAAK;GACjB;GACA,YAAY,SAAS;GACrB,aAAa,KAAK;GAClB,aAAa,KAAK;GAClB,sBAAsB,KAAK;GAC3B,iBAAiB,KAAK;GACtB,gBAAgB,KAAK;GACrB,QAAQ,KAAK;GACb,aAAa,KAAK;GAClB,qBAAqB,KAAK;GAC1B,gBAAgB,SAAS;GACzB,eAAe,KAAK,QAAQ;GAC5B,eAAe,KAAK;GACpB,gBAAgB,KAAK,QAAQ;GAC7B,oBAAoB,KAAK;GACzB,SAAS,KAAA;EACX,GACA;GACE,QAAQ,KAAK;GACb,WAAW,KAAK;EAClB,CACF;EAEA,KAAK,KAAK,IAAI,OAAO,GAAG;EACxB,OAAO;CACT;AACF;AAEA,SAAgB,eAgBd,QACA,UACA;CACA,OAAO,IAAI,iBAAwF,QAAQ,QAAQ;AACrH;AAEA,SAAgB,KAAK,gBAAwC;CAC3D,OAAO;EACL,iBAQE,WACG,eAA8E,QAAQ,cAAc;EACzG,YAAA,uBAAA;CACF;AACF"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { t as toWorkflowType } from "./utils-R6cB86BM.js";
|
|
2
2
|
import { Run, Workflow, createStep } from "@mastra/core/workflows";
|
|
3
3
|
// src/run.ts
|
|
4
|
+
function toStepResults(input, { steps, stepMeta }) {
|
|
5
|
+
if (!stepMeta) return {};
|
|
6
|
+
const records = { input };
|
|
7
|
+
for (const [stepId, times] of Object.entries(stepMeta)) records[stepId] = {
|
|
8
|
+
status: "success",
|
|
9
|
+
output: steps[stepId],
|
|
10
|
+
...times
|
|
11
|
+
};
|
|
12
|
+
return records;
|
|
13
|
+
}
|
|
4
14
|
var TemporalRun = class extends Run {
|
|
5
15
|
client;
|
|
6
16
|
taskQueue;
|
|
@@ -14,25 +24,27 @@ var TemporalRun = class extends Run {
|
|
|
14
24
|
const initialState = await this._validateInitialState(args.initialState);
|
|
15
25
|
await this._validateRequestContext(args.requestContext);
|
|
16
26
|
try {
|
|
27
|
+
const result = await (await this.client.workflow.start(toWorkflowType(this.workflowId), {
|
|
28
|
+
taskQueue: this.taskQueue,
|
|
29
|
+
workflowId: this.runId,
|
|
30
|
+
args: [{
|
|
31
|
+
inputData: input,
|
|
32
|
+
initialState,
|
|
33
|
+
requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},
|
|
34
|
+
runId: this.runId,
|
|
35
|
+
resourceId: this.resourceId,
|
|
36
|
+
outputOptions: args.outputOptions,
|
|
37
|
+
tracingOptions: args.tracingOptions,
|
|
38
|
+
perStep: args.perStep,
|
|
39
|
+
recordStepMeta: true
|
|
40
|
+
}]
|
|
41
|
+
})).result();
|
|
17
42
|
return {
|
|
18
43
|
status: "success",
|
|
19
44
|
input,
|
|
20
|
-
result:
|
|
21
|
-
taskQueue: this.taskQueue,
|
|
22
|
-
workflowId: this.runId,
|
|
23
|
-
args: [{
|
|
24
|
-
inputData: input,
|
|
25
|
-
initialState,
|
|
26
|
-
requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},
|
|
27
|
-
runId: this.runId,
|
|
28
|
-
resourceId: this.resourceId,
|
|
29
|
-
outputOptions: args.outputOptions,
|
|
30
|
-
tracingOptions: args.tracingOptions,
|
|
31
|
-
perStep: args.perStep
|
|
32
|
-
}]
|
|
33
|
-
})).result()).result,
|
|
45
|
+
result: result.result,
|
|
34
46
|
state: initialState,
|
|
35
|
-
steps:
|
|
47
|
+
steps: toStepResults(input, result)
|
|
36
48
|
};
|
|
37
49
|
} catch (error) {
|
|
38
50
|
return {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/run.ts","../src/workflow.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { WorkflowExecutionResult } from './transforms/temporal-workflow-runtime';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n const result = (await handle.result()) as WorkflowExecutionResult;\n\n return {\n status: 'success',\n input: input as TInput,\n result: result.result as TOutput,\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async cancel() {\n await this.client.workflow.getHandle(this.runId).cancel();\n await super.cancel();\n }\n\n private unsupported(method: string): never {\n throw new Error(`@mastra/temporal does not support ${method}() yet. Use start() or startAsync() instead.`);\n }\n\n override stream(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['stream']>\n ): never {\n return this.unsupported('stream');\n }\n\n override streamLegacy(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['streamLegacy']>\n ): never {\n return this.unsupported('streamLegacy');\n }\n\n override resumeStream(..._args: unknown[]): never {\n return this.unsupported('resumeStream');\n }\n\n override resume(..._args: unknown[]): never {\n return this.unsupported('resume');\n }\n\n override resumeAsync(..._args: unknown[]): never {\n return this.unsupported('resumeAsync');\n }\n\n override restart(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['restart']>\n ): never {\n return this.unsupported('restart');\n }\n\n override timeTravel(..._args: unknown[]): never {\n return this.unsupported('timeTravel');\n }\n\n override timeTravelStream(..._args: unknown[]): never {\n return this.unsupported('timeTravelStream');\n }\n\n async startAsync(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { ActivityOptions } from '@temporalio/workflow';\nimport { TemporalRun } from './run';\nimport type { TemporalEngineType } from './types';\n\nexport type TemporalWorkflowParams = {\n client: Client;\n taskQueue: string;\n startToCloseTimeout?: string;\n retry?: ActivityOptions['retry'];\n};\n\nexport class TemporalWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TPrevSchema = TInput,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Workflow<TemporalEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext> {\n private readonly temporalClient: Client;\n readonly taskQueue: string;\n readonly startToCloseTimeout: string;\n\n constructor(\n params: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporalParams: TemporalWorkflowParams,\n ) {\n super(params);\n\n this.engineType = 'temporal';\n this.temporalClient = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n this.startToCloseTimeout = temporalParams.startToCloseTimeout ?? '1 minute';\n }\n\n async createRun(options?: { runId?: string; resourceId?: string; disableScorers?: boolean }) {\n const runId = options?.runId ?? crypto.randomUUID();\n const run = new TemporalRun<TSteps, TState, TInput, TOutput, TRequestContext>(\n {\n workflowId: this.id,\n runId,\n resourceId: options?.resourceId,\n stateSchema: this.stateSchema,\n inputSchema: this.inputSchema,\n requestContextSchema: this.requestContextSchema,\n executionEngine: this.executionEngine,\n executionGraph: this.executionGraph,\n mastra: this.mastra,\n retryConfig: this.retryConfig,\n serializedStepGraph: this.serializedStepGraph,\n disableScorers: options?.disableScorers,\n tracingPolicy: this.options.tracingPolicy,\n workflowSteps: this.steps,\n validateInputs: this.options.validateInputs,\n workflowEngineType: this.engineType,\n cleanup: undefined,\n },\n {\n client: this.temporalClient,\n taskQueue: this.taskQueue,\n },\n );\n\n this.runs.set(runId, run);\n return run;\n }\n}\n\nexport function createWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n>(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporal: TemporalWorkflowParams,\n) {\n return new TemporalWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TInput, TRequestContext>(config, temporal);\n}\n\nexport function init(temporalParams: TemporalWorkflowParams) {\n return {\n createWorkflow: <\n TWorkflowId extends string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TSteps extends Step[] = Step[],\n TRequestContext extends Record<string, any> | unknown = unknown,\n >(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n ) => createWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TRequestContext>(config, temporalParams),\n createStep,\n };\n}\n"],"mappings":";;;AAcA,IAAa,cAAb,cAcU,IAA0E;CAClF;CACA;CAEA,YACE,QACA,gBAIA;EACA,MAAM,MAAM;EAEZ,KAAK,SAAS,eAAe;EAC7B,K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ACrB,QAAQ,KAAK;GACb,aAAa,KAAK;GAClB,qBAAqB,KAAK;GAC1B,gBAAgB,SAAS;GACzB,eAAe,KAAK,QAAQ;GAC5B,eAAe,KAAK;GACpB,gBAAgB,KAAK,QAAQ;GAC7B,oBAAoB,KAAK;GACzB,SAAS,KAAA;EACX,GACA;GACE,QAAQ,KAAK;GACb,WAAW,KAAK;EAClB,CACF;EAEA,KAAK,KAAK,IAAI,OAAO,GAAG;EACxB,OAAO;CACT;AACF;AAEA,SAAgB,eAgBd,QACA,UACA;CACA,OAAO,IAAI,iBAAwF,QAAQ,QAAQ;AACrH;AAEA,SAAgB,KAAK,gBAAwC;CAC3D,OAAO;EACL,iBAQE,WACG,eAA8E,QAAQ,cAAc;EACzG;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/run.ts","../src/workflow.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/di';\nimport { Run } from '@mastra/core/workflows';\nimport type { Step, WorkflowResult, WorkflowRunStartOptions } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { WorkflowExecutionResult } from './transforms/temporal-workflow-runtime';\nimport type { TemporalEngineType } from './types';\nimport { toWorkflowType } from './utils';\n\n// Builds Mastra step records from the Temporal result. Iterates `stepMeta` rather than `steps`\n// because a step that returned undefined has no key in `steps` once serialized. A result without\n// `stepMeta` came from a Worker that predates it, so `steps` stays empty instead of guessing times.\nfunction toStepResults(input: unknown, { steps, stepMeta }: WorkflowExecutionResult): Record<string, unknown> {\n if (!stepMeta) {\n return {};\n }\n\n const records: Record<string, unknown> = { input };\n for (const [stepId, times] of Object.entries(stepMeta)) {\n records[stepId] = { status: 'success', output: steps[stepId], ...times };\n }\n return records;\n}\n\ntype TemporalRunStartArgs<TState, TInput, TRequestContext> = {\n inputData?: TInput;\n initialState?: TState;\n requestContext?: RequestContext<TRequestContext>;\n} & WorkflowRunStartOptions;\n\nexport class TemporalRun<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext> {\n private readonly client: Client;\n private readonly taskQueue: string;\n\n constructor(\n params: ConstructorParameters<typeof Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>>[0],\n temporalParams: {\n client: Client;\n taskQueue: string;\n },\n ) {\n super(params);\n\n this.client = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n }\n\n async start(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n try {\n const handle = await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n recordStepMeta: true,\n },\n ],\n });\n const result = (await handle.result()) as WorkflowExecutionResult;\n\n return {\n status: 'success',\n input: input as TInput,\n result: result.result as TOutput,\n state: initialState,\n steps: toStepResults(input, result),\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n } catch (error) {\n return {\n status: 'failed',\n input: input as TInput,\n error: error instanceof Error ? error : new Error(String(error)),\n state: initialState,\n steps: {},\n } as WorkflowResult<TState, TInput, TOutput, TSteps>;\n }\n }\n\n async cancel() {\n await this.client.workflow.getHandle(this.runId).cancel();\n await super.cancel();\n }\n\n private unsupported(method: string): never {\n throw new Error(`@mastra/temporal does not support ${method}() yet. Use start() or startAsync() instead.`);\n }\n\n override stream(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['stream']>\n ): never {\n return this.unsupported('stream');\n }\n\n override streamLegacy(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['streamLegacy']>\n ): never {\n return this.unsupported('streamLegacy');\n }\n\n override resumeStream(..._args: unknown[]): never {\n return this.unsupported('resumeStream');\n }\n\n override resume(..._args: unknown[]): never {\n return this.unsupported('resume');\n }\n\n override resumeAsync(..._args: unknown[]): never {\n return this.unsupported('resumeAsync');\n }\n\n override restart(\n ..._args: Parameters<Run<TemporalEngineType, TSteps, TState, TInput, TOutput, TRequestContext>['restart']>\n ): never {\n return this.unsupported('restart');\n }\n\n override timeTravel(..._args: unknown[]): never {\n return this.unsupported('timeTravel');\n }\n\n override timeTravelStream(..._args: unknown[]): never {\n return this.unsupported('timeTravelStream');\n }\n\n async startAsync(args: TemporalRunStartArgs<TState, TInput, TRequestContext> = {}) {\n const input = await this._validateInput(args.inputData);\n const initialState = await this._validateInitialState(args.initialState);\n await this._validateRequestContext(args.requestContext as RequestContext<unknown> | undefined);\n\n await this.client.workflow.start(toWorkflowType(this.workflowId), {\n taskQueue: this.taskQueue,\n workflowId: this.runId,\n args: [\n {\n inputData: input,\n initialState,\n requestContext: args.requestContext ? Object.fromEntries(args.requestContext.entries()) : {},\n runId: this.runId,\n resourceId: this.resourceId,\n outputOptions: args.outputOptions,\n tracingOptions: args.tracingOptions,\n perStep: args.perStep,\n },\n ],\n });\n\n return { runId: this.runId };\n }\n}\n","import { Workflow, createStep } from '@mastra/core/workflows';\nimport type { Step, WorkflowConfig } from '@mastra/core/workflows';\nimport type { Client } from '@temporalio/client';\nimport type { ActivityOptions } from '@temporalio/workflow';\nimport { TemporalRun } from './run';\nimport type { TemporalEngineType } from './types';\n\nexport type TemporalWorkflowParams = {\n client: Client;\n taskQueue: string;\n startToCloseTimeout?: string;\n retry?: ActivityOptions['retry'];\n};\n\nexport class TemporalWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TPrevSchema = TInput,\n TRequestContext extends Record<string, any> | unknown = unknown,\n> extends Workflow<TemporalEngineType, TSteps, TWorkflowId, TState, TInput, TOutput, TPrevSchema, TRequestContext> {\n private readonly temporalClient: Client;\n readonly taskQueue: string;\n readonly startToCloseTimeout: string;\n\n constructor(\n params: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporalParams: TemporalWorkflowParams,\n ) {\n super(params);\n\n this.engineType = 'temporal';\n this.temporalClient = temporalParams.client;\n this.taskQueue = temporalParams.taskQueue;\n this.startToCloseTimeout = temporalParams.startToCloseTimeout ?? '1 minute';\n }\n\n async createRun(options?: { runId?: string; resourceId?: string; disableScorers?: boolean }) {\n const runId = options?.runId ?? crypto.randomUUID();\n const run = new TemporalRun<TSteps, TState, TInput, TOutput, TRequestContext>(\n {\n workflowId: this.id,\n runId,\n resourceId: options?.resourceId,\n stateSchema: this.stateSchema,\n inputSchema: this.inputSchema,\n requestContextSchema: this.requestContextSchema,\n executionEngine: this.executionEngine,\n executionGraph: this.executionGraph,\n mastra: this.mastra,\n retryConfig: this.retryConfig,\n serializedStepGraph: this.serializedStepGraph,\n disableScorers: options?.disableScorers,\n tracingPolicy: this.options.tracingPolicy,\n workflowSteps: this.steps,\n validateInputs: this.options.validateInputs,\n workflowEngineType: this.engineType,\n cleanup: undefined,\n },\n {\n client: this.temporalClient,\n taskQueue: this.taskQueue,\n },\n );\n\n this.runs.set(runId, run);\n return run;\n }\n}\n\nexport function createWorkflow<\n TSteps extends Step<string, any, any, any, any, any, TemporalEngineType, any>[] = Step<\n string,\n unknown,\n unknown,\n unknown,\n unknown,\n unknown,\n TemporalEngineType\n >[],\n TWorkflowId extends string = string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TRequestContext extends Record<string, any> | unknown = unknown,\n>(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n temporal: TemporalWorkflowParams,\n) {\n return new TemporalWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TInput, TRequestContext>(config, temporal);\n}\n\nexport function init(temporalParams: TemporalWorkflowParams) {\n return {\n createWorkflow: <\n TWorkflowId extends string,\n TState = unknown,\n TInput = unknown,\n TOutput = unknown,\n TSteps extends Step[] = Step[],\n TRequestContext extends Record<string, any> | unknown = unknown,\n >(\n config: WorkflowConfig<TWorkflowId, TState, TInput, TOutput, TSteps, TRequestContext>,\n ) => createWorkflow<TSteps, TWorkflowId, TState, TInput, TOutput, TRequestContext>(config, temporalParams),\n createStep,\n };\n}\n"],"mappings":";;;AAWA,SAAS,cAAc,OAAgB,EAAE,OAAO,YAA8D;CAC5G,IAAI,CAAC,UACH,OAAO,CAAC;CAGV,MAAM,UAAmC,EAAE,MAAM;CACjD,KAAK,MAAM,CAAC,QAAQ,UAAU,OAAO,QAAQ,QAAQ,GACnD,QAAQ,UAAU;EAAE,QAAQ;EAAW,QAAQ,MAAM;EAAS,GAAG;CAAM;CAEzE,OAAO;AACT;AAQA,IAAa,cAAb,cAcU,IAA0E;CAClF;CACA;CAEA,YACE,QACA,gBAIA;EACA,MAAM,MAAM;EAEZ,KAAK,SAAS,eAAe;EAC7B,KAAK,YAAY,eAAe;CAClC;CAEA,MAAM,MAAM,OAA8D,CAAC,GAAG;EAC5E,MAAM,QAAQ,MAAM,KAAK,eAAe,KAAK,SAAS;EACtD,MAAM,eAAe,MAAM,KAAK,sBAAsB,KAAK,YAAY;EACvE,MAAM,KAAK,wBAAwB,KAAK,cAAqD;EAE7F,IAAI;GAkBF,MAAM,SAAU,OAAM,MAjBD,KAAK,OAAO,SAAS,MAAM,eAAe,KAAK,UAAU,GAAG;IAC/E,WAAW,KAAK;IAChB,YAAY,KAAK;IACjB,MAAM,CAC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,SAAgB,eAgBd,QACA,UACA;CACA,OAAO,IAAI,iBAAwF,QAAQ,QAAQ;AACrH;AAEA,SAAgB,KAAK,gBAAwC;CAC3D,OAAO;EACL,iBAQE,WACG,eAA8E,QAAQ,cAAc;EACzG;CACF;AACF"}
|
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC5F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAkBlD,KAAK,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,IAAI;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;CAClD,GAAG,uBAAuB,CAAC;AAE5B,qBAAa,WAAW,CACtB,MAAM,SAAS,IA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AAe,CAAC,CAAC,cAAc,CAAC,CAAC,GAC9G,KAAK,CAEP;IAEQ,YAAY,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAEhD;IAEQ,MAAM,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAE1C;IAEQ,WAAW,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAE/C;IAEQ,OAAO,CACd,GAAG,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,GACzG,KAAK,CAEP;IAEQ,UAAU,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAE9C;IAEQ,gBAAgB,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,KAAK,CAEpD;IAEK,UAAU,CAAC,IAAI,GAAE,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAM;;OAuBhF;CACF"}
|
|
@@ -20,6 +20,9 @@ export class TemporalExecutionEngine {
|
|
|
20
20
|
...(params.resourceId !== undefined && { resourceId: params.resourceId }),
|
|
21
21
|
workflowId: params.workflowId,
|
|
22
22
|
};
|
|
23
|
+
// Step times let start() build Mastra step records. Only recorded on request so runs that
|
|
24
|
+
// never read them (startAsync, runs started before the field existed) keep their result size.
|
|
25
|
+
this.stepMeta = params.recordStepMeta ? {} : undefined;
|
|
23
26
|
let result = params.input;
|
|
24
27
|
const stepResults = {};
|
|
25
28
|
|
|
@@ -33,9 +36,22 @@ export class TemporalExecutionEngine {
|
|
|
33
36
|
result,
|
|
34
37
|
state: params.initialState,
|
|
35
38
|
steps: stepResults,
|
|
39
|
+
...(this.stepMeta && { stepMeta: this.stepMeta }),
|
|
36
40
|
};
|
|
37
41
|
}
|
|
38
42
|
|
|
43
|
+
// Runs one timed entry and stores its output under `id`. Date.now() in Workflow code is the
|
|
44
|
+
// Workflow Task time, which replay reads from history.
|
|
45
|
+
async timed(stepResults, id, run) {
|
|
46
|
+
const startedAt = Date.now();
|
|
47
|
+
const out = await run();
|
|
48
|
+
stepResults[id] = out;
|
|
49
|
+
if (this.stepMeta) {
|
|
50
|
+
this.stepMeta[id] = { startedAt, endedAt: Date.now() };
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
|
|
39
55
|
activityParams(inputData, extra = {}) {
|
|
40
56
|
return { inputData, ...extra, ...this.executionContext };
|
|
41
57
|
}
|
|
@@ -44,28 +60,26 @@ export class TemporalExecutionEngine {
|
|
|
44
60
|
switch (entry.type) {
|
|
45
61
|
case 'step': {
|
|
46
62
|
log.info('step', { stepId: entry.step.id });
|
|
47
|
-
|
|
48
|
-
this.activityParams(inputData, { initData: this.initData }),
|
|
63
|
+
return this.timed(stepResults, entry.step.id, () =>
|
|
64
|
+
this.activityHandle[entry.step.id](this.activityParams(inputData, { initData: this.initData })),
|
|
49
65
|
);
|
|
50
|
-
stepResults[entry.step.id] = out;
|
|
51
|
-
return out;
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
case 'childWorkflow': {
|
|
55
69
|
log.info('childWorkflow', { workflowType: entry.workflowType });
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
return this.timed(stepResults, entry.id, async () => {
|
|
71
|
+
const childResult = await executeChild(entry.workflowType, {
|
|
72
|
+
args: [{ inputData, ...this.executionContext }],
|
|
73
|
+
});
|
|
74
|
+
return childResult?.result ?? childResult;
|
|
58
75
|
});
|
|
59
|
-
const out = childResult?.result ?? childResult;
|
|
60
|
-
stepResults[entry.workflowType] = out;
|
|
61
|
-
return out;
|
|
62
76
|
}
|
|
63
77
|
|
|
64
78
|
case 'mapping': {
|
|
65
79
|
log.info('mapping', { mappingId: entry.id });
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
80
|
+
return this.timed(stepResults, entry.id, () =>
|
|
81
|
+
this.activityHandle[entry.id](this.activityParams(inputData, { initData: this.initData })),
|
|
82
|
+
);
|
|
69
83
|
}
|
|
70
84
|
|
|
71
85
|
case 'sleep': {
|
|
@@ -90,6 +104,8 @@ export class TemporalExecutionEngine {
|
|
|
90
104
|
}
|
|
91
105
|
|
|
92
106
|
case 'parallel': {
|
|
107
|
+
// The next step keeps reading a nested workflow under its Temporal type name, as before.
|
|
108
|
+
// Only the step records use the Mastra id.
|
|
93
109
|
const entryId = parallelEntry =>
|
|
94
110
|
parallelEntry.type === 'childWorkflow' ? parallelEntry.workflowType : parallelEntry.step.id;
|
|
95
111
|
log.info('parallel', { steps: entry.steps.map(entryId) });
|
|
@@ -117,9 +133,9 @@ export class TemporalExecutionEngine {
|
|
|
117
133
|
for (let i = 0; i < entry.steps.length; i++) {
|
|
118
134
|
if (condResults[i]) {
|
|
119
135
|
const stepId = entry.steps[i].step.id;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
136
|
+
out[stepId] = await this.timed(stepResults, stepId, () =>
|
|
137
|
+
this.activityHandle[stepId](this.activityParams(inputData, { initData: this.initData })),
|
|
138
|
+
);
|
|
123
139
|
}
|
|
124
140
|
}
|
|
125
141
|
|
|
@@ -131,8 +147,10 @@ export class TemporalExecutionEngine {
|
|
|
131
147
|
let current = inputData;
|
|
132
148
|
|
|
133
149
|
while (true) {
|
|
134
|
-
|
|
135
|
-
stepResults
|
|
150
|
+
const stepInput = current;
|
|
151
|
+
current = await this.timed(stepResults, entry.step.id, () =>
|
|
152
|
+
this.activityHandle[entry.step.id](this.activityParams(stepInput, { initData: this.initData })),
|
|
153
|
+
);
|
|
136
154
|
const shouldContinue = Boolean(
|
|
137
155
|
await this.activityHandle[entry.serializedCondition.id](this.activityParams(current)),
|
|
138
156
|
);
|
|
@@ -154,23 +172,24 @@ export class TemporalExecutionEngine {
|
|
|
154
172
|
: (entry.opts.concurrency ?? 1);
|
|
155
173
|
const concurrency = Number.isFinite(configured) ? Math.max(1, Math.floor(configured)) : 1;
|
|
156
174
|
log.info('foreach', { step: entry.step.id, concurrency });
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
175
|
+
return this.timed(stepResults, entry.step.id, async () => {
|
|
176
|
+
const results = new Array(items.length);
|
|
177
|
+
let index = 0;
|
|
178
|
+
const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
|
|
179
|
+
while (true) {
|
|
180
|
+
const i = index++;
|
|
181
|
+
if (i >= items.length) {
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
results[i] = await this.activityHandle[entry.step.id](
|
|
185
|
+
this.activityParams(items[i], { initData: this.initData }),
|
|
186
|
+
);
|
|
164
187
|
}
|
|
165
|
-
|
|
166
|
-
this.activityParams(items[i], { initData: this.initData }),
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
188
|
+
});
|
|
170
189
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
190
|
+
await Promise.all(workers);
|
|
191
|
+
return results;
|
|
192
|
+
});
|
|
174
193
|
}
|
|
175
194
|
|
|
176
195
|
default:
|
|
@@ -198,6 +217,7 @@ export function createWorkflow(workflowId, options) {
|
|
|
198
217
|
},
|
|
199
218
|
input: startArgs?.inputData,
|
|
200
219
|
initialState: startArgs?.initialState,
|
|
220
|
+
recordStepMeta: startArgs?.recordStepMeta,
|
|
201
221
|
});
|
|
202
222
|
};
|
|
203
223
|
|
|
@@ -211,10 +231,11 @@ export function createWorkflow(workflowId, options) {
|
|
|
211
231
|
});
|
|
212
232
|
return workflow;
|
|
213
233
|
},
|
|
214
|
-
thenWorkflow(workflowType) {
|
|
234
|
+
thenWorkflow(workflowType, id) {
|
|
215
235
|
stepFlow.push({
|
|
216
236
|
type: 'childWorkflow',
|
|
217
237
|
workflowType,
|
|
238
|
+
id,
|
|
218
239
|
});
|
|
219
240
|
return workflow;
|
|
220
241
|
},
|
|
@@ -6,6 +6,7 @@ export declare class TemporalExecutionEngine {
|
|
|
6
6
|
resourceId?: any;
|
|
7
7
|
workflowId: any;
|
|
8
8
|
} | undefined;
|
|
9
|
+
stepMeta: {} | undefined;
|
|
9
10
|
startToCloseTimeout: any;
|
|
10
11
|
activityHandle: import("@temporalio/workflow").ActivityInterfaceFor<import("@temporalio/workflow").UntypedActivities>;
|
|
11
12
|
constructor(params: any);
|
|
@@ -15,7 +16,9 @@ export declare class TemporalExecutionEngine {
|
|
|
15
16
|
result: any;
|
|
16
17
|
state: any;
|
|
17
18
|
steps: {};
|
|
19
|
+
stepMeta?: {} | undefined;
|
|
18
20
|
}>;
|
|
21
|
+
timed(stepResults: any, id: any, run: any): Promise<any>;
|
|
19
22
|
activityParams(inputData: any, extra?: {}): {
|
|
20
23
|
requestContext?: any;
|
|
21
24
|
runId?: any;
|
|
@@ -31,6 +34,7 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
31
34
|
result: any;
|
|
32
35
|
state: any;
|
|
33
36
|
steps: {};
|
|
37
|
+
stepMeta?: {} | undefined;
|
|
34
38
|
}>) & {
|
|
35
39
|
then(stepId: any): (startArgs: any) => Promise<{
|
|
36
40
|
status: string;
|
|
@@ -38,13 +42,15 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
38
42
|
result: any;
|
|
39
43
|
state: any;
|
|
40
44
|
steps: {};
|
|
45
|
+
stepMeta?: {} | undefined;
|
|
41
46
|
}>;
|
|
42
|
-
thenWorkflow(workflowType: any): (startArgs: any) => Promise<{
|
|
47
|
+
thenWorkflow(workflowType: any, id: any): (startArgs: any) => Promise<{
|
|
43
48
|
status: string;
|
|
44
49
|
input: any;
|
|
45
50
|
result: any;
|
|
46
51
|
state: any;
|
|
47
52
|
steps: {};
|
|
53
|
+
stepMeta?: {} | undefined;
|
|
48
54
|
}>;
|
|
49
55
|
map(mappingId: any): (startArgs: any) => Promise<{
|
|
50
56
|
status: string;
|
|
@@ -52,6 +58,7 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
52
58
|
result: any;
|
|
53
59
|
state: any;
|
|
54
60
|
steps: {};
|
|
61
|
+
stepMeta?: {} | undefined;
|
|
55
62
|
}>;
|
|
56
63
|
sleep(durationOrFnId: any): (startArgs: any) => Promise<{
|
|
57
64
|
status: string;
|
|
@@ -59,6 +66,7 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
59
66
|
result: any;
|
|
60
67
|
state: any;
|
|
61
68
|
steps: {};
|
|
69
|
+
stepMeta?: {} | undefined;
|
|
62
70
|
}>;
|
|
63
71
|
sleepUntil(dateOrFnId: any): (startArgs: any) => Promise<{
|
|
64
72
|
status: string;
|
|
@@ -66,6 +74,7 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
66
74
|
result: any;
|
|
67
75
|
state: any;
|
|
68
76
|
steps: {};
|
|
77
|
+
stepMeta?: {} | undefined;
|
|
69
78
|
}>;
|
|
70
79
|
parallel(entries: any): (startArgs: any) => Promise<{
|
|
71
80
|
status: string;
|
|
@@ -73,6 +82,7 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
73
82
|
result: any;
|
|
74
83
|
state: any;
|
|
75
84
|
steps: {};
|
|
85
|
+
stepMeta?: {} | undefined;
|
|
76
86
|
}>;
|
|
77
87
|
branch(pairs: any): (startArgs: any) => Promise<{
|
|
78
88
|
status: string;
|
|
@@ -80,6 +90,7 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
80
90
|
result: any;
|
|
81
91
|
state: any;
|
|
82
92
|
steps: {};
|
|
93
|
+
stepMeta?: {} | undefined;
|
|
83
94
|
}>;
|
|
84
95
|
dowhile(stepId: any, condId: any): (startArgs: any) => Promise<{
|
|
85
96
|
status: string;
|
|
@@ -87,6 +98,7 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
87
98
|
result: any;
|
|
88
99
|
state: any;
|
|
89
100
|
steps: {};
|
|
101
|
+
stepMeta?: {} | undefined;
|
|
90
102
|
}>;
|
|
91
103
|
dountil(stepId: any, condId: any): (startArgs: any) => Promise<{
|
|
92
104
|
status: string;
|
|
@@ -94,6 +106,7 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
94
106
|
result: any;
|
|
95
107
|
state: any;
|
|
96
108
|
steps: {};
|
|
109
|
+
stepMeta?: {} | undefined;
|
|
97
110
|
}>;
|
|
98
111
|
foreach(stepId: any, opts: any): (startArgs: any) => Promise<{
|
|
99
112
|
status: string;
|
|
@@ -101,6 +114,7 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
101
114
|
result: any;
|
|
102
115
|
state: any;
|
|
103
116
|
steps: {};
|
|
117
|
+
stepMeta?: {} | undefined;
|
|
104
118
|
}>;
|
|
105
119
|
commit(): (startArgs: any) => Promise<{
|
|
106
120
|
status: string;
|
|
@@ -108,6 +122,7 @@ export declare function createWorkflow(workflowId: any, options: any): ((startAr
|
|
|
108
122
|
result: any;
|
|
109
123
|
state: any;
|
|
110
124
|
steps: {};
|
|
125
|
+
stepMeta?: {} | undefined;
|
|
111
126
|
}>;
|
|
112
127
|
};
|
|
113
128
|
//# sourceMappingURL=temporal-workflow-runtime.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporal-workflow-runtime.d.mts","sourceRoot":"","sources":["../../src/transforms/temporal-workflow-runtime.mjs"],"names":[],"mappings":"AAEA,qBAAa,uBAAuB;IAa3B,QAAQ;IACR,gBAAgB;;;;;;
|
|
1
|
+
{"version":3,"file":"temporal-workflow-runtime.d.mts","sourceRoot":"","sources":["../../src/transforms/temporal-workflow-runtime.mjs"],"names":[],"mappings":"AAEA,qBAAa,uBAAuB;IAa3B,QAAQ;IACR,gBAAgB;;;;;;IAQhB,QAAQ;IArBf,mBAAmB,MAAC;IACpB,cAAc,wGAAC;IAEf,YAAY,MAAM,KAAA,EAMjB;IAEK,OAAO,CAAC,MAAM,KAAA;;;;;;;OA0BnB;IAIK,KAAK,CAAC,WAAW,KAAA,EAAE,EAAE,KAAA,EAAE,GAAG,KAAA,gBAQ/B;IAED,cAAc,CAAC,SAAS,KAAA,EAAE,KAAK,KAAK;;;;;;MAEnC;IAEK,YAAY,CAAC,KAAK,KAAA,EAAE,SAAS,KAAA,EAAE,WAAW,KAAA,gBA2I/C;CACF;AAED,wBAAgB,cAAc,CAAC,UAAU,KAAA,EAAE,OAAO,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsJjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/transforms/workflows.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/transforms/workflows.ts"],"names":[],"mappings":"AA2gBA,MAAM,WAAW,4BAA4B;CAE5C;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,sBAAsB,EAAE,CAAC;CACrC;AA+UD;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAsDjC"}
|
package/dist/worker.cjs
CHANGED
|
@@ -788,7 +788,10 @@ function collectWorkflowBindings(program, filePath) {
|
|
|
788
788
|
const [workflowConfig] = workflowChain?.createWorkflowCall.arguments ?? [];
|
|
789
789
|
if (!workflowChain || !workflowConfig || !_babel_types.isObjectExpression(workflowConfig)) continue;
|
|
790
790
|
const { workflowId } = getWorkflowIdMetadata(workflowConfig, declaration.id.name, filePath);
|
|
791
|
-
workflowBindings.set(declaration.id.name,
|
|
791
|
+
workflowBindings.set(declaration.id.name, {
|
|
792
|
+
workflowType: require_utils.toWorkflowType(workflowId),
|
|
793
|
+
workflowId
|
|
794
|
+
});
|
|
792
795
|
}
|
|
793
796
|
}
|
|
794
797
|
return workflowBindings;
|
|
@@ -820,8 +823,8 @@ function rewriteChainMethod(method, filePath, workflowName, workflowId, mappingO
|
|
|
820
823
|
case "then": {
|
|
821
824
|
const arg = argNode(0);
|
|
822
825
|
if (_babel_types.isIdentifier(arg)) {
|
|
823
|
-
const
|
|
824
|
-
if (
|
|
826
|
+
const binding = workflowBindings.get(arg.name);
|
|
827
|
+
if (binding) return rewritten([_babel_types.stringLiteral(binding.workflowType), _babel_types.stringLiteral(binding.workflowId)], "thenWorkflow");
|
|
825
828
|
}
|
|
826
829
|
const name = getWorkflowStepName(arg, stepBindings);
|
|
827
830
|
if (!name) throw new Error(`.then() in ${workflowName} (${filePath}) must take a step or workflow identifier (inline createStep calls are not supported)`);
|
|
@@ -847,8 +850,12 @@ function rewriteChainMethod(method, filePath, workflowName, workflowId, mappingO
|
|
|
847
850
|
if (!_babel_types.isArrayExpression(arg)) throw new Error(`.parallel() in ${workflowName} (${filePath}) requires an array literal argument`);
|
|
848
851
|
const entries = arg.elements.map((element) => {
|
|
849
852
|
if (_babel_types.isIdentifier(element)) {
|
|
850
|
-
const
|
|
851
|
-
if (
|
|
853
|
+
const binding = workflowBindings.get(element.name);
|
|
854
|
+
if (binding) return _babel_types.objectExpression([
|
|
855
|
+
_babel_types.objectProperty(_babel_types.identifier("type"), _babel_types.stringLiteral("childWorkflow")),
|
|
856
|
+
_babel_types.objectProperty(_babel_types.identifier("workflowType"), _babel_types.stringLiteral(binding.workflowType)),
|
|
857
|
+
_babel_types.objectProperty(_babel_types.identifier("id"), _babel_types.stringLiteral(binding.workflowId))
|
|
858
|
+
]);
|
|
852
859
|
}
|
|
853
860
|
const stepId = getWorkflowStepName(element, stepBindings);
|
|
854
861
|
if (!stepId) throw new Error(`Unable to determine step names inside .parallel() in ${workflowName} (${filePath})`);
|
|
@@ -1001,7 +1008,7 @@ function rewriteWorkflowImportDeclaration(statement, state) {
|
|
|
1001
1008
|
}
|
|
1002
1009
|
function getNormalizedWorkflowBindingName(name, state) {
|
|
1003
1010
|
if (!state.workflowNames.has(name)) return null;
|
|
1004
|
-
return state.workflowBindings.get(name) ?? name;
|
|
1011
|
+
return state.workflowBindings.get(name)?.workflowType ?? name;
|
|
1005
1012
|
}
|
|
1006
1013
|
function rewriteWorkflowNamedExport(statement, state) {
|
|
1007
1014
|
if (statement.source != null) return;
|