@open-kingdom/shared-frontend-feature-error-autologger 0.0.2-2
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.
- package/README.md +7 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +253 -0
- package/dist/lib/components/error-boundary.component.d.ts +25 -0
- package/dist/lib/components/error-boundary.component.d.ts.map +1 -0
- package/dist/lib/components/index.d.ts +2 -0
- package/dist/lib/components/index.d.ts.map +1 -0
- package/dist/lib/error-autologger.adapter.d.ts +9 -0
- package/dist/lib/error-autologger.adapter.d.ts.map +1 -0
- package/dist/lib/error-autologger.d.ts +13 -0
- package/dist/lib/error-autologger.d.ts.map +1 -0
- package/dist/lib/error-autologger.types.d.ts +43 -0
- package/dist/lib/error-autologger.types.d.ts.map +1 -0
- package/dist/lib/hooks/index.d.ts +3 -0
- package/dist/lib/hooks/index.d.ts.map +1 -0
- package/dist/lib/hooks/use-error-reporter.hook.d.ts +4 -0
- package/dist/lib/hooks/use-error-reporter.hook.d.ts.map +1 -0
- package/dist/lib/hooks/use-global-error-listener.hook.d.ts +3 -0
- package/dist/lib/hooks/use-global-error-listener.hook.d.ts.map +1 -0
- package/dist/lib/listeners/global-error.listener.d.ts +10 -0
- package/dist/lib/listeners/global-error.listener.d.ts.map +1 -0
- package/dist/lib/listeners/index.d.ts +2 -0
- package/dist/lib/listeners/index.d.ts.map +1 -0
- package/dist/lib/middlewares/index.d.ts +2 -0
- package/dist/lib/middlewares/index.d.ts.map +1 -0
- package/dist/lib/middlewares/rtk-error.middleware.d.ts +5 -0
- package/dist/lib/middlewares/rtk-error.middleware.d.ts.map +1 -0
- package/package.json +32 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './lib/components';
|
|
2
|
+
export * from './lib/hooks';
|
|
3
|
+
export * from './lib/listeners';
|
|
4
|
+
export * from './lib/middlewares';
|
|
5
|
+
export * from './lib/error-autologger.types';
|
|
6
|
+
export * from './lib/error-autologger.adapter';
|
|
7
|
+
export * from './lib/error-autologger';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { Component as m, useMemo as y, useCallback as E, useEffect as w } from "react";
|
|
2
|
+
class M {
|
|
3
|
+
adapt(e, r) {
|
|
4
|
+
return e instanceof Error ? {
|
|
5
|
+
message: e.message,
|
|
6
|
+
originalError: e,
|
|
7
|
+
stack: e.stack,
|
|
8
|
+
context: r
|
|
9
|
+
} : typeof e == "string" ? {
|
|
10
|
+
message: e,
|
|
11
|
+
originalError: e,
|
|
12
|
+
context: r
|
|
13
|
+
} : this.isObject(e) ? this.adaptObject(e, r) : {
|
|
14
|
+
message: "An unexpected error occurred",
|
|
15
|
+
originalError: e,
|
|
16
|
+
context: r
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
isObject(e) {
|
|
20
|
+
return e !== null && typeof e == "object";
|
|
21
|
+
}
|
|
22
|
+
adaptObject(e, r) {
|
|
23
|
+
if ("status" in e)
|
|
24
|
+
return {
|
|
25
|
+
message: this.extractStatusErrorMessage(e),
|
|
26
|
+
originalError: e,
|
|
27
|
+
context: { ...r, status: e.status }
|
|
28
|
+
};
|
|
29
|
+
if ("name" in e || "code" in e) {
|
|
30
|
+
const t = e;
|
|
31
|
+
return {
|
|
32
|
+
message: t.message || t.name || "An error occurred",
|
|
33
|
+
originalError: e,
|
|
34
|
+
stack: t.stack,
|
|
35
|
+
context: { ...r, code: t.code, name: t.name }
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return "message" in e && typeof e.message == "string" ? {
|
|
39
|
+
message: e.message,
|
|
40
|
+
originalError: e,
|
|
41
|
+
context: r
|
|
42
|
+
} : {
|
|
43
|
+
message: "An unexpected error occurred",
|
|
44
|
+
originalError: e,
|
|
45
|
+
context: r
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
messageExtractors = [
|
|
49
|
+
(e) => typeof e.error == "string" ? e.error : null,
|
|
50
|
+
(e) => this.isObject(e.data) && typeof e.data.message == "string" ? e.data.message : null,
|
|
51
|
+
(e) => typeof e.data == "string" ? e.data : null,
|
|
52
|
+
(e) => typeof e.status == "number" ? `Request failed with status ${e.status}` : null
|
|
53
|
+
];
|
|
54
|
+
extractStatusErrorMessage(e) {
|
|
55
|
+
for (const r of this.messageExtractors) {
|
|
56
|
+
const t = r(e);
|
|
57
|
+
if (t)
|
|
58
|
+
return t;
|
|
59
|
+
}
|
|
60
|
+
return "Request failed";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const j = (n) => console.error("[Error]", n), H = (n) => console.warn("[Notification]", n);
|
|
64
|
+
class g {
|
|
65
|
+
logger;
|
|
66
|
+
notificationHandler;
|
|
67
|
+
adapter;
|
|
68
|
+
constructor(e = {}) {
|
|
69
|
+
this.logger = e.logger ?? j, this.notificationHandler = e.notificationHandler ?? H, this.adapter = e.adapter ?? new M();
|
|
70
|
+
}
|
|
71
|
+
report(e, r = {}) {
|
|
72
|
+
const { notify: t = !0, log: o = !0, userMessage: i, context: s } = r, u = this.adapter.adapt(e, s), l = i || u.message;
|
|
73
|
+
if (o) {
|
|
74
|
+
const a = s ? `${u.message} | Context: ${JSON.stringify(s)}` : u.message;
|
|
75
|
+
this.logger(a);
|
|
76
|
+
}
|
|
77
|
+
t && this.notificationHandler(l);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
class A extends m {
|
|
81
|
+
reporter;
|
|
82
|
+
constructor(e) {
|
|
83
|
+
super(e), this.state = { hasError: !1, error: null }, this.reporter = new g({
|
|
84
|
+
logger: e.logger,
|
|
85
|
+
notificationHandler: e.notificationHandler
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
static getDerivedStateFromError(e) {
|
|
89
|
+
return {
|
|
90
|
+
hasError: !0,
|
|
91
|
+
error: e
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
componentDidCatch(e, r) {
|
|
95
|
+
const {
|
|
96
|
+
onError: t,
|
|
97
|
+
userMessage: o = "Something went wrong. Please try again.",
|
|
98
|
+
notify: i = !0,
|
|
99
|
+
log: s = !0
|
|
100
|
+
} = this.props;
|
|
101
|
+
this.reporter.report(e, {
|
|
102
|
+
notify: i,
|
|
103
|
+
log: s,
|
|
104
|
+
userMessage: o,
|
|
105
|
+
context: {
|
|
106
|
+
type: "error-boundary",
|
|
107
|
+
componentStack: r.componentStack
|
|
108
|
+
}
|
|
109
|
+
}), t?.(e, r);
|
|
110
|
+
}
|
|
111
|
+
render() {
|
|
112
|
+
const { hasError: e, error: r } = this.state, { children: t, fallback: o } = this.props;
|
|
113
|
+
return e && r ? typeof o == "function" ? o(r) : o ?? null : t;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function k(n = {}) {
|
|
117
|
+
const { logger: e, notificationHandler: r, adapter: t } = n, o = y(
|
|
118
|
+
() => new g({ logger: e, notificationHandler: r, adapter: t }),
|
|
119
|
+
[e, r, t]
|
|
120
|
+
);
|
|
121
|
+
return E(
|
|
122
|
+
(i, s = {}) => o.report(i, s),
|
|
123
|
+
[o]
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
class b {
|
|
127
|
+
reporter;
|
|
128
|
+
notify;
|
|
129
|
+
log;
|
|
130
|
+
defaultMessage;
|
|
131
|
+
constructor(e = {}) {
|
|
132
|
+
const {
|
|
133
|
+
logger: r,
|
|
134
|
+
notificationHandler: t,
|
|
135
|
+
notify: o = !0,
|
|
136
|
+
log: i = !0,
|
|
137
|
+
defaultMessage: s = "An unexpected error occurred"
|
|
138
|
+
} = e;
|
|
139
|
+
this.reporter = new g({ logger: r, notificationHandler: t }), this.notify = o, this.log = i, this.defaultMessage = s;
|
|
140
|
+
}
|
|
141
|
+
attach() {
|
|
142
|
+
const e = (t) => {
|
|
143
|
+
t.preventDefault(), this.reporter.report(t.error || t.message, {
|
|
144
|
+
notify: this.notify,
|
|
145
|
+
log: this.log,
|
|
146
|
+
userMessage: this.defaultMessage,
|
|
147
|
+
context: {
|
|
148
|
+
type: "uncaught-error",
|
|
149
|
+
filename: t.filename,
|
|
150
|
+
lineno: t.lineno,
|
|
151
|
+
colno: t.colno
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}, r = (t) => {
|
|
155
|
+
t.preventDefault(), this.reporter.report(t.reason, {
|
|
156
|
+
notify: this.notify,
|
|
157
|
+
log: this.log,
|
|
158
|
+
userMessage: this.defaultMessage,
|
|
159
|
+
context: { type: "unhandled-rejection" }
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
return window.addEventListener("error", e), window.addEventListener("unhandledrejection", r), () => {
|
|
163
|
+
window.removeEventListener("error", e), window.removeEventListener("unhandledrejection", r);
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function S(n = {}) {
|
|
168
|
+
w(() => new b(n).attach(), [
|
|
169
|
+
n.logger,
|
|
170
|
+
n.notificationHandler,
|
|
171
|
+
n.notify,
|
|
172
|
+
n.log,
|
|
173
|
+
n.defaultMessage
|
|
174
|
+
]);
|
|
175
|
+
}
|
|
176
|
+
const d = "An error occurred while processing your request";
|
|
177
|
+
function f(n) {
|
|
178
|
+
if (typeof n != "object" || n === null)
|
|
179
|
+
return !1;
|
|
180
|
+
const e = n;
|
|
181
|
+
return typeof e.type == "string" && (e.type.endsWith("/rejected") || e.meta?.rejectedWithValue === !0);
|
|
182
|
+
}
|
|
183
|
+
function p(n) {
|
|
184
|
+
return {
|
|
185
|
+
type: "rtk-query",
|
|
186
|
+
endpoint: n.meta?.arg?.endpointName || "unknown"
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function h(n) {
|
|
190
|
+
return n.payload || n.error;
|
|
191
|
+
}
|
|
192
|
+
function R(n = {}) {
|
|
193
|
+
const {
|
|
194
|
+
logger: e,
|
|
195
|
+
notificationHandler: r,
|
|
196
|
+
notify: t = !0,
|
|
197
|
+
log: o = !0,
|
|
198
|
+
defaultMessage: i = d,
|
|
199
|
+
shouldHandle: s
|
|
200
|
+
} = n, u = new g({ logger: e, notificationHandler: r });
|
|
201
|
+
return () => (l) => (a) => {
|
|
202
|
+
if (f(a)) {
|
|
203
|
+
if (s && !s(a))
|
|
204
|
+
return l(a);
|
|
205
|
+
u.report(h(a), {
|
|
206
|
+
notify: t,
|
|
207
|
+
log: o,
|
|
208
|
+
userMessage: i,
|
|
209
|
+
context: p(a)
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return l(a);
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function L(n) {
|
|
216
|
+
const {
|
|
217
|
+
logAction: e,
|
|
218
|
+
notifyAction: r,
|
|
219
|
+
notify: t = !0,
|
|
220
|
+
log: o = !0,
|
|
221
|
+
defaultMessage: i = d,
|
|
222
|
+
shouldHandle: s
|
|
223
|
+
} = n;
|
|
224
|
+
return ({ dispatch: u }) => {
|
|
225
|
+
const l = new g({
|
|
226
|
+
logger: (a) => u(e({ message: a, level: "error" })),
|
|
227
|
+
notificationHandler: (a) => u(r(a))
|
|
228
|
+
});
|
|
229
|
+
return (a) => (c) => {
|
|
230
|
+
if (f(c)) {
|
|
231
|
+
if (s && !s(c))
|
|
232
|
+
return a(c);
|
|
233
|
+
l.report(h(c), {
|
|
234
|
+
notify: t,
|
|
235
|
+
log: o,
|
|
236
|
+
userMessage: i,
|
|
237
|
+
context: p(c)
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return a(c);
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
export {
|
|
245
|
+
M as ErrorAdapter,
|
|
246
|
+
A as ErrorBoundary,
|
|
247
|
+
g as ErrorReporter,
|
|
248
|
+
b as GlobalErrorListener,
|
|
249
|
+
R as createRTKErrorMiddleware,
|
|
250
|
+
L as createReduxRTKErrorMiddleware,
|
|
251
|
+
k as useErrorReporter,
|
|
252
|
+
S as useGlobalErrorListener
|
|
253
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Component, ReactNode, ErrorInfo } from 'react';
|
|
2
|
+
import { LoggerFn, NotificationHandlerFn } from '../error-autologger.types';
|
|
3
|
+
export interface ErrorBoundaryProps {
|
|
4
|
+
logger?: LoggerFn;
|
|
5
|
+
notificationHandler?: NotificationHandlerFn;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
fallback?: ReactNode | ((error: Error) => ReactNode);
|
|
8
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
9
|
+
userMessage?: string;
|
|
10
|
+
notify?: boolean;
|
|
11
|
+
log?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface ErrorBoundaryState {
|
|
14
|
+
hasError: boolean;
|
|
15
|
+
error: Error | null;
|
|
16
|
+
}
|
|
17
|
+
export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
18
|
+
private reporter;
|
|
19
|
+
constructor(props: ErrorBoundaryProps);
|
|
20
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
21
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
22
|
+
render(): ReactNode;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=error-boundary.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-boundary.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/error-boundary.component.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AAGnC,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,mBAAmB,CAAC,EAAE,qBAAqB,CAAC;IAC5C,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC;IACrD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,UAAU,kBAAkB;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAID,qBAAa,aAAc,SAAQ,SAAS,CAC1C,kBAAkB,EAClB,kBAAkB,CACnB;IACC,OAAO,CAAC,QAAQ,CAAgB;gBAEpB,KAAK,EAAE,kBAAkB;IAUrC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,kBAAkB;IAOxD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;IAqB3D,MAAM,IAAI,SAAS;CAc7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NormalizedError } from './error-autologger.types';
|
|
2
|
+
export declare class ErrorAdapter {
|
|
3
|
+
adapt(error: unknown, context?: Record<string, unknown>): NormalizedError;
|
|
4
|
+
private isObject;
|
|
5
|
+
private adaptObject;
|
|
6
|
+
private messageExtractors;
|
|
7
|
+
private extractStatusErrorMessage;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=error-autologger.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-autologger.adapter.d.ts","sourceRoot":"","sources":["../../src/lib/error-autologger.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE,qBAAa,YAAY;IACvB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe;IA6BzE,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,WAAW;IA8CnB,OAAO,CAAC,iBAAiB,CAavB;IAEF,OAAO,CAAC,yBAAyB;CAWlC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ErrorHandlerConfig, HandleErrorOptions } from './error-autologger.types';
|
|
2
|
+
import { ErrorAdapter } from './error-autologger.adapter';
|
|
3
|
+
export interface ErrorReporterConfig extends ErrorHandlerConfig {
|
|
4
|
+
adapter?: ErrorAdapter;
|
|
5
|
+
}
|
|
6
|
+
export declare class ErrorReporter {
|
|
7
|
+
private logger;
|
|
8
|
+
private notificationHandler;
|
|
9
|
+
private adapter;
|
|
10
|
+
constructor(config?: ErrorReporterConfig);
|
|
11
|
+
report(error: unknown, options?: HandleErrorOptions): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=error-autologger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-autologger.d.ts","sourceRoot":"","sources":["../../src/lib/error-autologger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAQD,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,mBAAmB,CAAwB;IACnD,OAAO,CAAC,OAAO,CAAe;gBAElB,MAAM,GAAE,mBAAwB;IAO5C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,kBAAuB,GAAG,IAAI;CAiB/D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type LoggerFn = (message: string) => void;
|
|
2
|
+
export type NotificationHandlerFn = (message: string) => void;
|
|
3
|
+
export type CleanupFn = () => void;
|
|
4
|
+
export interface NormalizedError {
|
|
5
|
+
message: string;
|
|
6
|
+
originalError: unknown;
|
|
7
|
+
stack?: string;
|
|
8
|
+
context?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface ErrorHandlerConfig {
|
|
11
|
+
logger?: LoggerFn;
|
|
12
|
+
notificationHandler?: NotificationHandlerFn;
|
|
13
|
+
}
|
|
14
|
+
export interface HandleErrorOptions {
|
|
15
|
+
notify?: boolean;
|
|
16
|
+
log?: boolean;
|
|
17
|
+
userMessage?: string;
|
|
18
|
+
context?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface ErrorListenerConfig extends ErrorHandlerConfig {
|
|
21
|
+
notify?: boolean;
|
|
22
|
+
log?: boolean;
|
|
23
|
+
defaultMessage?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface RTKErrorMiddlewareConfig extends ErrorListenerConfig {
|
|
26
|
+
shouldHandle?: (action: unknown) => boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface ReduxRTKErrorMiddlewareConfig {
|
|
29
|
+
logAction: (payload: {
|
|
30
|
+
message: string;
|
|
31
|
+
level: 'error';
|
|
32
|
+
}) => {
|
|
33
|
+
type: string;
|
|
34
|
+
};
|
|
35
|
+
notifyAction: (message: string) => {
|
|
36
|
+
type: string;
|
|
37
|
+
};
|
|
38
|
+
notify?: boolean;
|
|
39
|
+
log?: boolean;
|
|
40
|
+
defaultMessage?: string;
|
|
41
|
+
shouldHandle?: (action: unknown) => boolean;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=error-autologger.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-autologger.types.d.ts","sourceRoot":"","sources":["../../src/lib/error-autologger.types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAGjD,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAG9D,MAAM,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC;AAGnC,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAGD,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,mBAAmB,CAAC,EAAE,qBAAqB,CAAC;CAC7C;AAGD,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAGD,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IACnE,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C;AAGD,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,CAAC,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9E,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HandleErrorOptions } from '../error-autologger.types';
|
|
2
|
+
import { ErrorReporterConfig } from '../error-autologger';
|
|
3
|
+
export declare function useErrorReporter(options?: ErrorReporterConfig): (error: unknown, opts?: HandleErrorOptions) => void;
|
|
4
|
+
//# sourceMappingURL=use-error-reporter.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-error-reporter.hook.d.ts","sourceRoot":"","sources":["../../../src/lib/hooks/use-error-reporter.hook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAiB,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAK9E,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,mBAAwB,WAStD,OAAO,SAAQ,kBAAkB,UAI5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-global-error-listener.hook.d.ts","sourceRoot":"","sources":["../../../src/lib/hooks/use-global-error-listener.hook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAKrE,wBAAgB,sBAAsB,CAAC,MAAM,GAAE,mBAAwB,GAAG,IAAI,CAY7E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CleanupFn, ErrorListenerConfig } from '../error-autologger.types';
|
|
2
|
+
export declare class GlobalErrorListener {
|
|
3
|
+
private reporter;
|
|
4
|
+
private notify;
|
|
5
|
+
private log;
|
|
6
|
+
private defaultMessage;
|
|
7
|
+
constructor(config?: ErrorListenerConfig);
|
|
8
|
+
attach(): CleanupFn;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=global-error.listener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-error.listener.d.ts","sourceRoot":"","sources":["../../../src/lib/listeners/global-error.listener.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAKhF,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,GAAG,CAAU;IACrB,OAAO,CAAC,cAAc,CAAS;gBAEnB,MAAM,GAAE,mBAAwB;IAe5C,MAAM,IAAI,SAAS;CAkCpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/listeners/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/middlewares/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Middleware } from '@reduxjs/toolkit';
|
|
2
|
+
import { RTKErrorMiddlewareConfig, ReduxRTKErrorMiddlewareConfig } from '../error-autologger.types';
|
|
3
|
+
export declare function createRTKErrorMiddleware(config?: RTKErrorMiddlewareConfig): Middleware;
|
|
4
|
+
export declare function createReduxRTKErrorMiddleware(config: ReduxRTKErrorMiddlewareConfig): Middleware;
|
|
5
|
+
//# sourceMappingURL=rtk-error.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rtk-error.middleware.d.ts","sourceRoot":"","sources":["../../../src/lib/middlewares/rtk-error.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EACV,wBAAwB,EACxB,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AAwCnC,wBAAgB,wBAAwB,CACtC,MAAM,GAAE,wBAA6B,GACpC,UAAU,CA4BZ;AAGD,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,6BAA6B,GACpC,UAAU,CAiCZ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@open-kingdom/shared-frontend-feature-error-autologger",
|
|
3
|
+
"version": "0.0.2-2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"development": "./src/index.ts",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"!**/*.tsbuildinfo"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"nx": {
|
|
25
|
+
"name": "@open-kingdom/shared-frontend-feature-error-autologger",
|
|
26
|
+
"tags": [
|
|
27
|
+
"type:feature",
|
|
28
|
+
"scope:shared",
|
|
29
|
+
"environment:frontend"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|