@datapos/datapos-shared 0.3.565 → 0.3.567

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