@temporalio/testing 1.14.2-canary-release-testing.0 → 1.16.0
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/lib/index.d.ts +1 -1
- package/lib/index.js.map +1 -1
- package/lib/testing-workflow-environment.d.ts +39 -0
- package/lib/testing-workflow-environment.js +57 -2
- package/lib/testing-workflow-environment.js.map +1 -1
- package/package.json +9 -9
- package/src/index.ts +1 -0
- package/src/testing-workflow-environment.ts +66 -2
package/lib/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
export { TestWorkflowEnvironment, type LocalTestWorkflowEnvironmentOptions, type TimeSkippingTestWorkflowEnvironmentOptions, type ExistingServerTestWorkflowEnvironmentOptions, } from './testing-workflow-environment';
|
|
10
|
+
export { TestWorkflowEnvironment, type LocalTestWorkflowEnvironmentOptions, type TimeSkippingTestWorkflowEnvironmentOptions, type ExistingServerTestWorkflowEnvironmentOptions, type NexusEndpointIdentifier, } from './testing-workflow-environment';
|
|
11
11
|
export { type DevServerConfig, type TimeSkippingServerConfig, type EphemeralServerExecutable, } from './ephemeral-server';
|
|
12
12
|
export { type ClientOptionsForTestEnv, TimeSkippingWorkflowClient } from './client';
|
|
13
13
|
export { type MockActivityEnvironmentOptions, MockActivityEnvironment, defaultActivityInfo, } from './mocking-activity-environment';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;AAEH,0DAA6B;AAE7B,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;AAEH,0DAA6B;AAE7B,+EAMwC;AALtC,uIAAA,uBAAuB,OAAA;AAazB,mCAAoF;AAA7C,oHAAA,0BAA0B,OAAA;AAEjE,+EAIwC;AAFtC,uIAAA,uBAAuB,OAAA;AACvB,mIAAA,mBAAmB,OAAA;AAGrB;;;;;GAKG;AACU,QAAA,0BAA0B,GAAG,CAAC,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,+BAA+B,CAAC,CAAC,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { AsyncCompletionClient, Client, ClientPlugin, Connection, ConnectionPlug
|
|
|
3
3
|
import { Duration } from '@temporalio/common';
|
|
4
4
|
import { NativeConnection, NativeConnectionPlugin, Runtime } from '@temporalio/worker';
|
|
5
5
|
import { native } from '@temporalio/core-bridge';
|
|
6
|
+
import { temporal } from '@temporalio/proto';
|
|
6
7
|
import { DevServerConfig, TimeSkippingServerConfig } from './ephemeral-server';
|
|
7
8
|
import { ClientOptionsForTestEnv } from './client';
|
|
8
9
|
/**
|
|
@@ -200,7 +201,45 @@ export declare class TestWorkflowEnvironment {
|
|
|
200
201
|
* time has been skipped to.
|
|
201
202
|
*/
|
|
202
203
|
currentTimeMs(): Promise<number>;
|
|
204
|
+
/**
|
|
205
|
+
* Create a Nexus endpoint targeting a worker task queue.
|
|
206
|
+
*
|
|
207
|
+
* This is a convenience method that wraps `connection.operatorService.createNexusEndpoint` for easier
|
|
208
|
+
* testing of Nexus services.
|
|
209
|
+
*
|
|
210
|
+
* @param name - The name of the Nexus endpoint
|
|
211
|
+
* @param taskQueue - The task queue that will handle Nexus operations
|
|
212
|
+
* @returns The created Nexus endpoint
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```ts
|
|
216
|
+
* const endpoint = await testEnv.createNexusEndpoint('my-endpoint', 'my-task-queue');
|
|
217
|
+
* const endpointId = endpoint.id;
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
createNexusEndpoint(name: string, taskQueue: string): Promise<NexusEndpointIdentifier>;
|
|
221
|
+
/**
|
|
222
|
+
* Delete a Nexus endpoint.
|
|
223
|
+
*
|
|
224
|
+
* This is a convenience method that wraps `connection.operatorService.deleteNexusEndpoint` for easier
|
|
225
|
+
* testing of Nexus services.
|
|
226
|
+
*
|
|
227
|
+
* @param endpoint - The endpoint to delete (can pass the full endpoint object or just an object with id and version)
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* const endpoint = await testEnv.createNexusEndpoint('my-endpoint', 'my-task-queue');
|
|
232
|
+
* // ... use the endpoint ...
|
|
233
|
+
* await testEnv.deleteNexusEndpoint(endpoint);
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
deleteNexusEndpoint(endpoint: Pick<NexusEndpointIdentifier, 'id' | 'version'>): Promise<void>;
|
|
203
237
|
}
|
|
238
|
+
export type NexusEndpointIdentifier = {
|
|
239
|
+
id: NonNullable<temporal.api.nexus.v1.IEndpoint['id']>;
|
|
240
|
+
version: NonNullable<temporal.api.nexus.v1.IEndpoint['version']>;
|
|
241
|
+
raw: temporal.api.nexus.v1.IEndpoint;
|
|
242
|
+
};
|
|
204
243
|
/**
|
|
205
244
|
* Options for {@link TestWorkflowEnvironment.create}
|
|
206
245
|
*/
|
|
@@ -79,8 +79,8 @@ class TestWorkflowEnvironment {
|
|
|
79
79
|
plugins: options.plugins,
|
|
80
80
|
...options.client,
|
|
81
81
|
});
|
|
82
|
-
this.asyncCompletionClient = this.client.activity; // eslint-disable-line
|
|
83
|
-
this.workflowClient = this.client.workflow; // eslint-disable-line
|
|
82
|
+
this.asyncCompletionClient = this.client.activity; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
83
|
+
this.workflowClient = this.client.workflow; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Start a time skipping workflow environment.
|
|
@@ -289,6 +289,61 @@ class TestWorkflowEnvironment {
|
|
|
289
289
|
return Date.now();
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Create a Nexus endpoint targeting a worker task queue.
|
|
294
|
+
*
|
|
295
|
+
* This is a convenience method that wraps `connection.operatorService.createNexusEndpoint` for easier
|
|
296
|
+
* testing of Nexus services.
|
|
297
|
+
*
|
|
298
|
+
* @param name - The name of the Nexus endpoint
|
|
299
|
+
* @param taskQueue - The task queue that will handle Nexus operations
|
|
300
|
+
* @returns The created Nexus endpoint
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* const endpoint = await testEnv.createNexusEndpoint('my-endpoint', 'my-task-queue');
|
|
305
|
+
* const endpointId = endpoint.id;
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
async createNexusEndpoint(name, taskQueue) {
|
|
309
|
+
const response = await this.connection.operatorService.createNexusEndpoint({
|
|
310
|
+
spec: {
|
|
311
|
+
name,
|
|
312
|
+
target: {
|
|
313
|
+
worker: {
|
|
314
|
+
namespace: this.namespace ?? 'default',
|
|
315
|
+
taskQueue,
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
if (!response.endpoint?.id || !response.endpoint?.version) {
|
|
321
|
+
throw new TypeError('Unexpected response from createNexusEndpoint');
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
id: response.endpoint.id,
|
|
325
|
+
version: response.endpoint.version,
|
|
326
|
+
raw: response.endpoint,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Delete a Nexus endpoint.
|
|
331
|
+
*
|
|
332
|
+
* This is a convenience method that wraps `connection.operatorService.deleteNexusEndpoint` for easier
|
|
333
|
+
* testing of Nexus services.
|
|
334
|
+
*
|
|
335
|
+
* @param endpoint - The endpoint to delete (can pass the full endpoint object or just an object with id and version)
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```ts
|
|
339
|
+
* const endpoint = await testEnv.createNexusEndpoint('my-endpoint', 'my-task-queue');
|
|
340
|
+
* // ... use the endpoint ...
|
|
341
|
+
* await testEnv.deleteNexusEndpoint(endpoint);
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
async deleteNexusEndpoint(endpoint) {
|
|
345
|
+
await this.connection.operatorService.deleteNexusEndpoint(endpoint);
|
|
346
|
+
}
|
|
292
347
|
}
|
|
293
348
|
exports.TestWorkflowEnvironment = TestWorkflowEnvironment;
|
|
294
349
|
function addDefaults(opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-workflow-environment.js","sourceRoot":"","sources":["../src/testing-workflow-environment.ts"],"names":[],"mappings":";;;AAAA,qCAAmC,CAAC,kDAAkD;AACtF,+CAO4B;AAC5B,kEAI2C;AAC3C,+CAAqE;AACrE,sDAAyE;AACzE,+CAAgH;AAChH,yDAAiD;
|
|
1
|
+
{"version":3,"file":"testing-workflow-environment.js","sourceRoot":"","sources":["../src/testing-workflow-environment.ts"],"names":[],"mappings":";;;AAAA,qCAAmC,CAAC,kDAAkD;AACtF,+CAO4B;AAC5B,kEAI2C;AAC3C,+CAAqE;AACrE,sDAAyE;AACzE,+CAAgH;AAChH,yDAAiD;AAEjD,gFAAkF;AAClF,yDAA8G;AAC9G,qCAAuE;AAgCvE;;;;;GAKG;AACH,MAAa,uBAAuB;IAsCf;IACD;IACA;IACG;IAOH;IA/ClB;;OAEG;IACa,SAAS,CAAU;IAEnC;;OAEG;IACa,UAAU,CAAa;IAEvC;;OAEG;IACa,MAAM,CAAS;IAE/B;;;;OAIG;IACa,qBAAqB,CAAwB;IAE7D;;;;OAIG;IACa,cAAc,CAAiB;IAE/C;;;;OAIG;IACa,gBAAgB,CAAmB;IAEnD,YACmB,OAAgB,EACjB,OAAmD,EACnD,oBAA6B,EAC1B,MAA2C,EAC9D,UAAsB,EACtB,gBAAkC,EAClC,SAA6B;IAC7B;;OAEG;IACa,OAAe;QAVd,YAAO,GAAP,OAAO,CAAS;QACjB,YAAO,GAAP,OAAO,CAA4C;QACnD,yBAAoB,GAApB,oBAAoB,C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CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/testing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Temporal.io SDK Testing sub-package",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"abort-controller": "^3.0.0",
|
|
16
|
-
"@temporalio/
|
|
17
|
-
"@temporalio/
|
|
18
|
-
"@temporalio/core-bridge": "1.
|
|
19
|
-
"@temporalio/proto": "1.
|
|
20
|
-
"@temporalio/worker": "1.
|
|
21
|
-
"@temporalio/
|
|
22
|
-
"@temporalio/workflow": "1.
|
|
16
|
+
"@temporalio/activity": "1.16.0",
|
|
17
|
+
"@temporalio/common": "1.16.0",
|
|
18
|
+
"@temporalio/core-bridge": "1.16.0",
|
|
19
|
+
"@temporalio/proto": "1.16.0",
|
|
20
|
+
"@temporalio/worker": "1.16.0",
|
|
21
|
+
"@temporalio/client": "1.16.0",
|
|
22
|
+
"@temporalio/workflow": "1.16.0"
|
|
23
23
|
},
|
|
24
24
|
"bugs": {
|
|
25
25
|
"url": "https://github.com/temporalio/sdk-typescript/issues"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/temporalio/sdk-typescript/tree/main/packages/testing",
|
|
33
33
|
"engines": {
|
|
34
|
-
"node": ">=
|
|
34
|
+
"node": ">= 20.0.0"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"lib",
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { Duration, TypedSearchAttributes } from '@temporalio/common';
|
|
|
16
16
|
import { msToNumber, msToTs, tsToMs } from '@temporalio/common/lib/time';
|
|
17
17
|
import { NativeConnection, NativeConnectionPlugin, NativeConnectionOptions, Runtime } from '@temporalio/worker';
|
|
18
18
|
import { native } from '@temporalio/core-bridge';
|
|
19
|
+
import { temporal } from '@temporalio/proto';
|
|
19
20
|
import { filterNullAndUndefined } from '@temporalio/common/lib/internal-workflow';
|
|
20
21
|
import { toNativeEphemeralServerConfig, DevServerConfig, TimeSkippingServerConfig } from './ephemeral-server';
|
|
21
22
|
import { ClientOptionsForTestEnv, TimeSkippingClient } from './client';
|
|
@@ -122,8 +123,8 @@ export class TestWorkflowEnvironment {
|
|
|
122
123
|
plugins: options.plugins,
|
|
123
124
|
...options.client,
|
|
124
125
|
});
|
|
125
|
-
this.asyncCompletionClient = this.client.activity; // eslint-disable-line
|
|
126
|
-
this.workflowClient = this.client.workflow; // eslint-disable-line
|
|
126
|
+
this.asyncCompletionClient = this.client.activity; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
127
|
+
this.workflowClient = this.client.workflow; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
127
128
|
}
|
|
128
129
|
|
|
129
130
|
/**
|
|
@@ -357,8 +358,71 @@ export class TestWorkflowEnvironment {
|
|
|
357
358
|
return Date.now();
|
|
358
359
|
}
|
|
359
360
|
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Create a Nexus endpoint targeting a worker task queue.
|
|
364
|
+
*
|
|
365
|
+
* This is a convenience method that wraps `connection.operatorService.createNexusEndpoint` for easier
|
|
366
|
+
* testing of Nexus services.
|
|
367
|
+
*
|
|
368
|
+
* @param name - The name of the Nexus endpoint
|
|
369
|
+
* @param taskQueue - The task queue that will handle Nexus operations
|
|
370
|
+
* @returns The created Nexus endpoint
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```ts
|
|
374
|
+
* const endpoint = await testEnv.createNexusEndpoint('my-endpoint', 'my-task-queue');
|
|
375
|
+
* const endpointId = endpoint.id;
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
async createNexusEndpoint(name: string, taskQueue: string): Promise<NexusEndpointIdentifier> {
|
|
379
|
+
const response = await this.connection.operatorService.createNexusEndpoint({
|
|
380
|
+
spec: {
|
|
381
|
+
name,
|
|
382
|
+
target: {
|
|
383
|
+
worker: {
|
|
384
|
+
namespace: this.namespace ?? 'default',
|
|
385
|
+
taskQueue,
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
if (!response.endpoint?.id || !response.endpoint?.version) {
|
|
391
|
+
throw new TypeError('Unexpected response from createNexusEndpoint');
|
|
392
|
+
}
|
|
393
|
+
return {
|
|
394
|
+
id: response.endpoint.id,
|
|
395
|
+
version: response.endpoint.version,
|
|
396
|
+
raw: response.endpoint,
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Delete a Nexus endpoint.
|
|
402
|
+
*
|
|
403
|
+
* This is a convenience method that wraps `connection.operatorService.deleteNexusEndpoint` for easier
|
|
404
|
+
* testing of Nexus services.
|
|
405
|
+
*
|
|
406
|
+
* @param endpoint - The endpoint to delete (can pass the full endpoint object or just an object with id and version)
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```ts
|
|
410
|
+
* const endpoint = await testEnv.createNexusEndpoint('my-endpoint', 'my-task-queue');
|
|
411
|
+
* // ... use the endpoint ...
|
|
412
|
+
* await testEnv.deleteNexusEndpoint(endpoint);
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
async deleteNexusEndpoint(endpoint: Pick<NexusEndpointIdentifier, 'id' | 'version'>): Promise<void> {
|
|
416
|
+
await this.connection.operatorService.deleteNexusEndpoint(endpoint);
|
|
417
|
+
}
|
|
360
418
|
}
|
|
361
419
|
|
|
420
|
+
export type NexusEndpointIdentifier = {
|
|
421
|
+
id: NonNullable<temporal.api.nexus.v1.IEndpoint['id']>;
|
|
422
|
+
version: NonNullable<temporal.api.nexus.v1.IEndpoint['version']>;
|
|
423
|
+
raw: temporal.api.nexus.v1.IEndpoint;
|
|
424
|
+
};
|
|
425
|
+
|
|
362
426
|
/**
|
|
363
427
|
* Options for {@link TestWorkflowEnvironment.create}
|
|
364
428
|
*/
|