@mastra/temporal 0.2.7-alpha.6 → 0.2.7-alpha.8
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 +34 -0
- package/dist/temporal-workflow-runtime.mjs +10 -8
- package/dist/transforms/temporal-workflow-runtime.d.mts +2 -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 +34 -4
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +34 -4
- package/dist/worker.js.map +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @mastra/temporal
|
|
2
2
|
|
|
3
|
+
## 0.2.7-alpha.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dependencies updates: ([#19391](https://github.com/mastra-ai/mastra/pull/19391))
|
|
8
|
+
- Updated dependency [`@temporalio/activity@^1.20.2` ↗︎](https://www.npmjs.com/package/@temporalio/activity/v/1.20.2) (from `^1.17.2`, in `dependencies`)
|
|
9
|
+
- Updated dependency [`@temporalio/client@^1.20.2` ↗︎](https://www.npmjs.com/package/@temporalio/client/v/1.20.2) (from `^1.17.2`, in `dependencies`)
|
|
10
|
+
- Updated dependency [`@temporalio/plugin@^1.20.2` ↗︎](https://www.npmjs.com/package/@temporalio/plugin/v/1.20.2) (from `^1.17.2`, in `dependencies`)
|
|
11
|
+
- Updated dependency [`@temporalio/worker@^1.20.2` ↗︎](https://www.npmjs.com/package/@temporalio/worker/v/1.20.2) (from `^1.17.2`, in `dependencies`)
|
|
12
|
+
- Updated dependency [`@temporalio/workflow@^1.20.2` ↗︎](https://www.npmjs.com/package/@temporalio/workflow/v/1.20.2) (from `^1.17.2`, in `dependencies`)
|
|
13
|
+
- Updated dependencies [[`bd6d240`](https://github.com/mastra-ai/mastra/commit/bd6d2402db93dddaef0721667e7e8a030e7c6e16), [`0111486`](https://github.com/mastra-ai/mastra/commit/01114867612593eef5cfa2fda6a1194dfedda841), [`96a3749`](https://github.com/mastra-ai/mastra/commit/96a37492235f5b8076b3e3177d83ed5a5e44a640), [`3e26c87`](https://github.com/mastra-ai/mastra/commit/3e26c87de0c5bc2583b795ce6ca5889b6b161acb), [`a5008f2`](https://github.com/mastra-ai/mastra/commit/a5008f22ae710ad9402ea9f2547d8c02f74d384b)]:
|
|
14
|
+
- @mastra/core@1.51.0-alpha.8
|
|
15
|
+
- @mastra/deployer@1.51.0-alpha.8
|
|
16
|
+
|
|
17
|
+
## 0.2.7-alpha.7
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Fixed Temporal workflows to apply the configured activity start-to-close timeout in generated worker bundles. ([#19347](https://github.com/mastra-ai/mastra/pull/19347))
|
|
22
|
+
|
|
23
|
+
- Added support for `foreach` concurrency resolver functions in the Temporal workflow runtime, matching the new `@mastra/core` behavior: ([#19329](https://github.com/mastra-ai/mastra/pull/19329))
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
workflow
|
|
27
|
+
.foreach(step, {
|
|
28
|
+
concurrency: ({ inputData, getInitData }) => (getInitData().fast ? 10 : 1),
|
|
29
|
+
})
|
|
30
|
+
.commit();
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [[`25e7c12`](https://github.com/mastra-ai/mastra/commit/25e7c126a770069ae7fb7ecf1d2adb40e017b009), [`1ce5121`](https://github.com/mastra-ai/mastra/commit/1ce512155d122bb21f47d98383e82ffbf84b39e8), [`3cfc47a`](https://github.com/mastra-ai/mastra/commit/3cfc47a6b89940aadd0f46fb01ae9624a73a865d), [`2bb7817`](https://github.com/mastra-ai/mastra/commit/2bb78176112fde628483de2830528f7eee911e56), [`51d9870`](https://github.com/mastra-ai/mastra/commit/51d987032c689c2855374d0f244f5d654da809d1), [`5cab274`](https://github.com/mastra-ai/mastra/commit/5cab2744250e22d12fefa7b32637dce224233cee), [`7fa27d3`](https://github.com/mastra-ai/mastra/commit/7fa27d3b6f5ed68cd34e454a4d3ad9c482a0cfbc), [`a58dcbb`](https://github.com/mastra-ai/mastra/commit/a58dcbb546d7e1d65ebdc1f39e55f0908fcd9391), [`153bd3b`](https://github.com/mastra-ai/mastra/commit/153bd3b396bdfed6b74cf43de12db8fd2d83c04a), [`07bb863`](https://github.com/mastra-ai/mastra/commit/07bb8631919c6f7cf377dccd45b096e0f17fbed0), [`8a586ec`](https://github.com/mastra-ai/mastra/commit/8a586eca9a4914f31dff6140d0d45ac375b00669), [`3927473`](https://github.com/mastra-ai/mastra/commit/392747323ddb10c643d12be7b9ae913159dfaeed), [`dce50dc`](https://github.com/mastra-ai/mastra/commit/dce50dc9a1c1fcd0f427bb5f6250ec74910cb04b), [`634caff`](https://github.com/mastra-ai/mastra/commit/634caff29a9200ad058b67d53f96d9e5832fb8a2)]:
|
|
34
|
+
- @mastra/core@1.51.0-alpha.7
|
|
35
|
+
- @mastra/deployer@1.51.0-alpha.7
|
|
36
|
+
|
|
3
37
|
## 0.2.7-alpha.6
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
|
@@ -10,6 +10,7 @@ export class TemporalExecutionEngine {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async execute(params) {
|
|
13
|
+
this.initData = params.input;
|
|
13
14
|
let result = params.input;
|
|
14
15
|
const stepResults = {};
|
|
15
16
|
|
|
@@ -117,9 +118,14 @@ export class TemporalExecutionEngine {
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
case 'foreach': {
|
|
120
|
-
log.info('foreach', { step: entry.step.id, concurrency: entry.opts.concurrency });
|
|
121
121
|
const items = Array.isArray(inputData) ? inputData : [];
|
|
122
|
-
|
|
122
|
+
// Concurrency may be a resolver function evaluated per run.
|
|
123
|
+
const configured =
|
|
124
|
+
typeof entry.opts.concurrency === 'function'
|
|
125
|
+
? entry.opts.concurrency({ inputData, getInitData: () => this.initData })
|
|
126
|
+
: (entry.opts.concurrency ?? 1);
|
|
127
|
+
const concurrency = Number.isFinite(configured) ? Math.max(1, Math.floor(configured)) : 1;
|
|
128
|
+
log.info('foreach', { step: entry.step.id, concurrency });
|
|
123
129
|
const results = new Array(items.length);
|
|
124
130
|
let index = 0;
|
|
125
131
|
const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
|
|
@@ -143,17 +149,13 @@ export class TemporalExecutionEngine {
|
|
|
143
149
|
}
|
|
144
150
|
}
|
|
145
151
|
|
|
146
|
-
export function createWorkflow(workflowId) {
|
|
152
|
+
export function createWorkflow(workflowId, options) {
|
|
147
153
|
const stepFlow = [];
|
|
148
154
|
let autoId = 0;
|
|
149
155
|
const nextId = prefix => `${prefix}_${autoId++}`;
|
|
150
156
|
|
|
151
157
|
const workflow = async startArgs => {
|
|
152
|
-
const engine = new TemporalExecutionEngine({
|
|
153
|
-
options: {
|
|
154
|
-
startToCloseTimeout: '1 minute',
|
|
155
|
-
},
|
|
156
|
-
});
|
|
158
|
+
const engine = new TemporalExecutionEngine({ options });
|
|
157
159
|
|
|
158
160
|
return engine.execute({
|
|
159
161
|
workflowId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function createWorkflow(workflowId: any): ((startArgs: any) => Promise<{
|
|
1
|
+
export function createWorkflow(workflowId: any, options: any): ((startArgs: any) => Promise<{
|
|
2
2
|
status: string;
|
|
3
3
|
input: any;
|
|
4
4
|
result: any;
|
|
@@ -87,6 +87,7 @@ export class TemporalExecutionEngine {
|
|
|
87
87
|
state: any;
|
|
88
88
|
steps: {};
|
|
89
89
|
}>;
|
|
90
|
+
initData: any;
|
|
90
91
|
executeEntry(entry: any, inputData: any, stepResults: any): Promise<any>;
|
|
91
92
|
}
|
|
92
93
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"temporal-workflow-runtime.d.mts","sourceRoot":"","sources":["../../src/transforms/temporal-workflow-runtime.mjs"],"names":[],"mappings":"AAuJA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiJC;AAtSD;IAIE,yBAGC;IAND,yBAAoB;IACpB,sHAAe;IAOf;;;;;;OAgBC;IAfC,cAA4B;IAiB9B,yEAuHC;CACF"}
|
|
@@ -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":"AAgcA,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;AAoUD;;;;;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
|
@@ -842,6 +842,30 @@ function createTemporalWorkflowHelperStatements() {
|
|
|
842
842
|
return [statement];
|
|
843
843
|
});
|
|
844
844
|
}
|
|
845
|
+
function getTemporalWorkflowRuntimeOptions(program3) {
|
|
846
|
+
for (const statement of program3.body) {
|
|
847
|
+
const declarationStatement = t3__namespace.isVariableDeclaration(statement) ? statement : t3__namespace.isExportNamedDeclaration(statement) && t3__namespace.isVariableDeclaration(statement.declaration) ? statement.declaration : null;
|
|
848
|
+
if (!declarationStatement) {
|
|
849
|
+
continue;
|
|
850
|
+
}
|
|
851
|
+
for (const declaration of declarationStatement.declarations) {
|
|
852
|
+
if (!isWorkflowHelperDestructure(declaration) || !t3__namespace.isCallExpression(declaration.init)) {
|
|
853
|
+
continue;
|
|
854
|
+
}
|
|
855
|
+
const [temporalParams] = declaration.init.arguments;
|
|
856
|
+
if (!temporalParams || !t3__namespace.isObjectExpression(temporalParams)) {
|
|
857
|
+
continue;
|
|
858
|
+
}
|
|
859
|
+
for (const property of temporalParams.properties) {
|
|
860
|
+
if (t3__namespace.isObjectProperty(property) && getObjectPropertyName(property) === "startToCloseTimeout" && t3__namespace.isExpression(property.value)) {
|
|
861
|
+
return t3__namespace.objectExpression([
|
|
862
|
+
t3__namespace.objectProperty(t3__namespace.identifier("startToCloseTimeout"), t3__namespace.cloneNode(property.value, true))
|
|
863
|
+
]);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
845
869
|
function parseWorkflowChain(node) {
|
|
846
870
|
const methods = [];
|
|
847
871
|
let current = node;
|
|
@@ -1037,8 +1061,12 @@ function rewriteChainMethod(method, filePath, workflowName, stepBindings, workfl
|
|
|
1037
1061
|
function getExportedName(node) {
|
|
1038
1062
|
return t3__namespace.isIdentifier(node) ? node.name : node.value;
|
|
1039
1063
|
}
|
|
1040
|
-
function createTemporalWorkflowStatements(exportName, workflowId, methods, filePath, includeCommit, stepBindings, workflowBindings) {
|
|
1041
|
-
|
|
1064
|
+
function createTemporalWorkflowStatements(exportName, workflowId, methods, filePath, includeCommit, stepBindings, workflowBindings, runtimeOptions) {
|
|
1065
|
+
const createWorkflowArgs = [t3__namespace.cloneNode(workflowId, true)];
|
|
1066
|
+
if (runtimeOptions) {
|
|
1067
|
+
createWorkflowArgs.push(t3__namespace.cloneNode(runtimeOptions, true));
|
|
1068
|
+
}
|
|
1069
|
+
let expression = t3__namespace.callExpression(t3__namespace.identifier("createWorkflow"), createWorkflowArgs);
|
|
1042
1070
|
for (const method of methods) {
|
|
1043
1071
|
const rewrittenMethod = rewriteChainMethod(method, filePath, exportName, stepBindings, workflowBindings);
|
|
1044
1072
|
expression = t3__namespace.callExpression(
|
|
@@ -1103,7 +1131,8 @@ function createWorkflowTransformState(program3, filePath) {
|
|
|
1103
1131
|
strippedNames: /* @__PURE__ */ new Set(),
|
|
1104
1132
|
stepBindings: collectStepBindings(program3),
|
|
1105
1133
|
workflowBindings: collectWorkflowBindings(program3, filePath),
|
|
1106
|
-
workflowExports: []
|
|
1134
|
+
workflowExports: [],
|
|
1135
|
+
runtimeOptions: getTemporalWorkflowRuntimeOptions(program3)
|
|
1107
1136
|
};
|
|
1108
1137
|
}
|
|
1109
1138
|
function collectWorkflowDeclarationMetadata(statement, state) {
|
|
@@ -1237,7 +1266,8 @@ function rewriteWorkflowVariableDeclaration(statement, filePath, state) {
|
|
|
1237
1266
|
filePath,
|
|
1238
1267
|
state.committedWorkflowNames.has(declaration.id.name),
|
|
1239
1268
|
state.stepBindings,
|
|
1240
|
-
state.workflowBindings
|
|
1269
|
+
state.workflowBindings,
|
|
1270
|
+
state.runtimeOptions
|
|
1241
1271
|
)
|
|
1242
1272
|
);
|
|
1243
1273
|
}
|