@temporalio/testing 0.20.2 → 0.22.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/generated-protos/index.d.ts +3954 -0
- package/generated-protos/index.js +10297 -0
- package/lib/assert-to-failure-interceptor.d.ts +7 -0
- package/lib/assert-to-failure-interceptor.js +47 -0
- package/lib/assert-to-failure-interceptor.js.map +1 -0
- package/lib/index.d.ts +116 -7
- package/lib/index.js +101 -9
- package/lib/index.js.map +1 -1
- package/lib/test-service-client.d.ts +13 -0
- package/lib/test-service-client.js +43 -0
- package/lib/test-service-client.js.map +1 -0
- package/lib/utils.js +0 -1
- package/lib/utils.js.map +1 -1
- package/package.json +14 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WorkflowInterceptors } from '@temporalio/workflow';
|
|
2
|
+
/**
|
|
3
|
+
* Simple interceptor that transforms {@link assert.AssertionError} into non retryable failures.
|
|
4
|
+
*
|
|
5
|
+
* This allows conveniently using `assert` directly from Workflows.
|
|
6
|
+
*/
|
|
7
|
+
export declare function interceptors(): WorkflowInterceptors;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.interceptors = void 0;
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
8
|
+
const workflow_1 = require("@temporalio/workflow");
|
|
9
|
+
/**
|
|
10
|
+
* Simple interceptor that transforms {@link assert.AssertionError} into non retryable failures.
|
|
11
|
+
*
|
|
12
|
+
* This allows conveniently using `assert` directly from Workflows.
|
|
13
|
+
*/
|
|
14
|
+
function interceptors() {
|
|
15
|
+
return {
|
|
16
|
+
inbound: [
|
|
17
|
+
{
|
|
18
|
+
async handleSignal(input, next) {
|
|
19
|
+
try {
|
|
20
|
+
return await next(input);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
if (err instanceof assert_1.default.AssertionError) {
|
|
24
|
+
const appErr = workflow_1.ApplicationFailure.nonRetryable(err.message);
|
|
25
|
+
appErr.stack = err.stack;
|
|
26
|
+
throw appErr;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
async execute(input, next) {
|
|
31
|
+
try {
|
|
32
|
+
return await next(input);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
if (err instanceof assert_1.default.AssertionError) {
|
|
36
|
+
const appErr = workflow_1.ApplicationFailure.nonRetryable(err.message);
|
|
37
|
+
appErr.stack = err.stack;
|
|
38
|
+
throw appErr;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.interceptors = interceptors;
|
|
47
|
+
//# sourceMappingURL=assert-to-failure-interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert-to-failure-interceptor.js","sourceRoot":"","sources":["../src/assert-to-failure-interceptor.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,mDAAgF;AAEhF;;;;GAIG;AACH,SAAgB,YAAY;IAC1B,OAAO;QACL,OAAO,EAAE;YACP;gBACE,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI;oBAC5B,IAAI;wBACF,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;qBAC1B;oBAAC,OAAO,GAAG,EAAE;wBACZ,IAAI,GAAG,YAAY,gBAAM,CAAC,cAAc,EAAE;4BACxC,MAAM,MAAM,GAAG,6BAAkB,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;4BAC5D,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;4BACzB,MAAM,MAAM,CAAC;yBACd;qBACF;gBACH,CAAC;gBACD,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI;oBACvB,IAAI;wBACF,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;qBAC1B;oBAAC,OAAO,GAAG,EAAE;wBACZ,IAAI,GAAG,YAAY,gBAAM,CAAC,cAAc,EAAE;4BACxC,MAAM,MAAM,GAAG,6BAAkB,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;4BAC5D,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;4BACzB,MAAM,MAAM,CAAC;yBACd;qBACF;gBACH,CAAC;aACF;SACF;KACF,CAAC;AACJ,CAAC;AA7BD,oCA6BC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,84 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as activity from '@temporalio/activity';
|
|
3
|
-
import { AsyncCompletionClient,
|
|
4
|
-
import { ActivityFunction } from '@temporalio/common';
|
|
3
|
+
import { AsyncCompletionClient, WorkflowClient as BaseWorkflowClient, WorkflowClientOptions, WorkflowResultOptions as BaseWorkflowResultOptions, WorkflowStartOptions as BaseWorkflowStartOptions } from '@temporalio/client';
|
|
4
|
+
import { ActivityFunction, Workflow, WorkflowResultType } from '@temporalio/common';
|
|
5
5
|
import { NativeConnection, Logger } from '@temporalio/worker';
|
|
6
6
|
import { ChildProcess, StdioOptions } from 'child_process';
|
|
7
7
|
import events from 'events';
|
|
8
|
+
import { Connection, TestService } from './test-service-client';
|
|
9
|
+
import { temporal } from '@temporalio/proto';
|
|
10
|
+
export declare const DEFAULT_TEST_SERVER_PATH: string;
|
|
8
11
|
/**
|
|
9
|
-
* Options
|
|
12
|
+
* Options passed to {@link WorkflowClient.result}, these are the same as the
|
|
13
|
+
* {@link BaseWorkflowResultOptions} with an additional option that controls
|
|
14
|
+
* whether to toggle time skipping in the Test server while waiting on a
|
|
15
|
+
* Workflow's result.
|
|
10
16
|
*/
|
|
11
|
-
export interface
|
|
17
|
+
export interface WorkflowResultOptions extends BaseWorkflowResultOptions {
|
|
18
|
+
/**
|
|
19
|
+
* If set to `true`, waiting for the result does not enable time skipping
|
|
20
|
+
*/
|
|
21
|
+
runInNormalTime?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Options passed to {@link WorkflowClient.execute}, these are the same as the
|
|
25
|
+
* {@link BaseWorkflowStartOptions} with an additional option that controls
|
|
26
|
+
* whether to toggle time skipping in the Test server while waiting on a
|
|
27
|
+
* Workflow's result.
|
|
28
|
+
*/
|
|
29
|
+
export declare type WorkflowStartOptions<T extends Workflow> = BaseWorkflowStartOptions<T> & {
|
|
30
|
+
/**
|
|
31
|
+
* If set to `true`, waiting for the result does not enable time skipping
|
|
32
|
+
*/
|
|
33
|
+
runInNormalTime?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A client with the exact same API as the "normal" client with 1 exception,
|
|
37
|
+
* When this client waits on a Workflow's result, it will enable time skipping
|
|
38
|
+
* in the test server.
|
|
39
|
+
*/
|
|
40
|
+
export declare class WorkflowClient extends BaseWorkflowClient {
|
|
41
|
+
protected readonly testService: TestService;
|
|
42
|
+
constructor(testService: TestService, workflowService?: temporal.api.workflowservice.v1.WorkflowService, options?: WorkflowClientOptions | undefined);
|
|
43
|
+
/**
|
|
44
|
+
* Execute a Workflow and wait for completion.
|
|
45
|
+
*
|
|
46
|
+
* @see {@link BaseWorkflowClient.execute}
|
|
47
|
+
*/
|
|
48
|
+
execute<T extends Workflow>(workflowTypeOrFunc: string | T, options: WorkflowStartOptions<T>): Promise<WorkflowResultType<T>>;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the result of a Workflow execution.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link BaseWorkflowClient.result}
|
|
53
|
+
*/
|
|
54
|
+
result<T>(workflowId: string, runId?: string | undefined, opts?: WorkflowResultOptions | undefined): Promise<T>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Convenience workflow interceptors
|
|
58
|
+
*
|
|
59
|
+
* Contains a single interceptor for transforming `AssertionError`s into non
|
|
60
|
+
* retryable `ApplicationFailure`s.
|
|
61
|
+
*/
|
|
62
|
+
export declare const workflowInterceptorModules: string[];
|
|
63
|
+
export interface TestServerSpawnerOptions {
|
|
64
|
+
/**
|
|
65
|
+
* @default {@link DEFAULT_TEST_SERVER_PATH}
|
|
66
|
+
*/
|
|
67
|
+
path?: string;
|
|
12
68
|
/**
|
|
13
|
-
*
|
|
69
|
+
* @default ignore
|
|
14
70
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
71
|
+
stdio?: StdioOptions;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A generic callback that returns a child process
|
|
75
|
+
*/
|
|
76
|
+
export declare type TestServerSpawner = (port: number) => ChildProcess;
|
|
77
|
+
/**
|
|
78
|
+
* Options for {@link TestWorkflowEnvironment.create}
|
|
79
|
+
*/
|
|
80
|
+
export interface TestWorkflowEnvironmentOptions {
|
|
81
|
+
testServer?: TestServerSpawner | TestServerSpawnerOptions;
|
|
17
82
|
logger?: Logger;
|
|
18
83
|
}
|
|
19
84
|
/**
|
|
@@ -51,7 +116,51 @@ export declare class TestWorkflowEnvironment {
|
|
|
51
116
|
* Kill the test server process and close the connection to it
|
|
52
117
|
*/
|
|
53
118
|
teardown(): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Wait for `durationMs` in "test server time".
|
|
121
|
+
*
|
|
122
|
+
* The test server toggles between skipped time and normal time depending on what it needs to execute.
|
|
123
|
+
*
|
|
124
|
+
* This method is likely to resolve in less than `durationMs` of "real time".
|
|
125
|
+
*
|
|
126
|
+
* Useful for simulating events far into the future like completion of long running activities.
|
|
127
|
+
*
|
|
128
|
+
* @param durationMs {@link https://www.npmjs.com/package/ms | ms} formatted string or number of milliseconds
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
*
|
|
132
|
+
* `workflow.ts`
|
|
133
|
+
*
|
|
134
|
+
* ```ts
|
|
135
|
+
* const activities = proxyActivities({ startToCloseTimeout: 2_000_000 });
|
|
136
|
+
*
|
|
137
|
+
* export async function raceActivityAndTimer(): Promise<string> {
|
|
138
|
+
* return await Promise.race([
|
|
139
|
+
* wf.sleep(500_000).then(() => 'timer'),
|
|
140
|
+
* activities.longRunning().then(() => 'activity'),
|
|
141
|
+
* ]);
|
|
142
|
+
* }
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* `test.ts`
|
|
146
|
+
*
|
|
147
|
+
* ```ts
|
|
148
|
+
* const worker = await Worker.create({
|
|
149
|
+
* connection: testEnv.nativeConnection,
|
|
150
|
+
* activities: {
|
|
151
|
+
* async longRunning() {
|
|
152
|
+
* await testEnv.sleep(1_000_000); // <-- sleep called here
|
|
153
|
+
* },
|
|
154
|
+
* },
|
|
155
|
+
* // ...
|
|
156
|
+
* });
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
sleep: (durationMs: number | string) => Promise<void>;
|
|
54
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Used as the default activity info for Activities executed in the {@link MockActivityEnvironment}
|
|
163
|
+
*/
|
|
55
164
|
export declare const defaultActivityInfo: activity.Info;
|
|
56
165
|
/**
|
|
57
166
|
* An execution environment for testing Activities.
|
package/lib/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.MockActivityEnvironment = exports.defaultActivityInfo = exports.TestWorkflowEnvironment = void 0;
|
|
29
|
+
exports.MockActivityEnvironment = exports.defaultActivityInfo = exports.TestWorkflowEnvironment = exports.workflowInterceptorModules = exports.WorkflowClient = exports.DEFAULT_TEST_SERVER_PATH = void 0;
|
|
30
30
|
const activity = __importStar(require("@temporalio/activity"));
|
|
31
31
|
const client_1 = require("@temporalio/client");
|
|
32
32
|
const common_1 = require("@temporalio/common");
|
|
@@ -37,15 +37,61 @@ const abort_controller_1 = require("abort-controller");
|
|
|
37
37
|
const child_process_1 = require("child_process");
|
|
38
38
|
const events_1 = __importDefault(require("events"));
|
|
39
39
|
const child_process_2 = require("./child-process");
|
|
40
|
+
const test_service_client_1 = require("./test-service-client");
|
|
40
41
|
const TEST_SERVER_EXECUTABLE_NAME = os_1.default.platform() === 'win32' ? 'test-server.exe' : 'test-server';
|
|
41
|
-
|
|
42
|
+
exports.DEFAULT_TEST_SERVER_PATH = path_1.default.join(__dirname, `../${TEST_SERVER_EXECUTABLE_NAME}`);
|
|
43
|
+
/**
|
|
44
|
+
* A client with the exact same API as the "normal" client with 1 exception,
|
|
45
|
+
* When this client waits on a Workflow's result, it will enable time skipping
|
|
46
|
+
* in the test server.
|
|
47
|
+
*/
|
|
48
|
+
class WorkflowClient extends client_1.WorkflowClient {
|
|
49
|
+
constructor(testService, workflowService, options) {
|
|
50
|
+
super(workflowService, options);
|
|
51
|
+
this.testService = testService;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Execute a Workflow and wait for completion.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link BaseWorkflowClient.execute}
|
|
57
|
+
*/
|
|
58
|
+
async execute(workflowTypeOrFunc, options) {
|
|
59
|
+
return super.execute(workflowTypeOrFunc, options);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Gets the result of a Workflow execution.
|
|
63
|
+
*
|
|
64
|
+
* @see {@link BaseWorkflowClient.result}
|
|
65
|
+
*/
|
|
66
|
+
async result(workflowId, runId, opts) {
|
|
67
|
+
if (opts?.runInNormalTime) {
|
|
68
|
+
return await super.result(workflowId, runId, opts);
|
|
69
|
+
}
|
|
70
|
+
await this.testService.unlockTimeSkipping({});
|
|
71
|
+
try {
|
|
72
|
+
return await super.result(workflowId, runId, opts);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
await this.testService.lockTimeSkipping({});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.WorkflowClient = WorkflowClient;
|
|
80
|
+
/**
|
|
81
|
+
* Convenience workflow interceptors
|
|
82
|
+
*
|
|
83
|
+
* Contains a single interceptor for transforming `AssertionError`s into non
|
|
84
|
+
* retryable `ApplicationFailure`s.
|
|
85
|
+
*/
|
|
86
|
+
exports.workflowInterceptorModules = [path_1.default.join(__dirname, 'assert-to-failure-interceptor')];
|
|
87
|
+
function addDefaults({ testServer, logger, }) {
|
|
42
88
|
return {
|
|
43
|
-
testServerSpawner:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
89
|
+
testServerSpawner: typeof testServer === 'function'
|
|
90
|
+
? testServer
|
|
91
|
+
: (port) => (0, child_process_1.spawn)(testServer?.path || exports.DEFAULT_TEST_SERVER_PATH, [`${port}`], {
|
|
92
|
+
stdio: testServer?.stdio || 'ignore',
|
|
93
|
+
}),
|
|
47
94
|
logger: logger ?? new worker_1.DefaultLogger('INFO'),
|
|
48
|
-
testServerStdio,
|
|
49
95
|
};
|
|
50
96
|
}
|
|
51
97
|
// TS transforms `import` statements into `require`s, this is a workaround until
|
|
@@ -60,9 +106,52 @@ const _importDynamic = new Function('modulePath', 'return import(modulePath)');
|
|
|
60
106
|
class TestWorkflowEnvironment {
|
|
61
107
|
constructor(serverProc, connection, nativeConnection) {
|
|
62
108
|
this.serverProc = serverProc;
|
|
109
|
+
/**
|
|
110
|
+
* Wait for `durationMs` in "test server time".
|
|
111
|
+
*
|
|
112
|
+
* The test server toggles between skipped time and normal time depending on what it needs to execute.
|
|
113
|
+
*
|
|
114
|
+
* This method is likely to resolve in less than `durationMs` of "real time".
|
|
115
|
+
*
|
|
116
|
+
* Useful for simulating events far into the future like completion of long running activities.
|
|
117
|
+
*
|
|
118
|
+
* @param durationMs {@link https://www.npmjs.com/package/ms | ms} formatted string or number of milliseconds
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
*
|
|
122
|
+
* `workflow.ts`
|
|
123
|
+
*
|
|
124
|
+
* ```ts
|
|
125
|
+
* const activities = proxyActivities({ startToCloseTimeout: 2_000_000 });
|
|
126
|
+
*
|
|
127
|
+
* export async function raceActivityAndTimer(): Promise<string> {
|
|
128
|
+
* return await Promise.race([
|
|
129
|
+
* wf.sleep(500_000).then(() => 'timer'),
|
|
130
|
+
* activities.longRunning().then(() => 'activity'),
|
|
131
|
+
* ]);
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* `test.ts`
|
|
136
|
+
*
|
|
137
|
+
* ```ts
|
|
138
|
+
* const worker = await Worker.create({
|
|
139
|
+
* connection: testEnv.nativeConnection,
|
|
140
|
+
* activities: {
|
|
141
|
+
* async longRunning() {
|
|
142
|
+
* await testEnv.sleep(1_000_000); // <-- sleep called here
|
|
143
|
+
* },
|
|
144
|
+
* },
|
|
145
|
+
* // ...
|
|
146
|
+
* });
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
this.sleep = async (durationMs) => {
|
|
150
|
+
await this.connection.testService.unlockTimeSkippingWithSleep({ duration: (0, common_1.msToTs)(durationMs) });
|
|
151
|
+
};
|
|
63
152
|
this.connection = connection;
|
|
64
153
|
this.nativeConnection = nativeConnection;
|
|
65
|
-
this.workflowClient = new
|
|
154
|
+
this.workflowClient = new WorkflowClient(this.connection.testService, this.connection.service);
|
|
66
155
|
this.asyncCompletionClient = new client_1.AsyncCompletionClient(this.connection.service);
|
|
67
156
|
}
|
|
68
157
|
/**
|
|
@@ -75,7 +164,7 @@ class TestWorkflowEnvironment {
|
|
|
75
164
|
const { testServerSpawner, logger } = addDefaults(opts ?? {});
|
|
76
165
|
const child = testServerSpawner(port);
|
|
77
166
|
const address = `127.0.0.1:${port}`;
|
|
78
|
-
const conn = new
|
|
167
|
+
const conn = new test_service_client_1.Connection({ address });
|
|
79
168
|
try {
|
|
80
169
|
await Promise.race([
|
|
81
170
|
conn.untilReady(),
|
|
@@ -106,6 +195,9 @@ class TestWorkflowEnvironment {
|
|
|
106
195
|
}
|
|
107
196
|
}
|
|
108
197
|
exports.TestWorkflowEnvironment = TestWorkflowEnvironment;
|
|
198
|
+
/**
|
|
199
|
+
* Used as the default activity info for Activities executed in the {@link MockActivityEnvironment}
|
|
200
|
+
*/
|
|
109
201
|
exports.defaultActivityInfo = {
|
|
110
202
|
attempt: 1,
|
|
111
203
|
isLocal: false,
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAiD;AACjD,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAiD;AACjD,+CAM4B;AAC5B,+CAA8G;AAC9G,+CAA6E;AAC7E,gDAAwB;AACxB,4CAAoB;AACpB,uDAAmD;AACnD,iDAAkE;AAClE,oDAA4B;AAC5B,mDAAoD;AAEpD,+DAAgE;AAGhE,MAAM,2BAA2B,GAAG,YAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC;AAErF,QAAA,wBAAwB,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,2BAA2B,EAAE,CAAC,CAAC;AA4BlG;;;;GAIG;AACH,MAAa,cAAe,SAAQ,uBAAkB;IACpD,YACqB,WAAwB,EAC3C,eAAiE,EACjE,OAA2C;QAE3C,KAAK,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAJb,gBAAW,GAAX,WAAW,CAAa;IAK7C,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO,CAClB,kBAA8B,EAC9B,OAAgC;QAEhC,O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Connection, ConnectionOptions } from '@temporalio/client';
|
|
3
|
+
import { temporal } from '../generated-protos';
|
|
4
|
+
export declare type TestService = temporal.api.testservice.v1.TestService;
|
|
5
|
+
export declare const TestService: typeof temporal.api.testservice.v1.TestService;
|
|
6
|
+
/**
|
|
7
|
+
* A Connection class that can be used to interact with both the test server's TestService and WorkflowService
|
|
8
|
+
*/
|
|
9
|
+
export declare class Connection extends BaseConnection {
|
|
10
|
+
static readonly TestServiceClient: grpc.ServiceClientConstructor;
|
|
11
|
+
readonly testService: TestService;
|
|
12
|
+
constructor(options?: ConnectionOptions);
|
|
13
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Connection = exports.TestService = void 0;
|
|
27
|
+
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
28
|
+
const client_1 = require("@temporalio/client");
|
|
29
|
+
const generated_protos_1 = require("../generated-protos");
|
|
30
|
+
exports.TestService = generated_protos_1.temporal.api.testservice.v1.TestService;
|
|
31
|
+
/**
|
|
32
|
+
* A Connection class that can be used to interact with both the test server's TestService and WorkflowService
|
|
33
|
+
*/
|
|
34
|
+
class Connection extends client_1.Connection {
|
|
35
|
+
constructor(options) {
|
|
36
|
+
super(options);
|
|
37
|
+
const rpcImpl = this.generateRPCImplementation('temporal.api.testservice.v1.TestService');
|
|
38
|
+
this.testService = new exports.TestService(rpcImpl, false, false);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.Connection = Connection;
|
|
42
|
+
Connection.TestServiceClient = grpc.makeGenericClientConstructor({}, 'TestService', {});
|
|
43
|
+
//# sourceMappingURL=test-service-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-service-client.js","sourceRoot":"","sources":["../src/test-service-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,+CAAqF;AACrF,0DAA+C;AAGhC,mBAAW,GAAK,2BAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,aAAC;AAE3D;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAc;IAI5C,YAAY,OAA2B;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,MAAM,OAAO,GAAG,IAAI,CAAC,yBAAyB,CAAC,yCAAyC,CAAC,CAAC;QAC1F,IAAI,CAAC,WAAW,GAAG,IAAI,mBAAW,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;;AATH,gCAUC;AATwB,4BAAiB,GAAG,IAAI,CAAC,4BAA4B,CAAC,EAAE,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC"}
|
package/lib/utils.js
CHANGED
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,mFAA8D;AAEvD,KAAK,UAAU,eAAe,CACnC,UAAsB,EACtB,SAAiB,EACjB,WAAW,GAAG,GAAG,EACjB,iBAAiB,GAAG,CAAC;IAErB,MAAM,KAAK,GAAG,sCAAsC,CAAC;IACrD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,EAAE,OAAO,EAAE;QACvD,IAAI;YACF,MAAM,UAAU,CAAC,OAAO,CAAC,2BAA2B,CAAC;gBACnD,SAAS;gBACT,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE;aACzC,CAAC,CAAC;SACJ;QAAC,OAAO,GAAQ,EAAE;YACjB,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,mFAA8D;AAEvD,KAAK,UAAU,eAAe,CACnC,UAAsB,EACtB,SAAiB,EACjB,WAAW,GAAG,GAAG,EACjB,iBAAiB,GAAG,CAAC;IAErB,MAAM,KAAK,GAAG,sCAAsC,CAAC;IACrD,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,EAAE,OAAO,EAAE;QACvD,IAAI;YACF,MAAM,UAAU,CAAC,OAAO,CAAC,2BAA2B,CAAC;gBACnD,SAAS;gBACT,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE;aACzC,CAAC,CAAC;SACJ;QAAC,OAAO,GAAQ,EAAE;YACjB,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBACrF,MAAM;aACP;YACD,IAAI,OAAO,KAAK,WAAW,EAAE;gBAC3B,MAAM,GAAG,CAAC;aACX;YACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC,CAAC,CAAC;SAC/E;KACF;AACH,CAAC;AAvBD,0CAuBC;AAEM,KAAK,UAAU,eAAe,CACnC,UAAsB,EACtB,SAAiB,EACjB,WAAW,GAAG,GAAG,EACjB,iBAAiB,GAAG,CAAC;IAErB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,EAAE,OAAO,EAAE;QACvD,IAAI;YACF,MAAM,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,SAAS,EAAE,gCAAgC,EAAE,IAAA,iCAAM,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC7G,MAAM;SACP;QAAC,OAAO,GAAQ,EAAE;YACjB,IAAI,GAAG,CAAC,OAAO,KAAK,2BAA2B,EAAE;gBAC/C,MAAM;aACP;YACD,IAAI,OAAO,KAAK,WAAW,EAAE;gBAC3B,MAAM,GAAG,CAAC;aACX;YACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC,CAAC,CAAC;SAC/E;KACF;AACH,CAAC;AApBD,0CAoBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Temporal.io SDK Testing sub-package",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -11,17 +11,23 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"install": "node ./scripts/download-test-server.mjs",
|
|
14
|
-
"build": "
|
|
14
|
+
"build": "npm-run-all build:protos install",
|
|
15
|
+
"build:protos": "node ./scripts/compile-proto.mjs"
|
|
15
16
|
},
|
|
16
17
|
"author": "Temporal Technologies Inc. <sdk@temporal.io>",
|
|
17
18
|
"license": "MIT",
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@temporalio/
|
|
21
|
-
"@temporalio/
|
|
20
|
+
"@grpc/grpc-js": "^1.5.7",
|
|
21
|
+
"@temporalio/activity": "^0.22.0",
|
|
22
|
+
"@temporalio/client": "^0.22.0",
|
|
23
|
+
"@temporalio/common": "^0.22.0",
|
|
24
|
+
"@temporalio/worker": "^0.22.0",
|
|
25
|
+
"@types/long": "^4.0.1",
|
|
22
26
|
"abort-controller": "^3.0.0",
|
|
23
27
|
"get-port": "^6.1.2",
|
|
24
28
|
"got": "^12.0.1",
|
|
29
|
+
"long": "^4.0.0",
|
|
30
|
+
"protobufjs": "^6.11.2",
|
|
25
31
|
"tar-stream": "^2.2.0",
|
|
26
32
|
"unzipper": "^0.10.11"
|
|
27
33
|
},
|
|
@@ -30,10 +36,11 @@
|
|
|
30
36
|
},
|
|
31
37
|
"homepage": "https://github.com/temporalio/sdk-typescript/tree/main/packages/testing",
|
|
32
38
|
"files": [
|
|
33
|
-
"lib"
|
|
39
|
+
"lib",
|
|
40
|
+
"generated-protos"
|
|
34
41
|
],
|
|
35
42
|
"publishConfig": {
|
|
36
43
|
"access": "public"
|
|
37
44
|
},
|
|
38
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "3aa1f14982bd170d21b728cbf016dc4f1b595a76"
|
|
39
46
|
}
|