@kohost/api-client 3.0.0-beta.26 → 3.0.0-beta.28
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/AMQPClient.js +11 -12
- package/dist/cjs/Client.js +3 -5
- package/dist/cjs/Models.js +461 -45
- package/dist/cjs/SocketIoClient.js +2 -4
- package/dist/cjs/defs.js +3 -5
- package/dist/cjs/utils.js +7 -1
- package/dist/esm/Models.js +434 -2
- package/dist/esm/Models.js.map +4 -4
- package/dist/esm/utils.js +7 -1
- package/dist/esm/utils.js.map +2 -2
- package/package.json +1 -1
package/dist/cjs/AMQPClient.js
CHANGED
|
@@ -270,30 +270,29 @@ var KohostAMQPClient = class {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
static parseMessage(message) {
|
|
273
|
-
var _a, _b, _c, _d, _e;
|
|
274
273
|
debug("parseMessage input %o", message);
|
|
275
274
|
let error = null;
|
|
276
275
|
let data = {};
|
|
277
276
|
let query = {};
|
|
278
277
|
let context = {};
|
|
279
278
|
let headers = {};
|
|
280
|
-
const isCommand =
|
|
281
|
-
const isEvent =
|
|
282
|
-
const messageHeaders =
|
|
279
|
+
const isCommand = message?.properties?.type === "Command";
|
|
280
|
+
const isEvent = message?.properties?.type === "Event";
|
|
281
|
+
const messageHeaders = message?.properties?.headers || {};
|
|
283
282
|
const commandName = messageHeaders[HEADER_KEY_COMMAND_NAME] || null;
|
|
284
283
|
const eventName = messageHeaders[HEADER_KEY_EVENT_NAME] || null;
|
|
285
284
|
if (message.content) {
|
|
286
285
|
try {
|
|
287
|
-
const payload =
|
|
288
|
-
data =
|
|
289
|
-
error = payload
|
|
290
|
-
query =
|
|
291
|
-
context =
|
|
286
|
+
const payload = message.properties?.contentType === "application/json" ? JSON.parse(message.content.toString()) : message.content.toString();
|
|
287
|
+
data = payload?.data || {};
|
|
288
|
+
error = payload?.error;
|
|
289
|
+
query = payload?.query || {};
|
|
290
|
+
context = payload?.context || {};
|
|
292
291
|
} catch (error2) {
|
|
293
292
|
data = message.content.toString();
|
|
294
293
|
}
|
|
295
294
|
}
|
|
296
|
-
if (
|
|
295
|
+
if (message?.properties?.headers) {
|
|
297
296
|
const orgHeader = message.properties.headers[HEADER_KEY_ORGANIZATION_ID];
|
|
298
297
|
const propertyHeader = message.properties.headers[HEADER_KEY_PROPERTY_ID];
|
|
299
298
|
const driverHeader = message.properties.headers[HEADER_KEY_DRIVER];
|
|
@@ -325,10 +324,10 @@ var KohostAMQPClient = class {
|
|
|
325
324
|
return parsed;
|
|
326
325
|
}
|
|
327
326
|
static getMessage(message) {
|
|
328
|
-
if (!
|
|
327
|
+
if (!message?.content)
|
|
329
328
|
return null;
|
|
330
329
|
const payload = JSON.parse(message.content.toString());
|
|
331
|
-
const data = payload
|
|
330
|
+
const data = payload?.data;
|
|
332
331
|
return data;
|
|
333
332
|
}
|
|
334
333
|
static isFatalError(err) {
|
package/dist/cjs/Client.js
CHANGED
|
@@ -5206,9 +5206,8 @@ var KohostApiClient = class extends EventEmitter {
|
|
|
5206
5206
|
};
|
|
5207
5207
|
}
|
|
5208
5208
|
_handleResponse(response) {
|
|
5209
|
-
var _a;
|
|
5210
5209
|
try {
|
|
5211
|
-
if (
|
|
5210
|
+
if (response?.data?.data) {
|
|
5212
5211
|
response.query = response.data.query;
|
|
5213
5212
|
response.pagination = response.data.pagination;
|
|
5214
5213
|
response.data = response.data.data;
|
|
@@ -5219,13 +5218,12 @@ var KohostApiClient = class extends EventEmitter {
|
|
|
5219
5218
|
}
|
|
5220
5219
|
}
|
|
5221
5220
|
_handleResponseError(error) {
|
|
5222
|
-
var _a, _b;
|
|
5223
5221
|
const { config: originalReq } = error;
|
|
5224
5222
|
if (!error.response)
|
|
5225
5223
|
return Promise.reject(error);
|
|
5226
5224
|
const { status, data } = error.response;
|
|
5227
|
-
const errorType =
|
|
5228
|
-
const errorMessage =
|
|
5225
|
+
const errorType = data?.error?.type;
|
|
5226
|
+
const errorMessage = data?.error?.message;
|
|
5229
5227
|
try {
|
|
5230
5228
|
const expectedError = status >= 400 && status < 500;
|
|
5231
5229
|
const newTokensNeeded = expectedError && errorType === "TokenExpiredError";
|