@opentap/runner-client 2.23.0-alpha.5.5.10792848470 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BaseClient.js +20 -0
- package/dist/cjs/SessionClient.js +39 -38
- package/dist/cjs/SystemClient.js +7 -0
- package/dist/cjs/utils.js +16 -0
- package/dist/mjs/BaseClient.d.ts +9 -2
- package/dist/mjs/BaseClient.js +18 -1
- package/dist/mjs/DTOs.d.ts +4 -0
- package/dist/mjs/SessionClient.d.ts +2 -1
- package/dist/mjs/SessionClient.js +40 -38
- package/dist/mjs/SystemClient.d.ts +2 -1
- package/dist/mjs/SystemClient.js +7 -0
- package/dist/mjs/utils.d.ts +11 -0
- package/dist/mjs/utils.js +12 -0
- package/package.json +1 -1
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -275,6 +275,26 @@ var BaseClient = /** @class */ (function () {
|
|
|
275
275
|
var natsSubject = "".concat(this.baseSubject, ".").concat(subject);
|
|
276
276
|
return this.connection.subscribe(natsSubject, options);
|
|
277
277
|
};
|
|
278
|
+
/**
|
|
279
|
+
* Subscribes to given subject.
|
|
280
|
+
* @param subject The subject to subscribe
|
|
281
|
+
* @param options Subscription options
|
|
282
|
+
* @returns Subscription object
|
|
283
|
+
*/
|
|
284
|
+
BaseClient.prototype.createJetStreamConsumer = function (stream, subject, options) {
|
|
285
|
+
var _this = this;
|
|
286
|
+
if (!this.connection) {
|
|
287
|
+
throw Error('Connection is not established');
|
|
288
|
+
}
|
|
289
|
+
return this.connection.jetstreamManager(__assign({}, options)).then(function (jetStreamManager) {
|
|
290
|
+
return jetStreamManager.consumers
|
|
291
|
+
.add(stream, {
|
|
292
|
+
filter_subject: subject,
|
|
293
|
+
ack_policy: nats_ws_1.AckPolicy.None,
|
|
294
|
+
})
|
|
295
|
+
.then(function (consumerInfo) { return _this.connection.jetstream(options).consumers.get(consumerInfo.stream_name, consumerInfo.name); });
|
|
296
|
+
});
|
|
297
|
+
};
|
|
278
298
|
BaseClient.prototype.encode = function (payload) {
|
|
279
299
|
if (!payload) {
|
|
280
300
|
return nats_ws_1.Empty;
|
|
@@ -31,11 +31,13 @@ var DTOs_1 = require("./DTOs");
|
|
|
31
31
|
var nats_ws_1 = require("nats.ws");
|
|
32
32
|
var encoders_1 = require("./encoders");
|
|
33
33
|
var BaseClient_1 = require("./BaseClient");
|
|
34
|
+
var utils_1 = require("./utils");
|
|
34
35
|
var SessionClient = /** @class */ (function (_super) {
|
|
35
36
|
__extends(SessionClient, _super);
|
|
36
37
|
function SessionClient(baseSubject, options) {
|
|
37
38
|
var _this = _super.call(this, baseSubject, options) || this;
|
|
38
39
|
_this.subscriptions = [];
|
|
40
|
+
_this.runnerId = (0, utils_1.getSubjectParts)(baseSubject).runnerId;
|
|
39
41
|
return _this;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
@@ -303,46 +305,45 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
303
305
|
* @param {SubscriptionOptions} options?
|
|
304
306
|
* @returns Subscription
|
|
305
307
|
*/
|
|
306
|
-
SessionClient.prototype.connectMetric = function (metricInfo, handler) {
|
|
307
|
-
var
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
.
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
handler(new DTOs_1.MetricValue({ value: value, time: time }), null);
|
|
338
|
-
}
|
|
339
|
-
catch (error) {
|
|
340
|
-
handler(undefined, error);
|
|
308
|
+
SessionClient.prototype.connectMetric = function (metricInfo, handler, sessionId) {
|
|
309
|
+
var baseSubject = sessionId
|
|
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), {
|
|
316
|
+
domain: this.runnerId,
|
|
317
|
+
}).then(function (consumer) {
|
|
318
|
+
consumer === null || consumer === void 0 ? void 0 : consumer.consume({
|
|
319
|
+
callback: function (encodedMessage) {
|
|
320
|
+
var _a, _b;
|
|
321
|
+
try {
|
|
322
|
+
var time = Number.parseInt((_b = (_a = encodedMessage.headers) === null || _a === void 0 ? void 0 : _a.get('timestamp')) !== null && _b !== void 0 ? _b : '');
|
|
323
|
+
var value = void 0;
|
|
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;
|
|
341
338
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
339
|
+
handler(new DTOs_1.MetricValue({ value: value, time: time }), null);
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
handler(undefined, error);
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
345
|
});
|
|
346
|
+
return consumer;
|
|
346
347
|
});
|
|
347
348
|
};
|
|
348
349
|
/**
|
package/dist/cjs/SystemClient.js
CHANGED
|
@@ -35,6 +35,13 @@ var SystemClient = /** @class */ (function (_super) {
|
|
|
35
35
|
function SystemClient(baseSubject, options) {
|
|
36
36
|
return _super.call(this, baseSubject, options) || this;
|
|
37
37
|
}
|
|
38
|
+
SystemClient.prototype.changeIdleSession = function (request) {
|
|
39
|
+
return this.request("".concat(this.baseSubject, ".RunnerRegistry.Request.ChangeIdleSession"), request, {
|
|
40
|
+
fullSubject: true,
|
|
41
|
+
})
|
|
42
|
+
.then(this.success())
|
|
43
|
+
.catch(this.error());
|
|
44
|
+
};
|
|
38
45
|
/**
|
|
39
46
|
* Subscribe to the lifetime event.
|
|
40
47
|
* @param listener
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSubjectParts = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Get the runner ID and session ID from the subject as SubjectParts.
|
|
6
|
+
* @param {string} subject
|
|
7
|
+
* @returns SubjectParts
|
|
8
|
+
*/
|
|
9
|
+
var getSubjectParts = function (subject) {
|
|
10
|
+
var parts = subject.split('.');
|
|
11
|
+
return {
|
|
12
|
+
runnerId: parts[2],
|
|
13
|
+
sessionId: parts[4],
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
exports.getSubjectParts = getSubjectParts;
|
package/dist/mjs/BaseClient.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DownloadTapSettingsRequest } from './requestDTOs';
|
|
2
2
|
import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileParameter, ListItemType, ProfileGroup, RepositoryPackageReference, RepositorySettingsPackageDefinition } from './DTOs';
|
|
3
|
-
import { ConnectionOptions,
|
|
3
|
+
import { ConnectionOptions, NatsError, Subscription, SubscriptionOptions, PublishOptions, JetStreamOptions, Consumer } from 'nats.ws';
|
|
4
4
|
interface BaseClientRequestOptions {
|
|
5
5
|
publishOptions?: PublishOptions;
|
|
6
6
|
rawResponse?: boolean;
|
|
@@ -9,7 +9,7 @@ interface BaseClientRequestOptions {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class BaseClient {
|
|
11
11
|
readonly baseSubject: string;
|
|
12
|
-
|
|
12
|
+
private connection;
|
|
13
13
|
private connectionOptions;
|
|
14
14
|
private domainAccess;
|
|
15
15
|
private eventEmitter;
|
|
@@ -61,6 +61,13 @@ export declare class BaseClient {
|
|
|
61
61
|
* @returns Subscription object
|
|
62
62
|
*/
|
|
63
63
|
protected subscribe(subject: string, options: SubscriptionOptions): Subscription;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribes to given subject.
|
|
66
|
+
* @param subject The subject to subscribe
|
|
67
|
+
* @param options Subscription options
|
|
68
|
+
* @returns Subscription object
|
|
69
|
+
*/
|
|
70
|
+
protected createJetStreamConsumer(stream: string, subject: string, options: JetStreamOptions): Promise<Consumer>;
|
|
64
71
|
protected encode(payload: any): Uint8Array;
|
|
65
72
|
/**
|
|
66
73
|
* Create a connection to the nats server.
|
package/dist/mjs/BaseClient.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileDescriptor, ListItemType, ProfileGroup, } from './DTOs';
|
|
11
|
-
import { Empty, ErrorCode, JSONCodec, StringCodec, connect, headers, } from 'nats.ws';
|
|
11
|
+
import { Empty, ErrorCode, JSONCodec, StringCodec, connect, headers, AckPolicy, } from 'nats.ws';
|
|
12
12
|
import { EventEmitter } from 'events';
|
|
13
13
|
import { v4 as uuidv4 } from 'uuid';
|
|
14
14
|
const DEFAULT_TIMEOUT = 40000; // default timeout of 40 seconds
|
|
@@ -229,6 +229,23 @@ export class BaseClient {
|
|
|
229
229
|
const natsSubject = `${this.baseSubject}.${subject}`;
|
|
230
230
|
return this.connection.subscribe(natsSubject, options);
|
|
231
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Subscribes to given subject.
|
|
234
|
+
* @param subject The subject to subscribe
|
|
235
|
+
* @param options Subscription options
|
|
236
|
+
* @returns Subscription object
|
|
237
|
+
*/
|
|
238
|
+
createJetStreamConsumer(stream, subject, options) {
|
|
239
|
+
if (!this.connection) {
|
|
240
|
+
throw Error('Connection is not established');
|
|
241
|
+
}
|
|
242
|
+
return this.connection.jetstreamManager(Object.assign({}, options)).then(jetStreamManager => jetStreamManager.consumers
|
|
243
|
+
.add(stream, {
|
|
244
|
+
filter_subject: subject,
|
|
245
|
+
ack_policy: AckPolicy.None,
|
|
246
|
+
})
|
|
247
|
+
.then(consumerInfo => this.connection.jetstream(options).consumers.get(consumerInfo.stream_name, consumerInfo.name)));
|
|
248
|
+
}
|
|
232
249
|
encode(payload) {
|
|
233
250
|
if (!payload) {
|
|
234
251
|
return Empty;
|
package/dist/mjs/DTOs.d.ts
CHANGED
|
@@ -1145,6 +1145,10 @@ export interface IMetricValue {
|
|
|
1145
1145
|
time: number;
|
|
1146
1146
|
value: boolean | number | string | object;
|
|
1147
1147
|
}
|
|
1148
|
+
export interface ChangeIdleSessionRequest {
|
|
1149
|
+
runnerId: string;
|
|
1150
|
+
sessionId: string;
|
|
1151
|
+
}
|
|
1148
1152
|
export declare class SessionEvent implements ISessionEvent {
|
|
1149
1153
|
eventType?: SessionEventType;
|
|
1150
1154
|
sessionId?: string;
|
|
@@ -3,6 +3,7 @@ import { ConnectionOptions, Consumer, NatsError, Subscription, SubscriptionOptio
|
|
|
3
3
|
import { BaseClient } from './BaseClient';
|
|
4
4
|
export declare class SessionClient extends BaseClient {
|
|
5
5
|
private subscriptions;
|
|
6
|
+
private runnerId;
|
|
6
7
|
constructor(baseSubject: string, options: ConnectionOptions);
|
|
7
8
|
/**
|
|
8
9
|
* @param sessionLogsHandler Function to be called when log list or error is received
|
|
@@ -88,7 +89,7 @@ export declare class SessionClient extends BaseClient {
|
|
|
88
89
|
* @param {SubscriptionOptions} options?
|
|
89
90
|
* @returns Subscription
|
|
90
91
|
*/
|
|
91
|
-
connectMetric(metricInfo: ISessionMetricInfo, handler: (result: IMetricValue | undefined, err: NatsError | Error | null) => void): Promise<Consumer
|
|
92
|
+
connectMetric(metricInfo: ISessionMetricInfo, handler: (result: IMetricValue | undefined, err: NatsError | Error | null) => void, sessionId?: string): Promise<Consumer>;
|
|
92
93
|
/**
|
|
93
94
|
* Unsubscibe from session events
|
|
94
95
|
*/
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, MetricValue, MetricsConfiguration, OnTestPlanRun, OnTestStepRun, Parameter, Result, RunStatus, SessionEvent, SessionMetricType, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog, } from './DTOs';
|
|
2
|
-
import { JSONCodec
|
|
2
|
+
import { JSONCodec } from 'nats.ws';
|
|
3
3
|
import { booleanCodec, jsonCodec, numberCodec, stringCodec } from './encoders';
|
|
4
4
|
import { BaseClient } from './BaseClient';
|
|
5
|
+
import { getSubjectParts } from './utils';
|
|
5
6
|
export class SessionClient extends BaseClient {
|
|
6
7
|
constructor(baseSubject, options) {
|
|
7
8
|
super(baseSubject, options);
|
|
8
9
|
this.subscriptions = [];
|
|
10
|
+
this.runnerId = getSubjectParts(baseSubject).runnerId;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* @param sessionLogsHandler Function to be called when log list or error is received
|
|
@@ -272,45 +274,45 @@ export class SessionClient extends BaseClient {
|
|
|
272
274
|
* @param {SubscriptionOptions} options?
|
|
273
275
|
* @returns Subscription
|
|
274
276
|
*/
|
|
275
|
-
connectMetric(metricInfo, handler) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
handler(new MetricValue({ value, time }), null);
|
|
306
|
-
}
|
|
307
|
-
catch (error) {
|
|
308
|
-
handler(undefined, error);
|
|
277
|
+
connectMetric(metricInfo, handler, sessionId) {
|
|
278
|
+
const baseSubject = sessionId
|
|
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
|
+
domain: this.runnerId,
|
|
286
|
+
}).then(consumer => {
|
|
287
|
+
consumer === null || consumer === void 0 ? void 0 : consumer.consume({
|
|
288
|
+
callback(encodedMessage) {
|
|
289
|
+
var _a, _b;
|
|
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;
|
|
309
307
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
308
|
+
handler(new MetricValue({ value, time }), null);
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
handler(undefined, error);
|
|
312
|
+
}
|
|
313
|
+
},
|
|
313
314
|
});
|
|
315
|
+
return consumer;
|
|
314
316
|
});
|
|
315
317
|
}
|
|
316
318
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConnectionOptions, Subscription, SubscriptionOptions } from 'nats.ws';
|
|
2
|
-
import { ErrorResponse, RunnerEvent, TestPlanRunCompletedEventArgs, TestPlanRunStartEventArgs, TestStepRunCompletedEventArgs, TestStepRunStartEventArgs } from './DTOs';
|
|
2
|
+
import { ChangeIdleSessionRequest, ErrorResponse, RunnerEvent, TestPlanRunCompletedEventArgs, TestPlanRunStartEventArgs, TestStepRunCompletedEventArgs, TestStepRunStartEventArgs } from './DTOs';
|
|
3
3
|
import { BaseClient } from './BaseClient';
|
|
4
4
|
export interface RunnerLifetimeEvent {
|
|
5
5
|
RunnerId: string;
|
|
@@ -8,6 +8,7 @@ export interface RunnerLifetimeEvent {
|
|
|
8
8
|
}
|
|
9
9
|
export declare class SystemClient extends BaseClient {
|
|
10
10
|
constructor(baseSubject: string, options: ConnectionOptions);
|
|
11
|
+
changeIdleSession(request: ChangeIdleSessionRequest): Promise<void>;
|
|
11
12
|
/**
|
|
12
13
|
* Subscribe to the lifetime event.
|
|
13
14
|
* @param listener
|
package/dist/mjs/SystemClient.js
CHANGED
|
@@ -5,6 +5,13 @@ export class SystemClient extends BaseClient {
|
|
|
5
5
|
constructor(baseSubject, options) {
|
|
6
6
|
super(baseSubject, options);
|
|
7
7
|
}
|
|
8
|
+
changeIdleSession(request) {
|
|
9
|
+
return this.request(`${this.baseSubject}.RunnerRegistry.Request.ChangeIdleSession`, request, {
|
|
10
|
+
fullSubject: true,
|
|
11
|
+
})
|
|
12
|
+
.then(this.success())
|
|
13
|
+
.catch(this.error());
|
|
14
|
+
}
|
|
8
15
|
/**
|
|
9
16
|
* Subscribe to the lifetime event.
|
|
10
17
|
* @param listener
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface SubjectParts {
|
|
2
|
+
runnerId: string | undefined;
|
|
3
|
+
sessionId: string | undefined;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Get the runner ID and session ID from the subject as SubjectParts.
|
|
7
|
+
* @param {string} subject
|
|
8
|
+
* @returns SubjectParts
|
|
9
|
+
*/
|
|
10
|
+
export declare const getSubjectParts: (subject: string) => SubjectParts;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the runner ID and session ID from the subject as SubjectParts.
|
|
3
|
+
* @param {string} subject
|
|
4
|
+
* @returns SubjectParts
|
|
5
|
+
*/
|
|
6
|
+
export const getSubjectParts = (subject) => {
|
|
7
|
+
const parts = subject.split('.');
|
|
8
|
+
return {
|
|
9
|
+
runnerId: parts[2],
|
|
10
|
+
sessionId: parts[4],
|
|
11
|
+
};
|
|
12
|
+
};
|
package/package.json
CHANGED