@opentap/runner-client 2.20.0-alpha.1.7.7789778780 → 2.20.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.
@@ -0,0 +1,159 @@
1
+ import { JSONCodec } from 'nats.ws';
2
+ import { RunnerEvent, TestPlanRunCompletedEventArgs, TestPlanRunStartEventArgs, TestStepRunCompletedEventArgs, TestStepRunStartEventArgs, } from './DTOs';
3
+ import { BaseClient } from './BaseClient';
4
+ export class SystemClient extends BaseClient {
5
+ constructor(baseSubject, options) {
6
+ super(baseSubject, options);
7
+ }
8
+ /**
9
+ * Subscribe to the lifetime event.
10
+ * @param listener
11
+ * @param {SubscriptionOptions} options
12
+ * @returns {Subscription}
13
+ */
14
+ subscribeLifetimeEventListener(listener, options) {
15
+ const subject = 'Runner.*.Events.Lifetime';
16
+ return this.subscribe(subject, Object.assign(Object.assign({}, options), { callback: (error, message) => {
17
+ if (error) {
18
+ listener(this.natsErrorHandler(error, subject), null);
19
+ return;
20
+ }
21
+ try {
22
+ const jsonCodec = JSONCodec();
23
+ const data = jsonCodec.decode(message === null || message === void 0 ? void 0 : message.data);
24
+ listener(null, data);
25
+ }
26
+ catch (error) {
27
+ listener(this.natsErrorHandler(error, subject), null);
28
+ }
29
+ } }));
30
+ }
31
+ /**
32
+ * Subscribe to the runner updated events for the given Runner ID.
33
+ * Wildcard can be used to receive all runner updated events.
34
+ * @param {string} runnerId
35
+ * @param {(error:ErrorResponse|null,message:RunnerEvent|null)=>void} listener
36
+ * @param {SubscriptionOptions} options?
37
+ */
38
+ subscribeRunnerUpdatedEvents(runnerId, listener, options) {
39
+ const subject = `RunnerRegistry.${runnerId}.Events.Updated`;
40
+ return this.subscribe(subject, Object.assign(Object.assign({}, options), { callback: (error, message) => {
41
+ if (error) {
42
+ listener(this.natsErrorHandler(error, subject), null);
43
+ return;
44
+ }
45
+ try {
46
+ const jsonCodec = JSONCodec();
47
+ const data = RunnerEvent.fromJS(jsonCodec.decode(message === null || message === void 0 ? void 0 : message.data));
48
+ listener(null, data);
49
+ }
50
+ catch (error) {
51
+ listener(this.natsErrorHandler(error, subject), null);
52
+ }
53
+ } }));
54
+ }
55
+ /**
56
+ * Subscribe to the test step run start events for the given Runner and Run ID.
57
+ * Wildcard can be used for the Runner or Run ID to receive all test step run start events.
58
+ * @param {string} runnerId
59
+ * @param {string} runId
60
+ * @param {(error:ErrorResponse|null,message:TestStepRunStartEventArgs|null)=>void} listener
61
+ * @param {SubscriptionOptions} options?
62
+ */
63
+ subscribeTestStepRunStartEventListener(runnerId, runId, listener, options) {
64
+ const subject = `Runner.${runnerId}.Runs.${runId}.Events.TestStepRunStart`;
65
+ return this.subscribe(subject, Object.assign(Object.assign({}, options), { callback: (error, message) => {
66
+ if (error) {
67
+ listener(this.natsErrorHandler(error, subject), null);
68
+ return;
69
+ }
70
+ try {
71
+ const jsonCodec = JSONCodec();
72
+ const testStepRunStartEventArgsJs = jsonCodec.decode(message === null || message === void 0 ? void 0 : message.data);
73
+ const testStepRunStartEventArgs = TestStepRunStartEventArgs.fromJS(testStepRunStartEventArgsJs);
74
+ listener(null, testStepRunStartEventArgs);
75
+ }
76
+ catch (error) {
77
+ listener(this.natsErrorHandler(error, subject), null);
78
+ }
79
+ } }));
80
+ }
81
+ /**
82
+ * Subscribe to the test step run completed events for the given Runner and Run ID.
83
+ * Wildcard can be used for the Runner or Run ID to receive all test step run completed events.
84
+ * @param {string} runnerId
85
+ * @param {string} runId
86
+ * @param {(error:ErrorResponse|null,message:TestStepRunStartEventArgs|null)=>void} listener
87
+ * @param {SubscriptionOptions} options?
88
+ */
89
+ subscribeTestStepRunCompletedEventListener(runnerId, runId, listener, options) {
90
+ const subject = `Runner.${runnerId}.Runs.${runId}.Events.TestStepRunCompleted`;
91
+ return this.subscribe(subject, Object.assign(Object.assign({}, options), { callback: (error, message) => {
92
+ if (error) {
93
+ listener(this.natsErrorHandler(error, subject), null);
94
+ return;
95
+ }
96
+ try {
97
+ const jsonCodec = JSONCodec();
98
+ const testStepRunCompletedEventArgsJs = jsonCodec.decode(message === null || message === void 0 ? void 0 : message.data);
99
+ const testStepRunCompletedEventArgs = TestStepRunCompletedEventArgs.fromJS(testStepRunCompletedEventArgsJs);
100
+ listener(null, testStepRunCompletedEventArgs);
101
+ }
102
+ catch (error) {
103
+ listener(this.natsErrorHandler(error, subject), null);
104
+ }
105
+ } }));
106
+ }
107
+ /**
108
+ * Subscribe to the test plan run start events for the given Runner and Run ID.
109
+ * Wildcard can be used for the Runner or Run ID to receive all test plan run start events.
110
+ * @param {string} runnerId
111
+ * @param {string} runId
112
+ * @param {(error:ErrorResponse|null,message:TestStepRunStartEventArgs|null)=>void} listener
113
+ * @param {SubscriptionOptions} options?
114
+ */
115
+ subscribeTestPlanRunStartEventListener(runnerId, runId, listener, options) {
116
+ const subject = `Runner.${runnerId}.Runs.${runId}.Events.TestPlanRunStart`;
117
+ return this.subscribe(subject, Object.assign(Object.assign({}, options), { callback: (error, message) => {
118
+ if (error) {
119
+ listener(this.natsErrorHandler(error, subject), null);
120
+ return;
121
+ }
122
+ try {
123
+ const jsonCodec = JSONCodec();
124
+ const testPlanRunStartEventArgsJs = jsonCodec.decode(message === null || message === void 0 ? void 0 : message.data);
125
+ const testPlanRunStartEventArgs = TestPlanRunStartEventArgs.fromJS(testPlanRunStartEventArgsJs);
126
+ listener(null, testPlanRunStartEventArgs);
127
+ }
128
+ catch (error) {
129
+ listener(this.natsErrorHandler(error, subject), null);
130
+ }
131
+ } }));
132
+ }
133
+ /**
134
+ * Subscribe to the test plan run completed events for the given Runner and Run ID.
135
+ * Wildcard can be used for the Runner or Run ID to receive all test plan run completed events.
136
+ * @param {string} runnerId
137
+ * @param {string} runId
138
+ * @param {(error:ErrorResponse|null,message:TestStepRunStartEventArgs|null)=>void} listener
139
+ * @param {SubscriptionOptions} options?
140
+ */
141
+ subscribeTestPlanRunCompletedEventListener(runnerId, runId, listener, options) {
142
+ const subject = `Runner.${runnerId}.Runs.${runId}.Events.TestPlanRunCompleted`;
143
+ return this.subscribe(subject, Object.assign(Object.assign({}, options), { callback: (error, message) => {
144
+ if (error) {
145
+ listener(this.natsErrorHandler(error, subject), null);
146
+ return;
147
+ }
148
+ try {
149
+ const jsonCodec = JSONCodec();
150
+ const testPlanRunCompletedEventArgsJs = jsonCodec.decode(message === null || message === void 0 ? void 0 : message.data);
151
+ const testPlanRunCompletedEventArgs = TestPlanRunCompletedEventArgs.fromJS(testPlanRunCompletedEventArgsJs);
152
+ listener(null, testPlanRunCompletedEventArgs);
153
+ }
154
+ catch (error) {
155
+ listener(this.natsErrorHandler(error, subject), null);
156
+ }
157
+ } }));
158
+ }
159
+ }
@@ -0,0 +1,5 @@
1
+ export { RunnerClient } from './RunnerClient';
2
+ export { SessionClient } from './SessionClient';
3
+ export { SystemClient } from './SystemClient';
4
+ export * from './DTOs';
5
+ export * from 'nats.ws';
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@opentap/runner-client",
3
- "version": "2.20.0-alpha.1.7.7789778780",
3
+ "version": "2.20.0",
4
4
  "description": "This is the web client for the OpenTAP Runner.",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/mjs/index.js",
7
+ "types": "./dist/mjs/index.d.ts",
8
+ "exports": {
9
+ "import": "./dist/mjs/index.js",
10
+ "require": "./dist/cjs/index.js"
11
+ },
7
12
  "scripts": {
8
- "build": "rimraf ./lib && tsc",
13
+ "build": "rimraf ./dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && ./post-build.sh",
9
14
  "lint": "eslint --ignore-path .eslintignore --ext .js,.ts .",
10
15
  "format": "prettier --write \"src/**/*.+(js|ts|json)\"",
11
16
  "prepare": "npm run build && husky install",
@@ -14,7 +19,7 @@
14
19
  "author": "OpenTap.io",
15
20
  "license": "MIT",
16
21
  "files": [
17
- "lib/**/*"
22
+ "dist/**/*"
18
23
  ],
19
24
  "keywords": [
20
25
  "opentap",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes