@opentap/runner-client 2.21.0 → 2.22.0-alpha.1.1.10179797802

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/dist/cjs/DTOs.js CHANGED
@@ -16,8 +16,8 @@ var __extends = (this && this.__extends) || (function () {
16
16
  })();
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.SessionShutdownInitiated = exports.SessionStartFailed = exports.SessionStarted = exports.SessionStartInitiated = exports.SessionEventArgs = exports.SettingsTapPackage = exports.RepositorySettingsPackageDefinition = exports.RepositoryPackageDefinition = exports.RepositoryPackageReference = exports.ProfileGroup = exports.ListItemType = exports.ComponentSettings = exports.FileDescriptor = exports.Resource = exports.PluginTypeSelectorControl = exports.PictureControl = exports.PasswordControl = exports.MultiSelectControl = exports.DropdownControl = exports.EnabledControl = exports.DirectoryPathControl = exports.FilePathControl = exports.ComboBoxControl = exports.TextBoxControl = exports.DataGridControl = exports.DataGridReferenceControl = exports.CheckBoxControl = exports.AvailableValue = exports.ButtonsControl = exports.ButtonControl = exports.ExternalParameter = exports.MetaData = exports.DisplayAttribute = exports.VisualStatus = exports.Icon = exports.ColumnDisplayName = exports.LayoutMode = exports.Layout = exports.Setting = exports.ComponentSettingsListItem = exports.AnnotatedObject = exports.ComponentSettingsList = exports.ComponentSettingsIdentifier = exports.ComponentSettingsBase = exports.Links = exports.Session = exports.ImageResolveErrorResponse = exports.ErrorResponse = exports.PackageSpecifier = exports.Image = void 0;
19
- exports.TestStepRunEvent = exports.OnTestStepRun = exports.OnTestPlanRun = exports.TestPlanSettingsChangedEventArgs = exports.UserInputRequestCompletedEventArgs = exports.UserInputRequestEventArgs = exports.BreakEventArgs = exports.TestStepChangeEventArgs = exports.SettingsChangedEventArgs = exports.TestPlanExecutionStateChangedEventArgs = exports.TestPlanChangeEventArgs = exports.StoppedEventArgs = exports.StoppingEventArgs = exports.StartedEventArgs = exports.StartingEventArgs = exports.SessionTimeoutEventArgs = exports.SessionEventType = exports.SessionEvent = exports.ResultColumn = exports.Result = exports.LogEvent = exports.TestStepRun = exports.TestRun = exports.WatchDog = exports.Parameter = exports.BreakPoints = exports.InstalledFile = exports.Interaction = exports.CommonContext = exports.CommonSettings = exports.ValidationError = exports.TestStepValidationError = exports.TestStepCopy = exports.TestStepType = exports.TestStep = exports.TestPlan = exports.ExecutionState = exports.Verdict = exports.RunStatus = exports.MissingLicenseResponse = exports.LogEntry = exports.LogList = exports.ApiException = exports.ImageCreationFailed = exports.ImageCreated = exports.ImageCreating = exports.ImageEventArgs = exports.SessionInactivityLimitHit = exports.SessionShutdownFailed = exports.SessionShutdown = void 0;
20
- exports.RunnerDeletedEvent = exports.RunnerUpdatedEvent = exports.RunnerRegisteredEvent = exports.RunnerEvent = exports.TestPlanRunCompletedEventArgs = exports.TestPlanRunStartEventArgs = exports.TestPlanRunEvent = exports.TestStepRunCompletedEventArgs = exports.TestStepRunStartEventArgs = void 0;
19
+ exports.BreakEventArgs = exports.TestStepChangeEventArgs = exports.SettingsChangedEventArgs = exports.TestPlanExecutionStateChangedEventArgs = exports.TestPlanChangeEventArgs = exports.StoppedEventArgs = exports.StoppingEventArgs = exports.StartedEventArgs = exports.StartingEventArgs = exports.SessionTimeoutEventArgs = exports.SessionEventType = exports.SessionEvent = exports.MetricValue = exports.MetricsRequest = exports.SessionMetricInfo = exports.MetricsPollRate = exports.SessionMetricType = exports.SessionMetricKind = exports.ResultColumn = exports.Result = exports.LogEvent = exports.TestStepRun = exports.TestRun = exports.WatchDog = exports.Parameter = exports.BreakPoints = exports.InstalledFile = exports.Interaction = exports.CommonContext = exports.CommonSettings = exports.ValidationError = exports.TestStepValidationError = exports.TestStepCopy = exports.TestStepType = exports.TestStep = exports.TestPlan = exports.ExecutionState = exports.Verdict = exports.RunStatus = exports.MissingLicenseResponse = exports.LogEntry = exports.LogList = exports.ApiException = exports.ImageCreationFailed = exports.ImageCreated = exports.ImageCreating = exports.ImageEventArgs = exports.SessionInactivityLimitHit = exports.SessionShutdownFailed = exports.SessionShutdown = void 0;
20
+ exports.RunnerDeletedEvent = exports.RunnerUpdatedEvent = exports.RunnerRegisteredEvent = exports.RunnerEvent = exports.TestPlanRunCompletedEventArgs = exports.TestPlanRunStartEventArgs = exports.TestPlanRunEvent = exports.TestStepRunCompletedEventArgs = exports.TestStepRunStartEventArgs = exports.TestStepRunEvent = exports.OnTestStepRun = exports.OnTestPlanRun = exports.TestPlanSettingsChangedEventArgs = exports.UserInputRequestCompletedEventArgs = exports.UserInputRequestEventArgs = void 0;
21
21
  var Image = /** @class */ (function () {
22
22
  function Image(data) {
23
23
  this.packages = [];
@@ -3062,6 +3062,144 @@ var ResultColumn = /** @class */ (function () {
3062
3062
  return ResultColumn;
3063
3063
  }());
3064
3064
  exports.ResultColumn = ResultColumn;
3065
+ var SessionMetricKind;
3066
+ (function (SessionMetricKind) {
3067
+ SessionMetricKind["Poll"] = "Poll";
3068
+ SessionMetricKind["Push"] = "Push";
3069
+ SessionMetricKind["PushPoll"] = "PushPoll";
3070
+ })(SessionMetricKind = exports.SessionMetricKind || (exports.SessionMetricKind = {}));
3071
+ var SessionMetricType;
3072
+ (function (SessionMetricType) {
3073
+ SessionMetricType["Unknown"] = "Unknown";
3074
+ SessionMetricType["Double"] = "Double";
3075
+ SessionMetricType["Boolean"] = "Boolean";
3076
+ SessionMetricType["String"] = "String";
3077
+ })(SessionMetricType = exports.SessionMetricType || (exports.SessionMetricType = {}));
3078
+ var MetricsPollRate;
3079
+ (function (MetricsPollRate) {
3080
+ MetricsPollRate[MetricsPollRate["OneSecond"] = 1] = "OneSecond";
3081
+ MetricsPollRate[MetricsPollRate["TwoSeconds"] = 2] = "TwoSeconds";
3082
+ MetricsPollRate[MetricsPollRate["FiveSeconds"] = 5] = "FiveSeconds";
3083
+ MetricsPollRate[MetricsPollRate["TenSeconds"] = 10] = "TenSeconds";
3084
+ MetricsPollRate[MetricsPollRate["FifteenSeconds"] = 15] = "FifteenSeconds";
3085
+ MetricsPollRate[MetricsPollRate["OneMinute"] = 60] = "OneMinute";
3086
+ MetricsPollRate[MetricsPollRate["TwoMinutes"] = 120] = "TwoMinutes";
3087
+ MetricsPollRate[MetricsPollRate["FiveMinutes"] = 300] = "FiveMinutes";
3088
+ MetricsPollRate[MetricsPollRate["TenMinutes"] = 600] = "TenMinutes";
3089
+ MetricsPollRate[MetricsPollRate["FifteenMinutes"] = 900] = "FifteenMinutes";
3090
+ MetricsPollRate[MetricsPollRate["OneHour"] = 3600] = "OneHour";
3091
+ })(MetricsPollRate = exports.MetricsPollRate || (exports.MetricsPollRate = {}));
3092
+ var SessionMetricInfo = /** @class */ (function () {
3093
+ function SessionMetricInfo(data) {
3094
+ this.attributes = [];
3095
+ if (data) {
3096
+ for (var property in data) {
3097
+ if (Object.prototype.hasOwnProperty.call(data, property))
3098
+ this[property] = data[property];
3099
+ }
3100
+ }
3101
+ }
3102
+ SessionMetricInfo.prototype.init = function (_data) {
3103
+ if (_data) {
3104
+ this.publish = _data['Publish'];
3105
+ this.kind = _data['Kind'];
3106
+ this.type = _data['Type'];
3107
+ this.groupName = _data['GroupName'];
3108
+ this.name = _data['Name'];
3109
+ this.metricFullName = _data['MetricFullName'];
3110
+ this.subjectPostfix = _data['SubjectPostfix'];
3111
+ if (Array.isArray(_data['Attributes']))
3112
+ this.attributes = _data['Attributes'];
3113
+ }
3114
+ };
3115
+ SessionMetricInfo.fromJS = function (data) {
3116
+ data = typeof data === 'object' ? data : {};
3117
+ var result = new SessionMetricInfo();
3118
+ result.init(data);
3119
+ return result;
3120
+ };
3121
+ SessionMetricInfo.prototype.toJSON = function (data) {
3122
+ data = typeof data === 'object' ? data : {};
3123
+ data['Publish'] = this.publish;
3124
+ data['Kind'] = this.kind;
3125
+ data['Type'] = this.type;
3126
+ data['GroupName'] = this.groupName;
3127
+ data['Name'] = this.name;
3128
+ data['MetricFullName'] = this.metricFullName;
3129
+ data['SubjectPostfix'] = this.subjectPostfix;
3130
+ data['Attributes'] = [];
3131
+ if (Array.isArray(this.attributes)) {
3132
+ data['Attributes'] = this.attributes;
3133
+ }
3134
+ return data;
3135
+ };
3136
+ return SessionMetricInfo;
3137
+ }());
3138
+ exports.SessionMetricInfo = SessionMetricInfo;
3139
+ var MetricsRequest = /** @class */ (function () {
3140
+ function MetricsRequest(data) {
3141
+ this.metrics = [];
3142
+ if (data) {
3143
+ for (var property in data) {
3144
+ if (Object.prototype.hasOwnProperty.call(data, property))
3145
+ this[property] = data[property];
3146
+ }
3147
+ }
3148
+ }
3149
+ MetricsRequest.prototype.init = function (_data) {
3150
+ if (_data) {
3151
+ this.publishRate = _data['PublishRate'];
3152
+ if (Array.isArray(_data['Metrics']))
3153
+ this.metrics = _data['Metrics'].map(function (item) { return SessionMetricInfo.fromJS(item); });
3154
+ }
3155
+ };
3156
+ MetricsRequest.fromJS = function (data) {
3157
+ data = typeof data === 'object' ? data : {};
3158
+ var result = new MetricsRequest();
3159
+ result.init(data);
3160
+ return result;
3161
+ };
3162
+ MetricsRequest.prototype.toJSON = function (data) {
3163
+ data = typeof data === 'object' ? data : {};
3164
+ data['PublishRate'] = this.publishRate;
3165
+ if (Array.isArray(this.metrics)) {
3166
+ data['SessionMetricInfo'] = this.metrics.map(function (item) { return item.toJSON(); });
3167
+ }
3168
+ return data;
3169
+ };
3170
+ return MetricsRequest;
3171
+ }());
3172
+ exports.MetricsRequest = MetricsRequest;
3173
+ var MetricValue = /** @class */ (function () {
3174
+ function MetricValue(data) {
3175
+ if (data) {
3176
+ for (var property in data) {
3177
+ if (Object.prototype.hasOwnProperty.call(data, property))
3178
+ this[property] = data[property];
3179
+ }
3180
+ }
3181
+ }
3182
+ MetricValue.prototype.init = function (_data) {
3183
+ if (_data) {
3184
+ this.time = _data['Time'];
3185
+ this.value = _data['Value'];
3186
+ }
3187
+ };
3188
+ MetricValue.fromJS = function (data) {
3189
+ data = typeof data === 'object' ? data : {};
3190
+ var result = new MetricValue();
3191
+ result.init(data);
3192
+ return result;
3193
+ };
3194
+ MetricValue.prototype.toJSON = function (data) {
3195
+ data = typeof data === 'object' ? data : {};
3196
+ data['Time'] = this.time;
3197
+ data['Value'] = this.value;
3198
+ return data;
3199
+ };
3200
+ return MetricValue;
3201
+ }());
3202
+ exports.MetricValue = MetricValue;
3065
3203
  var SessionEvent = /** @class */ (function () {
3066
3204
  function SessionEvent(data) {
3067
3205
  if (data) {
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.SessionClient = void 0;
30
30
  var DTOs_1 = require("./DTOs");
31
31
  var nats_ws_1 = require("nats.ws");
32
+ var encoders_1 = require("./encoders");
32
33
  var BaseClient_1 = require("./BaseClient");
33
34
  var SessionClient = /** @class */ (function (_super) {
34
35
  __extends(SessionClient, _super);
@@ -49,8 +50,8 @@ var SessionClient = /** @class */ (function (_super) {
49
50
  return;
50
51
  }
51
52
  try {
52
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
53
- var logListJson = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
53
+ var jsonCodec_1 = (0, nats_ws_1.JSONCodec)();
54
+ var logListJson = jsonCodec_1.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
54
55
  var logList = DTOs_1.LogList.fromJS(logListJson);
55
56
  sessionLogsHandler(logList, error);
56
57
  }
@@ -71,8 +72,8 @@ var SessionClient = /** @class */ (function (_super) {
71
72
  return;
72
73
  }
73
74
  try {
74
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
75
- var sessionEventJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
75
+ var jsonCodec_2 = (0, nats_ws_1.JSONCodec)();
76
+ var sessionEventJs = jsonCodec_2.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
76
77
  var sessionEvent = DTOs_1.SessionEvent.fromJS(sessionEventJs);
77
78
  eventHandler(sessionEvent, error);
78
79
  }
@@ -97,8 +98,8 @@ var SessionClient = /** @class */ (function (_super) {
97
98
  return;
98
99
  }
99
100
  try {
100
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
101
- var resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
101
+ var jsonCodec_3 = (0, nats_ws_1.JSONCodec)();
102
+ var resultJs = jsonCodec_3.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
102
103
  var result = DTOs_1.Result.fromJS(resultJs);
103
104
  resultHandler(result, error);
104
105
  }
@@ -112,8 +113,8 @@ var SessionClient = /** @class */ (function (_super) {
112
113
  return;
113
114
  }
114
115
  try {
115
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
116
- var testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
116
+ var jsonCodec_4 = (0, nats_ws_1.JSONCodec)();
117
+ var testRunJs = jsonCodec_4.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
117
118
  var testRun = DTOs_1.TestRun.fromJS(testRunJs);
118
119
  testRunHandler(testRun, error);
119
120
  }
@@ -135,8 +136,8 @@ var SessionClient = /** @class */ (function (_super) {
135
136
  return;
136
137
  }
137
138
  try {
138
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
139
- var testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
139
+ var jsonCodec_5 = (0, nats_ws_1.JSONCodec)();
140
+ var testRunJs = jsonCodec_5.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
140
141
  var testRun = DTOs_1.TestRun.fromJS(testRunJs);
141
142
  testRunHandler(testRun, error);
142
143
  }
@@ -159,8 +160,8 @@ var SessionClient = /** @class */ (function (_super) {
159
160
  return;
160
161
  }
161
162
  try {
162
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
163
- var onTestPlanRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
163
+ var jsonCodec_6 = (0, nats_ws_1.JSONCodec)();
164
+ var onTestPlanRunJs = jsonCodec_6.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
164
165
  var onTestPlanRun = DTOs_1.OnTestPlanRun.fromJS(onTestPlanRunJs);
165
166
  handler(onTestPlanRun, error);
166
167
  }
@@ -183,8 +184,8 @@ var SessionClient = /** @class */ (function (_super) {
183
184
  return;
184
185
  }
185
186
  try {
186
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
187
- var logListJson = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
187
+ var jsonCodec_7 = (0, nats_ws_1.JSONCodec)();
188
+ var logListJson = jsonCodec_7.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
188
189
  var logList = DTOs_1.LogList.fromJS(logListJson);
189
190
  handler(logList, error);
190
191
  }
@@ -207,8 +208,8 @@ var SessionClient = /** @class */ (function (_super) {
207
208
  return;
208
209
  }
209
210
  try {
210
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
211
- var parameterListJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
211
+ var jsonCodec_8 = (0, nats_ws_1.JSONCodec)();
212
+ var parameterListJs = jsonCodec_8.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
212
213
  var parameterList = parameterListJs.map(function (parameterJs) { return DTOs_1.Parameter.fromJS(parameterJs); });
213
214
  handler(parameterList, error);
214
215
  }
@@ -233,8 +234,8 @@ var SessionClient = /** @class */ (function (_super) {
233
234
  return;
234
235
  }
235
236
  try {
236
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
237
- var onTestStepRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
237
+ var jsonCodec_9 = (0, nats_ws_1.JSONCodec)();
238
+ var onTestStepRunJs = jsonCodec_9.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
238
239
  var onTestStepRun = DTOs_1.OnTestStepRun.fromJS(onTestStepRunJs);
239
240
  var stepRunId = (_a = encodedMessage.subject.match(/\.StepRun\.(.+)$/)) === null || _a === void 0 ? void 0 : _a[1];
240
241
  handler(stepRunId, onTestStepRun, error);
@@ -259,8 +260,8 @@ var SessionClient = /** @class */ (function (_super) {
259
260
  return;
260
261
  }
261
262
  try {
262
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
263
- var parameterListJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
263
+ var jsonCodec_10 = (0, nats_ws_1.JSONCodec)();
264
+ var parameterListJs = jsonCodec_10.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
264
265
  var parameterList = parameterListJs.map(function (parameterJs) { return DTOs_1.Parameter.fromJS(parameterJs); });
265
266
  handler(parameterList, error);
266
267
  }
@@ -285,8 +286,8 @@ var SessionClient = /** @class */ (function (_super) {
285
286
  return;
286
287
  }
287
288
  try {
288
- var jsonCodec = (0, nats_ws_1.JSONCodec)();
289
- var resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
289
+ var jsonCodec_11 = (0, nats_ws_1.JSONCodec)();
290
+ var resultJs = jsonCodec_11.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
290
291
  var result = DTOs_1.Result.fromJS(resultJs);
291
292
  handler(result, error);
292
293
  }
@@ -295,6 +296,45 @@ var SessionClient = /** @class */ (function (_super) {
295
296
  }
296
297
  } }));
297
298
  };
299
+ /**
300
+ * Connect to metrics published for the given SessionMetricInfo
301
+ * @param {ISessionMetricInfo} metricInfo
302
+ * @param {(result:MetricValue|undefined,err:NatsError|Error|null)=>void} handler
303
+ * @param {SubscriptionOptions} options?
304
+ * @returns Subscription
305
+ */
306
+ SessionClient.prototype.connectMetric = function (metricInfo, handler, options) {
307
+ return this.subscribe("Events.Metrics.".concat(metricInfo.subjectPostfix), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
308
+ var _a, _b;
309
+ if (error) {
310
+ handler(undefined, error);
311
+ return;
312
+ }
313
+ try {
314
+ var time = Number.parseInt((_b = (_a = encodedMessage.headers) === null || _a === void 0 ? void 0 : _a.get('timestamp')) !== null && _b !== void 0 ? _b : '');
315
+ var value = void 0;
316
+ // Decode the value based on the metric value type given in the metric info
317
+ switch (metricInfo.type) {
318
+ case DTOs_1.SessionMetricType.Boolean:
319
+ value = encoders_1.booleanCodec.decode(encodedMessage.data);
320
+ break;
321
+ case DTOs_1.SessionMetricType.Double:
322
+ value = encoders_1.numberCodec.decode(encodedMessage.data);
323
+ break;
324
+ case DTOs_1.SessionMetricType.String:
325
+ value = encoders_1.stringCodec.decode(encodedMessage.data);
326
+ break;
327
+ default:
328
+ value = encoders_1.jsonCodec.decode(encodedMessage.data);
329
+ break;
330
+ }
331
+ handler(new DTOs_1.MetricValue({ value: value, time: time }), error);
332
+ }
333
+ catch (error) {
334
+ handler(undefined, error);
335
+ }
336
+ } }));
337
+ };
298
338
  /**
299
339
  * Unsubscibe from session events
300
340
  */
@@ -769,6 +809,24 @@ var SessionClient = /** @class */ (function (_super) {
769
809
  SessionClient.prototype.getSettingsTypes = function () {
770
810
  return this.request('GetSettingsTypes').then(this.success()).catch(this.error());
771
811
  };
812
+ /**
813
+ * Get the metric information
814
+ * @returns Promise
815
+ */
816
+ SessionClient.prototype.getMetrics = function () {
817
+ return this.request('GetMetrics')
818
+ .then(function (metricsRequestJs) { return DTOs_1.MetricsRequest.fromJS(metricsRequestJs); })
819
+ .then(this.success())
820
+ .catch(this.error());
821
+ };
822
+ /**
823
+ * Set the metric information. Used for setting up which metrics should be published for polling.
824
+ * @param {IMetricsRequest} metricsRequest
825
+ * @returns Promise
826
+ */
827
+ SessionClient.prototype.setMetrics = function (metricsRequest) {
828
+ return this.request('SetMetrics', metricsRequest).then(this.success()).catch(this.error());
829
+ };
772
830
  return SessionClient;
773
831
  }(BaseClient_1.BaseClient));
774
832
  exports.SessionClient = SessionClient;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BooleanCodec = exports.NumberCodec = exports.jsonCodec = exports.stringCodec = exports.booleanCodec = exports.numberCodec = void 0;
4
+ var nats_ws_1 = require("nats.ws");
5
+ exports.numberCodec = NumberCodec();
6
+ exports.booleanCodec = BooleanCodec();
7
+ exports.stringCodec = (0, nats_ws_1.StringCodec)();
8
+ exports.jsonCodec = (0, nats_ws_1.JSONCodec)();
9
+ function NumberCodec() {
10
+ return {
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ encode: function (d) {
13
+ throw new Error('not implemented');
14
+ },
15
+ decode: function (a) {
16
+ var dataView = new DataView(a.buffer);
17
+ return dataView.getFloat64(a.byteOffset, true); // BitConverter.ToDouble in C# is little-endian
18
+ },
19
+ };
20
+ }
21
+ exports.NumberCodec = NumberCodec;
22
+ function BooleanCodec() {
23
+ return {
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ encode: function (d) {
26
+ throw new Error('not implemented');
27
+ },
28
+ decode: function (a) {
29
+ return a[0] === 1;
30
+ },
31
+ };
32
+ }
33
+ exports.BooleanCodec = BooleanCodec;
@@ -1067,6 +1067,78 @@ export interface IResultColumn {
1067
1067
  data?: any[] | undefined;
1068
1068
  typeCode?: string | undefined;
1069
1069
  }
1070
+ export declare enum SessionMetricKind {
1071
+ Poll = "Poll",
1072
+ Push = "Push",
1073
+ PushPoll = "PushPoll"
1074
+ }
1075
+ export declare enum SessionMetricType {
1076
+ Unknown = "Unknown",
1077
+ Double = "Double",
1078
+ Boolean = "Boolean",
1079
+ String = "String"
1080
+ }
1081
+ export declare enum MetricsPollRate {
1082
+ OneSecond = 1,
1083
+ TwoSeconds = 2,
1084
+ FiveSeconds = 5,
1085
+ TenSeconds = 10,
1086
+ FifteenSeconds = 15,
1087
+ OneMinute = 60,
1088
+ TwoMinutes = 120,
1089
+ FiveMinutes = 300,
1090
+ TenMinutes = 600,
1091
+ FifteenMinutes = 900,
1092
+ OneHour = 3600
1093
+ }
1094
+ export declare class SessionMetricInfo implements ISessionMetricInfo {
1095
+ publish: boolean;
1096
+ kind: SessionMetricKind;
1097
+ type: SessionMetricType;
1098
+ attributes: object[];
1099
+ groupName: string;
1100
+ name: string;
1101
+ metricFullName: string;
1102
+ subjectPostfix: string;
1103
+ constructor(data?: ISessionMetricInfo);
1104
+ init(_data?: any): void;
1105
+ static fromJS(data: any): SessionMetricInfo;
1106
+ toJSON(data?: any): any;
1107
+ }
1108
+ export interface ISessionMetricInfo {
1109
+ publish: boolean;
1110
+ kind: SessionMetricKind;
1111
+ type: SessionMetricType;
1112
+ attributes: object[];
1113
+ groupName: string;
1114
+ name: string;
1115
+ metricFullName: string;
1116
+ subjectPostfix: string;
1117
+ }
1118
+ export declare class MetricsRequest implements IMetricsRequest {
1119
+ publishRate: MetricsPollRate;
1120
+ metrics: SessionMetricInfo[];
1121
+ constructor(data?: IMetricsRequest);
1122
+ init(_data?: any): void;
1123
+ static fromJS(data: any): MetricsRequest;
1124
+ toJSON(data?: any): any;
1125
+ }
1126
+ export interface IMetricsRequest {
1127
+ publishRate: MetricsPollRate;
1128
+ metrics: ISessionMetricInfo[];
1129
+ }
1130
+ export declare class MetricValue implements IMetricValue {
1131
+ time: number;
1132
+ value: boolean | number | string | object;
1133
+ constructor(data?: IMetricValue);
1134
+ init(_data?: any): void;
1135
+ static fromJS(data: any): MetricValue;
1136
+ toJSON(data?: any): any;
1137
+ }
1138
+ export interface IMetricValue {
1139
+ time: number;
1140
+ value: boolean | number | string | object;
1141
+ }
1070
1142
  export declare class SessionEvent implements ISessionEvent {
1071
1143
  eventType?: SessionEventType;
1072
1144
  sessionId?: string;
package/dist/mjs/DTOs.js CHANGED
@@ -2672,6 +2672,138 @@ export class ResultColumn {
2672
2672
  return data;
2673
2673
  }
2674
2674
  }
2675
+ export var SessionMetricKind;
2676
+ (function (SessionMetricKind) {
2677
+ SessionMetricKind["Poll"] = "Poll";
2678
+ SessionMetricKind["Push"] = "Push";
2679
+ SessionMetricKind["PushPoll"] = "PushPoll";
2680
+ })(SessionMetricKind || (SessionMetricKind = {}));
2681
+ export var SessionMetricType;
2682
+ (function (SessionMetricType) {
2683
+ SessionMetricType["Unknown"] = "Unknown";
2684
+ SessionMetricType["Double"] = "Double";
2685
+ SessionMetricType["Boolean"] = "Boolean";
2686
+ SessionMetricType["String"] = "String";
2687
+ })(SessionMetricType || (SessionMetricType = {}));
2688
+ export var MetricsPollRate;
2689
+ (function (MetricsPollRate) {
2690
+ MetricsPollRate[MetricsPollRate["OneSecond"] = 1] = "OneSecond";
2691
+ MetricsPollRate[MetricsPollRate["TwoSeconds"] = 2] = "TwoSeconds";
2692
+ MetricsPollRate[MetricsPollRate["FiveSeconds"] = 5] = "FiveSeconds";
2693
+ MetricsPollRate[MetricsPollRate["TenSeconds"] = 10] = "TenSeconds";
2694
+ MetricsPollRate[MetricsPollRate["FifteenSeconds"] = 15] = "FifteenSeconds";
2695
+ MetricsPollRate[MetricsPollRate["OneMinute"] = 60] = "OneMinute";
2696
+ MetricsPollRate[MetricsPollRate["TwoMinutes"] = 120] = "TwoMinutes";
2697
+ MetricsPollRate[MetricsPollRate["FiveMinutes"] = 300] = "FiveMinutes";
2698
+ MetricsPollRate[MetricsPollRate["TenMinutes"] = 600] = "TenMinutes";
2699
+ MetricsPollRate[MetricsPollRate["FifteenMinutes"] = 900] = "FifteenMinutes";
2700
+ MetricsPollRate[MetricsPollRate["OneHour"] = 3600] = "OneHour";
2701
+ })(MetricsPollRate || (MetricsPollRate = {}));
2702
+ export class SessionMetricInfo {
2703
+ constructor(data) {
2704
+ this.attributes = [];
2705
+ if (data) {
2706
+ for (const property in data) {
2707
+ if (Object.prototype.hasOwnProperty.call(data, property))
2708
+ this[property] = data[property];
2709
+ }
2710
+ }
2711
+ }
2712
+ init(_data) {
2713
+ if (_data) {
2714
+ this.publish = _data['Publish'];
2715
+ this.kind = _data['Kind'];
2716
+ this.type = _data['Type'];
2717
+ this.groupName = _data['GroupName'];
2718
+ this.name = _data['Name'];
2719
+ this.metricFullName = _data['MetricFullName'];
2720
+ this.subjectPostfix = _data['SubjectPostfix'];
2721
+ if (Array.isArray(_data['Attributes']))
2722
+ this.attributes = _data['Attributes'];
2723
+ }
2724
+ }
2725
+ static fromJS(data) {
2726
+ data = typeof data === 'object' ? data : {};
2727
+ const result = new SessionMetricInfo();
2728
+ result.init(data);
2729
+ return result;
2730
+ }
2731
+ toJSON(data) {
2732
+ data = typeof data === 'object' ? data : {};
2733
+ data['Publish'] = this.publish;
2734
+ data['Kind'] = this.kind;
2735
+ data['Type'] = this.type;
2736
+ data['GroupName'] = this.groupName;
2737
+ data['Name'] = this.name;
2738
+ data['MetricFullName'] = this.metricFullName;
2739
+ data['SubjectPostfix'] = this.subjectPostfix;
2740
+ data['Attributes'] = [];
2741
+ if (Array.isArray(this.attributes)) {
2742
+ data['Attributes'] = this.attributes;
2743
+ }
2744
+ return data;
2745
+ }
2746
+ }
2747
+ export class MetricsRequest {
2748
+ constructor(data) {
2749
+ this.metrics = [];
2750
+ if (data) {
2751
+ for (const property in data) {
2752
+ if (Object.prototype.hasOwnProperty.call(data, property))
2753
+ this[property] = data[property];
2754
+ }
2755
+ }
2756
+ }
2757
+ init(_data) {
2758
+ if (_data) {
2759
+ this.publishRate = _data['PublishRate'];
2760
+ if (Array.isArray(_data['Metrics']))
2761
+ this.metrics = _data['Metrics'].map(item => SessionMetricInfo.fromJS(item));
2762
+ }
2763
+ }
2764
+ static fromJS(data) {
2765
+ data = typeof data === 'object' ? data : {};
2766
+ const result = new MetricsRequest();
2767
+ result.init(data);
2768
+ return result;
2769
+ }
2770
+ toJSON(data) {
2771
+ data = typeof data === 'object' ? data : {};
2772
+ data['PublishRate'] = this.publishRate;
2773
+ if (Array.isArray(this.metrics)) {
2774
+ data['SessionMetricInfo'] = this.metrics.map(item => item.toJSON());
2775
+ }
2776
+ return data;
2777
+ }
2778
+ }
2779
+ export class MetricValue {
2780
+ constructor(data) {
2781
+ if (data) {
2782
+ for (const property in data) {
2783
+ if (Object.prototype.hasOwnProperty.call(data, property))
2784
+ this[property] = data[property];
2785
+ }
2786
+ }
2787
+ }
2788
+ init(_data) {
2789
+ if (_data) {
2790
+ this.time = _data['Time'];
2791
+ this.value = _data['Value'];
2792
+ }
2793
+ }
2794
+ static fromJS(data) {
2795
+ data = typeof data === 'object' ? data : {};
2796
+ const result = new MetricValue();
2797
+ result.init(data);
2798
+ return result;
2799
+ }
2800
+ toJSON(data) {
2801
+ data = typeof data === 'object' ? data : {};
2802
+ data['Time'] = this.time;
2803
+ data['Value'] = this.value;
2804
+ return data;
2805
+ }
2806
+ }
2675
2807
  export class SessionEvent {
2676
2808
  constructor(data) {
2677
2809
  if (data) {
@@ -1,4 +1,4 @@
1
- import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, OnTestPlanRun, OnTestStepRun, Parameter, RepositoryPackageDefinition, RepositoryPackageReference, Resource, Result, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog } from './DTOs';
1
+ import { BreakPoints, CommonContext, CommonSettings, DataGridControl, IMetricValue, IMetricsRequest, ISessionMetricInfo, Image, Interaction, ListItemType, LogList, MetricsRequest, OnTestPlanRun, OnTestStepRun, Parameter, RepositoryPackageDefinition, RepositoryPackageReference, Resource, Result, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog } from './DTOs';
2
2
  import { ConnectionOptions, NatsError, Subscription, SubscriptionOptions } from 'nats.ws';
3
3
  import { BaseClient } from './BaseClient';
4
4
  export declare class SessionClient extends BaseClient {
@@ -81,6 +81,14 @@ export declare class SessionClient extends BaseClient {
81
81
  * @returns Subscription
82
82
  */
83
83
  connectTestStepRunResults(testPlanRunId: string, testStepRunId: string, resultName: string, handler: (result: Result | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
84
+ /**
85
+ * Connect to metrics published for the given SessionMetricInfo
86
+ * @param {ISessionMetricInfo} metricInfo
87
+ * @param {(result:MetricValue|undefined,err:NatsError|Error|null)=>void} handler
88
+ * @param {SubscriptionOptions} options?
89
+ * @returns Subscription
90
+ */
91
+ connectMetric(metricInfo: ISessionMetricInfo, handler: (result: IMetricValue | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
84
92
  /**
85
93
  * Unsubscibe from session events
86
94
  */
@@ -345,4 +353,15 @@ export declare class SessionClient extends BaseClient {
345
353
  * Retrieve settings types used in creating a Settings TapPackage
346
354
  */
347
355
  getSettingsTypes(): Promise<string[]>;
356
+ /**
357
+ * Get the metric information
358
+ * @returns Promise
359
+ */
360
+ getMetrics(): Promise<MetricsRequest>;
361
+ /**
362
+ * Set the metric information. Used for setting up which metrics should be published for polling.
363
+ * @param {IMetricsRequest} metricsRequest
364
+ * @returns Promise
365
+ */
366
+ setMetrics(metricsRequest: IMetricsRequest): Promise<void>;
348
367
  }
@@ -1,5 +1,6 @@
1
- import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, OnTestPlanRun, OnTestStepRun, Parameter, Result, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog, } from './DTOs';
1
+ import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, MetricValue, MetricsRequest, OnTestPlanRun, OnTestStepRun, Parameter, Result, RunStatus, SessionEvent, SessionMetricType, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog, } from './DTOs';
2
2
  import { JSONCodec } from 'nats.ws';
3
+ import { booleanCodec, jsonCodec, numberCodec, stringCodec } from './encoders';
3
4
  import { BaseClient } from './BaseClient';
4
5
  export class SessionClient extends BaseClient {
5
6
  constructor(baseSubject, options) {
@@ -264,6 +265,45 @@ export class SessionClient extends BaseClient {
264
265
  }
265
266
  } }));
266
267
  }
268
+ /**
269
+ * Connect to metrics published for the given SessionMetricInfo
270
+ * @param {ISessionMetricInfo} metricInfo
271
+ * @param {(result:MetricValue|undefined,err:NatsError|Error|null)=>void} handler
272
+ * @param {SubscriptionOptions} options?
273
+ * @returns Subscription
274
+ */
275
+ connectMetric(metricInfo, handler, options) {
276
+ return this.subscribe(`Events.Metrics.${metricInfo.subjectPostfix}`, Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
277
+ var _a, _b;
278
+ if (error) {
279
+ handler(undefined, error);
280
+ return;
281
+ }
282
+ try {
283
+ const time = Number.parseInt((_b = (_a = encodedMessage.headers) === null || _a === void 0 ? void 0 : _a.get('timestamp')) !== null && _b !== void 0 ? _b : '');
284
+ let value;
285
+ // Decode the value based on the metric value type given in the metric info
286
+ switch (metricInfo.type) {
287
+ case SessionMetricType.Boolean:
288
+ value = booleanCodec.decode(encodedMessage.data);
289
+ break;
290
+ case SessionMetricType.Double:
291
+ value = numberCodec.decode(encodedMessage.data);
292
+ break;
293
+ case SessionMetricType.String:
294
+ value = stringCodec.decode(encodedMessage.data);
295
+ break;
296
+ default:
297
+ value = jsonCodec.decode(encodedMessage.data);
298
+ break;
299
+ }
300
+ handler(new MetricValue({ value, time }), error);
301
+ }
302
+ catch (error) {
303
+ handler(undefined, error);
304
+ }
305
+ } }));
306
+ }
267
307
  /**
268
308
  * Unsubscibe from session events
269
309
  */
@@ -736,4 +776,22 @@ export class SessionClient extends BaseClient {
736
776
  getSettingsTypes() {
737
777
  return this.request('GetSettingsTypes').then(this.success()).catch(this.error());
738
778
  }
779
+ /**
780
+ * Get the metric information
781
+ * @returns Promise
782
+ */
783
+ getMetrics() {
784
+ return this.request('GetMetrics')
785
+ .then(metricsRequestJs => MetricsRequest.fromJS(metricsRequestJs))
786
+ .then(this.success())
787
+ .catch(this.error());
788
+ }
789
+ /**
790
+ * Set the metric information. Used for setting up which metrics should be published for polling.
791
+ * @param {IMetricsRequest} metricsRequest
792
+ * @returns Promise
793
+ */
794
+ setMetrics(metricsRequest) {
795
+ return this.request('SetMetrics', metricsRequest).then(this.success()).catch(this.error());
796
+ }
739
797
  }
@@ -0,0 +1,7 @@
1
+ import { Codec } from 'nats.ws';
2
+ export declare const numberCodec: Codec<number>;
3
+ export declare const booleanCodec: Codec<boolean>;
4
+ export declare const stringCodec: Codec<string>;
5
+ export declare const jsonCodec: Codec<unknown>;
6
+ export declare function NumberCodec(): Codec<number>;
7
+ export declare function BooleanCodec(): Codec<boolean>;
@@ -0,0 +1,28 @@
1
+ import { JSONCodec, StringCodec } from 'nats.ws';
2
+ export const numberCodec = NumberCodec();
3
+ export const booleanCodec = BooleanCodec();
4
+ export const stringCodec = StringCodec();
5
+ export const jsonCodec = JSONCodec();
6
+ export function NumberCodec() {
7
+ return {
8
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
+ encode(d) {
10
+ throw new Error('not implemented');
11
+ },
12
+ decode(a) {
13
+ const dataView = new DataView(a.buffer);
14
+ return dataView.getFloat64(a.byteOffset, true); // BitConverter.ToDouble in C# is little-endian
15
+ },
16
+ };
17
+ }
18
+ export function BooleanCodec() {
19
+ return {
20
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
+ encode(d) {
22
+ throw new Error('not implemented');
23
+ },
24
+ decode(a) {
25
+ return a[0] === 1;
26
+ },
27
+ };
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentap/runner-client",
3
- "version": "2.21.0",
3
+ "version": "2.22.0-alpha.1.1.10179797802",
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",
@@ -10,7 +10,7 @@
10
10
  "require": "./dist/cjs/index.js"
11
11
  },
12
12
  "scripts": {
13
- "build": "rimraf ./dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && ./post-build.sh",
13
+ "build": "rimraf ./dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && bash ./post-build.sh",
14
14
  "lint": "eslint --ignore-path .eslintignore --ext .js,.ts .",
15
15
  "format": "prettier --write \"src/**/*.+(js|ts|json)\"",
16
16
  "prepare": "npm run build && husky install",