@kohost/api-client 3.7.5 → 3.7.7
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/Client/index.js +8 -0
- package/dist/cjs/schemas/property.json +11 -0
- package/dist/cjs/utils/errorFactory.js +28 -4
- package/dist/esm/Client.js +87 -51
- package/dist/esm/Client.js.map +2 -2
- package/dist/esm/Models.js +14 -9
- package/dist/esm/Models.js.map +2 -2
- package/dist/esm/SocketIoClient.js +746 -615
- package/dist/esm/SocketIoClient.js.map +4 -4
- package/dist/esm/defs.js +87 -51
- package/dist/esm/defs.js.map +2 -2
- package/dist/esm/utils.js +42 -13
- package/dist/esm/utils.js.map +2 -2
- package/dist/types/Client/index.d.ts +2 -0
- package/dist/types/Client/index.d.ts.map +1 -1
- package/dist/types/schemas/PropertySchema.d.ts +2 -0
- package/dist/types/utils/errorFactory.d.ts +3 -1
- package/dist/types/utils/errorFactory.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/Client/index.js
CHANGED
|
@@ -7355,6 +7355,10 @@ var KohostApiClient = class _KohostApiClient extends EventEmitter {
|
|
|
7355
7355
|
const key = _KohostApiClient.defs.organizationHeader;
|
|
7356
7356
|
this._http.defaults.headers.common[key] = orgId;
|
|
7357
7357
|
}
|
|
7358
|
+
get organizationId() {
|
|
7359
|
+
const key = _KohostApiClient.defs.organizationHeader;
|
|
7360
|
+
return this._http.defaults.headers.common[key];
|
|
7361
|
+
}
|
|
7358
7362
|
/**
|
|
7359
7363
|
* @param {string} propertyId
|
|
7360
7364
|
* @returns {void}
|
|
@@ -7366,6 +7370,10 @@ var KohostApiClient = class _KohostApiClient extends EventEmitter {
|
|
|
7366
7370
|
const key = _KohostApiClient.defs.propertyHeader;
|
|
7367
7371
|
this._http.defaults.headers.common[key] = propertyId;
|
|
7368
7372
|
}
|
|
7373
|
+
get propertyId() {
|
|
7374
|
+
const key = _KohostApiClient.defs.propertyHeader;
|
|
7375
|
+
return this._http.defaults.headers.common[key];
|
|
7376
|
+
}
|
|
7369
7377
|
static get defs() {
|
|
7370
7378
|
return {
|
|
7371
7379
|
apiKeyHeader: "X-Api-Key",
|
|
@@ -208,6 +208,17 @@
|
|
|
208
208
|
"type": "boolean",
|
|
209
209
|
"default": false
|
|
210
210
|
},
|
|
211
|
+
"ratings": {
|
|
212
|
+
"type": "boolean",
|
|
213
|
+
"default": true
|
|
214
|
+
},
|
|
215
|
+
"newTicketCCs": {
|
|
216
|
+
"type": "array",
|
|
217
|
+
"items": {
|
|
218
|
+
"type": "string"
|
|
219
|
+
},
|
|
220
|
+
"default": []
|
|
221
|
+
},
|
|
211
222
|
"quickServices": {
|
|
212
223
|
"type": "array",
|
|
213
224
|
"items": {
|
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
const Errors = require("../Errors");
|
|
2
2
|
|
|
3
3
|
module.exports = function errorFactory(errName) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
switch (errName) {
|
|
5
|
+
case "AppError":
|
|
6
|
+
return Errors.AppError;
|
|
7
|
+
case "AuthenticationError":
|
|
8
|
+
return Errors.AuthenticationError;
|
|
9
|
+
case "AuthorizationError":
|
|
10
|
+
return Errors.AuthorizationError;
|
|
11
|
+
case "ConflictError":
|
|
12
|
+
return Errors.ConflictError;
|
|
13
|
+
case "DeviceCommError":
|
|
14
|
+
return Errors.DeviceCommError;
|
|
15
|
+
case "LoginError":
|
|
16
|
+
return Errors.LoginError;
|
|
17
|
+
case "NotFoundError":
|
|
18
|
+
return Errors.NotFoundError;
|
|
19
|
+
case "RequestError":
|
|
20
|
+
return Errors.RequestError;
|
|
21
|
+
case "SystemCommError":
|
|
22
|
+
return Errors.SystemCommError;
|
|
23
|
+
case "TokenExpiredError":
|
|
24
|
+
return Errors.TokenExpiredError;
|
|
25
|
+
case "UnprocessableRequestError":
|
|
26
|
+
return Errors.UnprocessableRequestError;
|
|
27
|
+
case "ValidationError":
|
|
28
|
+
return Errors.ValidationError;
|
|
29
|
+
default:
|
|
30
|
+
return new Error("Invalid error name: " + errName);
|
|
31
|
+
}
|
|
8
32
|
};
|
package/dist/esm/Client.js
CHANGED
|
@@ -9128,36 +9128,37 @@ var require_axios = __commonJS({
|
|
|
9128
9128
|
}, "dispatchXhrRequest"));
|
|
9129
9129
|
};
|
|
9130
9130
|
var composeSignals = /* @__PURE__ */ __name((signals, timeout) => {
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
const unsubscribe = /* @__PURE__ */ __name(() => {
|
|
9145
|
-
if (signals) {
|
|
9146
|
-
timer && clearTimeout(timer);
|
|
9131
|
+
const { length } = signals = signals ? signals.filter(Boolean) : [];
|
|
9132
|
+
if (timeout || length) {
|
|
9133
|
+
let controller = new AbortController();
|
|
9134
|
+
let aborted;
|
|
9135
|
+
const onabort = /* @__PURE__ */ __name(function(reason) {
|
|
9136
|
+
if (!aborted) {
|
|
9137
|
+
aborted = true;
|
|
9138
|
+
unsubscribe();
|
|
9139
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
9140
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
9141
|
+
}
|
|
9142
|
+
}, "onabort");
|
|
9143
|
+
let timer = timeout && setTimeout(() => {
|
|
9147
9144
|
timer = null;
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
signals
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9145
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
9146
|
+
}, timeout);
|
|
9147
|
+
const unsubscribe = /* @__PURE__ */ __name(() => {
|
|
9148
|
+
if (signals) {
|
|
9149
|
+
timer && clearTimeout(timer);
|
|
9150
|
+
timer = null;
|
|
9151
|
+
signals.forEach((signal2) => {
|
|
9152
|
+
signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
|
|
9153
|
+
});
|
|
9154
|
+
signals = null;
|
|
9155
|
+
}
|
|
9156
|
+
}, "unsubscribe");
|
|
9157
|
+
signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
|
|
9158
|
+
const { signal } = controller;
|
|
9159
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
9160
|
+
return signal;
|
|
9161
|
+
}
|
|
9161
9162
|
}, "composeSignals");
|
|
9162
9163
|
var composeSignals$1 = composeSignals;
|
|
9163
9164
|
var streamChunk = /* @__PURE__ */ __name(function* (chunk, chunkSize) {
|
|
@@ -9174,13 +9175,31 @@ var require_axios = __commonJS({
|
|
|
9174
9175
|
pos = end;
|
|
9175
9176
|
}
|
|
9176
9177
|
}, "streamChunk");
|
|
9177
|
-
var readBytes = /* @__PURE__ */ __name(async function* (iterable, chunkSize
|
|
9178
|
-
for await (const chunk of iterable) {
|
|
9179
|
-
yield* streamChunk(
|
|
9178
|
+
var readBytes = /* @__PURE__ */ __name(async function* (iterable, chunkSize) {
|
|
9179
|
+
for await (const chunk of readStream(iterable)) {
|
|
9180
|
+
yield* streamChunk(chunk, chunkSize);
|
|
9180
9181
|
}
|
|
9181
9182
|
}, "readBytes");
|
|
9182
|
-
var
|
|
9183
|
-
|
|
9183
|
+
var readStream = /* @__PURE__ */ __name(async function* (stream) {
|
|
9184
|
+
if (stream[Symbol.asyncIterator]) {
|
|
9185
|
+
yield* stream;
|
|
9186
|
+
return;
|
|
9187
|
+
}
|
|
9188
|
+
const reader = stream.getReader();
|
|
9189
|
+
try {
|
|
9190
|
+
for (; ; ) {
|
|
9191
|
+
const { done, value } = await reader.read();
|
|
9192
|
+
if (done) {
|
|
9193
|
+
break;
|
|
9194
|
+
}
|
|
9195
|
+
yield value;
|
|
9196
|
+
}
|
|
9197
|
+
} finally {
|
|
9198
|
+
await reader.cancel();
|
|
9199
|
+
}
|
|
9200
|
+
}, "readStream");
|
|
9201
|
+
var trackStream = /* @__PURE__ */ __name((stream, chunkSize, onProgress, onFinish) => {
|
|
9202
|
+
const iterator = readBytes(stream, chunkSize);
|
|
9184
9203
|
let bytes = 0;
|
|
9185
9204
|
let done;
|
|
9186
9205
|
let _onFinish = /* @__PURE__ */ __name((e) => {
|
|
@@ -9259,7 +9278,11 @@ var require_axios = __commonJS({
|
|
|
9259
9278
|
return body.size;
|
|
9260
9279
|
}
|
|
9261
9280
|
if (utils$1.isSpecCompliantForm(body)) {
|
|
9262
|
-
|
|
9281
|
+
const _request = new Request(platform.origin, {
|
|
9282
|
+
method: "POST",
|
|
9283
|
+
body
|
|
9284
|
+
});
|
|
9285
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
9263
9286
|
}
|
|
9264
9287
|
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
9265
9288
|
return body.byteLength;
|
|
@@ -9291,14 +9314,11 @@ var require_axios = __commonJS({
|
|
|
9291
9314
|
fetchOptions
|
|
9292
9315
|
} = resolveConfig(config);
|
|
9293
9316
|
responseType = responseType ? (responseType + "").toLowerCase() : "text";
|
|
9294
|
-
let
|
|
9295
|
-
let
|
|
9296
|
-
const
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
});
|
|
9300
|
-
finished = true;
|
|
9301
|
-
}, "onFinish");
|
|
9317
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
9318
|
+
let request;
|
|
9319
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
9320
|
+
composedSignal.unsubscribe();
|
|
9321
|
+
});
|
|
9302
9322
|
let requestContentLength;
|
|
9303
9323
|
try {
|
|
9304
9324
|
if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
|
|
@@ -9316,7 +9336,7 @@ var require_axios = __commonJS({
|
|
|
9316
9336
|
requestContentLength,
|
|
9317
9337
|
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
9318
9338
|
);
|
|
9319
|
-
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush
|
|
9339
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
9320
9340
|
}
|
|
9321
9341
|
}
|
|
9322
9342
|
if (!utils$1.isString(withCredentials)) {
|
|
@@ -9334,7 +9354,7 @@ var require_axios = __commonJS({
|
|
|
9334
9354
|
});
|
|
9335
9355
|
let response = await fetch(request);
|
|
9336
9356
|
const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
|
|
9337
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
|
9357
|
+
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
9338
9358
|
const options = {};
|
|
9339
9359
|
["status", "statusText", "headers"].forEach((prop) => {
|
|
9340
9360
|
options[prop] = response[prop];
|
|
@@ -9347,15 +9367,14 @@ var require_axios = __commonJS({
|
|
|
9347
9367
|
response = new Response(
|
|
9348
9368
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
9349
9369
|
flush && flush();
|
|
9350
|
-
|
|
9351
|
-
}
|
|
9370
|
+
unsubscribe && unsubscribe();
|
|
9371
|
+
}),
|
|
9352
9372
|
options
|
|
9353
9373
|
);
|
|
9354
9374
|
}
|
|
9355
9375
|
responseType = responseType || "text";
|
|
9356
9376
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config);
|
|
9357
|
-
!isStreamResponse &&
|
|
9358
|
-
stopTimeout && stopTimeout();
|
|
9377
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
9359
9378
|
return await new Promise((resolve, reject) => {
|
|
9360
9379
|
settle(resolve, reject, {
|
|
9361
9380
|
data: responseData,
|
|
@@ -9367,7 +9386,7 @@ var require_axios = __commonJS({
|
|
|
9367
9386
|
});
|
|
9368
9387
|
});
|
|
9369
9388
|
} catch (err) {
|
|
9370
|
-
|
|
9389
|
+
unsubscribe && unsubscribe();
|
|
9371
9390
|
if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
|
|
9372
9391
|
throw Object.assign(
|
|
9373
9392
|
new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request),
|
|
@@ -9476,7 +9495,7 @@ var require_axios = __commonJS({
|
|
|
9476
9495
|
}, "onAdapterRejection"));
|
|
9477
9496
|
}
|
|
9478
9497
|
__name(dispatchRequest, "dispatchRequest");
|
|
9479
|
-
var VERSION = "1.7.
|
|
9498
|
+
var VERSION = "1.7.7";
|
|
9480
9499
|
var validators$1 = {};
|
|
9481
9500
|
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
|
|
9482
9501
|
validators$1[type] = /* @__PURE__ */ __name(function validator2(thing) {
|
|
@@ -9774,6 +9793,15 @@ var require_axios = __commonJS({
|
|
|
9774
9793
|
this._listeners.splice(index, 1);
|
|
9775
9794
|
}
|
|
9776
9795
|
}
|
|
9796
|
+
toAbortSignal() {
|
|
9797
|
+
const controller = new AbortController();
|
|
9798
|
+
const abort = /* @__PURE__ */ __name((err) => {
|
|
9799
|
+
controller.abort(err);
|
|
9800
|
+
}, "abort");
|
|
9801
|
+
this.subscribe(abort);
|
|
9802
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
9803
|
+
return controller.signal;
|
|
9804
|
+
}
|
|
9777
9805
|
/**
|
|
9778
9806
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
9779
9807
|
* cancels the `CancelToken`.
|
|
@@ -10184,6 +10212,10 @@ var require_Client = __commonJS({
|
|
|
10184
10212
|
const key = _KohostApiClient.defs.organizationHeader;
|
|
10185
10213
|
this._http.defaults.headers.common[key] = orgId;
|
|
10186
10214
|
}
|
|
10215
|
+
get organizationId() {
|
|
10216
|
+
const key = _KohostApiClient.defs.organizationHeader;
|
|
10217
|
+
return this._http.defaults.headers.common[key];
|
|
10218
|
+
}
|
|
10187
10219
|
/**
|
|
10188
10220
|
* @param {string} propertyId
|
|
10189
10221
|
* @returns {void}
|
|
@@ -10195,6 +10227,10 @@ var require_Client = __commonJS({
|
|
|
10195
10227
|
const key = _KohostApiClient.defs.propertyHeader;
|
|
10196
10228
|
this._http.defaults.headers.common[key] = propertyId;
|
|
10197
10229
|
}
|
|
10230
|
+
get propertyId() {
|
|
10231
|
+
const key = _KohostApiClient.defs.propertyHeader;
|
|
10232
|
+
return this._http.defaults.headers.common[key];
|
|
10233
|
+
}
|
|
10198
10234
|
static get defs() {
|
|
10199
10235
|
return {
|
|
10200
10236
|
apiKeyHeader: "X-Api-Key",
|