@vinetechke/next-error-logger 0.1.0-beta.1

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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +442 -0
  3. package/dist/adapters/drizzle.cjs +123 -0
  4. package/dist/adapters/drizzle.cjs.map +1 -0
  5. package/dist/adapters/drizzle.d.cts +76 -0
  6. package/dist/adapters/drizzle.d.ts +76 -0
  7. package/dist/adapters/drizzle.js +99 -0
  8. package/dist/adapters/drizzle.js.map +1 -0
  9. package/dist/adapters/prisma.cjs +120 -0
  10. package/dist/adapters/prisma.cjs.map +1 -0
  11. package/dist/adapters/prisma.d.cts +75 -0
  12. package/dist/adapters/prisma.d.ts +75 -0
  13. package/dist/adapters/prisma.js +96 -0
  14. package/dist/adapters/prisma.js.map +1 -0
  15. package/dist/adapters/sql.cjs +206 -0
  16. package/dist/adapters/sql.cjs.map +1 -0
  17. package/dist/adapters/sql.d.cts +111 -0
  18. package/dist/adapters/sql.d.ts +111 -0
  19. package/dist/adapters/sql.js +182 -0
  20. package/dist/adapters/sql.js.map +1 -0
  21. package/dist/api/index.cjs +257 -0
  22. package/dist/api/index.cjs.map +1 -0
  23. package/dist/api/index.d.cts +137 -0
  24. package/dist/api/index.d.ts +137 -0
  25. package/dist/api/index.js +231 -0
  26. package/dist/api/index.js.map +1 -0
  27. package/dist/auth/clerk.cjs +60 -0
  28. package/dist/auth/clerk.cjs.map +1 -0
  29. package/dist/auth/clerk.d.cts +83 -0
  30. package/dist/auth/clerk.d.ts +83 -0
  31. package/dist/auth/clerk.js +36 -0
  32. package/dist/auth/clerk.js.map +1 -0
  33. package/dist/auth/next-auth.cjs +50 -0
  34. package/dist/auth/next-auth.cjs.map +1 -0
  35. package/dist/auth/next-auth.d.cts +53 -0
  36. package/dist/auth/next-auth.d.ts +53 -0
  37. package/dist/auth/next-auth.js +26 -0
  38. package/dist/auth/next-auth.js.map +1 -0
  39. package/dist/components/index.cjs +1175 -0
  40. package/dist/components/index.cjs.map +1 -0
  41. package/dist/components/index.d.cts +141 -0
  42. package/dist/components/index.d.ts +141 -0
  43. package/dist/components/index.js +1147 -0
  44. package/dist/components/index.js.map +1 -0
  45. package/dist/index.cjs +241 -0
  46. package/dist/index.cjs.map +1 -0
  47. package/dist/index.d.cts +109 -0
  48. package/dist/index.d.ts +109 -0
  49. package/dist/index.js +212 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/schemas/drizzle.cjs +100 -0
  52. package/dist/schemas/drizzle.cjs.map +1 -0
  53. package/dist/schemas/drizzle.d.cts +32 -0
  54. package/dist/schemas/drizzle.d.ts +32 -0
  55. package/dist/schemas/drizzle.js +74 -0
  56. package/dist/schemas/drizzle.js.map +1 -0
  57. package/dist/types-C3x_Ry2e.d.cts +195 -0
  58. package/dist/types-C3x_Ry2e.d.ts +195 -0
  59. package/package.json +128 -0
  60. package/schemas/prisma.prisma +23 -0
  61. package/schemas/schema.sql +75 -0
