@mastra/temporal 0.4.18-alpha.3 → 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/worker.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as toWorkflowType } from "./utils-B_iPTfDi.js";
1
+ import { t as toWorkflowType } from "./utils-R6cB86BM.js";
2
2
  import { builtinModules } from "module";
3
3
  import { readFileSync } from "fs";
4
4
  import { writeFile } from "fs/promises";
@@ -8,7 +8,7 @@ import { generate } from "@babel/generator";
8
8
  import { parse } from "@babel/parser";
9
9
  import * as t from "@babel/types";
10
10
  import { rollup } from "rollup";
11
- //#region src/transforms/shared.ts
11
+ // src/transforms/shared.ts
12
12
  const parserPlugins = [
13
13
  "typescript",
14
14
  "jsx",
@@ -265,8 +265,7 @@ function pruneUnusedTopLevelBindings(statements) {
265
265
  });
266
266
  return prunedStatements;
267
267
  }
268
- //#endregion
269
- //#region src/transforms/activities.ts
268
+ // src/transforms/activities.ts
270
269
  function normalizeImportPath(importPath, extension) {
271
270
  const normalizedPath = importPath.split(path.sep).join("/");
272
271
  const pathWithExtension = extension === ".mjs" || extension === ".cjs" ? normalizedPath : normalizedPath.replace(/\.[cm]?[jt]sx?$/, "");
@@ -649,8 +648,7 @@ async function buildTemporalActivitiesModule(entryFile, outputDirectory, outputF
649
648
  await bundle.close();
650
649
  }
651
650
  }
652
- //#endregion
653
- //#region src/transforms/workflows.ts
651
+ // src/transforms/workflows.ts
654
652
  /**
655
653
  * Temporal workflow types must be static so the loader can deterministically map
656
654
  * a source workflow to the runtime export name used by the worker.
@@ -766,7 +764,10 @@ function collectWorkflowBindings(program, filePath) {
766
764
  const [workflowConfig] = workflowChain?.createWorkflowCall.arguments ?? [];
767
765
  if (!workflowChain || !workflowConfig || !t.isObjectExpression(workflowConfig)) continue;
768
766
  const { workflowId } = getWorkflowIdMetadata(workflowConfig, declaration.id.name, filePath);
769
- workflowBindings.set(declaration.id.name, toWorkflowType(workflowId));
767
+ workflowBindings.set(declaration.id.name, {
768
+ workflowType: toWorkflowType(workflowId),
769
+ workflowId
770
+ });
770
771
  }
771
772
  }
772
773
  return workflowBindings;
@@ -798,8 +799,8 @@ function rewriteChainMethod(method, filePath, workflowName, workflowId, mappingO
798
799
  case "then": {
799
800
  const arg = argNode(0);
800
801
  if (t.isIdentifier(arg)) {
801
- const workflowType = workflowBindings.get(arg.name);
802
- if (workflowType) return rewritten([t.stringLiteral(workflowType)], "thenWorkflow");
802
+ const binding = workflowBindings.get(arg.name);
803
+ if (binding) return rewritten([t.stringLiteral(binding.workflowType), t.stringLiteral(binding.workflowId)], "thenWorkflow");
803
804
  }
804
805
  const name = getWorkflowStepName(arg, stepBindings);
805
806
  if (!name) throw new Error(`.then() in ${workflowName} (${filePath}) must take a step or workflow identifier (inline createStep calls are not supported)`);
@@ -825,8 +826,12 @@ function rewriteChainMethod(method, filePath, workflowName, workflowId, mappingO
825
826
  if (!t.isArrayExpression(arg)) throw new Error(`.parallel() in ${workflowName} (${filePath}) requires an array literal argument`);
826
827
  const entries = arg.elements.map((element) => {
827
828
  if (t.isIdentifier(element)) {
828
- const workflowType = workflowBindings.get(element.name);
829
- if (workflowType) return t.objectExpression([t.objectProperty(t.identifier("type"), t.stringLiteral("childWorkflow")), t.objectProperty(t.identifier("workflowType"), t.stringLiteral(workflowType))]);
829
+ const binding = workflowBindings.get(element.name);
830
+ if (binding) return t.objectExpression([
831
+ t.objectProperty(t.identifier("type"), t.stringLiteral("childWorkflow")),
832
+ t.objectProperty(t.identifier("workflowType"), t.stringLiteral(binding.workflowType)),
833
+ t.objectProperty(t.identifier("id"), t.stringLiteral(binding.workflowId))
834
+ ]);
830
835
  }
831
836
  const stepId = getWorkflowStepName(element, stepBindings);
832
837
  if (!stepId) throw new Error(`Unable to determine step names inside .parallel() in ${workflowName} (${filePath})`);
@@ -979,7 +984,7 @@ function rewriteWorkflowImportDeclaration(statement, state) {
979
984
  }
980
985
  function getNormalizedWorkflowBindingName(name, state) {
981
986
  if (!state.workflowNames.has(name)) return null;
982
- return state.workflowBindings.get(name) ?? name;
987
+ return state.workflowBindings.get(name)?.workflowType ?? name;
983
988
  }
984
989
  function rewriteWorkflowNamedExport(statement, state) {
985
990
  if (statement.source != null) return;
@@ -1101,8 +1106,7 @@ async function buildTemporalWorkflowModule(entryFile, outputDirectory, outputFil
1101
1106
  await bundle.close();
1102
1107
  }
1103
1108
  }
1104
- //#endregion
1105
- //#region src/plugin.ts
1109
+ // src/plugin.ts
1106
1110
  const CACHE_PATH = "node_modules/.mastra";
1107
1111
  const WORKFLOW_FILE_NAME = "workflow.mjs";
1108
1112
  const ACTIVITIES_FILE_NAME = "activities.mjs";
@@ -1128,7 +1132,7 @@ var MastraPlugin = class {
1128
1132
  this.projectRoot = projectRoot;
1129
1133
  }
1130
1134
  async #bundleMastra(entryFile, projectRoot, outputDirectory) {
1131
- const { BuildBundler } = await import("./mastra-deployer-rZLKb1Em.js");
1135
+ const { BuildBundler } = await import("./mastra-deployer-BtoNM1bq.js");
1132
1136
  const normalizedEntryFile = entryFile.startsWith("file:/") ? fileURLToPath(entryFile) : entryFile;
1133
1137
  const mastraBundler = new BuildBundler();
1134
1138
  await mastraBundler.prepare(outputDirectory);
@@ -1205,7 +1209,6 @@ var MastraPlugin = class {
1205
1209
  return augmentedOptions;
1206
1210
  }
1207
1211
  };
1208
- //#endregion
1209
1212
  export { MastraPlugin };
1210
1213
 
1211
1214
  //# sourceMappingURL=worker.js.map