@datapos/datapos-shared 0.3.586 → 0.3.588
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,59 +1,56 @@
|
|
|
1
|
-
class
|
|
1
|
+
class i extends Error {
|
|
2
|
+
data;
|
|
2
3
|
locator;
|
|
3
4
|
// Error locator 'package.module.method'
|
|
4
|
-
constructor(s,
|
|
5
|
-
super(s,
|
|
5
|
+
constructor(s, t, r, a) {
|
|
6
|
+
super(s, a), this.name = "DPUseError", this.data = r, this.locator = t;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
|
-
class
|
|
9
|
-
constructor(s,
|
|
10
|
-
super(s,
|
|
9
|
+
class u extends i {
|
|
10
|
+
constructor(s, t, r, a) {
|
|
11
|
+
super(s, t, r, a), this.name = "AppError";
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
class E extends
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
constructor(s, o, r, t) {
|
|
17
|
-
super(s, o, t), this.name = "APIError", this.body = l(r ?? void 0);
|
|
14
|
+
class E extends i {
|
|
15
|
+
constructor(s, t, r, a) {
|
|
16
|
+
super(s, t, r, a), this.name = "APIError";
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
class d extends
|
|
21
|
-
constructor(s,
|
|
22
|
-
super(s,
|
|
19
|
+
class d extends i {
|
|
20
|
+
constructor(s, t, r, a) {
|
|
21
|
+
super(s, t, r, a), this.name = "EngineError";
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
class m extends
|
|
26
|
-
constructor(s,
|
|
27
|
-
super(s,
|
|
24
|
+
class m extends i {
|
|
25
|
+
constructor(s, t, r, a) {
|
|
26
|
+
super(s, t, r, a), this.name = "ConnectorError";
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
class
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
constructor(s, o, r, t) {
|
|
34
|
-
super(s, o, t), this.name = "FetchError", this.body = l(r ?? void 0);
|
|
29
|
+
class l extends i {
|
|
30
|
+
constructor(s, t, r, a) {
|
|
31
|
+
super(s, t, r, a), this.name = "FetchError";
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
async function
|
|
38
|
-
const r = ` - ${e.statusText}`,
|
|
39
|
-
let
|
|
34
|
+
async function p(e, s, t) {
|
|
35
|
+
const r = ` - ${e.statusText}`, a = `${s} Response status '${e.status}${e.statusText ? r : ""}' received.`;
|
|
36
|
+
let c;
|
|
40
37
|
try {
|
|
41
|
-
|
|
42
|
-
} catch (
|
|
43
|
-
|
|
38
|
+
c = await e.text();
|
|
39
|
+
} catch (o) {
|
|
40
|
+
c = `<body unavailable: ${n(o).message}>`;
|
|
44
41
|
}
|
|
45
|
-
return new
|
|
42
|
+
return new l(a, t, { body: f(c) });
|
|
46
43
|
}
|
|
47
|
-
function
|
|
44
|
+
function h(e) {
|
|
48
45
|
return e.map((s) => s.message).join(" ");
|
|
49
46
|
}
|
|
50
|
-
function
|
|
47
|
+
function b(e) {
|
|
51
48
|
try {
|
|
52
49
|
e();
|
|
53
50
|
} catch {
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
|
-
function
|
|
53
|
+
function n(e) {
|
|
57
54
|
if (e instanceof Error) return e;
|
|
58
55
|
if (typeof e == "string") return new Error(e);
|
|
59
56
|
if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint") return new Error(String(e));
|
|
@@ -66,65 +63,72 @@ function a(e) {
|
|
|
66
63
|
}
|
|
67
64
|
return new Error("Unknown error");
|
|
68
65
|
}
|
|
69
|
-
function
|
|
70
|
-
const s = /* @__PURE__ */ new Set(),
|
|
71
|
-
let r =
|
|
66
|
+
function w(e) {
|
|
67
|
+
const s = /* @__PURE__ */ new Set(), t = [];
|
|
68
|
+
let r = n(e);
|
|
72
69
|
for (; r != null && !s.has(r); ) {
|
|
73
70
|
s.add(r);
|
|
74
|
-
let
|
|
71
|
+
let a;
|
|
75
72
|
switch (r.name) {
|
|
76
73
|
case "APIError": {
|
|
77
|
-
const
|
|
78
|
-
|
|
74
|
+
const o = r;
|
|
75
|
+
a = { data: o.data, locator: o.locator, message: r.message, name: "APIError", stack: r.stack }, r = r.cause == null ? null : n(r.cause);
|
|
79
76
|
break;
|
|
80
77
|
}
|
|
81
78
|
case "AppError": {
|
|
82
|
-
|
|
79
|
+
const o = r;
|
|
80
|
+
a = { data: o.data, locator: o.locator, message: r.message, name: "AppError", stack: r.stack }, r = r.cause == null ? null : n(r.cause);
|
|
83
81
|
break;
|
|
84
82
|
}
|
|
85
83
|
case "ConnectorError": {
|
|
86
|
-
|
|
84
|
+
const o = r;
|
|
85
|
+
a = { data: o.data, locator: o.locator, message: r.message, name: "ConnectorError", stack: r.stack }, r = r.cause == null ? null : n(r.cause);
|
|
87
86
|
break;
|
|
88
87
|
}
|
|
89
88
|
case "EngineError": {
|
|
90
|
-
|
|
89
|
+
const o = r;
|
|
90
|
+
a = { data: o.data, locator: o.locator, message: r.message, name: "EngineError", stack: r.stack }, r = r.cause == null ? null : n(r.cause);
|
|
91
91
|
break;
|
|
92
92
|
}
|
|
93
93
|
case "FetchError": {
|
|
94
|
-
const
|
|
95
|
-
|
|
94
|
+
const o = r;
|
|
95
|
+
a = { data: o.data, locator: o.locator, message: r.message, name: "FetchError", stack: r.stack }, r = r.cause == null ? null : n(r.cause);
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
default:
|
|
99
|
-
|
|
99
|
+
const c = { ...Object.fromEntries(Object.entries(e ?? {})) };
|
|
100
|
+
r.name ? (a = { data: c, locator: "", message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : (a = { data: c, locator: "", message: g(r), name: "Error", stack: void 0 }, r = null);
|
|
100
101
|
}
|
|
101
|
-
/(?:\.{3}|[.!?])$/.test(
|
|
102
|
+
/(?:\.{3}|[.!?])$/.test(a.message) || (a.message += "."), t.push(a);
|
|
102
103
|
}
|
|
103
|
-
return
|
|
104
|
+
return t;
|
|
104
105
|
}
|
|
105
|
-
function
|
|
106
|
+
function y(e) {
|
|
106
107
|
if (e.length === 0) return;
|
|
107
108
|
let s;
|
|
108
|
-
for (const
|
|
109
|
+
for (const t of e.toReversed()) {
|
|
109
110
|
let r;
|
|
110
|
-
switch (
|
|
111
|
+
switch (t.name) {
|
|
111
112
|
case "APIError":
|
|
112
|
-
r = new E(
|
|
113
|
+
r = new E(t.message, t.locator, t.data, { cause: s });
|
|
114
|
+
break;
|
|
115
|
+
case "AppError":
|
|
116
|
+
r = new u(t.message, t.locator, t.data, { cause: s });
|
|
113
117
|
break;
|
|
114
118
|
case "ConnectorError":
|
|
115
|
-
r = new m(
|
|
119
|
+
r = new m(t.message, t.locator, t.data, { cause: s });
|
|
116
120
|
break;
|
|
117
121
|
case "EngineError":
|
|
118
|
-
r = new d(
|
|
122
|
+
r = new d(t.message, t.locator, t.data, { cause: s });
|
|
119
123
|
break;
|
|
120
124
|
case "FetchError":
|
|
121
|
-
r = new
|
|
125
|
+
r = new l(t.message, t.locator, t.data, { cause: s });
|
|
122
126
|
break;
|
|
123
127
|
default:
|
|
124
|
-
r = new Error(
|
|
128
|
+
r = new Error(t.message, { cause: s }), r.name = t.name;
|
|
125
129
|
break;
|
|
126
130
|
}
|
|
127
|
-
|
|
131
|
+
t.stack !== void 0 && (r.stack = t.stack), s = r;
|
|
128
132
|
}
|
|
129
133
|
return s;
|
|
130
134
|
}
|
|
@@ -137,21 +141,21 @@ function g(e) {
|
|
|
137
141
|
}
|
|
138
142
|
return s === "" && (s = "Unknown error"), s;
|
|
139
143
|
}
|
|
140
|
-
function
|
|
144
|
+
function f(e) {
|
|
141
145
|
if (!(e == null || e === ""))
|
|
142
146
|
return e.length > 2048 ? `${e.slice(0, 2048)}... [truncated]` : e;
|
|
143
147
|
}
|
|
144
148
|
export {
|
|
145
149
|
E as APIError,
|
|
146
|
-
|
|
150
|
+
u as AppError,
|
|
147
151
|
m as ConnectorError,
|
|
148
|
-
|
|
152
|
+
i as DPUseError,
|
|
149
153
|
d as EngineError,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
l as FetchError,
|
|
155
|
+
p as buildFetchError,
|
|
156
|
+
h as concatenateSerialisedErrorMessages,
|
|
157
|
+
b as ignoreErrors,
|
|
158
|
+
n as normalizeToError,
|
|
159
|
+
w as serialiseError,
|
|
160
|
+
y as unserialiseError
|
|
157
161
|
};
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
export interface SerialisedError {
|
|
2
|
-
|
|
2
|
+
data: Record<string, unknown> | undefined;
|
|
3
3
|
locator: string;
|
|
4
4
|
message: string;
|
|
5
5
|
name: string;
|
|
6
6
|
stack: string | undefined;
|
|
7
7
|
}
|
|
8
|
-
export declare class
|
|
8
|
+
export declare class DPUseError extends Error {
|
|
9
|
+
readonly data: Record<string, unknown> | undefined;
|
|
9
10
|
readonly locator: string;
|
|
10
|
-
constructor(message: string, locator: string, options?: ErrorOptions);
|
|
11
|
+
constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions);
|
|
11
12
|
}
|
|
12
|
-
export declare class AppError extends
|
|
13
|
-
constructor(message: string, locator: string, options?: ErrorOptions);
|
|
13
|
+
export declare class AppError extends DPUseError {
|
|
14
|
+
constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions);
|
|
14
15
|
}
|
|
15
|
-
export declare class APIError extends
|
|
16
|
-
|
|
17
|
-
constructor(message: string, locator: string, body: string | undefined, options?: ErrorOptions);
|
|
16
|
+
export declare class APIError extends DPUseError {
|
|
17
|
+
constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions);
|
|
18
18
|
}
|
|
19
|
-
export declare class EngineError extends
|
|
20
|
-
constructor(message: string, locator: string, options?: ErrorOptions);
|
|
19
|
+
export declare class EngineError extends DPUseError {
|
|
20
|
+
constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions);
|
|
21
21
|
}
|
|
22
|
-
export declare class ConnectorError extends
|
|
23
|
-
constructor(message: string, locator: string, options?: ErrorOptions);
|
|
22
|
+
export declare class ConnectorError extends DPUseError {
|
|
23
|
+
constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions);
|
|
24
24
|
}
|
|
25
|
-
export declare class FetchError extends
|
|
26
|
-
|
|
27
|
-
constructor(message: string, locator: string, body: string | undefined, options?: ErrorOptions);
|
|
25
|
+
export declare class FetchError extends DPUseError {
|
|
26
|
+
constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions);
|
|
28
27
|
}
|
|
29
28
|
export declare function buildFetchError(response: {
|
|
30
29
|
status: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-shared",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.588",
|
|
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>",
|