@spica-devkit/identity 0.18.10 → 0.18.11

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/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import axios from 'axios';
2
+ import { Observable } from 'rxjs';
2
3
 
3
4
  function logWarning(response) {
4
5
  const warning = response.headers["warning"];
@@ -252,548 +253,6 @@ function addAuthHeader(headers, auth) {
252
253
  return headers;
253
254
  }
254
255
 
255
- /******************************************************************************
256
- Copyright (c) Microsoft Corporation.
257
-
258
- Permission to use, copy, modify, and/or distribute this software for any
259
- purpose with or without fee is hereby granted.
260
-
261
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
262
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
263
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
264
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
265
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
266
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
267
- PERFORMANCE OF THIS SOFTWARE.
268
- ***************************************************************************** */
269
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
270
-
271
- var extendStatics = function(d, b) {
272
- extendStatics = Object.setPrototypeOf ||
273
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
274
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
275
- return extendStatics(d, b);
276
- };
277
-
278
- function __extends(d, b) {
279
- if (typeof b !== "function" && b !== null)
280
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
281
- extendStatics(d, b);
282
- function __() { this.constructor = d; }
283
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
284
- }
285
-
286
- function __values(o) {
287
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
288
- if (m) return m.call(o);
289
- if (o && typeof o.length === "number") return {
290
- next: function () {
291
- if (o && i >= o.length) o = undefined;
292
- return { value: o && o[i++], done: !o };
293
- }
294
- };
295
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
296
- }
297
-
298
- function __read(o, n) {
299
- var m = typeof Symbol === "function" && o[Symbol.iterator];
300
- if (!m) return o;
301
- var i = m.call(o), r, ar = [], e;
302
- try {
303
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
304
- }
305
- catch (error) { e = { error: error }; }
306
- finally {
307
- try {
308
- if (r && !r.done && (m = i["return"])) m.call(i);
309
- }
310
- finally { if (e) throw e.error; }
311
- }
312
- return ar;
313
- }
314
-
315
- function __spreadArray(to, from, pack) {
316
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
317
- if (ar || !(i in from)) {
318
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
319
- ar[i] = from[i];
320
- }
321
- }
322
- return to.concat(ar || Array.prototype.slice.call(from));
323
- }
324
-
325
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
326
- var e = new Error(message);
327
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
328
- };
329
-
330
- function isFunction(value) {
331
- return typeof value === 'function';
332
- }
333
-
334
- function createErrorClass(createImpl) {
335
- var _super = function (instance) {
336
- Error.call(instance);
337
- instance.stack = new Error().stack;
338
- };
339
- var ctorFunc = createImpl(_super);
340
- ctorFunc.prototype = Object.create(Error.prototype);
341
- ctorFunc.prototype.constructor = ctorFunc;
342
- return ctorFunc;
343
- }
344
-
345
- var UnsubscriptionError = createErrorClass(function (_super) {
346
- return function UnsubscriptionErrorImpl(errors) {
347
- _super(this);
348
- this.message = errors
349
- ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
350
- : '';
351
- this.name = 'UnsubscriptionError';
352
- this.errors = errors;
353
- };
354
- });
355
-
356
- function arrRemove(arr, item) {
357
- if (arr) {
358
- var index = arr.indexOf(item);
359
- 0 <= index && arr.splice(index, 1);
360
- }
361
- }
362
-
363
- var Subscription = (function () {
364
- function Subscription(initialTeardown) {
365
- this.initialTeardown = initialTeardown;
366
- this.closed = false;
367
- this._parentage = null;
368
- this._finalizers = null;
369
- }
370
- Subscription.prototype.unsubscribe = function () {
371
- var e_1, _a, e_2, _b;
372
- var errors;
373
- if (!this.closed) {
374
- this.closed = true;
375
- var _parentage = this._parentage;
376
- if (_parentage) {
377
- this._parentage = null;
378
- if (Array.isArray(_parentage)) {
379
- try {
380
- for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
381
- var parent_1 = _parentage_1_1.value;
382
- parent_1.remove(this);
383
- }
384
- }
385
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
386
- finally {
387
- try {
388
- if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
389
- }
390
- finally { if (e_1) throw e_1.error; }
391
- }
392
- }
393
- else {
394
- _parentage.remove(this);
395
- }
396
- }
397
- var initialFinalizer = this.initialTeardown;
398
- if (isFunction(initialFinalizer)) {
399
- try {
400
- initialFinalizer();
401
- }
402
- catch (e) {
403
- errors = e instanceof UnsubscriptionError ? e.errors : [e];
404
- }
405
- }
406
- var _finalizers = this._finalizers;
407
- if (_finalizers) {
408
- this._finalizers = null;
409
- try {
410
- for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
411
- var finalizer = _finalizers_1_1.value;
412
- try {
413
- execFinalizer(finalizer);
414
- }
415
- catch (err) {
416
- errors = errors !== null && errors !== void 0 ? errors : [];
417
- if (err instanceof UnsubscriptionError) {
418
- errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
419
- }
420
- else {
421
- errors.push(err);
422
- }
423
- }
424
- }
425
- }
426
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
427
- finally {
428
- try {
429
- if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
430
- }
431
- finally { if (e_2) throw e_2.error; }
432
- }
433
- }
434
- if (errors) {
435
- throw new UnsubscriptionError(errors);
436
- }
437
- }
438
- };
439
- Subscription.prototype.add = function (teardown) {
440
- var _a;
441
- if (teardown && teardown !== this) {
442
- if (this.closed) {
443
- execFinalizer(teardown);
444
- }
445
- else {
446
- if (teardown instanceof Subscription) {
447
- if (teardown.closed || teardown._hasParent(this)) {
448
- return;
449
- }
450
- teardown._addParent(this);
451
- }
452
- (this._finalizers = (_a = this._finalizers) !== null && _a !== undefined ? _a : []).push(teardown);
453
- }
454
- }
455
- };
456
- Subscription.prototype._hasParent = function (parent) {
457
- var _parentage = this._parentage;
458
- return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
459
- };
460
- Subscription.prototype._addParent = function (parent) {
461
- var _parentage = this._parentage;
462
- this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
463
- };
464
- Subscription.prototype._removeParent = function (parent) {
465
- var _parentage = this._parentage;
466
- if (_parentage === parent) {
467
- this._parentage = null;
468
- }
469
- else if (Array.isArray(_parentage)) {
470
- arrRemove(_parentage, parent);
471
- }
472
- };
473
- Subscription.prototype.remove = function (teardown) {
474
- var _finalizers = this._finalizers;
475
- _finalizers && arrRemove(_finalizers, teardown);
476
- if (teardown instanceof Subscription) {
477
- teardown._removeParent(this);
478
- }
479
- };
480
- Subscription.EMPTY = (function () {
481
- var empty = new Subscription();
482
- empty.closed = true;
483
- return empty;
484
- })();
485
- return Subscription;
486
- }());
487
- Subscription.EMPTY;
488
- function isSubscription(value) {
489
- return (value instanceof Subscription ||
490
- (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
491
- }
492
- function execFinalizer(finalizer) {
493
- if (isFunction(finalizer)) {
494
- finalizer();
495
- }
496
- else {
497
- finalizer.unsubscribe();
498
- }
499
- }
500
-
501
- var config = {
502
- onUnhandledError: null,
503
- onStoppedNotification: null,
504
- Promise: undefined,
505
- useDeprecatedSynchronousErrorHandling: false,
506
- useDeprecatedNextContext: false,
507
- };
508
-
509
- var timeoutProvider = {
510
- setTimeout: function (handler, timeout) {
511
- var args = [];
512
- for (var _i = 2; _i < arguments.length; _i++) {
513
- args[_i - 2] = arguments[_i];
514
- }
515
- return setTimeout.apply(undefined, __spreadArray([handler, timeout], __read(args)));
516
- },
517
- clearTimeout: function (handle) {
518
- return (clearTimeout)(handle);
519
- },
520
- delegate: undefined,
521
- };
522
-
523
- function reportUnhandledError(err) {
524
- timeoutProvider.setTimeout(function () {
525
- {
526
- throw err;
527
- }
528
- });
529
- }
530
-
531
- function noop() { }
532
-
533
- function errorContext(cb) {
534
- {
535
- cb();
536
- }
537
- }
538
-
539
- var Subscriber = (function (_super) {
540
- __extends(Subscriber, _super);
541
- function Subscriber(destination) {
542
- var _this = _super.call(this) || this;
543
- _this.isStopped = false;
544
- if (destination) {
545
- _this.destination = destination;
546
- if (isSubscription(destination)) {
547
- destination.add(_this);
548
- }
549
- }
550
- else {
551
- _this.destination = EMPTY_OBSERVER;
552
- }
553
- return _this;
554
- }
555
- Subscriber.create = function (next, error, complete) {
556
- return new SafeSubscriber(next, error, complete);
557
- };
558
- Subscriber.prototype.next = function (value) {
559
- if (this.isStopped) ;
560
- else {
561
- this._next(value);
562
- }
563
- };
564
- Subscriber.prototype.error = function (err) {
565
- if (this.isStopped) ;
566
- else {
567
- this.isStopped = true;
568
- this._error(err);
569
- }
570
- };
571
- Subscriber.prototype.complete = function () {
572
- if (this.isStopped) ;
573
- else {
574
- this.isStopped = true;
575
- this._complete();
576
- }
577
- };
578
- Subscriber.prototype.unsubscribe = function () {
579
- if (!this.closed) {
580
- this.isStopped = true;
581
- _super.prototype.unsubscribe.call(this);
582
- this.destination = null;
583
- }
584
- };
585
- Subscriber.prototype._next = function (value) {
586
- this.destination.next(value);
587
- };
588
- Subscriber.prototype._error = function (err) {
589
- try {
590
- this.destination.error(err);
591
- }
592
- finally {
593
- this.unsubscribe();
594
- }
595
- };
596
- Subscriber.prototype._complete = function () {
597
- try {
598
- this.destination.complete();
599
- }
600
- finally {
601
- this.unsubscribe();
602
- }
603
- };
604
- return Subscriber;
605
- }(Subscription));
606
- var ConsumerObserver = (function () {
607
- function ConsumerObserver(partialObserver) {
608
- this.partialObserver = partialObserver;
609
- }
610
- ConsumerObserver.prototype.next = function (value) {
611
- var partialObserver = this.partialObserver;
612
- if (partialObserver.next) {
613
- try {
614
- partialObserver.next(value);
615
- }
616
- catch (error) {
617
- handleUnhandledError(error);
618
- }
619
- }
620
- };
621
- ConsumerObserver.prototype.error = function (err) {
622
- var partialObserver = this.partialObserver;
623
- if (partialObserver.error) {
624
- try {
625
- partialObserver.error(err);
626
- }
627
- catch (error) {
628
- handleUnhandledError(error);
629
- }
630
- }
631
- else {
632
- handleUnhandledError(err);
633
- }
634
- };
635
- ConsumerObserver.prototype.complete = function () {
636
- var partialObserver = this.partialObserver;
637
- if (partialObserver.complete) {
638
- try {
639
- partialObserver.complete();
640
- }
641
- catch (error) {
642
- handleUnhandledError(error);
643
- }
644
- }
645
- };
646
- return ConsumerObserver;
647
- }());
648
- var SafeSubscriber = (function (_super) {
649
- __extends(SafeSubscriber, _super);
650
- function SafeSubscriber(observerOrNext, error, complete) {
651
- var _this = _super.call(this) || this;
652
- var partialObserver;
653
- if (isFunction(observerOrNext) || !observerOrNext) {
654
- partialObserver = {
655
- next: (observerOrNext !== null && observerOrNext !== undefined ? observerOrNext : undefined),
656
- error: error !== null && error !== undefined ? error : undefined,
657
- complete: complete !== null && complete !== undefined ? complete : undefined,
658
- };
659
- }
660
- else {
661
- {
662
- partialObserver = observerOrNext;
663
- }
664
- }
665
- _this.destination = new ConsumerObserver(partialObserver);
666
- return _this;
667
- }
668
- return SafeSubscriber;
669
- }(Subscriber));
670
- function handleUnhandledError(error) {
671
- {
672
- reportUnhandledError(error);
673
- }
674
- }
675
- function defaultErrorHandler(err) {
676
- throw err;
677
- }
678
- var EMPTY_OBSERVER = {
679
- closed: true,
680
- next: noop,
681
- error: defaultErrorHandler,
682
- complete: noop,
683
- };
684
-
685
- var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
686
-
687
- function identity(x) {
688
- return x;
689
- }
690
-
691
- function pipeFromArray(fns) {
692
- if (fns.length === 0) {
693
- return identity;
694
- }
695
- if (fns.length === 1) {
696
- return fns[0];
697
- }
698
- return function piped(input) {
699
- return fns.reduce(function (prev, fn) { return fn(prev); }, input);
700
- };
701
- }
702
-
703
- var Observable = (function () {
704
- function Observable(subscribe) {
705
- if (subscribe) {
706
- this._subscribe = subscribe;
707
- }
708
- }
709
- Observable.prototype.lift = function (operator) {
710
- var observable = new Observable();
711
- observable.source = this;
712
- observable.operator = operator;
713
- return observable;
714
- };
715
- Observable.prototype.subscribe = function (observerOrNext, error, complete) {
716
- var _this = this;
717
- var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
718
- errorContext(function () {
719
- var _a = _this, operator = _a.operator, source = _a.source;
720
- subscriber.add(operator
721
- ?
722
- operator.call(subscriber, source)
723
- : source
724
- ?
725
- _this._subscribe(subscriber)
726
- :
727
- _this._trySubscribe(subscriber));
728
- });
729
- return subscriber;
730
- };
731
- Observable.prototype._trySubscribe = function (sink) {
732
- try {
733
- return this._subscribe(sink);
734
- }
735
- catch (err) {
736
- sink.error(err);
737
- }
738
- };
739
- Observable.prototype.forEach = function (next, promiseCtor) {
740
- var _this = this;
741
- promiseCtor = getPromiseCtor(promiseCtor);
742
- return new promiseCtor(function (resolve, reject) {
743
- var subscriber = new SafeSubscriber({
744
- next: function (value) {
745
- try {
746
- next(value);
747
- }
748
- catch (err) {
749
- reject(err);
750
- subscriber.unsubscribe();
751
- }
752
- },
753
- error: reject,
754
- complete: resolve,
755
- });
756
- _this.subscribe(subscriber);
757
- });
758
- };
759
- Observable.prototype._subscribe = function (subscriber) {
760
- var _a;
761
- return (_a = this.source) === null || _a === undefined ? undefined : _a.subscribe(subscriber);
762
- };
763
- Observable.prototype[observable] = function () {
764
- return this;
765
- };
766
- Observable.prototype.pipe = function () {
767
- var operations = [];
768
- for (var _i = 0; _i < arguments.length; _i++) {
769
- operations[_i] = arguments[_i];
770
- }
771
- return pipeFromArray(operations)(this);
772
- };
773
- Observable.prototype.toPromise = function (promiseCtor) {
774
- var _this = this;
775
- promiseCtor = getPromiseCtor(promiseCtor);
776
- return new promiseCtor(function (resolve, reject) {
777
- var value;
778
- _this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
779
- });
780
- };
781
- Observable.create = function (subscribe) {
782
- return new Observable(subscribe);
783
- };
784
- return Observable;
785
- }());
786
- function getPromiseCtor(promiseCtor) {
787
- var _a;
788
- return (_a = promiseCtor !== null && promiseCtor !== undefined ? promiseCtor : config.Promise) !== null && _a !== undefined ? _a : Promise;
789
- }
790
- function isObserver(value) {
791
- return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
792
- }
793
- function isSubscriber(value) {
794
- return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
795
- }
796
-
797
256
  function deepCopyJSON(param) {
798
257
  return JSON.parse(JSON.stringify(param));
799
258
  }