@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/esm/defs.js
CHANGED
|
@@ -2087,36 +2087,37 @@ var require_axios = __commonJS({
|
|
|
2087
2087
|
}, "dispatchXhrRequest"));
|
|
2088
2088
|
};
|
|
2089
2089
|
var composeSignals = /* @__PURE__ */ __name((signals, timeout) => {
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
const unsubscribe = /* @__PURE__ */ __name(() => {
|
|
2104
|
-
if (signals) {
|
|
2105
|
-
timer && clearTimeout(timer);
|
|
2090
|
+
const { length } = signals = signals ? signals.filter(Boolean) : [];
|
|
2091
|
+
if (timeout || length) {
|
|
2092
|
+
let controller = new AbortController();
|
|
2093
|
+
let aborted;
|
|
2094
|
+
const onabort = /* @__PURE__ */ __name(function(reason) {
|
|
2095
|
+
if (!aborted) {
|
|
2096
|
+
aborted = true;
|
|
2097
|
+
unsubscribe();
|
|
2098
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
2099
|
+
controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
|
|
2100
|
+
}
|
|
2101
|
+
}, "onabort");
|
|
2102
|
+
let timer = timeout && setTimeout(() => {
|
|
2106
2103
|
timer = null;
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
signals
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2104
|
+
onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
|
|
2105
|
+
}, timeout);
|
|
2106
|
+
const unsubscribe = /* @__PURE__ */ __name(() => {
|
|
2107
|
+
if (signals) {
|
|
2108
|
+
timer && clearTimeout(timer);
|
|
2109
|
+
timer = null;
|
|
2110
|
+
signals.forEach((signal2) => {
|
|
2111
|
+
signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
|
|
2112
|
+
});
|
|
2113
|
+
signals = null;
|
|
2114
|
+
}
|
|
2115
|
+
}, "unsubscribe");
|
|
2116
|
+
signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
|
|
2117
|
+
const { signal } = controller;
|
|
2118
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
2119
|
+
return signal;
|
|
2120
|
+
}
|
|
2120
2121
|
}, "composeSignals");
|
|
2121
2122
|
var composeSignals$1 = composeSignals;
|
|
2122
2123
|
var streamChunk = /* @__PURE__ */ __name(function* (chunk, chunkSize) {
|
|
@@ -2133,13 +2134,31 @@ var require_axios = __commonJS({
|
|
|
2133
2134
|
pos = end;
|
|
2134
2135
|
}
|
|
2135
2136
|
}, "streamChunk");
|
|
2136
|
-
var readBytes = /* @__PURE__ */ __name(async function* (iterable, chunkSize
|
|
2137
|
-
for await (const chunk of iterable) {
|
|
2138
|
-
yield* streamChunk(
|
|
2137
|
+
var readBytes = /* @__PURE__ */ __name(async function* (iterable, chunkSize) {
|
|
2138
|
+
for await (const chunk of readStream(iterable)) {
|
|
2139
|
+
yield* streamChunk(chunk, chunkSize);
|
|
2139
2140
|
}
|
|
2140
2141
|
}, "readBytes");
|
|
2141
|
-
var
|
|
2142
|
-
|
|
2142
|
+
var readStream = /* @__PURE__ */ __name(async function* (stream) {
|
|
2143
|
+
if (stream[Symbol.asyncIterator]) {
|
|
2144
|
+
yield* stream;
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
const reader = stream.getReader();
|
|
2148
|
+
try {
|
|
2149
|
+
for (; ; ) {
|
|
2150
|
+
const { done, value } = await reader.read();
|
|
2151
|
+
if (done) {
|
|
2152
|
+
break;
|
|
2153
|
+
}
|
|
2154
|
+
yield value;
|
|
2155
|
+
}
|
|
2156
|
+
} finally {
|
|
2157
|
+
await reader.cancel();
|
|
2158
|
+
}
|
|
2159
|
+
}, "readStream");
|
|
2160
|
+
var trackStream = /* @__PURE__ */ __name((stream, chunkSize, onProgress, onFinish) => {
|
|
2161
|
+
const iterator = readBytes(stream, chunkSize);
|
|
2143
2162
|
let bytes = 0;
|
|
2144
2163
|
let done;
|
|
2145
2164
|
let _onFinish = /* @__PURE__ */ __name((e) => {
|
|
@@ -2218,7 +2237,11 @@ var require_axios = __commonJS({
|
|
|
2218
2237
|
return body.size;
|
|
2219
2238
|
}
|
|
2220
2239
|
if (utils$1.isSpecCompliantForm(body)) {
|
|
2221
|
-
|
|
2240
|
+
const _request = new Request(platform.origin, {
|
|
2241
|
+
method: "POST",
|
|
2242
|
+
body
|
|
2243
|
+
});
|
|
2244
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
2222
2245
|
}
|
|
2223
2246
|
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
2224
2247
|
return body.byteLength;
|
|
@@ -2250,14 +2273,11 @@ var require_axios = __commonJS({
|
|
|
2250
2273
|
fetchOptions
|
|
2251
2274
|
} = resolveConfig(config);
|
|
2252
2275
|
responseType = responseType ? (responseType + "").toLowerCase() : "text";
|
|
2253
|
-
let
|
|
2254
|
-
let
|
|
2255
|
-
const
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
});
|
|
2259
|
-
finished = true;
|
|
2260
|
-
}, "onFinish");
|
|
2276
|
+
let composedSignal = composeSignals$1([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
2277
|
+
let request;
|
|
2278
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
2279
|
+
composedSignal.unsubscribe();
|
|
2280
|
+
});
|
|
2261
2281
|
let requestContentLength;
|
|
2262
2282
|
try {
|
|
2263
2283
|
if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
|
|
@@ -2275,7 +2295,7 @@ var require_axios = __commonJS({
|
|
|
2275
2295
|
requestContentLength,
|
|
2276
2296
|
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
2277
2297
|
);
|
|
2278
|
-
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush
|
|
2298
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
2279
2299
|
}
|
|
2280
2300
|
}
|
|
2281
2301
|
if (!utils$1.isString(withCredentials)) {
|
|
@@ -2293,7 +2313,7 @@ var require_axios = __commonJS({
|
|
|
2293
2313
|
});
|
|
2294
2314
|
let response = await fetch(request);
|
|
2295
2315
|
const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
|
|
2296
|
-
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
|
2316
|
+
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
2297
2317
|
const options = {};
|
|
2298
2318
|
["status", "statusText", "headers"].forEach((prop) => {
|
|
2299
2319
|
options[prop] = response[prop];
|
|
@@ -2306,15 +2326,14 @@ var require_axios = __commonJS({
|
|
|
2306
2326
|
response = new Response(
|
|
2307
2327
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
2308
2328
|
flush && flush();
|
|
2309
|
-
|
|
2310
|
-
}
|
|
2329
|
+
unsubscribe && unsubscribe();
|
|
2330
|
+
}),
|
|
2311
2331
|
options
|
|
2312
2332
|
);
|
|
2313
2333
|
}
|
|
2314
2334
|
responseType = responseType || "text";
|
|
2315
2335
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config);
|
|
2316
|
-
!isStreamResponse &&
|
|
2317
|
-
stopTimeout && stopTimeout();
|
|
2336
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
2318
2337
|
return await new Promise((resolve, reject) => {
|
|
2319
2338
|
settle(resolve, reject, {
|
|
2320
2339
|
data: responseData,
|
|
@@ -2326,7 +2345,7 @@ var require_axios = __commonJS({
|
|
|
2326
2345
|
});
|
|
2327
2346
|
});
|
|
2328
2347
|
} catch (err) {
|
|
2329
|
-
|
|
2348
|
+
unsubscribe && unsubscribe();
|
|
2330
2349
|
if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
|
|
2331
2350
|
throw Object.assign(
|
|
2332
2351
|
new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request),
|
|
@@ -2435,7 +2454,7 @@ var require_axios = __commonJS({
|
|
|
2435
2454
|
}, "onAdapterRejection"));
|
|
2436
2455
|
}
|
|
2437
2456
|
__name(dispatchRequest, "dispatchRequest");
|
|
2438
|
-
var VERSION = "1.7.
|
|
2457
|
+
var VERSION = "1.7.7";
|
|
2439
2458
|
var validators$1 = {};
|
|
2440
2459
|
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
|
|
2441
2460
|
validators$1[type] = /* @__PURE__ */ __name(function validator2(thing) {
|
|
@@ -2733,6 +2752,15 @@ var require_axios = __commonJS({
|
|
|
2733
2752
|
this._listeners.splice(index, 1);
|
|
2734
2753
|
}
|
|
2735
2754
|
}
|
|
2755
|
+
toAbortSignal() {
|
|
2756
|
+
const controller = new AbortController();
|
|
2757
|
+
const abort = /* @__PURE__ */ __name((err) => {
|
|
2758
|
+
controller.abort(err);
|
|
2759
|
+
}, "abort");
|
|
2760
|
+
this.subscribe(abort);
|
|
2761
|
+
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
2762
|
+
return controller.signal;
|
|
2763
|
+
}
|
|
2736
2764
|
/**
|
|
2737
2765
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
2738
2766
|
* cancels the `CancelToken`.
|
|
@@ -2935,6 +2963,10 @@ var require_Client = __commonJS({
|
|
|
2935
2963
|
const key = _KohostApiClient.defs.organizationHeader;
|
|
2936
2964
|
this._http.defaults.headers.common[key] = orgId;
|
|
2937
2965
|
}
|
|
2966
|
+
get organizationId() {
|
|
2967
|
+
const key = _KohostApiClient.defs.organizationHeader;
|
|
2968
|
+
return this._http.defaults.headers.common[key];
|
|
2969
|
+
}
|
|
2938
2970
|
/**
|
|
2939
2971
|
* @param {string} propertyId
|
|
2940
2972
|
* @returns {void}
|
|
@@ -2946,6 +2978,10 @@ var require_Client = __commonJS({
|
|
|
2946
2978
|
const key = _KohostApiClient.defs.propertyHeader;
|
|
2947
2979
|
this._http.defaults.headers.common[key] = propertyId;
|
|
2948
2980
|
}
|
|
2981
|
+
get propertyId() {
|
|
2982
|
+
const key = _KohostApiClient.defs.propertyHeader;
|
|
2983
|
+
return this._http.defaults.headers.common[key];
|
|
2984
|
+
}
|
|
2949
2985
|
static get defs() {
|
|
2950
2986
|
return {
|
|
2951
2987
|
apiKeyHeader: "X-Api-Key",
|