notu 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/notu.mjs CHANGED
@@ -169,1440 +169,15 @@ class Environment {
169
169
  return await this.client.customJob(name, data);
170
170
  }
171
171
  }
172
- function bind(fn, thisArg) {
173
- return function() {
174
- return fn.apply(thisArg, arguments);
175
- };
176
- }
177
- const { toString } = Object.prototype, { getPrototypeOf } = Object, kindOf = ((cache) => (thing) => {
178
- const str = toString.call(thing);
179
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
180
- })(/* @__PURE__ */ Object.create(null)), kindOfTest = (type) => (type = type.toLowerCase(), (thing) => kindOf(thing) === type), typeOfTest = (type) => (thing) => typeof thing === type, { isArray } = Array, isUndefined = typeOfTest("undefined");
181
- function isBuffer(val) {
182
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
183
- }
184
- const isArrayBuffer = kindOfTest("ArrayBuffer");
185
- function isArrayBufferView(val) {
186
- let result;
187
- return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? result = ArrayBuffer.isView(val) : result = val && val.buffer && isArrayBuffer(val.buffer), result;
188
- }
189
- 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) => {
190
- if (kindOf(val) !== "object")
191
- return !1;
192
- const prototype2 = getPrototypeOf(val);
193
- return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
194
- }, isDate = kindOfTest("Date"), isFile = kindOfTest("File"), isBlob = kindOfTest("Blob"), isFileList = kindOfTest("FileList"), isStream = (val) => isObject(val) && isFunction(val.pipe), isFormData = (thing) => {
195
- let kind;
196
- return thing && (typeof FormData == "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
197
- kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
198
- }, isURLSearchParams = kindOfTest("URLSearchParams"), trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
199
- function forEach(obj, fn, { allOwnKeys = !1 } = {}) {
200
- if (obj === null || typeof obj > "u")
201
- return;
202
- let i, l;
203
- if (typeof obj != "object" && (obj = [obj]), isArray(obj))
204
- for (i = 0, l = obj.length; i < l; i++)
205
- fn.call(null, obj[i], i, obj);
206
- else {
207
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj), len = keys.length;
208
- let key;
209
- for (i = 0; i < len; i++)
210
- key = keys[i], fn.call(null, obj[key], key, obj);
211
- }
212
- }
213
- function findKey(obj, key) {
214
- key = key.toLowerCase();
215
- const keys = Object.keys(obj);
216
- let i = keys.length, _key;
217
- for (; i-- > 0; )
218
- if (_key = keys[i], key === _key.toLowerCase())
219
- return _key;
220
- return null;
221
- }
222
- const _global = (() => typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global)(), isContextDefined = (context) => !isUndefined(context) && context !== _global;
223
- function merge() {
224
- const { caseless } = isContextDefined(this) && this || {}, result = {}, assignValue = (val, key) => {
225
- const targetKey = caseless && findKey(result, key) || key;
226
- 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;
227
- };
228
- for (let i = 0, l = arguments.length; i < l; i++)
229
- arguments[i] && forEach(arguments[i], assignValue);
230
- return result;
231
- }
232
- const extend = (a, b, thisArg, { allOwnKeys } = {}) => (forEach(b, (val, key) => {
233
- thisArg && isFunction(val) ? a[key] = bind(val, thisArg) : a[key] = val;
234
- }, { allOwnKeys }), a), stripBOM = (content) => (content.charCodeAt(0) === 65279 && (content = content.slice(1)), content), inherits = (constructor, superConstructor, props, descriptors2) => {
235
- constructor.prototype = Object.create(superConstructor.prototype, descriptors2), constructor.prototype.constructor = constructor, Object.defineProperty(constructor, "super", {
236
- value: superConstructor.prototype
237
- }), props && Object.assign(constructor.prototype, props);
238
- }, toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
239
- let props, i, prop;
240
- const merged = {};
241
- if (destObj = destObj || {}, sourceObj == null)
242
- return destObj;
243
- do {
244
- for (props = Object.getOwnPropertyNames(sourceObj), i = props.length; i-- > 0; )
245
- prop = props[i], (!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop] && (destObj[prop] = sourceObj[prop], merged[prop] = !0);
246
- sourceObj = filter2 !== !1 && getPrototypeOf(sourceObj);
247
- } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
248
- return destObj;
249
- }, endsWith = (str, searchString, position) => {
250
- str = String(str), (position === void 0 || position > str.length) && (position = str.length), position -= searchString.length;
251
- const lastIndex = str.indexOf(searchString, position);
252
- return lastIndex !== -1 && lastIndex === position;
253
- }, toArray = (thing) => {
254
- if (!thing)
255
- return null;
256
- if (isArray(thing))
257
- return thing;
258
- let i = thing.length;
259
- if (!isNumber(i))
260
- return null;
261
- const arr = new Array(i);
262
- for (; i-- > 0; )
263
- arr[i] = thing[i];
264
- return arr;
265
- }, isTypedArray = ((TypedArray) => (thing) => TypedArray && thing instanceof TypedArray)(typeof Uint8Array < "u" && getPrototypeOf(Uint8Array)), forEachEntry = (obj, fn) => {
266
- const iterator = (obj && obj[Symbol.iterator]).call(obj);
267
- let result;
268
- for (; (result = iterator.next()) && !result.done; ) {
269
- const pair = result.value;
270
- fn.call(obj, pair[0], pair[1]);
271
- }
272
- }, matchAll = (regExp, str) => {
273
- let matches;
274
- const arr = [];
275
- for (; (matches = regExp.exec(str)) !== null; )
276
- arr.push(matches);
277
- return arr;
278
- }, isHTMLForm = kindOfTest("HTMLFormElement"), toCamelCase = (str) => str.toLowerCase().replace(
279
- /[-_\s]([a-z\d])(\w*)/g,
280
- function(m, p1, p2) {
281
- return p1.toUpperCase() + p2;
282
- }
283
- ), hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype), isRegExp = kindOfTest("RegExp"), reduceDescriptors = (obj, reducer) => {
284
- const descriptors2 = Object.getOwnPropertyDescriptors(obj), reducedDescriptors = {};
285
- forEach(descriptors2, (descriptor, name) => {
286
- let ret;
287
- (ret = reducer(descriptor, name, obj)) !== !1 && (reducedDescriptors[name] = ret || descriptor);
288
- }), Object.defineProperties(obj, reducedDescriptors);
289
- }, freezeMethods = (obj) => {
290
- reduceDescriptors(obj, (descriptor, name) => {
291
- if (isFunction(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1)
292
- return !1;
293
- const value = obj[name];
294
- if (isFunction(value)) {
295
- if (descriptor.enumerable = !1, "writable" in descriptor) {
296
- descriptor.writable = !1;
297
- return;
298
- }
299
- descriptor.set || (descriptor.set = () => {
300
- throw Error("Can not rewrite read-only method '" + name + "'");
301
- });
302
- }
303
- });
304
- }, toObjectSet = (arrayOrString, delimiter) => {
305
- const obj = {}, define = (arr) => {
306
- arr.forEach((value) => {
307
- obj[value] = !0;
308
- });
309
- };
310
- return isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter)), obj;
311
- }, noop = () => {
312
- }, toFiniteNumber = (value, defaultValue) => (value = +value, Number.isFinite(value) ? value : defaultValue), ALPHA = "abcdefghijklmnopqrstuvwxyz", DIGIT = "0123456789", ALPHABET = {
313
- DIGIT,
314
- ALPHA,
315
- ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
316
- }, generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
317
- let str = "";
318
- const { length } = alphabet;
319
- for (; size--; )
320
- str += alphabet[Math.random() * length | 0];
321
- return str;
322
- };
323
- function isSpecCompliantForm(thing) {
324
- return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === "FormData" && thing[Symbol.iterator]);
325
- }
326
- const toJSONObject = (obj) => {
327
- const stack = new Array(10), visit = (source, i) => {
328
- if (isObject(source)) {
329
- if (stack.indexOf(source) >= 0)
330
- return;
331
- if (!("toJSON" in source)) {
332
- stack[i] = source;
333
- const target = isArray(source) ? [] : {};
334
- return forEach(source, (value, key) => {
335
- const reducedValue = visit(value, i + 1);
336
- !isUndefined(reducedValue) && (target[key] = reducedValue);
337
- }), stack[i] = void 0, target;
338
- }
339
- }
340
- return source;
341
- };
342
- return visit(obj, 0);
343
- }, isAsyncFn = kindOfTest("AsyncFunction"), isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch), utils = {
344
- isArray,
345
- isArrayBuffer,
346
- isBuffer,
347
- isFormData,
348
- isArrayBufferView,
349
- isString,
350
- isNumber,
351
- isBoolean,
352
- isObject,
353
- isPlainObject,
354
- isUndefined,
355
- isDate,
356
- isFile,
357
- isBlob,
358
- isRegExp,
359
- isFunction,
360
- isStream,
361
- isURLSearchParams,
362
- isTypedArray,
363
- isFileList,
364
- forEach,
365
- merge,
366
- extend,
367
- trim,
368
- stripBOM,
369
- inherits,
370
- toFlatObject,
371
- kindOf,
372
- kindOfTest,
373
- endsWith,
374
- toArray,
375
- forEachEntry,
376
- matchAll,
377
- isHTMLForm,
378
- hasOwnProperty,
379
- hasOwnProp: hasOwnProperty,
380
- // an alias to avoid ESLint no-prototype-builtins detection
381
- reduceDescriptors,
382
- freezeMethods,
383
- toObjectSet,
384
- toCamelCase,
385
- noop,
386
- toFiniteNumber,
387
- findKey,
388
- global: _global,
389
- isContextDefined,
390
- ALPHABET,
391
- generateString,
392
- isSpecCompliantForm,
393
- toJSONObject,
394
- isAsyncFn,
395
- isThenable
396
- };
397
- function AxiosError(message, code, config, request, response) {
398
- 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);
399
- }
400
- utils.inherits(AxiosError, Error, {
401
- toJSON: function() {
402
- return {
403
- // Standard
404
- message: this.message,
405
- name: this.name,
406
- // Microsoft
407
- description: this.description,
408
- number: this.number,
409
- // Mozilla
410
- fileName: this.fileName,
411
- lineNumber: this.lineNumber,
412
- columnNumber: this.columnNumber,
413
- stack: this.stack,
414
- // Axios
415
- config: utils.toJSONObject(this.config),
416
- code: this.code,
417
- status: this.response && this.response.status ? this.response.status : null
418
- };
419
- }
420
- });
421
- const prototype$1 = AxiosError.prototype, descriptors = {};
422
- [
423
- "ERR_BAD_OPTION_VALUE",
424
- "ERR_BAD_OPTION",
425
- "ECONNABORTED",
426
- "ETIMEDOUT",
427
- "ERR_NETWORK",
428
- "ERR_FR_TOO_MANY_REDIRECTS",
429
- "ERR_DEPRECATED",
430
- "ERR_BAD_RESPONSE",
431
- "ERR_BAD_REQUEST",
432
- "ERR_CANCELED",
433
- "ERR_NOT_SUPPORT",
434
- "ERR_INVALID_URL"
435
- // eslint-disable-next-line func-names
436
- ].forEach((code) => {
437
- descriptors[code] = { value: code };
438
- });
439
- Object.defineProperties(AxiosError, descriptors);
440
- Object.defineProperty(prototype$1, "isAxiosError", { value: !0 });
441
- AxiosError.from = (error, code, config, request, response, customProps) => {
442
- const axiosError = Object.create(prototype$1);
443
- return utils.toFlatObject(error, axiosError, function(obj) {
444
- return obj !== Error.prototype;
445
- }, (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;
446
- };
447
- const httpAdapter = null;
448
- function isVisitable(thing) {
449
- return utils.isPlainObject(thing) || utils.isArray(thing);
450
- }
451
- function removeBrackets(key) {
452
- return utils.endsWith(key, "[]") ? key.slice(0, -2) : key;
453
- }
454
- function renderKey(path, key, dots) {
455
- return path ? path.concat(key).map(function(token, i) {
456
- return token = removeBrackets(token), !dots && i ? "[" + token + "]" : token;
457
- }).join(dots ? "." : "") : key;
458
- }
459
- function isFlatArray(arr) {
460
- return utils.isArray(arr) && !arr.some(isVisitable);
461
- }
462
- const predicates = utils.toFlatObject(utils, {}, null, function(prop) {
463
- return /^is[A-Z]/.test(prop);
464
- });
465
- function toFormData(obj, formData, options) {
466
- if (!utils.isObject(obj))
467
- throw new TypeError("target must be an object");
468
- formData = formData || new FormData(), options = utils.toFlatObject(options, {
469
- metaTokens: !0,
470
- dots: !1,
471
- indexes: !1
472
- }, !1, function(option, source) {
473
- return !utils.isUndefined(source[option]);
474
- });
475
- const metaTokens = options.metaTokens, visitor = options.visitor || defaultVisitor, dots = options.dots, indexes = options.indexes, useBlob = (options.Blob || typeof Blob < "u" && Blob) && utils.isSpecCompliantForm(formData);
476
- if (!utils.isFunction(visitor))
477
- throw new TypeError("visitor must be a function");
478
- function convertValue(value) {
479
- if (value === null)
480
- return "";
481
- if (utils.isDate(value))
482
- return value.toISOString();
483
- if (!useBlob && utils.isBlob(value))
484
- throw new AxiosError("Blob is not supported. Use a Buffer instead.");
485
- return utils.isArrayBuffer(value) || utils.isTypedArray(value) ? useBlob && typeof Blob == "function" ? new Blob([value]) : Buffer.from(value) : value;
486
- }
487
- function defaultVisitor(value, key, path) {
488
- let arr = value;
489
- if (value && !path && typeof value == "object") {
490
- if (utils.endsWith(key, "{}"))
491
- key = metaTokens ? key : key.slice(0, -2), value = JSON.stringify(value);
492
- else if (utils.isArray(value) && isFlatArray(value) || (utils.isFileList(value) || utils.endsWith(key, "[]")) && (arr = utils.toArray(value)))
493
- return key = removeBrackets(key), arr.forEach(function(el, index) {
494
- !(utils.isUndefined(el) || el === null) && formData.append(
495
- // eslint-disable-next-line no-nested-ternary
496
- indexes === !0 ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
497
- convertValue(el)
498
- );
499
- }), !1;
500
- }
501
- return isVisitable(value) ? !0 : (formData.append(renderKey(path, key, dots), convertValue(value)), !1);
502
- }
503
- const stack = [], exposedHelpers = Object.assign(predicates, {
504
- defaultVisitor,
505
- convertValue,
506
- isVisitable
507
- });
508
- function build(value, path) {
509
- if (!utils.isUndefined(value)) {
510
- if (stack.indexOf(value) !== -1)
511
- throw Error("Circular reference detected in " + path.join("."));
512
- stack.push(value), utils.forEach(value, function(el, key) {
513
- (!(utils.isUndefined(el) || el === null) && visitor.call(
514
- formData,
515
- el,
516
- utils.isString(key) ? key.trim() : key,
517
- path,
518
- exposedHelpers
519
- )) === !0 && build(el, path ? path.concat(key) : [key]);
520
- }), stack.pop();
521
- }
522
- }
523
- if (!utils.isObject(obj))
524
- throw new TypeError("data must be an object");
525
- return build(obj), formData;
526
- }
527
- function encode$1(str) {
528
- const charMap = {
529
- "!": "%21",
530
- "'": "%27",
531
- "(": "%28",
532
- ")": "%29",
533
- "~": "%7E",
534
- "%20": "+",
535
- "%00": "\0"
536
- };
537
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function(match) {
538
- return charMap[match];
539
- });
540
- }
541
- function AxiosURLSearchParams(params, options) {
542
- this._pairs = [], params && toFormData(params, this, options);
543
- }
544
- const prototype = AxiosURLSearchParams.prototype;
545
- prototype.append = function(name, value) {
546
- this._pairs.push([name, value]);
547
- };
548
- prototype.toString = function(encoder) {
549
- const _encode = encoder ? function(value) {
550
- return encoder.call(this, value, encode$1);
551
- } : encode$1;
552
- return this._pairs.map(function(pair) {
553
- return _encode(pair[0]) + "=" + _encode(pair[1]);
554
- }, "").join("&");
555
- };
556
- function encode(val) {
557
- return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
558
- }
559
- function buildURL(url, params, options) {
560
- if (!params)
561
- return url;
562
- const _encode = options && options.encode || encode, serializeFn = options && options.serialize;
563
- let serializedParams;
564
- if (serializeFn ? serializedParams = serializeFn(params, options) : serializedParams = utils.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode), serializedParams) {
565
- const hashmarkIndex = url.indexOf("#");
566
- hashmarkIndex !== -1 && (url = url.slice(0, hashmarkIndex)), url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
567
- }
568
- return url;
569
- }
570
- class InterceptorManager {
571
- constructor() {
572
- this.handlers = [];
573
- }
574
- /**
575
- * Add a new interceptor to the stack
576
- *
577
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
578
- * @param {Function} rejected The function to handle `reject` for a `Promise`
579
- *
580
- * @return {Number} An ID used to remove interceptor later
581
- */
582
- use(fulfilled, rejected, options) {
583
- return this.handlers.push({
584
- fulfilled,
585
- rejected,
586
- synchronous: options ? options.synchronous : !1,
587
- runWhen: options ? options.runWhen : null
588
- }), this.handlers.length - 1;
589
- }
590
- /**
591
- * Remove an interceptor from the stack
592
- *
593
- * @param {Number} id The ID that was returned by `use`
594
- *
595
- * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
596
- */
597
- eject(id) {
598
- this.handlers[id] && (this.handlers[id] = null);
599
- }
600
- /**
601
- * Clear all interceptors from the stack
602
- *
603
- * @returns {void}
604
- */
605
- clear() {
606
- this.handlers && (this.handlers = []);
607
- }
608
- /**
609
- * Iterate over all the registered interceptors
610
- *
611
- * This method is particularly useful for skipping over any
612
- * interceptors that may have become `null` calling `eject`.
613
- *
614
- * @param {Function} fn The function to call for each interceptor
615
- *
616
- * @returns {void}
617
- */
618
- forEach(fn) {
619
- utils.forEach(this.handlers, function(h) {
620
- h !== null && fn(h);
621
- });
622
- }
623
- }
624
- const InterceptorManager$1 = InterceptorManager, transitionalDefaults = {
625
- silentJSONParsing: !0,
626
- forcedJSONParsing: !0,
627
- clarifyTimeoutError: !1
628
- }, URLSearchParams$1 = typeof URLSearchParams < "u" ? URLSearchParams : AxiosURLSearchParams, FormData$1 = typeof FormData < "u" ? FormData : null, Blob$1 = typeof Blob < "u" ? Blob : null, isStandardBrowserEnv = (() => {
629
- let product;
630
- return typeof navigator < "u" && ((product = navigator.product) === "ReactNative" || product === "NativeScript" || product === "NS") ? !1 : typeof window < "u" && typeof document < "u";
631
- })(), isStandardBrowserWebWorkerEnv = (() => typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
632
- self instanceof WorkerGlobalScope && typeof self.importScripts == "function")(), platform = {
633
- isBrowser: !0,
634
- classes: {
635
- URLSearchParams: URLSearchParams$1,
636
- FormData: FormData$1,
637
- Blob: Blob$1
638
- },
639
- isStandardBrowserEnv,
640
- isStandardBrowserWebWorkerEnv,
641
- protocols: ["http", "https", "file", "blob", "url", "data"]
642
- };
643
- function toURLEncodedForm(data, options) {
644
- return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
645
- visitor: function(value, key, path, helpers) {
646
- return platform.isNode && utils.isBuffer(value) ? (this.append(key, value.toString("base64")), !1) : helpers.defaultVisitor.apply(this, arguments);
647
- }
648
- }, options));
649
- }
650
- function parsePropPath(name) {
651
- return utils.matchAll(/\w+|\[(\w*)]/g, name).map((match) => match[0] === "[]" ? "" : match[1] || match[0]);
652
- }
653
- function arrayToObject(arr) {
654
- const obj = {}, keys = Object.keys(arr);
655
- let i;
656
- const len = keys.length;
657
- let key;
658
- for (i = 0; i < len; i++)
659
- key = keys[i], obj[key] = arr[key];
660
- return obj;
661
- }
662
- function formDataToJSON(formData) {
663
- function buildPath(path, value, target, index) {
664
- let name = path[index++];
665
- const isNumericKey = Number.isFinite(+name), isLast = index >= path.length;
666
- 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);
667
- }
668
- if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
669
- const obj = {};
670
- return utils.forEachEntry(formData, (name, value) => {
671
- buildPath(parsePropPath(name), value, obj, 0);
672
- }), obj;
673
- }
674
- return null;
675
- }
676
- function stringifySafely(rawValue, parser, encoder) {
677
- if (utils.isString(rawValue))
678
- try {
679
- return (parser || JSON.parse)(rawValue), utils.trim(rawValue);
680
- } catch (e) {
681
- if (e.name !== "SyntaxError")
682
- throw e;
683
- }
684
- return (encoder || JSON.stringify)(rawValue);
685
- }
686
- const defaults = {
687
- transitional: transitionalDefaults,
688
- adapter: ["xhr", "http"],
689
- transformRequest: [function(data, headers) {
690
- const contentType = headers.getContentType() || "", hasJSONContentType = contentType.indexOf("application/json") > -1, isObjectPayload = utils.isObject(data);
691
- if (isObjectPayload && utils.isHTMLForm(data) && (data = new FormData(data)), utils.isFormData(data))
692
- return hasJSONContentType && hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
693
- if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data))
694
- return data;
695
- if (utils.isArrayBufferView(data))
696
- return data.buffer;
697
- if (utils.isURLSearchParams(data))
698
- return headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), data.toString();
699
- let isFileList2;
700
- if (isObjectPayload) {
701
- if (contentType.indexOf("application/x-www-form-urlencoded") > -1)
702
- return toURLEncodedForm(data, this.formSerializer).toString();
703
- if ((isFileList2 = utils.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
704
- const _FormData = this.env && this.env.FormData;
705
- return toFormData(
706
- isFileList2 ? { "files[]": data } : data,
707
- _FormData && new _FormData(),
708
- this.formSerializer
709
- );
710
- }
711
- }
712
- return isObjectPayload || hasJSONContentType ? (headers.setContentType("application/json", !1), stringifySafely(data)) : data;
713
- }],
714
- transformResponse: [function(data) {
715
- const transitional2 = this.transitional || defaults.transitional, forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing, JSONRequested = this.responseType === "json";
716
- if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
717
- const strictJSONParsing = !(transitional2 && transitional2.silentJSONParsing) && JSONRequested;
718
- try {
719
- return JSON.parse(data);
720
- } catch (e) {
721
- if (strictJSONParsing)
722
- throw e.name === "SyntaxError" ? AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response) : e;
723
- }
724
- }
725
- return data;
726
- }],
727
- /**
728
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
729
- * timeout is not created.
730
- */
731
- timeout: 0,
732
- xsrfCookieName: "XSRF-TOKEN",
733
- xsrfHeaderName: "X-XSRF-TOKEN",
734
- maxContentLength: -1,
735
- maxBodyLength: -1,
736
- env: {
737
- FormData: platform.classes.FormData,
738
- Blob: platform.classes.Blob
739
- },
740
- validateStatus: function(status) {
741
- return status >= 200 && status < 300;
742
- },
743
- headers: {
744
- common: {
745
- Accept: "application/json, text/plain, */*",
746
- "Content-Type": void 0
747
- }
748
- }
749
- };
750
- utils.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
751
- defaults.headers[method] = {};
752
- });
753
- const defaults$1 = defaults, ignoreDuplicateOf = utils.toObjectSet([
754
- "age",
755
- "authorization",
756
- "content-length",
757
- "content-type",
758
- "etag",
759
- "expires",
760
- "from",
761
- "host",
762
- "if-modified-since",
763
- "if-unmodified-since",
764
- "last-modified",
765
- "location",
766
- "max-forwards",
767
- "proxy-authorization",
768
- "referer",
769
- "retry-after",
770
- "user-agent"
771
- ]), parseHeaders = (rawHeaders) => {
772
- const parsed = {};
773
- let key, val, i;
774
- return rawHeaders && rawHeaders.split(`
775
- `).forEach(function(line) {
776
- 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);
777
- }), parsed;
778
- }, $internals = Symbol("internals");
779
- function normalizeHeader(header) {
780
- return header && String(header).trim().toLowerCase();
781
- }
782
- function normalizeValue(value) {
783
- return value === !1 || value == null ? value : utils.isArray(value) ? value.map(normalizeValue) : String(value);
784
- }
785
- function parseTokens(str) {
786
- const tokens = /* @__PURE__ */ Object.create(null), tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
787
- let match;
788
- for (; match = tokensRE.exec(str); )
789
- tokens[match[1]] = match[2];
790
- return tokens;
791
- }
792
- const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
793
- function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
794
- if (utils.isFunction(filter2))
795
- return filter2.call(this, value, header);
796
- if (isHeaderNameFilter && (value = header), !!utils.isString(value)) {
797
- if (utils.isString(filter2))
798
- return value.indexOf(filter2) !== -1;
799
- if (utils.isRegExp(filter2))
800
- return filter2.test(value);
801
- }
802
- }
803
- function formatHeader(header) {
804
- return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => char.toUpperCase() + str);
805
- }
806
- function buildAccessors(obj, header) {
807
- const accessorName = utils.toCamelCase(" " + header);
808
- ["get", "set", "has"].forEach((methodName) => {
809
- Object.defineProperty(obj, methodName + accessorName, {
810
- value: function(arg1, arg2, arg3) {
811
- return this[methodName].call(this, header, arg1, arg2, arg3);
812
- },
813
- configurable: !0
814
- });
815
- });
816
- }
817
- class AxiosHeaders {
818
- constructor(headers) {
819
- headers && this.set(headers);
820
- }
821
- set(header, valueOrRewrite, rewrite) {
822
- const self2 = this;
823
- function setHeader(_value, _header, _rewrite) {
824
- const lHeader = normalizeHeader(_header);
825
- if (!lHeader)
826
- throw new Error("header name must be a non-empty string");
827
- const key = utils.findKey(self2, lHeader);
828
- (!key || self2[key] === void 0 || _rewrite === !0 || _rewrite === void 0 && self2[key] !== !1) && (self2[key || _header] = normalizeValue(_value));
829
- }
830
- const setHeaders = (headers, _rewrite) => utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
831
- 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;
832
- }
833
- get(header, parser) {
834
- if (header = normalizeHeader(header), header) {
835
- const key = utils.findKey(this, header);
836
- if (key) {
837
- const value = this[key];
838
- if (!parser)
839
- return value;
840
- if (parser === !0)
841
- return parseTokens(value);
842
- if (utils.isFunction(parser))
843
- return parser.call(this, value, key);
844
- if (utils.isRegExp(parser))
845
- return parser.exec(value);
846
- throw new TypeError("parser must be boolean|regexp|function");
847
- }
848
- }
849
- }
850
- has(header, matcher) {
851
- if (header = normalizeHeader(header), header) {
852
- const key = utils.findKey(this, header);
853
- return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
854
- }
855
- return !1;
856
- }
857
- delete(header, matcher) {
858
- const self2 = this;
859
- let deleted = !1;
860
- function deleteHeader(_header) {
861
- if (_header = normalizeHeader(_header), _header) {
862
- const key = utils.findKey(self2, _header);
863
- key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher)) && (delete self2[key], deleted = !0);
864
- }
865
- }
866
- return utils.isArray(header) ? header.forEach(deleteHeader) : deleteHeader(header), deleted;
867
- }
868
- clear(matcher) {
869
- const keys = Object.keys(this);
870
- let i = keys.length, deleted = !1;
871
- for (; i--; ) {
872
- const key = keys[i];
873
- (!matcher || matchHeaderValue(this, this[key], key, matcher, !0)) && (delete this[key], deleted = !0);
874
- }
875
- return deleted;
876
- }
877
- normalize(format) {
878
- const self2 = this, headers = {};
879
- return utils.forEach(this, (value, header) => {
880
- const key = utils.findKey(headers, header);
881
- if (key) {
882
- self2[key] = normalizeValue(value), delete self2[header];
883
- return;
884
- }
885
- const normalized = format ? formatHeader(header) : String(header).trim();
886
- normalized !== header && delete self2[header], self2[normalized] = normalizeValue(value), headers[normalized] = !0;
887
- }), this;
888
- }
889
- concat(...targets) {
890
- return this.constructor.concat(this, ...targets);
891
- }
892
- toJSON(asStrings) {
893
- const obj = /* @__PURE__ */ Object.create(null);
894
- return utils.forEach(this, (value, header) => {
895
- value != null && value !== !1 && (obj[header] = asStrings && utils.isArray(value) ? value.join(", ") : value);
896
- }), obj;
897
- }
898
- [Symbol.iterator]() {
899
- return Object.entries(this.toJSON())[Symbol.iterator]();
900
- }
901
- toString() {
902
- return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join(`
903
- `);
904
- }
905
- get [Symbol.toStringTag]() {
906
- return "AxiosHeaders";
907
- }
908
- static from(thing) {
909
- return thing instanceof this ? thing : new this(thing);
910
- }
911
- static concat(first, ...targets) {
912
- const computed = new this(first);
913
- return targets.forEach((target) => computed.set(target)), computed;
914
- }
915
- static accessor(header) {
916
- const accessors = (this[$internals] = this[$internals] = {
917
- accessors: {}
918
- }).accessors, prototype2 = this.prototype;
919
- function defineAccessor(_header) {
920
- const lHeader = normalizeHeader(_header);
921
- accessors[lHeader] || (buildAccessors(prototype2, _header), accessors[lHeader] = !0);
922
- }
923
- return utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header), this;
924
- }
925
- }
926
- AxiosHeaders.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
927
- utils.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
928
- let mapped = key[0].toUpperCase() + key.slice(1);
929
- return {
930
- get: () => value,
931
- set(headerValue) {
932
- this[mapped] = headerValue;
933
- }
934
- };
935
- });
936
- utils.freezeMethods(AxiosHeaders);
937
- const AxiosHeaders$1 = AxiosHeaders;
938
- function transformData(fns, response) {
939
- const config = this || defaults$1, context = response || config, headers = AxiosHeaders$1.from(context.headers);
940
- let data = context.data;
941
- return utils.forEach(fns, function(fn) {
942
- data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
943
- }), headers.normalize(), data;
944
- }
945
- function isCancel(value) {
946
- return !!(value && value.__CANCEL__);
947
- }
948
- function CanceledError(message, config, request) {
949
- AxiosError.call(this, message ?? "canceled", AxiosError.ERR_CANCELED, config, request), this.name = "CanceledError";
950
- }
951
- utils.inherits(CanceledError, AxiosError, {
952
- __CANCEL__: !0
953
- });
954
- function settle(resolve, reject, response) {
955
- const validateStatus2 = response.config.validateStatus;
956
- !response.status || !validateStatus2 || validateStatus2(response.status) ? resolve(response) : reject(new AxiosError(
957
- "Request failed with status code " + response.status,
958
- [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
959
- response.config,
960
- response.request,
961
- response
962
- ));
963
- }
964
- const cookies = platform.isStandardBrowserEnv ? (
965
- // Standard browser envs support document.cookie
966
- function() {
967
- return {
968
- write: function(name, value, expires, path, domain, secure) {
969
- const cookie = [];
970
- 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("; ");
971
- },
972
- read: function(name) {
973
- const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
974
- return match ? decodeURIComponent(match[3]) : null;
975
- },
976
- remove: function(name) {
977
- this.write(name, "", Date.now() - 864e5);
978
- }
979
- };
980
- }()
981
- ) : (
982
- // Non standard browser env (web workers, react-native) lack needed support.
983
- function() {
984
- return {
985
- write: function() {
986
- },
987
- read: function() {
988
- return null;
989
- },
990
- remove: function() {
991
- }
992
- };
993
- }()
994
- );
995
- function isAbsoluteURL(url) {
996
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
997
- }
998
- function combineURLs(baseURL, relativeURL) {
999
- return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
1000
- }
1001
- function buildFullPath(baseURL, requestedURL) {
1002
- return baseURL && !isAbsoluteURL(requestedURL) ? combineURLs(baseURL, requestedURL) : requestedURL;
1003
- }
1004
- const isURLSameOrigin = platform.isStandardBrowserEnv ? (
1005
- // Standard browser envs have full support of the APIs needed to test
1006
- // whether the request URL is of the same origin as current location.
1007
- function() {
1008
- const msie = /(msie|trident)/i.test(navigator.userAgent), urlParsingNode = document.createElement("a");
1009
- let originURL;
1010
- function resolveURL(url) {
1011
- let href = url;
1012
- return msie && (urlParsingNode.setAttribute("href", href), href = urlParsingNode.href), urlParsingNode.setAttribute("href", href), {
1013
- href: urlParsingNode.href,
1014
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
1015
- host: urlParsingNode.host,
1016
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
1017
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
1018
- hostname: urlParsingNode.hostname,
1019
- port: urlParsingNode.port,
1020
- pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
1021
- };
1022
- }
1023
- return originURL = resolveURL(window.location.href), function(requestURL) {
1024
- const parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
1025
- return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
1026
- };
1027
- }()
1028
- ) : (
1029
- // Non standard browser envs (web workers, react-native) lack needed support.
1030
- function() {
1031
- return function() {
1032
- return !0;
1033
- };
1034
- }()
1035
- );
1036
- function parseProtocol(url) {
1037
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1038
- return match && match[1] || "";
1039
- }
1040
- function speedometer(samplesCount, min) {
1041
- samplesCount = samplesCount || 10;
1042
- const bytes = new Array(samplesCount), timestamps = new Array(samplesCount);
1043
- let head = 0, tail = 0, firstSampleTS;
1044
- return min = min !== void 0 ? min : 1e3, function(chunkLength) {
1045
- const now = Date.now(), startedAt = timestamps[tail];
1046
- firstSampleTS || (firstSampleTS = now), bytes[head] = chunkLength, timestamps[head] = now;
1047
- let i = tail, bytesCount = 0;
1048
- for (; i !== head; )
1049
- bytesCount += bytes[i++], i = i % samplesCount;
1050
- if (head = (head + 1) % samplesCount, head === tail && (tail = (tail + 1) % samplesCount), now - firstSampleTS < min)
1051
- return;
1052
- const passed = startedAt && now - startedAt;
1053
- return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
1054
- };
1055
- }
1056
- function progressEventReducer(listener, isDownloadStream) {
1057
- let bytesNotified = 0;
1058
- const _speedometer = speedometer(50, 250);
1059
- return (e) => {
1060
- const loaded = e.loaded, total = e.lengthComputable ? e.total : void 0, progressBytes = loaded - bytesNotified, rate = _speedometer(progressBytes), inRange = loaded <= total;
1061
- bytesNotified = loaded;
1062
- const data = {
1063
- loaded,
1064
- total,
1065
- progress: total ? loaded / total : void 0,
1066
- bytes: progressBytes,
1067
- rate: rate || void 0,
1068
- estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
1069
- event: e
1070
- };
1071
- data[isDownloadStream ? "download" : "upload"] = !0, listener(data);
1072
- };
1073
- }
1074
- const isXHRAdapterSupported = typeof XMLHttpRequest < "u", xhrAdapter = isXHRAdapterSupported && function(config) {
1075
- return new Promise(function(resolve, reject) {
1076
- let requestData = config.data;
1077
- const requestHeaders = AxiosHeaders$1.from(config.headers).normalize(), responseType = config.responseType;
1078
- let onCanceled;
1079
- function done() {
1080
- config.cancelToken && config.cancelToken.unsubscribe(onCanceled), config.signal && config.signal.removeEventListener("abort", onCanceled);
1081
- }
1082
- let contentType;
1083
- 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"));
1084
- let request = new XMLHttpRequest();
1085
- if (config.auth) {
1086
- const username = config.auth.username || "", password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : "";
1087
- requestHeaders.set("Authorization", "Basic " + btoa(username + ":" + password));
1088
- }
1089
- const fullPath = buildFullPath(config.baseURL, config.url);
1090
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), !0), request.timeout = config.timeout;
1091
- function onloadend() {
1092
- if (!request)
1093
- return;
1094
- const responseHeaders = AxiosHeaders$1.from(
1095
- "getAllResponseHeaders" in request && request.getAllResponseHeaders()
1096
- ), response = {
1097
- data: !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response,
1098
- status: request.status,
1099
- statusText: request.statusText,
1100
- headers: responseHeaders,
1101
- config,
1102
- request
1103
- };
1104
- settle(function(value) {
1105
- resolve(value), done();
1106
- }, function(err) {
1107
- reject(err), done();
1108
- }, response), request = null;
1109
- }
1110
- if ("onloadend" in request ? request.onloadend = onloadend : request.onreadystatechange = function() {
1111
- !request || request.readyState !== 4 || request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0) || setTimeout(onloadend);
1112
- }, request.onabort = function() {
1113
- request && (reject(new AxiosError("Request aborted", AxiosError.ECONNABORTED, config, request)), request = null);
1114
- }, request.onerror = function() {
1115
- reject(new AxiosError("Network Error", AxiosError.ERR_NETWORK, config, request)), request = null;
1116
- }, request.ontimeout = function() {
1117
- let timeoutErrorMessage = config.timeout ? "timeout of " + config.timeout + "ms exceeded" : "timeout exceeded";
1118
- const transitional2 = config.transitional || transitionalDefaults;
1119
- config.timeoutErrorMessage && (timeoutErrorMessage = config.timeoutErrorMessage), reject(new AxiosError(
1120
- timeoutErrorMessage,
1121
- transitional2.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
1122
- config,
1123
- request
1124
- )), request = null;
1125
- }, platform.isStandardBrowserEnv) {
1126
- const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
1127
- xsrfValue && requestHeaders.set(config.xsrfHeaderName, xsrfValue);
1128
- }
1129
- requestData === void 0 && requestHeaders.setContentType(null), "setRequestHeader" in request && utils.forEach(requestHeaders.toJSON(), function(val, key) {
1130
- request.setRequestHeader(key, val);
1131
- }), 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) => {
1132
- request && (reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel), request.abort(), request = null);
1133
- }, config.cancelToken && config.cancelToken.subscribe(onCanceled), config.signal && (config.signal.aborted ? onCanceled() : config.signal.addEventListener("abort", onCanceled)));
1134
- const protocol = parseProtocol(fullPath);
1135
- if (protocol && platform.protocols.indexOf(protocol) === -1) {
1136
- reject(new AxiosError("Unsupported protocol " + protocol + ":", AxiosError.ERR_BAD_REQUEST, config));
1137
- return;
1138
- }
1139
- request.send(requestData || null);
1140
- });
1141
- }, knownAdapters = {
1142
- http: httpAdapter,
1143
- xhr: xhrAdapter
1144
- };
1145
- utils.forEach(knownAdapters, (fn, value) => {
1146
- if (fn) {
1147
- try {
1148
- Object.defineProperty(fn, "name", { value });
1149
- } catch {
1150
- }
1151
- Object.defineProperty(fn, "adapterName", { value });
1152
- }
1153
- });
1154
- const renderReason = (reason) => `- ${reason}`, isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === !1, adapters = {
1155
- getAdapter: (adapters2) => {
1156
- adapters2 = utils.isArray(adapters2) ? adapters2 : [adapters2];
1157
- const { length } = adapters2;
1158
- let nameOrAdapter, adapter;
1159
- const rejectedReasons = {};
1160
- for (let i = 0; i < length; i++) {
1161
- nameOrAdapter = adapters2[i];
1162
- let id;
1163
- if (adapter = nameOrAdapter, !isResolvedHandle(nameOrAdapter) && (adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()], adapter === void 0))
1164
- throw new AxiosError(`Unknown adapter '${id}'`);
1165
- if (adapter)
1166
- break;
1167
- rejectedReasons[id || "#" + i] = adapter;
1168
- }
1169
- if (!adapter) {
1170
- const reasons = Object.entries(rejectedReasons).map(
1171
- ([id, state]) => `adapter ${id} ` + (state === !1 ? "is not supported by the environment" : "is not available in the build")
1172
- );
1173
- let s = length ? reasons.length > 1 ? `since :
1174
- ` + reasons.map(renderReason).join(`
1175
- `) : " " + renderReason(reasons[0]) : "as no adapter specified";
1176
- throw new AxiosError(
1177
- "There is no suitable adapter to dispatch the request " + s,
1178
- "ERR_NOT_SUPPORT"
1179
- );
1180
- }
1181
- return adapter;
1182
- },
1183
- adapters: knownAdapters
1184
- };
1185
- function throwIfCancellationRequested(config) {
1186
- if (config.cancelToken && config.cancelToken.throwIfRequested(), config.signal && config.signal.aborted)
1187
- throw new CanceledError(null, config);
1188
- }
1189
- function dispatchRequest(config) {
1190
- return throwIfCancellationRequested(config), config.headers = AxiosHeaders$1.from(config.headers), config.data = transformData.call(
1191
- config,
1192
- config.transformRequest
1193
- ), ["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) {
1194
- return throwIfCancellationRequested(config), response.data = transformData.call(
1195
- config,
1196
- config.transformResponse,
1197
- response
1198
- ), response.headers = AxiosHeaders$1.from(response.headers), response;
1199
- }, function(reason) {
1200
- return isCancel(reason) || (throwIfCancellationRequested(config), reason && reason.response && (reason.response.data = transformData.call(
1201
- config,
1202
- config.transformResponse,
1203
- reason.response
1204
- ), reason.response.headers = AxiosHeaders$1.from(reason.response.headers))), Promise.reject(reason);
1205
- });
1206
- }
1207
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
1208
- function mergeConfig(config1, config2) {
1209
- config2 = config2 || {};
1210
- const config = {};
1211
- function getMergedValue(target, source, caseless) {
1212
- 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;
1213
- }
1214
- function mergeDeepProperties(a, b, caseless) {
1215
- if (utils.isUndefined(b)) {
1216
- if (!utils.isUndefined(a))
1217
- return getMergedValue(void 0, a, caseless);
1218
- } else
1219
- return getMergedValue(a, b, caseless);
1220
- }
1221
- function valueFromConfig2(a, b) {
1222
- if (!utils.isUndefined(b))
1223
- return getMergedValue(void 0, b);
1224
- }
1225
- function defaultToConfig2(a, b) {
1226
- if (utils.isUndefined(b)) {
1227
- if (!utils.isUndefined(a))
1228
- return getMergedValue(void 0, a);
1229
- } else
1230
- return getMergedValue(void 0, b);
1231
- }
1232
- function mergeDirectKeys(a, b, prop) {
1233
- if (prop in config2)
1234
- return getMergedValue(a, b);
1235
- if (prop in config1)
1236
- return getMergedValue(void 0, a);
1237
- }
1238
- const mergeMap = {
1239
- url: valueFromConfig2,
1240
- method: valueFromConfig2,
1241
- data: valueFromConfig2,
1242
- baseURL: defaultToConfig2,
1243
- transformRequest: defaultToConfig2,
1244
- transformResponse: defaultToConfig2,
1245
- paramsSerializer: defaultToConfig2,
1246
- timeout: defaultToConfig2,
1247
- timeoutMessage: defaultToConfig2,
1248
- withCredentials: defaultToConfig2,
1249
- adapter: defaultToConfig2,
1250
- responseType: defaultToConfig2,
1251
- xsrfCookieName: defaultToConfig2,
1252
- xsrfHeaderName: defaultToConfig2,
1253
- onUploadProgress: defaultToConfig2,
1254
- onDownloadProgress: defaultToConfig2,
1255
- decompress: defaultToConfig2,
1256
- maxContentLength: defaultToConfig2,
1257
- maxBodyLength: defaultToConfig2,
1258
- beforeRedirect: defaultToConfig2,
1259
- transport: defaultToConfig2,
1260
- httpAgent: defaultToConfig2,
1261
- httpsAgent: defaultToConfig2,
1262
- cancelToken: defaultToConfig2,
1263
- socketPath: defaultToConfig2,
1264
- responseEncoding: defaultToConfig2,
1265
- validateStatus: mergeDirectKeys,
1266
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), !0)
1267
- };
1268
- return utils.forEach(Object.keys(Object.assign({}, config1, config2)), function(prop) {
1269
- const merge2 = mergeMap[prop] || mergeDeepProperties, configValue = merge2(config1[prop], config2[prop], prop);
1270
- utils.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
1271
- }), config;
1272
- }
1273
- const VERSION = "1.5.1", validators$1 = {};
1274
- ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
1275
- validators$1[type] = function(thing) {
1276
- return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
1277
- };
1278
- });
1279
- const deprecatedWarnings = {};
1280
- validators$1.transitional = function(validator2, version, message) {
1281
- function formatMessage(opt, desc) {
1282
- return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
1283
- }
1284
- return (value, opt, opts) => {
1285
- if (validator2 === !1)
1286
- throw new AxiosError(
1287
- formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
1288
- AxiosError.ERR_DEPRECATED
1289
- );
1290
- return version && !deprecatedWarnings[opt] && (deprecatedWarnings[opt] = !0, console.warn(
1291
- formatMessage(
1292
- opt,
1293
- " has been deprecated since v" + version + " and will be removed in the near future"
1294
- )
1295
- )), validator2 ? validator2(value, opt, opts) : !0;
1296
- };
1297
- };
1298
- function assertOptions(options, schema, allowUnknown) {
1299
- if (typeof options != "object")
1300
- throw new AxiosError("options must be an object", AxiosError.ERR_BAD_OPTION_VALUE);
1301
- const keys = Object.keys(options);
1302
- let i = keys.length;
1303
- for (; i-- > 0; ) {
1304
- const opt = keys[i], validator2 = schema[opt];
1305
- if (validator2) {
1306
- const value = options[opt], result = value === void 0 || validator2(value, opt, options);
1307
- if (result !== !0)
1308
- throw new AxiosError("option " + opt + " must be " + result, AxiosError.ERR_BAD_OPTION_VALUE);
1309
- continue;
1310
- }
1311
- if (allowUnknown !== !0)
1312
- throw new AxiosError("Unknown option " + opt, AxiosError.ERR_BAD_OPTION);
1313
- }
1314
- }
1315
- const validator = {
1316
- assertOptions,
1317
- validators: validators$1
1318
- }, validators = validator.validators;
1319
- class Axios {
1320
- constructor(instanceConfig) {
1321
- this.defaults = instanceConfig, this.interceptors = {
1322
- request: new InterceptorManager$1(),
1323
- response: new InterceptorManager$1()
1324
- };
1325
- }
1326
- /**
1327
- * Dispatch a request
1328
- *
1329
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
1330
- * @param {?Object} config
1331
- *
1332
- * @returns {Promise} The Promise to be fulfilled
1333
- */
1334
- request(configOrUrl, config) {
1335
- typeof configOrUrl == "string" ? (config = config || {}, config.url = configOrUrl) : config = configOrUrl || {}, config = mergeConfig(this.defaults, config);
1336
- const { transitional: transitional2, paramsSerializer, headers } = config;
1337
- transitional2 !== void 0 && validator.assertOptions(transitional2, {
1338
- silentJSONParsing: validators.transitional(validators.boolean),
1339
- forcedJSONParsing: validators.transitional(validators.boolean),
1340
- clarifyTimeoutError: validators.transitional(validators.boolean)
1341
- }, !1), paramsSerializer != null && (utils.isFunction(paramsSerializer) ? config.paramsSerializer = {
1342
- serialize: paramsSerializer
1343
- } : validator.assertOptions(paramsSerializer, {
1344
- encode: validators.function,
1345
- serialize: validators.function
1346
- }, !0)), config.method = (config.method || this.defaults.method || "get").toLowerCase();
1347
- let contextHeaders = headers && utils.merge(
1348
- headers.common,
1349
- headers[config.method]
1350
- );
1351
- headers && utils.forEach(
1352
- ["delete", "get", "head", "post", "put", "patch", "common"],
1353
- (method) => {
1354
- delete headers[method];
1355
- }
1356
- ), config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
1357
- const requestInterceptorChain = [];
1358
- let synchronousRequestInterceptors = !0;
1359
- this.interceptors.request.forEach(function(interceptor) {
1360
- typeof interceptor.runWhen == "function" && interceptor.runWhen(config) === !1 || (synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous, requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected));
1361
- });
1362
- const responseInterceptorChain = [];
1363
- this.interceptors.response.forEach(function(interceptor) {
1364
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
1365
- });
1366
- let promise, i = 0, len;
1367
- if (!synchronousRequestInterceptors) {
1368
- const chain = [dispatchRequest.bind(this), void 0];
1369
- for (chain.unshift.apply(chain, requestInterceptorChain), chain.push.apply(chain, responseInterceptorChain), len = chain.length, promise = Promise.resolve(config); i < len; )
1370
- promise = promise.then(chain[i++], chain[i++]);
1371
- return promise;
1372
- }
1373
- len = requestInterceptorChain.length;
1374
- let newConfig = config;
1375
- for (i = 0; i < len; ) {
1376
- const onFulfilled = requestInterceptorChain[i++], onRejected = requestInterceptorChain[i++];
1377
- try {
1378
- newConfig = onFulfilled(newConfig);
1379
- } catch (error) {
1380
- onRejected.call(this, error);
1381
- break;
1382
- }
1383
- }
1384
- try {
1385
- promise = dispatchRequest.call(this, newConfig);
1386
- } catch (error) {
1387
- return Promise.reject(error);
1388
- }
1389
- for (i = 0, len = responseInterceptorChain.length; i < len; )
1390
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
1391
- return promise;
1392
- }
1393
- getUri(config) {
1394
- config = mergeConfig(this.defaults, config);
1395
- const fullPath = buildFullPath(config.baseURL, config.url);
1396
- return buildURL(fullPath, config.params, config.paramsSerializer);
1397
- }
1398
- }
1399
- utils.forEach(["delete", "get", "head", "options"], function(method) {
1400
- Axios.prototype[method] = function(url, config) {
1401
- return this.request(mergeConfig(config || {}, {
1402
- method,
1403
- url,
1404
- data: (config || {}).data
1405
- }));
1406
- };
1407
- });
1408
- utils.forEach(["post", "put", "patch"], function(method) {
1409
- function generateHTTPMethod(isForm) {
1410
- return function(url, data, config) {
1411
- return this.request(mergeConfig(config || {}, {
1412
- method,
1413
- headers: isForm ? {
1414
- "Content-Type": "multipart/form-data"
1415
- } : {},
1416
- url,
1417
- data
1418
- }));
1419
- };
1420
- }
1421
- Axios.prototype[method] = generateHTTPMethod(), Axios.prototype[method + "Form"] = generateHTTPMethod(!0);
1422
- });
1423
- const Axios$1 = Axios;
1424
- class CancelToken {
1425
- constructor(executor) {
1426
- if (typeof executor != "function")
1427
- throw new TypeError("executor must be a function.");
1428
- let resolvePromise;
1429
- this.promise = new Promise(function(resolve) {
1430
- resolvePromise = resolve;
1431
- });
1432
- const token = this;
1433
- this.promise.then((cancel) => {
1434
- if (!token._listeners)
1435
- return;
1436
- let i = token._listeners.length;
1437
- for (; i-- > 0; )
1438
- token._listeners[i](cancel);
1439
- token._listeners = null;
1440
- }), this.promise.then = (onfulfilled) => {
1441
- let _resolve;
1442
- const promise = new Promise((resolve) => {
1443
- token.subscribe(resolve), _resolve = resolve;
1444
- }).then(onfulfilled);
1445
- return promise.cancel = function() {
1446
- token.unsubscribe(_resolve);
1447
- }, promise;
1448
- }, executor(function(message, config, request) {
1449
- token.reason || (token.reason = new CanceledError(message, config, request), resolvePromise(token.reason));
1450
- });
1451
- }
1452
- /**
1453
- * Throws a `CanceledError` if cancellation has been requested.
1454
- */
1455
- throwIfRequested() {
1456
- if (this.reason)
1457
- throw this.reason;
1458
- }
1459
- /**
1460
- * Subscribe to the cancel signal
1461
- */
1462
- subscribe(listener) {
1463
- if (this.reason) {
1464
- listener(this.reason);
1465
- return;
1466
- }
1467
- this._listeners ? this._listeners.push(listener) : this._listeners = [listener];
1468
- }
1469
- /**
1470
- * Unsubscribe from the cancel signal
1471
- */
1472
- unsubscribe(listener) {
1473
- if (!this._listeners)
1474
- return;
1475
- const index = this._listeners.indexOf(listener);
1476
- index !== -1 && this._listeners.splice(index, 1);
1477
- }
1478
- /**
1479
- * Returns an object that contains a new `CancelToken` and a function that, when called,
1480
- * cancels the `CancelToken`.
1481
- */
1482
- static source() {
1483
- let cancel;
1484
- return {
1485
- token: new CancelToken(function(c) {
1486
- cancel = c;
1487
- }),
1488
- cancel
1489
- };
1490
- }
1491
- }
1492
- const CancelToken$1 = CancelToken;
1493
- function spread(callback) {
1494
- return function(arr) {
1495
- return callback.apply(null, arr);
1496
- };
1497
- }
1498
- function isAxiosError(payload) {
1499
- return utils.isObject(payload) && payload.isAxiosError === !0;
1500
- }
1501
- const HttpStatusCode = {
1502
- Continue: 100,
1503
- SwitchingProtocols: 101,
1504
- Processing: 102,
1505
- EarlyHints: 103,
1506
- Ok: 200,
1507
- Created: 201,
1508
- Accepted: 202,
1509
- NonAuthoritativeInformation: 203,
1510
- NoContent: 204,
1511
- ResetContent: 205,
1512
- PartialContent: 206,
1513
- MultiStatus: 207,
1514
- AlreadyReported: 208,
1515
- ImUsed: 226,
1516
- MultipleChoices: 300,
1517
- MovedPermanently: 301,
1518
- Found: 302,
1519
- SeeOther: 303,
1520
- NotModified: 304,
1521
- UseProxy: 305,
1522
- Unused: 306,
1523
- TemporaryRedirect: 307,
1524
- PermanentRedirect: 308,
1525
- BadRequest: 400,
1526
- Unauthorized: 401,
1527
- PaymentRequired: 402,
1528
- Forbidden: 403,
1529
- NotFound: 404,
1530
- MethodNotAllowed: 405,
1531
- NotAcceptable: 406,
1532
- ProxyAuthenticationRequired: 407,
1533
- RequestTimeout: 408,
1534
- Conflict: 409,
1535
- Gone: 410,
1536
- LengthRequired: 411,
1537
- PreconditionFailed: 412,
1538
- PayloadTooLarge: 413,
1539
- UriTooLong: 414,
1540
- UnsupportedMediaType: 415,
1541
- RangeNotSatisfiable: 416,
1542
- ExpectationFailed: 417,
1543
- ImATeapot: 418,
1544
- MisdirectedRequest: 421,
1545
- UnprocessableEntity: 422,
1546
- Locked: 423,
1547
- FailedDependency: 424,
1548
- TooEarly: 425,
1549
- UpgradeRequired: 426,
1550
- PreconditionRequired: 428,
1551
- TooManyRequests: 429,
1552
- RequestHeaderFieldsTooLarge: 431,
1553
- UnavailableForLegalReasons: 451,
1554
- InternalServerError: 500,
1555
- NotImplemented: 501,
1556
- BadGateway: 502,
1557
- ServiceUnavailable: 503,
1558
- GatewayTimeout: 504,
1559
- HttpVersionNotSupported: 505,
1560
- VariantAlsoNegotiates: 506,
1561
- InsufficientStorage: 507,
1562
- LoopDetected: 508,
1563
- NotExtended: 510,
1564
- NetworkAuthenticationRequired: 511
1565
- };
1566
- Object.entries(HttpStatusCode).forEach(([key, value]) => {
1567
- HttpStatusCode[value] = key;
1568
- });
1569
- const HttpStatusCode$1 = HttpStatusCode;
1570
- function createInstance(defaultConfig) {
1571
- const context = new Axios$1(defaultConfig), instance = bind(Axios$1.prototype.request, context);
1572
- return utils.extend(instance, Axios$1.prototype, context, { allOwnKeys: !0 }), utils.extend(instance, context, null, { allOwnKeys: !0 }), instance.create = function(instanceConfig) {
1573
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
1574
- }, instance;
1575
- }
1576
- const axios = createInstance(defaults$1);
1577
- axios.Axios = Axios$1;
1578
- axios.CanceledError = CanceledError;
1579
- axios.CancelToken = CancelToken$1;
1580
- axios.isCancel = isCancel;
1581
- axios.VERSION = VERSION;
1582
- axios.toFormData = toFormData;
1583
- axios.AxiosError = AxiosError;
1584
- axios.Cancel = axios.CanceledError;
1585
- axios.all = function(promises) {
1586
- return Promise.all(promises);
1587
- };
1588
- axios.spread = spread;
1589
- axios.isAxiosError = isAxiosError;
1590
- axios.mergeConfig = mergeConfig;
1591
- axios.AxiosHeaders = AxiosHeaders$1;
1592
- axios.formToJSON = (thing) => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
1593
- axios.getAdapter = adapters.getAdapter;
1594
- axios.HttpStatusCode = HttpStatusCode$1;
1595
- axios.default = axios;
1596
- const axios$1 = axios;
1597
172
  class HttpClient {
1598
- constructor(url, httpRequester = null) {
173
+ constructor(url, fetchMethod = null) {
1599
174
  __publicField(this, "_url", null);
1600
175
  __publicField(this, "_token", null);
1601
176
  //Added for testing support
1602
- __publicField(this, "_httpRequester");
177
+ __publicField(this, "_fetch");
1603
178
  if (!url)
1604
179
  throw Error("Endpoint URL must be passed in to NotuClient constructor");
1605
- this._url = url, this._httpRequester = httpRequester ?? axios$1;
180
+ url.endsWith("/") && (url = url.substring(0, url.length - 1)), this._url = url, this._fetch = fetchMethod ?? fetch;
1606
181
  }
1607
182
  get url() {
1608
183
  return this._url;
@@ -1614,77 +189,73 @@ class HttpClient {
1614
189
  this._token = value;
1615
190
  }
1616
191
  async login(username, password) {
1617
- try {
1618
- const result = await this._httpRequester({
1619
- method: "post",
1620
- url: (this.url + "/login").replace("//", "/"),
1621
- data: { username, password }
1622
- });
1623
- return this._token = result.data, { success: !0, error: null, token: result.data };
1624
- } catch (ex) {
1625
- if (ex.response.status == 401)
1626
- return { success: !1, error: "Invalid username & password.", token: null };
1627
- throw ex;
1628
- }
192
+ const result = await this._fetch(
193
+ this.url + "/login",
194
+ {
195
+ method: "POST",
196
+ body: JSON.stringify({ username, password })
197
+ }
198
+ );
199
+ return result.body != null ? (this._token = (await result.json()).token, { success: !0, error: null, token: this._token }) : { success: !1, error: "Invalid username & password.", token: null };
1629
200
  }
1630
201
  async getSpaces() {
1631
- return (await this._httpRequester({
1632
- method: "get",
1633
- url: (this.url + "/spaces").replace("//", "/"),
1634
- headers: {
1635
- Authorization: "Bearer " + this.token
202
+ return await (await this._fetch(
203
+ this.url + "/spaces",
204
+ {
205
+ method: "GET",
206
+ headers: { Authorization: "Bearer " + this.token }
1636
207
  }
1637
- })).data;
208
+ )).json();
1638
209
  }
1639
210
  async saveSpace(space) {
1640
- return (await this._httpRequester({
1641
- method: "post",
1642
- url: (this.url + "/spaces").replace("//", "/"),
1643
- data: space,
1644
- headers: {
1645
- Authorization: "Bearer " + this.token
211
+ return await (await this._fetch(
212
+ this.url + "/spaces",
213
+ {
214
+ method: "POST",
215
+ body: JSON.stringify(space),
216
+ headers: { Authorization: "Bearer " + this.token }
1646
217
  }
1647
- })).data;
218
+ )).json();
1648
219
  }
1649
220
  async getNotes(query, spaceId) {
1650
- return (await this._httpRequester({
1651
- method: "get",
1652
- url: (this.url + "/notes").replace("//", "/"),
1653
- data: { query, spaceId },
1654
- headers: {
1655
- Authorization: "Bearer " + this.token
221
+ return await (await this._fetch(
222
+ this.url + "/notes",
223
+ {
224
+ method: "GET",
225
+ body: JSON.stringify({ query, spaceId }),
226
+ headers: { Authorization: "Bearer " + this.token }
1656
227
  }
1657
- })).data;
228
+ )).json();
1658
229
  }
1659
230
  async getNoteCount(query, spaceId) {
1660
- return (await this._httpRequester({
1661
- method: "get",
1662
- url: (this.url + "/notes").replace("//", "/"),
1663
- data: { query, spaceId },
1664
- headers: {
1665
- Authorization: "Bearer " + this.token
231
+ return await (await this._fetch(
232
+ this.url + "/notes",
233
+ {
234
+ method: "GET",
235
+ body: JSON.stringify({ query, spaceId }),
236
+ headers: { Authorization: "Bearer " + this.token }
1666
237
  }
1667
- })).data;
238
+ )).json();
1668
239
  }
1669
240
  async saveNotes(notes) {
1670
- return (await this._httpRequester({
1671
- method: "post",
1672
- url: (this.url + "/notes").replace("//", "/"),
1673
- data: { notes },
1674
- headers: {
1675
- Authorization: "Bearer " + this.token
241
+ return await (await this._fetch(
242
+ this.url + "/notes",
243
+ {
244
+ method: "POST",
245
+ body: JSON.stringify(notes),
246
+ headers: { Authorization: "Bearer " + this.token }
1676
247
  }
1677
- })).data;
248
+ )).json();
1678
249
  }
1679
250
  async customJob(name, data) {
1680
- return (await this._httpRequester({
1681
- method: "post",
1682
- url: (this.url + "customjob").replace("//", "/"),
1683
- data: { name, data },
1684
- headers: {
1685
- Authorization: "Bearer " + this.token
251
+ return await (await this._fetch(
252
+ this.url + "customjob",
253
+ {
254
+ method: "POST",
255
+ body: JSON.stringify({ name, data }),
256
+ headers: { Authorization: "Bearer " + this.token }
1686
257
  }
1687
- })).data;
258
+ )).json();
1688
259
  }
1689
260
  }
1690
261
  class NoteAttr extends ModelWithState {
@@ -2038,7 +609,7 @@ class Note extends ModelWithState {
2038
609
  }
2039
610
  static fromJSON(json) {
2040
611
  const output = new Note(json.text);
2041
- return output.id = json.id, output.date = json.date, output.archived = json.archived, output.spaceId = json.spaceId, json.ownTag != null && output.setOwnTag(Tag.fromJSON(json.ownTag)), output._tags = json.tags.map((x) => NoteTag.fromJSON(x)), output._attrs = json.attrs.map((x) => NoteAttr.fromJSON(x)), output.state = json.state, output;
612
+ return output.id = json.id, output.date = new Date(json.date), output.archived = json.archived, output.spaceId = json.spaceId, json.ownTag != null && output.setOwnTag(Tag.fromJSON(json.ownTag)), output._tags = json.tags.map((x) => NoteTag.fromJSON(x)), output._attrs = json.attrs.map((x) => NoteAttr.fromJSON(x)), output.state = json.state, output;
2042
613
  }
2043
614
  validate(throwError = !1) {
2044
615
  let output = null;