@temporalio/testing 1.12.3 → 1.13.1

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/client.d.ts CHANGED
@@ -1,27 +1,24 @@
1
1
  import 'abort-controller/polyfill';
2
- import { Client, ClientOptions, WorkflowClient, WorkflowClientOptions, WorkflowResultOptions } from '@temporalio/client';
3
- import { Connection, TestService } from './connection';
4
- export interface TimeSkippingWorkflowClientOptions extends WorkflowClientOptions {
5
- connection: Connection;
6
- enableTimeSkipping: boolean;
7
- }
8
- export interface TestEnvClientOptions extends ClientOptions {
9
- connection: Connection;
10
- enableTimeSkipping: boolean;
11
- }
2
+ import { Client, ClientOptions, TestService, WorkflowClient, WorkflowClientOptions, WorkflowResultOptions } from '@temporalio/client';
12
3
  /**
13
4
  * Subset of the "normal" client options that are used to create a client for the test environment.
14
5
  */
15
6
  export type ClientOptionsForTestEnv = Omit<ClientOptions, 'namespace' | 'connection'>;
16
7
  /**
17
- * A client with the exact same API as the "normal" client with 1 exception,
18
- * When this client waits on a Workflow's result, it will enable time skipping
19
- * in the test server.
8
+ * A client with the exact same API as the "normal" client with one exception:
9
+ * when `TestEnvClient.workflow` (an instance of {@link TimeSkippingWorkflowClient})
10
+ * waits on a Workflow's result, it will enable time skipping in the Test Server.
11
+ */
12
+ export declare class TimeSkippingClient extends Client {
13
+ constructor(options: ClientOptions);
14
+ }
15
+ /**
16
+ * A client with the exact same API as the "normal" client with one exception: when this client
17
+ * waits on a Workflow's result, it will enable time skipping in the Test Server.
20
18
  */
21
19
  export declare class TimeSkippingWorkflowClient extends WorkflowClient {
22
20
  protected readonly testService: TestService;
23
- protected readonly enableTimeSkipping: boolean;
24
- constructor(options: TimeSkippingWorkflowClientOptions);
21
+ constructor(options: WorkflowClientOptions);
25
22
  /**
26
23
  * Gets the result of a Workflow execution.
27
24
  *
@@ -29,11 +26,3 @@ export declare class TimeSkippingWorkflowClient extends WorkflowClient {
29
26
  */
30
27
  result<T>(workflowId: string, runId?: string | undefined, opts?: WorkflowResultOptions | undefined): Promise<T>;
31
28
  }
32
- /**
33
- * A client with the exact same API as the "normal" client with one exception:
34
- * when `TestEnvClient.workflow` (an instance of {@link TimeSkippingWorkflowClient}) waits on a Workflow's result, it will enable time skipping
35
- * in the Test Server.
36
- */
37
- export declare class TestEnvClient extends Client {
38
- constructor(options: TestEnvClientOptions);
39
- }
package/lib/client.js CHANGED
@@ -1,20 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestEnvClient = exports.TimeSkippingWorkflowClient = void 0;
3
+ exports.TimeSkippingWorkflowClient = exports.TimeSkippingClient = void 0;
4
4
  require("abort-controller/polyfill"); // eslint-disable-line import/no-unassigned-import
5
5
  const client_1 = require("@temporalio/client");
6
6
  /**
7
- * A client with the exact same API as the "normal" client with 1 exception,
8
- * When this client waits on a Workflow's result, it will enable time skipping
9
- * in the test server.
7
+ * A client with the exact same API as the "normal" client with one exception:
8
+ * when `TestEnvClient.workflow` (an instance of {@link TimeSkippingWorkflowClient})
9
+ * waits on a Workflow's result, it will enable time skipping in the Test Server.
10
+ */
11
+ class TimeSkippingClient extends client_1.Client {
12
+ constructor(options) {
13
+ super(options);
14
+ // Recreate the client (this isn't optimal but it's better than adding public methods just for testing).
15
+ // NOTE: we cast to "any" to work around `workflow` being a readonly attribute.
16
+ this.workflow = new TimeSkippingWorkflowClient({
17
+ ...this.workflow.options,
18
+ connection: options.connection,
19
+ });
20
+ }
21
+ }
22
+ exports.TimeSkippingClient = TimeSkippingClient;
23
+ /**
24
+ * A client with the exact same API as the "normal" client with one exception: when this client
25
+ * waits on a Workflow's result, it will enable time skipping in the Test Server.
10
26
  */
