@temporalio/testing 1.3.0 → 1.4.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.js +5 -4
- package/lib/index.js.map +1 -1
- package/lib/utils.js +2 -2
- package/lib/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +3 -2
- package/src/utils.ts +1 -1
- package/lib/child-process.d.ts +0 -16
- package/lib/child-process.js +0 -57
- package/lib/child-process.js.map +0 -1
- package/lib/index-for-docs.d.ts +0 -1
- package/lib/index-for-docs.js +0 -29
- package/lib/index-for-docs.js.map +0 -1
- package/lib/test-service-client.d.ts +0 -21
- package/lib/test-service-client.js +0 -62
- package/lib/test-service-client.js.map +0 -1
package/lib/index.js
CHANGED
|
@@ -39,13 +39,14 @@ exports.MockActivityEnvironment = exports.defaultActivityInfo = exports.TestWork
|
|
|
39
39
|
const activity = __importStar(require("@temporalio/activity"));
|
|
40
40
|
const client_1 = require("@temporalio/client");
|
|
41
41
|
const common_1 = require("@temporalio/common");
|
|
42
|
+
const time_1 = require("@temporalio/common/lib/time");
|
|
42
43
|
const worker_1 = require("@temporalio/worker");
|
|
43
44
|
const core_bridge_1 = require("@temporalio/core-bridge");
|
|
44
45
|
const path_1 = __importDefault(require("path"));
|
|
45
46
|
const abort_controller_1 = require("abort-controller");
|
|
46
47
|
const events_1 = __importDefault(require("events"));
|
|
47
48
|
const connection_1 = require("./connection");
|
|
48
|
-
const
|
|
49
|
+
const internal_non_workflow_1 = require("@temporalio/common/lib/internal-non-workflow");
|
|
49
50
|
const ms_1 = __importDefault(require("ms"));
|
|
50
51
|
/**
|
|
51
52
|
* A client with the exact same API as the "normal" client with 1 exception,
|
|
@@ -173,7 +174,7 @@ class TestWorkflowEnvironment {
|
|
|
173
174
|
*/
|
|
174
175
|
this.sleep = async (durationMs) => {
|
|
175
176
|
if (this.supportsTimeSkipping) {
|
|
176
|
-
await this.connection.testService.unlockTimeSkippingWithSleep({ duration: (0,
|
|
177
|
+
await this.connection.testService.unlockTimeSkippingWithSleep({ duration: (0, time_1.msToTs)(durationMs) });
|
|
177
178
|
}
|
|
178
179
|
else {
|
|
179
180
|
await new Promise((resolve) => setTimeout(resolve, typeof durationMs === 'string' ? (0, ms_1.default)(durationMs) : durationMs));
|
|
@@ -241,7 +242,7 @@ class TestWorkflowEnvironment {
|
|
|
241
242
|
* @deprecated - use {@link createTimeSkipping} or {@link createLocal}
|
|
242
243
|
*/
|
|
243
244
|
static async create(opts) {
|
|
244
|
-
const optsWithDefaults = addDefaults((0,
|
|
245
|
+
const optsWithDefaults = addDefaults((0, internal_non_workflow_1.filterNullAndUndefined)(opts ?? {}));
|
|
245
246
|
const server = await worker_1.Runtime.instance().createEphemeralServer(optsWithDefaults.server);
|
|
246
247
|
const address = (0, core_bridge_1.getEphemeralServerTarget)(server);
|
|
247
248
|
const nativeConnection = await worker_1.NativeConnection.connect({ address });
|
|
@@ -265,7 +266,7 @@ class TestWorkflowEnvironment {
|
|
|
265
266
|
async currentTimeMs() {
|
|
266
267
|
if (this.supportsTimeSkipping) {
|
|
267
268
|
const { time } = await this.connection.testService.getCurrentTime({});
|
|
268
|
-
return (0,
|
|
269
|
+
return (0, time_1.tsToMs)(time);
|
|
269
270
|
}
|
|
270
271
|
else {
|
|
271
272
|
return Date.now();
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+DAAiD;AACjD,+CAQ4B;AAC5B,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+DAAiD;AACjD,+CAQ4B;AAC5B,+CAAwE;AACxE,sDAA6D;AAC7D,+CAA+D;AAC/D,y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ACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,GAAG,CAAuD,EAAK,EAAE,GAAG,IAAO;QAChF,OAAO,QAAQ,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACnE,CAAC;CACF;AA/BD,0DA+BC"}
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNamespace = exports.waitOnNamespace = void 0;
|
|
4
|
-
const
|
|
4
|
+
const time_1 = require("@temporalio/common/lib/time");
|
|
5
5
|
async function waitOnNamespace(connection, namespace, maxAttempts = 100, retryIntervalSecs = 1) {
|
|
6
6
|
const runId = '12345678-dead-beef-1234-1234567890ab';
|
|
7
7
|
for (let attempt = 1; attempt <= maxAttempts; ++attempt) {
|
|
@@ -28,7 +28,7 @@ async function createNamespace(connection, namespace, maxAttempts = 100, retryIn
|
|
|
28
28
|
try {
|
|
29
29
|
await connection.workflowService.registerNamespace({
|
|
30
30
|
namespace,
|
|
31
|
-
workflowExecutionRetentionPeriod: (0,
|
|
31
|
+
workflowExecutionRetentionPeriod: (0, time_1.msToTs)('1 day'),
|
|
32
32
|
});
|
|
33
33
|
break;
|
|
34
34
|
}
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AACA,sDAAqD;AAE9C,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,GA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,CAAC;SAC/E;KACF;AACH,CAAC;AAvBD,0CAuBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/testing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Temporal.io SDK Testing sub-package",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@grpc/grpc-js": "^1.6.7",
|
|
16
|
-
"@temporalio/activity": "^1.
|
|
17
|
-
"@temporalio/client": "^1.
|
|
18
|
-
"@temporalio/common": "^1.
|
|
19
|
-
"@temporalio/worker": "^1.
|
|
16
|
+
"@temporalio/activity": "^1.4.0",
|
|
17
|
+
"@temporalio/client": "^1.4.0",
|
|
18
|
+
"@temporalio/common": "^1.4.0",
|
|
19
|
+
"@temporalio/worker": "^1.4.0",
|
|
20
20
|
"abort-controller": "^3.0.0",
|
|
21
21
|
"ms": "^2.1.3"
|
|
22
22
|
},
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "4b757ebbc052f327cc37e5693f46c8127c156b0c"
|
|
35
35
|
}
|
package/src/index.ts
CHANGED
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
WorkflowClientOptions,
|
|
19
19
|
WorkflowResultOptions,
|
|
20
20
|
} from '@temporalio/client';
|
|
21
|
-
import { ActivityFunction, CancelledFailure
|
|
21
|
+
import { ActivityFunction, CancelledFailure } from '@temporalio/common';
|
|
22
|
+
import { msToTs, tsToMs } from '@temporalio/common/lib/time';
|
|
22
23
|
import { NativeConnection, Runtime } from '@temporalio/worker';
|
|
23
24
|
import {
|
|
24
25
|
EphemeralServer,
|
|
@@ -31,7 +32,7 @@ import path from 'path';
|
|
|
31
32
|
import { AbortController } from 'abort-controller';
|
|
32
33
|
import events from 'events';
|
|
33
34
|
import { Connection, TestService } from './connection';
|
|
34
|
-
import { filterNullAndUndefined } from '@temporalio/internal-non-workflow
|
|
35
|
+
import { filterNullAndUndefined } from '@temporalio/common/lib/internal-non-workflow';
|
|
35
36
|
import ms from 'ms';
|
|
36
37
|
|
|
37
38
|
export { TimeSkippingServerConfig, TemporaliteConfig, EphemeralServerExecutable } from '@temporalio/core-bridge';
|
package/src/utils.ts
CHANGED
package/lib/child-process.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { ChildProcess } from 'child_process';
|
|
4
|
-
export declare class ChildProcessError extends Error {
|
|
5
|
-
readonly code: number | null;
|
|
6
|
-
readonly signal: NodeJS.Signals | null;
|
|
7
|
-
readonly name = "ChildProcessError";
|
|
8
|
-
constructor(message: string, code: number | null, signal: NodeJS.Signals | null);
|
|
9
|
-
}
|
|
10
|
-
export interface WaitOptions {
|
|
11
|
-
validReturnCodes: number[];
|
|
12
|
-
}
|
|
13
|
-
export declare function waitOnChild(child: ChildProcess, opts?: WaitOptions): Promise<void>;
|
|
14
|
-
export declare function kill(child: ChildProcess, signal?: NodeJS.Signals, opts?: WaitOptions): Promise<void>;
|
|
15
|
-
export declare function killIfExists(child: ChildProcess, signal?: NodeJS.Signals, opts?: WaitOptions): Promise<void>;
|
|
16
|
-
export declare const shell: boolean;
|
package/lib/child-process.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shell = exports.killIfExists = exports.kill = exports.waitOnChild = exports.ChildProcessError = void 0;
|
|
4
|
-
class ChildProcessError extends Error {
|
|
5
|
-
constructor(message, code, signal) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.code = code;
|
|
8
|
-
this.signal = signal;
|
|
9
|
-
this.name = 'ChildProcessError';
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.ChildProcessError = ChildProcessError;
|
|
13
|
-
async function waitOnChild(child, opts) {
|
|
14
|
-
return new Promise((resolve, reject) => {
|
|
15
|
-
child.on('exit', (code, signal) => {
|
|
16
|
-
if (code !== null && (opts?.validReturnCodes ?? [0]).includes(code)) {
|
|
17
|
-
resolve();
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
reject(new ChildProcessError('Process failed', code, signal));
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
child.on('error', reject);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
exports.waitOnChild = waitOnChild;
|
|
27
|
-
async function kill(child, signal = 'SIGINT', opts) {
|
|
28
|
-
if (child.pid === undefined) {
|
|
29
|
-
throw new TypeError('Expected child with pid');
|
|
30
|
-
}
|
|
31
|
-
process.kill(child.pid, signal);
|
|
32
|
-
try {
|
|
33
|
-
await waitOnChild(child, opts);
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
// Should error if the error is not a child process error or it is a child
|
|
37
|
-
// process and either the platform is Windows or the signal matches.
|
|
38
|
-
const shouldError = !(err instanceof ChildProcessError) || (process.platform !== 'win32' && err.signal !== signal);
|
|
39
|
-
if (shouldError) {
|
|
40
|
-
throw err;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.kill = kill;
|
|
45
|
-
async function killIfExists(child, signal = 'SIGINT', opts) {
|
|
46
|
-
try {
|
|
47
|
-
await kill(child, signal, opts);
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
if (err.code !== 'ESRCH') {
|
|
51
|
-
throw err;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.killIfExists = killIfExists;
|
|
56
|
-
exports.shell = process.platform === 'win32';
|
|
57
|
-
//# sourceMappingURL=child-process.js.map
|
package/lib/child-process.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"child-process.js","sourceRoot":"","sources":["../src/child-process.ts"],"names":[],"mappings":";;;AAGA,MAAa,iBAAkB,SAAQ,KAAK;IAG1C,YAAY,OAAe,EAAkB,IAAmB,EAAkB,MAA6B;QAC7G,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,SAAI,GAAJ,IAAI,CAAe;QAAkB,WAAM,GAAN,MAAM,CAAuB;QAF/F,SAAI,GAAG,mBAAmB,CAAC;IAI3C,CAAC;CACF;AAND,8CAMC;AAMM,KAAK,UAAU,WAAW,CAAC,KAAmB,EAAE,IAAkB;IACvE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;YAChC,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,EAAE,gBAAgB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACnE,OAAO,EAAE,CAAC;aACX;iBAAM;gBACL,MAAM,CAAC,IAAI,iBAAiB,CAAC,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;aAC/D;QACH,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC;AAXD,kCAWC;AAEM,KAAK,UAAU,IAAI,CAAC,KAAmB,EAAE,SAAyB,QAAQ,EAAE,IAAkB;IACnG,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE;QAC3B,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;KAChD;IACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI;QACF,MAAM,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KAChC;IAAC,OAAO,GAAG,EAAE;QACZ,0EAA0E;QAC1E,oEAAoE;QACpE,MAAM,WAAW,GAAG,CAAC,CAAC,GAAG,YAAY,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;QACnH,IAAI,WAAW,EAAE;YACf,MAAM,GAAG,CAAC;SACX;KACF;AACH,CAAC;AAfD,oBAeC;AAEM,KAAK,UAAU,YAAY,CAChC,KAAmB,EACnB,SAAyB,QAAQ,EACjC,IAAkB;IAElB,IAAI;QACF,MAAM,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;KACjC;IAAC,OAAO,GAAQ,EAAE;QACjB,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE;YACxB,MAAM,GAAG,CAAC;SACX;KACF;AACH,CAAC;AAZD,oCAYC;AAEY,QAAA,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC"}
|
package/lib/index-for-docs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as testing from './index';
|
package/lib/index-for-docs.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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.testing = void 0;
|
|
27
|
-
// Reexports the contents of this package under the "testing" namespace for better docs generation
|
|
28
|
-
exports.testing = __importStar(require("./index"));
|
|
29
|
-
//# sourceMappingURL=index-for-docs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-for-docs.js","sourceRoot":"","sources":["../src/index-for-docs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kGAAkG;AAClG,mDAAmC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as grpc from '@grpc/grpc-js';
|
|
2
|
-
import { Connection as BaseConnection, ConnectionOptions } from '@temporalio/client';
|
|
3
|
-
import { ConnectionCtorOptions as BaseConnectionCtorOptions } from '@temporalio/client/lib/connection';
|
|
4
|
-
import { temporal } from '../generated-protos';
|
|
5
|
-
export declare type TestService = temporal.api.testservice.v1.TestService;
|
|
6
|
-
export declare const TestService: typeof temporal.api.testservice.v1.TestService;
|
|
7
|
-
interface ConnectionCtorOptions extends BaseConnectionCtorOptions {
|
|
8
|
-
testService: TestService;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* A Connection class that can be used to interact with both the test server's TestService and WorkflowService
|
|
12
|
-
*/
|
|
13
|
-
export declare class Connection extends BaseConnection {
|
|
14
|
-
static readonly TestServiceClient: grpc.ServiceClientConstructor;
|
|
15
|
-
readonly testService: TestService;
|
|
16
|
-
protected static createCtorOptions(options?: ConnectionOptions): ConnectionCtorOptions;
|
|
17
|
-
static lazy(options?: ConnectionOptions): Connection;
|
|
18
|
-
static connect(options?: ConnectionOptions): Promise<Connection>;
|
|
19
|
-
protected constructor(options: ConnectionCtorOptions);
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
this.testService = options.testService;
|
|
38
|
-
}
|
|
39
|
-
static createCtorOptions(options) {
|
|
40
|
-
const ctorOptions = client_1.Connection.createCtorOptions(options);
|
|
41
|
-
const rpcImpl = this.generateRPCImplementation({
|
|
42
|
-
serviceName: 'temporal.api.testservice.v1.TestService',
|
|
43
|
-
client: ctorOptions.client,
|
|
44
|
-
callContextStorage: ctorOptions.callContextStorage,
|
|
45
|
-
interceptors: ctorOptions.options.interceptors,
|
|
46
|
-
});
|
|
47
|
-
const testService = exports.TestService.create(rpcImpl, false, false);
|
|
48
|
-
return { ...ctorOptions, testService };
|
|
49
|
-
}
|
|
50
|
-
static lazy(options) {
|
|
51
|
-
const ctorOptions = this.createCtorOptions(options);
|
|
52
|
-
return new this(ctorOptions);
|
|
53
|
-
}
|
|
54
|
-
static async connect(options) {
|
|
55
|
-
const ret = this.lazy(options);
|
|
56
|
-
await ret.ensureConnected();
|
|
57
|
-
return ret;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.Connection = Connection;
|
|
61
|
-
Connection.TestServiceClient = grpc.makeGenericClientConstructor({}, 'TestService', {});
|
|
62
|
-
//# sourceMappingURL=test-service-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-service-client.js","sourceRoot":"","sources":["../src/test-service-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,+CAAqF;AAErF,0DAA+C;AAGhC,mBAA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