@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.
@@ -1,9 +1,8 @@
1
- //#region src/utils.ts
1
+ // src/utils.ts
2
2
  function toWorkflowType(id) {
3
3
  const camelCased = id.replace(/[-_]+([a-zA-Z0-9])/g, (_, char) => char.toUpperCase());
4
4
  return camelCased.endsWith("Workflow") ? camelCased : `${camelCased}Workflow`;
5
5
  }
6
- //#endregion
7
6
  Object.defineProperty(exports, "toWorkflowType", {
8
7
  enumerable: true,
9
8
  get: function() {
@@ -11,4 +10,4 @@ Object.defineProperty(exports, "toWorkflowType", {
11
10
  }
12
11
  });
13
12
 
14
- //# sourceMappingURL=utils-D94W1i81.cjs.map
13
+ //# sourceMappingURL=utils-BVE1AkTt.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils-D94W1i81.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export function toWorkflowType(id: string) {\n const camelCased = id.replace(/[-_]+([a-zA-Z0-9])/g, (_, char: string) => char.toUpperCase());\n return camelCased.endsWith('Workflow') ? camelCased : `${camelCased}Workflow`;\n}\n"],"mappings":";AAAA,SAAgB,eAAe,IAAY;CACzC,MAAM,aAAa,GAAG,QAAQ,wBAAwB,GAAG,SAAiB,KAAK,YAAY,CAAC;CAC5F,OAAO,WAAW,SAAS,UAAU,IAAI,aAAa,GAAG,WAAW;AACtE"}
1
+ {"version":3,"file":"utils-BVE1AkTt.cjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export function toWorkflowType(id: string) {\n const camelCased = id.replace(/[-_]+([a-zA-Z0-9])/g, (_, char: string) => char.toUpperCase());\n return camelCased.endsWith('Workflow') ? camelCased : `${camelCased}Workflow`;\n}\n"],"mappings":";AAAA,SAAgB,eAAe,IAAY;CACzC,MAAM,aAAa,GAAG,QAAQ,wBAAwB,GAAG,SAAiB,KAAK,YAAY,CAAC;CAC5F,OAAO,WAAW,SAAS,UAAU,IAAI,aAAa,GAAG,WAAW;AACtE"}
@@ -1,9 +1,8 @@
1
- //#region src/utils.ts
1
+ // src/utils.ts
2
2
  function toWorkflowType(id) {
3
3
  const camelCased = id.replace(/[-_]+([a-zA-Z0-9])/g, (_, char) => char.toUpperCase());
4
4
  return camelCased.endsWith("Workflow") ? camelCased : `${camelCased}Workflow`;
5
5
  }
6
- //#endregion
7
6
  export { toWorkflowType as t };
8
7
 
9
- //# sourceMappingURL=utils-B_iPTfDi.js.map
8
+ //# sourceMappingURL=utils-R6cB86BM.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils-B_iPTfDi.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export function toWorkflowType(id: string) {\n const camelCased = id.replace(/[-_]+([a-zA-Z0-9])/g, (_, char: string) => char.toUpperCase());\n return camelCased.endsWith('Workflow') ? camelCased : `${camelCased}Workflow`;\n}\n"],"mappings":";AAAA,SAAgB,eAAe,IAAY;CACzC,MAAM,aAAa,GAAG,QAAQ,wBAAwB,GAAG,SAAiB,KAAK,YAAY,CAAC;CAC5F,OAAO,WAAW,SAAS,UAAU,IAAI,aAAa,GAAG,WAAW;AACtE"}
1
+ {"version":3,"file":"utils-R6cB86BM.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export function toWorkflowType(id: string) {\n const camelCased = id.replace(/[-_]+([a-zA-Z0-9])/g, (_, char: string) => char.toUpperCase());\n return camelCased.endsWith('Workflow') ? camelCased : `${camelCased}Workflow`;\n}\n"],"mappings":";AAAA,SAAgB,eAAe,IAAY;CACzC,MAAM,aAAa,GAAG,QAAQ,wBAAwB,GAAG,SAAiB,KAAK,YAAY,CAAC;CAC5F,OAAO,WAAW,SAAS,UAAU,IAAI,aAAa,GAAG,WAAW;AACtE"}
package/dist/worker.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region \0rolldown/runtime.js
2
+ // \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -20,8 +20,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
- //#endregion
24
- const require_utils = require("./utils-D94W1i81.cjs");
23
+ const require_utils = require("./utils-BVE1AkTt.cjs");
25
24
  let fs = require("fs");
26
25
  let fs_promises = require("fs/promises");
27
26
  let path = require("path");
@@ -33,7 +32,7 @@ let _babel_types = require("@babel/types");
33
32
  _babel_types = __toESM(_babel_types, 1);
34
33
  let rollup = require("rollup");
35
34
  let module$1 = require("module");
36
- //#region src/transforms/shared.ts
35
+ // src/transforms/shared.ts
37
36
  const parserPlugins = [
38
37
  "typescript",
39
38
  "jsx",
@@ -290,8 +289,7 @@ function pruneUnusedTopLevelBindings(statements) {
290
289
  });
291
290
  return prunedStatements;
292
291
  }
