@datapos/datapos-shared 0.3.565 → 0.3.566

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,43 +1,43 @@
1
- class a extends Error {
1
+ class c extends Error {
2
2
  locator;
3
3
  // Logical source of the error
4
4
  constructor(o, s, r) {
5
5
  super(o, r), this.name = "DPUError", this.locator = s;
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
11
  constructor(o, s, r, t) {
12
- super(o, s, t), this.name = "APIError", this.body = E(r ?? void 0);
12
+ super(o, s, t), this.name = "APIError", this.body = l(r ?? void 0);
13
13
  }
14
14
  }
15
- class u extends a {
15
+ class d extends c {
16
16
  constructor(o, s, r) {
17
17
  super(o, s, r), this.name = "EngineError";
18
18
  }
19
19
  }
20
- class f extends a {
20
+ class m extends c {
21
21
  constructor(o, s, r) {
22
22
  super(o, s, 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
28
  constructor(o, s, r, t) {
29
- super(o, s, t), this.name = "FetchError", this.body = E(r ?? void 0);
29
+ super(o, s, t), this.name = "FetchError", this.body = l(r ?? void 0);
30
30
  }
31
31
  }
32
32
  async function b(e, o, s) {
33
33
  const r = ` - ${e.statusText}`, t = `${o} Response status '${e.status}${e.statusText ? r : ""}' received.`;
34
- let c;
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, s, n);
41
41
  }
42
42
  function y(e) {
43
43
  return e.map((o) => o.message).join(" ");
@@ -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));
@@ -63,34 +63,64 @@ function n(e) {
63
63
  }
64
64
  function h(e) {
65
65
  const o = /* @__PURE__ */ new Set(), s = [];
66
- let r = n(e);
66
+ let r = a(e);
67
67
  for (; r != null && !o.has(r); ) {
68
68
  o.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 (console.log("0000", r), 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
+ const n = r;
78
+ console.log(1111, n.locator), t = { body: void 0, locator: n.locator, message: r.message, name: "ConnectorError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
79
+ break;
80
+ }
81
+ case "EngineError": {
82
+ t = { body: void 0, locator: r.locator, message: r.message, name: "EngineError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
83
+ break;
84
+ }
85
+ case "FetchError": {
86
+ const n = r;
87
+ t = { body: n.body, locator: n.locator, message: r.message, name: "FetchError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
88
+ break;
89
+ }
90
+ case "DPUError": {
91
+ t = { body: void 0, locator: r.locator, message: r.message, name: "DPUError", stack: r.stack }, r = r.cause == null ? null : a(r.cause);
92
+ break;
93
+ }
94
+ case "Error":
95
+ t = { body: void 0, locator: "", message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : a(r.cause);
96
+ break;
97
+ default:
98
+ t = { body: void 0, locator: "", message: g(r), name: "Error", stack: void 0 }, r = null;
99
+ }
100
+ /(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."), s.push(t);
71
101
  }
72
102
  return s;
73
103
  }
74
- function w(e) {
104
+ function p(e) {
75
105
  if (e.length === 0) return;
76
106
  let o;
77
107
  for (const s of e.toReversed()) {
78
108
  let r;
79
109
  switch (s.name) {
80
110
  case "APIError":
81
- r = new l(s.message, s.locator, s.body, { cause: o });
111
+ r = new E(s.message, s.locator, s.body, { cause: o });
82
112
  break;
83
113
  case "ConnectorError":
84
- console.log(2222, s.locator), r = new f(s.message, s.locator, { cause: o });
114
+ console.log(2222, s.locator), r = new m(s.message, s.locator, { cause: o });
85
115
  break;
86
116
  case "EngineError":
87
- r = new u(s.message, s.locator, { cause: o });
117
+ r = new d(s.message, s.locator, { cause: o });
88
118
  break;
89
119
  case "FetchError":
90
120
  r = new i(s.message, s.locator, s.body, { cause: o });
91
121
  break;
92
122
  case "DPUError":
93
- r = new a(s.message, s.locator, { cause: o });
123
+ r = new c(s.message, s.locator, { cause: o });
94
124
  break;
95
125
  default:
96
126
  r = new Error(s.message, { cause: o }), r.name = s.name;
@@ -100,7 +130,7 @@ function w(e) {
100
130
  }
101
131
  return o;
102
132
  }
103
- function m(e) {
133
+ function g(e) {
104
134
  let o;
105
135
  try {
106
136
  o = JSON.stringify(e);
@@ -109,20 +139,20 @@ function m(e) {
109
139
  }
110
140
  return o === "" && (o = "Unknown error"), o;
111
141
  }
112
- function E(e) {
142
+ function l(e) {
113
143
  if (!(e == null || e === ""))
114
144
  return e.length > 2048 ? `${e.slice(0, 2048)}... [truncated]` : e;
115
145
  }
116
146
  export {
117
- l as APIError,
118
- f as ConnectorError,
119
- a as DPUError,
120
- u as EngineError,
147
+ E as APIError,
148
+ m as ConnectorError,
149
+ c as DPUError,
150
+ d as EngineError,
121
151
  i as FetchError,
122
152
  b as buildFetchError,
123
153
  y as concatenateSerialisedErrorMessages,
124
154
  k as ignoreErrors,
125
- n as normalizeToError,
155
+ a as normalizeToError,
126
156
  h as serialiseError,
127
- w as unserialiseError
157
+ p as unserialiseError
128
158
  };
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.566",
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>",