@metriport/shared 0.10.1-alpha.2 → 0.10.1-alpha.3
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/shared/src/common/env.d.ts +6 -0
- package/dist/shared/src/common/env.d.ts.map +1 -0
- package/dist/shared/src/common/env.js +9 -0
- package/dist/shared/src/common/env.js.map +1 -0
- package/dist/shared/src/error/shared.d.ts +8 -0
- package/dist/shared/src/error/shared.d.ts.map +1 -0
- package/dist/shared/src/error/shared.js +34 -0
- package/dist/shared/src/error/shared.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/common/env.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,OACwE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Indicates whether the code is running in a Node.js environment.
|
|
6
|
+
* From https://github.com/flexdinesh/browser-or-node/blob/master/src/index.ts
|
|
7
|
+
*/
|
|
8
|
+
exports.isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
9
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../../src/common/env.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,MAAM,GACjB,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type ErrorToStringOptions = {
|
|
2
|
+
detailed: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare function errorToString(err: unknown, options?: ErrorToStringOptions): string;
|
|
5
|
+
export declare function genericErrorToString(err: any): string;
|
|
6
|
+
export declare function detailedErrorToString(err: any): string;
|
|
7
|
+
export declare function getErrorMessage(error: unknown): string;
|
|
8
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../src/error/shared.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzD,wBAAgB,aAAa,CAC3B,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE,oBAAyC,GACjD,MAAM,CAKR;AAGD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAOrD;AAGD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAStD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,UAE7C"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getErrorMessage = exports.detailedErrorToString = exports.genericErrorToString = exports.errorToString = void 0;
|
|
4
|
+
function errorToString(err, options = { detailed: true }) {
|
|
5
|
+
if (options.detailed) {
|
|
6
|
+
return detailedErrorToString(err);
|
|
7
|
+
}
|
|
8
|
+
return genericErrorToString(err);
|
|
9
|
+
}
|
|
10
|
+
exports.errorToString = errorToString;
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
function genericErrorToString(err) {
|
|
13
|
+
const msg = "message" in err ? err.message : String(err);
|
|
14
|
+
const code = "code" in err ? err.code : undefined;
|
|
15
|
+
const status = "response" in err ? err.response.status : undefined;
|
|
16
|
+
const suffix = code && status ? ` (${code} - ${status})` : code || status ? ` (${code ?? status})` : "";
|
|
17
|
+
return msg + suffix;
|
|
18
|
+
}
|
|
19
|
+
exports.genericErrorToString = genericErrorToString;
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
function detailedErrorToString(err) {
|
|
22
|
+
const thisErrorMessage = genericErrorToString(err);
|
|
23
|
+
const additionalInfo = err.additionalInfo ? JSON.stringify(err.additionalInfo) : undefined;
|
|
24
|
+
const causeMessage = err.cause ? detailedErrorToString(err.cause) : undefined;
|
|
25
|
+
return (`${thisErrorMessage}` +
|
|
26
|
+
`${additionalInfo ? ` (${additionalInfo})` : ""}` +
|
|
27
|
+
`${causeMessage ? `; caused by ${causeMessage}` : ""}`);
|
|
28
|
+
}
|
|
29
|
+
exports.detailedErrorToString = detailedErrorToString;
|
|
30
|
+
function getErrorMessage(error) {
|
|
31
|
+
return errorToString(error);
|
|
32
|
+
}
|
|
33
|
+
exports.getErrorMessage = getErrorMessage;
|
|
34
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/error/shared.ts"],"names":[],"mappings":";;;AAEA,SAAgB,aAAa,CAC3B,GAAY,EACZ,UAAgC,EAAE,QAAQ,EAAE,IAAI,EAAE;IAElD,IAAI,OAAO,CAAC,QAAQ,EAAE;QACpB,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAC;KACnC;IACD,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AARD,sCAQC;AAED,8DAA8D;AAC9D,SAAgB,oBAAoB,CAAC,GAAQ;IAC3C,MAAM,GAAG,GAAG,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAClD,MAAM,MAAM,GAAG,UAA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4
4
|
"description": "Common code shared across packages - by Metriport Inc.",
|
|
5
5
|
"author": "Metriport Inc. <contact@metriport.com>",
|
|
6
6
|
"homepage": "https://metriport.com/",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@faker-js/faker": "^8.0.2"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "bcd51e57c49db4259b91bd3595b6d7025608d8de"
|
|
62
62
|
}
|