@mastra/temporal 0.1.16-alpha.0 → 0.1.16-alpha.2
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 +18 -0
- package/dist/transforms/activities.d.ts.map +1 -1
- package/dist/transforms/shared.d.ts +3 -0
- package/dist/transforms/shared.d.ts.map +1 -1
- package/dist/transforms/workflows.d.ts.map +1 -1
- package/dist/worker.cjs +114 -11
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +114 -11
- package/dist/worker.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/temporal
|
|
2
2
|
|
|
3
|
+
## 0.1.16-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed Temporal bundles to detect steps created by factory functions while preserving the factory code in generated activity modules. ([#17999](https://github.com/mastra-ai/mastra/pull/17999))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`339c57c`](https://github.com/mastra-ai/mastra/commit/339c57c5b2c6dbe75a125e138228e0556528976f), [`1dd4117`](https://github.com/mastra-ai/mastra/commit/1dd4117dcbd8e031ede9f0489436bfbc6f0315b8), [`2b11d1f`](https://github.com/mastra-ai/mastra/commit/2b11d1f6ac7024c5dd2b2dd12a48a956ac9d63bd), [`49af8df`](https://github.com/mastra-ai/mastra/commit/49af8df589c4ff71a5015a4553b377b32704b691), [`30ce559`](https://github.com/mastra-ai/mastra/commit/30ce55902ecf819b8ab8697398dd68b108228063), [`c241b92`](https://github.com/mastra-ai/mastra/commit/c241b929dc8c8d6a7b7219c99ed13ac1f3124a77), [`7d6ff70`](https://github.com/mastra-ai/mastra/commit/7d6ff708727297a0526ca0e26e93eeb5bbaaa187)]:
|
|
10
|
+
- @mastra/core@1.44.0-alpha.2
|
|
11
|
+
- @mastra/deployer@1.44.0-alpha.2
|
|
12
|
+
|
|
13
|
+
## 0.1.16-alpha.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`b7dff0a`](https://github.com/mastra-ai/mastra/commit/b7dff0a3d1022eb6868f48dc40a2b1febd5c277f), [`02087e1`](https://github.com/mastra-ai/mastra/commit/02087e1fbc54aa07f3071f7a200df1bf5be601a8), [`ab975d4`](https://github.com/mastra-ai/mastra/commit/ab975d4dd9488752f05bda7afa03166d207e3e2a)]:
|
|
18
|
+
- @mastra/core@1.44.0-alpha.1
|
|
19
|
+
- @mastra/deployer@1.44.0-alpha.1
|
|
20
|
+
|
|
3
21
|
## 0.1.16-alpha.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/transforms/activities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/transforms/activities.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mCAAmC;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,uBAAuB,EAAE,CAAC;CAC7C;AAED,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAmE/G;AA6HD,wBAAsB,6BAA6B,CACjD,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,mCAAmC,CAAC,CAuW9C"}
|
|
@@ -16,6 +16,9 @@ export declare function hasCreateWorkflowCall(node: t.Node): boolean;
|
|
|
16
16
|
export declare function getStepNameFromCall(node: t.CallExpression): string | null;
|
|
17
17
|
export declare function createExportedStepStatement(name: string, initializer: t.Expression): t.ExportNamedDeclaration;
|
|
18
18
|
export declare function collectInlineCreateSteps(node: t.Node, seenNames: Set<string>, statements: t.Statement[], onStep?: (exportName: string, call: t.CallExpression) => void): void;
|
|
19
|
+
export declare function getReturnedCreateStepCall(node: t.Node | null | undefined): t.CallExpression | null;
|
|
20
|
+
export declare function collectCreateStepFactoryBindings(program: t.Program): Map<string, t.CallExpression>;
|
|
21
|
+
export declare function getCreateStepCallFromExpression(node: t.Node | null | undefined, factoryBindings: Map<string, t.CallExpression>): t.CallExpression | null;
|
|
19
22
|
export declare function getCreateStepId(node: t.Node | null | undefined): string | null;
|
|
20
23
|
export declare function shouldCountIdentifierAsReference(parent: t.Node | null, key: string | null): boolean;
|
|
21
24
|
export declare function collectRuntimeReferencedIdentifiers(node: t.Node): Set<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/transforms/shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,eAAO,MAAM,aAAa,8JAShB,CAAC;AACX,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,CAUzE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAErE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,eAAO,MAAM,uBAAuB,aAA2D,CAAC;AAEhG,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,CAAC,CAAC,iBAAiB,GAAG,GAAG,CAAC,MAAM,CAAC,CAgBhF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CA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AAgB,+BAA+B,CAC7C,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,SAAS,EAC/B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,cAAc,CAAC,GAC7C,CAAC,CAAC,cAAc,GAAG,IAAI,CAqBzB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAwB9E;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CA+DnG;AAED,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAsC7E;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,SAAS,EAAE,CA4IpF"}
|
|
@@ -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":"AAqZA,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;AAiUD;;;;;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,CAwCjC"}
|
package/dist/worker.cjs
CHANGED
|
@@ -172,6 +172,70 @@ function collectInlineCreateSteps(node, seenNames, statements, onStep) {
|
|
|
172
172
|
return false;
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
+
function getReturnedCreateStepCall(node) {
|
|
176
|
+
if (!node) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
if (t3__namespace.isArrowFunctionExpression(node) && !t3__namespace.isBlockStatement(node.body)) {
|
|
180
|
+
return t3__namespace.isCallExpression(node.body) && isIdentifierNamed(node.body.callee, "createStep") ? node.body : null;
|
|
181
|
+
}
|
|
182
|
+
if (!t3__namespace.isFunctionDeclaration(node) && !t3__namespace.isFunctionExpression(node) && !t3__namespace.isArrowFunctionExpression(node)) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
if (!t3__namespace.isBlockStatement(node.body)) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
for (const statement of node.body.body) {
|
|
189
|
+
if (t3__namespace.isReturnStatement(statement) && t3__namespace.isCallExpression(statement.argument) && isIdentifierNamed(statement.argument.callee, "createStep")) {
|
|
190
|
+
return statement.argument;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
function collectCreateStepFactoryBindings(program3) {
|
|
196
|
+
const factories = /* @__PURE__ */ new Map();
|
|
197
|
+
for (const statement of program3.body) {
|
|
198
|
+
const declaration = t3__namespace.isExportNamedDeclaration(statement) ? statement.declaration : statement;
|
|
199
|
+
if (t3__namespace.isFunctionDeclaration(declaration) && declaration.id) {
|
|
200
|
+
const createStepCall = getReturnedCreateStepCall(declaration);
|
|
201
|
+
if (createStepCall) {
|
|
202
|
+
factories.set(declaration.id.name, createStepCall);
|
|
203
|
+
}
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (!t3__namespace.isVariableDeclaration(declaration)) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
for (const declarator of declaration.declarations) {
|
|
210
|
+
if (!t3__namespace.isIdentifier(declarator.id) || !declarator.init) {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
const createStepCall = getReturnedCreateStepCall(declarator.init);
|
|
214
|
+
if (createStepCall) {
|
|
215
|
+
factories.set(declarator.id.name, createStepCall);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return factories;
|
|
220
|
+
}
|
|
221
|
+
function getCreateStepCallFromExpression(node, factoryBindings) {
|
|
222
|
+
if (!node) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
if (t3__namespace.isCallExpression(node)) {
|
|
226
|
+
if (isIdentifierNamed(node.callee, "createStep")) {
|
|
227
|
+
return node;
|
|
228
|
+
}
|
|
229
|
+
if (t3__namespace.isIdentifier(node.callee)) {
|
|
230
|
+
return factoryBindings.get(node.callee.name) ?? null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const returnedCreateStepCall = getReturnedCreateStepCall(node);
|
|
234
|
+
if (returnedCreateStepCall) {
|
|
235
|
+
return returnedCreateStepCall;
|
|
236
|
+
}
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
175
239
|
function getCreateStepId(node) {
|
|
176
240
|
if (!node || !isCreateStepCall(node)) {
|
|
177
241
|
return null;
|
|
@@ -496,6 +560,7 @@ async function buildTemporalActivitiesModule(entryFile, outputDirectory, outputF
|
|
|
496
560
|
const seenNames = /* @__PURE__ */ new Set();
|
|
497
561
|
const strippedNames = /* @__PURE__ */ new Set();
|
|
498
562
|
const workflowBindingNames = collectWorkflowBindingNames(ast);
|
|
563
|
+
const stepFactoryBindings = collectCreateStepFactoryBindings(ast.program);
|
|
499
564
|
const sourceFilePath = id;
|
|
500
565
|
const hasMastraBinding = hasLocalMastraBinding(ast);
|
|
501
566
|
let helperInserted = false;
|
|
@@ -561,11 +626,23 @@ async function buildTemporalActivitiesModule(entryFile, outputDirectory, outputF
|
|
|
561
626
|
declarations.push(createPreservedDeclaration(declaration, strippedNames));
|
|
562
627
|
continue;
|
|
563
628
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
629
|
+
const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);
|
|
630
|
+
if (createStepCall) {
|
|
631
|
+
const isFactoryCall = t3__namespace.isCallExpression(declaration.init) && t3__namespace.isIdentifier(declaration.init.callee) && stepFactoryBindings.has(declaration.init.callee.name);
|
|
632
|
+
if (isFactoryCall) {
|
|
633
|
+
seenNames.add(declaration.id.name);
|
|
634
|
+
addActivityBinding(declaration.id.name, createStepCall);
|
|
635
|
+
statements.push(
|
|
636
|
+
t3__namespace.exportNamedDeclaration(t3__namespace.variableDeclaration(statement.kind, [t3__namespace.cloneNode(declaration, true)]))
|
|
637
|
+
);
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
if (isCreateStepCall(declaration.init)) {
|
|
641
|
+
seenNames.add(declaration.id.name);
|
|
642
|
+
addActivityBinding(declaration.id.name, createStepCall);
|
|
643
|
+
statements.push(createExportedStepStatement(declaration.id.name, createStepCall));
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
569
646
|
}
|
|
570
647
|
if (hasCreateWorkflowCall(declaration.init)) {
|
|
571
648
|
workflowBindingNames.add(declaration.id.name);
|
|
@@ -602,11 +679,21 @@ async function buildTemporalActivitiesModule(entryFile, outputDirectory, outputF
|
|
|
602
679
|
exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));
|
|
603
680
|
continue;
|
|
604
681
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
682
|
+
const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);
|
|
683
|
+
if (createStepCall) {
|
|
684
|
+
const isFactoryCall = t3__namespace.isCallExpression(declaration.init) && t3__namespace.isIdentifier(declaration.init.callee) && stepFactoryBindings.has(declaration.init.callee.name);
|
|
685
|
+
if (isFactoryCall) {
|
|
686
|
+
seenNames.add(declaration.id.name);
|
|
687
|
+
addActivityBinding(declaration.id.name, createStepCall);
|
|
688
|
+
exportedDeclarations.push(createPreservedDeclaration(declaration, strippedNames));
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
if (isCreateStepCall(declaration.init)) {
|
|
692
|
+
seenNames.add(declaration.id.name);
|
|
693
|
+
addActivityBinding(declaration.id.name, createStepCall);
|
|
694
|
+
statements.push(createExportedStepStatement(declaration.id.name, createStepCall));
|
|
695
|
+
continue;
|
|
696
|
+
}
|
|
610
697
|
}
|
|
611
698
|
if (hasCreateWorkflowCall(declaration.init)) {
|
|
612
699
|
workflowBindingNames.add(declaration.id.name);
|
|
@@ -649,6 +736,11 @@ async function buildTemporalActivitiesModule(entryFile, outputDirectory, outputF
|
|
|
649
736
|
continue;
|
|
650
737
|
}
|
|
651
738
|
if (t3__namespace.isExportNamedDeclaration(statement)) {
|
|
739
|
+
if (t3__namespace.isFunctionDeclaration(statement.declaration) || t3__namespace.isClassDeclaration(statement.declaration) || t3__namespace.isTSTypeAliasDeclaration(statement.declaration) || t3__namespace.isTSInterfaceDeclaration(statement.declaration) || t3__namespace.isTSEnumDeclaration(statement.declaration)) {
|
|
740
|
+
ensureHelperInserted();
|
|
741
|
+
statements.push(statement);
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
652
744
|
if (statement.declaration == null && statement.source == null) {
|
|
653
745
|
const retainedSpecifiers = statement.specifiers.filter(
|
|
654
746
|
(specifier) => t3__namespace.isExportSpecifier(specifier) && t3__namespace.isIdentifier(specifier.local) && specifier.local.name !== "mastra" && !workflowBindingNames.has(specifier.local.name) && !seenNames.has(specifier.local.name)
|
|
@@ -773,6 +865,13 @@ function parseWorkflowChain(node) {
|
|
|
773
865
|
}
|
|
774
866
|
function collectStepBindings(program3) {
|
|
775
867
|
const stepBindings = /* @__PURE__ */ new Map();
|
|
868
|
+
const stepFactoryBindings = collectCreateStepFactoryBindings(program3);
|
|
869
|
+
for (const [factoryName, createStepCall] of stepFactoryBindings) {
|
|
870
|
+
const stepId = getCreateStepId(createStepCall);
|
|
871
|
+
if (stepId) {
|
|
872
|
+
stepBindings.set(factoryName, stepId);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
776
875
|
for (const statement of program3.body) {
|
|
777
876
|
if (!t3__namespace.isVariableDeclaration(statement) && !(t3__namespace.isExportNamedDeclaration(statement) && t3__namespace.isVariableDeclaration(statement.declaration))) {
|
|
778
877
|
continue;
|
|
@@ -782,7 +881,8 @@ function collectStepBindings(program3) {
|
|
|
782
881
|
if (!t3__namespace.isIdentifier(declaration.id) || !declaration.init) {
|
|
783
882
|
continue;
|
|
784
883
|
}
|
|
785
|
-
const
|
|
884
|
+
const createStepCall = getCreateStepCallFromExpression(declaration.init, stepFactoryBindings);
|
|
885
|
+
const stepId = getCreateStepId(createStepCall);
|
|
786
886
|
if (stepId) {
|
|
787
887
|
stepBindings.set(declaration.id.name, stepId);
|
|
788
888
|
}
|
|
@@ -822,6 +922,9 @@ function getWorkflowStepName(node, stepBindings) {
|
|
|
822
922
|
if (t3__namespace.isStringLiteral(node)) {
|
|
823
923
|
return node.value;
|
|
824
924
|
}
|
|
925
|
+
if (t3__namespace.isCallExpression(node) && t3__namespace.isIdentifier(node.callee)) {
|
|
926
|
+
return stepBindings.get(node.callee.name) ?? getCreateStepId(node);
|
|
927
|
+
}
|
|
825
928
|
return getCreateStepId(node);
|
|
826
929
|
}
|
|
827
930
|
function rewriteChainMethod(method, filePath, workflowName, stepBindings, workflowBindings) {
|