@opentap/runner-client 1.0.0-beta.74 → 1.0.0-beta.75
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/lib/BaseClient.d.ts +3 -5
- package/lib/BaseClient.js +12 -17
- package/package.json +1 -1
- package/readme.md +25 -17
package/lib/BaseClient.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ConnectionOptions,
|
|
1
|
+
import { ConnectionOptions, RequestOptions } from 'nats.ws/cjs/nats.js';
|
|
2
2
|
import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileParameter, FileResponse, ListItemType, ProfileGroup, RepositoryPackageReference, RepositorySettingsPackageDefinition, SettingsTapPackage } from './DTOs';
|
|
3
3
|
export declare class BaseClient {
|
|
4
|
+
private connection;
|
|
5
|
+
private domainAccess;
|
|
4
6
|
private _accessToken;
|
|
5
7
|
/** Get access token */
|
|
6
8
|
get accessToken(): string;
|
|
@@ -17,10 +19,6 @@ export declare class BaseClient {
|
|
|
17
19
|
private _connectionOptions;
|
|
18
20
|
/** Get connection options */
|
|
19
21
|
get connectionOptions(): ConnectionOptions;
|
|
20
|
-
private _connection;
|
|
21
|
-
/** Get connection instance */
|
|
22
|
-
get connection(): NatsConnection;
|
|
23
|
-
private domainAccess;
|
|
24
22
|
constructor(baseSubject: string, options: ConnectionOptions);
|
|
25
23
|
/**
|
|
26
24
|
* Send a request to the nats server.
|
package/lib/BaseClient.js
CHANGED
|
@@ -87,14 +87,6 @@ var BaseClient = /** @class */ (function () {
|
|
|
87
87
|
enumerable: false,
|
|
88
88
|
configurable: true
|
|
89
89
|
});
|
|
90
|
-
Object.defineProperty(BaseClient.prototype, "connection", {
|
|
91
|
-
/** Get connection instance */
|
|
92
|
-
get: function () {
|
|
93
|
-
return this._connection;
|
|
94
|
-
},
|
|
95
|
-
enumerable: false,
|
|
96
|
-
configurable: true
|
|
97
|
-
});
|
|
98
90
|
/**
|
|
99
91
|
* Send a request to the nats server.
|
|
100
92
|
* @param subject The subject to request
|
|
@@ -103,15 +95,18 @@ var BaseClient = /** @class */ (function () {
|
|
|
103
95
|
* @returns Promise of an object
|
|
104
96
|
*/
|
|
105
97
|
BaseClient.prototype.request = function (subject, payload, options) {
|
|
106
|
-
var _a;
|
|
107
98
|
return __awaiter(this, void 0, void 0, function () {
|
|
108
99
|
var stringCodec, data;
|
|
109
100
|
var _this = this;
|
|
110
|
-
return __generator(this, function (
|
|
111
|
-
switch (
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
switch (_a.label) {
|
|
112
103
|
case 0:
|
|
113
|
-
if (!subject
|
|
114
|
-
return [2 /*return*/, Promise.reject()];
|
|
104
|
+
if (!subject)
|
|
105
|
+
return [2 /*return*/, Promise.reject('Subject is not defined!')];
|
|
106
|
+
if (!this.connection)
|
|
107
|
+
return [2 /*return*/, Promise.reject('Connection is down! Please try again!')];
|
|
108
|
+
if (this.connection.isClosed())
|
|
109
|
+
return [2 /*return*/, Promise.reject('Connection has been closed! Please reconnect!')];
|
|
115
110
|
subject = "".concat(this.baseSubject, ".Request.").concat(subject);
|
|
116
111
|
stringCodec = StringCodec();
|
|
117
112
|
data = payload ? stringCodec.encode(JSON.stringify(payload)) : Empty;
|
|
@@ -134,7 +129,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
134
129
|
return Promise.reject(error);
|
|
135
130
|
}
|
|
136
131
|
})];
|
|
137
|
-
case 1: return [2 /*return*/,
|
|
132
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
138
133
|
}
|
|
139
134
|
});
|
|
140
135
|
});
|
|
@@ -160,7 +155,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
160
155
|
case 0:
|
|
161
156
|
_a.trys.push([0, 2, , 3]);
|
|
162
157
|
return [4 /*yield*/, connect(options).then(function (connection) {
|
|
163
|
-
_this.
|
|
158
|
+
_this.connection = connection;
|
|
164
159
|
})];
|
|
165
160
|
case 1:
|
|
166
161
|
_a.sent();
|
|
@@ -182,8 +177,8 @@ var BaseClient = /** @class */ (function () {
|
|
|
182
177
|
return __generator(this, function (_b) {
|
|
183
178
|
switch (_b.label) {
|
|
184
179
|
case 0:
|
|
185
|
-
if (!this.
|
|
186
|
-
return [4 /*yield*/, ((_a = this.
|
|
180
|
+
if (!this.connection) return [3 /*break*/, 2];
|
|
181
|
+
return [4 /*yield*/, ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.close().catch(function (error) {
|
|
187
182
|
throw new Error("failed to close connection: ".concat(error));
|
|
188
183
|
}))];
|
|
189
184
|
case 1:
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
# OpenTap Runner Client
|
|
3
3
|
|
|
4
|
-
This is the
|
|
4
|
+
This is the web client for the OpenTAP Runner.
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
## Authors
|
|
@@ -14,18 +14,32 @@ This is the TypeScript Client for the OpenTAP Runner Plugin.
|
|
|
14
14
|
Install my-project with npm
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install
|
|
18
|
-
cd my-project
|
|
17
|
+
npm install @opentap/runner-client
|
|
19
18
|
```
|
|
20
19
|
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
## Usage example
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { RunnerClient } from "@openTap/runner-client";
|
|
24
|
+
|
|
25
|
+
class client {
|
|
26
|
+
runnerClient: RunnerClient;
|
|
27
|
+
|
|
28
|
+
constructor() {
|
|
29
|
+
this.runnerClient = new RunnerClient('<BASE_SUBJECT>', { servers: '<SERVER_ADDRESS>' });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getImages() {
|
|
33
|
+
try {
|
|
34
|
+
this.data = this.runnerClient?.getImages()
|
|
35
|
+
.then(res => console.log(res))
|
|
36
|
+
.catch(error => console.error(error));
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error(error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
28
41
|
}
|
|
42
|
+
|
|
29
43
|
```
|
|
30
44
|
|
|
31
45
|
|
|
@@ -49,19 +63,13 @@ Install dependencies
|
|
|
49
63
|
npm install
|
|
50
64
|
```
|
|
51
65
|
|
|
52
|
-
|
|
66
|
+
Build the library
|
|
53
67
|
|
|
54
68
|
```bash
|
|
55
69
|
npm run build
|
|
56
70
|
```
|
|
57
71
|
|
|
58
72
|
|
|
59
|
-
## Test
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
npm run test
|
|
63
|
-
```
|
|
64
73
|
## License
|
|
65
74
|
|
|
66
75
|
[MIT](https://choosealicense.com/licenses/mit/)
|
|
67
|
-
|