@datapos/datapos-shared 0.3.547 → 0.3.548

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,81 +1,81 @@
1
1
  class c extends Error {
2
2
  locator;
3
3
  /** Logical source of the error. */
4
- constructor(t, o, r) {
5
- super(t, r), this.name = new.target.name, this.locator = o;
4
+ constructor(s, t, e) {
5
+ super(s, e), this.name = new.target.name, this.locator = t;
6
6
  }
7
7
  }
8
8
  class i extends c {
9
9
  }
10
- class f extends i {
11
- }
12
10
  class d extends i {
13
11
  }
12
+ class u extends i {
13
+ }
14
14
  class l extends i {
15
15
  body;
16
16
  /** Sanitized HTTP response body. */
17
- constructor(t, o, r, s) {
18
- super(t, o, s), this.name = new.target.name, this.body = g(r ?? void 0);
17
+ constructor(s, t, e, o) {
18
+ super(s, t, o), this.name = new.target.name, this.body = g(e ?? void 0);
19
19
  }
20
20
  }
21
- async function y(e, t, o) {
22
- const r = ` - ${e.statusText}`, s = `${t} Response status '${e.status}${e.statusText ? r : ""}' received.`;
21
+ async function y(r, s, t) {
22
+ const e = ` - ${r.statusText}`, o = `${s} Response status '${r.status}${r.statusText ? e : ""}' received.`;
23
23
  let a;
24
24
  try {
25
- a = await e.text();
26
- } catch (u) {
27
- a = `<body unavailable: ${n(u).message}>`;
25
+ a = await r.text();
26
+ } catch (f) {
27
+ a = `<body unavailable: ${n(f).message}>`;
28
28
  }
29
- return new l(s, o, a);
29
+ return new l(o, t, a);
30
30
  }
31
- function w(e) {
32
- return e.map((t) => t.message).join(" ");
31
+ function b(r) {
32
+ return r.map((s) => s.message).join(" ");
33
33
  }
34
- function b(e) {
34
+ function w(r) {
35
35
  try {
36
- e();
36
+ r();
37
37
  } catch {
38
38
  }
39
39
  }
40
- function n(e) {
41
- if (e instanceof Error) return e;
42
- if (typeof e == "string") return new Error(e);
43
- if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint") return new Error(String(e));
44
- if (typeof e == "symbol") return new Error(e.description ?? "Unknown error");
45
- if (typeof e == "object")
40
+ function n(r) {
41
+ if (r instanceof Error) return r;
42
+ if (typeof r == "string") return new Error(r);
43
+ if (typeof r == "number" || typeof r == "boolean" || typeof r == "bigint") return new Error(String(r));
44
+ if (typeof r == "symbol") return new Error(r.description ?? "Unknown error");
45
+ if (typeof r == "object")
46
46
  try {
47
- return new Error(JSON.stringify(e));
47
+ return new Error(JSON.stringify(r));
48
48
  } catch {
49
49
  return new Error("Unknown error");
50
50
  }
51
51
  return new Error("Unknown error");
52
52
  }
53
- function k(e) {
54
- const t = /* @__PURE__ */ new Set(), o = [];
55
- let r = n(e);
56
- for (; r != null && !t.has(r); ) {
57
- t.add(r);
58
- let s;
59
- r instanceof l ? (s = { body: r.body, locator: r.locator, message: r.message, name: "FetchError", stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : r instanceof c ? (s = { body: void 0, locator: r.locator, message: r.message, name: "DataPosError", stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : r instanceof Error ? (s = { body: void 0, locator: "", message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : n(r.cause)) : (s = { body: void 0, locator: "", message: E(r), name: "Error", stack: void 0 }, r = null), /(?:\.{3}|[.!?])$/.test(s.message) || (s.message += "."), o.push(s);
53
+ function k(r) {
54
+ const s = /* @__PURE__ */ new Set(), t = [];
55
+ let e = n(r);
56
+ for (; e != null && !s.has(e); ) {
57
+ s.add(e);
58
+ let o;
59
+ e instanceof l ? (o = { body: e.body, locator: e.locator, message: e.message, name: "FetchError", stack: e.stack }, e = e.cause == null ? null : n(e.cause)) : e instanceof c ? (o = { body: void 0, locator: e.locator, message: e.message, name: "DataPosError", stack: e.stack }, e = e.cause == null ? null : n(e.cause)) : e instanceof u ? (o = { body: void 0, locator: e.locator, message: e.message, name: "EngineError", stack: e.stack }, e = e.cause == null ? null : n(e.cause)) : e instanceof Error ? (o = { body: void 0, locator: "", message: e.message, name: e.name, stack: e.stack }, e = e.cause == null ? null : n(e.cause)) : (o = { body: void 0, locator: "", message: E(e), name: "Error", stack: void 0 }, e = null), /(?:\.{3}|[.!?])$/.test(o.message) || (o.message += "."), t.push(o);
60
60
  }
61
- return o;
61
+ return t;
62
62
  }
63
- function h(e) {
64
- if (e.length === 0) return;
65
- let t;
66
- for (const o of e.toReversed()) {
67
- let r;
68
- if (console.log(1111, o), o.body !== void 0)
69
- r = new l(o.message, o.locator, o.body, { cause: t });
70
- else if (o.locator === "")
71
- r = new Error(o.message, { cause: t }), r.name = o.name;
63
+ function h(r) {
64
+ if (r.length === 0) return;
65
+ let s;
66
+ for (const t of r.toReversed()) {
67
+ let e;
68
+ if (console.log(1111, t), t.body !== void 0)
69
+ e = new l(t.message, t.locator, t.body, { cause: s });
70
+ else if (t.locator === "")
71
+ e = new Error(t.message, { cause: s }), e.name = t.name;
72
72
  else
73
- switch (o.name) {
73
+ switch (t.name) {
74
74
  case "APIError":
75
- r = new f(o.message, o.locator, { cause: t });
75
+ e = new d(t.message, t.locator, { cause: s });
76
76
  break;
77
77
  case "EngineError":
78
- r = new d(o.message, o.locator, { cause: t });
78
+ e = new u(t.message, t.locator, { cause: s });
79
79
  break;
80
80
  // case 'ApplicationError':
81
81
  // error = new ApplicationError(serialised.message, serialised.locator, { rebuiltError });
@@ -90,33 +90,33 @@ function h(e) {
90
90
  // error = new WindowHandledPromiseRejectionError(serialised.message, serialised.locator, { rebuiltError });
91
91
  // break;
92
92
  default:
93
- r = new c(o.message, o.locator, { cause: t });
93
+ e = new c(t.message, t.locator, { cause: s });
94
94
  break;
95
95
  }
96
- o.stack !== void 0 && (r.stack = o.stack), t = r;
96
+ t.stack !== void 0 && (e.stack = t.stack), s = e;
97
97
  }
98
- return t;
98
+ return s;
99
99
  }
100
- function E(e) {
101
- let t;
100
+ function E(r) {
101
+ let s;
102
102
  try {
103
- t = JSON.stringify(e);
103
+ s = JSON.stringify(r);
104
104
  } catch {
105
- typeof e == "symbol" ? t = e.description ?? "Unknown error" : typeof e == "bigint" ? t = e.toString() : t = "Unknown error";
105
+ typeof r == "symbol" ? s = r.description ?? "Unknown error" : typeof r == "bigint" ? s = r.toString() : s = "Unknown error";
106
106
  }
107
- return t === "" && (t = "Unknown error"), t;
107
+ return s === "" && (s = "Unknown error"), s;
108
108
  }
109
- function g(e) {
110
- if (!(e == null || e === ""))
111
- return e.length > 2048 ? `${e.slice(0, 2048)}... [truncated]` : e;
109
+ function g(r) {
110
+ if (!(r == null || r === ""))
111
+ return r.length > 2048 ? `${r.slice(0, 2048)}... [truncated]` : r;
112
112
  }
113
113
  export {
114
- f as APIError,
115
- d as EngineError,
114
+ d as APIError,
115
+ u as EngineError,
116
116
  l as FetchError,
117
117
  y as buildFetchError,
118
- w as concatenateSerialisedErrorMessages,
119
- b as ignoreErrors,
118
+ b as concatenateSerialisedErrorMessages,
119
+ w as ignoreErrors,
120
120
  n as normalizeToError,
121
121
  k as serialiseError,
122
122
  h as unserialiseError
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datapos/datapos-shared",
3
- "version": "0.3.547",
3
+ "version": "0.3.548",
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>",