@datapos/datapos-shared 0.3.544 → 0.3.546

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,58 +1,43 @@
1
1
  class c extends Error {
2
2
  locator;
3
3
  /** Logical source of the error. */
4
- constructor(o, n, r) {
5
- super(o, r), this.name = new.target.name, this.locator = n;
4
+ constructor(n, o, r) {
5
+ super(n, r), this.name = new.target.name, this.locator = o;
6
6
  }
7
7
  }
8
- class s extends c {
8
+ class i extends c {
9
9
  }
10
- class f extends s {
10
+ class f extends i {
11
11
  }
12
- class u extends s {
12
+ class d extends i {
13
13
  }
14
- class l extends s {
14
+ class l extends i {
15
15
  body;
16
16
  /** Sanitized HTTP response body. */
17
- constructor(o, n, r, t) {
18
- super(o, n, t), this.name = new.target.name, this.body = E(r ?? void 0);
17
+ constructor(n, o, r, t) {
18
+ super(n, o, t), this.name = new.target.name, this.body = m(r ?? void 0);
19
19
  }
20
20
  }
21
- class m extends c {
22
- }
23
- class y extends s {
24
- componentName;
25
- /** Vue component name, if available. */
26
- info;
27
- /** Vue error info string. */
28
- constructor(o, n, r, t, a) {
29
- super(o, n, a), this.name = new.target.name, this.info = r, this.componentName = t;
30
- }
31
- }
32
- class b extends s {
33
- }
34
- class k extends s {
35
- }
36
- async function p(e, o, n) {
37
- const r = ` - ${e.statusText}`, t = `${o} Response status '${e.status}${e.statusText ? r : ""}' received.`;
21
+ async function y(e, n, o) {
22
+ const r = ` - ${e.statusText}`, t = `${n} Response status '${e.status}${e.statusText ? r : ""}' received.`;
38
23
  let a;
39
24
  try {
40
25
  a = await e.text();
41
- } catch (d) {
42
- a = `<body unavailable: ${i(d).message}>`;
26
+ } catch (u) {
27
+ a = `<body unavailable: ${s(u).message}>`;
43
28
  }
44
- return new l(t, n, a);
29
+ return new l(t, o, a);
45
30
  }
46
- function h(e) {
47
- return e.map((o) => o.message).join(" ");
31
+ function w(e) {
32
+ return e.map((n) => n.message).join(" ");
48
33
  }
49
- function x(e) {
34
+ function b(e) {
50
35
  try {
51
36
  e();
52
37
  } catch {
53
38
  }
54
39
  }
55
- function i(e) {
40
+ function s(e) {
56
41
  if (e instanceof Error) return e;
57
42
  if (typeof e == "string") return new Error(e);
58
43
  if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint") return new Error(String(e));
@@ -65,81 +50,76 @@ function i(e) {
65
50
  }
66
51
  return new Error("Unknown error");
67
52
  }
68
- function R(e) {
69
- const o = /* @__PURE__ */ new Set(), n = [];
70
- let r = i(e);
71
- for (; r != null && !o.has(r); ) {
72
- o.add(r);
53
+ function k(e) {
54
+ const n = /* @__PURE__ */ new Set(), o = [];
55
+ let r = s(e);
56
+ for (; r != null && !n.has(r); ) {
57
+ n.add(r);
73
58
  let t;
74
- r instanceof l ? (t = { body: r.body, locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : i(r.cause)) : r instanceof c ? (t = { body: void 0, locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : i(r.cause)) : r instanceof Error ? (t = { body: void 0, locator: "", message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : i(r.cause)) : (t = { body: void 0, locator: "", message: g(r), name: "Error", stack: void 0 }, r = null), /(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."), n.push(t);
59
+ r instanceof l ? (t = { body: r.body, locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : s(r.cause)) : r instanceof c ? (t = { body: void 0, locator: r.locator, message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : s(r.cause)) : r instanceof Error ? (t = { body: void 0, locator: "", message: r.message, name: r.name, stack: r.stack }, r = r.cause == null ? null : s(r.cause)) : (t = { body: void 0, locator: "", message: g(r), name: "Error", stack: void 0 }, r = null), /(?:\.{3}|[.!?])$/.test(t.message) || (t.message += "."), o.push(t);
75
60
  }
76
- return n;
61
+ return o;
77
62
  }
78
- function O(e) {
63
+ function h(e) {
79
64
  if (e.length === 0) return;
80
- let o;
65
+ let n;
81
66
  console.log(1111, e);
82
- for (const n of e.toReversed()) {
83
- console.log(2222, n);
67
+ for (const o of e.toReversed()) {
68
+ console.log(2222, o);
84
69
  let r;
85
- if (n.body !== void 0)
86
- r = new l(n.message, n.locator, n.body, { cause: o });
87
- else if (n.locator === "")
88
- r = new Error(n.message, { cause: o }), r.name = n.name;
70
+ if (o.body !== void 0)
71
+ r = new l(o.message, o.locator, o.body, { cause: n });
72
+ else if (o.locator === "")
73
+ r = new Error(o.message, { cause: n }), r.name = o.name;
89
74
  else
90
- switch (n.name) {
75
+ switch (o.name) {
91
76
  case "APIError":
92
- r = new f(n.message, n.locator, { cause: o });
77
+ r = new f(o.message, o.locator, { cause: n });
93
78
  break;
94
79
  case "EngineError":
95
- r = new u(n.message, n.locator, { cause: o });
96
- break;
97
- case "ApplicationError":
98
- r = new s(n.message, n.locator, { cause: o });
99
- break;
100
- case "OperationalError":
101
- r = new m(n.message, n.locator, { cause: o });
80
+ r = new d(o.message, o.locator, { cause: n });
102
81
  break;
82
+ // case 'ApplicationError':
83
+ // error = new ApplicationError(serialised.message, serialised.locator, { pendingError });
84
+ // break;
85
+ // case 'OperationalError':
86
+ // error = new OperationalError(serialised.message, serialised.locator, { pendingError });
87
+ // break;
103
88
  // case 'WindowHandledRuntimeError':
104
- // error = new WindowHandledRuntimeError(serialised.message, serialised.locator, { cause });
89
+ // error = new WindowHandledRuntimeError(serialised.message, serialised.locator, { pendingError });
105
90
  // break;
106
91
  // case 'WindowHandledPromiseRejectionError':
107
- // error = new WindowHandledPromiseRejectionError(serialised.message, serialised.locator, { cause });
92
+ // error = new WindowHandledPromiseRejectionError(serialised.message, serialised.locator, { pendingError });
108
93
  // break;
109
94
  default:
110
- r = new c(n.message, n.locator, { cause: o });
95
+ r = new c(o.message, o.locator, { cause: n });
111
96
  break;
112
97
  }
113
- n.stack !== void 0 && (r.stack = n.stack), o = r;
98
+ o.stack !== void 0 && (r.stack = o.stack), n = r;
114
99
  }
115
- return o;
100
+ return console.log(3333, n), n;
116
101
  }
117
102
  function g(e) {
118
- let o;
103
+ let n;
119
104
  try {
120
- o = JSON.stringify(e);
105
+ n = JSON.stringify(e);
121
106
  } catch {
122
- typeof e == "symbol" ? o = e.description ?? "Unknown error" : typeof e == "bigint" ? o = e.toString() : o = "Unknown error";
107
+ typeof e == "symbol" ? n = e.description ?? "Unknown error" : typeof e == "bigint" ? n = e.toString() : n = "Unknown error";
123
108
  }
124
- return o === "" && (o = "Unknown error"), o;
109
+ return n === "" && (n = "Unknown error"), n;
125
110
  }
126
- function E(e) {
111
+ function m(e) {
127
112
  if (!(e == null || e === ""))
128
113
  return e.length > 2048 ? `${e.slice(0, 2048)}... [truncated]` : e;
129
114
  }
130
115
  export {
131
116
  f as APIError,
132
- s as ApplicationError,
133
- u as EngineError,
117
+ d as EngineError,
134
118
  l as FetchError,
135
- m as OperationalError,
136
- y as VueHandledError,
137
- k as WindowHandledPromiseRejectionError,
138
- b as WindowHandledRuntimeError,
139
- p as buildFetchError,
140
- h as concatenateSerialisedErrorMessages,
141
- x as ignoreErrors,
142
- i as normalizeToError,
143
- R as serialiseError,
144
- O as unserialiseError
119
+ y as buildFetchError,
120
+ w as concatenateSerialisedErrorMessages,
121
+ b as ignoreErrors,
122
+ s as normalizeToError,
123
+ k as serialiseError,
124
+ h as unserialiseError
145
125
  };
@@ -38,23 +38,6 @@ declare class FetchError extends ApplicationError {
38
38
  readonly body: string | undefined; /** Sanitized HTTP response body. */
39
39
  constructor(message: string, locator: string, body?: string | null, options?: ErrorOptions);
40
40
  }
41
- /** Represents operational failures not caused by application logic. */
42
- declare class OperationalError extends DataPosError {
43
- }
44
- /** Represents Vue errors that have been explicitly handled.
45
- * Used when capturing Vue error handler output with additional component context.
46
- */
47
- declare class VueHandledError extends ApplicationError {
48
- readonly componentName: string | undefined; /** Vue component name, if available. */
49
- readonly info: string; /** Vue error info string. */
50
- constructor(message: string, locator: string, info: string, componentName?: string, options?: ErrorOptions);
51
- }
52
- /** Represents handled window runtime errors. */
53
- declare class WindowHandledRuntimeError extends ApplicationError {
54
- }
55
- /** Represents handled window promise rejection errors. */
56
- declare class WindowHandledPromiseRejectionError extends ApplicationError {
57
- }
58
41
  /** Builds a {@link FetchError} from an HTTP response.
59
42
  * The response body is eagerly read so it can be included in error logs even after the response stream is closed.
60
43
  */
@@ -84,5 +67,5 @@ declare function serialiseError(error?: unknown): SerialisedError[];
84
67
  */
85
68
  declare function unserialiseError(serialisedErrors: SerialisedError[]): Error | undefined;
86
69
  export type { SerialisedError };
87
- export { ApplicationError, APIError, EngineError, FetchError, OperationalError, VueHandledError, WindowHandledRuntimeError, WindowHandledPromiseRejectionError };
70
+ export { APIError, EngineError, FetchError };
88
71
  export { buildFetchError, concatenateSerialisedErrorMessages, ignoreErrors, normalizeToError, serialiseError, unserialiseError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datapos/datapos-shared",
3
- "version": "0.3.544",
3
+ "version": "0.3.546",
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>",