@@ -0,0 +1,1175 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/components/index.ts
22
+ var components_exports = {};
23
+ __export(components_exports, {
24
+ ErrorBoundary: () => ErrorBoundary,
25
+ LogViewer: () => LogViewer,
26
+ withErrorBoundary: () => withErrorBoundary
27
+ });
28
+ module.exports = __toCommonJS(components_exports);
29
+
30
+ // src/components/LogViewer.tsx
31
+ var import_react = require("react");
32
+ var import_jsx_runtime = require("react/jsx-runtime");
33
+ var defaultTheme = {
34
+ errorBg: "rgb(254, 226, 226)",
35
+ errorText: "rgb(153, 27, 27)",
36
+ warnBg: "rgb(254, 249, 195)",
37
+ warnText: "rgb(133, 77, 14)",
38
+ infoBg: "rgb(219, 234, 254)",
39
+ infoText: "rgb(30, 64, 175)",
40
+ debugBg: "rgb(243, 244, 246)",
41
+ debugText: "rgb(55, 65, 81)"
42
+ };
43
+ function LogViewer({
44
+ apiBasePath = "/api/logs",
45
+ className = "",
46
+ pageSize = 50,
47
+ theme: customTheme,
48
+ onLogSelect,
49
+ showDelete = true,
50
+ autoRefresh = 0
51
+ }) {
52
+ const theme = { ...defaultTheme, ...customTheme };
53
+ const [logs, setLogs] = (0, import_react.useState)([]);
54
+ const [total, setTotal] = (0, import_react.useState)(0);
55
+ const [loading, setLoading] = (0, import_react.useState)(true);
56
+ const [page, setPage] = (0, import_react.useState)(1);
57
+ const [filters, setFilters] = (0, import_react.useState)({
58
+ level: "",
59
+ search: "",
60
+ userId: ""
61
+ });
62
+ const [selectedLog, setSelectedLog] = (0, import_react.useState)(null);
63
+ const [deleting, setDeleting] = (0, import_react.useState)(false);
64
+ const fetchLogs = (0, import_react.useCallback)(async () => {
65
+ setLoading(true);
66
+ try {
67
+ const params = new URLSearchParams({
68
+ page: page.toString(),
69
+ limit: pageSize.toString(),
70
+ ...filters.level && { level: filters.level },
71
+ ...filters.search && { search: filters.search },
72
+ ...filters.userId && { userId: filters.userId }
73
+ });
74
+ const res = await fetch(`${apiBasePath}?${params}`);
75
+ if (!res.ok) throw new Error("Failed to fetch logs");
76
+ const data = await res.json();
77
+ setLogs(data.logs);
78
+ setTotal(data.total);
79
+ } catch (error) {
80
+ console.error("Failed to fetch logs:", error);
81
+ } finally {
82
+ setLoading(false);
83
+ }
84
+ }, [apiBasePath, page, pageSize, filters]);
85
+ (0, import_react.useEffect)(() => {
86
+ fetchLogs();
87
+ }, [fetchLogs]);
88
+ (0, import_react.useEffect)(() => {
89
+ if (autoRefresh <= 0) return;
90
+ const interval = setInterval(fetchLogs, autoRefresh * 1e3);
91
+ return () => clearInterval(interval);
92
+ }, [autoRefresh, fetchLogs]);
93
+ const handleDelete = async (id) => {
94
+ if (!confirm("Are you sure you want to delete this log?")) return;
95
+ setDeleting(true);
96
+ try {
97
+ const res = await fetch(`${apiBasePath}/${id}`, {
98
+ method: "DELETE"
99
+ });
100
+ if (!res.ok) throw new Error("Failed to delete log");
101
+ setLogs((prev) => prev.filter((log) => log.id !== id));
102
+ setTotal((prev) => prev - 1);
103
+ if (selectedLog?.id === id) setSelectedLog(null);
104
+ } catch (error) {
105
+ console.error("Failed to delete log:", error);
106
+ alert("Failed to delete log");
107
+ } finally {
108
+ setDeleting(false);
109
+ }
110
+ };
111
+ const handleClearAll = async () => {
112
+ const confirmed = confirm(
113
+ "Are you sure you want to delete ALL logs? This cannot be undone."
114
+ );
115
+ if (!confirmed) return;
116
+ setDeleting(true);
117
+ try {
118
+ const res = await fetch(apiBasePath, {
119
+ method: "DELETE",
120
+ headers: { "Content-Type": "application/json" },
121
+ body: JSON.stringify({})
122
+ });
123
+ if (!res.ok) throw new Error("Failed to clear logs");
124
+ setLogs([]);
125
+ setTotal(0);
126
+ setSelectedLog(null);
127
+ } catch (error) {
128
+ console.error("Failed to clear logs:", error);
129
+ alert("Failed to clear logs");
130
+ } finally {
131
+ setDeleting(false);
132
+ }
133
+ };
134
+ const getLevelStyle = (level) => {
135
+ switch (level) {
136
+ case "error":
137
+ return {
138
+ backgroundColor: theme.errorBg,
139
+ color: theme.errorText
140
+ };
141
+ case "warn":
142
+ return { backgroundColor: theme.warnBg, color: theme.warnText };
143
+ case "info":
144
+ return { backgroundColor: theme.infoBg, color: theme.infoText };
145
+ case "debug":
146
+ return {
147
+ backgroundColor: theme.debugBg,
148
+ color: theme.debugText
149
+ };
150
+ }
151
+ };
152
+ const totalPages = Math.ceil(total / pageSize);
153
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
154
+ "div",
155
+ {
156
+ className,
157
+ style: { fontFamily: "system-ui, sans-serif" },
158
+ children: [
159
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
160
+ "div",
161
+ {
162
+ style: {
163
+ display: "flex",
164
+ gap: "1rem",
165
+ marginBottom: "1rem",
166
+ flexWrap: "wrap",
167
+ alignItems: "center"
168
+ },
169
+ children: [
170
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
171
+ "select",
172
+ {
173
+ value: filters.level,
174
+ onChange: (e) => {
175
+ setFilters({
176
+ ...filters,
177
+ level: e.target.value
178
+ });
179
+ setPage(1);
180
+ },
181
+ style: {
182
+ padding: "0.5rem 1rem",
183
+ borderRadius: "0.375rem",
184
+ border: "1px solid #d1d5db",
185
+ fontSize: "0.875rem"
186
+ },
187
+ children: [
188
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: "All Levels" }),
189
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "error", children: "Error" }),
190
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "warn", children: "Warning" }),
191
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "info", children: "Info" }),
192
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "debug", children: "Debug" })
193
+ ]
194
+ }
195
+ ),
196
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
197
+ "input",
198
+ {
199
+ type: "text",
200
+ placeholder: "Search logs...",
201
+ value: filters.search,
202
+ onChange: (e) => {
203
+ setFilters({ ...filters, search: e.target.value });
204
+ setPage(1);
205
+ },
206
+ style: {
207
+ padding: "0.5rem 1rem",
208
+ borderRadius: "0.375rem",
209
+ border: "1px solid #d1d5db",
210
+ flex: 1,
211
+ minWidth: "200px",
212
+ fontSize: "0.875rem"
213
+ }
214
+ }
215
+ ),
216
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
217
+ "input",
218
+ {
219
+ type: "text",
220
+ placeholder: "User ID...",
221
+ value: filters.userId,
222
+ onChange: (e) => {
223
+ setFilters({ ...filters, userId: e.target.value });
224
+ setPage(1);
225
+ },
226
+ style: {
227
+ padding: "0.5rem 1rem",
228
+ borderRadius: "0.375rem",
229
+ border: "1px solid #d1d5db",
230
+ width: "150px",
231
+ fontSize: "0.875rem"
232
+ }
233
+ }
234
+ ),
235
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
+ "button",
237
+ {
238
+ onClick: fetchLogs,
239
+ disabled: loading,
240
+ style: {
241
+ padding: "0.5rem 1rem",
242
+ borderRadius: "0.375rem",
243
+ backgroundColor: "#3b82f6",
244
+ color: "white",
245
+ border: "none",
246
+ cursor: loading ? "not-allowed" : "pointer",
247
+ opacity: loading ? 0.7 : 1,
248
+ fontSize: "0.875rem"
249
+ },
250
+ children: loading ? "Loading..." : "Refresh"
251
+ }
252
+ ),
253
+ showDelete && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
254
+ "button",
255
+ {
256
+ onClick: handleClearAll,
257
+ disabled: deleting || total === 0,
258
+ style: {
259
+ padding: "0.5rem 1rem",
260
+ borderRadius: "0.375rem",
261
+ backgroundColor: "#ef4444",
262
+ color: "white",
263
+ border: "none",
264
+ cursor: deleting || total === 0 ? "not-allowed" : "pointer",
265
+ opacity: deleting || total === 0 ? 0.7 : 1,
266
+ fontSize: "0.875rem"
267
+ },
268
+ children: "Clear All"
269
+ }
270
+ )
271
+ ]
272
+ }
273
+ ),
274
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
275
+ "div",
276
+ {
277
+ style: {
278
+ marginBottom: "1rem",
279
+ fontSize: "0.875rem",
280
+ color: "#6b7280"
281
+ },
282
+ children: [
283
+ "Showing ",
284
+ logs.length,
285
+ " of ",
286
+ total,
287
+ " logs",
288
+ autoRefresh > 0 && ` \u2022 Auto-refreshing every ${autoRefresh}s`
289
+ ]
290
+ }
291
+ ),
292
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
293
+ "div",
294
+ {
295
+ style: {
296
+ border: "1px solid #e5e7eb",
297
+ borderRadius: "0.5rem",
298
+ overflow: "hidden"
299
+ },
300
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { style: { width: "100%", borderCollapse: "collapse" }, children: [
301
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { style: { backgroundColor: "#f9fafb" }, children: [
302
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
303
+ "th",
304
+ {
305
+ style: {
306
+ padding: "0.75rem 1rem",
307
+ textAlign: "left",
308
+ fontSize: "0.875rem",
309
+ fontWeight: 500,
310
+ borderBottom: "1px solid #e5e7eb"
311
+ },
312
+ children: "Level"
313
+ }
314
+ ),
315
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
316
+ "th",
317
+ {
318
+ style: {
319
+ padding: "0.75rem 1rem",
320
+ textAlign: "left",
321
+ fontSize: "0.875rem",
322
+ fontWeight: 500,
323
+ borderBottom: "1px solid #e5e7eb"
324
+ },
325
+ children: "Message"
326
+ }
327
+ ),
328
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
329
+ "th",
330
+ {
331
+ style: {
332
+ padding: "0.75rem 1rem",
333
+ textAlign: "left",
334
+ fontSize: "0.875rem",
335
+ fontWeight: 500,
336
+ borderBottom: "1px solid #e5e7eb"
337
+ },
338
+ children: "User"
339
+ }
340
+ ),
341
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
342
+ "th",
343
+ {
344
+ style: {
345
+ padding: "0.75rem 1rem",
346
+ textAlign: "left",
347
+ fontSize: "0.875rem",
348
+ fontWeight: 500,
349
+ borderBottom: "1px solid #e5e7eb"
350
+ },
351
+ children: "Path"
352
+ }
353
+ ),
354
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
355
+ "th",
356
+ {
357
+ style: {
358
+ padding: "0.75rem 1rem",
359
+ textAlign: "left",
360
+ fontSize: "0.875rem",
361
+ fontWeight: 500,
362
+ borderBottom: "1px solid #e5e7eb"
363
+ },
364
+ children: "Time"
365
+ }
366
+ ),
367
+ showDelete && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
368
+ "th",
369
+ {
370
+ style: {
371
+ padding: "0.75rem 1rem",
372
+ textAlign: "center",
373
+ fontSize: "0.875rem",
374
+ fontWeight: 500,
375
+ borderBottom: "1px solid #e5e7eb",
376
+ width: "80px"
377
+ },
378
+ children: "Actions"
379
+ }
380
+ )
381
+ ] }) }),
382
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: loading && logs.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
383
+ "td",
384
+ {
385
+ colSpan: showDelete ? 6 : 5,
386
+ style: {
387
+ padding: "2rem",
388
+ textAlign: "center",
389
+ color: "#6b7280"
390
+ },
391
+ children: "Loading..."
392
+ }
393
+ ) }) : logs.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
394
+ "td",
395
+ {
396
+ colSpan: showDelete ? 6 : 5,
397
+ style: {
398
+ padding: "2rem",
399
+ textAlign: "center",
400
+ color: "#6b7280"
401
+ },
402
+ children: "No logs found"
403
+ }
404
+ ) }) : logs.map((log) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
405
+ "tr",
406
+ {
407
+ onClick: () => {
408
+ setSelectedLog(log);
409
+ onLogSelect?.(log);
410
+ },
411
+ style: {
412
+ cursor: "pointer",
413
+ backgroundColor: selectedLog?.id === log.id ? "#f3f4f6" : "white"
414
+ },
415
+ onMouseEnter: (e) => {
416
+ if (selectedLog?.id !== log.id) {
417
+ e.currentTarget.style.backgroundColor = "#f9fafb";
418
+ }
419
+ },
420
+ onMouseLeave: (e) => {
421
+ if (selectedLog?.id !== log.id) {
422
+ e.currentTarget.style.backgroundColor = "white";
423
+ }
424
+ },
425
+ children: [
426
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
427
+ "td",
428
+ {
429
+ style: {
430
+ padding: "0.75rem 1rem",
431
+ borderBottom: "1px solid #e5e7eb"
432
+ },
433
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
434
+ "span",
435
+ {
436
+ style: {
437
+ ...getLevelStyle(log.level),
438
+ padding: "0.25rem 0.5rem",
439
+ borderRadius: "0.25rem",
440
+ fontSize: "0.75rem",
441
+ fontWeight: 500,
442
+ textTransform: "uppercase"
443
+ },
444
+ children: log.level
445
+ }
446
+ )
447
+ }
448
+ ),
449
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
450
+ "td",
451
+ {
452
+ style: {
453
+ padding: "0.75rem 1rem",
454
+ borderBottom: "1px solid #e5e7eb",
455
+ fontSize: "0.875rem",
456
+ maxWidth: "300px",
457
+ overflow: "hidden",
458
+ textOverflow: "ellipsis",
459
+ whiteSpace: "nowrap"
460
+ },
461
+ children: log.message
462
+ }
463
+ ),
464
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
465
+ "td",
466
+ {
467
+ style: {
468
+ padding: "0.75rem 1rem",
469
+ borderBottom: "1px solid #e5e7eb",
470
+ fontSize: "0.875rem",
471
+ color: "#6b7280"
472
+ },
473
+ children: log.userEmail || log.userName || log.userId || "-"
474
+ }
475
+ ),
476
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
477
+ "td",
478
+ {
479
+ style: {
480
+ padding: "0.75rem 1rem",
481
+ borderBottom: "1px solid #e5e7eb",
482
+ fontSize: "0.875rem",
483
+ color: "#6b7280"
484
+ },
485
+ children: log.path || "-"
486
+ }
487
+ ),
488
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
489
+ "td",
490
+ {
491
+ style: {
492
+ padding: "0.75rem 1rem",
493
+ borderBottom: "1px solid #e5e7eb",
494
+ fontSize: "0.875rem",
495
+ color: "#6b7280",
496
+ whiteSpace: "nowrap"
497
+ },
498
+ children: new Date(
499
+ log.createdAt
500
+ ).toLocaleString()
501
+ }
502
+ ),
503
+ showDelete && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
504
+ "td",
505
+ {
506
+ style: {
507
+ padding: "0.75rem 1rem",
508
+ borderBottom: "1px solid #e5e7eb",
509
+ textAlign: "center"
510
+ },
511
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
512
+ "button",
513
+ {
514
+ onClick: (e) => {
515
+ e.stopPropagation();
516
+ handleDelete(log.id);
517
+ },
518
+ disabled: deleting,
519
+ style: {
520
+ padding: "0.25rem 0.5rem",
521
+ borderRadius: "0.25rem",
522
+ backgroundColor: "transparent",
523
+ color: "#ef4444",
524
+ border: "1px solid #ef4444",
525
+ cursor: deleting ? "not-allowed" : "pointer",
526
+ fontSize: "0.75rem"
527
+ },
528
+ children: "Delete"
529
+ }
530
+ )
531
+ }
532
+ )
533
+ ]
534
+ },
535
+ log.id
536
+ )) })
537
+ ] })
538
+ }
539
+ ),
540
+ totalPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
541
+ "div",
542
+ {
543
+ style: {
544
+ display: "flex",
545
+ justifyContent: "space-between",
546
+ alignItems: "center",
547
+ marginTop: "1rem"
548
+ },
549
+ children: [
550
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: { fontSize: "0.875rem", color: "#6b7280" }, children: [
551
+ "Page ",
552
+ page,
553
+ " of ",
554
+ totalPages
555
+ ] }),
556
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", gap: "0.5rem" }, children: [
557
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
558
+ "button",
559
+ {
560
+ onClick: () => setPage(1),
561
+ disabled: page === 1,
562
+ style: {
563
+ padding: "0.5rem 0.75rem",
564
+ borderRadius: "0.375rem",
565
+ border: "1px solid #d1d5db",
566
+ backgroundColor: "white",
567
+ cursor: page === 1 ? "not-allowed" : "pointer",
568
+ opacity: page === 1 ? 0.5 : 1,
569
+ fontSize: "0.875rem"
570
+ },
571
+ children: "First"
572
+ }
573
+ ),
574
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
575
+ "button",
576
+ {
577
+ onClick: () => setPage(Math.max(1, page - 1)),
578
+ disabled: page === 1,
579
+ style: {
580
+ padding: "0.5rem 0.75rem",
581
+ borderRadius: "0.375rem",
582
+ border: "1px solid #d1d5db",
583
+ backgroundColor: "white",
584
+ cursor: page === 1 ? "not-allowed" : "pointer",
585
+ opacity: page === 1 ? 0.5 : 1,
586
+ fontSize: "0.875rem"
587
+ },
588
+ children: "Previous"
589
+ }
590
+ ),
591
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
592
+ "button",
593
+ {
594
+ onClick: () => setPage(Math.min(totalPages, page + 1)),
595
+ disabled: page === totalPages,
596
+ style: {
597
+ padding: "0.5rem 0.75rem",
598
+ borderRadius: "0.375rem",
599
+ border: "1px solid #d1d5db",
600
+ backgroundColor: "white",
601
+ cursor: page === totalPages ? "not-allowed" : "pointer",
602
+ opacity: page === totalPages ? 0.5 : 1,
603
+ fontSize: "0.875rem"
604
+ },
605
+ children: "Next"
606
+ }
607
+ ),
608
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
609
+ "button",
610
+ {
611
+ onClick: () => setPage(totalPages),
612
+ disabled: page === totalPages,
613
+ style: {
614
+ padding: "0.5rem 0.75rem",
615
+ borderRadius: "0.375rem",
616
+ border: "1px solid #d1d5db",
617
+ backgroundColor: "white",
618
+ cursor: page === totalPages ? "not-allowed" : "pointer",
619
+ opacity: page === totalPages ? 0.5 : 1,
620
+ fontSize: "0.875rem"
621
+ },
622
+ children: "Last"
623
+ }
624
+ )
625
+ ] })
626
+ ]
627
+ }
628
+ ),
629
+ selectedLog && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
630
+ "div",
631
+ {
632
+ style: {
633
+ position: "fixed",
634
+ inset: 0,
635
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
636
+ display: "flex",
637
+ alignItems: "center",
638
+ justifyContent: "center",
639
+ padding: "1rem",
640
+ zIndex: 50
641
+ },
642
+ onClick: () => setSelectedLog(null),
643
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
644
+ "div",
645
+ {
646
+ style: {
647
+ backgroundColor: "white",
648
+ borderRadius: "0.5rem",
649
+ maxWidth: "48rem",
650
+ width: "100%",
651
+ maxHeight: "80vh",
652
+ overflow: "auto",
653
+ padding: "1.5rem"
654
+ },
655
+ onClick: (e) => e.stopPropagation(),
656
+ children: [
657
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
658
+ "div",
659
+ {
660
+ style: {
661
+ display: "flex",
662
+ justifyContent: "space-between",
663
+ alignItems: "flex-start",
664
+ marginBottom: "1rem"
665
+ },
666
+ children: [
667
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
668
+ "h2",
669
+ {
670
+ style: {
671
+ fontSize: "1.125rem",
672
+ fontWeight: 600,
673
+ margin: 0
674
+ },
675
+ children: "Log Details"
676
+ }
677
+ ),
678
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
679
+ "button",
680
+ {
681
+ onClick: () => setSelectedLog(null),
682
+ style: {
683
+ background: "none",
684
+ border: "none",
685
+ fontSize: "1.5rem",
686
+ cursor: "pointer",
687
+ color: "#6b7280",
688
+ lineHeight: 1
689
+ },
690
+ children: "\xD7"
691
+ }
692
+ )
693
+ ]
694
+ }
695
+ ),
696
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dl", { style: { display: "grid", gap: "1rem" }, children: [
697
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
698
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
699
+ "dt",
700
+ {
701
+ style: {
702
+ fontSize: "0.875rem",
703
+ fontWeight: 500,
704
+ color: "#6b7280",
705
+ marginBottom: "0.25rem"
706
+ },
707
+ children: "Level"
708
+ }
709
+ ),
710
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { style: { margin: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
711
+ "span",
712
+ {
713
+ style: {
714
+ ...getLevelStyle(selectedLog.level),
715
+ padding: "0.25rem 0.5rem",
716
+ borderRadius: "0.25rem",
717
+ fontSize: "0.75rem",
718
+ fontWeight: 500,
719
+ textTransform: "uppercase"
720
+ },
721
+ children: selectedLog.level
722
+ }
723
+ ) })
724
+ ] }),
725
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
726
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
727
+ "dt",
728
+ {
729
+ style: {
730
+ fontSize: "0.875rem",
731
+ fontWeight: 500,
732
+ color: "#6b7280",
733
+ marginBottom: "0.25rem"
734
+ },
735
+ children: "Message"
736
+ }
737
+ ),
738
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { style: { margin: 0, fontSize: "0.875rem" }, children: selectedLog.message })
739
+ ] }),
740
+ selectedLog.stack && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
741
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
742
+ "dt",
743
+ {
744
+ style: {
745
+ fontSize: "0.875rem",
746
+ fontWeight: 500,
747
+ color: "#6b7280",
748
+ marginBottom: "0.25rem"
749
+ },
750
+ children: "Stack Trace"
751
+ }
752
+ ),
753
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { style: { margin: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
754
+ "pre",
755
+ {
756
+ style: {
757
+ fontSize: "0.75rem",
758
+ fontFamily: "monospace",
759
+ backgroundColor: "#f3f4f6",
760
+ padding: "0.75rem",
761
+ borderRadius: "0.375rem",
762
+ overflow: "auto",
763
+ maxHeight: "200px",
764
+ margin: 0,
765
+ whiteSpace: "pre-wrap",
766
+ wordBreak: "break-all"
767
+ },
768
+ children: selectedLog.stack
769
+ }
770
+ ) })
771
+ ] }),
772
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
773
+ "div",
774
+ {
775
+ style: {
776
+ display: "grid",
777
+ gridTemplateColumns: "repeat(2, 1fr)",
778
+ gap: "1rem"
779
+ },
780
+ children: [
781
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
782
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
783
+ "dt",
784
+ {
785
+ style: {
786
+ fontSize: "0.875rem",
787
+ fontWeight: 500,
788
+ color: "#6b7280",
789
+ marginBottom: "0.25rem"
790
+ },
791
+ children: "User"
792
+ }
793
+ ),
794
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
795
+ "dd",
796
+ {
797
+ style: {
798
+ margin: 0,
799
+ fontSize: "0.875rem"
800
+ },
801
+ children: selectedLog.userEmail || selectedLog.userName || selectedLog.userId || "-"
802
+ }
803
+ )
804
+ ] }),
805
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
806
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
807
+ "dt",
808
+ {
809
+ style: {
810
+ fontSize: "0.875rem",
811
+ fontWeight: 500,
812
+ color: "#6b7280",
813
+ marginBottom: "0.25rem"
814
+ },
815
+ children: "User ID"
816
+ }
817
+ ),
818
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
819
+ "dd",
820
+ {
821
+ style: {
822
+ margin: 0,
823
+ fontSize: "0.875rem"
824
+ },
825
+ children: selectedLog.userId || "-"
826
+ }
827
+ )
828
+ ] }),
829
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
830
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
831
+ "dt",
832
+ {
833
+ style: {
834
+ fontSize: "0.875rem",
835
+ fontWeight: 500,
836
+ color: "#6b7280",
837
+ marginBottom: "0.25rem"
838
+ },
839
+ children: "Path"
840
+ }
841
+ ),
842
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
843
+ "dd",
844
+ {
845
+ style: {
846
+ margin: 0,
847
+ fontSize: "0.875rem"
848
+ },
849
+ children: selectedLog.path || "-"
850
+ }
851
+ )
852
+ ] }),
853
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
854
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
855
+ "dt",
856
+ {
857
+ style: {
858
+ fontSize: "0.875rem",
859
+ fontWeight: 500,
860
+ color: "#6b7280",
861
+ marginBottom: "0.25rem"
862
+ },
863
+ children: "Method"
864
+ }
865
+ ),
866
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
867
+ "dd",
868
+ {
869
+ style: {
870
+ margin: 0,
871
+ fontSize: "0.875rem"
872
+ },
873
+ children: selectedLog.method || "-"
874
+ }
875
+ )
876
+ ] }),
877
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
878
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
879
+ "dt",
880
+ {
881
+ style: {
882
+ fontSize: "0.875rem",
883
+ fontWeight: 500,
884
+ color: "#6b7280",
885
+ marginBottom: "0.25rem"
886
+ },
887
+ children: "IP Address"
888
+ }
889
+ ),
890
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
891
+ "dd",
892
+ {
893
+ style: {
894
+ margin: 0,
895
+ fontSize: "0.875rem"
896
+ },
897
+ children: selectedLog.ip || "-"
898
+ }
899
+ )
900
+ ] }),
901
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
902
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
903
+ "dt",
904
+ {
905
+ style: {
906
+ fontSize: "0.875rem",
907
+ fontWeight: 500,
908
+ color: "#6b7280",
909
+ marginBottom: "0.25rem"
910
+ },
911
+ children: "Time"
912
+ }
913
+ ),
914
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
915
+ "dd",
916
+ {
917
+ style: {
918
+ margin: 0,
919
+ fontSize: "0.875rem"
920
+ },
921
+ children: new Date(
922
+ selectedLog.createdAt
923
+ ).toLocaleString()
924
+ }
925
+ )
926
+ ] })
927
+ ]
928
+ }
929
+ ),
930
+ selectedLog.userAgent && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
931
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
932
+ "dt",
933
+ {
934
+ style: {
935
+ fontSize: "0.875rem",
936
+ fontWeight: 500,
937
+ color: "#6b7280",
938
+ marginBottom: "0.25rem"
939
+ },
940
+ children: "User Agent"
941
+ }
942
+ ),
943
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
944
+ "dd",
945
+ {
946
+ style: {
947
+ margin: 0,
948
+ fontSize: "0.75rem",
949
+ color: "#6b7280",
950
+ wordBreak: "break-all"
951
+ },
952
+ children: selectedLog.userAgent
953
+ }
954
+ )
955
+ ] }),
956
+ selectedLog.metadata && Object.keys(selectedLog.metadata).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
957
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
958
+ "dt",
959
+ {
960
+ style: {
961
+ fontSize: "0.875rem",
962
+ fontWeight: 500,
963
+ color: "#6b7280",
964
+ marginBottom: "0.25rem"
965
+ },
966
+ children: "Metadata"
967
+ }
968
+ ),
969
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("dd", { style: { margin: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
970
+ "pre",
971
+ {
972
+ style: {
973
+ fontSize: "0.75rem",
974
+ fontFamily: "monospace",
975
+ backgroundColor: "#f3f4f6",
976
+ padding: "0.75rem",
977
+ borderRadius: "0.375rem",
978
+ overflow: "auto",
979
+ maxHeight: "150px",
980
+ margin: 0
981
+ },
982
+ children: JSON.stringify(
983
+ selectedLog.metadata,
984
+ null,
985
+ 2
986
+ )
987
+ }
988
+ ) })
989
+ ] })
990
+ ] }),
991
+ showDelete && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
992
+ "div",
993
+ {
994
+ style: {
995
+ marginTop: "1.5rem",
996
+ textAlign: "right"
997
+ },
998
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
999
+ "button",
1000
+ {
1001
+ onClick: () => {
1002
+ handleDelete(selectedLog.id);
1003
+ },
1004
+ disabled: deleting,
1005
+ style: {
1006
+ padding: "0.5rem 1rem",
1007
+ borderRadius: "0.375rem",
1008
+ backgroundColor: "#ef4444",
1009
+ color: "white",
1010
+ border: "none",
1011
+ cursor: deleting ? "not-allowed" : "pointer",
1012
+ opacity: deleting ? 0.7 : 1,
1013
+ fontSize: "0.875rem"
1014
+ },
1015
+ children: "Delete This Log"
1016
+ }
1017
+ )
1018
+ }
1019
+ )
1020
+ ]
1021
+ }
1022
+ )
1023
+ }
1024
+ )
1025
+ ]
1026
+ }
1027
+ );
1028
+ }
1029
+
1030
+ // src/components/ErrorBoundary.tsx
1031
+ var import_react2 = require("react");
1032
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1033
+ var ErrorBoundary = class extends import_react2.Component {
1034
+ constructor(props) {
1035
+ super(props);
1036
+ this.reset = () => {
1037
+ this.setState({ hasError: false, error: null });
1038
+ };
1039
+ this.state = { hasError: false, error: null };
1040
+ }
1041
+ static getDerivedStateFromError(error) {
1042
+ return { hasError: true, error };
1043
+ }
1044
+ componentDidCatch(error, errorInfo) {
1045
+ const {
1046
+ onError,
1047
+ logToConsole = process.env.NODE_ENV === "development"
1048
+ } = this.props;
1049
+ if (logToConsole) {
1050
+ console.error("ErrorBoundary caught an error:", error);
1051
+ console.error("Component stack:", errorInfo.componentStack);
1052
+ }
1053
+ onError?.(error, errorInfo);
1054
+ }
1055
+ render() {
1056
+ const { hasError, error } = this.state;
1057
+ const { children, fallback } = this.props;
1058
+ if (hasError && error) {
1059
+ if (typeof fallback === "function") {
1060
+ return fallback(error, this.reset);
1061
+ }
1062
+ if (fallback) {
1063
+ return fallback;
1064
+ }
1065
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1066
+ "div",
1067
+ {
1068
+ style: {
1069
+ padding: "2rem",
1070
+ textAlign: "center",
1071
+ fontFamily: "system-ui, sans-serif"
1072
+ },
1073
+ children: [
1074
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1075
+ "h2",
1076
+ {
1077
+ style: {
1078
+ fontSize: "1.5rem",
1079
+ fontWeight: 600,
1080
+ color: "#dc2626",
1081
+ marginBottom: "1rem"
1082
+ },
1083
+ children: "Something went wrong"
1084
+ }
1085
+ ),
1086
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1087
+ "p",
1088
+ {
1089
+ style: {
1090
+ color: "#6b7280",
1091
+ marginBottom: "1rem"
1092
+ },
1093
+ children: "An unexpected error occurred. Please try again."
1094
+ }
1095
+ ),
1096
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1097
+ "details",
1098
+ {
1099
+ style: {
1100
+ marginBottom: "1rem",
1101
+ textAlign: "left",
1102
+ maxWidth: "600px",
1103
+ margin: "0 auto 1rem"
1104
+ },
1105
+ children: [
1106
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1107
+ "summary",
1108
+ {
1109
+ style: {
1110
+ cursor: "pointer",
1111
+ color: "#3b82f6",
1112
+ marginBottom: "0.5rem"
1113
+ },
1114
+ children: "Error details"
1115
+ }
1116
+ ),
1117
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1118
+ "pre",
1119
+ {
1120
+ style: {
1121
+ fontSize: "0.75rem",
1122
+ fontFamily: "monospace",
1123
+ backgroundColor: "#f3f4f6",
1124
+ padding: "1rem",
1125
+ borderRadius: "0.5rem",
1126
+ overflow: "auto",
1127
+ textAlign: "left",
1128
+ whiteSpace: "pre-wrap",
1129
+ wordBreak: "break-all"
1130
+ },
1131
+ children: [
1132
+ error.message,
1133
+ "\n\n",
1134
+ error.stack
1135
+ ]
1136
+ }
1137
+ )
1138
+ ]
1139
+ }
1140
+ ),
1141
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1142
+ "button",
1143
+ {
1144
+ onClick: this.reset,
1145
+ style: {
1146
+ padding: "0.75rem 1.5rem",
1147
+ backgroundColor: "#3b82f6",
1148
+ color: "white",
1149
+ border: "none",
1150
+ borderRadius: "0.375rem",
1151
+ cursor: "pointer",
1152
+ fontSize: "1rem"
1153
+ },
1154
+ children: "Try again"
1155
+ }
1156
+ )
1157
+ ]
1158
+ }
1159
+ );
1160
+ }
1161
+ return children;
1162
+ }
1163
+ };
1164
+ function withErrorBoundary(Component2, errorBoundaryProps) {
1165
+ const WrappedComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorBoundary, { ...errorBoundaryProps, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component2, { ...props }) });
1166
+ WrappedComponent.displayName = `withErrorBoundary(${Component2.displayName || Component2.name || "Component"})`;
1167
+ return WrappedComponent;
1168
+ }
1169
+ // Annotate the CommonJS export names for ESM import in node:
1170
+ 0 && (module.exports = {
1171
+ ErrorBoundary,
1172
+ LogViewer,
1173
+ withErrorBoundary
1174
+ });
1175
+ //# sourceMappingURL=index.cjs.map