@datapos/datapos-shared 0.3.585 → 0.3.587
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
1
|
class c 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 c {
|
|
10
|
+
constructor(s, t, r, a) {
|
|
11
|
+
super(s, t, r, a), this.name = "AppError";
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
class E extends c {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
constructor(s, o, r, t) {
|
|
17
|
-
super(s, o, t), this.name = "APIError", this.body = l(r ?? void 0);
|
|
15
|
+
constructor(s, t, r, a) {
|
|
16
|
+
super(s, t, r, a), this.name = "APIError";
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
class d extends c {
|
|
21
|
-
constructor(s,
|
|
22
|
-
super(s,
|
|
20
|
+
constructor(s, t, r, a) {
|
|
21
|
+
super(s, t, r, a), this.name = "EngineError";
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
class m extends c {
|
|
26
|
-
constructor(s,
|
|
27
|
-
super(s,
|
|
25
|
+
constructor(s, t, r, a) {
|
|
26
|
+
super(s, t, r, a), this.name = "ConnectorError";
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
class i extends c {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
constructor(s, o, r, t) {
|
|
34
|
-
super(s, o, t), this.name = "FetchError", this.body = l(r ?? void 0);
|
|
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 o;
|
|
40
37
|
try {
|
|
41
|
-
|
|
42
|
-
} catch (
|
|
43
|
-
|
|
38
|
+
o = await e.text();
|
|
39
|
+
} catch (l) {
|
|
40
|
+
o = `<body unavailable: ${n(l).message}>`;
|
|
44
41
|
}
|
|
45
|
-
return new i(t, o
|
|
42
|
+
return new i(a, t, { body: f(o) });
|
|
46
43
|
}
|
|
47
|
-
function
|
|
44
|
+
function h(e) {
|
|
48
45
|
return e.map((s) => s.message).join(" ");
|
|
49
46
|
}
|
|
50
|
-
function
|
|
47
|
+
function w(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,71 @@ 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 b(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
|
-
r.name ? (
|
|
99
|
+
r.name ? (a = { data: void 0, locator: "", message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : (a = { data: void 0, locator: "", message: g(r), name: "Error", stack: void 0 }, r = null);
|
|
100
100
|
}
|
|
101
|
-
/(?:\.{3}|[.!?])$/.test(
|
|
101
|
+
/(?:\.{3}|[.!?])$/.test(a.message) || (a.message += "."), t.push(a);
|
|
102
102
|
}
|
|
103
|
-
return
|
|
103
|
+
return t;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function y(e) {
|
|
106
106
|
if (e.length === 0) return;
|
|
107
107
|
let s;
|
|
108
|
-
for (const
|
|
108
|
+
for (const t of e.toReversed()) {
|
|
109
109
|
let r;
|
|
110
|
-
switch (
|
|
110
|
+
switch (t.name) {
|
|
111
111
|
case "APIError":
|
|
112
|
-
r = new E(
|
|
112
|
+
r = new E(t.message, t.locator, t.data, { cause: s });
|
|
113
|
+
break;
|
|
114
|
+
case "AppError":
|
|
115
|
+
r = new u(t.message, t.locator, t.data, { cause: s });
|
|
113
116
|
break;
|
|
114
117
|
case "ConnectorError":
|
|
115
|
-
r = new m(
|
|
118
|
+
r = new m(t.message, t.locator, t.data, { cause: s });
|
|
116
119
|
break;
|
|
117
120
|
case "EngineError":
|
|
118
|
-
r = new d(
|
|
121
|
+
r = new d(t.message, t.locator, t.data, { cause: s });
|
|
119
122
|
break;
|
|
120
123
|
case "FetchError":
|
|
121
|
-
r = new i(
|
|
124
|
+
r = new i(t.message, t.locator, t.data, { cause: s });
|
|
122
125
|
break;
|
|
123
126
|
default:
|
|
124
|
-
r = new Error(
|
|
127
|
+
r = new Error(t.message, { cause: s }), r.name = t.name;
|
|
125
128
|
break;
|
|
126
129
|
}
|
|
127
|
-
|
|
130
|
+
t.stack !== void 0 && (r.stack = t.stack), s = r;
|
|
128
131
|
}
|
|
129
132
|
return s;
|
|
130
133
|
}
|
|
@@ -137,21 +140,21 @@ function g(e) {
|
|
|
137
140
|
}
|
|
138
141
|
return s === "" && (s = "Unknown error"), s;
|
|
139
142
|
}
|
|
140
|
-
function
|
|
143
|
+
function f(e) {
|
|
141
144
|
if (!(e == null || e === ""))
|
|
142
145
|
return e.length > 2048 ? `${e.slice(0, 2048)}... [truncated]` : e;
|
|
143
146
|
}
|
|
144
147
|
export {
|
|
145
148
|
E as APIError,
|
|
146
|
-
|
|
149
|
+
u as AppError,
|
|
147
150
|
m as ConnectorError,
|
|
148
|
-
c as
|
|
151
|
+
c as DPUseError,
|
|
149
152
|
d as EngineError,
|
|
150
153
|
i as FetchError,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
p as buildFetchError,
|
|
155
|
+
h as concatenateSerialisedErrorMessages,
|
|
156
|
+
w as ignoreErrors,
|
|
157
|
+
n as normalizeToError,
|
|
158
|
+
b as serialiseError,
|
|
159
|
+
y as unserialiseError
|
|
157
160
|
};
|
|
@@ -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
|
|
9
|
-
readonly
|
|
10
|
-
|
|
8
|
+
export declare class DPUseError extends Error {
|
|
9
|
+
readonly data: Record<string, unknown> | undefined;
|
|
10
|
+
readonly locator: string;
|
|
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.587",
|
|
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>",
|