@opentap/runner-client 3.4.0 → 4.1.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.
@@ -6,6 +6,9 @@ interface BaseClientRequestOptions {
6
6
  rawResponse?: boolean;
7
7
  fullSubject?: boolean;
8
8
  timeout?: number;
9
+ headers?: {
10
+ [key: string]: string;
11
+ };
9
12
  }
10
13
  export declare class BaseClient {
11
14
  readonly baseSubject: string;
@@ -20,12 +20,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  });
21
21
  };
22
22
  var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
29
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
30
  if (y = 0, t) op = [op[0] & 2, t.value];
31
31
  switch (op[0]) {
@@ -113,10 +113,10 @@ var BaseClient = /** @class */ (function () {
113
113
  * @returns Promise of an object
114
114
  */
115
115
  BaseClient.prototype.request = function (subject, payload, options) {
116
- var _a, _b, _c, _d;
117
116
  return __awaiter(this, void 0, void 0, function () {
118
117
  var data, headers, timeout, replySubject, serverMaxPayload, chunkSize, requestId, opts, fileDescriptor, chunkNumber, getChunk, subscription, responsePromise, chunk, i;
119
118
  var _this = this;
119
+ var _a, _b, _c, _d;
120
120
  return __generator(this, function (_e) {
121
121
  // Prepend the base subject if the given subject does not start with that
122
122
  if (!(options === null || options === void 0 ? void 0 : options.fullSubject)) {
@@ -128,6 +128,12 @@ var BaseClient = /** @class */ (function () {
128
128
  return [2 /*return*/, Promise.reject("".concat(subject, ": Connection has been closed! Please reconnect!"))];
129
129
  data = this.encode(payload);
130
130
  headers = this.buildHeaders();
131
+ if (options === null || options === void 0 ? void 0 : options.headers) {
132
+ Object.entries(options.headers).forEach(function (_a) {
133
+ var key = _a[0], value = _a[1];
134
+ return headers.append(key, value);
135
+ });
136
+ }
131
137
  timeout = (options === null || options === void 0 ? void 0 : options.timeout) || this.timeout;
132
138
  replySubject = (_b = (_a = options === null || options === void 0 ? void 0 : options.publishOptions) === null || _a === void 0 ? void 0 : _a.reply) !== null && _b !== void 0 ? _b : "".concat(subject, ".Reply.").concat((0, uuid_1.v4)());
133
139
  serverMaxPayload = (_d = (_c = this.connection) === null || _c === void 0 ? void 0 : _c.info) === null || _d === void 0 ? void 0 : _d.max_payload;
@@ -251,7 +257,8 @@ var BaseClient = /** @class */ (function () {
251
257
  BaseClient.prototype.buildHeaders = function () {
252
258
  var _a;
253
259
  var _headers = (0, nats_ws_1.headers)();
254
- this._accessToken && _headers.set('Authorization', this._accessToken);
260
+ if (this._accessToken)
261
+ _headers.set('Authorization', this._accessToken);
255
262
  (_a = this.domainAccess) === null || _a === void 0 ? void 0 : _a.forEach(function (value, key) { return _headers.append('DomainAuthorization', "".concat(key, "|").concat(value)); });
256
263
  Object.entries(this._headers).forEach(function (_a) {
257
264
  var key = _a[0], value = _a[1];
@@ -343,9 +350,9 @@ var BaseClient = /** @class */ (function () {
343
350
  * Close the connection.
344
351
  */
345
352
  BaseClient.prototype.close = function () {
346
- var _a;
347
353
  return __awaiter(this, void 0, void 0, function () {
348
354
  var _this = this;
355
+ var _a;
349
356
  return __generator(this, function (_b) {
350
357
  switch (_b.label) {
351
358
  case 0:
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export declare class Image implements IImage {
3
2
  name?: string | undefined;
4
3
  packages?: PackageSpecifier[];
@@ -377,7 +376,7 @@ export declare class DataGridReferenceControl extends Setting implements IDataGr
377
376
  static fromJS(data: any): DataGridReferenceControl;
378
377
  toJSON(data?: any): any;
379
378
  }
380
- export declare type IDataGridReferenceControl = ISetting;
379
+ export type IDataGridReferenceControl = ISetting;
381
380
  export declare class DataGridControl extends Setting implements IDataGridControl {
382
381
  items?: Setting[][] | undefined;
383
382
  fixedSize?: boolean;
@@ -598,7 +597,7 @@ export declare class RepositorySettingsPackageDefinition extends RepositoryPacka
598
597
  static fromJS(data: any): RepositorySettingsPackageDefinition;
599
598
  toJSON(data?: any): any;
600
599
  }
601
- export declare type IRepositorySettingsPackageDefinition = IRepositoryPackageDefinition;
600
+ export type IRepositorySettingsPackageDefinition = IRepositoryPackageDefinition;
602
601
  export declare class GetTestPlanReferenceResponse implements IGetTestPlanReferenceResponse {
603
602
  testPlanReference?: RepositoryPackageReference | undefined;
604
603
  constructor(data?: IGetTestPlanReferenceResponse);
@@ -662,7 +661,7 @@ export declare class SessionStartInitiated extends SessionEventArgs implements I
662
661
  static fromJS(data: any): SessionStartInitiated;
663
662
  toJSON(data?: any): any;
664
663
  }
665
- export declare type ISessionStartInitiated = ISessionEventArgs;
664
+ export type ISessionStartInitiated = ISessionEventArgs;
666
665
  export declare class SessionStarted extends SessionEventArgs implements ISessionStarted {
667
666
  session?: Session | undefined;
668
667
  constructor(data?: ISessionStarted);
@@ -689,14 +688,14 @@ export declare class SessionShutdownInitiated extends SessionEventArgs implement
689
688
  static fromJS(data: any): SessionShutdownInitiated;
690
689
  toJSON(data?: any): any;
691
690
  }
692
- export declare type ISessionShutdownInitiated = ISessionEventArgs;
691
+ export type ISessionShutdownInitiated = ISessionEventArgs;
693
692
  export declare class SessionShutdown extends SessionEventArgs implements ISessionShutdown {
694
693
  constructor(data?: ISessionShutdown);
695
694
  init(_data?: any): void;
696
695
  static fromJS(data: any): SessionShutdown;
697
696
  toJSON(data?: any): any;
698
697
  }
699
- export declare type ISessionShutdown = ISessionEventArgs;
698
+ export type ISessionShutdown = ISessionEventArgs;
700
699
  export declare class SessionShutdownFailed extends SessionEventArgs implements ISessionShutdownFailed {
701
700
  reason?: string | undefined;
702
701
  constructor(data?: ISessionShutdownFailed);
@@ -713,7 +712,7 @@ export declare class SessionInactivityLimitHit extends SessionEventArgs implemen
713
712
  static fromJS(data: any): SessionInactivityLimitHit;
714
713
  toJSON(data?: any): any;
715
714
  }
716
- export declare type ISessionInactivityLimitHit = ISessionEventArgs;
715
+ export type ISessionInactivityLimitHit = ISessionEventArgs;
717
716
  export declare class ImageEventArgs implements IImageEventArgs {
718
717
  imageId?: string | undefined;
719
718
  protected _discriminator: string;
@@ -731,7 +730,7 @@ export declare class ImageCreating extends ImageEventArgs implements IImageCreat
731
730
  static fromJS(data: any): ImageCreating;
732
731
  toJSON(data?: any): any;
733
732
  }
734
- export declare type IImageCreating = IImageEventArgs;
733
+ export type IImageCreating = IImageEventArgs;
735
734
  export declare class ImageCreated extends ImageEventArgs implements IImageCreated {
736
735
  image?: Image | undefined;
737
736
  constructor(data?: IImageCreated);
@@ -833,6 +832,7 @@ export declare class RunStatus implements IRunStatus {
833
832
  failedToStart?: boolean;
834
833
  sessionState?: SessionState;
835
834
  executingSteps?: string[] | undefined;
835
+ createdAt?: string | undefined;
836
836
  constructor(data?: IRunStatus);
837
837
  init(_data?: any): void;
838
838
  static fromJS(data: any): RunStatus;
@@ -845,6 +845,7 @@ export interface IRunStatus {
845
845
  failedToStart?: boolean;
846
846
  sessionState?: SessionState;
847
847
  executingSteps?: string[] | undefined;
848
+ createdAt?: string | undefined;
848
849
  }
849
850
  export declare class EditStatus implements IEditStatus {
850
851
  undoBufferSize?: number;
@@ -938,7 +939,7 @@ export declare class TestStepCopy extends TestStep implements ITestStepCopy {
938
939
  static fromJS(data: any): TestStepCopy;
939
940
  toJSON(data?: any): any;
940
941
  }
941
- export declare type ITestStepCopy = ITestStep;
942
+ export type ITestStepCopy = ITestStep;
942
943
  export declare class TestStepValidationError implements ITestStepValidationError {
943
944
  stepId?: string | undefined;
944
945
  validationErrors?: ValidationError[] | undefined;
@@ -1049,7 +1050,7 @@ export interface IWatchDog {
1049
1050
  inactiveSeconds?: number;
1050
1051
  terminationTimeout?: number;
1051
1052
  }
1052
- export declare type IComponentSettingsIdentifier = IComponentSettingsBase;
1053
+ export type IComponentSettingsIdentifier = IComponentSettingsBase;
1053
1054
  export declare class TestStepRun implements ITestStepRun {
1054
1055
  parentId?: string | undefined;
1055
1056
  testStepId?: string | undefined;
@@ -1314,7 +1315,7 @@ export declare class UserInputRequestCompletedEvent extends SessionEvent {
1314
1315
  static fromJS(data: any): UserInputRequestCompletedEvent;
1315
1316
  toJSON(data?: any): any;
1316
1317
  }
1317
- export declare type ISessionEvent = SessionEvent;
1318
+ export type ISessionEvent = SessionEvent;
1318
1319
  export interface IOnTestPlanRun {
1319
1320
  status?: string;
1320
1321
  userId?: string;
@@ -1402,21 +1403,21 @@ export declare class RunnerEvent implements IRunnerEvent {
1402
1403
  static fromJS(data: any): RunnerEvent;
1403
1404
  toJSON(data?: any): any;
1404
1405
  }
1405
- export declare type IRunnerRegisteredEvent = IRunnerEvent;
1406
+ export type IRunnerRegisteredEvent = IRunnerEvent;
1406
1407
  export declare class RunnerRegisteredEvent extends RunnerEvent implements IRunnerRegisteredEvent {
1407
1408
  constructor(data?: IRunnerRegisteredEvent);
1408
1409
  init(_data?: any): void;
1409
1410
  static fromJS(data: any): RunnerRegisteredEvent;
1410
1411
  toJSON(data?: any): any;
1411
1412
  }
1412
- export declare type IRunnerUpdatedEvent = IRunnerEvent;
1413
+ export type IRunnerUpdatedEvent = IRunnerEvent;
1413
1414
  export declare class RunnerUpdatedEvent extends RunnerEvent implements IRunnerUpdatedEvent {
1414
1415
  constructor(data?: IRunnerUpdatedEvent);
1415
1416
  init(_data?: any): void;
1416
1417
  static fromJS(data: any): RunnerUpdatedEvent;
1417
1418
  toJSON(data?: any): any;
1418
1419
  }
1419
- export declare type IRunnerDeletedEvent = IRunnerEvent;
1420
+ export type IRunnerDeletedEvent = IRunnerEvent;
1420
1421
  export declare class RunnerDeletedEvent extends RunnerEvent implements IRunnerDeletedEvent {
1421
1422
  constructor(data?: IRunnerDeletedEvent);
1422
1423
  init(_data?: any): void;
package/dist/cjs/DTOs.js CHANGED
@@ -330,7 +330,7 @@ var DisplayMode;
330
330
  (function (DisplayMode) {
331
331
  DisplayMode["MasterDetail"] = "MasterDetail";
332
332
  DisplayMode["DataGrid"] = "DataGrid";
333
- })(DisplayMode = exports.DisplayMode || (exports.DisplayMode = {}));
333
+ })(DisplayMode || (exports.DisplayMode = DisplayMode = {}));
334
334
  var ComponentSettingsList = /** @class */ (function (_super) {
335
335
  __extends(ComponentSettingsList, _super);
336
336
  function ComponentSettingsList(data) {
@@ -634,7 +634,7 @@ var LayoutMode;
634
634
  LayoutMode["Normal"] = "Normal";
635
635
  LayoutMode["FullRow"] = "FullRow";
636
636
  LayoutMode["FloatBottom"] = "FloatBottom";
637
- })(LayoutMode = exports.LayoutMode || (exports.LayoutMode = {}));
637
+ })(LayoutMode || (exports.LayoutMode = LayoutMode = {}));
638
638
  var ColumnDisplayName = /** @class */ (function () {
639
639
  function ColumnDisplayName(data) {
640
640
  if (data) {
@@ -2350,7 +2350,7 @@ var RunStatus = /** @class */ (function () {
2350
2350
  }
2351
2351
  }
2352
2352
  RunStatus.prototype.init = function (_data) {
2353
- var _a;
2353
+ var _a, _b;
2354
2354
  if (_data) {
2355
2355
  this.sessionId = _data['SessionId'];
2356
2356
  this.verdict = _data['Verdict'];
@@ -2359,11 +2359,12 @@ var RunStatus = /** @class */ (function () {
2359
2359
  this.sessionState = (_a = _data['SessionState']) !== null && _a !== void 0 ? _a : _data['sessionState'];
2360
2360
  if (Array.isArray(_data['ExecutingSteps'])) {
2361
2361
  this.executingSteps = [];
2362
- for (var _i = 0, _b = _data['ExecutingSteps']; _i < _b.length; _i++) {
2363
- var item = _b[_i];
2362
+ for (var _i = 0, _c = _data['ExecutingSteps']; _i < _c.length; _i++) {
2363
+ var item = _c[_i];
2364
2364
  this.executingSteps.push(item);
2365
2365
  }
2366
2366
  }
2367
+ this.createdAt = (_b = _data['CreatedAt']) !== null && _b !== void 0 ? _b : undefined;
2367
2368
  }
2368
2369
  };
2369
2370
  RunStatus.fromJS = function (data) {
@@ -2386,6 +2387,7 @@ var RunStatus = /** @class */ (function () {
2386
2387
  data['ExecutingSteps'].push(item);
2387
2388
  }
2388
2389
  }
2390
+ data['CreatedAt'] = this.createdAt;
2389
2391
  return data;
2390
2392
  };
2391
2393
  return RunStatus;
@@ -2433,7 +2435,7 @@ var Verdict;
2433
2435
  Verdict["Fail"] = "Fail";
2434
2436
  Verdict["Aborted"] = "Aborted";
2435
2437
  Verdict["Error"] = "Error";
2436
- })(Verdict = exports.Verdict || (exports.Verdict = {}));
2438
+ })(Verdict || (exports.Verdict = Verdict = {}));
2437
2439
  var SessionState;
2438
2440
  (function (SessionState) {
2439
2441
  SessionState["Idle"] = "Idle";
@@ -2442,7 +2444,7 @@ var SessionState;
2442
2444
  SessionState["Aborting"] = "Aborting";
2443
2445
  SessionState["WaitingForUserInput"] = "WaitingForUserInput";
2444
2446
  SessionState["Loading"] = "Loading";
2445
- })(SessionState = exports.SessionState || (exports.SessionState = {}));
2447
+ })(SessionState || (exports.SessionState = SessionState = {}));
2446
2448
  var TestPlan = /** @class */ (function () {
2447
2449
  function TestPlan(data) {
2448
2450
  if (data) {
@@ -3173,14 +3175,14 @@ var SessionMetricKind;
3173
3175
  SessionMetricKind["Poll"] = "Poll";
3174
3176
  SessionMetricKind["Push"] = "Push";
3175
3177
  SessionMetricKind["PushPoll"] = "PushPoll";
3176
- })(SessionMetricKind = exports.SessionMetricKind || (exports.SessionMetricKind = {}));
3178
+ })(SessionMetricKind || (exports.SessionMetricKind = SessionMetricKind = {}));
3177
3179
  var SessionMetricType;
3178
3180
  (function (SessionMetricType) {
3179
3181
  SessionMetricType["Unknown"] = "Unknown";
3180
3182
  SessionMetricType["Double"] = "Double";
3181
3183
  SessionMetricType["Boolean"] = "Boolean";
3182
3184
  SessionMetricType["String"] = "String";
3183
- })(SessionMetricType = exports.SessionMetricType || (exports.SessionMetricType = {}));
3185
+ })(SessionMetricType || (exports.SessionMetricType = SessionMetricType = {}));
3184
3186
  var MetricsPollRate;
3185
3187
  (function (MetricsPollRate) {
3186
3188
  MetricsPollRate["OneSecond"] = "OneSecond";
@@ -3194,7 +3196,7 @@ var MetricsPollRate;
3194
3196
  MetricsPollRate["TenMinutes"] = "TenMinutes";
3195
3197
  MetricsPollRate["FifteenMinutes"] = "FifteenMinutes";
3196
3198
  MetricsPollRate["OneHour"] = "OneHour";
3197
- })(MetricsPollRate = exports.MetricsPollRate || (exports.MetricsPollRate = {}));
3199
+ })(MetricsPollRate || (exports.MetricsPollRate = MetricsPollRate = {}));
3198
3200
  var SessionMetricInfo = /** @class */ (function () {
3199
3201
  function SessionMetricInfo(data) {
3200
3202
  this.attributes = [];
@@ -3324,7 +3326,7 @@ var SessionEventName;
3324
3326
  SessionEventName["Break"] = "Break";
3325
3327
  SessionEventName["UserInputRequested"] = "UserInputRequested";
3326
3328
  SessionEventName["UserInputRequestCompleted"] = "UserInputRequestCompleted";
3327
- })(SessionEventName = exports.SessionEventName || (exports.SessionEventName = {}));
3329
+ })(SessionEventName || (exports.SessionEventName = SessionEventName = {}));
3328
3330
  var SessionEvent = /** @class */ (function () {
3329
3331
  function SessionEvent(eventName) {
3330
3332
  this.eventName = eventName;
@@ -54,9 +54,10 @@ export declare class RunnerClient extends BaseClient {
54
54
  /**
55
55
  * Shut down a session
56
56
  * @param sessionId the ID of the session to shut down
57
+ * @param force When true, the Runner terminates the session subprocess immediately without attempting a graceful shutdown.
57
58
  * @returns {{Promise<void>}}
58
59
  */
59
- shutdownSession(sessionId: string): Promise<void>;
60
+ shutdownSession(sessionId: string, force?: boolean): Promise<void>;
60
61
  /**
61
62
  * Start a session
62
63
  * @returns {{Promise<Session>}}
@@ -35,12 +35,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
35
35
  });
36
36
  };
37
37
  var __generator = (this && this.__generator) || function (thisArg, body) {
38
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
39
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
40
  function verb(n) { return function (v) { return step([n, v]); }; }
41
41
  function step(op) {
42
42
  if (f) throw new TypeError("Generator is already executing.");
43
- while (_) try {
43
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
44
44
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
45
  if (y = 0, t) op = [op[0] & 2, t.value];
46
46
  switch (op[0]) {
@@ -221,11 +221,15 @@ var RunnerClient = /** @class */ (function (_super) {
221
221
  /**
222
222
  * Shut down a session
223
223
  * @param sessionId the ID of the session to shut down
224
+ * @param force When true, the Runner terminates the session subprocess immediately without attempting a graceful shutdown.
224
225
  * @returns {{Promise<void>}}
225
226
  */
226
- RunnerClient.prototype.shutdownSession = function (sessionId) {
227
+ RunnerClient.prototype.shutdownSession = function (sessionId, force) {
228
+ if (force === void 0) { force = false; }
227
229
  return (sessionId === null || sessionId === void 0 ? void 0 : sessionId.length) > 0
228
- ? this.request('ShutdownSession', sessionId).then(this.success()).catch(this.error())
230
+ ? this.request('ShutdownSession', sessionId, force ? { headers: { Force: 'true' } } : undefined)
231
+ .then(this.success())
232
+ .catch(this.error())
229
233
  : Promise.reject('sessionId is not defined');
230
234
  };
231
235
  /**
@@ -314,19 +318,19 @@ var RunnerClient = /** @class */ (function (_super) {
314
318
  (function () { return __awaiter(_this, void 0, void 0, function () {
315
319
  var consumerInfo, numberPending, _loop_1, state_1;
316
320
  var _this = this;
317
- var e_1, _a;
318
- return __generator(this, function (_b) {
319
- switch (_b.label) {
321
+ var _a, e_1, _b, _c;
322
+ return __generator(this, function (_d) {
323
+ switch (_d.label) {
320
324
  case 0: return [4 /*yield*/, consumer.info()];
321
325
  case 1:
322
- consumerInfo = _b.sent();
326
+ consumerInfo = _d.sent();
323
327
  numberPending = consumerInfo.num_pending;
324
328
  _loop_1 = function () {
325
- var arraySize, metricData_1, messages, index, messages_1, messages_1_1, message, e_1_1, error_1;
326
- return __generator(this, function (_c) {
327
- switch (_c.label) {
329
+ var arraySize, metricData_1, messages, index, _e, messages_1, messages_1_1, message, e_1_1, _f;
330
+ return __generator(this, function (_g) {
331
+ switch (_g.label) {
328
332
  case 0:
329
- _c.trys.push([0, 14, , 15]);
333
+ _g.trys.push([0, 14, , 15]);
330
334
  arraySize = Math.max(Math.min(maxBatchSize, numberPending), 1);
331
335
  metricData_1 = {
332
336
  encodedMetrics: new Array(arraySize),
@@ -334,17 +338,19 @@ var RunnerClient = /** @class */ (function (_super) {
334
338
  };
335
339
  return [4 /*yield*/, consumer.fetch({ max_messages: arraySize })];
336
340
  case 1:
337
- messages = _c.sent();
341
+ messages = _g.sent();
338
342
  index = 0;
339
- _c.label = 2;
343
+ _g.label = 2;
340
344
  case 2:
341
- _c.trys.push([2, 7, 8, 13]);
342
- messages_1 = (e_1 = void 0, __asyncValues(messages));
343
- _c.label = 3;
345
+ _g.trys.push([2, 7, 8, 13]);
346
+ _e = true, messages_1 = (e_1 = void 0, __asyncValues(messages));
347
+ _g.label = 3;
344
348
  case 3: return [4 /*yield*/, messages_1.next()];
345
349
  case 4:
346
- if (!(messages_1_1 = _c.sent(), !messages_1_1.done)) return [3 /*break*/, 6];
347
- message = messages_1_1.value;
350
+ if (!(messages_1_1 = _g.sent(), _a = messages_1_1.done, !_a)) return [3 /*break*/, 6];
351
+ _c = messages_1_1.value;
352
+ _e = false;
353
+ message = _c;
348
354
  // Store the message data and timestamp
349
355
  metricData_1.encodedMetrics[index] = message.data;
350
356
  metricData_1.timestamps[index] = message.info.timestampNanos;
@@ -355,20 +361,22 @@ var RunnerClient = /** @class */ (function (_super) {
355
361
  }
356
362
  // Increment the index
357
363
  index++;
358
- _c.label = 5;
359
- case 5: return [3 /*break*/, 3];
364
+ _g.label = 5;
365
+ case 5:
366
+ _e = true;
367
+ return [3 /*break*/, 3];
360
368
  case 6: return [3 /*break*/, 13];
361
369
  case 7:
362
- e_1_1 = _c.sent();
370
+ e_1_1 = _g.sent();
363
371
  e_1 = { error: e_1_1 };
364
372
  return [3 /*break*/, 13];
365
373
  case 8:
366
- _c.trys.push([8, , 11, 12]);
367
- if (!(messages_1_1 && !messages_1_1.done && (_a = messages_1.return))) return [3 /*break*/, 10];
368
- return [4 /*yield*/, _a.call(messages_1)];
374
+ _g.trys.push([8, , 11, 12]);
375
+ if (!(!_e && !_a && (_b = messages_1.return))) return [3 /*break*/, 10];
376
+ return [4 /*yield*/, _b.call(messages_1)];
369
377
  case 9:
370
- _c.sent();
371
- _c.label = 10;
378
+ _g.sent();
379
+ _g.label = 10;
372
380
  case 10: return [3 /*break*/, 12];
373
381
  case 11:
374
382
  if (e_1) throw e_1.error;
@@ -380,18 +388,18 @@ var RunnerClient = /** @class */ (function (_super) {
380
388
  }); }); })();
381
389
  return [3 /*break*/, 15];
382
390
  case 14:
383
- error_1 = _c.sent();
391
+ _f = _g.sent();
384
392
  return [2 /*return*/, "break"];
385
393
  case 15: return [2 /*return*/];
386
394
  }
387
395
  });
388
396
  };
389
- _b.label = 2;
397
+ _d.label = 2;
390
398
  case 2:
391
399
  if (!!isCloseInitiated) return [3 /*break*/, 4];
392
400
  return [5 /*yield**/, _loop_1()];
393
401
  case 3:
394
- state_1 = _b.sent();
402
+ state_1 = _d.sent();
395
403
  if (state_1 === "break")
396
404
  return [3 /*break*/, 4];
397
405
  return [3 /*break*/, 2];
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BooleanCodec = exports.NumberCodec = exports.jsonCodec = exports.stringCodec = exports.booleanCodec = exports.numberCodec = void 0;
3
+ exports.jsonCodec = exports.stringCodec = exports.booleanCodec = exports.numberCodec = void 0;
4
+ exports.NumberCodec = NumberCodec;
5
+ exports.BooleanCodec = BooleanCodec;
4
6
  var nats_ws_1 = require("nats.ws");
5
7
  exports.numberCodec = NumberCodec();
6
8
  exports.booleanCodec = BooleanCodec();
@@ -18,7 +20,6 @@ function NumberCodec() {
18
20
  },
19
21
  };
20
22
  }
21
- exports.NumberCodec = NumberCodec;
22
23
  function BooleanCodec() {
23
24
  return {
24
25
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -30,4 +31,3 @@ function BooleanCodec() {
30
31
  },
31
32
  };
32
33
  }
33
- exports.BooleanCodec = BooleanCodec;
@@ -6,6 +6,9 @@ interface BaseClientRequestOptions {
6
6
  rawResponse?: boolean;
7
7
  fullSubject?: boolean;
8
8
  timeout?: number;
9
+ headers?: {
10
+ [key: string]: string;
11
+ };
9
12
  }
10
13
  export declare class BaseClient {
11
14
  readonly baseSubject: string;
@@ -17,14 +17,6 @@ var Events;
17
17
  Events["ERROR"] = "error_event";
18
18
  })(Events || (Events = {}));
19
19
  export class BaseClient {
20
- constructor(baseSubject, options) {
21
- this.domainAccess = new Map();
22
- this._headers = {};
23
- this.baseSubject = baseSubject;
24
- this.connectionOptions = Object.assign({}, options);
25
- this.connectionOptions.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || DEFAULT_TIMEOUT;
26
- this.eventEmitter = new EventEmitter();
27
- }
28
20
  /** Get request access token */
29
21
  get accessToken() {
30
22
  return this._accessToken;
@@ -49,6 +41,14 @@ export class BaseClient {
49
41
  set timeout(value) {
50
42
  this._timeout = value;
51
43
  }
44
+ constructor(baseSubject, options) {
45
+ this.domainAccess = new Map();
46
+ this._headers = {};
47
+ this.baseSubject = baseSubject;
48
+ this.connectionOptions = Object.assign({}, options);
49
+ this.connectionOptions.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || DEFAULT_TIMEOUT;
50
+ this.eventEmitter = new EventEmitter();
51
+ }
52
52
  withTimeout(promise, timeout) {
53
53
  return Promise.race([promise, new Promise((_, reject) => setTimeout(() => reject(new Error(ErrorCode.Timeout)), timeout))]);
54
54
  }
@@ -60,8 +60,8 @@ export class BaseClient {
60
60
  * @returns Promise of an object
61
61
  */
62
62
  request(subject, payload, options) {
63
- var _a, _b, _c, _d;
64
63
  return __awaiter(this, void 0, void 0, function* () {
64
+ var _a, _b, _c, _d;
65
65
  // Prepend the base subject if the given subject does not start with that
66
66
  if (!(options === null || options === void 0 ? void 0 : options.fullSubject)) {
67
67
  subject = `${this.baseSubject}.Request.${subject}`;
@@ -72,6 +72,9 @@ export class BaseClient {
72
72
  return Promise.reject(`${subject}: Connection has been closed! Please reconnect!`);
73
73
  const data = this.encode(payload);
74
74
  const headers = this.buildHeaders();
75
+ if (options === null || options === void 0 ? void 0 : options.headers) {
76
+ Object.entries(options.headers).forEach(([key, value]) => headers.append(key, value));
77
+ }
75
78
  const timeout = (options === null || options === void 0 ? void 0 : options.timeout) || this.timeout;
76
79
  // Generate a unique reply subject that we can subscribe to
77
80
  const replySubject = (_b = (_a = options === null || options === void 0 ? void 0 : options.publishOptions) === null || _a === void 0 ? void 0 : _a.reply) !== null && _b !== void 0 ? _b : `${subject}.Reply.${uuidv4()}`;
@@ -208,7 +211,8 @@ export class BaseClient {
208
211
  buildHeaders() {
209
212
  var _a;
210
213
  const _headers = headers();
211
- this._accessToken && _headers.set('Authorization', this._accessToken);
214
+ if (this._accessToken)
215
+ _headers.set('Authorization', this._accessToken);
212
216
  (_a = this.domainAccess) === null || _a === void 0 ? void 0 : _a.forEach((value, key) => _headers.append('DomainAuthorization', `${key}|${value}`));
213
217
  Object.entries(this._headers).forEach(([key, value]) => _headers.append(key, value));
214
218
  return _headers;
@@ -279,8 +283,8 @@ export class BaseClient {
279
283
  * Close the connection.
280
284
  */
281
285
  close() {
282
- var _a;
283
286
  return __awaiter(this, void 0, void 0, function* () {
287
+ var _a;
284
288
  if (this.connection) {
285
289
  yield ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.close().then(() => {
286
290
  this.connection = null;
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  export declare class Image implements IImage {
3
2
  name?: string | undefined;
4
3
  packages?: PackageSpecifier[];
@@ -377,7 +376,7 @@ export declare class DataGridReferenceControl extends Setting implements IDataGr
377
376
  static fromJS(data: any): DataGridReferenceControl;
378
377
  toJSON(data?: any): any;
379
378
  }
380
- export declare type IDataGridReferenceControl = ISetting;
379
+ export type IDataGridReferenceControl = ISetting;
381
380
  export declare class DataGridControl extends Setting implements IDataGridControl {
382
381
  items?: Setting[][] | undefined;
383
382
  fixedSize?: boolean;
@@ -598,7 +597,7 @@ export declare class RepositorySettingsPackageDefinition extends RepositoryPacka
598
597
  static fromJS(data: any): RepositorySettingsPackageDefinition;
599
598
  toJSON(data?: any): any;
600
599
  }
601
- export declare type IRepositorySettingsPackageDefinition = IRepositoryPackageDefinition;
600
+ export type IRepositorySettingsPackageDefinition = IRepositoryPackageDefinition;
602
601
  export declare class GetTestPlanReferenceResponse implements IGetTestPlanReferenceResponse {
603
602
  testPlanReference?: RepositoryPackageReference | undefined;
604
603
  constructor(data?: IGetTestPlanReferenceResponse);
@@ -662,7 +661,7 @@ export declare class SessionStartInitiated extends SessionEventArgs implements I
662
661
  static fromJS(data: any): SessionStartInitiated;
663
662
  toJSON(data?: any): any;
664
663
  }
665
- export declare type ISessionStartInitiated = ISessionEventArgs;
664
+ export type ISessionStartInitiated = ISessionEventArgs;
666
665
  export declare class SessionStarted extends SessionEventArgs implements ISessionStarted {
667
666
  session?: Session | undefined;
668
667
  constructor(data?: ISessionStarted);
@@ -689,14 +688,14 @@ export declare class SessionShutdownInitiated extends SessionEventArgs implement
689
688
  static fromJS(data: any): SessionShutdownInitiated;
690
689
  toJSON(data?: any): any;
691
690
  }
692
- export declare type ISessionShutdownInitiated = ISessionEventArgs;
691
+ export type ISessionShutdownInitiated = ISessionEventArgs;
693
692
  export declare class SessionShutdown extends SessionEventArgs implements ISessionShutdown {
694
693
  constructor(data?: ISessionShutdown);
695
694
  init(_data?: any): void;
696
695
  static fromJS(data: any): SessionShutdown;
697
696
  toJSON(data?: any): any;
698
697
  }
699
- export declare type ISessionShutdown = ISessionEventArgs;
698
+ export type ISessionShutdown = ISessionEventArgs;
700
699
  export declare class SessionShutdownFailed extends SessionEventArgs implements ISessionShutdownFailed {
701
700
  reason?: string | undefined;
702
701
  constructor(data?: ISessionShutdownFailed);
@@ -713,7 +712,7 @@ export declare class SessionInactivityLimitHit extends SessionEventArgs implemen
713
712
  static fromJS(data: any): SessionInactivityLimitHit;
714
713
  toJSON(data?: any): any;
715
714
  }
716
- export declare type ISessionInactivityLimitHit = ISessionEventArgs;
715
+ export type ISessionInactivityLimitHit = ISessionEventArgs;
717
716
  export declare class ImageEventArgs implements IImageEventArgs {
718
717
  imageId?: string | undefined;
719
718
  protected _discriminator: string;
@@ -731,7 +730,7 @@ export declare class ImageCreating extends ImageEventArgs implements IImageCreat
731
730
  static fromJS(data: any): ImageCreating;
732
731
  toJSON(data?: any): any;
733
732
  }
734
- export declare type IImageCreating = IImageEventArgs;
733
+ export type IImageCreating = IImageEventArgs;
735
734
  export declare class ImageCreated extends ImageEventArgs implements IImageCreated {
736
735
  image?: Image | undefined;
737
736
  constructor(data?: IImageCreated);
@@ -833,6 +832,7 @@ export declare class RunStatus implements IRunStatus {
833
832
  failedToStart?: boolean;
834
833
  sessionState?: SessionState;
835
834
  executingSteps?: string[] | undefined;
835
+ createdAt?: string | undefined;
836
836
  constructor(data?: IRunStatus);
837
837
  init(_data?: any): void;
838
838
  static fromJS(data: any): RunStatus;
@@ -845,6 +845,7 @@ export interface IRunStatus {
845
845
  failedToStart?: boolean;
846
846
  sessionState?: SessionState;
847
847
  executingSteps?: string[] | undefined;
848
+ createdAt?: string | undefined;
848
849
  }
849
850
  export declare class EditStatus implements IEditStatus {
850
851
  undoBufferSize?: number;
@@ -938,7 +939,7 @@ export declare class TestStepCopy extends TestStep implements ITestStepCopy {
938
939
  static fromJS(data: any): TestStepCopy;
939
940
  toJSON(data?: any): any;
940
941
  }
941
- export declare type ITestStepCopy = ITestStep;
942
+ export type ITestStepCopy = ITestStep;
942
943
  export declare class TestStepValidationError implements ITestStepValidationError {
943
944
  stepId?: string | undefined;
944
945
  validationErrors?: ValidationError[] | undefined;
@@ -1049,7 +1050,7 @@ export interface IWatchDog {
1049
1050
  inactiveSeconds?: number;
1050
1051
  terminationTimeout?: number;
1051
1052
  }
1052
- export declare type IComponentSettingsIdentifier = IComponentSettingsBase;
1053
+ export type IComponentSettingsIdentifier = IComponentSettingsBase;
1053
1054
  export declare class TestStepRun implements ITestStepRun {
1054
1055
  parentId?: string | undefined;
1055
1056
  testStepId?: string | undefined;
@@ -1314,7 +1315,7 @@ export declare class UserInputRequestCompletedEvent extends SessionEvent {
1314
1315
  static fromJS(data: any): UserInputRequestCompletedEvent;
1315
1316
  toJSON(data?: any): any;
1316
1317
  }
1317
- export declare type ISessionEvent = SessionEvent;
1318
+ export type ISessionEvent = SessionEvent;
1318
1319
  export interface IOnTestPlanRun {
1319
1320
  status?: string;
1320
1321
  userId?: string;
@@ -1402,21 +1403,21 @@ export declare class RunnerEvent implements IRunnerEvent {
1402
1403
  static fromJS(data: any): RunnerEvent;
1403
1404
  toJSON(data?: any): any;
1404
1405
  }
1405
- export declare type IRunnerRegisteredEvent = IRunnerEvent;
1406
+ export type IRunnerRegisteredEvent = IRunnerEvent;
1406
1407
  export declare class RunnerRegisteredEvent extends RunnerEvent implements IRunnerRegisteredEvent {
1407
1408
  constructor(data?: IRunnerRegisteredEvent);
1408
1409
  init(_data?: any): void;
1409
1410
  static fromJS(data: any): RunnerRegisteredEvent;
1410
1411
  toJSON(data?: any): any;
1411
1412
  }
1412
- export declare type IRunnerUpdatedEvent = IRunnerEvent;
1413
+ export type IRunnerUpdatedEvent = IRunnerEvent;
1413
1414
  export declare class RunnerUpdatedEvent extends RunnerEvent implements IRunnerUpdatedEvent {
1414
1415
  constructor(data?: IRunnerUpdatedEvent);
1415
1416
  init(_data?: any): void;
1416
1417
  static fromJS(data: any): RunnerUpdatedEvent;
1417
1418
  toJSON(data?: any): any;
1418
1419
  }
1419
- export declare type IRunnerDeletedEvent = IRunnerEvent;
1420
+ export type IRunnerDeletedEvent = IRunnerEvent;
1420
1421
  export declare class RunnerDeletedEvent extends RunnerEvent implements IRunnerDeletedEvent {
1421
1422
  constructor(data?: IRunnerDeletedEvent);
1422
1423
  init(_data?: any): void;
package/dist/mjs/DTOs.js CHANGED
@@ -2057,7 +2057,7 @@ export class RunStatus {
2057
2057
  }
2058
2058
  }
2059
2059
  init(_data) {
2060
- var _a;
2060
+ var _a, _b;
2061
2061
  if (_data) {
2062
2062
  this.sessionId = _data['SessionId'];
2063
2063
  this.verdict = _data['Verdict'];
@@ -2069,6 +2069,7 @@ export class RunStatus {
2069
2069
  for (const item of _data['ExecutingSteps'])
2070
2070
  this.executingSteps.push(item);
2071
2071
  }
2072
+ this.createdAt = (_b = _data['CreatedAt']) !== null && _b !== void 0 ? _b : undefined;
2072
2073
  }
2073
2074
  }
2074
2075
  static fromJS(data) {
@@ -2089,6 +2090,7 @@ export class RunStatus {
2089
2090
  for (const item of this.executingSteps)
2090
2091
  data['ExecutingSteps'].push(item);
2091
2092
  }
2093
+ data['CreatedAt'] = this.createdAt;
2092
2094
  return data;
2093
2095
  }
2094
2096
  }
@@ -54,9 +54,10 @@ export declare class RunnerClient extends BaseClient {
54
54
  /**
55
55
  * Shut down a session
56
56
  * @param sessionId the ID of the session to shut down
57
+ * @param force When true, the Runner terminates the session subprocess immediately without attempting a graceful shutdown.
57
58
  * @returns {{Promise<void>}}
58
59
  */
59
- shutdownSession(sessionId: string): Promise<void>;
60
+ shutdownSession(sessionId: string, force?: boolean): Promise<void>;
60
61
  /**
61
62
  * Start a session
62
63
  * @returns {{Promise<Session>}}
@@ -161,11 +161,14 @@ export class RunnerClient extends BaseClient {
161
161
  /**
162
162
  * Shut down a session
163
163
  * @param sessionId the ID of the session to shut down
164
+ * @param force When true, the Runner terminates the session subprocess immediately without attempting a graceful shutdown.
164
165
  * @returns {{Promise<void>}}
165
166
  */
166
- shutdownSession(sessionId) {
167
+ shutdownSession(sessionId, force = false) {
167
168
  return (sessionId === null || sessionId === void 0 ? void 0 : sessionId.length) > 0
168
- ? this.request('ShutdownSession', sessionId).then(this.success()).catch(this.error())
169
+ ? this.request('ShutdownSession', sessionId, force ? { headers: { Force: 'true' } } : undefined)
170
+ .then(this.success())
171
+ .catch(this.error())
169
172
  : Promise.reject('sessionId is not defined');
170
173
  }
171
174
  /**
@@ -251,7 +254,7 @@ export class RunnerClient extends BaseClient {
251
254
  };
252
255
  // Async function here so the loop starts without blocking returning a consumer
253
256
  (() => __awaiter(this, void 0, void 0, function* () {
254
- var e_1, _a;
257
+ var _a, e_1, _b, _c;
255
258
  // Get the consumer info to determine the number of pending messages
256
259
  const consumerInfo = yield consumer.info();
257
260
  let numberPending = consumerInfo.num_pending;
@@ -269,8 +272,10 @@ export class RunnerClient extends BaseClient {
269
272
  // for await of doesn't return the index, so we need to keep track of it
270
273
  let index = 0;
271
274
  try {
272
- for (var messages_1 = (e_1 = void 0, __asyncValues(messages)), messages_1_1; messages_1_1 = yield messages_1.next(), !messages_1_1.done;) {
273
- const message = messages_1_1.value;
275
+ for (var _d = true, messages_1 = (e_1 = void 0, __asyncValues(messages)), messages_1_1; messages_1_1 = yield messages_1.next(), _a = messages_1_1.done, !_a; _d = true) {
276
+ _c = messages_1_1.value;
277
+ _d = false;
278
+ const message = _c;
274
279
  // Store the message data and timestamp
275
280
  metricData.encodedMetrics[index] = message.data;
276
281
  metricData.timestamps[index] = message.info.timestampNanos;
@@ -286,13 +291,13 @@ export class RunnerClient extends BaseClient {
286
291
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
287
292
  finally {
288
293
  try {
289
- if (messages_1_1 && !messages_1_1.done && (_a = messages_1.return)) yield _a.call(messages_1);
294
+ if (!_d && !_a && (_b = messages_1.return)) yield _b.call(messages_1);
290
295
  }
291
296
  finally { if (e_1) throw e_1.error; }
292
297
  }
293
298
  (() => __awaiter(this, void 0, void 0, function* () { return handler(metricData); }))();
294
299
  }
295
- catch (error) {
300
+ catch (_e) {
296
301
  break;
297
302
  }
298
303
  }
@@ -3,13 +3,13 @@ import { BaseClient } from './BaseClient';
3
3
  import { jsonCodec } from './encoders';
4
4
  import { NIL } from 'uuid';
5
5
  export class SessionClient extends BaseClient {
6
+ get sessionId() {
7
+ return this._sessionId;
8
+ }
6
9
  constructor(baseSubject, options) {
7
10
  super(baseSubject, options);
8
11
  this._sessionId = this.getSessionIdFromSubject(baseSubject);
9
12
  }
10
- get sessionId() {
11
- return this._sessionId;
12
- }
13
13
  /**
14
14
  * Extracts the sessionId from the subject.
15
15
  * @param subject //OpenTap.Runner.<runnerId>.Session.<sessionId>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentap/runner-client",
3
- "version": "3.4.0",
3
+ "version": "4.1.0",
4
4
  "description": "This is the web client for the OpenTAP Runner.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/mjs/index.js",
@@ -34,22 +34,21 @@
34
34
  "url": "git://github.com/opentap/runner-client-web.git"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/node": "^18.11.9",
38
- "@types/uuid": "^8.3.4",
39
- "@typescript-eslint/eslint-plugin": "^5.36.1",
40
- "@typescript-eslint/parser": "^5.36.1",
41
- "eslint": "^8.23.0",
37
+ "@types/node": "^22.13.0",
38
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
39
+ "@typescript-eslint/parser": "^8.0.0",
40
+ "eslint": "^8.57.0",
42
41
  "eslint-config-prettier": "^8.5.0",
43
42
  "eslint-plugin-prettier": "^4.2.1",
44
43
  "husky": "^8.0.0",
45
44
  "lint-staged": "^13.0.3",
46
45
  "prettier": "^2.7.1",
47
46
  "rimraf": "^3.0.2",
48
- "typescript": "^4.8.2"
47
+ "typescript": "^5.8"
49
48
  },
50
49
  "dependencies": {
51
50
  "nats.ws": "~1.29.0",
52
- "uuid": "^9.0.0",
51
+ "uuid": "^14.0.0",
53
52
  "events": "^3.3.0"
54
53
  },
55
54
  "lint-staged": {