@datapos/datapos-shared 0.3.556 → 0.3.557

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