@datapos/datapos-shared 0.3.583 → 0.3.585

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