11
27
  class TimeSkippingWorkflowClient extends client_1.WorkflowClient {
12
28
  testService;
13
- enableTimeSkipping;
14
29
  constructor(options) {
15
30
  super(options);
16
- this.enableTimeSkipping = options.enableTimeSkipping;
17
- this.testService = options.connection.testService;
31
+ const testService = options.connection.testService;
32
+ if (!testService) {
33
+ throw new TypeError('TestService must be present when creating a TimeSkippingWorkflowClient');
34
+ }
35
+ this.testService = testService;
18
36
  }
19
37
  /**
20
38
  * Gets the result of a Workflow execution.
@@ -22,37 +40,14 @@ class TimeSkippingWorkflowClient extends client_1.WorkflowClient {
22
40
  * @see {@link WorkflowClient.result}
23
41
  */
24
42
  async result(workflowId, runId, opts) {
25
- if (this.enableTimeSkipping) {
26
- await this.testService.unlockTimeSkipping({});
27
- try {
28
- return await super.result(workflowId, runId, opts);
29
- }
30
- finally {
31
- await this.testService.lockTimeSkipping({});
32
- }
33
- }
34
- else {
43
+ await this.testService.unlockTimeSkipping({});
44
+ try {
35
45
  return await super.result(workflowId, runId, opts);
36
46
  }
47
+ finally {
48
+ await this.testService.lockTimeSkipping({});
49
+ }
37
50
  }
38
51
  }
39
52
  exports.TimeSkippingWorkflowClient = TimeSkippingWorkflowClient;
40
- /**
41
- * A client with the exact same API as the "normal" client with one exception:
42
- * when `TestEnvClient.workflow` (an instance of {@link TimeSkippingWorkflowClient}) waits on a Workflow's result, it will enable time skipping
43
- * in the Test Server.
44
- */
45
- class TestEnvClient extends client_1.Client {
46
- constructor(options) {
47
- super(options);
48
- // Recreate the client (this isn't optimal but it's better than adding public methods just for testing).
49
- // NOTE: we cast to "any" to work around `workflow` being a readonly attribute.
50
- this.workflow = new TimeSkippingWorkflowClient({
51
- ...this.workflow.options,
52
- connection: options.connection,
53
- enableTimeSkipping: options.enableTimeSkipping,
54
- });
55
- }
56
- }
57
- exports.TestEnvClient = TestEnvClient;
58
53
  //# sourceMappingURL=client.js.map
package/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,qCAAmC,CAAC,kDAAkD;AACtF,+CAM4B;AAkB5B;;;;GAIG;AACH,MAAa,0BAA2B,SAAQ,uBAAc;IACzC,WAAW,CAAc;IACzB,kBAAkB,CAAU;I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,kBAAmB,SAAQ,eAAM;IAC5C,YAAY,OAAsB;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,wGAAwG;QACxG,+EAA+E;QAC9E,IAAY,CAAC,QAAQ,GAAG,IAAI,0BAA0B,CAAC;YACtD,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO;YACxB,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAC,CAAC;IACL,CAAC;CACF;AAXD,gDAWC;AAED;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,uBAAc;IACzC,WAAW,CAAc;IAE5C,YAAY,OAA8B;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,WAAW,GAAI,OAAO,CAAC,UAAyB,CAAC,WAAW,CAAC;QACnE,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,SAAS,CAAC,wEAAwE,CAAC,CAAC;QAChG,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAC,MAAM,CACnB,UAAkB,EAClB,KAA0B,EAC1B,IAAwC;QAExC,MAAM,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC;YACH,OAAO,MAAM,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACrD,CAAC;gBAAS,CAAC;YACT,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF;AA7BD,gEA6BC"}
package/lib/index.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
  export { TestWorkflowEnvironment, type LocalTestWorkflowEnvironmentOptions, type TimeSkippingTestWorkflowEnvironmentOptions, type ExistingServerTestWorkflowEnvironmentOptions, } from './testing-workflow-environment';
11
11
  export { type DevServerConfig, type TimeSkippingServerConfig, type EphemeralServerExecutable, } from './ephemeral-server';
12
- export { type ClientOptionsForTestEnv, type TestEnvClientOptions, type TimeSkippingWorkflowClientOptions, TestEnvClient, TimeSkippingWorkflowClient, } from './client';
12
+ export { type ClientOptionsForTestEnv, TimeSkippingWorkflowClient } from './client';
13
13
  export { type MockActivityEnvironmentOptions, MockActivityEnvironment, defaultActivityInfo, } from './mocking-activity-environment';
14
14
  /**
15
15
  * Convenience workflow interceptors
package/lib/index.js CHANGED
@@ -12,12 +12,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.workflowInterceptorModules = exports.defaultActivityInfo = exports.MockActivityEnvironment = exports.TimeSkippingWorkflowClient = exports.TestEnvClient = exports.TestWorkflowEnvironment = void 0;
15
+ exports.workflowInterceptorModules = exports.defaultActivityInfo = exports.MockActivityEnvironment = exports.TimeSkippingWorkflowClient = exports.TestWorkflowEnvironment = void 0;
16
16
  const node_path_1 = __importDefault(require("node:path"));
17
17
  var testing_workflow_environment_1 = require("./testing-workflow-environment");
18
18
  Object.defineProperty(exports, "TestWorkflowEnvironment", { enumerable: true, get: function () { return testing_workflow_environment_1.TestWorkflowEnvironment; } });
19
19
  var client_1 = require("./client");
20
- Object.defineProperty(exports, "TestEnvClient", { enumerable: true, get: function () { return client_1.TestEnvClient; } });
21
20
  Object.defineProperty(exports, "TimeSkippingWorkflowClient", { enumerable: true, get: function () { return client_1.TimeSkippingWorkflowClient; } });
22
21
  var mocking_activity_environment_1 = require("./mocking-activity-environment");
23
22
  Object.defineProperty(exports, "MockActivityEnvironment", { enumerable: true, get: function () { return mocking_activity_environment_1.MockActivityEnvironment; } });
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,+EAKwC;AAJtC,uIAAA,uBAAuB,OAAA;AAYzB,mCAOkB;AAFhB,uGAAA,aAAa,OAAA;AACb,oHAAA,0BAA0B,OAAA;AAG5B,+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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;AAEH,0DAA6B;AAE7B,+EAKwC;AAJtC,uIAAA,uBAAuB,OAAA;AAYzB,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"}
@@ -2,12 +2,14 @@ import 'abort-controller/polyfill';
2
2
  import events from 'node:events';
3
3
  import * as activity from '@temporalio/activity';
4
4
  import { ActivityFunction, Logger, MetricMeter, ActivityCancellationDetails } from '@temporalio/common';
5
+ import { Client } from '@temporalio/client';
5
6
  import { ActivityInterceptorsFactory } from '@temporalio/worker';
6
7
  import { CancelReason } from '@temporalio/worker/lib/activity';
7
8
  export interface MockActivityEnvironmentOptions {
8
9
  interceptors?: ActivityInterceptorsFactory[];
9
10
  logger?: Logger;
10
11
  metricMeter?: MetricMeter;
12
+ client?: Client;
11
13
  }
12
14
  /**
13
15
  * An execution environment for testing Activities.
@@ -31,7 +31,7 @@ class MockActivityEnvironment extends node_events_1.default.EventEmitter {
31
31
  payloadCodecs: [],
32
32
  failureConverter: common_1.defaultFailureConverter,
33
33
  };
34
- this.activity = new activity_1.Activity({ ...exports.defaultActivityInfo, ...info }, undefined, loadedDataConverter, heartbeatCallback, logger_1.LoggerWithComposedMetadata.compose(opts?.logger ?? new worker_1.DefaultLogger(), { sdkComponent: common_1.SdkComponent.worker }), opts?.metricMeter ?? common_1.noopMetricMeter, opts?.interceptors ?? []);
34
+ this.activity = new activity_1.Activity({ ...exports.defaultActivityInfo, ...info }, undefined, loadedDataConverter, heartbeatCallback, opts?.client, logger_1.LoggerWithComposedMetadata.compose(opts?.logger ?? new worker_1.DefaultLogger(), { sdkComponent: common_1.SdkComponent.worker }), opts?.metricMeter ?? common_1.noopMetricMeter, opts?.interceptors ?? []);
35
35
  this.context = this.activity.context;
36
36
  this.cancel = (reason, details) => {
37
37
  // Default to CANCELLED if nothing provided.
@@ -72,5 +72,6 @@ exports.defaultActivityInfo = {
72
72
  scheduleToCloseTimeoutMs: 1000,
73
73
  currentAttemptScheduledTimestampMs: 1,
74
74
  priority: undefined,
75
+ retryPolicy: undefined,
75
76
  };
76
77
  //# sourceMappingURL=mocking-activity-environment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mocking-activity-environment.js","sourceRoot":"","sources":["../src/mocking-activity-environment.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAmC,CAAC,kDAAkD;AACtF,8DAAiC;AAEjC,+CAS4B;AAC5B,0DAA2E;AAC3E,+CAAgF;AAChF,8DAAyE;AAQzE;;;;;;;;GAQG;AACH,MAAa,uBAAwB,SAAQ,qBAAM,CAAC,YAAY;IACvD,MAAM,GAA2E,GAAG,EAAE,CAAC,SAAS,CAAC;IACxF,OAAO,CAAmB;IACzB,QAAQ,CAAW;IAEpC,YAAY,IAA6B,EAAE,IAAqC;QAC9E,KAAK,EAAE,CAAC;QACR,MAAM,iBAAiB,GAAG,CAAC,OAAiB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACjF,MAAM,mBAAmB,GAAG;YAC1B,gBAAgB,EAAE,gCAAuB;YACzC,aAAa,EAAE,EAAE;YACjB,gBAAgB,EA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AS;IAC5B,iBAAiB,EAAE,SAAS;IAC5B,iBAAiB,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,sCAAsC,EAAE;IACxF,oBAAoB,EAAE,CAAC;IACvB,qBAAqB,EAAE,IAAI;IAC3B,wBAAwB,EAAE,IAAI;IAC9B,kCAAkC,EAAE,CAAC;IACrC,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,SAAS;CACvB,CAAC"}
@@ -1,9 +1,8 @@
1
1
  import 'abort-controller/polyfill';
2
- import { AsyncCompletionClient, Client, WorkflowClient } from '@temporalio/client';
2
+ import { AsyncCompletionClient, Client, Connection, WorkflowClient } from '@temporalio/client';
3
3
  import { Duration } from '@temporalio/common';
4
4
  import { NativeConnection, Runtime } from '@temporalio/worker';
5
5
  import { native } from '@temporalio/core-bridge';
6
- import { Connection } from './connection';
7
6
  import { DevServerConfig, TimeSkippingServerConfig } from './ephemeral-server';
8
7
  import { ClientOptionsForTestEnv } from './client';
9
8
  /**
@@ -50,7 +49,7 @@ export declare class TestWorkflowEnvironment {
50
49
  */
51
50
  readonly connection: Connection;
52
51
  /**
53
- * A {@link TestEnvClient} for interacting with the ephemeral server
52
+ * A {@link TimeSkippingClient} for interacting with the ephemeral server
54
53
  */
55
54
  readonly client: Client;
56
55
  /**
@@ -2,14 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TestWorkflowEnvironment = void 0;
4
4
  require("abort-controller/polyfill"); // eslint-disable-line import/no-unassigned-import
5
+ const client_1 = require("@temporalio/client");
6
+ const connection_1 = require("@temporalio/client/lib/connection");
5
7
  const common_1 = require("@temporalio/common");
6
8
  const time_1 = require("@temporalio/common/lib/time");
7
9
  const worker_1 = require("@temporalio/worker");
8
10
  const core_bridge_1 = require("@temporalio/core-bridge");
9
11
  const internal_workflow_1 = require("@temporalio/common/lib/internal-workflow");
10
- const connection_1 = require("./connection");
11
12
  const ephemeral_server_1 = require("./ephemeral-server");
12
- const client_1 = require("./client");
13
+ const client_2 = require("./client");
13
14
  /**
14
15
  * An execution environment for running Workflow integration tests.
15
16
  *
@@ -30,7 +31,7 @@ class TestWorkflowEnvironment {
30
31
  */
31
32
  connection;
32
33
  /**
33
- * A {@link TestEnvClient} for interacting with the ephemeral server
34
+ * A {@link TimeSkippingClient} for interacting with the ephemeral server
34
35
  */
35
36
  client;
36
37
  /**
@@ -59,12 +60,17 @@ class TestWorkflowEnvironment {
59
60
  this.connection = connection;
60
61
  this.nativeConnection = nativeConnection;
61
62
  this.namespace = namespace;
62
- this.client = new client_1.TestEnvClient({
63
- connection,
64
- namespace: this.namespace,
65
- enableTimeSkipping: supportsTimeSkipping,
66
- ...options.client,
67
- });
63
+ this.client = supportsTimeSkipping
64
+ ? new client_2.TimeSkippingClient({
65
+ connection,
66
+ namespace: this.namespace,
67
+ ...options.client,
68
+ })
69
+ : new client_1.Client({
70
+ connection,
71
+ namespace: this.namespace,
72
+ ...options.client,
73
+ });
68
74
  this.asyncCompletionClient = this.client.activity; // eslint-disable-line deprecation/deprecation
69
75
  this.workflowClient = this.client.workflow; // eslint-disable-line deprecation/deprecation
70
76
  }
@@ -174,8 +180,14 @@ class TestWorkflowEnvironment {
174
180
  address = opts.address ?? 'localhost:7233';
175
181
  server = 'existing';
176
182
  }
177
- const nativeConnection = await worker_1.NativeConnection.connect({ address });
178
- const connection = await connection_1.Connection.connect({ address });
183
+ const nativeConnection = await worker_1.NativeConnection.connect({
184
+ address,
185
+ [connection_1.InternalConnectionOptionsSymbol]: { supportsTestService: supportsTimeSkipping },
186
+ });
187
+ const connection = await client_1.Connection.connect({
188
+ address,
189
+ [connection_1.InternalConnectionOptionsSymbol]: { supportsTestService: supportsTimeSkipping },
190
+ });
179
191
  return new this(runtime, optsWithDefaults, supportsTimeSkipping, server, connection, nativeConnection, namespace);
180
192
  }
181
193
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"testing-workflow-environment.js","sourceRoot":"","sources":["../src/testing-workflow-environment.ts"],"names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I,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC9B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAO,IAAI,CAAC,UAAyB,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;YACtF,OAAO,IAAA,aAAM,EAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;CACF;AA9QD,0DA8QC;AAcD,SAAS,WAAW,CAAC,IAAoC;IACvD,OAAO;QACL,MAAM,EAAE,EAAE;QACV,GAAG,IAAI;QACP,MAAM,EAAE;YACN,GAAG,IAAI,CAAC,MAAM;SACf;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"testing-workflow-environment.js","sourceRoot":"","sources":["../src/testing-workflow-environment.ts"],"names":[],"mappings":";;;AAAA,qCAAmC,CAAC,kDAAkD;AACtF,+CAA+F;AAC/F,kEAI2C;AAC3C,+CAAqE;AACrE,sDAAyE;AACzE,+CAAwF;AACxF,yDAAiD;AACjD,gFAAkF;AAClF,yDAA8G;AAC9G,qCAAuE;AA6BvE;;;;;GAKG;AACH,MAAa,uBAAuB;IAsCf;IACD;IACA;IACG;IAxCrB;;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;QANZ,YAAO,GAAP,OAAO,CAAS;QACjB,YAAO,GAAP,OAAO,CAA4C;QACnD,yBAAoB,GAApB,oBAAoB,CAAS;QAC1B,WAAM,GAAN,MAAM,CAAqC;QAK9D,IAAI,CAAC,UAAU,GA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M;SACf;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/testing",
3
- "version": "1.12.3",
3
+ "version": "1.13.1",
4
4
  "description": "Temporal.io SDK Testing sub-package",
5
5
  "main": "lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -12,13 +12,13 @@
12
12
  "author": "Temporal Technologies Inc. <sdk@temporal.io>",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@temporalio/activity": "1.12.3",
16
- "@temporalio/client": "1.12.3",
17
- "@temporalio/common": "1.12.3",
18
- "@temporalio/core-bridge": "1.12.3",
19
- "@temporalio/proto": "1.12.3",
20
- "@temporalio/worker": "1.12.3",
21
- "@temporalio/workflow": "1.12.3",
15
+ "@temporalio/activity": "1.13.1",
16
+ "@temporalio/client": "1.13.1",
17
+ "@temporalio/common": "1.13.1",
18
+ "@temporalio/core-bridge": "1.13.1",
19
+ "@temporalio/proto": "1.13.1",
20
+ "@temporalio/worker": "1.13.1",
21
+ "@temporalio/workflow": "1.13.1",
22
22
  "abort-controller": "^3.0.0"
23
23
  },
24
24
  "bugs": {
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "e25f1d5ddaf0b5c755457b1cc1dde7c6e089a63b"
43
+ "gitHead": "7904e19bc72dcdf9eb0275ecaa585a2ff2fec072"
44
44
  }
package/src/client.ts CHANGED
@@ -2,21 +2,12 @@ import 'abort-controller/polyfill'; // eslint-disable-line import/no-unassigned-
2
2
  import {
3
3
  Client,
4
4
  ClientOptions,
5
+ Connection,
6
+ TestService,
5
7
  WorkflowClient,
6
8
  WorkflowClientOptions,
7
9
  WorkflowResultOptions,
8
10
  } from '@temporalio/client';
9
- import { Connection, TestService } from './connection';
10
-
11
- export interface TimeSkippingWorkflowClientOptions extends WorkflowClientOptions {
12
- connection: Connection;
13
- enableTimeSkipping: boolean;
14
- }
15
-
16
- export interface TestEnvClientOptions extends ClientOptions {
17
- connection: Connection;
18
- enableTimeSkipping: boolean;
19
- }
20
11
 
21
12
  /**
22
13
  * Subset of the "normal" client options that are used to create a client for the test environment.
@@ -24,18 +15,37 @@ export interface TestEnvClientOptions extends ClientOptions {
24
15
  export type ClientOptionsForTestEnv = Omit<ClientOptions, 'namespace' | 'connection'>;
25
16
 
26
17
  /**
27
- * A client with the exact same API as the "normal" client with 1 exception,
28
- * When this client waits on a Workflow's result, it will enable time skipping
29
- * in the test server.
18
+ * A client with the exact same API as the "normal" client with one exception:
19
+ * when `TestEnvClient.workflow` (an instance of {@link TimeSkippingWorkflowClient})
20
+ * waits on a Workflow's result, it will enable time skipping in the Test Server.
21
+ */
22
+ export class TimeSkippingClient extends Client {
23
+ constructor(options: ClientOptions) {
24
+ super(options);
25
+
26
+ // Recreate the client (this isn't optimal but it's better than adding public methods just for testing).
27
+ // NOTE: we cast to "any" to work around `workflow` being a readonly attribute.
28
+ (this as any).workflow = new TimeSkippingWorkflowClient({
29
+ ...this.workflow.options,
30
+ connection: options.connection,
31
+ });
32
+ }
33
+ }
34
+
35
+ /**
36
+ * A client with the exact same API as the "normal" client with one exception: when this client
37
+ * waits on a Workflow's result, it will enable time skipping in the Test Server.
30
38
  */
31
39
  export class TimeSkippingWorkflowClient extends WorkflowClient {
32
40
  protected readonly testService: TestService;
33
- protected readonly enableTimeSkipping: boolean;
34
41
 
35
- constructor(options: TimeSkippingWorkflowClientOptions) {
42
+ constructor(options: WorkflowClientOptions) {
36
43
  super(options);
37
- this.enableTimeSkipping = options.enableTimeSkipping;
38
- this.testService = options.connection.testService;
44
+ const testService = (options.connection as Connection).testService;
45
+ if (!testService) {
46
+ throw new TypeError('TestService must be present when creating a TimeSkippingWorkflowClient');
47
+ }
48
+ this.testService = testService;
39
49
  }
40
50
 
41
51
  /**
@@ -48,34 +58,11 @@ export class TimeSkippingWorkflowClient extends WorkflowClient {
48
58
  runId?: string | undefined,
49
59
  opts?: WorkflowResultOptions | undefined
50
60
  ): Promise<T> {
51
- if (this.enableTimeSkipping) {
52
- await this.testService.unlockTimeSkipping({});
53
- try {
54
- return await super.result(workflowId, runId, opts);
55
- } finally {
56
- await this.testService.lockTimeSkipping({});
57
- }
58
- } else {
61
+ await this.testService.unlockTimeSkipping({});
62
+ try {
59
63
  return await super.result(workflowId, runId, opts);
64
+ } finally {
65
+ await this.testService.lockTimeSkipping({});
60
66
  }
61
67
  }
62
68
  }
63
-
64
- /**
65
- * A client with the exact same API as the "normal" client with one exception:
66
- * when `TestEnvClient.workflow` (an instance of {@link TimeSkippingWorkflowClient}) waits on a Workflow's result, it will enable time skipping
67
- * in the Test Server.
68
- */
69
- export class TestEnvClient extends Client {
70
- constructor(options: TestEnvClientOptions) {
71
- super(options);
72
-
73
- // Recreate the client (this isn't optimal but it's better than adding public methods just for testing).
74
- // NOTE: we cast to "any" to work around `workflow` being a readonly attribute.
75
- (this as any).workflow = new TimeSkippingWorkflowClient({
76
- ...this.workflow.options,
77
- connection: options.connection,
78
- enableTimeSkipping: options.enableTimeSkipping,
79
- });
80
- }
81
- }
package/src/index.ts CHANGED
@@ -23,14 +23,7 @@ export {
23
23
  type EphemeralServerExecutable,
24
24
  } from './ephemeral-server';
25
25
 
26
- export {
27
- // FIXME: Revise the pertinence of these types
28
- type ClientOptionsForTestEnv,
29
- type TestEnvClientOptions,
30
- type TimeSkippingWorkflowClientOptions,
31
- TestEnvClient,
32
- TimeSkippingWorkflowClient,
33
- } from './client';
26
+ export { type ClientOptionsForTestEnv, TimeSkippingWorkflowClient } from './client';
34
27
 
35
28
  export {
36
29
  type MockActivityEnvironmentOptions,
@@ -12,6 +12,7 @@ import {
12
12
  ActivityCancellationDetails,
13
13
  } from '@temporalio/common';
14
14
  import { LoggerWithComposedMetadata } from '@temporalio/common/lib/logger';
15
+ import { Client } from '@temporalio/client';
15
16
  import { ActivityInterceptorsFactory, DefaultLogger } from '@temporalio/worker';
16
17
  import { Activity, CancelReason } from '@temporalio/worker/lib/activity';
17
18
 
@@ -19,6 +20,7 @@ export interface MockActivityEnvironmentOptions {
19
20
  interceptors?: ActivityInterceptorsFactory[];
20
21
  logger?: Logger;
21
22
  metricMeter?: MetricMeter;
23
+ client?: Client;
22
24
  }
23
25
 
24
26
  /**
@@ -48,6 +50,7 @@ export class MockActivityEnvironment extends events.EventEmitter {
48
50
  undefined,
49
51
  loadedDataConverter,
50
52
  heartbeatCallback,
53
+ opts?.client,
51
54
  LoggerWithComposedMetadata.compose(opts?.logger ?? new DefaultLogger(), { sdkComponent: SdkComponent.worker }),
52
55
  opts?.metricMeter ?? noopMetricMeter,
53
56
  opts?.interceptors ?? []
@@ -93,4 +96,5 @@ export const defaultActivityInfo: activity.Info = {
93
96
  scheduleToCloseTimeoutMs: 1000,
94
97
  currentAttemptScheduledTimestampMs: 1,
95
98
  priority: undefined,
99
+ retryPolicy: undefined,
96
100
  };
@@ -1,13 +1,17 @@
1
1
  import 'abort-controller/polyfill'; // eslint-disable-line import/no-unassigned-import
2
- import { AsyncCompletionClient, Client, WorkflowClient } from '@temporalio/client';
2
+ import { AsyncCompletionClient, Client, Connection, WorkflowClient } from '@temporalio/client';
3
+ import {
4
+ ConnectionOptions,
5
+ InternalConnectionOptions,
6
+ InternalConnectionOptionsSymbol,
7
+ } from '@temporalio/client/lib/connection';
3
8
  import { Duration, TypedSearchAttributes } from '@temporalio/common';
4
9
  import { msToNumber, msToTs, tsToMs } from '@temporalio/common/lib/time';
5
- import { NativeConnection, Runtime } from '@temporalio/worker';
10
+ import { NativeConnection, NativeConnectionOptions, Runtime } from '@temporalio/worker';
6
11
  import { native } from '@temporalio/core-bridge';
7
12
  import { filterNullAndUndefined } from '@temporalio/common/lib/internal-workflow';
8
- import { Connection } from './connection';
9
13
  import { toNativeEphemeralServerConfig, DevServerConfig, TimeSkippingServerConfig } from './ephemeral-server';
10
- import { ClientOptionsForTestEnv, TestEnvClient } from './client';
14
+ import { ClientOptionsForTestEnv, TimeSkippingClient } from './client';
11
15
 
12
16
  /**
13
17
  * Options for {@link TestWorkflowEnvironment.createLocal}
@@ -54,7 +58,7 @@ export class TestWorkflowEnvironment {
54
58
  public readonly connection: Connection;
55
59
 
56
60
  /**
57
- * A {@link TestEnvClient} for interacting with the ephemeral server
61
+ * A {@link TimeSkippingClient} for interacting with the ephemeral server
58
62
  */
59
63
  public readonly client: Client;
60
64
 
@@ -91,12 +95,17 @@ export class TestWorkflowEnvironment {
91
95
  this.connection = connection;
92
96
  this.nativeConnection = nativeConnection;
93
97
  this.namespace = namespace;
94
- this.client = new TestEnvClient({
95
- connection,
96
- namespace: this.namespace,
97
- enableTimeSkipping: supportsTimeSkipping,
98
- ...options.client,
99
- });
98
+ this.client = supportsTimeSkipping
99
+ ? new TimeSkippingClient({
100
+ connection,
101
+ namespace: this.namespace,
102
+ ...options.client,
103
+ })
104
+ : new Client({
105
+ connection,
106
+ namespace: this.namespace,
107
+ ...options.client,
108
+ });
100
109
  this.asyncCompletionClient = this.client.activity; // eslint-disable-line deprecation/deprecation
101
110
  this.workflowClient = this.client.workflow; // eslint-disable-line deprecation/deprecation
102
111
  }
@@ -220,8 +229,14 @@ export class TestWorkflowEnvironment {
220
229
  server = 'existing';
221
230
  }
222
231
 
223
- const nativeConnection = await NativeConnection.connect({ address });
224
- const connection = await Connection.connect({ address });
232
+ const nativeConnection = await NativeConnection.connect(<NativeConnectionOptions & InternalConnectionOptions>{
233
+ address,
234
+ [InternalConnectionOptionsSymbol]: { supportsTestService: supportsTimeSkipping },
235
+ });
236
+ const connection = await Connection.connect(<ConnectionOptions & InternalConnectionOptions>{
237
+ address,
238
+ [InternalConnectionOptionsSymbol]: { supportsTestService: supportsTimeSkipping },
239
+ });
225
240
 
226
241
  return new this(runtime, optsWithDefaults, supportsTimeSkipping, server, connection, nativeConnection, namespace);
227
242
  }
@@ -292,7 +307,7 @@ export class TestWorkflowEnvironment {
292
307
  */
293
308
  sleep = async (durationMs: Duration): Promise<void> => {
294
309
  if (this.supportsTimeSkipping) {
295
- await (this.connection as Connection).testService.unlockTimeSkippingWithSleep({ duration: msToTs(durationMs) });
310
+ await this.connection.testService!.unlockTimeSkippingWithSleep({ duration: msToTs(durationMs) });
296
311
  } else {
297
312
  await new Promise((resolve) => setTimeout(resolve, msToNumber(durationMs)));
298
313
  }
@@ -306,7 +321,7 @@ export class TestWorkflowEnvironment {
306
321
  */
307
322
  async currentTimeMs(): Promise<number> {
308
323
  if (this.supportsTimeSkipping) {
309
- const { time } = await (this.connection as Connection).testService.getCurrentTime({});
324
+ const { time } = await this.connection.testService!.getCurrentTime({});
310
325
  return tsToMs(time);
311
326
  } else {
312
327
  return Date.now();
@@ -1,19 +0,0 @@
1
- import { Connection as BaseConnection, ConnectionOptions } from '@temporalio/client';
2
- import { ConnectionCtorOptions as BaseConnectionCtorOptions } from '@temporalio/client/lib/connection';
3
- import { temporal } from '@temporalio/proto';
4
- export type TestService = temporal.api.testservice.v1.TestService;
5
- export declare const TestService: typeof temporal.api.testservice.v1.TestService;
6
- interface ConnectionCtorOptions extends BaseConnectionCtorOptions {
7
- testService: TestService;
8
- }
9
- /**
10
- * A Connection class that can be used to interact with both the test server's TestService and WorkflowService
11
- */
12
- export declare class Connection extends BaseConnection {
13
- readonly testService: TestService;
14
- protected static createCtorOptions(options?: ConnectionOptions): ConnectionCtorOptions;
15
- static lazy(options?: ConnectionOptions): Connection;
16
- static connect(options?: ConnectionOptions): Promise<Connection>;
17
- protected constructor(options: ConnectionCtorOptions);
18
- }
19
- export {};
package/lib/connection.js DELETED
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Connection = exports.TestService = void 0;
4
- const client_1 = require("@temporalio/client");
5
- const proto_1 = require("@temporalio/proto");
6
- exports.TestService = proto_1.temporal.api.testservice.v1.TestService;
7
- /**
8
- * A Connection class that can be used to interact with both the test server's TestService and WorkflowService
9
- */
10
- class Connection extends client_1.Connection {
11
- testService;
12
- static createCtorOptions(options) {
13
- const ctorOptions = client_1.Connection.createCtorOptions(options);
14
- const rpcImpl = this.generateRPCImplementation({
15
- serviceName: 'temporal.api.testservice.v1.TestService',
16
- client: ctorOptions.client,
17
- callContextStorage: ctorOptions.callContextStorage,
18
- interceptors: ctorOptions.options.interceptors,
19
- staticMetadata: ctorOptions.options.metadata,
20
- apiKeyFnRef: {},
21
- });
22
- const testService = exports.TestService.create(rpcImpl, false, false);
23
- return { ...ctorOptions, testService };
24
- }
25
- static lazy(options) {
26
- const ctorOptions = this.createCtorOptions(options);
27
- return new this(ctorOptions);
28
- }
29
- static async connect(options) {
30
- const ret = this.lazy(options);
31
- await ret.ensureConnected();
32
- return ret;
33
- }
34
- constructor(options) {
35
- super(options);
36
- this.testService = options.testService;
37
- }
38
- }
39
- exports.Connection = Connection;
40
- //# sourceMappingURL=connection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;AAAA,+CAAqF;AAErF,6CAA6C;AAG9B,mBAAW,GAAK,gBAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,aAAC;AAM3D;;GAEG;AACH,MAAa,UAAW,SAAQ,mBAAc;IAC5B,WAAW,CAAc;IAE/B,MAAM,CAAC,iBAAiB,CAAC,OAA2B;QAC5D,MAAM,WAAW,GAAG,mBAAc,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,yBAAyB,CAAC;YAC7C,WAAW,EAAE,yCAAyC;YACtD,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,kBAAkB,EAAE,WAAW,CAAC,kBAAkB;YAClD,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC,YAAY;YAC9C,cAAc,EAAE,WAAW,CAAC,OAAO,CAAC,QAAQ;YAC5C,WAAW,EAAE,EAAE;SAChB,CAAC,CAAC;QACH,MAAM,WAAW,GAAG,mBAAW,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC9D,OAAO,EAAE,GAAG,WAAW,EAAE,WAAW,EAAE,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAA2B;QACrC,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACpD,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAA2B;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/B,MAAM,GAAG,CAAC,eAAe,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAC;IACb,CAAC;IAED,YAAsB,OAA8B;QAClD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;CACF;AAhCD,gCAgCC"}
package/src/connection.ts DELETED
@@ -1,47 +0,0 @@
1
- import { Connection as BaseConnection, ConnectionOptions } from '@temporalio/client';
2
- import { ConnectionCtorOptions as BaseConnectionCtorOptions } from '@temporalio/client/lib/connection';
3
- import { temporal } from '@temporalio/proto';
4
-
5
- export type TestService = temporal.api.testservice.v1.TestService;
6
- export const { TestService } = temporal.api.testservice.v1;
7
-
8
- interface ConnectionCtorOptions extends BaseConnectionCtorOptions {
9
- testService: TestService;
10
- }
11
-
12
- /**
13
- * A Connection class that can be used to interact with both the test server's TestService and WorkflowService
14
- */
15
- export class Connection extends BaseConnection {
16
- public readonly testService: TestService;
17
-
18
- protected static createCtorOptions(options?: ConnectionOptions): ConnectionCtorOptions {
19
- const ctorOptions = BaseConnection.createCtorOptions(options);
20
- const rpcImpl = this.generateRPCImplementation({
21
- serviceName: 'temporal.api.testservice.v1.TestService',
22
- client: ctorOptions.client,
23
- callContextStorage: ctorOptions.callContextStorage,
24
- interceptors: ctorOptions.options.interceptors,
25
- staticMetadata: ctorOptions.options.metadata,
26
- apiKeyFnRef: {},
27
- });
28
- const testService = TestService.create(rpcImpl, false, false);
29
- return { ...ctorOptions, testService };
30
- }
31
-
32
- static lazy(options?: ConnectionOptions): Connection {
33
- const ctorOptions = this.createCtorOptions(options);
34
- return new this(ctorOptions);
35
- }
36
-
37
- static async connect(options?: ConnectionOptions): Promise<Connection> {
38
- const ret = this.lazy(options);
39
- await ret.ensureConnected();
40
- return ret;
41
- }
42
-
43
- protected constructor(options: ConnectionCtorOptions) {
44
- super(options);
45
- this.testService = options.testService;
46
- }
47
- }