@vertesia/workflow 1.0.0-dev.20260225.024852Z → 1.0.0-dev.20260227.112605Z

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.
Files changed (33) hide show
  1. package/lib/cjs/activities/chunkDocument.js +30 -4
  2. package/lib/cjs/activities/chunkDocument.js.map +1 -1
  3. package/lib/cjs/activities/executeInteraction.js +32 -5
  4. package/lib/cjs/activities/executeInteraction.js.map +1 -1
  5. package/lib/cjs/activities/generateDocumentProperties.js +30 -6
  6. package/lib/cjs/activities/generateDocumentProperties.js.map +1 -1
  7. package/lib/cjs/activities/generateOrAssignContentType.js +59 -11
  8. package/lib/cjs/activities/generateOrAssignContentType.js.map +1 -1
  9. package/lib/esm/activities/chunkDocument.js +31 -5
  10. package/lib/esm/activities/chunkDocument.js.map +1 -1
  11. package/lib/esm/activities/executeInteraction.js +31 -4
  12. package/lib/esm/activities/executeInteraction.js.map +1 -1
  13. package/lib/esm/activities/generateDocumentProperties.js +31 -7
  14. package/lib/esm/activities/generateDocumentProperties.js.map +1 -1
  15. package/lib/esm/activities/generateOrAssignContentType.js +60 -12
  16. package/lib/esm/activities/generateOrAssignContentType.js.map +1 -1
  17. package/lib/tsconfig.tsbuildinfo +1 -1
  18. package/lib/types/activities/chunkDocument.d.ts.map +1 -1
  19. package/lib/types/activities/executeInteraction.d.ts.map +1 -1
  20. package/lib/types/activities/generateDocumentProperties.d.ts.map +1 -1
  21. package/lib/types/activities/generateOrAssignContentType.d.ts.map +1 -1
  22. package/lib/workflows-bundle.js +241 -4
  23. package/package.json +5 -5
  24. package/src/activities/chunkDocument.ts +32 -5
  25. package/src/activities/executeInteraction.ts +37 -5
  26. package/src/activities/generateDocumentProperties.ts +38 -13
  27. package/src/activities/generateOrAssignContentType.ts +72 -22
  28. package/src/conversion/mutool.test.ts +1 -4
  29. package/src/conversion/pandoc.test.ts +1 -4
  30. package/src/dsl/workflow-exec-child.test.ts +12 -8
  31. package/src/dsl/workflow-fetch.test.ts +9 -6
  32. package/src/dsl/workflow-import.test.ts +10 -7
  33. package/src/dsl/workflow.test.ts +11 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertesia/workflow",
3
- "version": "1.0.0-dev.20260225.024852Z",
3
+ "version": "1.0.0-dev.20260227.112605Z",
4
4
  "type": "module",
5
5
  "description": "Vertesia workflow DSL",
6
6
  "main": "./lib/esm/index.js",
@@ -43,11 +43,11 @@
43
43
  "tmp": "^0.2.4",
44
44
  "tmp-promise": "^3.0.3",
45
45
  "yaml": "^2.6.0",
46
- "@vertesia/api-fetch-client": "1.0.0-dev.20260225.024852Z",
47
46
  "@llumiverse/common": "1.0.0-dev.20260224.234313Z",
48
- "@vertesia/common": "1.0.0-dev.20260225.024852Z",
49
- "@vertesia/client": "1.0.0-dev.20260225.024852Z",
50
- "@vertesia/memory": "1.0.0-dev.20260225.024852Z"
47
+ "@vertesia/client": "1.0.0-dev.20260227.112605Z",
48
+ "@vertesia/common": "1.0.0-dev.20260227.112605Z",
49
+ "@vertesia/memory": "1.0.0-dev.20260227.112605Z",
50
+ "@vertesia/api-fetch-client": "1.0.0-dev.20260227.112605Z"
51
51
  },
