@datapos/datapos-shared 0.3.549 → 0.3.551

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