standard-log 11.4.0 → 11.5.0
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/README.md +5 -0
- package/cjs/index.d.ts +2 -2
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +0 -1
- package/cjs/index.js.map +1 -1
- package/cjs/logger.d.ts.map +1 -1
- package/cjs/logger.js +4 -4
- package/cjs/logger.js.map +1 -1
- package/cjs/standardLog.ctx.d.ts +10 -0
- package/cjs/standardLog.ctx.d.ts.map +1 -0
- package/cjs/standardLog.ctx.js +6 -0
- package/cjs/standardLog.ctx.js.map +1 -0
- package/cjs/standardLog.d.ts +1 -15
- package/cjs/standardLog.d.ts.map +1 -1
- package/cjs/standardLog.js +14 -14
- package/cjs/standardLog.js.map +1 -1
- package/cjs/types.d.ts +9 -2
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js.map +1 -1
- package/dist/standard-log.es5.js +201 -269
- package/dist/standard-log.es5.js.gz +0 -0
- package/dist/standard-log.es5.js.map +1 -1
- package/dist/standard-log.es5.js.map.gz +0 -0
- package/dist/standard-log.esm.js +200 -163
- package/dist/standard-log.esm.js.gz +0 -0
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.esm.js.map.gz +0 -0
- package/esm/index.d.ts +2 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +0 -1
- package/esm/index.js.map +1 -1
- package/esm/logger.d.ts.map +1 -1
- package/esm/logger.js +4 -4
- package/esm/logger.js.map +1 -1
- package/esm/standardLog.ctx.d.ts +10 -0
- package/esm/standardLog.ctx.d.ts.map +1 -0
- package/esm/standardLog.ctx.js +3 -0
- package/esm/standardLog.ctx.js.map +1 -0
- package/esm/standardLog.d.ts +1 -15
- package/esm/standardLog.d.ts.map +1 -1
- package/esm/standardLog.js +1 -1
- package/esm/standardLog.js.map +1 -1
- package/esm/types.d.ts +9 -2
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/package.json +3 -3
- package/ts/index.ts +7 -2
- package/ts/logger.ts +3 -4
- package/ts/standardLog.ctx.ts +8 -0
- package/ts/standardLog.ts +2 -14
- package/ts/types.ts +10 -2
package/dist/standard-log.es5.js
CHANGED
|
@@ -5918,7 +5918,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
5918
5918
|
})();
|
|
5919
5919
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5920
5920
|
exports.InvalidId = exports.StandardLogError = void 0;
|
|
5921
|
-
var iso_error_1 = __webpack_require__(/*! iso-error */ "../../node_modules/.pnpm/iso-error@
|
|
5921
|
+
var iso_error_1 = __webpack_require__(/*! iso-error */ "../../node_modules/.pnpm/iso-error@5.0.0/node_modules/iso-error/cjs/index.js");
|
|
5922
5922
|
/**
|
|
5923
5923
|
* @deprecated No longer used since 11.2.0
|
|
5924
5924
|
*/
|
|
@@ -6057,7 +6057,6 @@ Object.defineProperty(exports, "createStandardLog", ({ enumerable: true, get: fu
|
|
|
6057
6057
|
Object.defineProperty(exports, "createStandardLogForTest", ({ enumerable: true, get: function () { return standardLog_js_1.createStandardLogForTest; } }));
|
|
6058
6058
|
Object.defineProperty(exports, "getLogger", ({ enumerable: true, get: function () { return standardLog_js_1.getLogger; } }));
|
|
6059
6059
|
Object.defineProperty(exports, "suppressLogs", ({ enumerable: true, get: function () { return standardLog_js_1.suppressLogs; } }));
|
|
6060
|
-
__exportStar(__webpack_require__(/*! ./types.js */ "./ts/types.ts"), exports);
|
|
6061
6060
|
|
|
6062
6061
|
|
|
6063
6062
|
/***/ }),
|
|
@@ -6293,11 +6292,10 @@ function createLogger(store, id, options) {
|
|
|
6293
6292
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6294
6293
|
args[_i] = arguments[_i];
|
|
6295
6294
|
}
|
|
6296
|
-
|
|
6297
|
-
if (shouldLog(store, level, logger.level))
|
|
6295
|
+
if (shouldLog(store, logLevels_js_1.logLevels.debug, logger.level))
|
|
6298
6296
|
write({
|
|
6299
6297
|
id: id,
|
|
6300
|
-
level:
|
|
6298
|
+
level: logLevels_js_1.logLevels.debug,
|
|
6301
6299
|
args: __spreadArray([++counter], args, true),
|
|
6302
6300
|
timestamp: new Date()
|
|
6303
6301
|
});
|
|
@@ -6306,11 +6304,12 @@ function createLogger(store, id, options) {
|
|
|
6306
6304
|
on: {
|
|
6307
6305
|
writable: false,
|
|
6308
6306
|
value: function (level, logFn) {
|
|
6307
|
+
var _a;
|
|
6309
6308
|
var logLevel = typeof level === 'string' ? store.logLevelStore.getLevel(level) : level;
|
|
6310
6309
|
if (shouldLog(store, logLevel, logger.level)) {
|
|
6311
6310
|
var methodName = store.logLevelStore.getName(logLevel);
|
|
6312
6311
|
var bindedMethod = logger[methodName].bind(logger);
|
|
6313
|
-
var result = logFn(bindedMethod);
|
|
6312
|
+
var result = logFn(bindedMethod, (_a = logger.level) !== null && _a !== void 0 ? _a : store.logLevel);
|
|
6314
6313
|
if (result)
|
|
6315
6314
|
bindedMethod(result);
|
|
6316
6315
|
}
|
|
@@ -6440,6 +6439,22 @@ exports.toInspectLogEntry = toInspectLogEntry;
|
|
|
6440
6439
|
exports.polyfill = (0, type_plus_1.record)();
|
|
6441
6440
|
|
|
6442
6441
|
|
|
6442
|
+
/***/ }),
|
|
6443
|
+
|
|
6444
|
+
/***/ "./ts/standardLog.ctx.ts":
|
|
6445
|
+
/*!*******************************!*\
|
|
6446
|
+
!*** ./ts/standardLog.ctx.ts ***!
|
|
6447
|
+
\*******************************/
|
|
6448
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
6449
|
+
|
|
6450
|
+
"use strict";
|
|
6451
|
+
|
|
6452
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6453
|
+
exports.ctx = void 0;
|
|
6454
|
+
var type_plus_1 = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/type-plus@4.16.0/node_modules/type-plus/cjs/index.js");
|
|
6455
|
+
exports.ctx = (0, type_plus_1.record)();
|
|
6456
|
+
|
|
6457
|
+
|
|
6443
6458
|
/***/ }),
|
|
6444
6459
|
|
|
6445
6460
|
/***/ "./ts/standardLog.ts":
|
|
@@ -6462,12 +6477,13 @@ var __assign = (this && this.__assign) || function () {
|
|
|
6462
6477
|
return __assign.apply(this, arguments);
|
|
6463
6478
|
};
|
|
6464
6479
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6465
|
-
exports.configGlobal = exports.
|
|
6480
|
+
exports.configGlobal = exports.getLogger = exports.suppressLogs = exports.createStandardLogForTest = exports.createStandardLogClosure = exports.createStandardLog = void 0;
|
|
6466
6481
|
var type_plus_1 = __webpack_require__(/*! type-plus */ "../../node_modules/.pnpm/type-plus@4.16.0/node_modules/type-plus/cjs/index.js");
|
|
6467
6482
|
var logger_js_1 = __webpack_require__(/*! ./logger.js */ "./ts/logger.ts");
|
|
6468
6483
|
var logLevels_js_1 = __webpack_require__(/*! ./logLevels.js */ "./ts/logLevels.ts");
|
|
6469
6484
|
var logStore_js_1 = __webpack_require__(/*! ./logStore.js */ "./ts/logStore.ts");
|
|
6470
6485
|
var memory_js_1 = __webpack_require__(/*! ./memory.js */ "./ts/memory.ts");
|
|
6486
|
+
var standardLog_ctx_js_1 = __webpack_require__(/*! ./standardLog.ctx.js */ "./ts/standardLog.ctx.ts");
|
|
6471
6487
|
function createStandardLog(options) {
|
|
6472
6488
|
var _a;
|
|
6473
6489
|
var closure = createStandardLogClosure(options);
|
|
@@ -6475,8 +6491,8 @@ function createStandardLog(options) {
|
|
|
6475
6491
|
var log = closure.standardLog.getLogger('standard-log');
|
|
6476
6492
|
log.critical("Detected reporter with empty id. This is not allowed as it will create problems with feature like 'getNonConsoleLogger()'. Please add an id to your reporter.");
|
|
6477
6493
|
}
|
|
6478
|
-
if (!
|
|
6479
|
-
|
|
6494
|
+
if (!standardLog_ctx_js_1.ctx.gsl)
|
|
6495
|
+
standardLog_ctx_js_1.ctx.gsl = closure;
|
|
6480
6496
|
return closure.standardLog;
|
|
6481
6497
|
}
|
|
6482
6498
|
exports.createStandardLog = createStandardLog;
|
|
@@ -6551,48 +6567,34 @@ function getLogger(id, options) {
|
|
|
6551
6567
|
return getGlobalSL().getLogger(id, options);
|
|
6552
6568
|
}
|
|
6553
6569
|
exports.getLogger = getLogger;
|
|
6554
|
-
exports.ctx = (0, type_plus_1.record)();
|
|
6555
6570
|
function getGlobalSL() {
|
|
6556
|
-
if (!
|
|
6557
|
-
|
|
6558
|
-
return
|
|
6571
|
+
if (!standardLog_ctx_js_1.ctx.gsl)
|
|
6572
|
+
standardLog_ctx_js_1.ctx.gsl = createStandardLogClosure();
|
|
6573
|
+
return standardLog_ctx_js_1.ctx.gsl.standardLog;
|
|
6559
6574
|
}
|
|
6560
6575
|
function configGlobal(options) {
|
|
6561
|
-
if (
|
|
6562
|
-
var log =
|
|
6576
|
+
if (standardLog_ctx_js_1.ctx.configured) {
|
|
6577
|
+
var log = standardLog_ctx_js_1.ctx.gsl.standardLog.getLogger('standard-log');
|
|
6563
6578
|
log.warn('configGlobal() is being called more than once. Please make sure this is expected. Application should use `createStandardLog()` most of the time.');
|
|
6564
6579
|
}
|
|
6565
|
-
if (
|
|
6580
|
+
if (standardLog_ctx_js_1.ctx.gsl) {
|
|
6566
6581
|
if (options.logLevel) {
|
|
6567
|
-
|
|
6582
|
+
standardLog_ctx_js_1.ctx.gsl.store.logLevel = options.logLevel;
|
|
6568
6583
|
}
|
|
6569
6584
|
if (options.reporters) {
|
|
6570
|
-
var reporters =
|
|
6585
|
+
var reporters = standardLog_ctx_js_1.ctx.gsl.store.reporters;
|
|
6571
6586
|
reporters.length = 0;
|
|
6572
6587
|
reporters.push.apply(reporters, options.reporters);
|
|
6573
6588
|
}
|
|
6574
6589
|
}
|
|
6575
6590
|
else {
|
|
6576
|
-
|
|
6591
|
+
standardLog_ctx_js_1.ctx.gsl = createStandardLogClosure(options);
|
|
6577
6592
|
}
|
|
6578
|
-
|
|
6593
|
+
standardLog_ctx_js_1.ctx.configured = true;
|
|
6579
6594
|
}
|
|
6580
6595
|
exports.configGlobal = configGlobal;
|
|
6581
6596
|
|
|
6582
6597
|
|
|
6583
|
-
/***/ }),
|
|
6584
|
-
|
|
6585
|
-
/***/ "./ts/types.ts":
|
|
6586
|
-
/*!*********************!*\
|
|
6587
|
-
!*** ./ts/types.ts ***!
|
|
6588
|
-
\*********************/
|
|
6589
|
-
/***/ (function(__unused_webpack_module, exports) {
|
|
6590
|
-
|
|
6591
|
-
"use strict";
|
|
6592
|
-
|
|
6593
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
6598
|
/***/ }),
|
|
6597
6599
|
|
|
6598
6600
|
/***/ "../../node_modules/.pnpm/upper-case@2.0.2/node_modules/upper-case/dist/index.js":
|
|
@@ -6654,40 +6656,19 @@ exports.upperCase = upperCase;
|
|
|
6654
6656
|
|
|
6655
6657
|
/***/ }),
|
|
6656
6658
|
|
|
6657
|
-
/***/ "../../node_modules/.pnpm/iso-error@
|
|
6659
|
+
/***/ "../../node_modules/.pnpm/iso-error@5.0.0/node_modules/iso-error/cjs/index.js":
|
|
6658
6660
|
/*!************************************************************************************!*\
|
|
6659
|
-
!*** ../../node_modules/.pnpm/iso-error@
|
|
6661
|
+
!*** ../../node_modules/.pnpm/iso-error@5.0.0/node_modules/iso-error/cjs/index.js ***!
|
|
6660
6662
|
\************************************************************************************/
|
|
6661
6663
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
6662
6664
|
|
|
6663
6665
|
"use strict";
|
|
6664
6666
|
|
|
6665
6667
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
6666
|
-
var
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6671
|
-
return extendStatics(d, b);
|
|
6672
|
-
};
|
|
6673
|
-
return function (d, b) {
|
|
6674
|
-
if (typeof b !== "function" && b !== null)
|
|
6675
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
6676
|
-
extendStatics(d, b);
|
|
6677
|
-
function __() { this.constructor = d; }
|
|
6678
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
6679
|
-
};
|
|
6680
|
-
})();
|
|
6681
|
-
var __assign = (this && this.__assign) || function () {
|
|
6682
|
-
__assign = Object.assign || function(t) {
|
|
6683
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6684
|
-
s = arguments[i];
|
|
6685
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6686
|
-
t[p] = s[p];
|
|
6687
|
-
}
|
|
6688
|
-
return t;
|
|
6689
|
-
};
|
|
6690
|
-
return __assign.apply(this, arguments);
|
|
6668
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
6669
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
6670
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
6671
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6691
6672
|
};
|
|
6692
6673
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
6693
6674
|
var t = {};
|
|
@@ -6700,13 +6681,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
6700
6681
|
}
|
|
6701
6682
|
return t;
|
|
6702
6683
|
};
|
|
6684
|
+
var _SerializableConverter_instances, _SerializableConverter_plugins, _SerializableConverter_fromSerializable, _SerializableConverter_deserializeError, _SerializableConverter_toSerializable, _a, _IsoError_hasCause, _IsoError_toIsoError;
|
|
6703
6685
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6704
|
-
exports.isAggregateError = exports.ModuleError = exports.IsoError = void 0;
|
|
6686
|
+
exports.isAggregateError = exports.ModuleError = exports.IsoError = exports.SerializableConverter = void 0;
|
|
6705
6687
|
//#region captureStackTrace polyfill
|
|
6706
6688
|
// istanbul ignore next
|
|
6707
6689
|
if (!Error.captureStackTrace) {
|
|
6708
6690
|
Error.captureStackTrace = function (error) {
|
|
6709
|
-
|
|
6691
|
+
const container = new Error();
|
|
6710
6692
|
Object.defineProperty(error, 'stack', {
|
|
6711
6693
|
configurable: true,
|
|
6712
6694
|
get: function () {
|
|
@@ -6722,260 +6704,210 @@ if (!Error.captureStackTrace) {
|
|
|
6722
6704
|
function defineStack(target, value) {
|
|
6723
6705
|
Object.defineProperty(target, 'stack', {
|
|
6724
6706
|
configurable: true,
|
|
6725
|
-
value
|
|
6707
|
+
value,
|
|
6726
6708
|
writable: true,
|
|
6727
6709
|
});
|
|
6728
6710
|
}
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
function IsoError(message, options) {
|
|
6737
|
-
var _newTarget = this.constructor;
|
|
6738
|
-
var _this = _super.call(this, message) || this;
|
|
6739
|
-
/**
|
|
6740
|
-
* Name of the error
|
|
6741
|
-
*/
|
|
6742
|
-
Object.defineProperty(_this, "name", {
|
|
6743
|
-
enumerable: true,
|
|
6744
|
-
configurable: true,
|
|
6745
|
-
writable: true,
|
|
6746
|
-
value: void 0
|
|
6747
|
-
});
|
|
6748
|
-
/**
|
|
6749
|
-
* Error cause
|
|
6750
|
-
*/
|
|
6751
|
-
Object.defineProperty(_this, "cause", {
|
|
6752
|
-
enumerable: true,
|
|
6753
|
-
configurable: true,
|
|
6754
|
-
writable: true,
|
|
6755
|
-
value: void 0
|
|
6756
|
-
});
|
|
6757
|
-
//restore prototype chain
|
|
6758
|
-
var actualProto = _newTarget.prototype;
|
|
6759
|
-
_this.name = actualProto.constructor.name;
|
|
6760
|
-
// istanbul ignore next
|
|
6761
|
-
if (Object.setPrototypeOf)
|
|
6762
|
-
Object.setPrototypeOf(_this, actualProto);
|
|
6763
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
6764
|
-
else
|
|
6765
|
-
_this.__proto__ = actualProto;
|
|
6766
|
-
if (options === null || options === void 0 ? void 0 : options.cause)
|
|
6767
|
-
_this.cause = toIsoError(options.cause);
|
|
6768
|
-
if (options === null || options === void 0 ? void 0 : options.ssf)
|
|
6769
|
-
Error.captureStackTrace(_this, options.ssf);
|
|
6770
|
-
return _this;
|
|
6711
|
+
class SerializableConverter {
|
|
6712
|
+
constructor() {
|
|
6713
|
+
_SerializableConverter_instances.add(this);
|
|
6714
|
+
_SerializableConverter_plugins.set(this, []);
|
|
6715
|
+
}
|
|
6716
|
+
addPlugin(plugin) {
|
|
6717
|
+
__classPrivateFieldGet(this, _SerializableConverter_plugins, "f").unshift(plugin);
|
|
6771
6718
|
}
|
|
6772
6719
|
/**
|
|
6773
|
-
*
|
|
6774
|
-
* @param props properties of the IsoError
|
|
6775
|
-
*/
|
|
6776
|
-
Object.defineProperty(IsoError, "create", {
|
|
6777
|
-
enumerable: false,
|
|
6778
|
-
configurable: true,
|
|
6779
|
-
writable: true,
|
|
6780
|
-
value: function (props) {
|
|
6781
|
-
var message = props.message, cause = props.cause, rest = __rest(props, ["message", "cause"]);
|
|
6782
|
-
var err = new IsoError(message, { cause: cause, ssf: IsoError.create });
|
|
6783
|
-
return Object.assign(err, rest);
|
|
6784
|
-
}
|
|
6785
|
-
});
|
|
6786
|
-
Object.defineProperty(IsoError, "stringify", {
|
|
6787
|
-
enumerable: false,
|
|
6788
|
-
configurable: true,
|
|
6789
|
-
writable: true,
|
|
6790
|
-
value: function (err) {
|
|
6791
|
-
return this.serialize(err);
|
|
6792
|
-
}
|
|
6793
|
-
});
|
|
6794
|
-
Object.defineProperty(IsoError, "serialize", {
|
|
6795
|
-
enumerable: false,
|
|
6796
|
-
configurable: true,
|
|
6797
|
-
writable: true,
|
|
6798
|
-
value: function (err) {
|
|
6799
|
-
return JSON.stringify(this.toSerializable(err));
|
|
6800
|
-
}
|
|
6801
|
-
});
|
|
6802
|
-
/**
|
|
6803
|
-
* @type P Additional properties of the IsoError
|
|
6804
|
-
* @param text Json representation of a IsoError
|
|
6805
|
-
*/
|
|
6806
|
-
Object.defineProperty(IsoError, "parse", {
|
|
6807
|
-
enumerable: false,
|
|
6808
|
-
configurable: true,
|
|
6809
|
-
writable: true,
|
|
6810
|
-
value: function (text) {
|
|
6811
|
-
return deserialize(IsoError.parse, text);
|
|
6812
|
-
}
|
|
6813
|
-
});
|
|
6814
|
-
/**
|
|
6815
|
-
* @type P Additional properties of the IsoError
|
|
6816
|
-
* @param text Json representation of a IsoError
|
|
6720
|
+
* Deserialize an `Error` from `Serializable`
|
|
6817
6721
|
*/
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
return deserialize(IsoError.deserialize, text);
|
|
6824
|
-
}
|
|
6825
|
-
});
|
|
6826
|
-
Object.defineProperty(IsoError, "toSerializable", {
|
|
6827
|
-
enumerable: false,
|
|
6828
|
-
configurable: true,
|
|
6829
|
-
writable: true,
|
|
6830
|
-
value: function (err) {
|
|
6831
|
-
return serializers.reduce(function (p, s) { return p || s(err); }, undefined)
|
|
6832
|
-
|| toSerializableError(err);
|
|
6833
|
-
}
|
|
6834
|
-
});
|
|
6835
|
-
Object.defineProperty(IsoError, "fromSerializable", {
|
|
6836
|
-
enumerable: false,
|
|
6837
|
-
configurable: true,
|
|
6838
|
-
writable: true,
|
|
6839
|
-
value: function (json) {
|
|
6840
|
-
var err = deserializeError(json);
|
|
6841
|
-
Error.captureStackTrace(err, IsoError.fromSerializable);
|
|
6842
|
-
return err;
|
|
6843
|
-
}
|
|
6844
|
-
});
|
|
6722
|
+
fromSerializable(json, options) {
|
|
6723
|
+
const err = __classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_deserializeError).call(this, json);
|
|
6724
|
+
Error.captureStackTrace(err, options === null || options === void 0 ? void 0 : options.ssf);
|
|
6725
|
+
return err;
|
|
6726
|
+
}
|
|
6845
6727
|
/**
|
|
6846
|
-
*
|
|
6728
|
+
* Serialize `Error` to `Serializable`
|
|
6847
6729
|
*/
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
configurable: true,
|
|
6851
|
-
writable: true,
|
|
6852
|
-
value: function (err) {
|
|
6853
|
-
return trace(err);
|
|
6854
|
-
}
|
|
6855
|
-
});
|
|
6856
|
-
Object.defineProperty(IsoError, "addPlugin", {
|
|
6857
|
-
enumerable: false,
|
|
6858
|
-
configurable: true,
|
|
6859
|
-
writable: true,
|
|
6860
|
-
value: function (_a) {
|
|
6861
|
-
var toSerializable = _a.toSerializable, fromSerializable = _a.fromSerializable;
|
|
6862
|
-
serializers.unshift(toSerializable);
|
|
6863
|
-
deserializers.unshift(fromSerializable);
|
|
6864
|
-
}
|
|
6865
|
-
});
|
|
6866
|
-
Object.defineProperty(IsoError.prototype, "toString", {
|
|
6867
|
-
enumerable: false,
|
|
6868
|
-
configurable: true,
|
|
6869
|
-
writable: true,
|
|
6870
|
-
value: function () { return IsoError.serialize(this); }
|
|
6871
|
-
});
|
|
6872
|
-
Object.defineProperty(IsoError.prototype, "trace", {
|
|
6873
|
-
enumerable: false,
|
|
6874
|
-
configurable: true,
|
|
6875
|
-
writable: true,
|
|
6876
|
-
value: function () { return IsoError.trace(this); }
|
|
6877
|
-
});
|
|
6878
|
-
return IsoError;
|
|
6879
|
-
}(Error));
|
|
6880
|
-
exports.IsoError = IsoError;
|
|
6881
|
-
function deserialize(fn, text) {
|
|
6882
|
-
var json = JSON.parse(text);
|
|
6883
|
-
var err = deserializeError(json);
|
|
6884
|
-
Error.captureStackTrace(err, fn);
|
|
6885
|
-
return err;
|
|
6886
|
-
}
|
|
6887
|
-
function deserializeError(json) {
|
|
6888
|
-
var err = undefined;
|
|
6889
|
-
for (var _i = 0, deserializers_1 = deserializers; _i < deserializers_1.length; _i++) {
|
|
6890
|
-
var d = deserializers_1[_i];
|
|
6891
|
-
err = d(json);
|
|
6892
|
-
if (err)
|
|
6893
|
-
break;
|
|
6730
|
+
toSerializable(err) {
|
|
6731
|
+
return __classPrivateFieldGet(this, _SerializableConverter_plugins, "f").reduce((p, s) => p || s.toSerializable(err), undefined) || __classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_toSerializable).call(this, err);
|
|
6894
6732
|
}
|
|
6895
|
-
return err || defaultDeserializeError(json);
|
|
6896
6733
|
}
|
|
6897
|
-
|
|
6734
|
+
exports.SerializableConverter = SerializableConverter;
|
|
6735
|
+
_SerializableConverter_plugins = new WeakMap(), _SerializableConverter_instances = new WeakSet(), _SerializableConverter_fromSerializable = function _SerializableConverter_fromSerializable(json) {
|
|
6898
6736
|
if (json.name === 'AggregateError') {
|
|
6899
|
-
|
|
6737
|
+
const _b = json, { message, errors } = _b, rest = __rest(_b, ["message", "errors"]);
|
|
6900
6738
|
// @ts-ignore
|
|
6739
|
+
// istanbul ignore next
|
|
6901
6740
|
if (__webpack_require__.g.AggregateError) {
|
|
6902
|
-
return Object.assign(new AggregateError(errors,
|
|
6741
|
+
return Object.assign(new AggregateError(errors, message), rest);
|
|
6903
6742
|
}
|
|
6904
6743
|
else {
|
|
6905
|
-
return Object.assign(new Error(
|
|
6744
|
+
return Object.assign(new Error(message), Object.assign(Object.assign({}, rest), { errors }));
|
|
6906
6745
|
}
|
|
6907
6746
|
}
|
|
6908
|
-
|
|
6909
|
-
|
|
6747
|
+
const { message, cause } = json, rest = __rest(json, ["message", "cause"]);
|
|
6748
|
+
const causeError = cause ? __classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_deserializeError).call(this, cause) : undefined;
|
|
6910
6749
|
if (json.name === 'Error') {
|
|
6911
|
-
return Object.assign(new Error(message), causeError ?
|
|
6750
|
+
return Object.assign(new Error(message), causeError ? Object.assign(Object.assign({}, rest), { cause: causeError }) : rest);
|
|
6912
6751
|
}
|
|
6913
6752
|
// @ts-ignore
|
|
6914
6753
|
return Object.assign(new IsoError(message, causeError ? { cause: causeError } : undefined), rest);
|
|
6915
|
-
}
|
|
6916
|
-
|
|
6754
|
+
}, _SerializableConverter_deserializeError = function _SerializableConverter_deserializeError(json) {
|
|
6755
|
+
let err = undefined;
|
|
6756
|
+
for (const { fromSerializable } of __classPrivateFieldGet(this, _SerializableConverter_plugins, "f")) {
|
|
6757
|
+
err = fromSerializable(json);
|
|
6758
|
+
if (err)
|
|
6759
|
+
break;
|
|
6760
|
+
}
|
|
6761
|
+
return err || __classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_fromSerializable).call(this, json);
|
|
6762
|
+
}, _SerializableConverter_toSerializable = function _SerializableConverter_toSerializable(err) {
|
|
6917
6763
|
if (isAggregateError(err)) {
|
|
6918
|
-
return
|
|
6764
|
+
return Object.assign(Object.assign({}, err), { name: err.constructor.name, message: err.message, errors: err.errors.map(__classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_toSerializable)) });
|
|
6919
6765
|
}
|
|
6920
6766
|
if (err instanceof Error) {
|
|
6921
|
-
|
|
6767
|
+
const { message, cause } = err;
|
|
6922
6768
|
return cause
|
|
6923
|
-
?
|
|
6769
|
+
? Object.assign(Object.assign({}, err), { name: err.constructor.name, message, cause: __classPrivateFieldGet(this, _SerializableConverter_instances, "m", _SerializableConverter_toSerializable).call(this, cause) }) : Object.assign(Object.assign({}, err), { name: err.constructor.name, message });
|
|
6924
6770
|
}
|
|
6925
6771
|
return err;
|
|
6926
|
-
}
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6772
|
+
};
|
|
6773
|
+
/**
|
|
6774
|
+
* Isomorphic Error that works across physical boundary.
|
|
6775
|
+
*/
|
|
6776
|
+
class IsoError extends Error {
|
|
6777
|
+
/**
|
|
6778
|
+
* Create an IsoError with additional properties without the need to create a new class.
|
|
6779
|
+
* @param props properties of the IsoError
|
|
6780
|
+
*/
|
|
6781
|
+
static create(props) {
|
|
6782
|
+
const { message, cause } = props, rest = __rest(props, ["message", "cause"]);
|
|
6783
|
+
const err = new IsoError(message, { cause, ssf: IsoError.create });
|
|
6784
|
+
return Object.assign(err, rest);
|
|
6939
6785
|
}
|
|
6940
|
-
|
|
6941
|
-
|
|
6786
|
+
static stringify(err) {
|
|
6787
|
+
return this.serialize(err);
|
|
6942
6788
|
}
|
|
6943
|
-
|
|
6944
|
-
|
|
6789
|
+
static serialize(err) {
|
|
6790
|
+
return JSON.stringify(this.toSerializable(err));
|
|
6945
6791
|
}
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
messages.push.apply(messages, trace(err.cause).split('\n').map(function (s) { return ' ' + s; }));
|
|
6792
|
+
static toSerializable(err) {
|
|
6793
|
+
return this.converter.toSerializable(err);
|
|
6949
6794
|
}
|
|
6950
|
-
|
|
6951
|
-
|
|
6795
|
+
/**
|
|
6796
|
+
* @type P Additional properties of the IsoError
|
|
6797
|
+
* @param text Json representation of a IsoError
|
|
6798
|
+
*/
|
|
6799
|
+
static parse(text) {
|
|
6800
|
+
const json = JSON.parse(text);
|
|
6801
|
+
return this.converter.fromSerializable(json, { ssf: IsoError.parse });
|
|
6802
|
+
}
|
|
6803
|
+
/**
|
|
6804
|
+
* @type P Additional properties of the IsoError
|
|
6805
|
+
* @param text Json representation of a IsoError
|
|
6806
|
+
*/
|
|
6807
|
+
static deserialize(text) {
|
|
6808
|
+
const json = JSON.parse(text);
|
|
6809
|
+
return this.converter.fromSerializable(json, { ssf: IsoError.deserialize });
|
|
6810
|
+
}
|
|
6811
|
+
static fromSerializable(json) {
|
|
6812
|
+
return this.converter.fromSerializable(json, { ssf: IsoError.fromSerializable });
|
|
6813
|
+
}
|
|
6814
|
+
/**
|
|
6815
|
+
* returns the error message including the error causes.
|
|
6816
|
+
*/
|
|
6817
|
+
static trace(err) {
|
|
6818
|
+
const messages = [];
|
|
6819
|
+
if (err instanceof ModuleError) {
|
|
6820
|
+
messages.push(`${err.name}(${err.module}): ${err.message}`);
|
|
6821
|
+
}
|
|
6822
|
+
else if (err instanceof Error) {
|
|
6823
|
+
messages.push(`${err.name}: ${err.message}`);
|
|
6824
|
+
}
|
|
6825
|
+
if (isAggregateError(err)) {
|
|
6826
|
+
err.errors.forEach(e => messages.push(...this.trace(e).split('\n').map(s => ' ' + s)));
|
|
6827
|
+
}
|
|
6828
|
+
if (err instanceof Error) {
|
|
6829
|
+
if (__classPrivateFieldGet(this, _a, "m", _IsoError_hasCause).call(this, err))
|
|
6830
|
+
messages.push(...this.trace(err.cause).split('\n').map(s => ' ' + s));
|
|
6831
|
+
}
|
|
6832
|
+
else {
|
|
6833
|
+
messages.push(typeof err === 'string' ? err : JSON.stringify(err));
|
|
6834
|
+
}
|
|
6835
|
+
return messages.join('\n');
|
|
6836
|
+
}
|
|
6837
|
+
static addPlugin(plugin) {
|
|
6838
|
+
this.converter.addPlugin(plugin);
|
|
6952
6839
|
}
|
|
6953
|
-
|
|
6840
|
+
constructor(message, options) {
|
|
6841
|
+
super(message);
|
|
6842
|
+
/**
|
|
6843
|
+
* Name of the error
|
|
6844
|
+
*/
|
|
6845
|
+
Object.defineProperty(this, "name", {
|
|
6846
|
+
enumerable: true,
|
|
6847
|
+
configurable: true,
|
|
6848
|
+
writable: true,
|
|
6849
|
+
value: void 0
|
|
6850
|
+
});
|
|
6851
|
+
/**
|
|
6852
|
+
* Error cause
|
|
6853
|
+
*/
|
|
6854
|
+
Object.defineProperty(this, "cause", {
|
|
6855
|
+
enumerable: true,
|
|
6856
|
+
configurable: true,
|
|
6857
|
+
writable: true,
|
|
6858
|
+
value: void 0
|
|
6859
|
+
});
|
|
6860
|
+
// restore prototype chain
|
|
6861
|
+
const actualProto = new.target.prototype;
|
|
6862
|
+
this.name = actualProto.constructor.name;
|
|
6863
|
+
// istanbul ignore next
|
|
6864
|
+
if (Object.setPrototypeOf)
|
|
6865
|
+
Object.setPrototypeOf(this, actualProto);
|
|
6866
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
6867
|
+
else
|
|
6868
|
+
this.__proto__ = actualProto;
|
|
6869
|
+
if (options === null || options === void 0 ? void 0 : options.cause)
|
|
6870
|
+
this.cause = __classPrivateFieldGet(IsoError, _a, "m", _IsoError_toIsoError).call(IsoError, options.cause);
|
|
6871
|
+
if (options === null || options === void 0 ? void 0 : options.ssf)
|
|
6872
|
+
Error.captureStackTrace(this, options.ssf);
|
|
6873
|
+
}
|
|
6874
|
+
toString() { return IsoError.serialize(this); }
|
|
6875
|
+
trace() { return IsoError.trace(this); }
|
|
6954
6876
|
}
|
|
6955
|
-
|
|
6877
|
+
exports.IsoError = IsoError;
|
|
6878
|
+
_a = IsoError, _IsoError_hasCause = function _IsoError_hasCause(x) {
|
|
6956
6879
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
6957
6880
|
return !!x.cause;
|
|
6958
|
-
}
|
|
6881
|
+
}, _IsoError_toIsoError = function _IsoError_toIsoError(err) {
|
|
6882
|
+
if (err instanceof IsoError)
|
|
6883
|
+
return err;
|
|
6884
|
+
// When the error is an internal error from deserialization,
|
|
6885
|
+
// the err.constructor.name is object
|
|
6886
|
+
return Object.assign(err, { name: err.constructor.name !== 'Object' ? err.constructor.name : err.name });
|
|
6887
|
+
};
|
|
6888
|
+
Object.defineProperty(IsoError, "converter", {
|
|
6889
|
+
enumerable: true,
|
|
6890
|
+
configurable: true,
|
|
6891
|
+
writable: true,
|
|
6892
|
+
value: new SerializableConverter()
|
|
6893
|
+
});
|
|
6959
6894
|
/**
|
|
6960
6895
|
* An IsoError with a module property.
|
|
6961
6896
|
*/
|
|
6962
|
-
|
|
6963
|
-
__extends(ModuleError, _super);
|
|
6897
|
+
class ModuleError extends IsoError {
|
|
6964
6898
|
/**
|
|
6965
6899
|
* @param module The module that defines this error.
|
|
6966
6900
|
*/
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
Object.defineProperty(
|
|
6901
|
+
constructor(module, message, options) {
|
|
6902
|
+
super(message, options);
|
|
6903
|
+
Object.defineProperty(this, "module", {
|
|
6970
6904
|
enumerable: true,
|
|
6971
6905
|
configurable: true,
|
|
6972
6906
|
writable: true,
|
|
6973
6907
|
value: module
|
|
6974
6908
|
});
|
|
6975
|
-
return _this;
|
|
6976
6909
|
}
|
|
6977
|
-
|
|
6978
|
-
}(IsoError));
|
|
6910
|
+
}
|
|
6979
6911
|
exports.ModuleError = ModuleError;
|
|
6980
6912
|
function isAggregateError(error) {
|
|
6981
6913
|
return error instanceof Error && Array.isArray(error.errors);
|
|
Binary file
|