@opentap/runner-client 1.2.1 → 1.2.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -13
- package/lib/BaseClient.js +1 -1
- package/lib/SessionClient.d.ts +7 -1
- package/lib/SessionClient.js +28 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,15 +9,15 @@ This is the web client for the OpenTAP Runner.
|
|
|
9
9
|
- [@OpenTAP.io](https://opentap.io/)
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## How to install the client
|
|
13
13
|
|
|
14
|
-
Install
|
|
14
|
+
Install with npm
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
npm install @opentap/runner-client
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## How to use the client
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
23
|
import { RunnerClient } from "@openTap/runner-client";
|
|
@@ -27,34 +27,34 @@ class client {
|
|
|
27
27
|
|
|
28
28
|
constructor() {
|
|
29
29
|
this.runnerClient = new RunnerClient('<BASE_SUBJECT>', { servers: '<SERVER_ADDRESS>' });
|
|
30
|
+
// Always connect first
|
|
31
|
+
this.runnerClient.connect()
|
|
32
|
+
.then(() => console.log('CONNECTED'))
|
|
33
|
+
.catch(err => console.log(err));
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
getImages() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.catch(error => console.error(error));
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.error(error);
|
|
39
|
-
}
|
|
37
|
+
this.data = this.runnerClient?.getImages()
|
|
38
|
+
.then(res => console.log(res))
|
|
39
|
+
.catch(error => console.error(error));
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
##
|
|
46
|
+
## How to build locally
|
|
47
47
|
|
|
48
48
|
Clone the project
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
git clone https://
|
|
51
|
+
~ git clone https://github.com/opentap/runner-client-web.git
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
Go to the project directory
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
|
-
cd
|
|
57
|
+
~ cd runner-client-web
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
Install dependencies
|
|
@@ -69,6 +69,7 @@ Build the library
|
|
|
69
69
|
npm run build
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
## How to debug the project
|
|
72
73
|
|
|
73
74
|
## License
|
|
74
75
|
|
package/lib/BaseClient.js
CHANGED
|
@@ -184,7 +184,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
184
184
|
* @returns {boolean}
|
|
185
185
|
*/
|
|
186
186
|
BaseClient.prototype.isErrorResponse = function (response) {
|
|
187
|
-
return response && typeof response === 'object' && ['Type', 'Message', 'StackTrace'
|
|
187
|
+
return response && typeof response === 'object' && ['Type', 'Message', 'StackTrace'].every(function (prop) { return prop in response; });
|
|
188
188
|
};
|
|
189
189
|
/**
|
|
190
190
|
* Create a connection to the nats server.
|
package/lib/SessionClient.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Int
|
|
|
2
2
|
import { ConnectionOptions, NatsError, Subscription, SubscriptionOptions } from 'nats.ws/cjs/nats.js';
|
|
3
3
|
import { BaseClient } from './BaseClient';
|
|
4
4
|
export declare class SessionClient extends BaseClient {
|
|
5
|
+
private eventsSubscription;
|
|
6
|
+
private eventsWildcardSubscription;
|
|
5
7
|
constructor(baseSubject: string, options: ConnectionOptions);
|
|
6
8
|
/**
|
|
7
9
|
* @param sessionLogsHandler Function to be called when log list or error is received
|
|
@@ -14,7 +16,7 @@ export declare class SessionClient extends BaseClient {
|
|
|
14
16
|
* @param options (optional) Subscription options
|
|
15
17
|
* @returns Subscription object
|
|
16
18
|
*/
|
|
17
|
-
connectSessionEvents(eventHandler: (sessionEvent: SessionEvent | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions):
|
|
19
|
+
connectSessionEvents(eventHandler: (sessionEvent: SessionEvent | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): void;
|
|
18
20
|
/**
|
|
19
21
|
* @param resultHandler Function to be called when result or error is received
|
|
20
22
|
* @param testRunHandler Function to be called when test run or error is received
|
|
@@ -22,6 +24,10 @@ export declare class SessionClient extends BaseClient {
|
|
|
22
24
|
* @returns Subscription array: Result and Test Run subscriptions
|
|
23
25
|
*/
|
|
24
26
|
connectSessionResults(resultHandler: (result: Result | undefined, err: NatsError | Error | null) => void, testRunHandler: (testRun: TestRun | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): [Subscription, Subscription];
|
|
27
|
+
/**
|
|
28
|
+
* Unsubscibe from session events
|
|
29
|
+
*/
|
|
30
|
+
unsubscribeSessionEvents(): void;
|
|
25
31
|
/**
|
|
26
32
|
* Retrieve session logs
|
|
27
33
|
* @param id (optional)
|
package/lib/SessionClient.js
CHANGED
|
@@ -60,21 +60,23 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
60
60
|
* @returns Subscription object
|
|
61
61
|
*/
|
|
62
62
|
SessionClient.prototype.connectSessionEvents = function (eventHandler, options) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
var callback = function (error, encodedMessage) {
|
|
64
|
+
if (error) {
|
|
65
|
+
eventHandler(undefined, error);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
var jsonCodec = JSONCodec();
|
|
70
|
+
var sessionEventJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
|
|
71
|
+
var sessionEvent = SessionEvent.fromJS(sessionEventJs);
|
|
72
|
+
eventHandler(sessionEvent, error);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
eventHandler(undefined, error);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
this.eventsSubscription = this.subscribe('Events', __assign(__assign({}, options), { callback: callback }));
|
|
79
|
+
this.eventsWildcardSubscription = this.subscribe('Events.*', __assign(__assign({}, options), { callback: callback }));
|
|
78
80
|
};
|
|
79
81
|
/**
|
|
80
82
|
* @param resultHandler Function to be called when result or error is received
|
|
@@ -116,6 +118,17 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
116
118
|
} })),
|
|
117
119
|
];
|
|
118
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* Unsubscibe from session events
|
|
123
|
+
*/
|
|
124
|
+
SessionClient.prototype.unsubscribeSessionEvents = function () {
|
|
125
|
+
if (this.eventsSubscription) {
|
|
126
|
+
this.eventsSubscription.unsubscribe();
|
|
127
|
+
}
|
|
128
|
+
if (this.eventsWildcardSubscription) {
|
|
129
|
+
this.eventsWildcardSubscription.unsubscribe();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
119
132
|
/**
|
|
120
133
|
* Retrieve session logs
|
|
121
134
|
* @param id (optional)
|