52
52
  "ts_dual_module": {
53
53
  "outDir": "lib",
@@ -1,4 +1,4 @@
1
- import { log } from "@temporalio/activity";
1
+ import { ApplicationFailure, log } from "@temporalio/activity";
2
2
  import { DSLActivityExecutionPayload, DSLActivitySpec } from "@vertesia/common";
3
3
  import { setupActivity } from "../dsl/setup/ActivityContext.js";
4
4
  import { DocPart } from "../utils/chunks.js";
@@ -79,10 +79,37 @@ export async function chunkDocument(payload: DSLActivityExecutionPayload<ChunkDo
79
79
  const lines = document.text.split('\n')
80
80
  const instrumented = lines.map((l, i) => `{%${i}%}${l}`).join('\n')
81
81
 
82
- const res = await executeInteractionFromActivity(client, interactionName, params, {
83
- objectId: objectId,
84
- content: instrumented
85
- });
82
+ let res;
83
+ try {
84
+ res = await executeInteractionFromActivity(client, interactionName, params, {
85
+ objectId: objectId,
86
+ content: instrumented
87
+ });
88
+ } catch (error: any) {
89
+ log.error(`Failed to chunk document ${objectId}`, { error, retryable: error.retryable });
90
+
91
+ // Check retryability and convert to ApplicationFailure for Temporal
92
+ const isRetryable = error.retryable !== undefined
93
+ ? error.retryable !== false
94
+ : undefined;
95
+
96
+ if (isRetryable !== undefined) {
97
+ if (isRetryable) {
98
+ throw ApplicationFailure.create({
99
+ message: `Document chunking failed for ${objectId}: ${error.message}`,
100
+ nonRetryable: false,
101
+ });
102
+ } else {
103
+ throw ApplicationFailure.create({
104
+ message: `Non-retryable document chunking failed for ${objectId}: ${error.message}`,
105
+ nonRetryable: true,
106
+ });
107
+ }
108
+ }
109
+
110
+ // Unknown retryability - rethrow
111
+ throw error;
112
+ }
86
113
 
87
114
  const jsonResult = res.result.object();
88
115
 
@@ -1,5 +1,5 @@
1
- import { CompletionResult, ModelOptions } from "@llumiverse/common";
2
- import { activityInfo, log } from "@temporalio/activity";
1
+ import { CompletionResult, ModelOptions, LlumiverseError } from "@llumiverse/common";
2
+ import { activityInfo, ApplicationFailure, log } from "@temporalio/activity";
3
3
  import { VertesiaClient } from "@vertesia/client";
4
4
  import { NodeStreamSource } from "@vertesia/client/node";
5
5
  import {
@@ -208,9 +208,32 @@ export async function executeInteraction(payload: DSLActivityExecutionPayload<Ex
208
208
  } else if (error.message.includes("modelId: Path `modelId` is required")) {
209
209
  //issue with the input data, don't retry
210
210
  throw new ActivityParamInvalidError("model", payload.activity, error.message);
211
- } else {
212
- throw new Error(`Interaction Execution failed ${interactionName}: ${error.message}`);
213
211
  }
212
+
213
+ // Check retryability from error object (set by executeInteractionFromActivity)
214
+ // or from LlumiverseError instance (direct driver errors in some paths)
215
+ const isRetryable = error.retryable !== undefined
216
+ ? error.retryable !== false // Treat undefined as retryable
217
+ : (error instanceof LlumiverseError ? error.retryable !== false : undefined);
218
+
219
+ if (isRetryable !== undefined) {
220
+ if (isRetryable) {
221
+ log.debug('Marking error as retryable', { interactionName, errorCode: error.errorCode });
222
+ throw ApplicationFailure.create({
223
+ message: `Interaction Execution failed ${interactionName}: ${error.message}`,
224
+ nonRetryable: false,
225
+ });
226
+ } else {
227
+ log.debug('Marking error as non-retryable', { interactionName, errorCode: error.errorCode });
228
+ throw ApplicationFailure.create({
229
+ message: `Non-retryable Interaction Execution failed ${interactionName}: ${error.message}`,
230
+ nonRetryable: true,
231
+ });
232
+ }
233
+ }
234
+
235
+ // Unknown retryability - rethrow as generic error (Temporal will use default retry policy)
236
+ throw new Error(`Interaction Execution failed ${interactionName}: ${error.message}`);
214
237
  }
215
238
  }
216
239
 
@@ -293,7 +316,16 @@ export async function executeInteractionFromActivity(
293
316
 
294
317
  if (res.error || res.status === ExecutionRunStatus.failed) {
295
318
  log.error(`Error executing interaction ${interactionName}`, { error: res.error });
296
- throw new Error(`Interaction Execution failed ${interactionName}: ${res.error}`);
319
+
320
+ // Create error with retryability information
321
+ const errorMessage = `Interaction Execution failed ${interactionName}: ${res.error?.message || 'Unknown error'}`;
322
+ const error = new Error(errorMessage);
323
+
324
+ // Attach retryable property so the catch block can access it
325
+ (error as any).retryable = res.error?.retryable;
326
+ (error as any).errorCode = res.error?.code;
327
+
328
+ throw error;
297
329
  }
298
330
 
299
331
  return res;
@@ -1,4 +1,4 @@
1
- import { log } from "@temporalio/activity";
1
+ import { ApplicationFailure, log } from "@temporalio/activity";
2
2
  import { DSLActivityExecutionPayload, DSLActivitySpec } from "@vertesia/common";
3
3
  import { setupActivity } from "../dsl/setup/ActivityContext.js";
4
4
  import { TruncateSpec, truncByMaxTokens } from "../utils/tokens.js";
@@ -72,18 +72,43 @@ export async function generateDocumentProperties(
72
72
  payload.debug_mode ? { params } : undefined,
73
73
  );
74
74
 
75
- const infoRes = await executeInteractionFromActivity(
76
- client,
77
- interactionName,
78
- {
79
- ...params,
80
- include_previous_error: true,
81
- result_schema: type.object_schema,
82
- validate_result: type.strict_mode,
83
- },
84
- promptData,
85
- payload.debug_mode ?? false,
86
- );
75
+ let infoRes;
76
+ try {
77
+ infoRes = await executeInteractionFromActivity(
78
+ client,
79
+ interactionName,
80
+ {
81
+ ...params,
82
+ include_previous_error: true,
83
+ result_schema: type.object_schema,
84
+ validate_result: type.strict_mode,
85
+ },
86
+ promptData,
87
+ payload.debug_mode ?? false,
88
+ );
89
+ } catch (error: any) {
90
+ log.error(`Failed to extract document properties for ${objectId}`, { error, retryable: error.retryable });
91
+
92
+ const isRetryable = error.retryable !== undefined
93
+ ? error.retryable !== false
94
+ : undefined;
95
+
96
+ if (isRetryable !== undefined) {
97
+ if (isRetryable) {
98
+ throw ApplicationFailure.create({
99
+ message: `Document property extraction failed for ${objectId}: ${error.message}`,
100
+ nonRetryable: false,
101
+ });
102
+ } else {
103
+ throw ApplicationFailure.create({
104
+ message: `Non-retryable document property extraction failed for ${objectId}: ${error.message}`,
105
+ nonRetryable: true,
106
+ });
107
+ }
108
+ }
109
+
110
+ throw error;
111
+ }
87
112
 
88
113
  const getText = () => {
89
114
  if (doc.text) {
@@ -1,4 +1,4 @@
1
- import { log } from "@temporalio/activity";
1
+ import { ApplicationFailure, log } from "@temporalio/activity";
2
2
  import {
3
3
  ContentObjectTypeItem,
4
4
  CreateContentObjectTypePayload,
@@ -122,16 +122,41 @@ export async function generateOrAssignContentType(
122
122
  existing_types.filter((t) => !t.tags?.includes("system")),
123
123
  );
124
124
 
125
- const res = await executeInteractionFromActivity(
126
- client,
127
- interactionName,
128
- params,
129
- {
130
- existing_types,
131
- content,
132
- image: fileRef,
133
- },
134
- );
125
+ let res;
126
+ try {
127
+ res = await executeInteractionFromActivity(
128
+ client,
129
+ interactionName,
130
+ params,
131
+ {
132
+ existing_types,
133
+ content,
134
+ image: fileRef,
135
+ },
136
+ );
137
+ } catch (error: any) {
138
+ log.error(`Failed to select document type`, { error, retryable: error.retryable });
139
+
140
+ const isRetryable = error.retryable !== undefined
141
+ ? error.retryable !== false
142
+ : undefined;
143
+
144
+ if (isRetryable !== undefined) {
145
+ if (isRetryable) {
146
+ throw ApplicationFailure.create({
147
+ message: `Document type selection failed: ${error.message}`,
148
+ nonRetryable: false,
149
+ });
150
+ } else {
151
+ throw ApplicationFailure.create({
152
+ message: `Non-retryable document type selection failed: ${error.message}`,
153
+ nonRetryable: true,
154
+ });
155
+ }
156
+ }
157
+
158
+ throw error;
159
+ }
135
160
 
136
161
  const jsonResult = res.result.object();
137
162
 
@@ -184,17 +209,42 @@ async function generateNewType(
184
209
  params.interactionNames?.generateMetadataModel ??
185
210
  INT_GENERATE_METADATA_MODEL;
186
211
 
187
- const genTypeRes = await executeInteractionFromActivity(
188
- client,
189
- interactionName,
190
- params,
191
- {
192
- existing_types,
193
- content: content,
194
- human_context: project?.configuration?.human_context ?? undefined,
195
- image: fileRef ? fileRef : undefined,
196
- },
197
- );
212
+ let genTypeRes;
213
+ try {
214
+ genTypeRes = await executeInteractionFromActivity(
215
+ client,
216
+ interactionName,
217
+ params,
218
+ {
219
+ existing_types,
220
+ content: content,
221
+ human_context: project?.configuration?.human_context ?? undefined,
222
+ image: fileRef ? fileRef : undefined,
223
+ },
224
+ );
225
+ } catch (error: any) {
226
+ log.error(`Failed to generate new document type`, { error, retryable: error.retryable });
227
+
228
+ const isRetryable = error.retryable !== undefined
229
+ ? error.retryable !== false
230
+ : undefined;
231
+
232
+ if (isRetryable !== undefined) {
233
+ if (isRetryable) {
234
+ throw ApplicationFailure.create({
235
+ message: `Document type generation failed: ${error.message}`,
236
+ nonRetryable: false,
237
+ });
238
+ } else {
239
+ throw ApplicationFailure.create({
240
+ message: `Non-retryable document type generation failed: ${error.message}`,
241
+ nonRetryable: true,
242
+ });
243
+ }
244
+ }
245
+
246
+ throw error;
247
+ }
198
248
 
199
249
  const jsonResult = genTypeRes.result.object();
200
250
 
@@ -1,15 +1,12 @@
1
- import { MockActivityEnvironment, TestWorkflowEnvironment } from '@temporalio/testing';
1
+ import { MockActivityEnvironment } from '@temporalio/testing';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { beforeAll, expect, test } from 'vitest';
5
5
  import { mutoolPdfToText, pdfExtractPages, pdfToImages } from './mutool.js';
6
6
 
7
-
8
- let testEnv: TestWorkflowEnvironment;
9
7
  let activityContext: MockActivityEnvironment;
10
8
 
11
9
  beforeAll(async () => {
12
- testEnv = await TestWorkflowEnvironment.createLocal();
13
10
  activityContext = new MockActivityEnvironment();
14
11
  });
15
12
 
@@ -1,15 +1,12 @@
1
- import { MockActivityEnvironment, TestWorkflowEnvironment } from '@temporalio/testing';
1
+ import { MockActivityEnvironment } from '@temporalio/testing';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { beforeAll, expect, test } from 'vitest';
5
5
  import { markdownWithPandoc } from '../conversion/pandoc';
6
6
 
7
-
8
- let testEnv: TestWorkflowEnvironment;
9
7
  let activityContext: MockActivityEnvironment;
10
8
 
11
9
  beforeAll(async () => {
12
- testEnv = await TestWorkflowEnvironment.createLocal();
13
10
  activityContext = new MockActivityEnvironment();
14
11
  });
15
12
 
@@ -1,6 +1,6 @@
1
1
  import * as protos from '@temporalio/proto';
2
2
  import { TestWorkflowEnvironment } from '@temporalio/testing';
3
- import { Worker } from '@temporalio/worker';
3
+ import { Worker, bundleWorkflowCode, type WorkflowBundleWithSourceMap } from '@temporalio/worker';
4
4
  import { ContentEventName, DSLActivityExecutionPayload, DSLWorkflowExecutionPayload, DSLWorkflowStep } from '@vertesia/common';
5
5
  import { afterAll, beforeAll, describe, expect, test } from 'vitest';
6
6
  import { dslWorkflow } from './dsl-workflow.js';
@@ -119,6 +119,7 @@ const steps3: DSLWorkflowStep[] = [
119
119
  describe('DSL Workflow with child workflows', () => {
120
120
 
121
121
  let testEnv: TestWorkflowEnvironment;
122
+ let workflowBundle: WorkflowBundleWithSourceMap;
122
123
 
123
124
  beforeAll(async () => {
124
125
  testEnv = await TestWorkflowEnvironment.createLocal();
@@ -133,7 +134,10 @@ describe('DSL Workflow with child workflows', () => {
133
134
  InitiatedBy: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
134
135
  },
135
136
  });
136
- });
137
+ workflowBundle = await bundleWorkflowCode({
138
+ workflowsPath: new URL('./test/test-child-workflow.ts', import.meta.url).pathname,
139
+ });
140
+ }, 60_000);
137
141
 
138
142
  afterAll(async () => {
139
143
  await testEnv?.teardown();
@@ -148,7 +152,7 @@ describe('DSL Workflow with child workflows', () => {
148
152
  const worker = await Worker.create({
149
153
  connection: nativeConnection,
150
154
  taskQueue,
151
- workflowsPath: new URL("./test/test-child-workflow.ts", import.meta.url).pathname,
155
+ workflowBundle,
152
156
  activities: { sayHelloFromParent, prepareResult },
153
157
  });
154
158
 
@@ -173,7 +177,7 @@ describe('DSL Workflow with child workflows', () => {
173
177
  }
174
178
  }
175
179
 
176
- let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
180
+ const result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
177
181
  args: [payload],
178
182
  workflowId: 'test',
179
183
  taskQueue,
@@ -192,7 +196,7 @@ describe('DSL Workflow with child workflows', () => {
192
196
  const worker = await Worker.create({
193
197
  connection: nativeConnection,
194
198
  taskQueue,
195
- workflowsPath: new URL("./test/test-child-workflow.ts", import.meta.url).pathname,
199
+ workflowBundle,
196
200
  activities: { sayHelloFromParent, prepareResult, sayHelloFromDSLChild },
197
201
  });
198
202
 
@@ -217,7 +221,7 @@ describe('DSL Workflow with child workflows', () => {
217
221
  }
218
222
  }
219
223
 
220
- let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
224
+ const result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
221
225
  args: [payload],
222
226
  workflowId: 'test',
223
227
  taskQueue,
@@ -236,7 +240,7 @@ describe('DSL Workflow with child workflows', () => {
236
240
  const worker = await Worker.create({
237
241
  connection: nativeConnection,
238
242
  taskQueue,
239
- workflowsPath: new URL("./test/test-child-workflow.ts", import.meta.url).pathname,
243
+ workflowBundle,
240
244
  activities: { sayHelloFromParent, prepareResult, sayHelloFromDSLChild },
241
245
  });
242
246
 
@@ -261,7 +265,7 @@ describe('DSL Workflow with child workflows', () => {
261
265
  }
262
266
  }
263
267
 
264
- let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
268
+ const result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
265
269
  args: [payload],
266
270
  workflowId: 'test-vars',
267
271
  taskQueue,
@@ -1,7 +1,7 @@
1
+ import { TestWorkflowEnvironment } from '@temporalio/testing';
2
+ import { Worker, bundleWorkflowCode, type WorkflowBundleWithSourceMap } from '@temporalio/worker';
1
3
  import { VertesiaClient } from '@vertesia/client';
2
4
  import { ContentEventName, DSLActivityExecutionPayload, DSLActivitySpec, DSLWorkflowExecutionPayload, FindPayload } from '@vertesia/common';
3
- import { TestWorkflowEnvironment } from '@temporalio/testing';
4
- import { Worker } from '@temporalio/worker';
5
5
  import { afterAll, beforeAll, describe, expect, it } from 'vitest';
6
6
  import { dslWorkflow } from './dsl-workflow.js';
7
7
  import { setupActivity } from "./setup/ActivityContext.js";
@@ -77,10 +77,14 @@ const activities: DSLActivitySpec[] = [
77
77
  describe('DSL Workflow', () => {
78
78
 
79
79
  let testEnv: TestWorkflowEnvironment;
80
+ let workflowBundle: WorkflowBundleWithSourceMap;
80
81
 
81
82
  beforeAll(async () => {
82
83
  testEnv = await TestWorkflowEnvironment.createLocal();
83
- });
84
+ workflowBundle = await bundleWorkflowCode({
85
+ workflowsPath: new URL('./dsl-workflow.ts', import.meta.url).pathname,
86
+ });
87
+ }, 60_000);
84
88
 
85
89
  afterAll(async () => {
86
90
  await testEnv?.teardown();
@@ -95,7 +99,7 @@ describe('DSL Workflow', () => {
95
99
  const worker = await Worker.create({
96
100
  connection: nativeConnection,
97
101
  taskQueue,
98
- workflowsPath: new URL("./dsl-workflow.ts", import.meta.url).pathname,
102
+ workflowBundle,
99
103
  activities: { sayMessage },
100
104
  });
101
105
 
@@ -105,7 +109,6 @@ describe('DSL Workflow', () => {
105
109
  vars: {},
106
110
  account_id: '123',
107
111
  project_id: '123',
108
- timestamp: Date.now(),
109
112
  wf_rule_name: 'test',
110
113
  auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
111
114
  config: {
@@ -121,7 +124,7 @@ describe('DSL Workflow', () => {
121
124
  }
122
125
  }
123
126
 
124
- let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
127
+ const result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
125
128
  args: [payload],
126
129
  workflowId: 'test',
127
130
  taskQueue,
@@ -1,12 +1,12 @@
1
- import { ContentEventName, DSLActivityExecutionPayload, DSLActivitySpec, DSLWorkflowExecutionPayload } from '@vertesia/common';
2
1
  import { TestWorkflowEnvironment } from '@temporalio/testing';
3
- import { Worker } from '@temporalio/worker';
2
+ import { Worker, bundleWorkflowCode, type WorkflowBundleWithSourceMap } from '@temporalio/worker';
3
+ import { ContentEventName, DSLActivityExecutionPayload, DSLActivitySpec, DSLWorkflowExecutionPayload } from '@vertesia/common';
4
4
  import { afterAll, beforeAll, describe, expect, it } from 'vitest';
5
5
  import { dslWorkflow } from './dsl-workflow.js';
6
6
  import { setupActivity } from "./setup/ActivityContext.js";
7
7
 
8
8
 
9
- async function testImportedVars(payload: DSLActivityExecutionPayload) {
9
+ async function testImportedVars(payload: DSLActivityExecutionPayload<Record<string, any>>) {
10
10
  const { params } = await setupActivity(payload);
11
11
  if (!params.object_name) throw new Error('object_name is required');
12
12
  console.log('!!!!!!!!!!@@@@@@@@@@@@@@!!!!!!!!!!!!!!', params.object_name);
@@ -28,10 +28,14 @@ const activities: DSLActivitySpec[] = [
28
28
  describe('DSL Workflow import vars', () => {
29
29
 
30
30
  let testEnv: TestWorkflowEnvironment;
31
+ let workflowBundle: WorkflowBundleWithSourceMap;
31
32
 
32
33
  beforeAll(async () => {
33
34
  testEnv = await TestWorkflowEnvironment.createLocal();
34
- });
35
+ workflowBundle = await bundleWorkflowCode({
36
+ workflowsPath: new URL('./dsl-workflow.ts', import.meta.url).pathname,
37
+ });
38
+ }, 60_000);
35
39
 
36
40
  afterAll(async () => {
37
41
  await testEnv?.teardown();
@@ -49,7 +53,7 @@ describe('DSL Workflow import vars', () => {
49
53
  const worker = await Worker.create({
50
54
  connection: nativeConnection,
51
55
  taskQueue,
52
- workflowsPath: new URL("./dsl-workflow.ts", import.meta.url).pathname,
56
+ workflowBundle,
53
57
  activities: { testImportedVars },
54
58
  });
55
59
 
@@ -59,7 +63,6 @@ describe('DSL Workflow import vars', () => {
59
63
  vars: {},
60
64
  account_id: '123',
61
65
  project_id: '123',
62
- timestamp: Date.now(),
63
66
  wf_rule_name: 'test',
64
67
  auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
65
68
  config: {
@@ -75,7 +78,7 @@ describe('DSL Workflow import vars', () => {
75
78
  }
76
79
  }
77
80
 
78
- let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
81
+ const result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
79
82
  args: [payload],
80
83
  workflowId: 'test',
81
84
  taskQueue,
@@ -1,22 +1,22 @@
1
1
  import * as protos from '@temporalio/proto';
2
2
  import { TestWorkflowEnvironment } from '@temporalio/testing';
3
- import { Worker } from '@temporalio/worker';
3
+ import { Worker, bundleWorkflowCode, type WorkflowBundleWithSourceMap } from '@temporalio/worker';
4
4
  import { ContentEventName, DSLActivityExecutionPayload, DSLActivitySpec, DSLWorkflowExecutionPayload } from '@vertesia/common';
5
5
  import { afterAll, beforeAll, describe, expect, it } from 'vitest';
6
6
  import { dslWorkflow } from './dsl-workflow.js';
7
7
  import { setupActivity } from "./setup/ActivityContext.js";
8
8
 
9
- async function sayHello(payload: DSLActivityExecutionPayload): Promise<string> {
9
+ async function sayHello(payload: DSLActivityExecutionPayload<Record<string, any>>): Promise<string> {
10
10
  const { params } = await setupActivity(payload);
11
11
  return params.lang === 'fr' ? "Bonjour" : "Hello";
12
12
  }
13
13
 
14
- async function sayName(payload: DSLActivityExecutionPayload): Promise<string> {
14
+ async function sayName(payload: DSLActivityExecutionPayload<Record<string, any>>): Promise<string> {
15
15
  const { params } = await setupActivity(payload);
16
16
  return params.lang === 'fr' ? "Monde" : "World";
17
17
  }
18
18
 
19
- async function sayGreeting(payload: DSLActivityExecutionPayload): Promise<string> {
19
+ async function sayGreeting(payload: DSLActivityExecutionPayload<Record<string, any>>): Promise<string> {
20
20
  const { params } = await setupActivity(payload);
21
21
  return `${params.hello}, ${params.name}!`;
22
22
  }
@@ -50,6 +50,7 @@ const activities: DSLActivitySpec[] = [
50
50
  describe('DSL Workflow', () => {
51
51
 
52
52
  let testEnv: TestWorkflowEnvironment;
53
+ let workflowBundle: WorkflowBundleWithSourceMap;
53
54
 
54
55
  beforeAll(async () => {
55
56
  testEnv = await TestWorkflowEnvironment.createLocal();
@@ -64,7 +65,10 @@ describe('DSL Workflow', () => {
64
65
  InitiatedBy: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
65
66
  },
66
67
  });
67
- });
68
+ workflowBundle = await bundleWorkflowCode({
69
+ workflowsPath: new URL('./dsl-workflow.ts', import.meta.url).pathname,
70
+ });
71
+ }, 60_000);
68
72
 
69
73
  afterAll(async () => {
70
74
  await testEnv?.teardown();
@@ -79,7 +83,7 @@ describe('DSL Workflow', () => {
79
83
  const worker = await Worker.create({
80
84
  connection: nativeConnection,
81
85
  taskQueue,
82
- workflowsPath: new URL("./dsl-workflow.ts", import.meta.url).pathname,
86
+ workflowBundle,
83
87
  activities: { sayHello, sayName, sayGreeting },
84
88
  });
85
89
 
@@ -89,7 +93,6 @@ describe('DSL Workflow', () => {
89
93
  vars: {},
90
94
  account_id: '123',
91
95
  project_id: '123',
92
- timestamp: Date.now(),
93
96
  wf_rule_name: 'test',
94
97
  auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
95
98
  config: {
@@ -105,7 +108,7 @@ describe('DSL Workflow', () => {
105
108
  }
106
109
  }
107
110
 
108
- let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
111
+ const result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
109
112
  args: [payload],
110
113
  workflowId: 'test',
111
114
  taskQueue,