notu 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +31 -30
- package/dist/notu.js +0 -2060
- /package/dist/{notu.umd.cjs → index.js} +0 -0
package/dist/notu.js
DELETED
|
@@ -1,2060 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => (__defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value), value);
|
|
4
|
-
class ModelWithState {
|
|
5
|
-
constructor() {
|
|
6
|
-
__publicField(this, "state", "NEW");
|
|
7
|
-
}
|
|
8
|
-
new() {
|
|
9
|
-
return this.state = "NEW", this;
|
|
10
|
-
}
|
|
11
|
-
clean() {
|
|
12
|
-
return this.state = "CLEAN", this;
|
|
13
|
-
}
|
|
14
|
-
dirty() {
|
|
15
|
-
return this.state = "DIRTY", this;
|
|
16
|
-
}
|
|
17
|
-
delete() {
|
|
18
|
-
return this.state = "DELETED", this;
|
|
19
|
-
}
|
|
20
|
-
get isNew() {
|
|
21
|
-
return this.state == "NEW";
|
|
22
|
-
}
|
|
23
|
-
get isClean() {
|
|
24
|
-
return this.state == "CLEAN";
|
|
25
|
-
}
|
|
26
|
-
get isDirty() {
|
|
27
|
-
return this.state == "DIRTY";
|
|
28
|
-
}
|
|
29
|
-
get isDeleted() {
|
|
30
|
-
return this.state == "DELETED";
|
|
31
|
-
}
|
|
32
|
-
validate(throwError = !1) {
|
|
33
|
-
return !0;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
class Attr extends ModelWithState {
|
|
37
|
-
constructor() {
|
|
38
|
-
super(...arguments);
|
|
39
|
-
__publicField(this, "id", 0);
|
|
40
|
-
__publicField(this, "_name", "");
|
|
41
|
-
__publicField(this, "_type", "TEXT");
|
|
42
|
-
__publicField(this, "_spaceId", 0);
|
|
43
|
-
__publicField(this, "_space", null);
|
|
44
|
-
}
|
|
45
|
-
get name() {
|
|
46
|
-
return this._name;
|
|
47
|
-
}
|
|
48
|
-
set name(value) {
|
|
49
|
-
value !== this._name && (this._name = value, this.isClean && this.dirty());
|
|
50
|
-
}
|
|
51
|
-
get type() {
|
|
52
|
-
return this._type;
|
|
53
|
-
}
|
|
54
|
-
set type(value) {
|
|
55
|
-
if (!this.isNew)
|
|
56
|
-
throw Error("Cannot change an attribute's type once it has been created.");
|
|
57
|
-
this._type = value;
|
|
58
|
-
}
|
|
59
|
-
get isText() {
|
|
60
|
-
return this.type == "TEXT";
|
|
61
|
-
}
|
|
62
|
-
get isNumber() {
|
|
63
|
-
return this.type == "NUMBER";
|
|
64
|
-
}
|
|
65
|
-
get isBoolean() {
|
|
66
|
-
return this.type == "BOOLEAN";
|
|
67
|
-
}
|
|
68
|
-
get isDate() {
|
|
69
|
-
return this.type == "DATE";
|
|
70
|
-
}
|
|
71
|
-
asText() {
|
|
72
|
-
return this.type = "TEXT", this;
|
|
73
|
-
}
|
|
74
|
-
asNumber() {
|
|
75
|
-
return this.type = "NUMBER", this;
|
|
76
|
-
}
|
|
77
|
-
asBoolean() {
|
|
78
|
-
return this.type = "BOOLEAN", this;
|
|
79
|
-
}
|
|
80
|
-
asDate() {
|
|
81
|
-
return this.type = "DATE", this;
|
|
82
|
-
}
|
|
83
|
-
get spaceId() {
|
|
84
|
-
return this._spaceId;
|
|
85
|
-
}
|
|
86
|
-
set spaceId(value) {
|
|
87
|
-
var _a;
|
|
88
|
-
value !== this._spaceId && (this._spaceId = value, value !== ((_a = this.space) == null ? void 0 : _a.id) && (this._space = null), this.isClean && this.dirty());
|
|
89
|
-
}
|
|
90
|
-
get space() {
|
|
91
|
-
return this._space;
|
|
92
|
-
}
|
|
93
|
-
set space(value) {
|
|
94
|
-
this._space = value, this.spaceId = (value == null ? void 0 : value.id) ?? 0;
|
|
95
|
-
}
|
|
96
|
-
duplicate() {
|
|
97
|
-
const output = new Attr();
|
|
98
|
-
return output.id = this.id, output.name = this.name, output.type = this.type, output.space = this.space, output;
|
|
99
|
-
}
|
|
100
|
-
validate(throwError = !1) {
|
|
101
|
-
let output = null;
|
|
102
|
-
if (this.spaceId <= 0 ? output = "Note spaceId must be greater than zero." : !this.isNew && this.id <= 0 && (output = "Attr id must be greater than zero if in non-new state."), throwError && output != null)
|
|
103
|
-
throw Error(output);
|
|
104
|
-
return output == null;
|
|
105
|
-
}
|
|
106
|
-
get defaultValue() {
|
|
107
|
-
switch (this.type) {
|
|
108
|
-
case "TEXT":
|
|
109
|
-
return "";
|
|
110
|
-
case "NUMBER":
|
|
111
|
-
return 0;
|
|
112
|
-
case "BOOLEAN":
|
|
113
|
-
return !1;
|
|
114
|
-
case "DATE":
|
|
115
|
-
return /* @__PURE__ */ new Date();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
class Environment {
|
|
120
|
-
constructor(client) {
|
|
121
|
-
__publicField(this, "_client", null);
|
|
122
|
-
__publicField(this, "_spaces", []);
|
|
123
|
-
if (!client)
|
|
124
|
-
throw Error("Client must be set on Environment constructor");
|
|
125
|
-
this._client = client;
|
|
126
|
-
}
|
|
127
|
-
get client() {
|
|
128
|
-
return this._client;
|
|
129
|
-
}
|
|
130
|
-
get spaces() {
|
|
131
|
-
return this._spaces;
|
|
132
|
-
}
|
|
133
|
-
async loadSpaces() {
|
|
134
|
-
return this._spaces = await this.client.getSpaces(), this.spaces;
|
|
135
|
-
}
|
|
136
|
-
async saveSpace(space) {
|
|
137
|
-
return await this.client.saveSpace(space);
|
|
138
|
-
}
|
|
139
|
-
async getNotes(query, spaceId) {
|
|
140
|
-
return await this.client.getNotes(query, spaceId);
|
|
141
|
-
}
|
|
142
|
-
async getNoteCount(query, spaceId) {
|
|
143
|
-
return await this.client.getNoteCount(query, spaceId);
|
|
144
|
-
}
|
|
145
|
-
async saveNote(note) {
|
|
146
|
-
return (await this.client.saveNotes([note]))[0];
|
|
147
|
-
}
|
|
148
|
-
async saveNotes(notes) {
|
|
149
|
-
return await this.client.saveNotes(notes);
|
|
150
|
-
}
|
|
151
|
-
async customJob(name, data) {
|
|
152
|
-
return await this.client.customJob(name, data);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function bind(fn, thisArg) {
|
|
156
|
-
return function() {
|
|
157
|
-
return fn.apply(thisArg, arguments);
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
const { toString } = Object.prototype, { getPrototypeOf } = Object, kindOf = ((cache) => (thing) => {
|
|
161
|
-
const str = toString.call(thing);
|
|
162
|
-
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
163
|
-
})(/* @__PURE__ */ Object.create(null)), kindOfTest = (type) => (type = type.toLowerCase(), (thing) => kindOf(thing) === type), typeOfTest = (type) => (thing) => typeof thing === type, { isArray } = Array, isUndefined = typeOfTest("undefined");
|
|
164
|
-
function isBuffer(val) {
|
|
165
|
-
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
166
|
-
}
|
|
167
|
-
const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
168
|
-
function isArrayBufferView(val) {
|
|
169
|
-
let result;
|
|
170
|
-
return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? result = ArrayBuffer.isView(val) : result = val && val.buffer && isArrayBuffer(val.buffer), result;
|
|
171
|
-
}
|
|
172
|
-
const isString = typeOfTest("string"), isFunction = typeOfTest("function"), isNumber = typeOfTest("number"), isObject = (thing) => thing !== null && typeof thing == "object", isBoolean = (thing) => thing === !0 || thing === !1, isPlainObject = (val) => {
|
|
173
|
-
if (kindOf(val) !== "object")
|
|
174
|
-
return !1;
|
|
175
|
-
const prototype2 = getPrototypeOf(val);
|
|
176
|
-
return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
|
177
|
-
}, isDate = kindOfTest("Date"), isFile = kindOfTest("File"), isBlob = kindOfTest("Blob"), isFileList = kindOfTest("FileList"), isStream = (val) => isObject(val) && isFunction(val.pipe), isFormData = (thing) => {
|
|
178
|
-
let kind;
|
|
179
|
-
return thing && (typeof FormData == "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
|
|
180
|
-
kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
|
|
181
|
-
}, isURLSearchParams = kindOfTest("URLSearchParams"), trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
182
|
-
function forEach(obj, fn, { allOwnKeys = !1 } = {}) {
|
|
183
|
-
if (obj === null || typeof obj > "u")
|
|
184
|
-
return;
|
|
185
|
-
let i, l;
|
|
186
|
-
if (typeof obj != "object" && (obj = [obj]), isArray(obj))
|
|
187
|
-
for (i = 0, l = obj.length; i < l; i++)
|
|
188
|
-
fn.call(null, obj[i], i, obj);
|
|
189
|
-
else {
|
|
190
|
-
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj), len = keys.length;
|
|
191
|
-
let key;
|
|
192
|
-
for (i = 0; i < len; i++)
|
|
193
|
-
key = keys[i], fn.call(null, obj[key], key, obj);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
function findKey(obj, key) {
|
|
197
|
-
key = key.toLowerCase();
|
|
198
|
-
const keys = Object.keys(obj);
|
|
199
|
-
let i = keys.length, _key;
|
|
200
|
-
for (; i-- > 0; )
|
|
201
|
-
if (_key = keys[i], key === _key.toLowerCase())
|
|
202
|
-
return _key;
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
const _global = (() => typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global)(), isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
206
|
-
function merge() {
|
|
207
|
-
const { caseless } = isContextDefined(this) && this || {}, result = {}, assignValue = (val, key) => {
|
|
208
|
-
const targetKey = caseless && findKey(result, key) || key;
|
|
209
|
-
isPlainObject(result[targetKey]) && isPlainObject(val) ? result[targetKey] = merge(result[targetKey], val) : isPlainObject(val) ? result[targetKey] = merge({}, val) : isArray(val) ? result[targetKey] = val.slice() : result[targetKey] = val;
|
|
210
|
-
};
|
|
211
|
-
for (let i = 0, l = arguments.length; i < l; i++)
|
|
212
|
-
arguments[i] && forEach(arguments[i], assignValue);
|
|
213
|
-
return result;
|
|
214
|
-
}
|
|
215
|
-
const extend = (a, b, thisArg, { allOwnKeys } = {}) => (forEach(b, (val, key) => {
|
|
216
|
-
thisArg && isFunction(val) ? a[key] = bind(val, thisArg) : a[key] = val;
|
|
217
|
-
}, { allOwnKeys }), a), stripBOM = (content) => (content.charCodeAt(0) === 65279 && (content = content.slice(1)), content), inherits = (constructor, superConstructor, props, descriptors2) => {
|
|
218
|
-
constructor.prototype = Object.create(superConstructor.prototype, descriptors2), constructor.prototype.constructor = constructor, Object.defineProperty(constructor, "super", {
|
|
219
|
-
value: superConstructor.prototype
|
|
220
|
-
}), props && Object.assign(constructor.prototype, props);
|
|
221
|
-
}, toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
|
|
222
|
-
let props, i, prop;
|
|
223
|
-
const merged = {};
|
|
224
|
-
if (destObj = destObj || {}, sourceObj == null)
|
|
225
|
-
return destObj;
|
|
226
|
-
do {
|
|
227
|
-
for (props = Object.getOwnPropertyNames(sourceObj), i = props.length; i-- > 0; )
|
|
228
|
-
prop = props[i], (!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop] && (destObj[prop] = sourceObj[prop], merged[prop] = !0);
|
|
229
|
-
sourceObj = filter2 !== !1 && getPrototypeOf(sourceObj);
|
|
230
|
-
} while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
231
|
-
return destObj;
|
|
232
|
-
}, endsWith = (str, searchString, position) => {
|
|
233
|
-
str = String(str), (position === void 0 || position > str.length) && (position = str.length), position -= searchString.length;
|
|
234
|
-
const lastIndex = str.indexOf(searchString, position);
|
|
235
|
-
return lastIndex !== -1 && lastIndex === position;
|
|
236
|
-
}, toArray = (thing) => {
|
|
237
|
-
if (!thing)
|
|
238
|
-
return null;
|
|
239
|
-
if (isArray(thing))
|
|
240
|
-
return thing;
|
|
241
|
-
let i = thing.length;
|
|
242
|
-
if (!isNumber(i))
|
|
243
|
-
return null;
|
|
244
|
-
const arr = new Array(i);
|
|
245
|
-
for (; i-- > 0; )
|
|
246
|
-
arr[i] = thing[i];
|
|
247
|
-
return arr;
|
|
248
|
-
}, isTypedArray = ((TypedArray) => (thing) => TypedArray && thing instanceof TypedArray)(typeof Uint8Array < "u" && getPrototypeOf(Uint8Array)), forEachEntry = (obj, fn) => {
|
|
249
|
-
const iterator = (obj && obj[Symbol.iterator]).call(obj);
|
|
250
|
-
let result;
|
|
251
|
-
for (; (result = iterator.next()) && !result.done; ) {
|
|
252
|
-
const pair = result.value;
|
|
253
|
-
fn.call(obj, pair[0], pair[1]);
|
|
254
|
-
}
|
|
255
|
-
}, matchAll = (regExp, str) => {
|
|
256
|
-
let matches;
|
|
257
|
-
const arr = [];
|
|
258
|
-
for (; (matches = regExp.exec(str)) !== null; )
|
|
259
|
-
arr.push(matches);
|
|
260
|
-
return arr;
|
|
261
|
-
}, isHTMLForm = kindOfTest("HTMLFormElement"), toCamelCase = (str) => str.toLowerCase().replace(
|
|
262
|
-
/[-_\s]([a-z\d])(\w*)/g,
|
|
263
|
-
function(m, p1, p2) {
|
|
264
|
-
return p1.toUpperCase() + p2;
|
|
265
|
-
}
|
|
266
|
-
), hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype), isRegExp = kindOfTest("RegExp"), reduceDescriptors = (obj, reducer) => {
|
|
267
|
-
const descriptors2 = Object.getOwnPropertyDescriptors(obj), reducedDescriptors = {};
|
|
268
|
-
forEach(descriptors2, (descriptor, name) => {
|
|
269
|
-
let ret;
|
|
270
|
-
(ret = reducer(descriptor, name, obj)) !== !1 && (reducedDescriptors[name] = ret || descriptor);
|
|
271
|
-
}), Object.defineProperties(obj, reducedDescriptors);
|
|
272
|
-
}, freezeMethods = (obj) => {
|
|
273
|
-
reduceDescriptors(obj, (descriptor, name) => {
|
|
274
|
-
if (isFunction(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1)
|
|
275
|
-
return !1;
|
|
276
|
-
const value = obj[name];
|
|
277
|
-
if (isFunction(value)) {
|
|
278
|
-
if (descriptor.enumerable = !1, "writable" in descriptor) {
|
|
279
|
-
descriptor.writable = !1;
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
descriptor.set || (descriptor.set = () => {
|
|
283
|
-
throw Error("Can not rewrite read-only method '" + name + "'");
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
}, toObjectSet = (arrayOrString, delimiter) => {
|
|
288
|
-
const obj = {}, define = (arr) => {
|
|
289
|
-
arr.forEach((value) => {
|
|
290
|
-
obj[value] = !0;
|
|
291
|
-
});
|
|
292
|
-
};
|
|
293
|
-
return isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter)), obj;
|
|
294
|
-
}, noop = () => {
|
|
295
|
-
}, toFiniteNumber = (value, defaultValue) => (value = +value, Number.isFinite(value) ? value : defaultValue), ALPHA = "abcdefghijklmnopqrstuvwxyz", DIGIT = "0123456789", ALPHABET = {
|
|
296
|
-
DIGIT,
|
|
297
|
-
ALPHA,
|
|
298
|
-
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
|
299
|
-
}, generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
|
300
|
-
let str = "";
|
|
301
|
-
const { length } = alphabet;
|
|
302
|
-
for (; size--; )
|
|
303
|
-
str += alphabet[Math.random() * length | 0];
|
|
304
|
-
return str;
|
|
305
|
-
};
|
|
306
|
-
function isSpecCompliantForm(thing) {
|
|
307
|
-
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === "FormData" && thing[Symbol.iterator]);
|
|
308
|
-
}
|
|
309
|
-
const toJSONObject = (obj) => {
|
|
310
|
-
const stack = new Array(10), visit = (source, i) => {
|
|
311
|
-
if (isObject(source)) {
|
|
312
|
-
if (stack.indexOf(source) >= 0)
|
|
313
|
-
return;
|
|
314
|
-
if (!("toJSON" in source)) {
|
|
315
|
-
stack[i] = source;
|
|
316
|
-
const target = isArray(source) ? [] : {};
|
|
317
|
-
return forEach(source, (value, key) => {
|
|
318
|
-
const reducedValue = visit(value, i + 1);
|
|
319
|
-
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
320
|
-
}), stack[i] = void 0, target;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
return source;
|
|
324
|
-
};
|
|
325
|
-
return visit(obj, 0);
|
|
326
|
-
}, isAsyncFn = kindOfTest("AsyncFunction"), isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch), utils = {
|
|
327
|
-
isArray,
|
|
328
|
-
isArrayBuffer,
|
|
329
|
-
isBuffer,
|
|
330
|
-
isFormData,
|
|
331
|
-
isArrayBufferView,
|
|
332
|
-
isString,
|
|
333
|
-
isNumber,
|
|
334
|
-
isBoolean,
|
|
335
|
-
isObject,
|
|
336
|
-
isPlainObject,
|
|
337
|
-
isUndefined,
|
|
338
|
-
isDate,
|
|
339
|
-
isFile,
|
|
340
|
-
isBlob,
|
|
341
|
-
isRegExp,
|
|
342
|
-
isFunction,
|
|
343
|
-
isStream,
|
|
344
|
-
isURLSearchParams,
|
|
345
|
-
isTypedArray,
|
|
346
|
-
isFileList,
|
|
347
|
-
forEach,
|
|
348
|
-
merge,
|
|
349
|
-
extend,
|
|
350
|
-
trim,
|
|
351
|
-
stripBOM,
|
|
352
|
-
inherits,
|
|
353
|
-
toFlatObject,
|
|
354
|
-
kindOf,
|
|
355
|
-
kindOfTest,
|
|
356
|
-
endsWith,
|
|
357
|
-
toArray,
|
|
358
|
-
forEachEntry,
|
|
359
|
-
matchAll,
|
|
360
|
-
isHTMLForm,
|
|
361
|
-
hasOwnProperty,
|
|
362
|
-
hasOwnProp: hasOwnProperty,
|
|
363
|
-
// an alias to avoid ESLint no-prototype-builtins detection
|
|
364
|
-
reduceDescriptors,
|
|
365
|
-
freezeMethods,
|
|
366
|
-
toObjectSet,
|
|
367
|
-
toCamelCase,
|
|
368
|
-
noop,
|
|
369
|
-
toFiniteNumber,
|
|
370
|
-
findKey,
|
|
371
|
-
global: _global,
|
|
372
|
-
isContextDefined,
|
|
373
|
-
ALPHABET,
|
|
374
|
-
generateString,
|
|
375
|
-
isSpecCompliantForm,
|
|
376
|
-
toJSONObject,
|
|
377
|
-
isAsyncFn,
|
|
378
|
-
isThenable
|
|
379
|
-
};
|
|
380
|
-
function AxiosError(message, code, config, request, response) {
|
|
381
|
-
Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = message, this.name = "AxiosError", code && (this.code = code), config && (this.config = config), request && (this.request = request), response && (this.response = response);
|
|
382
|
-
}
|
|
383
|
-
utils.inherits(AxiosError, Error, {
|
|
384
|
-
toJSON: function() {
|
|
385
|
-
return {
|
|
386
|
-
// Standard
|
|
387
|
-
message: this.message,
|
|
388
|
-
name: this.name,
|
|
389
|
-
// Microsoft
|
|
390
|
-
description: this.description,
|
|
391
|
-
number: this.number,
|
|
392
|
-
// Mozilla
|
|
393
|
-
fileName: this.fileName,
|
|
394
|
-
lineNumber: this.lineNumber,
|
|
395
|
-
columnNumber: this.columnNumber,
|
|
396
|
-
stack: this.stack,
|
|
397
|
-
// Axios
|
|
398
|
-
config: utils.toJSONObject(this.config),
|
|
399
|
-
code: this.code,
|
|
400
|
-
status: this.response && this.response.status ? this.response.status : null
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
const prototype$1 = AxiosError.prototype, descriptors = {};
|
|
405
|
-
[
|
|
406
|
-
"ERR_BAD_OPTION_VALUE",
|
|
407
|
-
"ERR_BAD_OPTION",
|
|
408
|
-
"ECONNABORTED",
|
|
409
|
-
"ETIMEDOUT",
|
|
410
|
-
"ERR_NETWORK",
|
|
411
|
-
"ERR_FR_TOO_MANY_REDIRECTS",
|
|
412
|
-
"ERR_DEPRECATED",
|
|
413
|
-
"ERR_BAD_RESPONSE",
|
|
414
|
-
"ERR_BAD_REQUEST",
|
|
415
|
-
"ERR_CANCELED",
|
|
416
|
-
"ERR_NOT_SUPPORT",
|
|
417
|
-
"ERR_INVALID_URL"
|
|
418
|
-
// eslint-disable-next-line func-names
|
|
419
|
-
].forEach((code) => {
|
|
420
|
-
descriptors[code] = { value: code };
|
|
421
|
-
});
|
|
422
|
-
Object.defineProperties(AxiosError, descriptors);
|
|
423
|
-
Object.defineProperty(prototype$1, "isAxiosError", { value: !0 });
|
|
424
|
-
AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
425
|
-
const axiosError = Object.create(prototype$1);
|
|
426
|
-
return utils.toFlatObject(error, axiosError, function(obj) {
|
|
427
|
-
return obj !== Error.prototype;
|
|
428
|
-
}, (prop) => prop !== "isAxiosError"), AxiosError.call(axiosError, error.message, code, config, request, response), axiosError.cause = error, axiosError.name = error.name, customProps && Object.assign(axiosError, customProps), axiosError;
|
|
429
|
-
};
|
|
430
|
-
const httpAdapter = null;
|
|
431
|
-
function isVisitable(thing) {
|
|
432
|
-
return utils.isPlainObject(thing) || utils.isArray(thing);
|
|
433
|
-
}
|
|
434
|
-
function removeBrackets(key) {
|
|
435
|
-
return utils.endsWith(key, "[]") ? key.slice(0, -2) : key;
|
|
436
|
-
}
|
|
437
|
-
function renderKey(path, key, dots) {
|
|
438
|
-
return path ? path.concat(key).map(function(token, i) {
|
|
439
|
-
return token = removeBrackets(token), !dots && i ? "[" + token + "]" : token;
|
|
440
|
-
}).join(dots ? "." : "") : key;
|
|
441
|
-
}
|
|
442
|
-
function isFlatArray(arr) {
|
|
443
|
-
return utils.isArray(arr) && !arr.some(isVisitable);
|
|
444
|
-
}
|
|
445
|
-
const predicates = utils.toFlatObject(utils, {}, null, function(prop) {
|
|
446
|
-
return /^is[A-Z]/.test(prop);
|
|
447
|
-
});
|
|
448
|
-
function toFormData(obj, formData, options) {
|
|
449
|
-
if (!utils.isObject(obj))
|
|
450
|
-
throw new TypeError("target must be an object");
|
|
451
|
-
formData = formData || new FormData(), options = utils.toFlatObject(options, {
|
|
452
|
-
metaTokens: !0,
|
|
453
|
-
dots: !1,
|
|
454
|
-
indexes: !1
|
|
455
|
-
}, !1, function(option, source) {
|
|
456
|
-
return !utils.isUndefined(source[option]);
|
|
457
|
-
});
|
|
458
|
-
const metaTokens = options.metaTokens, visitor = options.visitor || defaultVisitor, dots = options.dots, indexes = options.indexes, useBlob = (options.Blob || typeof Blob < "u" && Blob) && utils.isSpecCompliantForm(formData);
|
|
459
|
-
if (!utils.isFunction(visitor))
|
|
460
|
-
throw new TypeError("visitor must be a function");
|
|
461
|
-
function convertValue(value) {
|
|
462
|
-
if (value === null)
|
|
463
|
-
return "";
|
|
464
|
-
if (utils.isDate(value))
|
|
465
|
-
return value.toISOString();
|
|
466
|
-
if (!useBlob && utils.isBlob(value))
|
|
467
|
-
throw new AxiosError("Blob is not supported. Use a Buffer instead.");
|
|
468
|
-
return utils.isArrayBuffer(value) || utils.isTypedArray(value) ? useBlob && typeof Blob == "function" ? new Blob([value]) : Buffer.from(value) : value;
|
|
469
|
-
}
|
|
470
|
-
function defaultVisitor(value, key, path) {
|
|
471
|
-
let arr = value;
|
|
472
|
-
if (value && !path && typeof value == "object") {
|
|
473
|
-
if (utils.endsWith(key, "{}"))
|
|
474
|
-
key = metaTokens ? key : key.slice(0, -2), value = JSON.stringify(value);
|
|
475
|
-
else if (utils.isArray(value) && isFlatArray(value) || (utils.isFileList(value) || utils.endsWith(key, "[]")) && (arr = utils.toArray(value)))
|
|
476
|
-
return key = removeBrackets(key), arr.forEach(function(el, index) {
|
|
477
|
-
!(utils.isUndefined(el) || el === null) && formData.append(
|
|
478
|
-
// eslint-disable-next-line no-nested-ternary
|
|
479
|
-
indexes === !0 ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
|
|
480
|
-
convertValue(el)
|
|
481
|
-
);
|
|
482
|
-
}), !1;
|
|
483
|
-
}
|
|
484
|
-
return isVisitable(value) ? !0 : (formData.append(renderKey(path, key, dots), convertValue(value)), !1);
|
|
485
|
-
}
|
|
486
|
-
const stack = [], exposedHelpers = Object.assign(predicates, {
|
|
487
|
-
defaultVisitor,
|
|
488
|
-
convertValue,
|
|
489
|
-
isVisitable
|
|
490
|
-
});
|
|
491
|
-
function build(value, path) {
|
|
492
|
-
if (!utils.isUndefined(value)) {
|
|
493
|
-
if (stack.indexOf(value) !== -1)
|
|
494
|
-
throw Error("Circular reference detected in " + path.join("."));
|
|
495
|
-
stack.push(value), utils.forEach(value, function(el, key) {
|
|
496
|
-
(!(utils.isUndefined(el) || el === null) && visitor.call(
|
|
497
|
-
formData,
|
|
498
|
-
el,
|
|
499
|
-
utils.isString(key) ? key.trim() : key,
|
|
500
|
-
path,
|
|
501
|
-
exposedHelpers
|
|
502
|
-
)) === !0 && build(el, path ? path.concat(key) : [key]);
|
|
503
|
-
}), stack.pop();
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
if (!utils.isObject(obj))
|
|
507
|
-
throw new TypeError("data must be an object");
|
|
508
|
-
return build(obj), formData;
|
|
509
|
-
}
|
|
510
|
-
function encode$1(str) {
|
|
511
|
-
const charMap = {
|
|
512
|
-
"!": "%21",
|
|
513
|
-
"'": "%27",
|
|
514
|
-
"(": "%28",
|
|
515
|
-
")": "%29",
|
|
516
|
-
"~": "%7E",
|
|
517
|
-
"%20": "+",
|
|
518
|
-
"%00": "\0"
|
|
519
|
-
};
|
|
520
|
-
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function(match) {
|
|
521
|
-
return charMap[match];
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
function AxiosURLSearchParams(params, options) {
|
|
525
|
-
this._pairs = [], params && toFormData(params, this, options);
|
|
526
|
-
}
|
|
527
|
-
const prototype = AxiosURLSearchParams.prototype;
|
|
528
|
-
prototype.append = function(name, value) {
|
|
529
|
-
this._pairs.push([name, value]);
|
|
530
|
-
};
|
|
531
|
-
prototype.toString = function(encoder) {
|
|
532
|
-
const _encode = encoder ? function(value) {
|
|
533
|
-
return encoder.call(this, value, encode$1);
|
|
534
|
-
} : encode$1;
|
|
535
|
-
return this._pairs.map(function(pair) {
|
|
536
|
-
return _encode(pair[0]) + "=" + _encode(pair[1]);
|
|
537
|
-
}, "").join("&");
|
|
538
|
-
};
|
|
539
|
-
function encode(val) {
|
|
540
|
-
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
|
541
|
-
}
|
|
542
|
-
function buildURL(url, params, options) {
|
|
543
|
-
if (!params)
|
|
544
|
-
return url;
|
|
545
|
-
const _encode = options && options.encode || encode, serializeFn = options && options.serialize;
|
|
546
|
-
let serializedParams;
|
|
547
|
-
if (serializeFn ? serializedParams = serializeFn(params, options) : serializedParams = utils.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode), serializedParams) {
|
|
548
|
-
const hashmarkIndex = url.indexOf("#");
|
|
549
|
-
hashmarkIndex !== -1 && (url = url.slice(0, hashmarkIndex)), url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
550
|
-
}
|
|
551
|
-
return url;
|
|
552
|
-
}
|
|
553
|
-
class InterceptorManager {
|
|
554
|
-
constructor() {
|
|
555
|
-
this.handlers = [];
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* Add a new interceptor to the stack
|
|
559
|
-
*
|
|
560
|
-
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
561
|
-
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
562
|
-
*
|
|
563
|
-
* @return {Number} An ID used to remove interceptor later
|
|
564
|
-
*/
|
|
565
|
-
use(fulfilled, rejected, options) {
|
|
566
|
-
return this.handlers.push({
|
|
567
|
-
fulfilled,
|
|
568
|
-
rejected,
|
|
569
|
-
synchronous: options ? options.synchronous : !1,
|
|
570
|
-
runWhen: options ? options.runWhen : null
|
|
571
|
-
}), this.handlers.length - 1;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Remove an interceptor from the stack
|
|
575
|
-
*
|
|
576
|
-
* @param {Number} id The ID that was returned by `use`
|
|
577
|
-
*
|
|
578
|
-
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
|
579
|
-
*/
|
|
580
|
-
eject(id) {
|
|
581
|
-
this.handlers[id] && (this.handlers[id] = null);
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Clear all interceptors from the stack
|
|
585
|
-
*
|
|
586
|
-
* @returns {void}
|
|
587
|
-
*/
|
|
588
|
-
clear() {
|
|
589
|
-
this.handlers && (this.handlers = []);
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* Iterate over all the registered interceptors
|
|
593
|
-
*
|
|
594
|
-
* This method is particularly useful for skipping over any
|
|
595
|
-
* interceptors that may have become `null` calling `eject`.
|
|
596
|
-
*
|
|
597
|
-
* @param {Function} fn The function to call for each interceptor
|
|
598
|
-
*
|
|
599
|
-
* @returns {void}
|
|
600
|
-
*/
|
|
601
|
-
forEach(fn) {
|
|
602
|
-
utils.forEach(this.handlers, function(h) {
|
|
603
|
-
h !== null && fn(h);
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
const InterceptorManager$1 = InterceptorManager, transitionalDefaults = {
|
|
608
|
-
silentJSONParsing: !0,
|
|
609
|
-
forcedJSONParsing: !0,
|
|
610
|
-
clarifyTimeoutError: !1
|
|
611
|
-
}, URLSearchParams$1 = typeof URLSearchParams < "u" ? URLSearchParams : AxiosURLSearchParams, FormData$1 = typeof FormData < "u" ? FormData : null, Blob$1 = typeof Blob < "u" ? Blob : null, isStandardBrowserEnv = (() => {
|
|
612
|
-
let product;
|
|
613
|
-
return typeof navigator < "u" && ((product = navigator.product) === "ReactNative" || product === "NativeScript" || product === "NS") ? !1 : typeof window < "u" && typeof document < "u";
|
|
614
|
-
})(), isStandardBrowserWebWorkerEnv = (() => typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
|
|
615
|
-
self instanceof WorkerGlobalScope && typeof self.importScripts == "function")(), platform = {
|
|
616
|
-
isBrowser: !0,
|
|
617
|
-
classes: {
|
|
618
|
-
URLSearchParams: URLSearchParams$1,
|
|
619
|
-
FormData: FormData$1,
|
|
620
|
-
Blob: Blob$1
|
|
621
|
-
},
|
|
622
|
-
isStandardBrowserEnv,
|
|
623
|
-
isStandardBrowserWebWorkerEnv,
|
|
624
|
-
protocols: ["http", "https", "file", "blob", "url", "data"]
|
|
625
|
-
};
|
|
626
|
-
function toURLEncodedForm(data, options) {
|
|
627
|
-
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
628
|
-
visitor: function(value, key, path, helpers) {
|
|
629
|
-
return platform.isNode && utils.isBuffer(value) ? (this.append(key, value.toString("base64")), !1) : helpers.defaultVisitor.apply(this, arguments);
|
|
630
|
-
}
|
|
631
|
-
}, options));
|
|
632
|
-
}
|
|
633
|
-
function parsePropPath(name) {
|
|
634
|
-
return utils.matchAll(/\w+|\[(\w*)]/g, name).map((match) => match[0] === "[]" ? "" : match[1] || match[0]);
|
|
635
|
-
}
|
|
636
|
-
function arrayToObject(arr) {
|
|
637
|
-
const obj = {}, keys = Object.keys(arr);
|
|
638
|
-
let i;
|
|
639
|
-
const len = keys.length;
|
|
640
|
-
let key;
|
|
641
|
-
for (i = 0; i < len; i++)
|
|
642
|
-
key = keys[i], obj[key] = arr[key];
|
|
643
|
-
return obj;
|
|
644
|
-
}
|
|
645
|
-
function formDataToJSON(formData) {
|
|
646
|
-
function buildPath(path, value, target, index) {
|
|
647
|
-
let name = path[index++];
|
|
648
|
-
const isNumericKey = Number.isFinite(+name), isLast = index >= path.length;
|
|
649
|
-
return name = !name && utils.isArray(target) ? target.length : name, isLast ? (utils.hasOwnProp(target, name) ? target[name] = [target[name], value] : target[name] = value, !isNumericKey) : ((!target[name] || !utils.isObject(target[name])) && (target[name] = []), buildPath(path, value, target[name], index) && utils.isArray(target[name]) && (target[name] = arrayToObject(target[name])), !isNumericKey);
|
|
650
|
-
}
|
|
651
|
-
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
|
|
652
|
-
const obj = {};
|
|
653
|
-
return utils.forEachEntry(formData, (name, value) => {
|
|
654
|
-
buildPath(parsePropPath(name), value, obj, 0);
|
|
655
|
-
}), obj;
|
|
656
|
-
}
|
|
657
|
-
return null;
|
|
658
|
-
}
|
|
659
|
-
function stringifySafely(rawValue, parser, encoder) {
|
|
660
|
-
if (utils.isString(rawValue))
|
|
661
|
-
try {
|
|
662
|
-
return (parser || JSON.parse)(rawValue), utils.trim(rawValue);
|
|
663
|
-
} catch (e) {
|
|
664
|
-
if (e.name !== "SyntaxError")
|
|
665
|
-
throw e;
|
|
666
|
-
}
|
|
667
|
-
return (encoder || JSON.stringify)(rawValue);
|
|
668
|
-
}
|
|
669
|
-
const defaults = {
|
|
670
|
-
transitional: transitionalDefaults,
|
|
671
|
-
adapter: ["xhr", "http"],
|
|
672
|
-
transformRequest: [function(data, headers) {
|
|
673
|
-
const contentType = headers.getContentType() || "", hasJSONContentType = contentType.indexOf("application/json") > -1, isObjectPayload = utils.isObject(data);
|
|
674
|
-
if (isObjectPayload && utils.isHTMLForm(data) && (data = new FormData(data)), utils.isFormData(data))
|
|
675
|
-
return hasJSONContentType && hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
676
|
-
if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data))
|
|
677
|
-
return data;
|
|
678
|
-
if (utils.isArrayBufferView(data))
|
|
679
|
-
return data.buffer;
|
|
680
|
-
if (utils.isURLSearchParams(data))
|
|
681
|
-
return headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), data.toString();
|
|
682
|
-
let isFileList2;
|
|
683
|
-
if (isObjectPayload) {
|
|
684
|
-
if (contentType.indexOf("application/x-www-form-urlencoded") > -1)
|
|
685
|
-
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
686
|
-
if ((isFileList2 = utils.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
|
|
687
|
-
const _FormData = this.env && this.env.FormData;
|
|
688
|
-
return toFormData(
|
|
689
|
-
isFileList2 ? { "files[]": data } : data,
|
|
690
|
-
_FormData && new _FormData(),
|
|
691
|
-
this.formSerializer
|
|
692
|
-
);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
return isObjectPayload || hasJSONContentType ? (headers.setContentType("application/json", !1), stringifySafely(data)) : data;
|
|
696
|
-
}],
|
|
697
|
-
transformResponse: [function(data) {
|
|
698
|
-
const transitional2 = this.transitional || defaults.transitional, forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing, JSONRequested = this.responseType === "json";
|
|
699
|
-
if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
|
700
|
-
const strictJSONParsing = !(transitional2 && transitional2.silentJSONParsing) && JSONRequested;
|
|
701
|
-
try {
|
|
702
|
-
return JSON.parse(data);
|
|
703
|
-
} catch (e) {
|
|
704
|
-
if (strictJSONParsing)
|
|
705
|
-
throw e.name === "SyntaxError" ? AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response) : e;
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
return data;
|
|
709
|
-
}],
|
|
710
|
-
/**
|
|
711
|
-
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
712
|
-
* timeout is not created.
|
|
713
|
-
*/
|
|
714
|
-
timeout: 0,
|
|
715
|
-
xsrfCookieName: "XSRF-TOKEN",
|
|
716
|
-
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
717
|
-
maxContentLength: -1,
|
|
718
|
-
maxBodyLength: -1,
|
|
719
|
-
env: {
|
|
720
|
-
FormData: platform.classes.FormData,
|
|
721
|
-
Blob: platform.classes.Blob
|
|
722
|
-
},
|
|
723
|
-
validateStatus: function(status) {
|
|
724
|
-
return status >= 200 && status < 300;
|
|
725
|
-
},
|
|
726
|
-
headers: {
|
|
727
|
-
common: {
|
|
728
|
-
Accept: "application/json, text/plain, */*",
|
|
729
|
-
"Content-Type": void 0
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
utils.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
|
|
734
|
-
defaults.headers[method] = {};
|
|
735
|
-
});
|
|
736
|
-
const defaults$1 = defaults, ignoreDuplicateOf = utils.toObjectSet([
|
|
737
|
-
"age",
|
|
738
|
-
"authorization",
|
|
739
|
-
"content-length",
|
|
740
|
-
"content-type",
|
|
741
|
-
"etag",
|
|
742
|
-
"expires",
|
|
743
|
-
"from",
|
|
744
|
-
"host",
|
|
745
|
-
"if-modified-since",
|
|
746
|
-
"if-unmodified-since",
|
|
747
|
-
"last-modified",
|
|
748
|
-
"location",
|
|
749
|
-
"max-forwards",
|
|
750
|
-
"proxy-authorization",
|
|
751
|
-
"referer",
|
|
752
|
-
"retry-after",
|
|
753
|
-
"user-agent"
|
|
754
|
-
]), parseHeaders = (rawHeaders) => {
|
|
755
|
-
const parsed = {};
|
|
756
|
-
let key, val, i;
|
|
757
|
-
return rawHeaders && rawHeaders.split(`
|
|
758
|
-
`).forEach(function(line) {
|
|
759
|
-
i = line.indexOf(":"), key = line.substring(0, i).trim().toLowerCase(), val = line.substring(i + 1).trim(), !(!key || parsed[key] && ignoreDuplicateOf[key]) && (key === "set-cookie" ? parsed[key] ? parsed[key].push(val) : parsed[key] = [val] : parsed[key] = parsed[key] ? parsed[key] + ", " + val : val);
|
|
760
|
-
}), parsed;
|
|
761
|
-
}, $internals = Symbol("internals");
|
|
762
|
-
function normalizeHeader(header) {
|
|
763
|
-
return header && String(header).trim().toLowerCase();
|
|
764
|
-
}
|
|
765
|
-
function normalizeValue(value) {
|
|
766
|
-
return value === !1 || value == null ? value : utils.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
767
|
-
}
|
|
768
|
-
function parseTokens(str) {
|
|
769
|
-
const tokens = /* @__PURE__ */ Object.create(null), tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
770
|
-
let match;
|
|
771
|
-
for (; match = tokensRE.exec(str); )
|
|
772
|
-
tokens[match[1]] = match[2];
|
|
773
|
-
return tokens;
|
|
774
|
-
}
|
|
775
|
-
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
776
|
-
function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
|
|
777
|
-
if (utils.isFunction(filter2))
|
|
778
|
-
return filter2.call(this, value, header);
|
|
779
|
-
if (isHeaderNameFilter && (value = header), !!utils.isString(value)) {
|
|
780
|
-
if (utils.isString(filter2))
|
|
781
|
-
return value.indexOf(filter2) !== -1;
|
|
782
|
-
if (utils.isRegExp(filter2))
|
|
783
|
-
return filter2.test(value);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
function formatHeader(header) {
|
|
787
|
-
return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => char.toUpperCase() + str);
|
|
788
|
-
}
|
|
789
|
-
function buildAccessors(obj, header) {
|
|
790
|
-
const accessorName = utils.toCamelCase(" " + header);
|
|
791
|
-
["get", "set", "has"].forEach((methodName) => {
|
|
792
|
-
Object.defineProperty(obj, methodName + accessorName, {
|
|
793
|
-
value: function(arg1, arg2, arg3) {
|
|
794
|
-
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
795
|
-
},
|
|
796
|
-
configurable: !0
|
|
797
|
-
});
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
class AxiosHeaders {
|
|
801
|
-
constructor(headers) {
|
|
802
|
-
headers && this.set(headers);
|
|
803
|
-
}
|
|
804
|
-
set(header, valueOrRewrite, rewrite) {
|
|
805
|
-
const self2 = this;
|
|
806
|
-
function setHeader(_value, _header, _rewrite) {
|
|
807
|
-
const lHeader = normalizeHeader(_header);
|
|
808
|
-
if (!lHeader)
|
|
809
|
-
throw new Error("header name must be a non-empty string");
|
|
810
|
-
const key = utils.findKey(self2, lHeader);
|
|
811
|
-
(!key || self2[key] === void 0 || _rewrite === !0 || _rewrite === void 0 && self2[key] !== !1) && (self2[key || _header] = normalizeValue(_value));
|
|
812
|
-
}
|
|
813
|
-
const setHeaders = (headers, _rewrite) => utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
814
|
-
return utils.isPlainObject(header) || header instanceof this.constructor ? setHeaders(header, valueOrRewrite) : utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header) ? setHeaders(parseHeaders(header), valueOrRewrite) : header != null && setHeader(valueOrRewrite, header, rewrite), this;
|
|
815
|
-
}
|
|
816
|
-
get(header, parser) {
|
|
817
|
-
if (header = normalizeHeader(header), header) {
|
|
818
|
-
const key = utils.findKey(this, header);
|
|
819
|
-
if (key) {
|
|
820
|
-
const value = this[key];
|
|
821
|
-
if (!parser)
|
|
822
|
-
return value;
|
|
823
|
-
if (parser === !0)
|
|
824
|
-
return parseTokens(value);
|
|
825
|
-
if (utils.isFunction(parser))
|
|
826
|
-
return parser.call(this, value, key);
|
|
827
|
-
if (utils.isRegExp(parser))
|
|
828
|
-
return parser.exec(value);
|
|
829
|
-
throw new TypeError("parser must be boolean|regexp|function");
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
has(header, matcher) {
|
|
834
|
-
if (header = normalizeHeader(header), header) {
|
|
835
|
-
const key = utils.findKey(this, header);
|
|
836
|
-
return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
837
|
-
}
|
|
838
|
-
return !1;
|
|
839
|
-
}
|
|
840
|
-
delete(header, matcher) {
|
|
841
|
-
const self2 = this;
|
|
842
|
-
let deleted = !1;
|
|
843
|
-
function deleteHeader(_header) {
|
|
844
|
-
if (_header = normalizeHeader(_header), _header) {
|
|
845
|
-
const key = utils.findKey(self2, _header);
|
|
846
|
-
key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher)) && (delete self2[key], deleted = !0);
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
return utils.isArray(header) ? header.forEach(deleteHeader) : deleteHeader(header), deleted;
|
|
850
|
-
}
|
|
851
|
-
clear(matcher) {
|
|
852
|
-
const keys = Object.keys(this);
|
|
853
|
-
let i = keys.length, deleted = !1;
|
|
854
|
-
for (; i--; ) {
|
|
855
|
-
const key = keys[i];
|
|
856
|
-
(!matcher || matchHeaderValue(this, this[key], key, matcher, !0)) && (delete this[key], deleted = !0);
|
|
857
|
-
}
|
|
858
|
-
return deleted;
|
|
859
|
-
}
|
|
860
|
-
normalize(format) {
|
|
861
|
-
const self2 = this, headers = {};
|
|
862
|
-
return utils.forEach(this, (value, header) => {
|
|
863
|
-
const key = utils.findKey(headers, header);
|
|
864
|
-
if (key) {
|
|
865
|
-
self2[key] = normalizeValue(value), delete self2[header];
|
|
866
|
-
return;
|
|
867
|
-
}
|
|
868
|
-
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
869
|
-
normalized !== header && delete self2[header], self2[normalized] = normalizeValue(value), headers[normalized] = !0;
|
|
870
|
-
}), this;
|
|
871
|
-
}
|
|
872
|
-
concat(...targets) {
|
|
873
|
-
return this.constructor.concat(this, ...targets);
|
|
874
|
-
}
|
|
875
|
-
toJSON(asStrings) {
|
|
876
|
-
const obj = /* @__PURE__ */ Object.create(null);
|
|
877
|
-
return utils.forEach(this, (value, header) => {
|
|
878
|
-
value != null && value !== !1 && (obj[header] = asStrings && utils.isArray(value) ? value.join(", ") : value);
|
|
879
|
-
}), obj;
|
|
880
|
-
}
|
|
881
|
-
[Symbol.iterator]() {
|
|
882
|
-
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
883
|
-
}
|
|
884
|
-
toString() {
|
|
885
|
-
return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join(`
|
|
886
|
-
`);
|
|
887
|
-
}
|
|
888
|
-
get [Symbol.toStringTag]() {
|
|
889
|
-
return "AxiosHeaders";
|
|
890
|
-
}
|
|
891
|
-
static from(thing) {
|
|
892
|
-
return thing instanceof this ? thing : new this(thing);
|
|
893
|
-
}
|
|
894
|
-
static concat(first, ...targets) {
|
|
895
|
-
const computed = new this(first);
|
|
896
|
-
return targets.forEach((target) => computed.set(target)), computed;
|
|
897
|
-
}
|
|
898
|
-
static accessor(header) {
|
|
899
|
-
const accessors = (this[$internals] = this[$internals] = {
|
|
900
|
-
accessors: {}
|
|
901
|
-
}).accessors, prototype2 = this.prototype;
|
|
902
|
-
function defineAccessor(_header) {
|
|
903
|
-
const lHeader = normalizeHeader(_header);
|
|
904
|
-
accessors[lHeader] || (buildAccessors(prototype2, _header), accessors[lHeader] = !0);
|
|
905
|
-
}
|
|
906
|
-
return utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header), this;
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
AxiosHeaders.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
|
|
910
|
-
utils.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
|
|
911
|
-
let mapped = key[0].toUpperCase() + key.slice(1);
|
|
912
|
-
return {
|
|
913
|
-
get: () => value,
|
|
914
|
-
set(headerValue) {
|
|
915
|
-
this[mapped] = headerValue;
|
|
916
|
-
}
|
|
917
|
-
};
|
|
918
|
-
});
|
|
919
|
-
utils.freezeMethods(AxiosHeaders);
|
|
920
|
-
const AxiosHeaders$1 = AxiosHeaders;
|
|
921
|
-
function transformData(fns, response) {
|
|
922
|
-
const config = this || defaults$1, context = response || config, headers = AxiosHeaders$1.from(context.headers);
|
|
923
|
-
let data = context.data;
|
|
924
|
-
return utils.forEach(fns, function(fn) {
|
|
925
|
-
data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
|
|
926
|
-
}), headers.normalize(), data;
|
|
927
|
-
}
|
|
928
|
-
function isCancel(value) {
|
|
929
|
-
return !!(value && value.__CANCEL__);
|
|
930
|
-
}
|
|
931
|
-
function CanceledError(message, config, request) {
|
|
932
|
-
AxiosError.call(this, message ?? "canceled", AxiosError.ERR_CANCELED, config, request), this.name = "CanceledError";
|
|
933
|
-
}
|
|
934
|
-
utils.inherits(CanceledError, AxiosError, {
|
|
935
|
-
__CANCEL__: !0
|
|
936
|
-
});
|
|
937
|
-
function settle(resolve, reject, response) {
|
|
938
|
-
const validateStatus2 = response.config.validateStatus;
|
|
939
|
-
!response.status || !validateStatus2 || validateStatus2(response.status) ? resolve(response) : reject(new AxiosError(
|
|
940
|
-
"Request failed with status code " + response.status,
|
|
941
|
-
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
942
|
-
response.config,
|
|
943
|
-
response.request,
|
|
944
|
-
response
|
|
945
|
-
));
|
|
946
|
-
}
|
|
947
|
-
const cookies = platform.isStandardBrowserEnv ? (
|
|
948
|
-
// Standard browser envs support document.cookie
|
|
949
|
-
function() {
|
|
950
|
-
return {
|
|
951
|
-
write: function(name, value, expires, path, domain, secure) {
|
|
952
|
-
const cookie = [];
|
|
953
|
-
cookie.push(name + "=" + encodeURIComponent(value)), utils.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString()), utils.isString(path) && cookie.push("path=" + path), utils.isString(domain) && cookie.push("domain=" + domain), secure === !0 && cookie.push("secure"), document.cookie = cookie.join("; ");
|
|
954
|
-
},
|
|
955
|
-
read: function(name) {
|
|
956
|
-
const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
|
|
957
|
-
return match ? decodeURIComponent(match[3]) : null;
|
|
958
|
-
},
|
|
959
|
-
remove: function(name) {
|
|
960
|
-
this.write(name, "", Date.now() - 864e5);
|
|
961
|
-
}
|
|
962
|
-
};
|
|
963
|
-
}()
|
|
964
|
-
) : (
|
|
965
|
-
// Non standard browser env (web workers, react-native) lack needed support.
|
|
966
|
-
function() {
|
|
967
|
-
return {
|
|
968
|
-
write: function() {
|
|
969
|
-
},
|
|
970
|
-
read: function() {
|
|
971
|
-
return null;
|
|
972
|
-
},
|
|
973
|
-
remove: function() {
|
|
974
|
-
}
|
|
975
|
-
};
|
|
976
|
-
}()
|
|
977
|
-
);
|
|
978
|
-
function isAbsoluteURL(url) {
|
|
979
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
980
|
-
}
|
|
981
|
-
function combineURLs(baseURL, relativeURL) {
|
|
982
|
-
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
983
|
-
}
|
|
984
|
-
function buildFullPath(baseURL, requestedURL) {
|
|
985
|
-
return baseURL && !isAbsoluteURL(requestedURL) ? combineURLs(baseURL, requestedURL) : requestedURL;
|
|
986
|
-
}
|
|
987
|
-
const isURLSameOrigin = platform.isStandardBrowserEnv ? (
|
|
988
|
-
// Standard browser envs have full support of the APIs needed to test
|
|
989
|
-
// whether the request URL is of the same origin as current location.
|
|
990
|
-
function() {
|
|
991
|
-
const msie = /(msie|trident)/i.test(navigator.userAgent), urlParsingNode = document.createElement("a");
|
|
992
|
-
let originURL;
|
|
993
|
-
function resolveURL(url) {
|
|
994
|
-
let href = url;
|
|
995
|
-
return msie && (urlParsingNode.setAttribute("href", href), href = urlParsingNode.href), urlParsingNode.setAttribute("href", href), {
|
|
996
|
-
href: urlParsingNode.href,
|
|
997
|
-
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
|
|
998
|
-
host: urlParsingNode.host,
|
|
999
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
|
|
1000
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
|
|
1001
|
-
hostname: urlParsingNode.hostname,
|
|
1002
|
-
port: urlParsingNode.port,
|
|
1003
|
-
pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
|
|
1004
|
-
};
|
|
1005
|
-
}
|
|
1006
|
-
return originURL = resolveURL(window.location.href), function(requestURL) {
|
|
1007
|
-
const parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
|
1008
|
-
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
|
1009
|
-
};
|
|
1010
|
-
}()
|
|
1011
|
-
) : (
|
|
1012
|
-
// Non standard browser envs (web workers, react-native) lack needed support.
|
|
1013
|
-
function() {
|
|
1014
|
-
return function() {
|
|
1015
|
-
return !0;
|
|
1016
|
-
};
|
|
1017
|
-
}()
|
|
1018
|
-
);
|
|
1019
|
-
function parseProtocol(url) {
|
|
1020
|
-
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
1021
|
-
return match && match[1] || "";
|
|
1022
|
-
}
|
|
1023
|
-
function speedometer(samplesCount, min) {
|
|
1024
|
-
samplesCount = samplesCount || 10;
|
|
1025
|
-
const bytes = new Array(samplesCount), timestamps = new Array(samplesCount);
|
|
1026
|
-
let head = 0, tail = 0, firstSampleTS;
|
|
1027
|
-
return min = min !== void 0 ? min : 1e3, function(chunkLength) {
|
|
1028
|
-
const now = Date.now(), startedAt = timestamps[tail];
|
|
1029
|
-
firstSampleTS || (firstSampleTS = now), bytes[head] = chunkLength, timestamps[head] = now;
|
|
1030
|
-
let i = tail, bytesCount = 0;
|
|
1031
|
-
for (; i !== head; )
|
|
1032
|
-
bytesCount += bytes[i++], i = i % samplesCount;
|
|
1033
|
-
if (head = (head + 1) % samplesCount, head === tail && (tail = (tail + 1) % samplesCount), now - firstSampleTS < min)
|
|
1034
|
-
return;
|
|
1035
|
-
const passed = startedAt && now - startedAt;
|
|
1036
|
-
return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
|
|
1037
|
-
};
|
|
1038
|
-
}
|
|
1039
|
-
function progressEventReducer(listener, isDownloadStream) {
|
|
1040
|
-
let bytesNotified = 0;
|
|
1041
|
-
const _speedometer = speedometer(50, 250);
|
|
1042
|
-
return (e) => {
|
|
1043
|
-
const loaded = e.loaded, total = e.lengthComputable ? e.total : void 0, progressBytes = loaded - bytesNotified, rate = _speedometer(progressBytes), inRange = loaded <= total;
|
|
1044
|
-
bytesNotified = loaded;
|
|
1045
|
-
const data = {
|
|
1046
|
-
loaded,
|
|
1047
|
-
total,
|
|
1048
|
-
progress: total ? loaded / total : void 0,
|
|
1049
|
-
bytes: progressBytes,
|
|
1050
|
-
rate: rate || void 0,
|
|
1051
|
-
estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
|
|
1052
|
-
event: e
|
|
1053
|
-
};
|
|
1054
|
-
data[isDownloadStream ? "download" : "upload"] = !0, listener(data);
|
|
1055
|
-
};
|
|
1056
|
-
}
|
|
1057
|
-
const isXHRAdapterSupported = typeof XMLHttpRequest < "u", xhrAdapter = isXHRAdapterSupported && function(config) {
|
|
1058
|
-
return new Promise(function(resolve, reject) {
|
|
1059
|
-
let requestData = config.data;
|
|
1060
|
-
const requestHeaders = AxiosHeaders$1.from(config.headers).normalize(), responseType = config.responseType;
|
|
1061
|
-
let onCanceled;
|
|
1062
|
-
function done() {
|
|
1063
|
-
config.cancelToken && config.cancelToken.unsubscribe(onCanceled), config.signal && config.signal.removeEventListener("abort", onCanceled);
|
|
1064
|
-
}
|
|
1065
|
-
let contentType;
|
|
1066
|
-
utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv ? requestHeaders.setContentType(!1) : requestHeaders.getContentType(/^\s*multipart\/form-data/) ? utils.isString(contentType = requestHeaders.getContentType()) && requestHeaders.setContentType(contentType.replace(/^\s*(multipart\/form-data);+/, "$1")) : requestHeaders.setContentType("multipart/form-data"));
|
|
1067
|
-
let request = new XMLHttpRequest();
|
|
1068
|
-
if (config.auth) {
|
|
1069
|
-
const username = config.auth.username || "", password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
|
|
1070
|
-
requestHeaders.set("Authorization", "Basic " + btoa(username + ":" + password));
|
|
1071
|
-
}
|
|
1072
|
-
const fullPath = buildFullPath(config.baseURL, config.url);
|
|
1073
|
-
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), !0), request.timeout = config.timeout;
|
|
1074
|
-
function onloadend() {
|
|
1075
|
-
if (!request)
|
|
1076
|
-
return;
|
|
1077
|
-
const responseHeaders = AxiosHeaders$1.from(
|
|
1078
|
-
"getAllResponseHeaders" in request && request.getAllResponseHeaders()
|
|
1079
|
-
), response = {
|
|
1080
|
-
data: !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response,
|
|
1081
|
-
status: request.status,
|
|
1082
|
-
statusText: request.statusText,
|
|
1083
|
-
headers: responseHeaders,
|
|
1084
|
-
config,
|
|
1085
|
-
request
|
|
1086
|
-
};
|
|
1087
|
-
settle(function(value) {
|
|
1088
|
-
resolve(value), done();
|
|
1089
|
-
}, function(err) {
|
|
1090
|
-
reject(err), done();
|
|
1091
|
-
}, response), request = null;
|
|
1092
|
-
}
|
|
1093
|
-
if ("onloadend" in request ? request.onloadend = onloadend : request.onreadystatechange = function() {
|
|
1094
|
-
!request || request.readyState !== 4 || request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0) || setTimeout(onloadend);
|
|
1095
|
-
}, request.onabort = function() {
|
|
1096
|
-
request && (reject(new AxiosError("Request aborted", AxiosError.ECONNABORTED, config, request)), request = null);
|
|
1097
|
-
}, request.onerror = function() {
|
|
1098
|
-
reject(new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request)), request = null;
|
|
1099
|
-
}, request.ontimeout = function() {
|
|
1100
|
-
let timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded";
|
|
1101
|
-
const transitional2 = config.transitional || transitionalDefaults;
|
|
1102
|
-
config.timeoutErrorMessage && (timeoutErrorMessage = config.timeoutErrorMessage), reject(new AxiosError(
|
|
1103
|
-
timeoutErrorMessage,
|
|
1104
|
-
transitional2.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
|
1105
|
-
config,
|
|
1106
|
-
request
|
|
1107
|
-
)), request = null;
|
|
1108
|
-
}, platform.isStandardBrowserEnv) {
|
|
1109
|
-
const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
|
1110
|
-
xsrfValue && requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
|
1111
|
-
}
|
|
1112
|
-
requestData === void 0 && requestHeaders.setContentType(null), "setRequestHeader" in request && utils.forEach(requestHeaders.toJSON(), function(val, key) {
|
|
1113
|
-
request.setRequestHeader(key, val);
|
|
1114
|
-
}), utils.isUndefined(config.withCredentials) || (request.withCredentials = !!config.withCredentials), responseType && responseType !== "json" && (request.responseType = config.responseType), typeof config.onDownloadProgress == "function" && request.addEventListener("progress", progressEventReducer(config.onDownloadProgress, !0)), typeof config.onUploadProgress == "function" && request.upload && request.upload.addEventListener("progress", progressEventReducer(config.onUploadProgress)), (config.cancelToken || config.signal) && (onCanceled = (cancel) => {
|
|
1115
|
-
request && (reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel), request.abort(), request = null);
|
|
1116
|
-
}, config.cancelToken && config.cancelToken.subscribe(onCanceled), config.signal && (config.signal.aborted ? onCanceled() : config.signal.addEventListener("abort", onCanceled)));
|
|
1117
|
-
const protocol = parseProtocol(fullPath);
|
|
1118
|
-
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
1119
|
-
reject(new AxiosError("Unsupported protocol " + protocol + ":", AxiosError.ERR_BAD_REQUEST, config));
|
|
1120
|
-
return;
|
|
1121
|
-
}
|
|
1122
|
-
request.send(requestData || null);
|
|
1123
|
-
});
|
|
1124
|
-
}, knownAdapters = {
|
|
1125
|
-
http: httpAdapter,
|
|
1126
|
-
xhr: xhrAdapter
|
|
1127
|
-
};
|
|
1128
|
-
utils.forEach(knownAdapters, (fn, value) => {
|
|
1129
|
-
if (fn) {
|
|
1130
|
-
try {
|
|
1131
|
-
Object.defineProperty(fn, "name", { value });
|
|
1132
|
-
} catch {
|
|
1133
|
-
}
|
|
1134
|
-
Object.defineProperty(fn, "adapterName", { value });
|
|
1135
|
-
}
|
|
1136
|
-
});
|
|
1137
|
-
const renderReason = (reason) => `- ${reason}`, isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === !1, adapters = {
|
|
1138
|
-
getAdapter: (adapters2) => {
|
|
1139
|
-
adapters2 = utils.isArray(adapters2) ? adapters2 : [adapters2];
|
|
1140
|
-
const { length } = adapters2;
|
|
1141
|
-
let nameOrAdapter, adapter;
|
|
1142
|
-
const rejectedReasons = {};
|
|
1143
|
-
for (let i = 0; i < length; i++) {
|
|
1144
|
-
nameOrAdapter = adapters2[i];
|
|
1145
|
-
let id;
|
|
1146
|
-
if (adapter = nameOrAdapter, !isResolvedHandle(nameOrAdapter) && (adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()], adapter === void 0))
|
|
1147
|
-
throw new AxiosError(`Unknown adapter '${id}'`);
|
|
1148
|
-
if (adapter)
|
|
1149
|
-
break;
|
|
1150
|
-
rejectedReasons[id || "#" + i] = adapter;
|
|
1151
|
-
}
|
|
1152
|
-
if (!adapter) {
|
|
1153
|
-
const reasons = Object.entries(rejectedReasons).map(
|
|
1154
|
-
([id, state]) => `adapter ${id} ` + (state === !1 ? "is not supported by the environment" : "is not available in the build")
|
|
1155
|
-
);
|
|
1156
|
-
let s = length ? reasons.length > 1 ? `since :
|
|
1157
|
-
` + reasons.map(renderReason).join(`
|
|
1158
|
-
`) : " " + renderReason(reasons[0]) : "as no adapter specified";
|
|
1159
|
-
throw new AxiosError(
|
|
1160
|
-
"There is no suitable adapter to dispatch the request " + s,
|
|
1161
|
-
"ERR_NOT_SUPPORT"
|
|
1162
|
-
);
|
|
1163
|
-
}
|
|
1164
|
-
return adapter;
|
|
1165
|
-
},
|
|
1166
|
-
adapters: knownAdapters
|
|
1167
|
-
};
|
|
1168
|
-
function throwIfCancellationRequested(config) {
|
|
1169
|
-
if (config.cancelToken && config.cancelToken.throwIfRequested(), config.signal && config.signal.aborted)
|
|
1170
|
-
throw new CanceledError(null, config);
|
|
1171
|
-
}
|
|
1172
|
-
function dispatchRequest(config) {
|
|
1173
|
-
return throwIfCancellationRequested(config), config.headers = AxiosHeaders$1.from(config.headers), config.data = transformData.call(
|
|
1174
|
-
config,
|
|
1175
|
-
config.transformRequest
|
|
1176
|
-
), ["post", "put", "patch"].indexOf(config.method) !== -1 && config.headers.setContentType("application/x-www-form-urlencoded", !1), adapters.getAdapter(config.adapter || defaults$1.adapter)(config).then(function(response) {
|
|
1177
|
-
return throwIfCancellationRequested(config), response.data = transformData.call(
|
|
1178
|
-
config,
|
|
1179
|
-
config.transformResponse,
|
|
1180
|
-
response
|
|
1181
|
-
), response.headers = AxiosHeaders$1.from(response.headers), response;
|
|
1182
|
-
}, function(reason) {
|
|
1183
|
-
return isCancel(reason) || (throwIfCancellationRequested(config), reason && reason.response && (reason.response.data = transformData.call(
|
|
1184
|
-
config,
|
|
1185
|
-
config.transformResponse,
|
|
1186
|
-
reason.response
|
|
1187
|
-
), reason.response.headers = AxiosHeaders$1.from(reason.response.headers))), Promise.reject(reason);
|
|
1188
|
-
});
|
|
1189
|
-
}
|
|
1190
|
-
const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
|
|
1191
|
-
function mergeConfig(config1, config2) {
|
|
1192
|
-
config2 = config2 || {};
|
|
1193
|
-
const config = {};
|
|
1194
|
-
function getMergedValue(target, source, caseless) {
|
|
1195
|
-
return utils.isPlainObject(target) && utils.isPlainObject(source) ? utils.merge.call({ caseless }, target, source) : utils.isPlainObject(source) ? utils.merge({}, source) : utils.isArray(source) ? source.slice() : source;
|
|
1196
|
-
}
|
|
1197
|
-
function mergeDeepProperties(a, b, caseless) {
|
|
1198
|
-
if (utils.isUndefined(b)) {
|
|
1199
|
-
if (!utils.isUndefined(a))
|
|
1200
|
-
return getMergedValue(void 0, a, caseless);
|
|
1201
|
-
} else
|
|
1202
|
-
return getMergedValue(a, b, caseless);
|
|
1203
|
-
}
|
|
1204
|
-
function valueFromConfig2(a, b) {
|
|
1205
|
-
if (!utils.isUndefined(b))
|
|
1206
|
-
return getMergedValue(void 0, b);
|
|
1207
|
-
}
|
|
1208
|
-
function defaultToConfig2(a, b) {
|
|
1209
|
-
if (utils.isUndefined(b)) {
|
|
1210
|
-
if (!utils.isUndefined(a))
|
|
1211
|
-
return getMergedValue(void 0, a);
|
|
1212
|
-
} else
|
|
1213
|
-
return getMergedValue(void 0, b);
|
|
1214
|
-
}
|
|
1215
|
-
function mergeDirectKeys(a, b, prop) {
|
|
1216
|
-
if (prop in config2)
|
|
1217
|
-
return getMergedValue(a, b);
|
|
1218
|
-
if (prop in config1)
|
|
1219
|
-
return getMergedValue(void 0, a);
|
|
1220
|
-
}
|
|
1221
|
-
const mergeMap = {
|
|
1222
|
-
url: valueFromConfig2,
|
|
1223
|
-
method: valueFromConfig2,
|
|
1224
|
-
data: valueFromConfig2,
|
|
1225
|
-
baseURL: defaultToConfig2,
|
|
1226
|
-
transformRequest: defaultToConfig2,
|
|
1227
|
-
transformResponse: defaultToConfig2,
|
|
1228
|
-
paramsSerializer: defaultToConfig2,
|
|
1229
|
-
timeout: defaultToConfig2,
|
|
1230
|
-
timeoutMessage: defaultToConfig2,
|
|
1231
|
-
withCredentials: defaultToConfig2,
|
|
1232
|
-
adapter: defaultToConfig2,
|
|
1233
|
-
responseType: defaultToConfig2,
|
|
1234
|
-
xsrfCookieName: defaultToConfig2,
|
|
1235
|
-
xsrfHeaderName: defaultToConfig2,
|
|
1236
|
-
onUploadProgress: defaultToConfig2,
|
|
1237
|
-
onDownloadProgress: defaultToConfig2,
|
|
1238
|
-
decompress: defaultToConfig2,
|
|
1239
|
-
maxContentLength: defaultToConfig2,
|
|
1240
|
-
maxBodyLength: defaultToConfig2,
|
|
1241
|
-
beforeRedirect: defaultToConfig2,
|
|
1242
|
-
transport: defaultToConfig2,
|
|
1243
|
-
httpAgent: defaultToConfig2,
|
|
1244
|
-
httpsAgent: defaultToConfig2,
|
|
1245
|
-
cancelToken: defaultToConfig2,
|
|
1246
|
-
socketPath: defaultToConfig2,
|
|
1247
|
-
responseEncoding: defaultToConfig2,
|
|
1248
|
-
validateStatus: mergeDirectKeys,
|
|
1249
|
-
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), !0)
|
|
1250
|
-
};
|
|
1251
|
-
return utils.forEach(Object.keys(Object.assign({}, config1, config2)), function(prop) {
|
|
1252
|
-
const merge2 = mergeMap[prop] || mergeDeepProperties, configValue = merge2(config1[prop], config2[prop], prop);
|
|
1253
|
-
utils.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
|
|
1254
|
-
}), config;
|
|
1255
|
-
}
|
|
1256
|
-
const VERSION = "1.5.1", validators$1 = {};
|
|
1257
|
-
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
|
|
1258
|
-
validators$1[type] = function(thing) {
|
|
1259
|
-
return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
|
|
1260
|
-
};
|
|
1261
|
-
});
|
|
1262
|
-
const deprecatedWarnings = {};
|
|
1263
|
-
validators$1.transitional = function(validator2, version, message) {
|
|
1264
|
-
function formatMessage(opt, desc) {
|
|
1265
|
-
return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
1266
|
-
}
|
|
1267
|
-
return (value, opt, opts) => {
|
|
1268
|
-
if (validator2 === !1)
|
|
1269
|
-
throw new AxiosError(
|
|
1270
|
-
formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
|
|
1271
|
-
AxiosError.ERR_DEPRECATED
|
|
1272
|
-
);
|
|
1273
|
-
return version && !deprecatedWarnings[opt] && (deprecatedWarnings[opt] = !0, console.warn(
|
|
1274
|
-
formatMessage(
|
|
1275
|
-
opt,
|
|
1276
|
-
" has been deprecated since v" + version + " and will be removed in the near future"
|
|
1277
|
-
)
|
|
1278
|
-
)), validator2 ? validator2(value, opt, opts) : !0;
|
|
1279
|
-
};
|
|
1280
|
-
};
|
|
1281
|
-
function assertOptions(options, schema, allowUnknown) {
|
|
1282
|
-
if (typeof options != "object")
|
|
1283
|
-
throw new AxiosError("options must be an object", AxiosError.ERR_BAD_OPTION_VALUE);
|
|
1284
|
-
const keys = Object.keys(options);
|
|
1285
|
-
let i = keys.length;
|
|
1286
|
-
for (; i-- > 0; ) {
|
|
1287
|
-
const opt = keys[i], validator2 = schema[opt];
|
|
1288
|
-
if (validator2) {
|
|
1289
|
-
const value = options[opt], result = value === void 0 || validator2(value, opt, options);
|
|
1290
|
-
if (result !== !0)
|
|
1291
|
-
throw new AxiosError("option " + opt + " must be " + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
|
1292
|
-
continue;
|
|
1293
|
-
}
|
|
1294
|
-
if (allowUnknown !== !0)
|
|
1295
|
-
throw new AxiosError("Unknown option " + opt, AxiosError.ERR_BAD_OPTION);
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
const validator = {
|
|
1299
|
-
assertOptions,
|
|
1300
|
-
validators: validators$1
|
|
1301
|
-
}, validators = validator.validators;
|
|
1302
|
-
class Axios {
|
|
1303
|
-
constructor(instanceConfig) {
|
|
1304
|
-
this.defaults = instanceConfig, this.interceptors = {
|
|
1305
|
-
request: new InterceptorManager$1(),
|
|
1306
|
-
response: new InterceptorManager$1()
|
|
1307
|
-
};
|
|
1308
|
-
}
|
|
1309
|
-
/**
|
|
1310
|
-
* Dispatch a request
|
|
1311
|
-
*
|
|
1312
|
-
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|
1313
|
-
* @param {?Object} config
|
|
1314
|
-
*
|
|
1315
|
-
* @returns {Promise} The Promise to be fulfilled
|
|
1316
|
-
*/
|
|
1317
|
-
request(configOrUrl, config) {
|
|
1318
|
-
typeof configOrUrl == "string" ? (config = config || {}, config.url = configOrUrl) : config = configOrUrl || {}, config = mergeConfig(this.defaults, config);
|
|
1319
|
-
const { transitional: transitional2, paramsSerializer, headers } = config;
|
|
1320
|
-
transitional2 !== void 0 && validator.assertOptions(transitional2, {
|
|
1321
|
-
silentJSONParsing: validators.transitional(validators.boolean),
|
|
1322
|
-
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
1323
|
-
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
1324
|
-
}, !1), paramsSerializer != null && (utils.isFunction(paramsSerializer) ? config.paramsSerializer = {
|
|
1325
|
-
serialize: paramsSerializer
|
|
1326
|
-
} : validator.assertOptions(paramsSerializer, {
|
|
1327
|
-
encode: validators.function,
|
|
1328
|
-
serialize: validators.function
|
|
1329
|
-
}, !0)), config.method = (config.method || this.defaults.method || "get").toLowerCase();
|
|
1330
|
-
let contextHeaders = headers && utils.merge(
|
|
1331
|
-
headers.common,
|
|
1332
|
-
headers[config.method]
|
|
1333
|
-
);
|
|
1334
|
-
headers && utils.forEach(
|
|
1335
|
-
["delete", "get", "head", "post", "put", "patch", "common"],
|
|
1336
|
-
(method) => {
|
|
1337
|
-
delete headers[method];
|
|
1338
|
-
}
|
|
1339
|
-
), config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
|
1340
|
-
const requestInterceptorChain = [];
|
|
1341
|
-
let synchronousRequestInterceptors = !0;
|
|
1342
|
-
this.interceptors.request.forEach(function(interceptor) {
|
|
1343
|
-
typeof interceptor.runWhen == "function" && interceptor.runWhen(config) === !1 || (synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous, requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected));
|
|
1344
|
-
});
|
|
1345
|
-
const responseInterceptorChain = [];
|
|
1346
|
-
this.interceptors.response.forEach(function(interceptor) {
|
|
1347
|
-
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
1348
|
-
});
|
|
1349
|
-
let promise, i = 0, len;
|
|
1350
|
-
if (!synchronousRequestInterceptors) {
|
|
1351
|
-
const chain = [dispatchRequest.bind(this), void 0];
|
|
1352
|
-
for (chain.unshift.apply(chain, requestInterceptorChain), chain.push.apply(chain, responseInterceptorChain), len = chain.length, promise = Promise.resolve(config); i < len; )
|
|
1353
|
-
promise = promise.then(chain[i++], chain[i++]);
|
|
1354
|
-
return promise;
|
|
1355
|
-
}
|
|
1356
|
-
len = requestInterceptorChain.length;
|
|
1357
|
-
let newConfig = config;
|
|
1358
|
-
for (i = 0; i < len; ) {
|
|
1359
|
-
const onFulfilled = requestInterceptorChain[i++], onRejected = requestInterceptorChain[i++];
|
|
1360
|
-
try {
|
|
1361
|
-
newConfig = onFulfilled(newConfig);
|
|
1362
|
-
} catch (error) {
|
|
1363
|
-
onRejected.call(this, error);
|
|
1364
|
-
break;
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
try {
|
|
1368
|
-
promise = dispatchRequest.call(this, newConfig);
|
|
1369
|
-
} catch (error) {
|
|
1370
|
-
return Promise.reject(error);
|
|
1371
|
-
}
|
|
1372
|
-
for (i = 0, len = responseInterceptorChain.length; i < len; )
|
|
1373
|
-
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
|
1374
|
-
return promise;
|
|
1375
|
-
}
|
|
1376
|
-
getUri(config) {
|
|
1377
|
-
config = mergeConfig(this.defaults, config);
|
|
1378
|
-
const fullPath = buildFullPath(config.baseURL, config.url);
|
|
1379
|
-
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
utils.forEach(["delete", "get", "head", "options"], function(method) {
|
|
1383
|
-
Axios.prototype[method] = function(url, config) {
|
|
1384
|
-
return this.request(mergeConfig(config || {}, {
|
|
1385
|
-
method,
|
|
1386
|
-
url,
|
|
1387
|
-
data: (config || {}).data
|
|
1388
|
-
}));
|
|
1389
|
-
};
|
|
1390
|
-
});
|
|
1391
|
-
utils.forEach(["post", "put", "patch"], function(method) {
|
|
1392
|
-
function generateHTTPMethod(isForm) {
|
|
1393
|
-
return function(url, data, config) {
|
|
1394
|
-
return this.request(mergeConfig(config || {}, {
|
|
1395
|
-
method,
|
|
1396
|
-
headers: isForm ? {
|
|
1397
|
-
"Content-Type": "multipart/form-data"
|
|
1398
|
-
} : {},
|
|
1399
|
-
url,
|
|
1400
|
-
data
|
|
1401
|
-
}));
|
|
1402
|
-
};
|
|
1403
|
-
}
|
|
1404
|
-
Axios.prototype[method] = generateHTTPMethod(), Axios.prototype[method + "Form"] = generateHTTPMethod(!0);
|
|
1405
|
-
});
|
|
1406
|
-
const Axios$1 = Axios;
|
|
1407
|
-
class CancelToken {
|
|
1408
|
-
constructor(executor) {
|
|
1409
|
-
if (typeof executor != "function")
|
|
1410
|
-
throw new TypeError("executor must be a function.");
|
|
1411
|
-
let resolvePromise;
|
|
1412
|
-
this.promise = new Promise(function(resolve) {
|
|
1413
|
-
resolvePromise = resolve;
|
|
1414
|
-
});
|
|
1415
|
-
const token = this;
|
|
1416
|
-
this.promise.then((cancel) => {
|
|
1417
|
-
if (!token._listeners)
|
|
1418
|
-
return;
|
|
1419
|
-
let i = token._listeners.length;
|
|
1420
|
-
for (; i-- > 0; )
|
|
1421
|
-
token._listeners[i](cancel);
|
|
1422
|
-
token._listeners = null;
|
|
1423
|
-
}), this.promise.then = (onfulfilled) => {
|
|
1424
|
-
let _resolve;
|
|
1425
|
-
const promise = new Promise((resolve) => {
|
|
1426
|
-
token.subscribe(resolve), _resolve = resolve;
|
|
1427
|
-
}).then(onfulfilled);
|
|
1428
|
-
return promise.cancel = function() {
|
|
1429
|
-
token.unsubscribe(_resolve);
|
|
1430
|
-
}, promise;
|
|
1431
|
-
}, executor(function(message, config, request) {
|
|
1432
|
-
token.reason || (token.reason = new CanceledError(message, config, request), resolvePromise(token.reason));
|
|
1433
|
-
});
|
|
1434
|
-
}
|
|
1435
|
-
/**
|
|
1436
|
-
* Throws a `CanceledError` if cancellation has been requested.
|
|
1437
|
-
*/
|
|
1438
|
-
throwIfRequested() {
|
|
1439
|
-
if (this.reason)
|
|
1440
|
-
throw this.reason;
|
|
1441
|
-
}
|
|
1442
|
-
/**
|
|
1443
|
-
* Subscribe to the cancel signal
|
|
1444
|
-
*/
|
|
1445
|
-
subscribe(listener) {
|
|
1446
|
-
if (this.reason) {
|
|
1447
|
-
listener(this.reason);
|
|
1448
|
-
return;
|
|
1449
|
-
}
|
|
1450
|
-
this._listeners ? this._listeners.push(listener) : this._listeners = [listener];
|
|
1451
|
-
}
|
|
1452
|
-
/**
|
|
1453
|
-
* Unsubscribe from the cancel signal
|
|
1454
|
-
*/
|
|
1455
|
-
unsubscribe(listener) {
|
|
1456
|
-
if (!this._listeners)
|
|
1457
|
-
return;
|
|
1458
|
-
const index = this._listeners.indexOf(listener);
|
|
1459
|
-
index !== -1 && this._listeners.splice(index, 1);
|
|
1460
|
-
}
|
|
1461
|
-
/**
|
|
1462
|
-
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
1463
|
-
* cancels the `CancelToken`.
|
|
1464
|
-
*/
|
|
1465
|
-
static source() {
|
|
1466
|
-
let cancel;
|
|
1467
|
-
return {
|
|
1468
|
-
token: new CancelToken(function(c) {
|
|
1469
|
-
cancel = c;
|
|
1470
|
-
}),
|
|
1471
|
-
cancel
|
|
1472
|
-
};
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
const CancelToken$1 = CancelToken;
|
|
1476
|
-
function spread(callback) {
|
|
1477
|
-
return function(arr) {
|
|
1478
|
-
return callback.apply(null, arr);
|
|
1479
|
-
};
|
|
1480
|
-
}
|
|
1481
|
-
function isAxiosError(payload) {
|
|
1482
|
-
return utils.isObject(payload) && payload.isAxiosError === !0;
|
|
1483
|
-
}
|
|
1484
|
-
const HttpStatusCode = {
|
|
1485
|
-
Continue: 100,
|
|
1486
|
-
SwitchingProtocols: 101,
|
|
1487
|
-
Processing: 102,
|
|
1488
|
-
EarlyHints: 103,
|
|
1489
|
-
Ok: 200,
|
|
1490
|
-
Created: 201,
|
|
1491
|
-
Accepted: 202,
|
|
1492
|
-
NonAuthoritativeInformation: 203,
|
|
1493
|
-
NoContent: 204,
|
|
1494
|
-
ResetContent: 205,
|
|
1495
|
-
PartialContent: 206,
|
|
1496
|
-
MultiStatus: 207,
|
|
1497
|
-
AlreadyReported: 208,
|
|
1498
|
-
ImUsed: 226,
|
|
1499
|
-
MultipleChoices: 300,
|
|
1500
|
-
MovedPermanently: 301,
|
|
1501
|
-
Found: 302,
|
|
1502
|
-
SeeOther: 303,
|
|
1503
|
-
NotModified: 304,
|
|
1504
|
-
UseProxy: 305,
|
|
1505
|
-
Unused: 306,
|
|
1506
|
-
TemporaryRedirect: 307,
|
|
1507
|
-
PermanentRedirect: 308,
|
|
1508
|
-
BadRequest: 400,
|
|
1509
|
-
Unauthorized: 401,
|
|
1510
|
-
PaymentRequired: 402,
|
|
1511
|
-
Forbidden: 403,
|
|
1512
|
-
NotFound: 404,
|
|
1513
|
-
MethodNotAllowed: 405,
|
|
1514
|
-
NotAcceptable: 406,
|
|
1515
|
-
ProxyAuthenticationRequired: 407,
|
|
1516
|
-
RequestTimeout: 408,
|
|
1517
|
-
Conflict: 409,
|
|
1518
|
-
Gone: 410,
|
|
1519
|
-
LengthRequired: 411,
|
|
1520
|
-
PreconditionFailed: 412,
|
|
1521
|
-
PayloadTooLarge: 413,
|
|
1522
|
-
UriTooLong: 414,
|
|
1523
|
-
UnsupportedMediaType: 415,
|
|
1524
|
-
RangeNotSatisfiable: 416,
|
|
1525
|
-
ExpectationFailed: 417,
|
|
1526
|
-
ImATeapot: 418,
|
|
1527
|
-
MisdirectedRequest: 421,
|
|
1528
|
-
UnprocessableEntity: 422,
|
|
1529
|
-
Locked: 423,
|
|
1530
|
-
FailedDependency: 424,
|
|
1531
|
-
TooEarly: 425,
|
|
1532
|
-
UpgradeRequired: 426,
|
|
1533
|
-
PreconditionRequired: 428,
|
|
1534
|
-
TooManyRequests: 429,
|
|
1535
|
-
RequestHeaderFieldsTooLarge: 431,
|
|
1536
|
-
UnavailableForLegalReasons: 451,
|
|
1537
|
-
InternalServerError: 500,
|
|
1538
|
-
NotImplemented: 501,
|
|
1539
|
-
BadGateway: 502,
|
|
1540
|
-
ServiceUnavailable: 503,
|
|
1541
|
-
GatewayTimeout: 504,
|
|
1542
|
-
HttpVersionNotSupported: 505,
|
|
1543
|
-
VariantAlsoNegotiates: 506,
|
|
1544
|
-
InsufficientStorage: 507,
|
|
1545
|
-
LoopDetected: 508,
|
|
1546
|
-
NotExtended: 510,
|
|
1547
|
-
NetworkAuthenticationRequired: 511
|
|
1548
|
-
};
|
|
1549
|
-
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
1550
|
-
HttpStatusCode[value] = key;
|
|
1551
|
-
});
|
|
1552
|
-
const HttpStatusCode$1 = HttpStatusCode;
|
|
1553
|
-
function createInstance(defaultConfig) {
|
|
1554
|
-
const context = new Axios$1(defaultConfig), instance = bind(Axios$1.prototype.request, context);
|
|
1555
|
-
return utils.extend(instance, Axios$1.prototype, context, { allOwnKeys: !0 }), utils.extend(instance, context, null, { allOwnKeys: !0 }), instance.create = function(instanceConfig) {
|
|
1556
|
-
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
|
1557
|
-
}, instance;
|
|
1558
|
-
}
|
|
1559
|
-
const axios = createInstance(defaults$1);
|
|
1560
|
-
axios.Axios = Axios$1;
|
|
1561
|
-
axios.CanceledError = CanceledError;
|
|
1562
|
-
axios.CancelToken = CancelToken$1;
|
|
1563
|
-
axios.isCancel = isCancel;
|
|
1564
|
-
axios.VERSION = VERSION;
|
|
1565
|
-
axios.toFormData = toFormData;
|
|
1566
|
-
axios.AxiosError = AxiosError;
|
|
1567
|
-
axios.Cancel = axios.CanceledError;
|
|
1568
|
-
axios.all = function(promises) {
|
|
1569
|
-
return Promise.all(promises);
|
|
1570
|
-
};
|
|
1571
|
-
axios.spread = spread;
|
|
1572
|
-
axios.isAxiosError = isAxiosError;
|
|
1573
|
-
axios.mergeConfig = mergeConfig;
|
|
1574
|
-
axios.AxiosHeaders = AxiosHeaders$1;
|
|
1575
|
-
axios.formToJSON = (thing) => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
1576
|
-
axios.getAdapter = adapters.getAdapter;
|
|
1577
|
-
axios.HttpStatusCode = HttpStatusCode$1;
|
|
1578
|
-
axios.default = axios;
|
|
1579
|
-
const axios$1 = axios;
|
|
1580
|
-
class HttpClient {
|
|
1581
|
-
constructor(url, httpRequester = null) {
|
|
1582
|
-
__publicField(this, "_url", null);
|
|
1583
|
-
__publicField(this, "_token", null);
|
|
1584
|
-
//Added for testing support
|
|
1585
|
-
__publicField(this, "_httpRequester");
|
|
1586
|
-
if (!url)
|
|
1587
|
-
throw Error("Endpoint URL must be passed in to NotuClient constructor");
|
|
1588
|
-
this._url = url, this._httpRequester = httpRequester ?? axios$1;
|
|
1589
|
-
}
|
|
1590
|
-
get url() {
|
|
1591
|
-
return this._url;
|
|
1592
|
-
}
|
|
1593
|
-
get token() {
|
|
1594
|
-
return this._token;
|
|
1595
|
-
}
|
|
1596
|
-
set token(value) {
|
|
1597
|
-
this._token = value;
|
|
1598
|
-
}
|
|
1599
|
-
async login(username, password) {
|
|
1600
|
-
try {
|
|
1601
|
-
const result = await this._httpRequester({
|
|
1602
|
-
method: "post",
|
|
1603
|
-
url: (this.url + "/login").replace("//", "/"),
|
|
1604
|
-
data: { username, password }
|
|
1605
|
-
});
|
|
1606
|
-
return this._token = result.data, { success: !0, error: null, token: result.data };
|
|
1607
|
-
} catch (ex) {
|
|
1608
|
-
if (ex.response.status == 401)
|
|
1609
|
-
return { success: !1, error: "Invalid username & password.", token: null };
|
|
1610
|
-
throw ex;
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
async getSpaces() {
|
|
1614
|
-
return (await this._httpRequester({
|
|
1615
|
-
method: "get",
|
|
1616
|
-
url: (this.url + "/spaces").replace("//", "/"),
|
|
1617
|
-
headers: {
|
|
1618
|
-
Authorization: "Bearer " + this.token
|
|
1619
|
-
}
|
|
1620
|
-
})).data;
|
|
1621
|
-
}
|
|
1622
|
-
async saveSpace(space) {
|
|
1623
|
-
return (await this._httpRequester({
|
|
1624
|
-
method: "post",
|
|
1625
|
-
url: (this.url + "/spaces").replace("//", "/"),
|
|
1626
|
-
data: space,
|
|
1627
|
-
headers: {
|
|
1628
|
-
Authorization: "Bearer " + this.token
|
|
1629
|
-
}
|
|
1630
|
-
})).data;
|
|
1631
|
-
}
|
|
1632
|
-
async getNotes(query, spaceId) {
|
|
1633
|
-
return (await this._httpRequester({
|
|
1634
|
-
method: "get",
|
|
1635
|
-
url: (this.url + "/notes").replace("//", "/"),
|
|
1636
|
-
data: { query, spaceId },
|
|
1637
|
-
headers: {
|
|
1638
|
-
Authorization: "Bearer " + this.token
|
|
1639
|
-
}
|
|
1640
|
-
})).data;
|
|
1641
|
-
}
|
|
1642
|
-
async getNoteCount(query, spaceId) {
|
|
1643
|
-
return (await this._httpRequester({
|
|
1644
|
-
method: "get",
|
|
1645
|
-
url: (this.url + "/notes").replace("//", "/"),
|
|
1646
|
-
data: { query, spaceId },
|
|
1647
|
-
headers: {
|
|
1648
|
-
Authorization: "Bearer " + this.token
|
|
1649
|
-
}
|
|
1650
|
-
})).data;
|
|
1651
|
-
}
|
|
1652
|
-
async saveNotes(notes) {
|
|
1653
|
-
return (await this._httpRequester({
|
|
1654
|
-
method: "post",
|
|
1655
|
-
url: (this.url + "/notes").replace("//", "/"),
|
|
1656
|
-
data: { notes },
|
|
1657
|
-
headers: {
|
|
1658
|
-
Authorization: "Bearer " + this.token
|
|
1659
|
-
}
|
|
1660
|
-
})).data;
|
|
1661
|
-
}
|
|
1662
|
-
async customJob(name, data) {
|
|
1663
|
-
return (await this._httpRequester({
|
|
1664
|
-
method: "post",
|
|
1665
|
-
url: (this.url + "customjob").replace("//", "/"),
|
|
1666
|
-
data: { name, data },
|
|
1667
|
-
headers: {
|
|
1668
|
-
Authorization: "Bearer " + this.token
|
|
1669
|
-
}
|
|
1670
|
-
})).data;
|
|
1671
|
-
}
|
|
1672
|
-
}
|
|
1673
|
-
class NoteAttr extends ModelWithState {
|
|
1674
|
-
constructor() {
|
|
1675
|
-
super(...arguments);
|
|
1676
|
-
__publicField(this, "_noteId", 0);
|
|
1677
|
-
__publicField(this, "_note", null);
|
|
1678
|
-
__publicField(this, "_attrId", 0);
|
|
1679
|
-
__publicField(this, "_attr", null);
|
|
1680
|
-
__publicField(this, "_value", null);
|
|
1681
|
-
__publicField(this, "_tagId", null);
|
|
1682
|
-
__publicField(this, "_tag", null);
|
|
1683
|
-
}
|
|
1684
|
-
get noteId() {
|
|
1685
|
-
return this._noteId;
|
|
1686
|
-
}
|
|
1687
|
-
set noteId(value) {
|
|
1688
|
-
var _a;
|
|
1689
|
-
value !== this._noteId && (this._noteId = value, value !== ((_a = this.note) == null ? void 0 : _a.id) && (this._note = null), this.isClean && this.dirty());
|
|
1690
|
-
}
|
|
1691
|
-
get note() {
|
|
1692
|
-
return this._note;
|
|
1693
|
-
}
|
|
1694
|
-
set note(value) {
|
|
1695
|
-
this._note = value, this.noteId = (value == null ? void 0 : value.id) ?? 0;
|
|
1696
|
-
}
|
|
1697
|
-
get attrId() {
|
|
1698
|
-
return this._attrId;
|
|
1699
|
-
}
|
|
1700
|
-
set attrId(value) {
|
|
1701
|
-
var _a;
|
|
1702
|
-
value !== this._attrId && (this._attrId = value, value !== ((_a = this.attr) == null ? void 0 : _a.id) && (this._attr = null), this.isClean && this.dirty());
|
|
1703
|
-
}
|
|
1704
|
-
get attr() {
|
|
1705
|
-
return this._attr;
|
|
1706
|
-
}
|
|
1707
|
-
set attr(newAttr) {
|
|
1708
|
-
const oldAttr = this._attr;
|
|
1709
|
-
this._attr = newAttr, newAttr ? (!oldAttr || newAttr.type != oldAttr.type) && (this.value = newAttr.defaultValue) : this.value = null, this.attrId = (newAttr == null ? void 0 : newAttr.id) ?? 0;
|
|
1710
|
-
}
|
|
1711
|
-
get value() {
|
|
1712
|
-
return this._value;
|
|
1713
|
-
}
|
|
1714
|
-
set value(newVal) {
|
|
1715
|
-
newVal != this._value && (this._value = newVal, this.isClean && this.dirty());
|
|
1716
|
-
}
|
|
1717
|
-
get tagId() {
|
|
1718
|
-
return this._tagId;
|
|
1719
|
-
}
|
|
1720
|
-
set tagId(value) {
|
|
1721
|
-
var _a;
|
|
1722
|
-
value !== this._tagId && (this._tagId = value, value !== ((_a = this.tag) == null ? void 0 : _a.id) && (this._tag = null), this.isClean && this.dirty());
|
|
1723
|
-
}
|
|
1724
|
-
get tag() {
|
|
1725
|
-
return this._tag;
|
|
1726
|
-
}
|
|
1727
|
-
set tag(value) {
|
|
1728
|
-
this._tag = value, this.tagId = (value == null ? void 0 : value.id) ?? null;
|
|
1729
|
-
}
|
|
1730
|
-
duplicate() {
|
|
1731
|
-
const output = new NoteAttr();
|
|
1732
|
-
return output.noteId = this.noteId, output.note = this.note, output.attrId = this.attrId, output.attr = this.attr, output.tagId = this.tagId, output.tag = this.tag, output.value = this.value, output;
|
|
1733
|
-
}
|
|
1734
|
-
validate(throwError = !1) {
|
|
1735
|
-
let output = null;
|
|
1736
|
-
if (this.noteId <= 0 && !this.isNew ? output = "NoteAttr noteId must be greater than zero" : this.attrId <= 0 && (output = "NoteAttr attrId must be greater than zero"), throwError && output != null)
|
|
1737
|
-
throw Error(output);
|
|
1738
|
-
return output == null;
|
|
1739
|
-
}
|
|
1740
|
-
}
|
|
1741
|
-
class NoteTag extends ModelWithState {
|
|
1742
|
-
constructor() {
|
|
1743
|
-
super(...arguments);
|
|
1744
|
-
__publicField(this, "_noteId", 0);
|
|
1745
|
-
__publicField(this, "_note", null);
|
|
1746
|
-
__publicField(this, "_tagId", 0);
|
|
1747
|
-
__publicField(this, "_tag", null);
|
|
1748
|
-
}
|
|
1749
|
-
get noteId() {
|
|
1750
|
-
return this._noteId;
|
|
1751
|
-
}
|
|
1752
|
-
set noteId(value) {
|
|
1753
|
-
var _a;
|
|
1754
|
-
value !== this._noteId && (this._noteId = value, value !== ((_a = this.note) == null ? void 0 : _a.id) && (this._note = null), this.isClean && this.dirty());
|
|
1755
|
-
}
|
|
1756
|
-
get note() {
|
|
1757
|
-
return this._note;
|
|
1758
|
-
}
|
|
1759
|
-
set note(value) {
|
|
1760
|
-
this._note = value, this.noteId = (value == null ? void 0 : value.id) ?? 0;
|
|
1761
|
-
}
|
|
1762
|
-
get tagId() {
|
|
1763
|
-
return this._tagId;
|
|
1764
|
-
}
|
|
1765
|
-
set tagId(value) {
|
|
1766
|
-
var _a;
|
|
1767
|
-
value !== this._tagId && (this._tagId = value, value !== ((_a = this.tag) == null ? void 0 : _a.id) && (this._tag = null), this.isClean && this.dirty());
|
|
1768
|
-
}
|
|
1769
|
-
get tag() {
|
|
1770
|
-
return this._tag;
|
|
1771
|
-
}
|
|
1772
|
-
set tag(value) {
|
|
1773
|
-
this._tag = value, this.tagId = (value == null ? void 0 : value.id) ?? 0;
|
|
1774
|
-
}
|
|
1775
|
-
get attrs() {
|
|
1776
|
-
return this.note.attrs.filter((x) => x.tagId == this.tagId);
|
|
1777
|
-
}
|
|
1778
|
-
addAttr(attr) {
|
|
1779
|
-
if (!this.note)
|
|
1780
|
-
throw new Error("Cannot call addAttr on NoteTag where note property has not been set");
|
|
1781
|
-
const na = this.note.addAttr(attr);
|
|
1782
|
-
return na.tag = this.tag, na;
|
|
1783
|
-
}
|
|
1784
|
-
duplicate() {
|
|
1785
|
-
const output = new NoteTag();
|
|
1786
|
-
return output.noteId = this.noteId, output.tagId = this.tagId, output;
|
|
1787
|
-
}
|
|
1788
|
-
validate(throwError = !1) {
|
|
1789
|
-
let output = null;
|
|
1790
|
-
if (this.noteId <= 0 && !this.isNew ? output = "NoteTag noteId must be greater than zero" : this.tagId <= 0 ? output = "NoteTag tagId must be greater than zero" : this.noteId == this.tagId && (output = "NoteTag cannot link a note to its own tag"), throwError && output != null)
|
|
1791
|
-
throw Error(output);
|
|
1792
|
-
return output == null;
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
class Tag extends ModelWithState {
|
|
1796
|
-
constructor(name = "") {
|
|
1797
|
-
super();
|
|
1798
|
-
__publicField(this, "_id", 0);
|
|
1799
|
-
__publicField(this, "_name", "");
|
|
1800
|
-
__publicField(this, "_color", null);
|
|
1801
|
-
this._name = name;
|
|
1802
|
-
}
|
|
1803
|
-
get id() {
|
|
1804
|
-
return this._id;
|
|
1805
|
-
}
|
|
1806
|
-
set id(value) {
|
|
1807
|
-
value !== this._id && (this._id = value, this.isClean && this.dirty());
|
|
1808
|
-
}
|
|
1809
|
-
get name() {
|
|
1810
|
-
return this._name;
|
|
1811
|
-
}
|
|
1812
|
-
set name(value) {
|
|
1813
|
-
value !== this._name && (this._name = value, this.isClean && this.dirty());
|
|
1814
|
-
}
|
|
1815
|
-
get color() {
|
|
1816
|
-
return this._color;
|
|
1817
|
-
}
|
|
1818
|
-
set color(value) {
|
|
1819
|
-
value !== this._color && (this._color = value, this.isClean && this.dirty());
|
|
1820
|
-
}
|
|
1821
|
-
duplicate() {
|
|
1822
|
-
const output = new Tag();
|
|
1823
|
-
return output.id = this.id, output.name = this.name, output.state = this.state, output;
|
|
1824
|
-
}
|
|
1825
|
-
validate(throwError = !1) {
|
|
1826
|
-
let output = null;
|
|
1827
|
-
if (!this.isNew && this.id <= 0 ? output = "Tag id must be greater than zero if in non-new state." : !this.name || !/^[a-zA-Z][a-zA-Z0-9 ]*[a-zA-Z0-9]?$/.test(this.name) ? output = "Tag name is invalid, must only contain letters, numbers, and spaces, starting with a letter" : this.color && !/^#?[A-z0-9]{6}$/.test(this.color) && (output = "Tag color is invalid, must be a 6 character hexadecimal."), throwError && output != null)
|
|
1828
|
-
throw Error(output);
|
|
1829
|
-
return output == null;
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
class Note extends ModelWithState {
|
|
1833
|
-
constructor() {
|
|
1834
|
-
super(...arguments);
|
|
1835
|
-
__publicField(this, "id", 0);
|
|
1836
|
-
__publicField(this, "_date", /* @__PURE__ */ new Date());
|
|
1837
|
-
__publicField(this, "_text", "");
|
|
1838
|
-
__publicField(this, "_archived", !1);
|
|
1839
|
-
__publicField(this, "_spaceId", 0);
|
|
1840
|
-
__publicField(this, "_space", null);
|
|
1841
|
-
__publicField(this, "_ownTag", null);
|
|
1842
|
-
__publicField(this, "_tags", []);
|
|
1843
|
-
__publicField(this, "_attrs", []);
|
|
1844
|
-
}
|
|
1845
|
-
get date() {
|
|
1846
|
-
return this._date;
|
|
1847
|
-
}
|
|
1848
|
-
set date(value) {
|
|
1849
|
-
value !== this._date && (this._date = value, this.isClean && this.dirty());
|
|
1850
|
-
}
|
|
1851
|
-
get text() {
|
|
1852
|
-
return this._text;
|
|
1853
|
-
}
|
|
1854
|
-
set text(value) {
|
|
1855
|
-
value !== this._text && (this._text = value, this.isClean && this.dirty());
|
|
1856
|
-
}
|
|
1857
|
-
get archived() {
|
|
1858
|
-
return this._archived;
|
|
1859
|
-
}
|
|
1860
|
-
set archived(value) {
|
|
1861
|
-
value !== this._archived && (this._archived = value, this.isClean && this.dirty());
|
|
1862
|
-
}
|
|
1863
|
-
get spaceId() {
|
|
1864
|
-
return this._spaceId;
|
|
1865
|
-
}
|
|
1866
|
-
set spaceId(value) {
|
|
1867
|
-
var _a;
|
|
1868
|
-
value !== this._spaceId && (this._spaceId = value, value !== ((_a = this.space) == null ? void 0 : _a.id) && (this._space = null), this.isClean && this.dirty());
|
|
1869
|
-
}
|
|
1870
|
-
get space() {
|
|
1871
|
-
return this._space;
|
|
1872
|
-
}
|
|
1873
|
-
set space(value) {
|
|
1874
|
-
this._space = value, this.spaceId = (value == null ? void 0 : value.id) ?? 0;
|
|
1875
|
-
}
|
|
1876
|
-
get ownTag() {
|
|
1877
|
-
return this._ownTag;
|
|
1878
|
-
}
|
|
1879
|
-
setOwnTag(tag) {
|
|
1880
|
-
if (typeof tag == "string")
|
|
1881
|
-
this.ownTag == null && (this._ownTag = new Tag()), this.ownTag.name = tag, this.ownTag.id = this.id;
|
|
1882
|
-
else {
|
|
1883
|
-
if (this.ownTag)
|
|
1884
|
-
throw new Error("Note has already had its tag set. If you would like to change the tag name, call setTag with just a string specifying the new tag name.");
|
|
1885
|
-
if (tag.id != 0 && tag.id != this.id)
|
|
1886
|
-
throw new Error("Attempted to set tag to note with non-matching ID. Added tag id must either match the note id, which indicates that the tag has already been added to the note. Otherwise the tag id must be zero, indicating that the tag still needs to be added.");
|
|
1887
|
-
this._ownTag = tag;
|
|
1888
|
-
}
|
|
1889
|
-
return this;
|
|
1890
|
-
}
|
|
1891
|
-
removeOwnTag() {
|
|
1892
|
-
this.ownTag && (this.ownTag.isNew ? this._ownTag = null : this.ownTag.delete());
|
|
1893
|
-
}
|
|
1894
|
-
get tags() {
|
|
1895
|
-
return this._tags;
|
|
1896
|
-
}
|
|
1897
|
-
addTag(tag) {
|
|
1898
|
-
if (tag.isDeleted)
|
|
1899
|
-
throw Error("Cannot add a tag marked as deleted to a note");
|
|
1900
|
-
if (tag.isNew)
|
|
1901
|
-
throw Error("Cannot add a tag that hasn't yet been saved to a note");
|
|
1902
|
-
if (tag.id == this.id)
|
|
1903
|
-
throw Error("Note cannot add its own tag as a linked tag");
|
|
1904
|
-
let nt = this.tags.find((x) => x.tagId == tag.id);
|
|
1905
|
-
return nt ? (nt.isDeleted && nt.dirty(), nt) : (nt = new NoteTag(), nt.note = this, nt.tag = tag, this._tags.push(nt), nt);
|
|
1906
|
-
}
|
|
1907
|
-
removeTag(tag) {
|
|
1908
|
-
const nt = this.tags.find((x) => x.tagId == tag.id);
|
|
1909
|
-
return nt ? (nt.isNew ? this._tags = this._tags.filter((x) => x !== nt) : nt.delete(), this) : this;
|
|
1910
|
-
}
|
|
1911
|
-
get attrs() {
|
|
1912
|
-
return this._attrs;
|
|
1913
|
-
}
|
|
1914
|
-
addAttr(attr) {
|
|
1915
|
-
if (attr.isDeleted)
|
|
1916
|
-
throw Error("Cannot add an attribute marked as deleted to a note");
|
|
1917
|
-
if (attr.isNew)
|
|
1918
|
-
throw Error("Cannot add an attribute that hasn't yet been saved to a note");
|
|
1919
|
-
let na = this.attrs.find((x) => x.attrId == attr.id);
|
|
1920
|
-
return na ? (na.isDeleted && na.dirty(), na) : (na = new NoteAttr(), na.note = this, na.attr = attr, this._attrs.push(na), na);
|
|
1921
|
-
}
|
|
1922
|
-
removeAttr(attr) {
|
|
1923
|
-
const na = this.attrs.find((x) => x.attrId == attr.id);
|
|
1924
|
-
return na ? (na.isNew ? this._attrs = this._attrs.filter((x) => x !== na) : na.delete(), this) : this;
|
|
1925
|
-
}
|
|
1926
|
-
duplicate() {
|
|
1927
|
-
const output = new Note();
|
|
1928
|
-
return output.id = this.id, output.date = this.date, output.text = this.text, output.archived = this.archived, output.space = this.space, output.state = this.state, output;
|
|
1929
|
-
}
|
|
1930
|
-
validate(throwError = !1) {
|
|
1931
|
-
let output = null;
|
|
1932
|
-
if (this.spaceId <= 0 ? output = "Note spaceId must be greater than zero." : !this.isNew && this.id <= 0 && (output = "Note id must be greater than zero if in non-new state."), throwError && output != null)
|
|
1933
|
-
throw Error(output);
|
|
1934
|
-
if (this.ownTag && !this.ownTag.validate(throwError))
|
|
1935
|
-
return !1;
|
|
1936
|
-
for (const nt of this.tags)
|
|
1937
|
-
if (!nt.validate(throwError))
|
|
1938
|
-
return !1;
|
|
1939
|
-
for (const na of this.attrs)
|
|
1940
|
-
if (!na.validate(throwError))
|
|
1941
|
-
return !1;
|
|
1942
|
-
return output == null;
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
1945
|
-
class ParsedQuery {
|
|
1946
|
-
constructor() {
|
|
1947
|
-
__publicField(this, "where", null);
|
|
1948
|
-
__publicField(this, "order", null);
|
|
1949
|
-
__publicField(this, "tags", []);
|
|
1950
|
-
__publicField(this, "attrs", []);
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
class ParsedTag {
|
|
1954
|
-
constructor() {
|
|
1955
|
-
__publicField(this, "space", null);
|
|
1956
|
-
__publicField(this, "name", null);
|
|
1957
|
-
__publicField(this, "searchDepth", 0);
|
|
1958
|
-
__publicField(this, "strictSearchDepth", !0);
|
|
1959
|
-
__publicField(this, "includeOwner", !1);
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
class ParsedAttr {
|
|
1963
|
-
constructor() {
|
|
1964
|
-
__publicField(this, "space", null);
|
|
1965
|
-
__publicField(this, "name", null);
|
|
1966
|
-
__publicField(this, "exists", !1);
|
|
1967
|
-
__publicField(this, "tagNameFilters", null);
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1970
|
-
function parseQuery(query) {
|
|
1971
|
-
const output = splitQuery(query);
|
|
1972
|
-
return output.where = identifyTags(output.where, output), output.order = identifyTags(output.order, output), output.where = identifyAttrs(output.where, output), output.order = identifyAttrs(output.order, output), output;
|
|
1973
|
-
}
|
|
1974
|
-
function splitQuery(query) {
|
|
1975
|
-
query = " " + query + " ";
|
|
1976
|
-
const output = new ParsedQuery(), orderByIndex = query.toUpperCase().indexOf(" ORDER BY ");
|
|
1977
|
-
return orderByIndex < 0 ? output.where = query.trim() : (output.where = query.substring(0, orderByIndex).trim(), output.order = query.substring(orderByIndex + 10).trim()), output.where == "" && (output.where = null), output;
|
|
1978
|
-
}
|
|
1979
|
-
function identifyTags(query, parsedQuery) {
|
|
1980
|
-
const regexes = [
|
|
1981
|
-
/(#+\??~?|~)([\w\d]+\.)?([\w\d]+)/,
|
|
1982
|
-
//Single word tags and space names
|
|
1983
|
-
/(#+\??~?|~)\[([\w\d\s]+\.)?([\w\d\s]+)\]/
|
|
1984
|
-
//Multi-word tags and space names wrapped in []
|
|
1985
|
-
];
|
|
1986
|
-
for (const regex of regexes)
|
|
1987
|
-
for (; ; ) {
|
|
1988
|
-
const match = regex.exec(query);
|
|
1989
|
-
if (!match)
|
|
1990
|
-
break;
|
|
1991
|
-
const hashPrefix = match[1], parsedTag = new ParsedTag();
|
|
1992
|
-
parsedTag.space = match[2] ? match[2].substring(0, match[2].length - 1) : null, parsedTag.name = match[3], parsedTag.includeOwner = hashPrefix.includes("~"), parsedTag.searchDepth = (hashPrefix.match(/#/g) || []).length, parsedTag.strictSearchDepth = !hashPrefix.includes("?");
|
|
1993
|
-
const fullMatch = match[0], matchStart = query.indexOf(fullMatch), matchEnd = matchStart + fullMatch.length;
|
|
1994
|
-
query = query.substring(0, matchStart) + `{tag${parsedQuery.tags.length}}` + query.substring(matchEnd), parsedQuery.tags.push(parsedTag);
|
|
1995
|
-
}
|
|
1996
|
-
return query;
|
|
1997
|
-
}
|
|
1998
|
-
function identifyAttrs(query, parsedQuery) {
|
|
1999
|
-
const regexes = [
|
|
2000
|
-
/@([\w\d]+\.(?!Exists\(|On\())?([\w\d]+)/,
|
|
2001
|
-
/@\[([\w\d\s]+\.)?([\w\d\s]+)\]/
|
|
2002
|
-
];
|
|
2003
|
-
for (const regex of regexes)
|
|
2004
|
-
for (; ; ) {
|
|
2005
|
-
const match = regex.exec(query);
|
|
2006
|
-
if (!match)
|
|
2007
|
-
break;
|
|
2008
|
-
const parsedAttr = new ParsedAttr();
|
|
2009
|
-
parsedAttr.space = match[1] ? match[1].substring(0, match[1].length - 1) : null, parsedAttr.name = match[2];
|
|
2010
|
-
const matchStart = query.indexOf(match[0]);
|
|
2011
|
-
let matchEnd = matchStart + match[0].length;
|
|
2012
|
-
if (query.substring(matchEnd, matchEnd + 9) == ".Exists()" && (parsedAttr.exists = !0, matchEnd += 9), query.substring(matchEnd, matchEnd + 4) == ".On(") {
|
|
2013
|
-
let tagFilterStart = matchEnd + 4;
|
|
2014
|
-
if (matchEnd = query.indexOf(")", tagFilterStart), matchEnd < 0)
|
|
2015
|
-
throw Error("Unclosed bracket detected");
|
|
2016
|
-
let tagNameFilters = query.substring(tagFilterStart, matchEnd).split("|");
|
|
2017
|
-
const dummyParsedQuery = new ParsedQuery();
|
|
2018
|
-
for (let tagNameFilter of tagNameFilters)
|
|
2019
|
-
tagNameFilter.startsWith("~") || (tagNameFilter = "~" + tagNameFilter), identifyTags(tagNameFilter, dummyParsedQuery);
|
|
2020
|
-
parsedAttr.tagNameFilters = dummyParsedQuery.tags, matchEnd++;
|
|
2021
|
-
}
|
|
2022
|
-
query = query.substring(0, matchStart) + `{attr${parsedQuery.attrs.length}}` + query.substring(matchEnd), parsedQuery.attrs.push(parsedAttr);
|
|
2023
|
-
}
|
|
2024
|
-
return query;
|
|
2025
|
-
}
|
|
2026
|
-
class Space extends ModelWithState {
|
|
2027
|
-
constructor(name = "") {
|
|
2028
|
-
super();
|
|
2029
|
-
__publicField(this, "id", 0);
|
|
2030
|
-
__publicField(this, "_name", "");
|
|
2031
|
-
this._name = name;
|
|
2032
|
-
}
|
|
2033
|
-
get name() {
|
|
2034
|
-
return this._name;
|
|
2035
|
-
}
|
|
2036
|
-
set name(value) {
|
|
2037
|
-
value !== this._name && (this._name = value, this.isClean && this.dirty());
|
|
2038
|
-
}
|
|
2039
|
-
duplicate() {
|
|
2040
|
-
const output = new Space();
|
|
2041
|
-
return output.id = this.id, output.name = this.name, output.state = this.state, output;
|
|
2042
|
-
}
|
|
2043
|
-
validate(throwError = !1) {
|
|
2044
|
-
let output = null;
|
|
2045
|
-
if (!this.isNew && this.id <= 0 && (output = "Space id must be greater than zero if in non-new state."), throwError && output != null)
|
|
2046
|
-
throw Error(output);
|
|
2047
|
-
return output == null;
|
|
2048
|
-
}
|
|
2049
|
-
}
|
|
2050
|
-
export {
|
|
2051
|
-
Attr,
|
|
2052
|
-
Environment,
|
|
2053
|
-
HttpClient,
|
|
2054
|
-
Note,
|
|
2055
|
-
NoteAttr,
|
|
2056
|
-
NoteTag,
|
|
2057
|
-
Space,
|
|
2058
|
-
Tag,
|
|
2059
|
-
parseQuery
|
|
2060
|
-
};
|