293
- //#endregion
294
- //#region src/transforms/activities.ts
292
+ // src/transforms/activities.ts
295
293
  function normalizeImportPath(importPath, extension) {
296
294
  const normalizedPath = importPath.split(path.default.sep).join("/");
297
295
  const pathWithExtension = extension === ".mjs" || extension === ".cjs" ? normalizedPath : normalizedPath.replace(/\.[cm]?[jt]sx?$/, "");
@@ -674,8 +672,7 @@ async function buildTemporalActivitiesModule(entryFile, outputDirectory, outputF
674
672
  await bundle.close();
675
673
  }
676
674
  }
677
- //#endregion
678
- //#region src/transforms/workflows.ts
675
+ // src/transforms/workflows.ts
679
676
  /**
680
677
  * Temporal workflow types must be static so the loader can deterministically map
681
678
  * a source workflow to the runtime export name used by the worker.
@@ -791,7 +788,10 @@ function collectWorkflowBindings(program, filePath) {
791
788
  const [workflowConfig] = workflowChain?.createWorkflowCall.arguments ?? [];
792
789
  if (!workflowChain || !workflowConfig || !_babel_types.isObjectExpression(workflowConfig)) continue;
793
790
  const { workflowId } = getWorkflowIdMetadata(workflowConfig, declaration.id.name, filePath);
794
- workflowBindings.set(declaration.id.name, require_utils.toWorkflowType(workflowId));
791
+ workflowBindings.set(declaration.id.name, {
792
+ workflowType: require_utils.toWorkflowType(workflowId),
793
+ workflowId
794
+ });
795
795
  }
796
796
  }
797
797
  return workflowBindings;
@@ -823,8 +823,8 @@ function rewriteChainMethod(method, filePath, workflowName, workflowId, mappingO
823
823
  case "then": {
824
824
  const arg = argNode(0);
825
825
  if (_babel_types.isIdentifier(arg)) {
826
- const workflowType = workflowBindings.get(arg.name);
827
- if (workflowType) return rewritten([_babel_types.stringLiteral(workflowType)], "thenWorkflow");
826
+ const binding = workflowBindings.get(arg.name);
827
+ if (binding) return rewritten([_babel_types.stringLiteral(binding.workflowType), _babel_types.stringLiteral(binding.workflowId)], "thenWorkflow");
828
828
  }
829
829
  const name = getWorkflowStepName(arg, stepBindings);
830
830
  if (!name) throw new Error(`.then() in ${workflowName} (${filePath}) must take a step or workflow identifier (inline createStep calls are not supported)`);
@@ -850,8 +850,12 @@ function rewriteChainMethod(method, filePath, workflowName, workflowId, mappingO
850
850
  if (!_babel_types.isArrayExpression(arg)) throw new Error(`.parallel() in ${workflowName} (${filePath}) requires an array literal argument`);
851
851
  const entries = arg.elements.map((element) => {
852
852
  if (_babel_types.isIdentifier(element)) {
853
- const workflowType = workflowBindings.get(element.name);
854
- if (workflowType) return _babel_types.objectExpression([_babel_types.objectProperty(_babel_types.identifier("type"), _babel_types.stringLiteral("childWorkflow")), _babel_types.objectProperty(_babel_types.identifier("workflowType"), _babel_types.stringLiteral(workflowType))]);
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
+ ]);
855
859
  }
856
860
  const stepId = getWorkflowStepName(element, stepBindings);
857
861
  if (!stepId) throw new Error(`Unable to determine step names inside .parallel() in ${workflowName} (${filePath})`);
@@ -1004,7 +1008,7 @@ function rewriteWorkflowImportDeclaration(statement, state) {
1004
1008
  }
1005
1009
  function getNormalizedWorkflowBindingName(name, state) {
1006
1010
  if (!state.workflowNames.has(name)) return null;
1007
- return state.workflowBindings.get(name) ?? name;
1011
+ return state.workflowBindings.get(name)?.workflowType ?? name;
1008
1012
  }
1009
1013
  function rewriteWorkflowNamedExport(statement, state) {
1010
1014
  if (statement.source != null) return;
@@ -1126,8 +1130,7 @@ async function buildTemporalWorkflowModule(entryFile, outputDirectory, outputFil
1126
1130
  await bundle.close();
1127
1131
  }
1128
1132
  }
1129
- //#endregion
1130
- //#region src/plugin.ts
1133
+ // src/plugin.ts
1131
1134
  const CACHE_PATH = "node_modules/.mastra";
1132
1135
  const WORKFLOW_FILE_NAME = "workflow.mjs";
1133
1136
  const ACTIVITIES_FILE_NAME = "activities.mjs";
@@ -1153,7 +1156,7 @@ var MastraPlugin = class {
1153
1156
  this.projectRoot = projectRoot;
1154
1157
  }
1155
1158
  async #bundleMastra(entryFile, projectRoot, outputDirectory) {
1156
- const { BuildBundler } = await Promise.resolve().then(() => require("./mastra-deployer-D6fHvmFM.cjs"));
1159
+ const { BuildBundler } = await Promise.resolve().then(() => require("./mastra-deployer-CxXfbT3P.cjs"));
1157
1160
  const normalizedEntryFile = entryFile.startsWith("file:/") ? (0, url.fileURLToPath)(entryFile) : entryFile;
1158
1161
  const mastraBundler = new BuildBundler();
1159
1162
  await mastraBundler.prepare(outputDirectory);
@@ -1230,7 +1233,6 @@ var MastraPlugin = class {
1230
1233
  return augmentedOptions;
1231
1234
  }
1232
1235
  };
1233
- //#endregion
1234
1236
  exports.MastraPlugin = MastraPlugin;
1235
1237
 
1236
1238
  //# sourceMappingURL=worker.cjs.map