@datapos/datapos-shared 0.3.515 → 0.3.516
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.
|
@@ -1,124 +1,164 @@
|
|
|
1
1
|
class i extends Error {
|
|
2
2
|
locator;
|
|
3
3
|
/** Logical source of the error. */
|
|
4
|
-
constructor(
|
|
5
|
-
super(
|
|
4
|
+
constructor(n, o, e) {
|
|
5
|
+
super(n, e), this.name = new.target.name, this.locator = o;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
class a extends i {
|
|
9
9
|
}
|
|
10
|
-
class
|
|
10
|
+
class d extends a {
|
|
11
11
|
}
|
|
12
|
-
class
|
|
12
|
+
class f extends a {
|
|
13
13
|
}
|
|
14
14
|
class c extends a {
|
|
15
15
|
body;
|
|
16
16
|
/** Sanitized HTTP response body. */
|
|
17
|
-
constructor(
|
|
18
|
-
super(o, t
|
|
17
|
+
constructor(n, o, e, t) {
|
|
18
|
+
super(n, o, t), this.name = new.target.name, this.body = b(e ?? void 0);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class g extends i {
|
|
22
22
|
}
|
|
23
|
-
class
|
|
23
|
+
class l extends a {
|
|
24
24
|
componentName;
|
|
25
25
|
/** Vue component name, if available. */
|
|
26
26
|
info;
|
|
27
27
|
/** Vue error info string. */
|
|
28
|
-
constructor(
|
|
29
|
-
super(
|
|
28
|
+
constructor(n, o, e, t, s) {
|
|
29
|
+
super(n, o, s), this.name = new.target.name, this.info = e, this.componentName = t;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
class
|
|
32
|
+
class E extends a {
|
|
33
33
|
}
|
|
34
|
-
class
|
|
34
|
+
class u extends a {
|
|
35
35
|
}
|
|
36
|
-
async function
|
|
37
|
-
const
|
|
36
|
+
async function y(r, n, o) {
|
|
37
|
+
const e = ` - ${r.statusText}`, t = `${n} Response status '${r.status}${r.statusText ? e : ""}' received.`;
|
|
38
38
|
let s;
|
|
39
39
|
try {
|
|
40
|
-
s = await
|
|
41
|
-
} catch (
|
|
42
|
-
s = `<body unavailable: ${
|
|
40
|
+
s = await r.text();
|
|
41
|
+
} catch (m) {
|
|
42
|
+
s = `<body unavailable: ${w(m).message}>`;
|
|
43
43
|
}
|
|
44
|
-
return new c(
|
|
44
|
+
return new c(t, o, s);
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
return
|
|
46
|
+
function h(r) {
|
|
47
|
+
return r.map((n) => n.message).join(" ");
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function R(r) {
|
|
50
50
|
try {
|
|
51
|
-
|
|
51
|
+
r();
|
|
52
52
|
} catch {
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
if (
|
|
57
|
-
if (typeof
|
|
58
|
-
if (typeof
|
|
59
|
-
if (typeof
|
|
60
|
-
if (
|
|
55
|
+
function w(r) {
|
|
56
|
+
if (r instanceof Error) return r;
|
|
57
|
+
if (typeof r == "string") return new Error(r);
|
|
58
|
+
if (typeof r == "number" || typeof r == "boolean" || typeof r == "bigint") return new Error(String(r));
|
|
59
|
+
if (typeof r == "symbol") return new Error(r.description ?? "Unknown error");
|
|
60
|
+
if (r != null && typeof r == "object")
|
|
61
61
|
try {
|
|
62
|
-
return new Error(JSON.stringify(
|
|
62
|
+
return new Error(JSON.stringify(r));
|
|
63
63
|
} catch {
|
|
64
64
|
return new Error("Unknown error");
|
|
65
65
|
}
|
|
66
66
|
return new Error("Unknown error");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const
|
|
70
|
-
let
|
|
71
|
-
for (;
|
|
72
|
-
|
|
73
|
-
let
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
else if (
|
|
77
|
-
|
|
78
|
-
componentName:
|
|
68
|
+
function x(r) {
|
|
69
|
+
const n = /* @__PURE__ */ new Set(), o = [];
|
|
70
|
+
let e = r;
|
|
71
|
+
for (; e != null && !n.has(e); ) {
|
|
72
|
+
n.add(e);
|
|
73
|
+
let t;
|
|
74
|
+
if (e instanceof c)
|
|
75
|
+
t = { componentName: void 0, body: e.body, info: void 0, locator: e.locator, message: e.message, name: e.name, stack: e.stack }, e = e.cause;
|
|
76
|
+
else if (e instanceof l)
|
|
77
|
+
t = {
|
|
78
|
+
componentName: e.componentName,
|
|
79
79
|
body: void 0,
|
|
80
|
-
info:
|
|
81
|
-
locator:
|
|
82
|
-
message:
|
|
83
|
-
name:
|
|
84
|
-
stack:
|
|
85
|
-
},
|
|
86
|
-
else if (
|
|
87
|
-
|
|
88
|
-
else if (
|
|
89
|
-
const s =
|
|
90
|
-
|
|
80
|
+
info: e.info,
|
|
81
|
+
locator: e.locator,
|
|
82
|
+
message: e.message,
|
|
83
|
+
name: e.name,
|
|
84
|
+
stack: e.stack
|
|
85
|
+
}, e = e.cause;
|
|
86
|
+
else if (e instanceof i)
|
|
87
|
+
t = { componentName: void 0, body: void 0, info: void 0, locator: e.locator, message: e.message, name: e.name, stack: e.stack }, e = e.cause;
|
|
88
|
+
else if (e instanceof Error) {
|
|
89
|
+
const s = e;
|
|
90
|
+
t = { componentName: void 0, body: void 0, info: void 0, locator: "", message: s.message, name: s.name, stack: s.stack }, e = s.cause;
|
|
91
91
|
} else
|
|
92
|
-
|
|
93
|
-
/(?:\.{3}|[.!?])$/.test(
|
|
92
|
+
t = { componentName: void 0, body: void 0, info: void 0, locator: "", message: p(e), name: "Error", stack: void 0 }, e = void 0;
|
|
93
|
+
/(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."), o.push(t);
|
|
94
94
|
}
|
|
95
|
-
return
|
|
95
|
+
return o;
|
|
96
|
+
}
|
|
97
|
+
function v(r) {
|
|
98
|
+
if (r.length === 0) return;
|
|
99
|
+
let n;
|
|
100
|
+
for (const o of r.toReversed()) {
|
|
101
|
+
let e;
|
|
102
|
+
if (o.body !== void 0)
|
|
103
|
+
e = new c(o.message, o.locator, o.body, { cause: n });
|
|
104
|
+
else if (o.info !== void 0)
|
|
105
|
+
e = new l(o.message, o.locator, o.info, o.componentName, { cause: n });
|
|
106
|
+
else if (o.locator === "")
|
|
107
|
+
e = new Error(o.message, { cause: n }), e.name = o.name;
|
|
108
|
+
else
|
|
109
|
+
switch (o.name) {
|
|
110
|
+
case "APIError":
|
|
111
|
+
e = new d(o.message, o.locator, { cause: n });
|
|
112
|
+
break;
|
|
113
|
+
case "EngineError":
|
|
114
|
+
e = new f(o.message, o.locator, { cause: n });
|
|
115
|
+
break;
|
|
116
|
+
case "ApplicationError":
|
|
117
|
+
e = new a(o.message, o.locator, { cause: n });
|
|
118
|
+
break;
|
|
119
|
+
case "OperationalError":
|
|
120
|
+
e = new g(o.message, o.locator, { cause: n });
|
|
121
|
+
break;
|
|
122
|
+
case "WindowHandledRuntimeError":
|
|
123
|
+
e = new E(o.message, o.locator, { cause: n });
|
|
124
|
+
break;
|
|
125
|
+
case "WindowHandledPromiseRejectionError":
|
|
126
|
+
e = new u(o.message, o.locator, { cause: n });
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
e = new i(o.message, o.locator, { cause: n });
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
o.stack !== void 0 && (e.stack = o.stack), n = e;
|
|
133
|
+
}
|
|
134
|
+
return n;
|
|
96
135
|
}
|
|
97
|
-
function
|
|
98
|
-
let
|
|
136
|
+
function p(r) {
|
|
137
|
+
let n;
|
|
99
138
|
try {
|
|
100
|
-
|
|
139
|
+
n = JSON.stringify(r);
|
|
101
140
|
} catch {
|
|
102
|
-
typeof
|
|
141
|
+
typeof r == "symbol" ? n = r.description ?? "Unknown error" : typeof r == "bigint" ? n = r.toString() : n = "Unknown error";
|
|
103
142
|
}
|
|
104
|
-
return
|
|
143
|
+
return n === "" && (n = "Unknown error"), n;
|
|
105
144
|
}
|
|
106
|
-
function
|
|
107
|
-
if (!(
|
|
108
|
-
return
|
|
145
|
+
function b(r) {
|
|
146
|
+
if (!(r == null || r === ""))
|
|
147
|
+
return r.length > 2048 ? `${r.slice(0, 2048)}... [truncated]` : r;
|
|
109
148
|
}
|
|
110
149
|
export {
|
|
111
|
-
|
|
150
|
+
d as APIError,
|
|
112
151
|
a as ApplicationError,
|
|
113
|
-
|
|
152
|
+
f as EngineError,
|
|
114
153
|
c as FetchError,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
154
|
+
g as OperationalError,
|
|
155
|
+
l as VueHandledError,
|
|
156
|
+
u as WindowHandledPromiseRejectionError,
|
|
157
|
+
E as WindowHandledRuntimeError,
|
|
158
|
+
y as buildFetchError,
|
|
159
|
+
h as concatenateSerialisedErrorMessages,
|
|
160
|
+
R as ignoreErrors,
|
|
161
|
+
w as normalizeToError,
|
|
162
|
+
x as serialiseError,
|
|
163
|
+
v as unserialiseError
|
|
124
164
|
};
|
|
@@ -79,7 +79,13 @@ declare function normalizeToError(value: unknown): Error;
|
|
|
79
79
|
* - Messages are normalized to end with punctuation.
|
|
80
80
|
*/
|
|
81
81
|
declare function serialiseError(error?: unknown): SerialisedError[];
|
|
82
|
+
/** Unserialises an array of {@link SerialisedError} objects back into an error with a cause chain.
|
|
83
|
+
* - Reconstructs the appropriate error class based on serialized properties.
|
|
84
|
+
* - Chains errors from outermost to root cause using the `cause` option.
|
|
85
|
+
* - Returns `undefined` if the input array is empty.
|
|
86
|
+
*/
|
|
87
|
+
declare function unserialiseError(serialisedErrors: SerialisedError[]): Error | undefined;
|
|
82
88
|
/** Exports. */
|
|
83
89
|
export type { SerialisedError };
|
|
84
90
|
export { ApplicationError, APIError, EngineError, FetchError, OperationalError, VueHandledError, WindowHandledRuntimeError, WindowHandledPromiseRejectionError };
|
|
85
|
-
export { buildFetchError, concatenateSerialisedErrorMessages, ignoreErrors, normalizeToError, serialiseError };
|
|
91
|
+
export { buildFetchError, concatenateSerialisedErrorMessages, ignoreErrors, normalizeToError, serialiseError, unserialiseError };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.516",
|
|
4
4
|
"description": "A library containing common constants, types and utilities used across all Data Positioning projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jonathan Terrell <terrell.jm@gmail.com>",
|