@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/index.cjs +30 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -20
- package/dist/index.js.map +1 -1
- package/dist/{mastra-deployer-rZLKb1Em.js → mastra-deployer-BtoNM1bq.js} +2 -3
- package/dist/{mastra-deployer-rZLKb1Em.js.map → mastra-deployer-BtoNM1bq.js.map} +1 -1
- package/dist/{mastra-deployer-D6fHvmFM.cjs → mastra-deployer-CxXfbT3P.cjs} +2 -3
- package/dist/{mastra-deployer-D6fHvmFM.cjs.map → mastra-deployer-CxXfbT3P.cjs.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/{utils-D94W1i81.cjs → utils-BVE1AkTt.cjs} +2 -3
- package/dist/{utils-D94W1i81.cjs.map → utils-BVE1AkTt.cjs.map} +1 -1
- package/dist/{utils-B_iPTfDi.js → utils-R6cB86BM.js} +2 -3
- package/dist/{utils-B_iPTfDi.js.map → utils-R6cB86BM.js.map} +1 -1
- package/dist/worker.cjs +20 -18
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +19 -16
- package/dist/worker.js.map +1 -1
- package/package.json +15 -15
package/dist/worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as toWorkflowType } from "./utils-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
802
|
-
if (
|
|
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
|
|
829
|
-
if (
|
|
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
|
-
|
|
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-
|
|
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
|