strapi-plugin-faqchatbot 1.0.5 → 1.0.9
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/_chunks/{App-Bv3LDXXw.mjs → App-ClKpIPkC.mjs} +176 -116
- package/dist/_chunks/{App-Cc6UTNkw.js → App-DracDGJ6.js} +176 -116
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +2588 -29
- package/dist/server/index.mjs +2587 -29
- package/package.json +4 -9
package/dist/server/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dns from "dns/promises";
|
|
1
2
|
import OpenAI from "openai";
|
|
2
3
|
const bootstrap = ({ strapi }) => {
|
|
3
4
|
const UID = "plugin::faqchatbot.faqqa";
|
|
@@ -73,6 +74,2494 @@ const controller = ({ strapi }) => ({
|
|
|
73
74
|
ctx.body = strapi.plugin("faqchatbot").service("service").getWelcomeMessage();
|
|
74
75
|
}
|
|
75
76
|
});
|
|
77
|
+
function bind(fn, thisArg) {
|
|
78
|
+
return function wrap() {
|
|
79
|
+
return fn.apply(thisArg, arguments);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const { toString } = Object.prototype;
|
|
83
|
+
const { getPrototypeOf } = Object;
|
|
84
|
+
const { iterator, toStringTag } = Symbol;
|
|
85
|
+
const kindOf = /* @__PURE__ */ ((cache) => (thing) => {
|
|
86
|
+
const str = toString.call(thing);
|
|
87
|
+
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
88
|
+
})(/* @__PURE__ */ Object.create(null));
|
|
89
|
+
const kindOfTest = (type) => {
|
|
90
|
+
type = type.toLowerCase();
|
|
91
|
+
return (thing) => kindOf(thing) === type;
|
|
92
|
+
};
|
|
93
|
+
const typeOfTest = (type) => (thing) => typeof thing === type;
|
|
94
|
+
const { isArray } = Array;
|
|
95
|
+
const isUndefined = typeOfTest("undefined");
|
|
96
|
+
function isBuffer(val) {
|
|
97
|
+
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
98
|
+
}
|
|
99
|
+
const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
100
|
+
function isArrayBufferView(val) {
|
|
101
|
+
let result;
|
|
102
|
+
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
103
|
+
result = ArrayBuffer.isView(val);
|
|
104
|
+
} else {
|
|
105
|
+
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
const isString = typeOfTest("string");
|
|
110
|
+
const isFunction$1 = typeOfTest("function");
|
|
111
|
+
const isNumber = typeOfTest("number");
|
|
112
|
+
const isObject = (thing) => thing !== null && typeof thing === "object";
|
|
113
|
+
const isBoolean = (thing) => thing === true || thing === false;
|
|
114
|
+
const isPlainObject = (val) => {
|
|
115
|
+
if (kindOf(val) !== "object") {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const prototype2 = getPrototypeOf(val);
|
|
119
|
+
return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(toStringTag in val) && !(iterator in val);
|
|
120
|
+
};
|
|
121
|
+
const isEmptyObject = (val) => {
|
|
122
|
+
if (!isObject(val) || isBuffer(val)) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
127
|
+
} catch (e) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const isDate = kindOfTest("Date");
|
|
132
|
+
const isFile = kindOfTest("File");
|
|
133
|
+
const isBlob = kindOfTest("Blob");
|
|
134
|
+
const isFileList = kindOfTest("FileList");
|
|
135
|
+
const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
|
|
136
|
+
const isFormData = (thing) => {
|
|
137
|
+
let kind2;
|
|
138
|
+
return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction$1(thing.append) && ((kind2 = kindOf(thing)) === "formdata" || // detect form-data instance
|
|
139
|
+
kind2 === "object" && isFunction$1(thing.toString) && thing.toString() === "[object FormData]"));
|
|
140
|
+
};
|
|
141
|
+
const isURLSearchParams = kindOfTest("URLSearchParams");
|
|
142
|
+
const [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
|
|
143
|
+
const trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
144
|
+
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
145
|
+
if (obj === null || typeof obj === "undefined") {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
let i;
|
|
149
|
+
let l;
|
|
150
|
+
if (typeof obj !== "object") {
|
|
151
|
+
obj = [obj];
|
|
152
|
+
}
|
|
153
|
+
if (isArray(obj)) {
|
|
154
|
+
for (i = 0, l = obj.length; i < l; i++) {
|
|
155
|
+
fn.call(null, obj[i], i, obj);
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
if (isBuffer(obj)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
162
|
+
const len = keys.length;
|
|
163
|
+
let key;
|
|
164
|
+
for (i = 0; i < len; i++) {
|
|
165
|
+
key = keys[i];
|
|
166
|
+
fn.call(null, obj[key], key, obj);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function findKey(obj, key) {
|
|
171
|
+
if (isBuffer(obj)) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
key = key.toLowerCase();
|
|
175
|
+
const keys = Object.keys(obj);
|
|
176
|
+
let i = keys.length;
|
|
177
|
+
let _key;
|
|
178
|
+
while (i-- > 0) {
|
|
179
|
+
_key = keys[i];
|
|
180
|
+
if (key === _key.toLowerCase()) {
|
|
181
|
+
return _key;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
const _global = (() => {
|
|
187
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
|
188
|
+
return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
|
|
189
|
+
})();
|
|
190
|
+
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
191
|
+
function merge() {
|
|
192
|
+
const { caseless, skipUndefined } = isContextDefined(this) && this || {};
|
|
193
|
+
const result = {};
|
|
194
|
+
const assignValue = (val, key) => {
|
|
195
|
+
const targetKey = caseless && findKey(result, key) || key;
|
|
196
|
+
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
|
197
|
+
result[targetKey] = merge(result[targetKey], val);
|
|
198
|
+
} else if (isPlainObject(val)) {
|
|
199
|
+
result[targetKey] = merge({}, val);
|
|
200
|
+
} else if (isArray(val)) {
|
|
201
|
+
result[targetKey] = val.slice();
|
|
202
|
+
} else if (!skipUndefined || !isUndefined(val)) {
|
|
203
|
+
result[targetKey] = val;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
for (let i = 0, l = arguments.length; i < l; i++) {
|
|
207
|
+
arguments[i] && forEach(arguments[i], assignValue);
|
|
208
|
+
}
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
212
|
+
forEach(b, (val, key) => {
|
|
213
|
+
if (thisArg && isFunction$1(val)) {
|
|
214
|
+
a[key] = bind(val, thisArg);
|
|
215
|
+
} else {
|
|
216
|
+
a[key] = val;
|
|
217
|
+
}
|
|
218
|
+
}, { allOwnKeys });
|
|
219
|
+
return a;
|
|
220
|
+
};
|
|
221
|
+
const stripBOM = (content) => {
|
|
222
|
+
if (content.charCodeAt(0) === 65279) {
|
|
223
|
+
content = content.slice(1);
|
|
224
|
+
}
|
|
225
|
+
return content;
|
|
226
|
+
};
|
|
227
|
+
const inherits = (constructor, superConstructor, props, descriptors2) => {
|
|
228
|
+
constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
|
|
229
|
+
constructor.prototype.constructor = constructor;
|
|
230
|
+
Object.defineProperty(constructor, "super", {
|
|
231
|
+
value: superConstructor.prototype
|
|
232
|
+
});
|
|
233
|
+
props && Object.assign(constructor.prototype, props);
|
|
234
|
+
};
|
|
235
|
+
const toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
|
|
236
|
+
let props;
|
|
237
|
+
let i;
|
|
238
|
+
let prop;
|
|
239
|
+
const merged = {};
|
|
240
|
+
destObj = destObj || {};
|
|
241
|
+
if (sourceObj == null) return destObj;
|
|
242
|
+
do {
|
|
243
|
+
props = Object.getOwnPropertyNames(sourceObj);
|
|
244
|
+
i = props.length;
|
|
245
|
+
while (i-- > 0) {
|
|
246
|
+
prop = props[i];
|
|
247
|
+
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|
248
|
+
destObj[prop] = sourceObj[prop];
|
|
249
|
+
merged[prop] = true;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
|
|
253
|
+
} while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
254
|
+
return destObj;
|
|
255
|
+
};
|
|
256
|
+
const endsWith = (str, searchString, position) => {
|
|
257
|
+
str = String(str);
|
|
258
|
+
if (position === void 0 || position > str.length) {
|
|
259
|
+
position = str.length;
|
|
260
|
+
}
|
|
261
|
+
position -= searchString.length;
|
|
262
|
+
const lastIndex = str.indexOf(searchString, position);
|
|
263
|
+
return lastIndex !== -1 && lastIndex === position;
|
|
264
|
+
};
|
|
265
|
+
const toArray = (thing) => {
|
|
266
|
+
if (!thing) return null;
|
|
267
|
+
if (isArray(thing)) return thing;
|
|
268
|
+
let i = thing.length;
|
|
269
|
+
if (!isNumber(i)) return null;
|
|
270
|
+
const arr = new Array(i);
|
|
271
|
+
while (i-- > 0) {
|
|
272
|
+
arr[i] = thing[i];
|
|
273
|
+
}
|
|
274
|
+
return arr;
|
|
275
|
+
};
|
|
276
|
+
const isTypedArray = /* @__PURE__ */ ((TypedArray) => {
|
|
277
|
+
return (thing) => {
|
|
278
|
+
return TypedArray && thing instanceof TypedArray;
|
|
279
|
+
};
|
|
280
|
+
})(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
|
|
281
|
+
const forEachEntry = (obj, fn) => {
|
|
282
|
+
const generator = obj && obj[iterator];
|
|
283
|
+
const _iterator = generator.call(obj);
|
|
284
|
+
let result;
|
|
285
|
+
while ((result = _iterator.next()) && !result.done) {
|
|
286
|
+
const pair = result.value;
|
|
287
|
+
fn.call(obj, pair[0], pair[1]);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
const matchAll = (regExp, str) => {
|
|
291
|
+
let matches;
|
|
292
|
+
const arr = [];
|
|
293
|
+
while ((matches = regExp.exec(str)) !== null) {
|
|
294
|
+
arr.push(matches);
|
|
295
|
+
}
|
|
296
|
+
return arr;
|
|
297
|
+
};
|
|
298
|
+
const isHTMLForm = kindOfTest("HTMLFormElement");
|
|
299
|
+
const toCamelCase = (str) => {
|
|
300
|
+
return str.toLowerCase().replace(
|
|
301
|
+
/[-_\s]([a-z\d])(\w*)/g,
|
|
302
|
+
function replacer(m, p1, p2) {
|
|
303
|
+
return p1.toUpperCase() + p2;
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
};
|
|
307
|
+
const hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
|
|
308
|
+
const isRegExp = kindOfTest("RegExp");
|
|
309
|
+
const reduceDescriptors = (obj, reducer) => {
|
|
310
|
+
const descriptors2 = Object.getOwnPropertyDescriptors(obj);
|
|
311
|
+
const reducedDescriptors = {};
|
|
312
|
+
forEach(descriptors2, (descriptor, name) => {
|
|
313
|
+
let ret;
|
|
314
|
+
if ((ret = reducer(descriptor, name, obj)) !== false) {
|
|
315
|
+
reducedDescriptors[name] = ret || descriptor;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
Object.defineProperties(obj, reducedDescriptors);
|
|
319
|
+
};
|
|
320
|
+
const freezeMethods = (obj) => {
|
|
321
|
+
reduceDescriptors(obj, (descriptor, name) => {
|
|
322
|
+
if (isFunction$1(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
const value = obj[name];
|
|
326
|
+
if (!isFunction$1(value)) return;
|
|
327
|
+
descriptor.enumerable = false;
|
|
328
|
+
if ("writable" in descriptor) {
|
|
329
|
+
descriptor.writable = false;
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (!descriptor.set) {
|
|
333
|
+
descriptor.set = () => {
|
|
334
|
+
throw Error("Can not rewrite read-only method '" + name + "'");
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
const toObjectSet = (arrayOrString, delimiter) => {
|
|
340
|
+
const obj = {};
|
|
341
|
+
const define = (arr) => {
|
|
342
|
+
arr.forEach((value) => {
|
|
343
|
+
obj[value] = true;
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
|
347
|
+
return obj;
|
|
348
|
+
};
|
|
349
|
+
const noop = () => {
|
|
350
|
+
};
|
|
351
|
+
const toFiniteNumber = (value, defaultValue) => {
|
|
352
|
+
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
353
|
+
};
|
|
354
|
+
function isSpecCompliantForm(thing) {
|
|
355
|
+
return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === "FormData" && thing[iterator]);
|
|
356
|
+
}
|
|
357
|
+
const toJSONObject = (obj) => {
|
|
358
|
+
const stack = new Array(10);
|
|
359
|
+
const visit = (source, i) => {
|
|
360
|
+
if (isObject(source)) {
|
|
361
|
+
if (stack.indexOf(source) >= 0) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
if (isBuffer(source)) {
|
|
365
|
+
return source;
|
|
366
|
+
}
|
|
367
|
+
if (!("toJSON" in source)) {
|
|
368
|
+
stack[i] = source;
|
|
369
|
+
const target = isArray(source) ? [] : {};
|
|
370
|
+
forEach(source, (value, key) => {
|
|
371
|
+
const reducedValue = visit(value, i + 1);
|
|
372
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
373
|
+
});
|
|
374
|
+
stack[i] = void 0;
|
|
375
|
+
return target;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return source;
|
|
379
|
+
};
|
|
380
|
+
return visit(obj, 0);
|
|
381
|
+
};
|
|
382
|
+
const isAsyncFn = kindOfTest("AsyncFunction");
|
|
383
|
+
const isThenable = (thing) => thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
|
|
384
|
+
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
385
|
+
if (setImmediateSupported) {
|
|
386
|
+
return setImmediate;
|
|
387
|
+
}
|
|
388
|
+
return postMessageSupported ? ((token, callbacks) => {
|
|
389
|
+
_global.addEventListener("message", ({ source, data }) => {
|
|
390
|
+
if (source === _global && data === token) {
|
|
391
|
+
callbacks.length && callbacks.shift()();
|
|
392
|
+
}
|
|
393
|
+
}, false);
|
|
394
|
+
return (cb) => {
|
|
395
|
+
callbacks.push(cb);
|
|
396
|
+
_global.postMessage(token, "*");
|
|
397
|
+
};
|
|
398
|
+
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
399
|
+
})(
|
|
400
|
+
typeof setImmediate === "function",
|
|
401
|
+
isFunction$1(_global.postMessage)
|
|
402
|
+
);
|
|
403
|
+
const asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
|
|
404
|
+
const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
|
|
405
|
+
const utils$1 = {
|
|
406
|
+
isArray,
|
|
407
|
+
isArrayBuffer,
|
|
408
|
+
isBuffer,
|
|
409
|
+
isFormData,
|
|
410
|
+
isArrayBufferView,
|
|
411
|
+
isString,
|
|
412
|
+
isNumber,
|
|
413
|
+
isBoolean,
|
|
414
|
+
isObject,
|
|
415
|
+
isPlainObject,
|
|
416
|
+
isEmptyObject,
|
|
417
|
+
isReadableStream,
|
|
418
|
+
isRequest,
|
|
419
|
+
isResponse,
|
|
420
|
+
isHeaders,
|
|
421
|
+
isUndefined,
|
|
422
|
+
isDate,
|
|
423
|
+
isFile,
|
|
424
|
+
isBlob,
|
|
425
|
+
isRegExp,
|
|
426
|
+
isFunction: isFunction$1,
|
|
427
|
+
isStream,
|
|
428
|
+
isURLSearchParams,
|
|
429
|
+
isTypedArray,
|
|
430
|
+
isFileList,
|
|
431
|
+
forEach,
|
|
432
|
+
merge,
|
|
433
|
+
extend,
|
|
434
|
+
trim,
|
|
435
|
+
stripBOM,
|
|
436
|
+
inherits,
|
|
437
|
+
toFlatObject,
|
|
438
|
+
kindOf,
|
|
439
|
+
kindOfTest,
|
|
440
|
+
endsWith,
|
|
441
|
+
toArray,
|
|
442
|
+
forEachEntry,
|
|
443
|
+
matchAll,
|
|
444
|
+
isHTMLForm,
|
|
445
|
+
hasOwnProperty,
|
|
446
|
+
hasOwnProp: hasOwnProperty,
|
|
447
|
+
// an alias to avoid ESLint no-prototype-builtins detection
|
|
448
|
+
reduceDescriptors,
|
|
449
|
+
freezeMethods,
|
|
450
|
+
toObjectSet,
|
|
451
|
+
toCamelCase,
|
|
452
|
+
noop,
|
|
453
|
+
toFiniteNumber,
|
|
454
|
+
findKey,
|
|
455
|
+
global: _global,
|
|
456
|
+
isContextDefined,
|
|
457
|
+
isSpecCompliantForm,
|
|
458
|
+
toJSONObject,
|
|
459
|
+
isAsyncFn,
|
|
460
|
+
isThenable,
|
|
461
|
+
setImmediate: _setImmediate,
|
|
462
|
+
asap,
|
|
463
|
+
isIterable
|
|
464
|
+
};
|
|
465
|
+
function AxiosError$1(message, code, config2, request, response) {
|
|
466
|
+
Error.call(this);
|
|
467
|
+
if (Error.captureStackTrace) {
|
|
468
|
+
Error.captureStackTrace(this, this.constructor);
|
|
469
|
+
} else {
|
|
470
|
+
this.stack = new Error().stack;
|
|
471
|
+
}
|
|
472
|
+
this.message = message;
|
|
473
|
+
this.name = "AxiosError";
|
|
474
|
+
code && (this.code = code);
|
|
475
|
+
config2 && (this.config = config2);
|
|
476
|
+
request && (this.request = request);
|
|
477
|
+
if (response) {
|
|
478
|
+
this.response = response;
|
|
479
|
+
this.status = response.status ? response.status : null;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
utils$1.inherits(AxiosError$1, Error, {
|
|
483
|
+
toJSON: function toJSON() {
|
|
484
|
+
return {
|
|
485
|
+
// Standard
|
|
486
|
+
message: this.message,
|
|
487
|
+
name: this.name,
|
|
488
|
+
// Microsoft
|
|
489
|
+
description: this.description,
|
|
490
|
+
number: this.number,
|
|
491
|
+
// Mozilla
|
|
492
|
+
fileName: this.fileName,
|
|
493
|
+
lineNumber: this.lineNumber,
|
|
494
|
+
columnNumber: this.columnNumber,
|
|
495
|
+
stack: this.stack,
|
|
496
|
+
// Axios
|
|
497
|
+
config: utils$1.toJSONObject(this.config),
|
|
498
|
+
code: this.code,
|
|
499
|
+
status: this.status
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
const prototype$1 = AxiosError$1.prototype;
|
|
504
|
+
const descriptors = {};
|
|
505
|
+
[
|
|
506
|
+
"ERR_BAD_OPTION_VALUE",
|
|
507
|
+
"ERR_BAD_OPTION",
|
|
508
|
+
"ECONNABORTED",
|
|
509
|
+
"ETIMEDOUT",
|
|
510
|
+
"ERR_NETWORK",
|
|
511
|
+
"ERR_FR_TOO_MANY_REDIRECTS",
|
|
512
|
+
"ERR_DEPRECATED",
|
|
513
|
+
"ERR_BAD_RESPONSE",
|
|
514
|
+
"ERR_BAD_REQUEST",
|
|
515
|
+
"ERR_CANCELED",
|
|
516
|
+
"ERR_NOT_SUPPORT",
|
|
517
|
+
"ERR_INVALID_URL"
|
|
518
|
+
// eslint-disable-next-line func-names
|
|
519
|
+
].forEach((code) => {
|
|
520
|
+
descriptors[code] = { value: code };
|
|
521
|
+
});
|
|
522
|
+
Object.defineProperties(AxiosError$1, descriptors);
|
|
523
|
+
Object.defineProperty(prototype$1, "isAxiosError", { value: true });
|
|
524
|
+
AxiosError$1.from = (error, code, config2, request, response, customProps) => {
|
|
525
|
+
const axiosError = Object.create(prototype$1);
|
|
526
|
+
utils$1.toFlatObject(error, axiosError, function filter2(obj) {
|
|
527
|
+
return obj !== Error.prototype;
|
|
528
|
+
}, (prop) => {
|
|
529
|
+
return prop !== "isAxiosError";
|
|
530
|
+
});
|
|
531
|
+
const msg = error && error.message ? error.message : "Error";
|
|
532
|
+
const errCode = code == null && error ? error.code : code;
|
|
533
|
+
AxiosError$1.call(axiosError, msg, errCode, config2, request, response);
|
|
534
|
+
if (error && axiosError.cause == null) {
|
|
535
|
+
Object.defineProperty(axiosError, "cause", { value: error, configurable: true });
|
|
536
|
+
}
|
|
537
|
+
axiosError.name = error && error.name || "Error";
|
|
538
|
+
customProps && Object.assign(axiosError, customProps);
|
|
539
|
+
return axiosError;
|
|
540
|
+
};
|
|
541
|
+
const httpAdapter = null;
|
|
542
|
+
function isVisitable(thing) {
|
|
543
|
+
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
544
|
+
}
|
|
545
|
+
function removeBrackets(key) {
|
|
546
|
+
return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
|
|
547
|
+
}
|
|
548
|
+
function renderKey(path, key, dots) {
|
|
549
|
+
if (!path) return key;
|
|
550
|
+
return path.concat(key).map(function each(token, i) {
|
|
551
|
+
token = removeBrackets(token);
|
|
552
|
+
return !dots && i ? "[" + token + "]" : token;
|
|
553
|
+
}).join(dots ? "." : "");
|
|
554
|
+
}
|
|
555
|
+
function isFlatArray(arr) {
|
|
556
|
+
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
557
|
+
}
|
|
558
|
+
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
559
|
+
return /^is[A-Z]/.test(prop);
|
|
560
|
+
});
|
|
561
|
+
function toFormData$1(obj, formData, options2) {
|
|
562
|
+
if (!utils$1.isObject(obj)) {
|
|
563
|
+
throw new TypeError("target must be an object");
|
|
564
|
+
}
|
|
565
|
+
formData = formData || new FormData();
|
|
566
|
+
options2 = utils$1.toFlatObject(options2, {
|
|
567
|
+
metaTokens: true,
|
|
568
|
+
dots: false,
|
|
569
|
+
indexes: false
|
|
570
|
+
}, false, function defined(option, source) {
|
|
571
|
+
return !utils$1.isUndefined(source[option]);
|
|
572
|
+
});
|
|
573
|
+
const metaTokens = options2.metaTokens;
|
|
574
|
+
const visitor = options2.visitor || defaultVisitor;
|
|
575
|
+
const dots = options2.dots;
|
|
576
|
+
const indexes = options2.indexes;
|
|
577
|
+
const _Blob = options2.Blob || typeof Blob !== "undefined" && Blob;
|
|
578
|
+
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
579
|
+
if (!utils$1.isFunction(visitor)) {
|
|
580
|
+
throw new TypeError("visitor must be a function");
|
|
581
|
+
}
|
|
582
|
+
function convertValue(value) {
|
|
583
|
+
if (value === null) return "";
|
|
584
|
+
if (utils$1.isDate(value)) {
|
|
585
|
+
return value.toISOString();
|
|
586
|
+
}
|
|
587
|
+
if (utils$1.isBoolean(value)) {
|
|
588
|
+
return value.toString();
|
|
589
|
+
}
|
|
590
|
+
if (!useBlob && utils$1.isBlob(value)) {
|
|
591
|
+
throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");
|
|
592
|
+
}
|
|
593
|
+
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
594
|
+
return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
|
|
595
|
+
}
|
|
596
|
+
return value;
|
|
597
|
+
}
|
|
598
|
+
function defaultVisitor(value, key, path) {
|
|
599
|
+
let arr = value;
|
|
600
|
+
if (value && !path && typeof value === "object") {
|
|
601
|
+
if (utils$1.endsWith(key, "{}")) {
|
|
602
|
+
key = metaTokens ? key : key.slice(0, -2);
|
|
603
|
+
value = JSON.stringify(value);
|
|
604
|
+
} else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
|
|
605
|
+
key = removeBrackets(key);
|
|
606
|
+
arr.forEach(function each(el, index2) {
|
|
607
|
+
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
|
608
|
+
// eslint-disable-next-line no-nested-ternary
|
|
609
|
+
indexes === true ? renderKey([key], index2, dots) : indexes === null ? key : key + "[]",
|
|
610
|
+
convertValue(el)
|
|
611
|
+
);
|
|
612
|
+
});
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (isVisitable(value)) {
|
|
617
|
+
return true;
|
|
618
|
+
}
|
|
619
|
+
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
620
|
+
return false;
|
|
621
|
+
}
|
|
622
|
+
const stack = [];
|
|
623
|
+
const exposedHelpers = Object.assign(predicates, {
|
|
624
|
+
defaultVisitor,
|
|
625
|
+
convertValue,
|
|
626
|
+
isVisitable
|
|
627
|
+
});
|
|
628
|
+
function build(value, path) {
|
|
629
|
+
if (utils$1.isUndefined(value)) return;
|
|
630
|
+
if (stack.indexOf(value) !== -1) {
|
|
631
|
+
throw Error("Circular reference detected in " + path.join("."));
|
|
632
|
+
}
|
|
633
|
+
stack.push(value);
|
|
634
|
+
utils$1.forEach(value, function each(el, key) {
|
|
635
|
+
const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
|
|
636
|
+
formData,
|
|
637
|
+
el,
|
|
638
|
+
utils$1.isString(key) ? key.trim() : key,
|
|
639
|
+
path,
|
|
640
|
+
exposedHelpers
|
|
641
|
+
);
|
|
642
|
+
if (result === true) {
|
|
643
|
+
build(el, path ? path.concat(key) : [key]);
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
stack.pop();
|
|
647
|
+
}
|
|
648
|
+
if (!utils$1.isObject(obj)) {
|
|
649
|
+
throw new TypeError("data must be an object");
|
|
650
|
+
}
|
|
651
|
+
build(obj);
|
|
652
|
+
return formData;
|
|
653
|
+
}
|
|
654
|
+
function encode$1(str) {
|
|
655
|
+
const charMap = {
|
|
656
|
+
"!": "%21",
|
|
657
|
+
"'": "%27",
|
|
658
|
+
"(": "%28",
|
|
659
|
+
")": "%29",
|
|
660
|
+
"~": "%7E",
|
|
661
|
+
"%20": "+",
|
|
662
|
+
"%00": "\0"
|
|
663
|
+
};
|
|
664
|
+
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
|
665
|
+
return charMap[match];
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
function AxiosURLSearchParams(params, options2) {
|
|
669
|
+
this._pairs = [];
|
|
670
|
+
params && toFormData$1(params, this, options2);
|
|
671
|
+
}
|
|
672
|
+
const prototype = AxiosURLSearchParams.prototype;
|
|
673
|
+
prototype.append = function append(name, value) {
|
|
674
|
+
this._pairs.push([name, value]);
|
|
675
|
+
};
|
|
676
|
+
prototype.toString = function toString2(encoder) {
|
|
677
|
+
const _encode = encoder ? function(value) {
|
|
678
|
+
return encoder.call(this, value, encode$1);
|
|
679
|
+
} : encode$1;
|
|
680
|
+
return this._pairs.map(function each(pair) {
|
|
681
|
+
return _encode(pair[0]) + "=" + _encode(pair[1]);
|
|
682
|
+
}, "").join("&");
|
|
683
|
+
};
|
|
684
|
+
function encode(val) {
|
|
685
|
+
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
|
|
686
|
+
}
|
|
687
|
+
function buildURL(url, params, options2) {
|
|
688
|
+
if (!params) {
|
|
689
|
+
return url;
|
|
690
|
+
}
|
|
691
|
+
const _encode = options2 && options2.encode || encode;
|
|
692
|
+
if (utils$1.isFunction(options2)) {
|
|
693
|
+
options2 = {
|
|
694
|
+
serialize: options2
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
const serializeFn = options2 && options2.serialize;
|
|
698
|
+
let serializedParams;
|
|
699
|
+
if (serializeFn) {
|
|
700
|
+
serializedParams = serializeFn(params, options2);
|
|
701
|
+
} else {
|
|
702
|
+
serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options2).toString(_encode);
|
|
703
|
+
}
|
|
704
|
+
if (serializedParams) {
|
|
705
|
+
const hashmarkIndex = url.indexOf("#");
|
|
706
|
+
if (hashmarkIndex !== -1) {
|
|
707
|
+
url = url.slice(0, hashmarkIndex);
|
|
708
|
+
}
|
|
709
|
+
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
710
|
+
}
|
|
711
|
+
return url;
|
|
712
|
+
}
|
|
713
|
+
class InterceptorManager {
|
|
714
|
+
constructor() {
|
|
715
|
+
this.handlers = [];
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Add a new interceptor to the stack
|
|
719
|
+
*
|
|
720
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
721
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
722
|
+
*
|
|
723
|
+
* @return {Number} An ID used to remove interceptor later
|
|
724
|
+
*/
|
|
725
|
+
use(fulfilled, rejected, options2) {
|
|
726
|
+
this.handlers.push({
|
|
727
|
+
fulfilled,
|
|
728
|
+
rejected,
|
|
729
|
+
synchronous: options2 ? options2.synchronous : false,
|
|
730
|
+
runWhen: options2 ? options2.runWhen : null
|
|
731
|
+
});
|
|
732
|
+
return this.handlers.length - 1;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Remove an interceptor from the stack
|
|
736
|
+
*
|
|
737
|
+
* @param {Number} id The ID that was returned by `use`
|
|
738
|
+
*
|
|
739
|
+
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
|
740
|
+
*/
|
|
741
|
+
eject(id) {
|
|
742
|
+
if (this.handlers[id]) {
|
|
743
|
+
this.handlers[id] = null;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Clear all interceptors from the stack
|
|
748
|
+
*
|
|
749
|
+
* @returns {void}
|
|
750
|
+
*/
|
|
751
|
+
clear() {
|
|
752
|
+
if (this.handlers) {
|
|
753
|
+
this.handlers = [];
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Iterate over all the registered interceptors
|
|
758
|
+
*
|
|
759
|
+
* This method is particularly useful for skipping over any
|
|
760
|
+
* interceptors that may have become `null` calling `eject`.
|
|
761
|
+
*
|
|
762
|
+
* @param {Function} fn The function to call for each interceptor
|
|
763
|
+
*
|
|
764
|
+
* @returns {void}
|
|
765
|
+
*/
|
|
766
|
+
forEach(fn) {
|
|
767
|
+
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
|
768
|
+
if (h !== null) {
|
|
769
|
+
fn(h);
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
const transitionalDefaults = {
|
|
775
|
+
silentJSONParsing: true,
|
|
776
|
+
forcedJSONParsing: true,
|
|
777
|
+
clarifyTimeoutError: false
|
|
778
|
+
};
|
|
779
|
+
const URLSearchParams$1 = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams;
|
|
780
|
+
const FormData$1 = typeof FormData !== "undefined" ? FormData : null;
|
|
781
|
+
const Blob$1 = typeof Blob !== "undefined" ? Blob : null;
|
|
782
|
+
const platform$1 = {
|
|
783
|
+
isBrowser: true,
|
|
784
|
+
classes: {
|
|
785
|
+
URLSearchParams: URLSearchParams$1,
|
|
786
|
+
FormData: FormData$1,
|
|
787
|
+
Blob: Blob$1
|
|
788
|
+
},
|
|
789
|
+
protocols: ["http", "https", "file", "blob", "url", "data"]
|
|
790
|
+
};
|
|
791
|
+
const hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
|
|
792
|
+
const _navigator = typeof navigator === "object" && navigator || void 0;
|
|
793
|
+
const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
|
|
794
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
795
|
+
return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
|
|
796
|
+
self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
|
|
797
|
+
})();
|
|
798
|
+
const origin = hasBrowserEnv && window.location.href || "http://localhost";
|
|
799
|
+
const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
800
|
+
__proto__: null,
|
|
801
|
+
hasBrowserEnv,
|
|
802
|
+
hasStandardBrowserEnv,
|
|
803
|
+
hasStandardBrowserWebWorkerEnv,
|
|
804
|
+
navigator: _navigator,
|
|
805
|
+
origin
|
|
806
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
807
|
+
const platform = {
|
|
808
|
+
...utils,
|
|
809
|
+
...platform$1
|
|
810
|
+
};
|
|
811
|
+
function toURLEncodedForm(data, options2) {
|
|
812
|
+
return toFormData$1(data, new platform.classes.URLSearchParams(), {
|
|
813
|
+
visitor: function(value, key, path, helpers) {
|
|
814
|
+
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
815
|
+
this.append(key, value.toString("base64"));
|
|
816
|
+
return false;
|
|
817
|
+
}
|
|
818
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
819
|
+
},
|
|
820
|
+
...options2
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
function parsePropPath(name) {
|
|
824
|
+
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
|
|
825
|
+
return match[0] === "[]" ? "" : match[1] || match[0];
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
function arrayToObject(arr) {
|
|
829
|
+
const obj = {};
|
|
830
|
+
const keys = Object.keys(arr);
|
|
831
|
+
let i;
|
|
832
|
+
const len = keys.length;
|
|
833
|
+
let key;
|
|
834
|
+
for (i = 0; i < len; i++) {
|
|
835
|
+
key = keys[i];
|
|
836
|
+
obj[key] = arr[key];
|
|
837
|
+
}
|
|
838
|
+
return obj;
|
|
839
|
+
}
|
|
840
|
+
function formDataToJSON(formData) {
|
|
841
|
+
function buildPath(path, value, target, index2) {
|
|
842
|
+
let name = path[index2++];
|
|
843
|
+
if (name === "__proto__") return true;
|
|
844
|
+
const isNumericKey = Number.isFinite(+name);
|
|
845
|
+
const isLast = index2 >= path.length;
|
|
846
|
+
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
847
|
+
if (isLast) {
|
|
848
|
+
if (utils$1.hasOwnProp(target, name)) {
|
|
849
|
+
target[name] = [target[name], value];
|
|
850
|
+
} else {
|
|
851
|
+
target[name] = value;
|
|
852
|
+
}
|
|
853
|
+
return !isNumericKey;
|
|
854
|
+
}
|
|
855
|
+
if (!target[name] || !utils$1.isObject(target[name])) {
|
|
856
|
+
target[name] = [];
|
|
857
|
+
}
|
|
858
|
+
const result = buildPath(path, value, target[name], index2);
|
|
859
|
+
if (result && utils$1.isArray(target[name])) {
|
|
860
|
+
target[name] = arrayToObject(target[name]);
|
|
861
|
+
}
|
|
862
|
+
return !isNumericKey;
|
|
863
|
+
}
|
|
864
|
+
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
865
|
+
const obj = {};
|
|
866
|
+
utils$1.forEachEntry(formData, (name, value) => {
|
|
867
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
868
|
+
});
|
|
869
|
+
return obj;
|
|
870
|
+
}
|
|
871
|
+
return null;
|
|
872
|
+
}
|
|
873
|
+
function stringifySafely(rawValue, parser, encoder) {
|
|
874
|
+
if (utils$1.isString(rawValue)) {
|
|
875
|
+
try {
|
|
876
|
+
(parser || JSON.parse)(rawValue);
|
|
877
|
+
return utils$1.trim(rawValue);
|
|
878
|
+
} catch (e) {
|
|
879
|
+
if (e.name !== "SyntaxError") {
|
|
880
|
+
throw e;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
return (encoder || JSON.stringify)(rawValue);
|
|
885
|
+
}
|
|
886
|
+
const defaults = {
|
|
887
|
+
transitional: transitionalDefaults,
|
|
888
|
+
adapter: ["xhr", "http", "fetch"],
|
|
889
|
+
transformRequest: [function transformRequest(data, headers) {
|
|
890
|
+
const contentType = headers.getContentType() || "";
|
|
891
|
+
const hasJSONContentType = contentType.indexOf("application/json") > -1;
|
|
892
|
+
const isObjectPayload = utils$1.isObject(data);
|
|
893
|
+
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
894
|
+
data = new FormData(data);
|
|
895
|
+
}
|
|
896
|
+
const isFormData2 = utils$1.isFormData(data);
|
|
897
|
+
if (isFormData2) {
|
|
898
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
899
|
+
}
|
|
900
|
+
if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
|
|
901
|
+
return data;
|
|
902
|
+
}
|
|
903
|
+
if (utils$1.isArrayBufferView(data)) {
|
|
904
|
+
return data.buffer;
|
|
905
|
+
}
|
|
906
|
+
if (utils$1.isURLSearchParams(data)) {
|
|
907
|
+
headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
|
|
908
|
+
return data.toString();
|
|
909
|
+
}
|
|
910
|
+
let isFileList2;
|
|
911
|
+
if (isObjectPayload) {
|
|
912
|
+
if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
|
|
913
|
+
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
914
|
+
}
|
|
915
|
+
if ((isFileList2 = utils$1.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
|
|
916
|
+
const _FormData = this.env && this.env.FormData;
|
|
917
|
+
return toFormData$1(
|
|
918
|
+
isFileList2 ? { "files[]": data } : data,
|
|
919
|
+
_FormData && new _FormData(),
|
|
920
|
+
this.formSerializer
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
if (isObjectPayload || hasJSONContentType) {
|
|
925
|
+
headers.setContentType("application/json", false);
|
|
926
|
+
return stringifySafely(data);
|
|
927
|
+
}
|
|
928
|
+
return data;
|
|
929
|
+
}],
|
|
930
|
+
transformResponse: [function transformResponse(data) {
|
|
931
|
+
const transitional2 = this.transitional || defaults.transitional;
|
|
932
|
+
const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
|
|
933
|
+
const JSONRequested = this.responseType === "json";
|
|
934
|
+
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
935
|
+
return data;
|
|
936
|
+
}
|
|
937
|
+
if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
|
938
|
+
const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
|
|
939
|
+
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
940
|
+
try {
|
|
941
|
+
return JSON.parse(data, this.parseReviver);
|
|
942
|
+
} catch (e) {
|
|
943
|
+
if (strictJSONParsing) {
|
|
944
|
+
if (e.name === "SyntaxError") {
|
|
945
|
+
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
|
946
|
+
}
|
|
947
|
+
throw e;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
return data;
|
|
952
|
+
}],
|
|
953
|
+
/**
|
|
954
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
955
|
+
* timeout is not created.
|
|
956
|
+
*/
|
|
957
|
+
timeout: 0,
|
|
958
|
+
xsrfCookieName: "XSRF-TOKEN",
|
|
959
|
+
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
960
|
+
maxContentLength: -1,
|
|
961
|
+
maxBodyLength: -1,
|
|
962
|
+
env: {
|
|
963
|
+
FormData: platform.classes.FormData,
|
|
964
|
+
Blob: platform.classes.Blob
|
|
965
|
+
},
|
|
966
|
+
validateStatus: function validateStatus(status) {
|
|
967
|
+
return status >= 200 && status < 300;
|
|
968
|
+
},
|
|
969
|
+
headers: {
|
|
970
|
+
common: {
|
|
971
|
+
"Accept": "application/json, text/plain, */*",
|
|
972
|
+
"Content-Type": void 0
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
|
|
977
|
+
defaults.headers[method] = {};
|
|
978
|
+
});
|
|
979
|
+
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
980
|
+
"age",
|
|
981
|
+
"authorization",
|
|
982
|
+
"content-length",
|
|
983
|
+
"content-type",
|
|
984
|
+
"etag",
|
|
985
|
+
"expires",
|
|
986
|
+
"from",
|
|
987
|
+
"host",
|
|
988
|
+
"if-modified-since",
|
|
989
|
+
"if-unmodified-since",
|
|
990
|
+
"last-modified",
|
|
991
|
+
"location",
|
|
992
|
+
"max-forwards",
|
|
993
|
+
"proxy-authorization",
|
|
994
|
+
"referer",
|
|
995
|
+
"retry-after",
|
|
996
|
+
"user-agent"
|
|
997
|
+
]);
|
|
998
|
+
const parseHeaders = (rawHeaders) => {
|
|
999
|
+
const parsed = {};
|
|
1000
|
+
let key;
|
|
1001
|
+
let val;
|
|
1002
|
+
let i;
|
|
1003
|
+
rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
|
|
1004
|
+
i = line.indexOf(":");
|
|
1005
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
1006
|
+
val = line.substring(i + 1).trim();
|
|
1007
|
+
if (!key || parsed[key] && ignoreDuplicateOf[key]) {
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
if (key === "set-cookie") {
|
|
1011
|
+
if (parsed[key]) {
|
|
1012
|
+
parsed[key].push(val);
|
|
1013
|
+
} else {
|
|
1014
|
+
parsed[key] = [val];
|
|
1015
|
+
}
|
|
1016
|
+
} else {
|
|
1017
|
+
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
return parsed;
|
|
1021
|
+
};
|
|
1022
|
+
const $internals = Symbol("internals");
|
|
1023
|
+
function normalizeHeader(header) {
|
|
1024
|
+
return header && String(header).trim().toLowerCase();
|
|
1025
|
+
}
|
|
1026
|
+
function normalizeValue(value) {
|
|
1027
|
+
if (value === false || value == null) {
|
|
1028
|
+
return value;
|
|
1029
|
+
}
|
|
1030
|
+
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
1031
|
+
}
|
|
1032
|
+
function parseTokens(str) {
|
|
1033
|
+
const tokens = /* @__PURE__ */ Object.create(null);
|
|
1034
|
+
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
1035
|
+
let match;
|
|
1036
|
+
while (match = tokensRE.exec(str)) {
|
|
1037
|
+
tokens[match[1]] = match[2];
|
|
1038
|
+
}
|
|
1039
|
+
return tokens;
|
|
1040
|
+
}
|
|
1041
|
+
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
1042
|
+
function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
|
|
1043
|
+
if (utils$1.isFunction(filter2)) {
|
|
1044
|
+
return filter2.call(this, value, header);
|
|
1045
|
+
}
|
|
1046
|
+
if (isHeaderNameFilter) {
|
|
1047
|
+
value = header;
|
|
1048
|
+
}
|
|
1049
|
+
if (!utils$1.isString(value)) return;
|
|
1050
|
+
if (utils$1.isString(filter2)) {
|
|
1051
|
+
return value.indexOf(filter2) !== -1;
|
|
1052
|
+
}
|
|
1053
|
+
if (utils$1.isRegExp(filter2)) {
|
|
1054
|
+
return filter2.test(value);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
function formatHeader(header) {
|
|
1058
|
+
return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
1059
|
+
return char.toUpperCase() + str;
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
function buildAccessors(obj, header) {
|
|
1063
|
+
const accessorName = utils$1.toCamelCase(" " + header);
|
|
1064
|
+
["get", "set", "has"].forEach((methodName) => {
|
|
1065
|
+
Object.defineProperty(obj, methodName + accessorName, {
|
|
1066
|
+
value: function(arg1, arg2, arg3) {
|
|
1067
|
+
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
1068
|
+
},
|
|
1069
|
+
configurable: true
|
|
1070
|
+
});
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
let AxiosHeaders$1 = class AxiosHeaders {
|
|
1074
|
+
constructor(headers) {
|
|
1075
|
+
headers && this.set(headers);
|
|
1076
|
+
}
|
|
1077
|
+
set(header, valueOrRewrite, rewrite) {
|
|
1078
|
+
const self2 = this;
|
|
1079
|
+
function setHeader(_value, _header, _rewrite) {
|
|
1080
|
+
const lHeader = normalizeHeader(_header);
|
|
1081
|
+
if (!lHeader) {
|
|
1082
|
+
throw new Error("header name must be a non-empty string");
|
|
1083
|
+
}
|
|
1084
|
+
const key = utils$1.findKey(self2, lHeader);
|
|
1085
|
+
if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
|
|
1086
|
+
self2[key || _header] = normalizeValue(_value);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
1090
|
+
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
1091
|
+
setHeaders(header, valueOrRewrite);
|
|
1092
|
+
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
1093
|
+
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
1094
|
+
} else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
|
|
1095
|
+
let obj = {}, dest, key;
|
|
1096
|
+
for (const entry of header) {
|
|
1097
|
+
if (!utils$1.isArray(entry)) {
|
|
1098
|
+
throw TypeError("Object iterator must return a key-value pair");
|
|
1099
|
+
}
|
|
1100
|
+
obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
|
|
1101
|
+
}
|
|
1102
|
+
setHeaders(obj, valueOrRewrite);
|
|
1103
|
+
} else {
|
|
1104
|
+
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
1105
|
+
}
|
|
1106
|
+
return this;
|
|
1107
|
+
}
|
|
1108
|
+
get(header, parser) {
|
|
1109
|
+
header = normalizeHeader(header);
|
|
1110
|
+
if (header) {
|
|
1111
|
+
const key = utils$1.findKey(this, header);
|
|
1112
|
+
if (key) {
|
|
1113
|
+
const value = this[key];
|
|
1114
|
+
if (!parser) {
|
|
1115
|
+
return value;
|
|
1116
|
+
}
|
|
1117
|
+
if (parser === true) {
|
|
1118
|
+
return parseTokens(value);
|
|
1119
|
+
}
|
|
1120
|
+
if (utils$1.isFunction(parser)) {
|
|
1121
|
+
return parser.call(this, value, key);
|
|
1122
|
+
}
|
|
1123
|
+
if (utils$1.isRegExp(parser)) {
|
|
1124
|
+
return parser.exec(value);
|
|
1125
|
+
}
|
|
1126
|
+
throw new TypeError("parser must be boolean|regexp|function");
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
has(header, matcher) {
|
|
1131
|
+
header = normalizeHeader(header);
|
|
1132
|
+
if (header) {
|
|
1133
|
+
const key = utils$1.findKey(this, header);
|
|
1134
|
+
return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
1135
|
+
}
|
|
1136
|
+
return false;
|
|
1137
|
+
}
|
|
1138
|
+
delete(header, matcher) {
|
|
1139
|
+
const self2 = this;
|
|
1140
|
+
let deleted = false;
|
|
1141
|
+
function deleteHeader(_header) {
|
|
1142
|
+
_header = normalizeHeader(_header);
|
|
1143
|
+
if (_header) {
|
|
1144
|
+
const key = utils$1.findKey(self2, _header);
|
|
1145
|
+
if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
|
|
1146
|
+
delete self2[key];
|
|
1147
|
+
deleted = true;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
if (utils$1.isArray(header)) {
|
|
1152
|
+
header.forEach(deleteHeader);
|
|
1153
|
+
} else {
|
|
1154
|
+
deleteHeader(header);
|
|
1155
|
+
}
|
|
1156
|
+
return deleted;
|
|
1157
|
+
}
|
|
1158
|
+
clear(matcher) {
|
|
1159
|
+
const keys = Object.keys(this);
|
|
1160
|
+
let i = keys.length;
|
|
1161
|
+
let deleted = false;
|
|
1162
|
+
while (i--) {
|
|
1163
|
+
const key = keys[i];
|
|
1164
|
+
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
1165
|
+
delete this[key];
|
|
1166
|
+
deleted = true;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
return deleted;
|
|
1170
|
+
}
|
|
1171
|
+
normalize(format) {
|
|
1172
|
+
const self2 = this;
|
|
1173
|
+
const headers = {};
|
|
1174
|
+
utils$1.forEach(this, (value, header) => {
|
|
1175
|
+
const key = utils$1.findKey(headers, header);
|
|
1176
|
+
if (key) {
|
|
1177
|
+
self2[key] = normalizeValue(value);
|
|
1178
|
+
delete self2[header];
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
1182
|
+
if (normalized !== header) {
|
|
1183
|
+
delete self2[header];
|
|
1184
|
+
}
|
|
1185
|
+
self2[normalized] = normalizeValue(value);
|
|
1186
|
+
headers[normalized] = true;
|
|
1187
|
+
});
|
|
1188
|
+
return this;
|
|
1189
|
+
}
|
|
1190
|
+
concat(...targets) {
|
|
1191
|
+
return this.constructor.concat(this, ...targets);
|
|
1192
|
+
}
|
|
1193
|
+
toJSON(asStrings) {
|
|
1194
|
+
const obj = /* @__PURE__ */ Object.create(null);
|
|
1195
|
+
utils$1.forEach(this, (value, header) => {
|
|
1196
|
+
value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(", ") : value);
|
|
1197
|
+
});
|
|
1198
|
+
return obj;
|
|
1199
|
+
}
|
|
1200
|
+
[Symbol.iterator]() {
|
|
1201
|
+
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
1202
|
+
}
|
|
1203
|
+
toString() {
|
|
1204
|
+
return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
|
|
1205
|
+
}
|
|
1206
|
+
getSetCookie() {
|
|
1207
|
+
return this.get("set-cookie") || [];
|
|
1208
|
+
}
|
|
1209
|
+
get [Symbol.toStringTag]() {
|
|
1210
|
+
return "AxiosHeaders";
|
|
1211
|
+
}
|
|
1212
|
+
static from(thing) {
|
|
1213
|
+
return thing instanceof this ? thing : new this(thing);
|
|
1214
|
+
}
|
|
1215
|
+
static concat(first, ...targets) {
|
|
1216
|
+
const computed = new this(first);
|
|
1217
|
+
targets.forEach((target) => computed.set(target));
|
|
1218
|
+
return computed;
|
|
1219
|
+
}
|
|
1220
|
+
static accessor(header) {
|
|
1221
|
+
const internals = this[$internals] = this[$internals] = {
|
|
1222
|
+
accessors: {}
|
|
1223
|
+
};
|
|
1224
|
+
const accessors = internals.accessors;
|
|
1225
|
+
const prototype2 = this.prototype;
|
|
1226
|
+
function defineAccessor(_header) {
|
|
1227
|
+
const lHeader = normalizeHeader(_header);
|
|
1228
|
+
if (!accessors[lHeader]) {
|
|
1229
|
+
buildAccessors(prototype2, _header);
|
|
1230
|
+
accessors[lHeader] = true;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
1234
|
+
return this;
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
AxiosHeaders$1.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
|
|
1238
|
+
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
1239
|
+
let mapped = key[0].toUpperCase() + key.slice(1);
|
|
1240
|
+
return {
|
|
1241
|
+
get: () => value,
|
|
1242
|
+
set(headerValue) {
|
|
1243
|
+
this[mapped] = headerValue;
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
});
|
|
1247
|
+
utils$1.freezeMethods(AxiosHeaders$1);
|
|
1248
|
+
function transformData(fns, response) {
|
|
1249
|
+
const config2 = this || defaults;
|
|
1250
|
+
const context = response || config2;
|
|
1251
|
+
const headers = AxiosHeaders$1.from(context.headers);
|
|
1252
|
+
let data = context.data;
|
|
1253
|
+
utils$1.forEach(fns, function transform(fn) {
|
|
1254
|
+
data = fn.call(config2, data, headers.normalize(), response ? response.status : void 0);
|
|
1255
|
+
});
|
|
1256
|
+
headers.normalize();
|
|
1257
|
+
return data;
|
|
1258
|
+
}
|
|
1259
|
+
function isCancel$1(value) {
|
|
1260
|
+
return !!(value && value.__CANCEL__);
|
|
1261
|
+
}
|
|
1262
|
+
function CanceledError$1(message, config2, request) {
|
|
1263
|
+
AxiosError$1.call(this, message == null ? "canceled" : message, AxiosError$1.ERR_CANCELED, config2, request);
|
|
1264
|
+
this.name = "CanceledError";
|
|
1265
|
+
}
|
|
1266
|
+
utils$1.inherits(CanceledError$1, AxiosError$1, {
|
|
1267
|
+
__CANCEL__: true
|
|
1268
|
+
});
|
|
1269
|
+
function settle(resolve, reject, response) {
|
|
1270
|
+
const validateStatus2 = response.config.validateStatus;
|
|
1271
|
+
if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
|
|
1272
|
+
resolve(response);
|
|
1273
|
+
} else {
|
|
1274
|
+
reject(new AxiosError$1(
|
|
1275
|
+
"Request failed with status code " + response.status,
|
|
1276
|
+
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
1277
|
+
response.config,
|
|
1278
|
+
response.request,
|
|
1279
|
+
response
|
|
1280
|
+
));
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
function parseProtocol(url) {
|
|
1284
|
+
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
1285
|
+
return match && match[1] || "";
|
|
1286
|
+
}
|
|
1287
|
+
function speedometer(samplesCount, min) {
|
|
1288
|
+
samplesCount = samplesCount || 10;
|
|
1289
|
+
const bytes = new Array(samplesCount);
|
|
1290
|
+
const timestamps = new Array(samplesCount);
|
|
1291
|
+
let head = 0;
|
|
1292
|
+
let tail = 0;
|
|
1293
|
+
let firstSampleTS;
|
|
1294
|
+
min = min !== void 0 ? min : 1e3;
|
|
1295
|
+
return function push(chunkLength) {
|
|
1296
|
+
const now = Date.now();
|
|
1297
|
+
const startedAt = timestamps[tail];
|
|
1298
|
+
if (!firstSampleTS) {
|
|
1299
|
+
firstSampleTS = now;
|
|
1300
|
+
}
|
|
1301
|
+
bytes[head] = chunkLength;
|
|
1302
|
+
timestamps[head] = now;
|
|
1303
|
+
let i = tail;
|
|
1304
|
+
let bytesCount = 0;
|
|
1305
|
+
while (i !== head) {
|
|
1306
|
+
bytesCount += bytes[i++];
|
|
1307
|
+
i = i % samplesCount;
|
|
1308
|
+
}
|
|
1309
|
+
head = (head + 1) % samplesCount;
|
|
1310
|
+
if (head === tail) {
|
|
1311
|
+
tail = (tail + 1) % samplesCount;
|
|
1312
|
+
}
|
|
1313
|
+
if (now - firstSampleTS < min) {
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
const passed = startedAt && now - startedAt;
|
|
1317
|
+
return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
function throttle(fn, freq) {
|
|
1321
|
+
let timestamp = 0;
|
|
1322
|
+
let threshold = 1e3 / freq;
|
|
1323
|
+
let lastArgs;
|
|
1324
|
+
let timer;
|
|
1325
|
+
const invoke = (args, now = Date.now()) => {
|
|
1326
|
+
timestamp = now;
|
|
1327
|
+
lastArgs = null;
|
|
1328
|
+
if (timer) {
|
|
1329
|
+
clearTimeout(timer);
|
|
1330
|
+
timer = null;
|
|
1331
|
+
}
|
|
1332
|
+
fn(...args);
|
|
1333
|
+
};
|
|
1334
|
+
const throttled = (...args) => {
|
|
1335
|
+
const now = Date.now();
|
|
1336
|
+
const passed = now - timestamp;
|
|
1337
|
+
if (passed >= threshold) {
|
|
1338
|
+
invoke(args, now);
|
|
1339
|
+
} else {
|
|
1340
|
+
lastArgs = args;
|
|
1341
|
+
if (!timer) {
|
|
1342
|
+
timer = setTimeout(() => {
|
|
1343
|
+
timer = null;
|
|
1344
|
+
invoke(lastArgs);
|
|
1345
|
+
}, threshold - passed);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
};
|
|
1349
|
+
const flush = () => lastArgs && invoke(lastArgs);
|
|
1350
|
+
return [throttled, flush];
|
|
1351
|
+
}
|
|
1352
|
+
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
1353
|
+
let bytesNotified = 0;
|
|
1354
|
+
const _speedometer = speedometer(50, 250);
|
|
1355
|
+
return throttle((e) => {
|
|
1356
|
+
const loaded = e.loaded;
|
|
1357
|
+
const total = e.lengthComputable ? e.total : void 0;
|
|
1358
|
+
const progressBytes = loaded - bytesNotified;
|
|
1359
|
+
const rate = _speedometer(progressBytes);
|
|
1360
|
+
const inRange = loaded <= total;
|
|
1361
|
+
bytesNotified = loaded;
|
|
1362
|
+
const data = {
|
|
1363
|
+
loaded,
|
|
1364
|
+
total,
|
|
1365
|
+
progress: total ? loaded / total : void 0,
|
|
1366
|
+
bytes: progressBytes,
|
|
1367
|
+
rate: rate ? rate : void 0,
|
|
1368
|
+
estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
|
|
1369
|
+
event: e,
|
|
1370
|
+
lengthComputable: total != null,
|
|
1371
|
+
[isDownloadStream ? "download" : "upload"]: true
|
|
1372
|
+
};
|
|
1373
|
+
listener(data);
|
|
1374
|
+
}, freq);
|
|
1375
|
+
};
|
|
1376
|
+
const progressEventDecorator = (total, throttled) => {
|
|
1377
|
+
const lengthComputable = total != null;
|
|
1378
|
+
return [(loaded) => throttled[0]({
|
|
1379
|
+
lengthComputable,
|
|
1380
|
+
total,
|
|
1381
|
+
loaded
|
|
1382
|
+
}), throttled[1]];
|
|
1383
|
+
};
|
|
1384
|
+
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
|
1385
|
+
const isURLSameOrigin = platform.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url) => {
|
|
1386
|
+
url = new URL(url, platform.origin);
|
|
1387
|
+
return origin2.protocol === url.protocol && origin2.host === url.host && (isMSIE || origin2.port === url.port);
|
|
1388
|
+
})(
|
|
1389
|
+
new URL(platform.origin),
|
|
1390
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
1391
|
+
) : () => true;
|
|
1392
|
+
const cookies = platform.hasStandardBrowserEnv ? (
|
|
1393
|
+
// Standard browser envs support document.cookie
|
|
1394
|
+
{
|
|
1395
|
+
write(name, value, expires, path, domain, secure) {
|
|
1396
|
+
const cookie = [name + "=" + encodeURIComponent(value)];
|
|
1397
|
+
utils$1.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
|
|
1398
|
+
utils$1.isString(path) && cookie.push("path=" + path);
|
|
1399
|
+
utils$1.isString(domain) && cookie.push("domain=" + domain);
|
|
1400
|
+
secure === true && cookie.push("secure");
|
|
1401
|
+
document.cookie = cookie.join("; ");
|
|
1402
|
+
},
|
|
1403
|
+
read(name) {
|
|
1404
|
+
const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
|
|
1405
|
+
return match ? decodeURIComponent(match[3]) : null;
|
|
1406
|
+
},
|
|
1407
|
+
remove(name) {
|
|
1408
|
+
this.write(name, "", Date.now() - 864e5);
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
) : (
|
|
1412
|
+
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
1413
|
+
{
|
|
1414
|
+
write() {
|
|
1415
|
+
},
|
|
1416
|
+
read() {
|
|
1417
|
+
return null;
|
|
1418
|
+
},
|
|
1419
|
+
remove() {
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
);
|
|
1423
|
+
function isAbsoluteURL(url) {
|
|
1424
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
1425
|
+
}
|
|
1426
|
+
function combineURLs(baseURL, relativeURL) {
|
|
1427
|
+
return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
1428
|
+
}
|
|
1429
|
+
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
1430
|
+
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
1431
|
+
if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
|
|
1432
|
+
return combineURLs(baseURL, requestedURL);
|
|
1433
|
+
}
|
|
1434
|
+
return requestedURL;
|
|
1435
|
+
}
|
|
1436
|
+
const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
1437
|
+
function mergeConfig$1(config1, config2) {
|
|
1438
|
+
config2 = config2 || {};
|
|
1439
|
+
const config3 = {};
|
|
1440
|
+
function getMergedValue(target, source, prop, caseless) {
|
|
1441
|
+
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
1442
|
+
return utils$1.merge.call({ caseless }, target, source);
|
|
1443
|
+
} else if (utils$1.isPlainObject(source)) {
|
|
1444
|
+
return utils$1.merge({}, source);
|
|
1445
|
+
} else if (utils$1.isArray(source)) {
|
|
1446
|
+
return source.slice();
|
|
1447
|
+
}
|
|
1448
|
+
return source;
|
|
1449
|
+
}
|
|
1450
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
1451
|
+
if (!utils$1.isUndefined(b)) {
|
|
1452
|
+
return getMergedValue(a, b, prop, caseless);
|
|
1453
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
1454
|
+
return getMergedValue(void 0, a, prop, caseless);
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
function valueFromConfig2(a, b) {
|
|
1458
|
+
if (!utils$1.isUndefined(b)) {
|
|
1459
|
+
return getMergedValue(void 0, b);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
function defaultToConfig2(a, b) {
|
|
1463
|
+
if (!utils$1.isUndefined(b)) {
|
|
1464
|
+
return getMergedValue(void 0, b);
|
|
1465
|
+
} else if (!utils$1.isUndefined(a)) {
|
|
1466
|
+
return getMergedValue(void 0, a);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
function mergeDirectKeys(a, b, prop) {
|
|
1470
|
+
if (prop in config2) {
|
|
1471
|
+
return getMergedValue(a, b);
|
|
1472
|
+
} else if (prop in config1) {
|
|
1473
|
+
return getMergedValue(void 0, a);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
const mergeMap = {
|
|
1477
|
+
url: valueFromConfig2,
|
|
1478
|
+
method: valueFromConfig2,
|
|
1479
|
+
data: valueFromConfig2,
|
|
1480
|
+
baseURL: defaultToConfig2,
|
|
1481
|
+
transformRequest: defaultToConfig2,
|
|
1482
|
+
transformResponse: defaultToConfig2,
|
|
1483
|
+
paramsSerializer: defaultToConfig2,
|
|
1484
|
+
timeout: defaultToConfig2,
|
|
1485
|
+
timeoutMessage: defaultToConfig2,
|
|
1486
|
+
withCredentials: defaultToConfig2,
|
|
1487
|
+
withXSRFToken: defaultToConfig2,
|
|
1488
|
+
adapter: defaultToConfig2,
|
|
1489
|
+
responseType: defaultToConfig2,
|
|
1490
|
+
xsrfCookieName: defaultToConfig2,
|
|
1491
|
+
xsrfHeaderName: defaultToConfig2,
|
|
1492
|
+
onUploadProgress: defaultToConfig2,
|
|
1493
|
+
onDownloadProgress: defaultToConfig2,
|
|
1494
|
+
decompress: defaultToConfig2,
|
|
1495
|
+
maxContentLength: defaultToConfig2,
|
|
1496
|
+
maxBodyLength: defaultToConfig2,
|
|
1497
|
+
beforeRedirect: defaultToConfig2,
|
|
1498
|
+
transport: defaultToConfig2,
|
|
1499
|
+
httpAgent: defaultToConfig2,
|
|
1500
|
+
httpsAgent: defaultToConfig2,
|
|
1501
|
+
cancelToken: defaultToConfig2,
|
|
1502
|
+
socketPath: defaultToConfig2,
|
|
1503
|
+
responseEncoding: defaultToConfig2,
|
|
1504
|
+
validateStatus: mergeDirectKeys,
|
|
1505
|
+
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
1506
|
+
};
|
|
1507
|
+
utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
1508
|
+
const merge2 = mergeMap[prop] || mergeDeepProperties;
|
|
1509
|
+
const configValue = merge2(config1[prop], config2[prop], prop);
|
|
1510
|
+
utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config3[prop] = configValue);
|
|
1511
|
+
});
|
|
1512
|
+
return config3;
|
|
1513
|
+
}
|
|
1514
|
+
const resolveConfig = (config2) => {
|
|
1515
|
+
const newConfig = mergeConfig$1({}, config2);
|
|
1516
|
+
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
1517
|
+
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
1518
|
+
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config2.params, config2.paramsSerializer);
|
|
1519
|
+
if (auth) {
|
|
1520
|
+
headers.set(
|
|
1521
|
+
"Authorization",
|
|
1522
|
+
"Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
|
|
1523
|
+
);
|
|
1524
|
+
}
|
|
1525
|
+
if (utils$1.isFormData(data)) {
|
|
1526
|
+
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
1527
|
+
headers.setContentType(void 0);
|
|
1528
|
+
} else if (utils$1.isFunction(data.getHeaders)) {
|
|
1529
|
+
const formHeaders = data.getHeaders();
|
|
1530
|
+
const allowedHeaders = ["content-type", "content-length"];
|
|
1531
|
+
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
1532
|
+
if (allowedHeaders.includes(key.toLowerCase())) {
|
|
1533
|
+
headers.set(key, val);
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
if (platform.hasStandardBrowserEnv) {
|
|
1539
|
+
withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
1540
|
+
if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
|
|
1541
|
+
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
1542
|
+
if (xsrfValue) {
|
|
1543
|
+
headers.set(xsrfHeaderName, xsrfValue);
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
return newConfig;
|
|
1548
|
+
};
|
|
1549
|
+
const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
1550
|
+
const xhrAdapter = isXHRAdapterSupported && function(config2) {
|
|
1551
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
1552
|
+
const _config = resolveConfig(config2);
|
|
1553
|
+
let requestData = _config.data;
|
|
1554
|
+
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
1555
|
+
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
1556
|
+
let onCanceled;
|
|
1557
|
+
let uploadThrottled, downloadThrottled;
|
|
1558
|
+
let flushUpload, flushDownload;
|
|
1559
|
+
function done() {
|
|
1560
|
+
flushUpload && flushUpload();
|
|
1561
|
+
flushDownload && flushDownload();
|
|
1562
|
+
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
1563
|
+
_config.signal && _config.signal.removeEventListener("abort", onCanceled);
|
|
1564
|
+
}
|
|
1565
|
+
let request = new XMLHttpRequest();
|
|
1566
|
+
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
1567
|
+
request.timeout = _config.timeout;
|
|
1568
|
+
function onloadend() {
|
|
1569
|
+
if (!request) {
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
const responseHeaders = AxiosHeaders$1.from(
|
|
1573
|
+
"getAllResponseHeaders" in request && request.getAllResponseHeaders()
|
|
1574
|
+
);
|
|
1575
|
+
const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
|
|
1576
|
+
const response = {
|
|
1577
|
+
data: responseData,
|
|
1578
|
+
status: request.status,
|
|
1579
|
+
statusText: request.statusText,
|
|
1580
|
+
headers: responseHeaders,
|
|
1581
|
+
config: config2,
|
|
1582
|
+
request
|
|
1583
|
+
};
|
|
1584
|
+
settle(function _resolve(value) {
|
|
1585
|
+
resolve(value);
|
|
1586
|
+
done();
|
|
1587
|
+
}, function _reject(err) {
|
|
1588
|
+
reject(err);
|
|
1589
|
+
done();
|
|
1590
|
+
}, response);
|
|
1591
|
+
request = null;
|
|
1592
|
+
}
|
|
1593
|
+
if ("onloadend" in request) {
|
|
1594
|
+
request.onloadend = onloadend;
|
|
1595
|
+
} else {
|
|
1596
|
+
request.onreadystatechange = function handleLoad() {
|
|
1597
|
+
if (!request || request.readyState !== 4) {
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
|
|
1601
|
+
return;
|
|
1602
|
+
}
|
|
1603
|
+
setTimeout(onloadend);
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
request.onabort = function handleAbort() {
|
|
1607
|
+
if (!request) {
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
reject(new AxiosError$1("Request aborted", AxiosError$1.ECONNABORTED, config2, request));
|
|
1611
|
+
request = null;
|
|
1612
|
+
};
|
|
1613
|
+
request.onerror = function handleError(event) {
|
|
1614
|
+
const msg = event && event.message ? event.message : "Network Error";
|
|
1615
|
+
const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config2, request);
|
|
1616
|
+
err.event = event || null;
|
|
1617
|
+
reject(err);
|
|
1618
|
+
request = null;
|
|
1619
|
+
};
|
|
1620
|
+
request.ontimeout = function handleTimeout() {
|
|
1621
|
+
let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
|
|
1622
|
+
const transitional2 = _config.transitional || transitionalDefaults;
|
|
1623
|
+
if (_config.timeoutErrorMessage) {
|
|
1624
|
+
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
1625
|
+
}
|
|
1626
|
+
reject(new AxiosError$1(
|
|
1627
|
+
timeoutErrorMessage,
|
|
1628
|
+
transitional2.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
1629
|
+
config2,
|
|
1630
|
+
request
|
|
1631
|
+
));
|
|
1632
|
+
request = null;
|
|
1633
|
+
};
|
|
1634
|
+
requestData === void 0 && requestHeaders.setContentType(null);
|
|
1635
|
+
if ("setRequestHeader" in request) {
|
|
1636
|
+
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
1637
|
+
request.setRequestHeader(key, val);
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
1641
|
+
request.withCredentials = !!_config.withCredentials;
|
|
1642
|
+
}
|
|
1643
|
+
if (responseType && responseType !== "json") {
|
|
1644
|
+
request.responseType = _config.responseType;
|
|
1645
|
+
}
|
|
1646
|
+
if (onDownloadProgress) {
|
|
1647
|
+
[downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
|
|
1648
|
+
request.addEventListener("progress", downloadThrottled);
|
|
1649
|
+
}
|
|
1650
|
+
if (onUploadProgress && request.upload) {
|
|
1651
|
+
[uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
|
|
1652
|
+
request.upload.addEventListener("progress", uploadThrottled);
|
|
1653
|
+
request.upload.addEventListener("loadend", flushUpload);
|
|
1654
|
+
}
|
|
1655
|
+
if (_config.cancelToken || _config.signal) {
|
|
1656
|
+
onCanceled = (cancel) => {
|
|
1657
|
+
if (!request) {
|
|
1658
|
+
return;
|
|
1659
|
+
}
|
|
1660
|
+
reject(!cancel || cancel.type ? new CanceledError$1(null, config2, request) : cancel);
|
|
1661
|
+
request.abort();
|
|
1662
|
+
request = null;
|
|
1663
|
+
};
|
|
1664
|
+
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
1665
|
+
if (_config.signal) {
|
|
1666
|
+
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
const protocol = parseProtocol(_config.url);
|
|
1670
|
+
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
1671
|
+
reject(new AxiosError$1("Unsupported protocol " + protocol + ":", AxiosError$1.ERR_BAD_REQUEST, config2));
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
request.send(requestData || null);
|
|
1675
|
+
});
|
|
1676
|
+
};
|
|
1677
|
+
const composeSignals = (signals, timeout) => {
|
|
1678
|
+
const { length } = signals = signals ? signals.filter(Boolean) : [];
|
|
1679
|
+
if (timeout || length) {
|
|
1680
|
+
let controller2 = new AbortController();
|
|
1681
|
+
let aborted;
|
|
1682
|
+
const onabort = function(reason) {
|
|
1683
|
+
if (!aborted) {
|
|
1684
|
+
aborted = true;
|
|
1685
|
+
unsubscribe();
|
|
1686
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
1687
|
+
controller2.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
let timer = timeout && setTimeout(() => {
|
|
1691
|
+
timer = null;
|
|
1692
|
+
onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
1693
|
+
}, timeout);
|
|
1694
|
+
const unsubscribe = () => {
|
|
1695
|
+
if (signals) {
|
|
1696
|
+
timer && clearTimeout(timer);
|
|
1697
|
+
timer = null;
|
|
1698
|
+
signals.forEach((signal2) => {
|
|
1699
|
+
signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
|
|
1700
|
+
});
|
|
1701
|
+
signals = null;
|
|
1702
|
+
}
|
|
1703
|
+
};
|
|
1704
|
+
signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
|
|
1705
|
+
const { signal } = controller2;
|
|
1706
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
1707
|
+
return signal;
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
const streamChunk = function* (chunk, chunkSize) {
|
|
1711
|
+
let len = chunk.byteLength;
|
|
1712
|
+
if (len < chunkSize) {
|
|
1713
|
+
yield chunk;
|
|
1714
|
+
return;
|
|
1715
|
+
}
|
|
1716
|
+
let pos = 0;
|
|
1717
|
+
let end;
|
|
1718
|
+
while (pos < len) {
|
|
1719
|
+
end = pos + chunkSize;
|
|
1720
|
+
yield chunk.slice(pos, end);
|
|
1721
|
+
pos = end;
|
|
1722
|
+
}
|
|
1723
|
+
};
|
|
1724
|
+
const readBytes = async function* (iterable, chunkSize) {
|
|
1725
|
+
for await (const chunk of readStream(iterable)) {
|
|
1726
|
+
yield* streamChunk(chunk, chunkSize);
|
|
1727
|
+
}
|
|
1728
|
+
};
|
|
1729
|
+
const readStream = async function* (stream) {
|
|
1730
|
+
if (stream[Symbol.asyncIterator]) {
|
|
1731
|
+
yield* stream;
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
const reader = stream.getReader();
|
|
1735
|
+
try {
|
|
1736
|
+
for (; ; ) {
|
|
1737
|
+
const { done, value } = await reader.read();
|
|
1738
|
+
if (done) {
|
|
1739
|
+
break;
|
|
1740
|
+
}
|
|
1741
|
+
yield value;
|
|
1742
|
+
}
|
|
1743
|
+
} finally {
|
|
1744
|
+
await reader.cancel();
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
1748
|
+
const iterator2 = readBytes(stream, chunkSize);
|
|
1749
|
+
let bytes = 0;
|
|
1750
|
+
let done;
|
|
1751
|
+
let _onFinish = (e) => {
|
|
1752
|
+
if (!done) {
|
|
1753
|
+
done = true;
|
|
1754
|
+
onFinish && onFinish(e);
|
|
1755
|
+
}
|
|
1756
|
+
};
|
|
1757
|
+
return new ReadableStream({
|
|
1758
|
+
async pull(controller2) {
|
|
1759
|
+
try {
|
|
1760
|
+
const { done: done2, value } = await iterator2.next();
|
|
1761
|
+
if (done2) {
|
|
1762
|
+
_onFinish();
|
|
1763
|
+
controller2.close();
|
|
1764
|
+
return;
|
|
1765
|
+
}
|
|
1766
|
+
let len = value.byteLength;
|
|
1767
|
+
if (onProgress) {
|
|
1768
|
+
let loadedBytes = bytes += len;
|
|
1769
|
+
onProgress(loadedBytes);
|
|
1770
|
+
}
|
|
1771
|
+
controller2.enqueue(new Uint8Array(value));
|
|
1772
|
+
} catch (err) {
|
|
1773
|
+
_onFinish(err);
|
|
1774
|
+
throw err;
|
|
1775
|
+
}
|
|
1776
|
+
},
|
|
1777
|
+
cancel(reason) {
|
|
1778
|
+
_onFinish(reason);
|
|
1779
|
+
return iterator2.return();
|
|
1780
|
+
}
|
|
1781
|
+
}, {
|
|
1782
|
+
highWaterMark: 2
|
|
1783
|
+
});
|
|
1784
|
+
};
|
|
1785
|
+
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
1786
|
+
const { isFunction } = utils$1;
|
|
1787
|
+
const globalFetchAPI = (({ Request, Response }) => ({
|
|
1788
|
+
Request,
|
|
1789
|
+
Response
|
|
1790
|
+
}))(utils$1.global);
|
|
1791
|
+
const {
|
|
1792
|
+
ReadableStream: ReadableStream$1,
|
|
1793
|
+
TextEncoder
|
|
1794
|
+
} = utils$1.global;
|
|
1795
|
+
const test = (fn, ...args) => {
|
|
1796
|
+
try {
|
|
1797
|
+
return !!fn(...args);
|
|
1798
|
+
} catch (e) {
|
|
1799
|
+
return false;
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
const factory = (env) => {
|
|
1803
|
+
env = utils$1.merge.call({
|
|
1804
|
+
skipUndefined: true
|
|
1805
|
+
}, globalFetchAPI, env);
|
|
1806
|
+
const { fetch: envFetch, Request, Response } = env;
|
|
1807
|
+
const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === "function";
|
|
1808
|
+
const isRequestSupported = isFunction(Request);
|
|
1809
|
+
const isResponseSupported = isFunction(Response);
|
|
1810
|
+
if (!isFetchSupported) {
|
|
1811
|
+
return false;
|
|
1812
|
+
}
|
|
1813
|
+
const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
|
|
1814
|
+
const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
|
|
1815
|
+
const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
|
|
1816
|
+
let duplexAccessed = false;
|
|
1817
|
+
const hasContentType = new Request(platform.origin, {
|
|
1818
|
+
body: new ReadableStream$1(),
|
|
1819
|
+
method: "POST",
|
|
1820
|
+
get duplex() {
|
|
1821
|
+
duplexAccessed = true;
|
|
1822
|
+
return "half";
|
|
1823
|
+
}
|
|
1824
|
+
}).headers.has("Content-Type");
|
|
1825
|
+
return duplexAccessed && !hasContentType;
|
|
1826
|
+
});
|
|
1827
|
+
const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response("").body));
|
|
1828
|
+
const resolvers = {
|
|
1829
|
+
stream: supportsResponseStream && ((res) => res.body)
|
|
1830
|
+
};
|
|
1831
|
+
isFetchSupported && (() => {
|
|
1832
|
+
["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
|
|
1833
|
+
!resolvers[type] && (resolvers[type] = (res, config2) => {
|
|
1834
|
+
let method = res && res[type];
|
|
1835
|
+
if (method) {
|
|
1836
|
+
return method.call(res);
|
|
1837
|
+
}
|
|
1838
|
+
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config2);
|
|
1839
|
+
});
|
|
1840
|
+
});
|
|
1841
|
+
})();
|
|
1842
|
+
const getBodyLength = async (body) => {
|
|
1843
|
+
if (body == null) {
|
|
1844
|
+
return 0;
|
|
1845
|
+
}
|
|
1846
|
+
if (utils$1.isBlob(body)) {
|
|
1847
|
+
return body.size;
|
|
1848
|
+
}
|
|
1849
|
+
if (utils$1.isSpecCompliantForm(body)) {
|
|
1850
|
+
const _request = new Request(platform.origin, {
|
|
1851
|
+
method: "POST",
|
|
1852
|
+
body
|
|
1853
|
+
});
|
|
1854
|
+
return (await _request.arrayBuffer()).byteLength;
|
|
1855
|
+
}
|
|
1856
|
+
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
1857
|
+
return body.byteLength;
|
|
1858
|
+
}
|
|
1859
|
+
if (utils$1.isURLSearchParams(body)) {
|
|
1860
|
+
body = body + "";
|
|
1861
|
+
}
|
|
1862
|
+
if (utils$1.isString(body)) {
|
|
1863
|
+
return (await encodeText(body)).byteLength;
|
|
1864
|
+
}
|
|
1865
|
+
};
|
|
1866
|
+
const resolveBodyLength = async (headers, body) => {
|
|
1867
|
+
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
1868
|
+
return length == null ? getBodyLength(body) : length;
|
|
1869
|
+
};
|
|
1870
|
+
return async (config2) => {
|
|
1871
|
+
let {
|
|
1872
|
+
url,
|
|
1873
|
+
method,
|
|
1874
|
+
data,
|
|
1875
|
+
signal,
|
|
1876
|
+
cancelToken,
|
|
1877
|
+
timeout,
|
|
1878
|
+
onDownloadProgress,
|
|
1879
|
+
onUploadProgress,
|
|
1880
|
+
responseType,
|
|
1881
|
+
headers,
|
|
1882
|
+
withCredentials = "same-origin",
|
|
1883
|
+
fetchOptions
|
|
1884
|
+
} = resolveConfig(config2);
|
|
1885
|
+
let _fetch = envFetch || fetch;
|
|
1886
|
+
responseType = responseType ? (responseType + "").toLowerCase() : "text";
|
|
1887
|
+
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
|
|
1888
|
+
let request = null;
|
|
1889
|
+
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
1890
|
+
composedSignal.unsubscribe();
|
|
1891
|
+
});
|
|
1892
|
+
let requestContentLength;
|
|
1893
|
+
try {
|
|
1894
|
+
if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
|
|
1895
|
+
let _request = new Request(url, {
|
|
1896
|
+
method: "POST",
|
|
1897
|
+
body: data,
|
|
1898
|
+
duplex: "half"
|
|
1899
|
+
});
|
|
1900
|
+
let contentTypeHeader;
|
|
1901
|
+
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
|
|
1902
|
+
headers.setContentType(contentTypeHeader);
|
|
1903
|
+
}
|
|
1904
|
+
if (_request.body) {
|
|
1905
|
+
const [onProgress, flush] = progressEventDecorator(
|
|
1906
|
+
requestContentLength,
|
|
1907
|
+
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
1908
|
+
);
|
|
1909
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
if (!utils$1.isString(withCredentials)) {
|
|
1913
|
+
withCredentials = withCredentials ? "include" : "omit";
|
|
1914
|
+
}
|
|
1915
|
+
const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
|
|
1916
|
+
const resolvedOptions = {
|
|
1917
|
+
...fetchOptions,
|
|
1918
|
+
signal: composedSignal,
|
|
1919
|
+
method: method.toUpperCase(),
|
|
1920
|
+
headers: headers.normalize().toJSON(),
|
|
1921
|
+
body: data,
|
|
1922
|
+
duplex: "half",
|
|
1923
|
+
credentials: isCredentialsSupported ? withCredentials : void 0
|
|
1924
|
+
};
|
|
1925
|
+
request = isRequestSupported && new Request(url, resolvedOptions);
|
|
1926
|
+
let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
|
|
1927
|
+
const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
|
|
1928
|
+
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
1929
|
+
const options2 = {};
|
|
1930
|
+
["status", "statusText", "headers"].forEach((prop) => {
|
|
1931
|
+
options2[prop] = response[prop];
|
|
1932
|
+
});
|
|
1933
|
+
const responseContentLength = utils$1.toFiniteNumber(response.headers.get("content-length"));
|
|
1934
|
+
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
1935
|
+
responseContentLength,
|
|
1936
|
+
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
1937
|
+
) || [];
|
|
1938
|
+
response = new Response(
|
|
1939
|
+
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
1940
|
+
flush && flush();
|
|
1941
|
+
unsubscribe && unsubscribe();
|
|
1942
|
+
}),
|
|
1943
|
+
options2
|
|
1944
|
+
);
|
|
1945
|
+
}
|
|
1946
|
+
responseType = responseType || "text";
|
|
1947
|
+
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config2);
|
|
1948
|
+
!isStreamResponse && unsubscribe && unsubscribe();
|
|
1949
|
+
return await new Promise((resolve, reject) => {
|
|
1950
|
+
settle(resolve, reject, {
|
|
1951
|
+
data: responseData,
|
|
1952
|
+
headers: AxiosHeaders$1.from(response.headers),
|
|
1953
|
+
status: response.status,
|
|
1954
|
+
statusText: response.statusText,
|
|
1955
|
+
config: config2,
|
|
1956
|
+
request
|
|
1957
|
+
});
|
|
1958
|
+
});
|
|
1959
|
+
} catch (err) {
|
|
1960
|
+
unsubscribe && unsubscribe();
|
|
1961
|
+
if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
|
|
1962
|
+
throw Object.assign(
|
|
1963
|
+
new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config2, request),
|
|
1964
|
+
{
|
|
1965
|
+
cause: err.cause || err
|
|
1966
|
+
}
|
|
1967
|
+
);
|
|
1968
|
+
}
|
|
1969
|
+
throw AxiosError$1.from(err, err && err.code, config2, request);
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
};
|
|
1973
|
+
const seedCache = /* @__PURE__ */ new Map();
|
|
1974
|
+
const getFetch = (config2) => {
|
|
1975
|
+
let env = config2 ? config2.env : {};
|
|
1976
|
+
const { fetch: fetch2, Request, Response } = env;
|
|
1977
|
+
const seeds = [
|
|
1978
|
+
Request,
|
|
1979
|
+
Response,
|
|
1980
|
+
fetch2
|
|
1981
|
+
];
|
|
1982
|
+
let len = seeds.length, i = len, seed, target, map = seedCache;
|
|
1983
|
+
while (i--) {
|
|
1984
|
+
seed = seeds[i];
|
|
1985
|
+
target = map.get(seed);
|
|
1986
|
+
target === void 0 && map.set(seed, target = i ? /* @__PURE__ */ new Map() : factory(env));
|
|
1987
|
+
map = target;
|
|
1988
|
+
}
|
|
1989
|
+
return target;
|
|
1990
|
+
};
|
|
1991
|
+
getFetch();
|
|
1992
|
+
const knownAdapters = {
|
|
1993
|
+
http: httpAdapter,
|
|
1994
|
+
xhr: xhrAdapter,
|
|
1995
|
+
fetch: {
|
|
1996
|
+
get: getFetch
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
2000
|
+
if (fn) {
|
|
2001
|
+
try {
|
|
2002
|
+
Object.defineProperty(fn, "name", { value });
|
|
2003
|
+
} catch (e) {
|
|
2004
|
+
}
|
|
2005
|
+
Object.defineProperty(fn, "adapterName", { value });
|
|
2006
|
+
}
|
|
2007
|
+
});
|
|
2008
|
+
const renderReason = (reason) => `- ${reason}`;
|
|
2009
|
+
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
2010
|
+
const adapters = {
|
|
2011
|
+
getAdapter: (adapters2, config2) => {
|
|
2012
|
+
adapters2 = utils$1.isArray(adapters2) ? adapters2 : [adapters2];
|
|
2013
|
+
const { length } = adapters2;
|
|
2014
|
+
let nameOrAdapter;
|
|
2015
|
+
let adapter;
|
|
2016
|
+
const rejectedReasons = {};
|
|
2017
|
+
for (let i = 0; i < length; i++) {
|
|
2018
|
+
nameOrAdapter = adapters2[i];
|
|
2019
|
+
let id;
|
|
2020
|
+
adapter = nameOrAdapter;
|
|
2021
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
|
2022
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
2023
|
+
if (adapter === void 0) {
|
|
2024
|
+
throw new AxiosError$1(`Unknown adapter '${id}'`);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config2)))) {
|
|
2028
|
+
break;
|
|
2029
|
+
}
|
|
2030
|
+
rejectedReasons[id || "#" + i] = adapter;
|
|
2031
|
+
}
|
|
2032
|
+
if (!adapter) {
|
|
2033
|
+
const reasons = Object.entries(rejectedReasons).map(
|
|
2034
|
+
([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
|
|
2035
|
+
);
|
|
2036
|
+
let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
|
|
2037
|
+
throw new AxiosError$1(
|
|
2038
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
|
2039
|
+
"ERR_NOT_SUPPORT"
|
|
2040
|
+
);
|
|
2041
|
+
}
|
|
2042
|
+
return adapter;
|
|
2043
|
+
},
|
|
2044
|
+
adapters: knownAdapters
|
|
2045
|
+
};
|
|
2046
|
+
function throwIfCancellationRequested(config2) {
|
|
2047
|
+
if (config2.cancelToken) {
|
|
2048
|
+
config2.cancelToken.throwIfRequested();
|
|
2049
|
+
}
|
|
2050
|
+
if (config2.signal && config2.signal.aborted) {
|
|
2051
|
+
throw new CanceledError$1(null, config2);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
function dispatchRequest(config2) {
|
|
2055
|
+
throwIfCancellationRequested(config2);
|
|
2056
|
+
config2.headers = AxiosHeaders$1.from(config2.headers);
|
|
2057
|
+
config2.data = transformData.call(
|
|
2058
|
+
config2,
|
|
2059
|
+
config2.transformRequest
|
|
2060
|
+
);
|
|
2061
|
+
if (["post", "put", "patch"].indexOf(config2.method) !== -1) {
|
|
2062
|
+
config2.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
2063
|
+
}
|
|
2064
|
+
const adapter = adapters.getAdapter(config2.adapter || defaults.adapter, config2);
|
|
2065
|
+
return adapter(config2).then(function onAdapterResolution(response) {
|
|
2066
|
+
throwIfCancellationRequested(config2);
|
|
2067
|
+
response.data = transformData.call(
|
|
2068
|
+
config2,
|
|
2069
|
+
config2.transformResponse,
|
|
2070
|
+
response
|
|
2071
|
+
);
|
|
2072
|
+
response.headers = AxiosHeaders$1.from(response.headers);
|
|
2073
|
+
return response;
|
|
2074
|
+
}, function onAdapterRejection(reason) {
|
|
2075
|
+
if (!isCancel$1(reason)) {
|
|
2076
|
+
throwIfCancellationRequested(config2);
|
|
2077
|
+
if (reason && reason.response) {
|
|
2078
|
+
reason.response.data = transformData.call(
|
|
2079
|
+
config2,
|
|
2080
|
+
config2.transformResponse,
|
|
2081
|
+
reason.response
|
|
2082
|
+
);
|
|
2083
|
+
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
return Promise.reject(reason);
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
const VERSION$1 = "1.12.2";
|
|
2090
|
+
const validators$1 = {};
|
|
2091
|
+
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
|
|
2092
|
+
validators$1[type] = function validator2(thing) {
|
|
2093
|
+
return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
|
|
2094
|
+
};
|
|
2095
|
+
});
|
|
2096
|
+
const deprecatedWarnings = {};
|
|
2097
|
+
validators$1.transitional = function transitional(validator2, version, message) {
|
|
2098
|
+
function formatMessage(opt, desc) {
|
|
2099
|
+
return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
2100
|
+
}
|
|
2101
|
+
return (value, opt, opts) => {
|
|
2102
|
+
if (validator2 === false) {
|
|
2103
|
+
throw new AxiosError$1(
|
|
2104
|
+
formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
|
|
2105
|
+
AxiosError$1.ERR_DEPRECATED
|
|
2106
|
+
);
|
|
2107
|
+
}
|
|
2108
|
+
if (version && !deprecatedWarnings[opt]) {
|
|
2109
|
+
deprecatedWarnings[opt] = true;
|
|
2110
|
+
console.warn(
|
|
2111
|
+
formatMessage(
|
|
2112
|
+
opt,
|
|
2113
|
+
" has been deprecated since v" + version + " and will be removed in the near future"
|
|
2114
|
+
)
|
|
2115
|
+
);
|
|
2116
|
+
}
|
|
2117
|
+
return validator2 ? validator2(value, opt, opts) : true;
|
|
2118
|
+
};
|
|
2119
|
+
};
|
|
2120
|
+
validators$1.spelling = function spelling(correctSpelling) {
|
|
2121
|
+
return (value, opt) => {
|
|
2122
|
+
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
2123
|
+
return true;
|
|
2124
|
+
};
|
|
2125
|
+
};
|
|
2126
|
+
function assertOptions(options2, schema2, allowUnknown) {
|
|
2127
|
+
if (typeof options2 !== "object") {
|
|
2128
|
+
throw new AxiosError$1("options must be an object", AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
2129
|
+
}
|
|
2130
|
+
const keys = Object.keys(options2);
|
|
2131
|
+
let i = keys.length;
|
|
2132
|
+
while (i-- > 0) {
|
|
2133
|
+
const opt = keys[i];
|
|
2134
|
+
const validator2 = schema2[opt];
|
|
2135
|
+
if (validator2) {
|
|
2136
|
+
const value = options2[opt];
|
|
2137
|
+
const result = value === void 0 || validator2(value, opt, options2);
|
|
2138
|
+
if (result !== true) {
|
|
2139
|
+
throw new AxiosError$1("option " + opt + " must be " + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
2140
|
+
}
|
|
2141
|
+
continue;
|
|
2142
|
+
}
|
|
2143
|
+
if (allowUnknown !== true) {
|
|
2144
|
+
throw new AxiosError$1("Unknown option " + opt, AxiosError$1.ERR_BAD_OPTION);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
const validator = {
|
|
2149
|
+
assertOptions,
|
|
2150
|
+
validators: validators$1
|
|
2151
|
+
};
|
|
2152
|
+
const validators = validator.validators;
|
|
2153
|
+
let Axios$1 = class Axios {
|
|
2154
|
+
constructor(instanceConfig) {
|
|
2155
|
+
this.defaults = instanceConfig || {};
|
|
2156
|
+
this.interceptors = {
|
|
2157
|
+
request: new InterceptorManager(),
|
|
2158
|
+
response: new InterceptorManager()
|
|
2159
|
+
};
|
|
2160
|
+
}
|
|
2161
|
+
/**
|
|
2162
|
+
* Dispatch a request
|
|
2163
|
+
*
|
|
2164
|
+
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|
2165
|
+
* @param {?Object} config
|
|
2166
|
+
*
|
|
2167
|
+
* @returns {Promise} The Promise to be fulfilled
|
|
2168
|
+
*/
|
|
2169
|
+
async request(configOrUrl, config2) {
|
|
2170
|
+
try {
|
|
2171
|
+
return await this._request(configOrUrl, config2);
|
|
2172
|
+
} catch (err) {
|
|
2173
|
+
if (err instanceof Error) {
|
|
2174
|
+
let dummy = {};
|
|
2175
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
|
|
2176
|
+
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
|
|
2177
|
+
try {
|
|
2178
|
+
if (!err.stack) {
|
|
2179
|
+
err.stack = stack;
|
|
2180
|
+
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
|
|
2181
|
+
err.stack += "\n" + stack;
|
|
2182
|
+
}
|
|
2183
|
+
} catch (e) {
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
throw err;
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
_request(configOrUrl, config2) {
|
|
2190
|
+
if (typeof configOrUrl === "string") {
|
|
2191
|
+
config2 = config2 || {};
|
|
2192
|
+
config2.url = configOrUrl;
|
|
2193
|
+
} else {
|
|
2194
|
+
config2 = configOrUrl || {};
|
|
2195
|
+
}
|
|
2196
|
+
config2 = mergeConfig$1(this.defaults, config2);
|
|
2197
|
+
const { transitional: transitional2, paramsSerializer, headers } = config2;
|
|
2198
|
+
if (transitional2 !== void 0) {
|
|
2199
|
+
validator.assertOptions(transitional2, {
|
|
2200
|
+
silentJSONParsing: validators.transitional(validators.boolean),
|
|
2201
|
+
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
2202
|
+
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
2203
|
+
}, false);
|
|
2204
|
+
}
|
|
2205
|
+
if (paramsSerializer != null) {
|
|
2206
|
+
if (utils$1.isFunction(paramsSerializer)) {
|
|
2207
|
+
config2.paramsSerializer = {
|
|
2208
|
+
serialize: paramsSerializer
|
|
2209
|
+
};
|
|
2210
|
+
} else {
|
|
2211
|
+
validator.assertOptions(paramsSerializer, {
|
|
2212
|
+
encode: validators.function,
|
|
2213
|
+
serialize: validators.function
|
|
2214
|
+
}, true);
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
if (config2.allowAbsoluteUrls !== void 0) ;
|
|
2218
|
+
else if (this.defaults.allowAbsoluteUrls !== void 0) {
|
|
2219
|
+
config2.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
2220
|
+
} else {
|
|
2221
|
+
config2.allowAbsoluteUrls = true;
|
|
2222
|
+
}
|
|
2223
|
+
validator.assertOptions(config2, {
|
|
2224
|
+
baseUrl: validators.spelling("baseURL"),
|
|
2225
|
+
withXsrfToken: validators.spelling("withXSRFToken")
|
|
2226
|
+
}, true);
|
|
2227
|
+
config2.method = (config2.method || this.defaults.method || "get").toLowerCase();
|
|
2228
|
+
let contextHeaders = headers && utils$1.merge(
|
|
2229
|
+
headers.common,
|
|
2230
|
+
headers[config2.method]
|
|
2231
|
+
);
|
|
2232
|
+
headers && utils$1.forEach(
|
|
2233
|
+
["delete", "get", "head", "post", "put", "patch", "common"],
|
|
2234
|
+
(method) => {
|
|
2235
|
+
delete headers[method];
|
|
2236
|
+
}
|
|
2237
|
+
);
|
|
2238
|
+
config2.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
|
2239
|
+
const requestInterceptorChain = [];
|
|
2240
|
+
let synchronousRequestInterceptors = true;
|
|
2241
|
+
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
2242
|
+
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config2) === false) {
|
|
2243
|
+
return;
|
|
2244
|
+
}
|
|
2245
|
+
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
2246
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
2247
|
+
});
|
|
2248
|
+
const responseInterceptorChain = [];
|
|
2249
|
+
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
2250
|
+
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
2251
|
+
});
|
|
2252
|
+
let promise;
|
|
2253
|
+
let i = 0;
|
|
2254
|
+
let len;
|
|
2255
|
+
if (!synchronousRequestInterceptors) {
|
|
2256
|
+
const chain = [dispatchRequest.bind(this), void 0];
|
|
2257
|
+
chain.unshift(...requestInterceptorChain);
|
|
2258
|
+
chain.push(...responseInterceptorChain);
|
|
2259
|
+
len = chain.length;
|
|
2260
|
+
promise = Promise.resolve(config2);
|
|
2261
|
+
while (i < len) {
|
|
2262
|
+
promise = promise.then(chain[i++], chain[i++]);
|
|
2263
|
+
}
|
|
2264
|
+
return promise;
|
|
2265
|
+
}
|
|
2266
|
+
len = requestInterceptorChain.length;
|
|
2267
|
+
let newConfig = config2;
|
|
2268
|
+
while (i < len) {
|
|
2269
|
+
const onFulfilled = requestInterceptorChain[i++];
|
|
2270
|
+
const onRejected = requestInterceptorChain[i++];
|
|
2271
|
+
try {
|
|
2272
|
+
newConfig = onFulfilled(newConfig);
|
|
2273
|
+
} catch (error) {
|
|
2274
|
+
onRejected.call(this, error);
|
|
2275
|
+
break;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
try {
|
|
2279
|
+
promise = dispatchRequest.call(this, newConfig);
|
|
2280
|
+
} catch (error) {
|
|
2281
|
+
return Promise.reject(error);
|
|
2282
|
+
}
|
|
2283
|
+
i = 0;
|
|
2284
|
+
len = responseInterceptorChain.length;
|
|
2285
|
+
while (i < len) {
|
|
2286
|
+
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
|
2287
|
+
}
|
|
2288
|
+
return promise;
|
|
2289
|
+
}
|
|
2290
|
+
getUri(config2) {
|
|
2291
|
+
config2 = mergeConfig$1(this.defaults, config2);
|
|
2292
|
+
const fullPath = buildFullPath(config2.baseURL, config2.url, config2.allowAbsoluteUrls);
|
|
2293
|
+
return buildURL(fullPath, config2.params, config2.paramsSerializer);
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2296
|
+
utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
|
|
2297
|
+
Axios$1.prototype[method] = function(url, config2) {
|
|
2298
|
+
return this.request(mergeConfig$1(config2 || {}, {
|
|
2299
|
+
method,
|
|
2300
|
+
url,
|
|
2301
|
+
data: (config2 || {}).data
|
|
2302
|
+
}));
|
|
2303
|
+
};
|
|
2304
|
+
});
|
|
2305
|
+
utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
2306
|
+
function generateHTTPMethod(isForm) {
|
|
2307
|
+
return function httpMethod(url, data, config2) {
|
|
2308
|
+
return this.request(mergeConfig$1(config2 || {}, {
|
|
2309
|
+
method,
|
|
2310
|
+
headers: isForm ? {
|
|
2311
|
+
"Content-Type": "multipart/form-data"
|
|
2312
|
+
} : {},
|
|
2313
|
+
url,
|
|
2314
|
+
data
|
|
2315
|
+
}));
|
|
2316
|
+
};
|
|
2317
|
+
}
|
|
2318
|
+
Axios$1.prototype[method] = generateHTTPMethod();
|
|
2319
|
+
Axios$1.prototype[method + "Form"] = generateHTTPMethod(true);
|
|
2320
|
+
});
|
|
2321
|
+
let CancelToken$1 = class CancelToken {
|
|
2322
|
+
constructor(executor) {
|
|
2323
|
+
if (typeof executor !== "function") {
|
|
2324
|
+
throw new TypeError("executor must be a function.");
|
|
2325
|
+
}
|
|
2326
|
+
let resolvePromise;
|
|
2327
|
+
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
2328
|
+
resolvePromise = resolve;
|
|
2329
|
+
});
|
|
2330
|
+
const token = this;
|
|
2331
|
+
this.promise.then((cancel) => {
|
|
2332
|
+
if (!token._listeners) return;
|
|
2333
|
+
let i = token._listeners.length;
|
|
2334
|
+
while (i-- > 0) {
|
|
2335
|
+
token._listeners[i](cancel);
|
|
2336
|
+
}
|
|
2337
|
+
token._listeners = null;
|
|
2338
|
+
});
|
|
2339
|
+
this.promise.then = (onfulfilled) => {
|
|
2340
|
+
let _resolve;
|
|
2341
|
+
const promise = new Promise((resolve) => {
|
|
2342
|
+
token.subscribe(resolve);
|
|
2343
|
+
_resolve = resolve;
|
|
2344
|
+
}).then(onfulfilled);
|
|
2345
|
+
promise.cancel = function reject() {
|
|
2346
|
+
token.unsubscribe(_resolve);
|
|
2347
|
+
};
|
|
2348
|
+
return promise;
|
|
2349
|
+
};
|
|
2350
|
+
executor(function cancel(message, config2, request) {
|
|
2351
|
+
if (token.reason) {
|
|
2352
|
+
return;
|
|
2353
|
+
}
|
|
2354
|
+
token.reason = new CanceledError$1(message, config2, request);
|
|
2355
|
+
resolvePromise(token.reason);
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2358
|
+
/**
|
|
2359
|
+
* Throws a `CanceledError` if cancellation has been requested.
|
|
2360
|
+
*/
|
|
2361
|
+
throwIfRequested() {
|
|
2362
|
+
if (this.reason) {
|
|
2363
|
+
throw this.reason;
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
/**
|
|
2367
|
+
* Subscribe to the cancel signal
|
|
2368
|
+
*/
|
|
2369
|
+
subscribe(listener) {
|
|
2370
|
+
if (this.reason) {
|
|
2371
|
+
listener(this.reason);
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2374
|
+
if (this._listeners) {
|
|
2375
|
+
this._listeners.push(listener);
|
|
2376
|
+
} else {
|
|
2377
|
+
this._listeners = [listener];
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
/**
|
|
2381
|
+
* Unsubscribe from the cancel signal
|
|
2382
|
+
*/
|
|
2383
|
+
unsubscribe(listener) {
|
|
2384
|
+
if (!this._listeners) {
|
|
2385
|
+
return;
|
|
2386
|
+
}
|
|
2387
|
+
const index2 = this._listeners.indexOf(listener);
|
|
2388
|
+
if (index2 !== -1) {
|
|
2389
|
+
this._listeners.splice(index2, 1);
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
toAbortSignal() {
|
|
2393
|
+
const controller2 = new AbortController();
|
|
2394
|
+
const abort = (err) => {
|
|
2395
|
+
controller2.abort(err);
|
|
2396
|
+
};
|
|
2397
|
+
this.subscribe(abort);
|
|
2398
|
+
controller2.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
2399
|
+
return controller2.signal;
|
|
2400
|
+
}
|
|
2401
|
+
/**
|
|
2402
|
+
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
2403
|
+
* cancels the `CancelToken`.
|
|
2404
|
+
*/
|
|
2405
|
+
static source() {
|
|
2406
|
+
let cancel;
|
|
2407
|
+
const token = new CancelToken(function executor(c) {
|
|
2408
|
+
cancel = c;
|
|
2409
|
+
});
|
|
2410
|
+
return {
|
|
2411
|
+
token,
|
|
2412
|
+
cancel
|
|
2413
|
+
};
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2416
|
+
function spread$1(callback) {
|
|
2417
|
+
return function wrap(arr) {
|
|
2418
|
+
return callback.apply(null, arr);
|
|
2419
|
+
};
|
|
2420
|
+
}
|
|
2421
|
+
function isAxiosError$1(payload) {
|
|
2422
|
+
return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|
2423
|
+
}
|
|
2424
|
+
const HttpStatusCode$1 = {
|
|
2425
|
+
Continue: 100,
|
|
2426
|
+
SwitchingProtocols: 101,
|
|
2427
|
+
Processing: 102,
|
|
2428
|
+
EarlyHints: 103,
|
|
2429
|
+
Ok: 200,
|
|
2430
|
+
Created: 201,
|
|
2431
|
+
Accepted: 202,
|
|
2432
|
+
NonAuthoritativeInformation: 203,
|
|
2433
|
+
NoContent: 204,
|
|
2434
|
+
ResetContent: 205,
|
|
2435
|
+
PartialContent: 206,
|
|
2436
|
+
MultiStatus: 207,
|
|
2437
|
+
AlreadyReported: 208,
|
|
2438
|
+
ImUsed: 226,
|
|
2439
|
+
MultipleChoices: 300,
|
|
2440
|
+
MovedPermanently: 301,
|
|
2441
|
+
Found: 302,
|
|
2442
|
+
SeeOther: 303,
|
|
2443
|
+
NotModified: 304,
|
|
2444
|
+
UseProxy: 305,
|
|
2445
|
+
Unused: 306,
|
|
2446
|
+
TemporaryRedirect: 307,
|
|
2447
|
+
PermanentRedirect: 308,
|
|
2448
|
+
BadRequest: 400,
|
|
2449
|
+
Unauthorized: 401,
|
|
2450
|
+
PaymentRequired: 402,
|
|
2451
|
+
Forbidden: 403,
|
|
2452
|
+
NotFound: 404,
|
|
2453
|
+
MethodNotAllowed: 405,
|
|
2454
|
+
NotAcceptable: 406,
|
|
2455
|
+
ProxyAuthenticationRequired: 407,
|
|
2456
|
+
RequestTimeout: 408,
|
|
2457
|
+
Conflict: 409,
|
|
2458
|
+
Gone: 410,
|
|
2459
|
+
LengthRequired: 411,
|
|
2460
|
+
PreconditionFailed: 412,
|
|
2461
|
+
PayloadTooLarge: 413,
|
|
2462
|
+
UriTooLong: 414,
|
|
2463
|
+
UnsupportedMediaType: 415,
|
|
2464
|
+
RangeNotSatisfiable: 416,
|
|
2465
|
+
ExpectationFailed: 417,
|
|
2466
|
+
ImATeapot: 418,
|
|
2467
|
+
MisdirectedRequest: 421,
|
|
2468
|
+
UnprocessableEntity: 422,
|
|
2469
|
+
Locked: 423,
|
|
2470
|
+
FailedDependency: 424,
|
|
2471
|
+
TooEarly: 425,
|
|
2472
|
+
UpgradeRequired: 426,
|
|
2473
|
+
PreconditionRequired: 428,
|
|
2474
|
+
TooManyRequests: 429,
|
|
2475
|
+
RequestHeaderFieldsTooLarge: 431,
|
|
2476
|
+
UnavailableForLegalReasons: 451,
|
|
2477
|
+
InternalServerError: 500,
|
|
2478
|
+
NotImplemented: 501,
|
|
2479
|
+
BadGateway: 502,
|
|
2480
|
+
ServiceUnavailable: 503,
|
|
2481
|
+
GatewayTimeout: 504,
|
|
2482
|
+
HttpVersionNotSupported: 505,
|
|
2483
|
+
VariantAlsoNegotiates: 506,
|
|
2484
|
+
InsufficientStorage: 507,
|
|
2485
|
+
LoopDetected: 508,
|
|
2486
|
+
NotExtended: 510,
|
|
2487
|
+
NetworkAuthenticationRequired: 511
|
|
2488
|
+
};
|
|
2489
|
+
Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
|
|
2490
|
+
HttpStatusCode$1[value] = key;
|
|
2491
|
+
});
|
|
2492
|
+
function createInstance(defaultConfig) {
|
|
2493
|
+
const context = new Axios$1(defaultConfig);
|
|
2494
|
+
const instance = bind(Axios$1.prototype.request, context);
|
|
2495
|
+
utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
|
|
2496
|
+
utils$1.extend(instance, context, null, { allOwnKeys: true });
|
|
2497
|
+
instance.create = function create(instanceConfig) {
|
|
2498
|
+
return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
|
|
2499
|
+
};
|
|
2500
|
+
return instance;
|
|
2501
|
+
}
|
|
2502
|
+
const axios = createInstance(defaults);
|
|
2503
|
+
axios.Axios = Axios$1;
|
|
2504
|
+
axios.CanceledError = CanceledError$1;
|
|
2505
|
+
axios.CancelToken = CancelToken$1;
|
|
2506
|
+
axios.isCancel = isCancel$1;
|
|
2507
|
+
axios.VERSION = VERSION$1;
|
|
2508
|
+
axios.toFormData = toFormData$1;
|
|
2509
|
+
axios.AxiosError = AxiosError$1;
|
|
2510
|
+
axios.Cancel = axios.CanceledError;
|
|
2511
|
+
axios.all = function all(promises) {
|
|
2512
|
+
return Promise.all(promises);
|
|
2513
|
+
};
|
|
2514
|
+
axios.spread = spread$1;
|
|
2515
|
+
axios.isAxiosError = isAxiosError$1;
|
|
2516
|
+
axios.mergeConfig = mergeConfig$1;
|
|
2517
|
+
axios.AxiosHeaders = AxiosHeaders$1;
|
|
2518
|
+
axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
2519
|
+
axios.getAdapter = adapters.getAdapter;
|
|
2520
|
+
axios.HttpStatusCode = HttpStatusCode$1;
|
|
2521
|
+
axios.default = axios;
|
|
2522
|
+
const {
|
|
2523
|
+
Axios: Axios2,
|
|
2524
|
+
AxiosError,
|
|
2525
|
+
CanceledError,
|
|
2526
|
+
isCancel,
|
|
2527
|
+
CancelToken: CancelToken2,
|
|
2528
|
+
VERSION,
|
|
2529
|
+
all: all2,
|
|
2530
|
+
Cancel,
|
|
2531
|
+
isAxiosError,
|
|
2532
|
+
spread,
|
|
2533
|
+
toFormData,
|
|
2534
|
+
AxiosHeaders: AxiosHeaders2,
|
|
2535
|
+
HttpStatusCode,
|
|
2536
|
+
formToJSON,
|
|
2537
|
+
getAdapter,
|
|
2538
|
+
mergeConfig
|
|
2539
|
+
} = axios;
|
|
2540
|
+
async function validateBaseDomain(url, isDev) {
|
|
2541
|
+
try {
|
|
2542
|
+
if (!url) return { valid: true };
|
|
2543
|
+
let normalized = url.trim().toLowerCase();
|
|
2544
|
+
if (!normalized.startsWith("http://") && !normalized.startsWith("https://")) {
|
|
2545
|
+
normalized = "https://" + normalized;
|
|
2546
|
+
}
|
|
2547
|
+
normalized = normalized.replace(/\/+$/, "");
|
|
2548
|
+
const parsed = new URL(normalized);
|
|
2549
|
+
if (isDev) {
|
|
2550
|
+
return { valid: true };
|
|
2551
|
+
}
|
|
2552
|
+
await dns.lookup(parsed.hostname);
|
|
2553
|
+
await axios.get(parsed.origin, {
|
|
2554
|
+
timeout: 2e3,
|
|
2555
|
+
validateStatus: () => true
|
|
2556
|
+
});
|
|
2557
|
+
return { valid: true };
|
|
2558
|
+
} catch {
|
|
2559
|
+
return {
|
|
2560
|
+
valid: false,
|
|
2561
|
+
message: "Base domain is invalid, DNS failed, or site not reachable."
|
|
2562
|
+
};
|
|
2563
|
+
}
|
|
2564
|
+
}
|
|
76
2565
|
const config$1 = ({ strapi }) => ({
|
|
77
2566
|
async index(ctx) {
|
|
78
2567
|
const settings = await strapi.plugin("faqchatbot").service("config").getConfig();
|
|
@@ -90,6 +2579,13 @@ const config$1 = ({ strapi }) => ({
|
|
|
90
2579
|
},
|
|
91
2580
|
async update(ctx) {
|
|
92
2581
|
const settings = ctx.request.body;
|
|
2582
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
2583
|
+
const check = await validateBaseDomain(settings.baseDomain, isDev);
|
|
2584
|
+
if (!check.valid) {
|
|
2585
|
+
ctx.status = 400;
|
|
2586
|
+
ctx.body = { error: check.message };
|
|
2587
|
+
return;
|
|
2588
|
+
}
|
|
93
2589
|
const data = await strapi.plugin("faqchatbot").service("config").setConfig(settings);
|
|
94
2590
|
ctx.body = data;
|
|
95
2591
|
}
|
|
@@ -128,6 +2624,15 @@ async function getInstructions(strapi) {
|
|
|
128
2624
|
response: settings?.responseInstructions || ""
|
|
129
2625
|
};
|
|
130
2626
|
}
|
|
2627
|
+
async function getCardStyles(strapi) {
|
|
2628
|
+
const pluginStore = strapi.store({
|
|
2629
|
+
environment: null,
|
|
2630
|
+
type: "plugin",
|
|
2631
|
+
name: "faqchatbot"
|
|
2632
|
+
});
|
|
2633
|
+
const settings = await pluginStore.get({ key: "settings" });
|
|
2634
|
+
return settings?.cardStyles || {};
|
|
2635
|
+
}
|
|
131
2636
|
async function getActiveCollections(strapi) {
|
|
132
2637
|
try {
|
|
133
2638
|
const pluginStore = strapi.store({
|
|
@@ -139,10 +2644,9 @@ async function getActiveCollections(strapi) {
|
|
|
139
2644
|
if (!settings) return [];
|
|
140
2645
|
const activeList = [];
|
|
141
2646
|
for (const item of settings) {
|
|
142
|
-
const ignored = ["faqitem", "item"];
|
|
143
|
-
const name = item.name.toLowerCase();
|
|
144
2647
|
const hasEnabledFields = item.fields?.some((f) => f.enabled);
|
|
145
|
-
if (!hasEnabledFields
|
|
2648
|
+
if (!hasEnabledFields) {
|
|
2649
|
+
console.log(` - Skipping '${item.name}' (no enabled fields)`);
|
|
146
2650
|
continue;
|
|
147
2651
|
}
|
|
148
2652
|
const uid = `api::${item.name}.${item.name}`;
|
|
@@ -151,9 +2655,9 @@ async function getActiveCollections(strapi) {
|
|
|
151
2655
|
console.warn(` [WARNING] Content type not found for UID: ${uid}`);
|
|
152
2656
|
continue;
|
|
153
2657
|
}
|
|
154
|
-
const
|
|
155
|
-
const attr = contentType.attributes[
|
|
156
|
-
return [
|
|
2658
|
+
const enabledFields = item.fields?.filter((f) => f.enabled)?.map((f) => f.name)?.filter((fieldName) => {
|
|
2659
|
+
const attr = contentType.attributes[fieldName];
|
|
2660
|
+
return attr && [
|
|
157
2661
|
"string",
|
|
158
2662
|
"text",
|
|
159
2663
|
"email",
|
|
@@ -167,14 +2671,18 @@ async function getActiveCollections(strapi) {
|
|
|
167
2671
|
"date",
|
|
168
2672
|
"datetime",
|
|
169
2673
|
"time",
|
|
170
|
-
"relation"
|
|
2674
|
+
"relation",
|
|
2675
|
+
"media"
|
|
171
2676
|
].includes(attr.type);
|
|
172
2677
|
});
|
|
173
|
-
|
|
2678
|
+
if (!enabledFields || enabledFields.length === 0) continue;
|
|
2679
|
+
activeList.push({
|
|
2680
|
+
name: item.name,
|
|
2681
|
+
fields: enabledFields
|
|
2682
|
+
});
|
|
174
2683
|
}
|
|
175
2684
|
return activeList;
|
|
176
2685
|
} catch (err) {
|
|
177
|
-
console.error(" [ERROR] Error loading active collections:", err);
|
|
178
2686
|
return [];
|
|
179
2687
|
}
|
|
180
2688
|
}
|
|
@@ -271,15 +2779,33 @@ function updateJsonContext(prevContext, question) {
|
|
|
271
2779
|
ctx.lastQuestion = question;
|
|
272
2780
|
return ctx;
|
|
273
2781
|
}
|
|
2782
|
+
function extractFilterFields(filters, collected = /* @__PURE__ */ new Set()) {
|
|
2783
|
+
if (!filters || typeof filters !== "object") return [];
|
|
2784
|
+
for (const key in filters) {
|
|
2785
|
+
if (key.startsWith("$")) {
|
|
2786
|
+
extractFilterFields(filters[key], collected);
|
|
2787
|
+
} else {
|
|
2788
|
+
collected.add(key);
|
|
2789
|
+
extractFilterFields(filters[key], collected);
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
return Array.from(collected);
|
|
2793
|
+
}
|
|
274
2794
|
async function searchRealtime(strapi, plan, activeCollections) {
|
|
275
2795
|
if (!plan || !plan.collection) {
|
|
276
2796
|
return null;
|
|
277
2797
|
}
|
|
278
|
-
const sanitizedFilters = sanitizeFilters(plan.filters || {});
|
|
279
2798
|
const config2 = activeCollections.find((c) => c.name === plan.collection);
|
|
280
2799
|
if (!config2) {
|
|
281
2800
|
return null;
|
|
282
2801
|
}
|
|
2802
|
+
const sanitizedFilters = sanitizeFilters(plan.filters || {});
|
|
2803
|
+
const requestedFields = extractFilterFields(sanitizedFilters);
|
|
2804
|
+
for (const field of requestedFields) {
|
|
2805
|
+
if (!config2.fields.includes(field)) {
|
|
2806
|
+
return null;
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
283
2809
|
const uid = `api::${plan.collection}.${plan.collection}`;
|
|
284
2810
|
try {
|
|
285
2811
|
if (plan.operation === "count") {
|
|
@@ -292,14 +2818,35 @@ async function searchRealtime(strapi, plan, activeCollections) {
|
|
|
292
2818
|
value: count
|
|
293
2819
|
};
|
|
294
2820
|
}
|
|
2821
|
+
const contentType = strapi.contentTypes[uid];
|
|
2822
|
+
const mediaFields = config2.fields.filter((field) => {
|
|
2823
|
+
const attr = contentType.attributes[field];
|
|
2824
|
+
return attr?.type === "media";
|
|
2825
|
+
});
|
|
2826
|
+
let populateObj = void 0;
|
|
2827
|
+
if (mediaFields.length > 0) {
|
|
2828
|
+
populateObj = {};
|
|
2829
|
+
mediaFields.forEach((field) => {
|
|
2830
|
+
populateObj[field] = true;
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
295
2833
|
const result = await strapi.entityService.findMany(uid, {
|
|
296
2834
|
filters: sanitizedFilters,
|
|
297
2835
|
sort: plan.sort,
|
|
298
|
-
limit: 10
|
|
2836
|
+
limit: 10,
|
|
2837
|
+
...populateObj ? { populate: populateObj } : {}
|
|
299
2838
|
});
|
|
300
2839
|
const cleaned = result.map((row) => {
|
|
301
2840
|
const clean = {};
|
|
302
|
-
for (const f of config2.fields)
|
|
2841
|
+
for (const f of config2.fields) {
|
|
2842
|
+
const value = row[f];
|
|
2843
|
+
if (value && typeof value === "object" && value.url) {
|
|
2844
|
+
console.log(`🖼 Extracted image for field '${f}':`, value.url);
|
|
2845
|
+
clean[f] = value.url;
|
|
2846
|
+
} else {
|
|
2847
|
+
clean[f] = value;
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
303
2850
|
return clean;
|
|
304
2851
|
});
|
|
305
2852
|
return {
|
|
@@ -570,7 +3117,7 @@ ${JSON.stringify(realtimeData)}
|
|
|
570
3117
|
const text = response.choices[0].message.content;
|
|
571
3118
|
return text;
|
|
572
3119
|
}
|
|
573
|
-
async function finalAggregator(strapi, ctx, question, faq, realtimeMeta, realtimeText, contactLink, instructions) {
|
|
3120
|
+
async function finalAggregator(strapi, ctx, question, faq, realtimeMeta, realtimeText, contactLink, instructions, cardStyles) {
|
|
574
3121
|
ctx.set("Content-Type", "text/event-stream");
|
|
575
3122
|
ctx.set("Cache-Control", "no-cache");
|
|
576
3123
|
ctx.set("Connection", "keep-alive");
|
|
@@ -677,10 +3224,12 @@ ${realtimeText}
|
|
|
677
3224
|
}
|
|
678
3225
|
}
|
|
679
3226
|
if (realtimeMeta && realtimeMeta.type === "list") {
|
|
3227
|
+
const collectionUid = `api::${realtimeMeta.collection}.${realtimeMeta.collection}`;
|
|
680
3228
|
const cardsPayload = {
|
|
681
3229
|
title: realtimeMeta.collection,
|
|
682
3230
|
schema: realtimeMeta.schema,
|
|
683
|
-
items: realtimeMeta.items
|
|
3231
|
+
items: realtimeMeta.items,
|
|
3232
|
+
cardStyle: cardStyles?.[collectionUid] || null
|
|
684
3233
|
};
|
|
685
3234
|
ctx.res.write(`event: cards
|
|
686
3235
|
`);
|
|
@@ -718,6 +3267,7 @@ const ask = ({ strapi }) => ({
|
|
|
718
3267
|
}
|
|
719
3268
|
const rewritten = await rephraseQuestion(strapi, history, question);
|
|
720
3269
|
const contactLink = await getContactLink(strapi);
|
|
3270
|
+
const cardStyles = await getCardStyles(strapi);
|
|
721
3271
|
const faqResults = await searchFAQ(rewritten, strapi);
|
|
722
3272
|
const plan = await simplePlanner(strapi, rewritten, activeCollections, instructions);
|
|
723
3273
|
let realtimeResults = null;
|
|
@@ -735,7 +3285,8 @@ const ask = ({ strapi }) => ({
|
|
|
735
3285
|
realtimeResults,
|
|
736
3286
|
realtimeAIText,
|
|
737
3287
|
contactLink,
|
|
738
|
-
instructions
|
|
3288
|
+
instructions,
|
|
3289
|
+
cardStyles
|
|
739
3290
|
);
|
|
740
3291
|
return;
|
|
741
3292
|
} catch (err) {
|
|
@@ -827,20 +3378,6 @@ const contentApi = () => ({
|
|
|
827
3378
|
config: {
|
|
828
3379
|
auth: false
|
|
829
3380
|
}
|
|
830
|
-
},
|
|
831
|
-
{
|
|
832
|
-
method: "GET",
|
|
833
|
-
path: "/card-mapping",
|
|
834
|
-
handler: "cardMapping.index",
|
|
835
|
-
config: { auth: false }
|
|
836
|
-
},
|
|
837
|
-
{
|
|
838
|
-
method: "POST",
|
|
839
|
-
path: "/validate-key",
|
|
840
|
-
handler: "ask.validateKey",
|
|
841
|
-
config: {
|
|
842
|
-
auth: false
|
|
843
|
-
}
|
|
844
3381
|
}
|
|
845
3382
|
]
|
|
846
3383
|
});
|
|
@@ -897,10 +3434,31 @@ const config = ({ strapi }) => ({
|
|
|
897
3434
|
});
|
|
898
3435
|
const existingRaw = await pluginStore.get({ key: "settings" });
|
|
899
3436
|
const existingSettings = existingRaw && typeof existingRaw === "object" ? existingRaw : {};
|
|
3437
|
+
let rebuiltCollections = [];
|
|
3438
|
+
if (newSettings.config) {
|
|
3439
|
+
rebuiltCollections = Object.entries(newSettings.config).map(([uid, selectedFields]) => {
|
|
3440
|
+
const contentType = strapi.contentTypes[uid];
|
|
3441
|
+
if (!contentType) return null;
|
|
3442
|
+
const allFields = Object.keys(contentType.attributes);
|
|
3443
|
+
return {
|
|
3444
|
+
name: uid.split(".")[1],
|
|
3445
|
+
fields: allFields.map((field) => ({
|
|
3446
|
+
name: field,
|
|
3447
|
+
enabled: selectedFields.includes(field)
|
|
3448
|
+
}))
|
|
3449
|
+
};
|
|
3450
|
+
}).filter(Boolean);
|
|
3451
|
+
}
|
|
900
3452
|
const mergedSettings = {
|
|
901
3453
|
...existingSettings,
|
|
902
3454
|
...newSettings
|
|
903
3455
|
};
|
|
3456
|
+
if (rebuiltCollections.length > 0) {
|
|
3457
|
+
await pluginStore.set({
|
|
3458
|
+
key: "collections",
|
|
3459
|
+
value: rebuiltCollections
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
904
3462
|
await pluginStore.set({
|
|
905
3463
|
key: "settings",
|
|
906
3464
|
value: mergedSettings
|