@awarevue/agent-sdk 1.0.110 → 1.0.112
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/agent-app.d.ts +1 -0
- package/dist/agent-app.js +15 -52
- package/dist/package.json +2 -2
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +18 -0
- package/package.json +2 -2
package/dist/agent-app.d.ts
CHANGED
package/dist/agent-app.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AgentApp = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const default_validator_1 = require("./default-validator");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
6
7
|
class AgentApp {
|
|
7
8
|
constructor(agent, options) {
|
|
8
9
|
this.agent = agent;
|
|
@@ -13,7 +14,7 @@ class AgentApp {
|
|
|
13
14
|
const reply$ = (id) => this.options.transport.messages$.pipe((0, rxjs_1.mergeMap)((message) => {
|
|
14
15
|
if (message.kind === 'error-rs' && message.requestId === id) {
|
|
15
16
|
const error = message.error;
|
|
16
|
-
return (0, rxjs_1.throwError)(() => new Error(`Server failed to process message ${
|
|
17
|
+
return (0, rxjs_1.throwError)(() => new Error(`Server failed to process message ${payload.kind}: ${error}`));
|
|
17
18
|
}
|
|
18
19
|
return (0, rxjs_1.of)(message);
|
|
19
20
|
}), (0, rxjs_1.filter)((message) => message.kind === responseKind &&
|
|
@@ -25,6 +26,13 @@ class AgentApp {
|
|
|
25
26
|
// wait for the agent to reply
|
|
26
27
|
(0, rxjs_1.mergeMap)(({ id }) => reply$(id)));
|
|
27
28
|
};
|
|
29
|
+
this.handleResponse$ = (requestId) => (obs) => obs.pipe((0, rxjs_1.tap)({
|
|
30
|
+
error: (error) => console.error('Error processing request', requestId, (0, utils_1.stringifyError)(error)),
|
|
31
|
+
}), (0, rxjs_1.catchError)((error) => (0, rxjs_1.of)({
|
|
32
|
+
kind: 'error-rs',
|
|
33
|
+
requestId,
|
|
34
|
+
error: (0, utils_1.stringifyError)(error),
|
|
35
|
+
})), (0, rxjs_1.tap)((rs) => this.options.transport.send(this.addEnvelope(rs))));
|
|
28
36
|
this.addEnvelope = (payload) => ({
|
|
29
37
|
...payload,
|
|
30
38
|
id: AgentApp.nextId(),
|
|
@@ -73,18 +81,7 @@ class AgentApp {
|
|
|
73
81
|
(0, rxjs_1.map)(() => ({
|
|
74
82
|
kind: 'command-rs',
|
|
75
83
|
requestId: message.id,
|
|
76
|
-
})),
|
|
77
|
-
// error
|
|
78
|
-
(0, rxjs_1.catchError)((error) => {
|
|
79
|
-
var _a;
|
|
80
|
-
return (0, rxjs_1.of)({
|
|
81
|
-
kind: 'error-rs',
|
|
82
|
-
requestId: message.id,
|
|
83
|
-
error: (_a = error.message) !== null && _a !== void 0 ? _a : 'Unknown error',
|
|
84
|
-
});
|
|
85
|
-
}),
|
|
86
|
-
// send the response
|
|
87
|
-
(0, rxjs_1.tap)((rs) => this.options.transport.send(this.addEnvelope(rs))));
|
|
84
|
+
})), this.handleResponse$(message.id));
|
|
88
85
|
case 'get-available-devices':
|
|
89
86
|
// get available devices
|
|
90
87
|
return this.agent.getDevicesAndRelations$(context).pipe(
|
|
@@ -93,16 +90,7 @@ class AgentApp {
|
|
|
93
90
|
kind: 'get-available-devices-rs',
|
|
94
91
|
...rs,
|
|
95
92
|
requestId: message.id,
|
|
96
|
-
})),
|
|
97
|
-
// error
|
|
98
|
-
(0, rxjs_1.catchError)((error) => {
|
|
99
|
-
var _a;
|
|
100
|
-
return (0, rxjs_1.of)({
|
|
101
|
-
kind: 'error-rs',
|
|
102
|
-
requestId: message.id,
|
|
103
|
-
error: (_a = error.message) !== null && _a !== void 0 ? _a : 'Unknown error',
|
|
104
|
-
});
|
|
105
|
-
}), (0, rxjs_1.tap)((rs) => this.options.transport.send(this.addEnvelope(rs))));
|
|
93
|
+
})), this.handleResponse$(message.id));
|
|
106
94
|
case 'validate-change':
|
|
107
95
|
// validate access change
|
|
108
96
|
const validateOb$ = !this.agent.validateAccessChange$
|
|
@@ -118,32 +106,18 @@ class AgentApp {
|
|
|
118
106
|
kind: 'validate-change-rs',
|
|
119
107
|
requestId: message.id,
|
|
120
108
|
issues,
|
|
121
|
-
})), (
|
|
122
|
-
var _a;
|
|
123
|
-
return (0, rxjs_1.of)({
|
|
124
|
-
kind: 'error-rs',
|
|
125
|
-
requestId: message.id,
|
|
126
|
-
error: (_a = error.message) !== null && _a !== void 0 ? _a : 'Unknown error',
|
|
127
|
-
});
|
|
128
|
-
}), (0, rxjs_1.tap)((rs) => this.options.transport.send(this.addEnvelope(rs))));
|
|
109
|
+
})), this.handleResponse$(message.id));
|
|
129
110
|
case 'apply-change':
|
|
130
111
|
// apply access change
|
|
131
112
|
const applyContext = this.createAccessChangeContext(context, message.refMap, objectCache);
|
|
132
113
|
const applyOb$ = !this.agent.applyAccessChange$
|
|
133
|
-
? (0, rxjs_1.throwError)(() => new Error(`Agent ${context.provider} does not support access change
|
|
114
|
+
? (0, rxjs_1.throwError)(() => new Error(`Agent ${context.provider} does not support access change apply`))
|
|
134
115
|
: this.agent.applyAccessChange$(applyContext, message);
|
|
135
116
|
return applyOb$.pipe((0, rxjs_1.map)((result) => ({
|
|
136
117
|
kind: 'apply-change-rs',
|
|
137
118
|
requestId: message.id,
|
|
138
119
|
refs: result,
|
|
139
|
-
})), (
|
|
140
|
-
var _a;
|
|
141
|
-
return (0, rxjs_1.of)({
|
|
142
|
-
kind: 'error-rs',
|
|
143
|
-
requestId: message.id,
|
|
144
|
-
error: (_a = error.message) !== null && _a !== void 0 ? _a : 'Unknown error',
|
|
145
|
-
});
|
|
146
|
-
}), (0, rxjs_1.tap)((rs) => this.options.transport.send(this.addEnvelope(rs))));
|
|
120
|
+
})), this.handleResponse$(message.id));
|
|
147
121
|
default:
|
|
148
122
|
return rxjs_1.EMPTY;
|
|
149
123
|
}
|
|
@@ -194,18 +168,7 @@ class AgentApp {
|
|
|
194
168
|
kind: 'validate-config-rs',
|
|
195
169
|
requestId: message.id,
|
|
196
170
|
issues,
|
|
197
|
-
})),
|
|
198
|
-
// error
|
|
199
|
-
(0, rxjs_1.catchError)((error) => {
|
|
200
|
-
var _a;
|
|
201
|
-
return (0, rxjs_1.of)({
|
|
202
|
-
kind: 'error-rs',
|
|
203
|
-
requestId: message.id,
|
|
204
|
-
error: (_a = error.message) !== null && _a !== void 0 ? _a : 'Unknown error',
|
|
205
|
-
});
|
|
206
|
-
}),
|
|
207
|
-
// send the response
|
|
208
|
-
(0, rxjs_1.tap)((rs) => this.options.transport.send(this.addEnvelope(rs))));
|
|
171
|
+
})), this.handleResponse$(message.id));
|
|
209
172
|
}));
|
|
210
173
|
return (0, rxjs_1.merge)(registration$, startStop$, validateConfig$);
|
|
211
174
|
};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awarevue/agent-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.112",
|
|
4
4
|
"description": "SDK for building Agent implementations that speak the Aware protocol.",
|
|
5
5
|
"author": "Yaser Awajan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"lint:fix": "yarn lint --fix"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@awarevue/api-types": "^1.0.
|
|
30
|
+
"@awarevue/api-types": "^1.0.112",
|
|
31
31
|
"rxjs": "^7.8.2",
|
|
32
32
|
"ws": "^8",
|
|
33
33
|
"zod": "3.24.2"
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const stringifyError: (error: unknown) => string;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringifyError = void 0;
|
|
4
|
+
const stringifyError = (error) => {
|
|
5
|
+
if (error instanceof Error) {
|
|
6
|
+
return `\nMessage: ${error.message}\nStack: ${error.stack}`;
|
|
7
|
+
}
|
|
8
|
+
if (typeof error === 'string') {
|
|
9
|
+
return error;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
return JSON.stringify(error);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return String(error);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.stringifyError = stringifyError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awarevue/agent-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.112",
|
|
4
4
|
"description": "SDK for building Agent implementations that speak the Aware protocol.",
|
|
5
5
|
"author": "Yaser Awajan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"lint:fix": "yarn lint --fix"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@awarevue/api-types": "^1.0.
|
|
30
|
+
"@awarevue/api-types": "^1.0.112",
|
|
31
31
|
"rxjs": "^7.8.2",
|
|
32
32
|
"ws": "^8",
|
|
33
33
|
"zod": "3.24.2"
|