@opentap/runner-client 2.24.0 → 2.25.0-alpha.1.1.11217168217
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/SessionClient.js +65 -56
- package/dist/cjs/index.js +6 -1
- package/dist/mjs/SessionClient.d.ts +3 -3
- package/dist/mjs/SessionClient.js +14 -35
- package/dist/mjs/index.d.ts +1 -0
- package/dist/mjs/index.js +1 -0
- package/package.json +1 -1
|
@@ -25,11 +25,46 @@ var __assign = (this && this.__assign) || function () {
|
|
|
25
25
|
};
|
|
26
26
|
return __assign.apply(this, arguments);
|
|
27
27
|
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
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;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
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
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
28
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
65
|
exports.SessionClient = void 0;
|
|
30
66
|
var DTOs_1 = require("./DTOs");
|
|
31
67
|
var nats_ws_1 = require("nats.ws");
|
|
32
|
-
var encoders_1 = require("./encoders");
|
|
33
68
|
var BaseClient_1 = require("./BaseClient");
|
|
34
69
|
var utils_1 = require("./utils");
|
|
35
70
|
var SessionClient = /** @class */ (function (_super) {
|
|
@@ -52,8 +87,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
52
87
|
return;
|
|
53
88
|
}
|
|
54
89
|
try {
|
|
55
|
-
var
|
|
56
|
-
var logListJson =
|
|
90
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
91
|
+
var logListJson = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
57
92
|
var logList = DTOs_1.LogList.fromJS(logListJson);
|
|
58
93
|
sessionLogsHandler(logList, error);
|
|
59
94
|
}
|
|
@@ -74,8 +109,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
74
109
|
return;
|
|
75
110
|
}
|
|
76
111
|
try {
|
|
77
|
-
var
|
|
78
|
-
var sessionEventJs =
|
|
112
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
113
|
+
var sessionEventJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
79
114
|
var sessionEvent = DTOs_1.SessionEvent.fromJS(sessionEventJs);
|
|
80
115
|
eventHandler(sessionEvent, error);
|
|
81
116
|
}
|
|
@@ -100,8 +135,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
100
135
|
return;
|
|
101
136
|
}
|
|
102
137
|
try {
|
|
103
|
-
var
|
|
104
|
-
var resultJs =
|
|
138
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
139
|
+
var resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
105
140
|
var result = DTOs_1.Result.fromJS(resultJs);
|
|
106
141
|
resultHandler(result, error);
|
|
107
142
|
}
|
|
@@ -115,8 +150,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
115
150
|
return;
|
|
116
151
|
}
|
|
117
152
|
try {
|
|
118
|
-
var
|
|
119
|
-
var testRunJs =
|
|
153
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
154
|
+
var testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
120
155
|
var testRun = DTOs_1.TestRun.fromJS(testRunJs);
|
|
121
156
|
testRunHandler(testRun, error);
|
|
122
157
|
}
|
|
@@ -138,8 +173,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
138
173
|
return;
|
|
139
174
|
}
|
|
140
175
|
try {
|
|
141
|
-
var
|
|
142
|
-
var testRunJs =
|
|
176
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
177
|
+
var testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
143
178
|
var testRun = DTOs_1.TestRun.fromJS(testRunJs);
|
|
144
179
|
testRunHandler(testRun, error);
|
|
145
180
|
}
|
|
@@ -162,8 +197,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
162
197
|
return;
|
|
163
198
|
}
|
|
164
199
|
try {
|
|
165
|
-
var
|
|
166
|
-
var onTestPlanRunJs =
|
|
200
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
201
|
+
var onTestPlanRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
167
202
|
var onTestPlanRun = DTOs_1.OnTestPlanRun.fromJS(onTestPlanRunJs);
|
|
168
203
|
handler(onTestPlanRun, error);
|
|
169
204
|
}
|
|
@@ -186,8 +221,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
186
221
|
return;
|
|
187
222
|
}
|
|
188
223
|
try {
|
|
189
|
-
var
|
|
190
|
-
var logListJson =
|
|
224
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
225
|
+
var logListJson = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
191
226
|
var logList = DTOs_1.LogList.fromJS(logListJson);
|
|
192
227
|
handler(logList, error);
|
|
193
228
|
}
|
|
@@ -210,8 +245,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
210
245
|
return;
|
|
211
246
|
}
|
|
212
247
|
try {
|
|
213
|
-
var
|
|
214
|
-
var parameterListJs =
|
|
248
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
249
|
+
var parameterListJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
215
250
|
var parameterList = parameterListJs.map(function (parameterJs) { return DTOs_1.Parameter.fromJS(parameterJs); });
|
|
216
251
|
handler(parameterList, error);
|
|
217
252
|
}
|
|
@@ -236,8 +271,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
236
271
|
return;
|
|
237
272
|
}
|
|
238
273
|
try {
|
|
239
|
-
var
|
|
240
|
-
var onTestStepRunJs =
|
|
274
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
275
|
+
var onTestStepRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
241
276
|
var onTestStepRun = DTOs_1.OnTestStepRun.fromJS(onTestStepRunJs);
|
|
242
277
|
var stepRunId = (_a = encodedMessage.subject.match(/\.StepRun\.(.+)$/)) === null || _a === void 0 ? void 0 : _a[1];
|
|
243
278
|
handler(stepRunId, onTestStepRun, error);
|
|
@@ -262,8 +297,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
262
297
|
return;
|
|
263
298
|
}
|
|
264
299
|
try {
|
|
265
|
-
var
|
|
266
|
-
var parameterListJs =
|
|
300
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
301
|
+
var parameterListJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
267
302
|
var parameterList = parameterListJs.map(function (parameterJs) { return DTOs_1.Parameter.fromJS(parameterJs); });
|
|
268
303
|
handler(parameterList, error);
|
|
269
304
|
}
|
|
@@ -288,8 +323,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
288
323
|
return;
|
|
289
324
|
}
|
|
290
325
|
try {
|
|
291
|
-
var
|
|
292
|
-
var resultJs =
|
|
326
|
+
var jsonCodec = (0, nats_ws_1.JSONCodec)();
|
|
327
|
+
var resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
293
328
|
var result = DTOs_1.Result.fromJS(resultJs);
|
|
294
329
|
handler(result, error);
|
|
295
330
|
}
|
|
@@ -305,42 +340,16 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
305
340
|
* @param {SubscriptionOptions} options?
|
|
306
341
|
* @returns Subscription
|
|
307
342
|
*/
|
|
308
|
-
SessionClient.prototype.connectMetric = function (metricInfo, handler
|
|
309
|
-
|
|
310
|
-
? this.baseSubject
|
|
311
|
-
.split('.')
|
|
312
|
-
.map(function (part, index) { return (index === 4 ? sessionId : part); })
|
|
313
|
-
.join('.')
|
|
314
|
-
: this.baseSubject;
|
|
315
|
-
return this.createJetStreamConsumer('Metrics', "".concat(baseSubject, ".Events.Metrics.").concat(metricInfo.subjectPostfix), {
|
|
343
|
+
SessionClient.prototype.connectMetric = function (metricInfo, handler) {
|
|
344
|
+
return this.createJetStreamConsumer('Metrics', "M.".concat(metricInfo.subjectPostfix), {
|
|
316
345
|
domain: this.runnerId,
|
|
317
346
|
}).then(function (consumer) {
|
|
318
|
-
consumer
|
|
347
|
+
consumer.consume({
|
|
319
348
|
callback: function (encodedMessage) {
|
|
320
|
-
var
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
// Decode the value based on the metric value type given in the metric info
|
|
325
|
-
switch (metricInfo.type) {
|
|
326
|
-
case DTOs_1.SessionMetricType.Boolean:
|
|
327
|
-
value = encoders_1.booleanCodec.decode(encodedMessage.data);
|
|
328
|
-
break;
|
|
329
|
-
case DTOs_1.SessionMetricType.Double:
|
|
330
|
-
value = encoders_1.numberCodec.decode(encodedMessage.data);
|
|
331
|
-
break;
|
|
332
|
-
case DTOs_1.SessionMetricType.String:
|
|
333
|
-
value = encoders_1.stringCodec.decode(encodedMessage.data);
|
|
334
|
-
break;
|
|
335
|
-
default:
|
|
336
|
-
value = encoders_1.jsonCodec.decode(encodedMessage.data);
|
|
337
|
-
break;
|
|
338
|
-
}
|
|
339
|
-
handler(new DTOs_1.MetricValue({ value: value, time: time }), null);
|
|
340
|
-
}
|
|
341
|
-
catch (error) {
|
|
342
|
-
handler(undefined, error);
|
|
343
|
-
}
|
|
349
|
+
var _this = this;
|
|
350
|
+
(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
351
|
+
return [2 /*return*/, handler(encodedMessage, metricInfo.type)];
|
|
352
|
+
}); }); })();
|
|
344
353
|
},
|
|
345
354
|
});
|
|
346
355
|
return consumer;
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,7 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SystemClient = exports.SessionClient = exports.RunnerClient = void 0;
|
|
17
|
+
exports.SystemClient = exports.SessionClient = exports.RunnerClient = exports.stringCodec = exports.numberCodec = exports.jsonCodec = exports.booleanCodec = void 0;
|
|
18
|
+
var encoders_1 = require("./encoders");
|
|
19
|
+
Object.defineProperty(exports, "booleanCodec", { enumerable: true, get: function () { return encoders_1.booleanCodec; } });
|
|
20
|
+
Object.defineProperty(exports, "jsonCodec", { enumerable: true, get: function () { return encoders_1.jsonCodec; } });
|
|
21
|
+
Object.defineProperty(exports, "numberCodec", { enumerable: true, get: function () { return encoders_1.numberCodec; } });
|
|
22
|
+
Object.defineProperty(exports, "stringCodec", { enumerable: true, get: function () { return encoders_1.stringCodec; } });
|
|
18
23
|
var RunnerClient_1 = require("./RunnerClient");
|
|
19
24
|
Object.defineProperty(exports, "RunnerClient", { enumerable: true, get: function () { return RunnerClient_1.RunnerClient; } });
|
|
20
25
|
var SessionClient_1 = require("./SessionClient");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BreakPoints, CommonContext, CommonSettings, DataGridControl,
|
|
2
|
-
import { ConnectionOptions, Consumer, NatsError, Subscription, SubscriptionOptions } from 'nats.ws';
|
|
1
|
+
import { BreakPoints, CommonContext, CommonSettings, DataGridControl, IMetricsConfiguration, ISessionMetricInfo, Image, Interaction, ListItemType, LogList, MetricsConfiguration, OnTestPlanRun, OnTestStepRun, Parameter, RepositoryPackageDefinition, RepositoryPackageReference, Resource, Result, RunStatus, SessionEvent, SessionMetricType, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog } from './DTOs';
|
|
2
|
+
import { ConnectionOptions, Consumer, JsMsg, NatsError, Subscription, SubscriptionOptions } from 'nats.ws';
|
|
3
3
|
import { BaseClient } from './BaseClient';
|
|
4
4
|
export declare class SessionClient extends BaseClient {
|
|
5
5
|
private subscriptions;
|
|
@@ -89,7 +89,7 @@ export declare class SessionClient extends BaseClient {
|
|
|
89
89
|
* @param {SubscriptionOptions} options?
|
|
90
90
|
* @returns Subscription
|
|
91
91
|
*/
|
|
92
|
-
connectMetric(metricInfo: ISessionMetricInfo, handler: (result:
|
|
92
|
+
connectMetric(metricInfo: ISessionMetricInfo, handler: (result: JsMsg | undefined, type: SessionMetricType) => void): Promise<Consumer>;
|
|
93
93
|
/**
|
|
94
94
|
* Unsubscibe from session events
|
|
95
95
|
*/
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, MetricsConfiguration, OnTestPlanRun, OnTestStepRun, Parameter, Result, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog, } from './DTOs';
|
|
2
11
|
import { JSONCodec } from 'nats.ws';
|
|
3
|
-
import { booleanCodec, jsonCodec, numberCodec, stringCodec } from './encoders';
|
|
4
12
|
import { BaseClient } from './BaseClient';
|
|
5
13
|
import { getSubjectParts } from './utils';
|
|
6
14
|
export class SessionClient extends BaseClient {
|
|
@@ -274,42 +282,13 @@ export class SessionClient extends BaseClient {
|
|
|
274
282
|
* @param {SubscriptionOptions} options?
|
|
275
283
|
* @returns Subscription
|
|
276
284
|
*/
|
|
277
|
-
connectMetric(metricInfo, handler
|
|
278
|
-
|
|
279
|
-
? this.baseSubject
|
|
280
|
-
.split('.')
|
|
281
|
-
.map((part, index) => (index === 4 ? sessionId : part))
|
|
282
|
-
.join('.')
|
|
283
|
-
: this.baseSubject;
|
|
284
|
-
return this.createJetStreamConsumer('Metrics', `${baseSubject}.Events.Metrics.${metricInfo.subjectPostfix}`, {
|
|
285
|
+
connectMetric(metricInfo, handler) {
|
|
286
|
+
return this.createJetStreamConsumer('Metrics', `M.${metricInfo.subjectPostfix}`, {
|
|
285
287
|
domain: this.runnerId,
|
|
286
288
|
}).then(consumer => {
|
|
287
|
-
consumer
|
|
289
|
+
consumer.consume({
|
|
288
290
|
callback(encodedMessage) {
|
|
289
|
-
|
|
290
|
-
try {
|
|
291
|
-
const time = Number.parseInt((_b = (_a = encodedMessage.headers) === null || _a === void 0 ? void 0 : _a.get('timestamp')) !== null && _b !== void 0 ? _b : '');
|
|
292
|
-
let value;
|
|
293
|
-
// Decode the value based on the metric value type given in the metric info
|
|
294
|
-
switch (metricInfo.type) {
|
|
295
|
-
case SessionMetricType.Boolean:
|
|
296
|
-
value = booleanCodec.decode(encodedMessage.data);
|
|
297
|
-
break;
|
|
298
|
-
case SessionMetricType.Double:
|
|
299
|
-
value = numberCodec.decode(encodedMessage.data);
|
|
300
|
-
break;
|
|
301
|
-
case SessionMetricType.String:
|
|
302
|
-
value = stringCodec.decode(encodedMessage.data);
|
|
303
|
-
break;
|
|
304
|
-
default:
|
|
305
|
-
value = jsonCodec.decode(encodedMessage.data);
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
handler(new MetricValue({ value, time }), null);
|
|
309
|
-
}
|
|
310
|
-
catch (error) {
|
|
311
|
-
handler(undefined, error);
|
|
312
|
-
}
|
|
291
|
+
(() => __awaiter(this, void 0, void 0, function* () { return handler(encodedMessage, metricInfo.type); }))();
|
|
313
292
|
},
|
|
314
293
|
});
|
|
315
294
|
return consumer;
|
package/dist/mjs/index.d.ts
CHANGED
package/dist/mjs/index.js
CHANGED
package/package.json
CHANGED