@lensjs/core 2.0.0 → 2.1.0
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 +69 -0
- package/dist/abstracts/store.cjs +13 -0
- package/dist/abstracts/store.d.cts +6 -3
- package/dist/abstracts/store.d.ts +6 -3
- package/dist/abstracts/store.js +13 -0
- package/dist/core/api_controller.cjs +22 -1
- package/dist/core/api_controller.d.cts +4 -2
- package/dist/core/api_controller.d.ts +4 -2
- package/dist/core/api_controller.js +22 -1
- package/dist/core/lens.cjs +52 -4
- package/dist/core/lens.js +52 -4
- package/dist/exception-3AZsPtAg.d.ts +52 -0
- package/dist/exception-C69UCHPk.d.cts +52 -0
- package/dist/index.cjs +206 -29
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +203 -29
- package/dist/stores/better_sqlite.cjs +19 -3
- package/dist/stores/better_sqlite.d.cts +9 -1
- package/dist/stores/better_sqlite.d.ts +9 -1
- package/dist/stores/better_sqlite.js +19 -3
- package/dist/stores/index.cjs +19 -3
- package/dist/stores/index.js +19 -3
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +26 -2
- package/dist/types/index.d.ts +26 -2
- package/dist/types/index.js +1 -0
- package/dist/ui/assets/{CacheActionBadge-3jjmNjC6.js → CacheActionBadge-3t8U516j.js} +1 -1
- package/dist/ui/assets/CacheEntriesTable-BqLquILg.js +1 -0
- package/dist/ui/assets/CacheEntryContainer-B86waEsR.js +2 -0
- package/dist/ui/assets/{CacheEntryDetails-CHt_pNTk.js → CacheEntryDetails-Dm-oXALj.js} +1 -1
- package/dist/ui/assets/CacheEntryDetailsContainer-BCyXGgkx.js +2 -0
- package/dist/ui/assets/ExceptionContainer-DSQBz5cb.js +2 -0
- package/dist/ui/assets/ExceptionDetails-gmpSQ_eu.js +16 -0
- package/dist/ui/assets/ExceptionDetailsContainer-BHIz-TUv.js +2 -0
- package/dist/ui/assets/ExceptionTable-BhrX9MSS.js +1 -0
- package/dist/ui/assets/{LoadMore-DHOrhPsi.js → LoadMore-26PcNWcP.js} +1 -1
- package/dist/ui/assets/QueriesContainer-BSF-O4s3.js +2 -0
- package/dist/ui/assets/{QueryDetailsContainer-eoLkgEjj.js → QueryDetailsContainer-BjQM9QIb.js} +7 -7
- package/dist/ui/assets/{QueryTable-BXSzT-Cm.js → QueryTable-szgIT5Uc.js} +1 -1
- package/dist/ui/assets/RequestDetails-CvQhX-2F.js +1 -0
- package/dist/ui/assets/{RequestDetailsContainer-BaH6fUK7.js → RequestDetailsContainer-XYPFJFX0.js} +2 -2
- package/dist/ui/assets/RequestsContainer-D0QPK2Ii.js +2 -0
- package/dist/ui/assets/{RequetsTable-B51VXisk.js → RequetsTable-6Fqchsrt.js} +1 -1
- package/dist/ui/assets/{StatusCode-DVhX11V3.js → StatusCode-CfVCLID2.js} +1 -1
- package/dist/ui/assets/TabbedDataViewer-Cl5ednx4.js +1 -0
- package/dist/ui/assets/{Table-D1Kpw7PA.js → Table-CGe8JwTO.js} +1 -1
- package/dist/ui/assets/{columns-BIDLCW64.js → columns-BFxCubt5.js} +1 -1
- package/dist/ui/assets/columns-Cw7tw3Em.js +1 -0
- package/dist/ui/assets/{columns-jYfhBxOM.js → columns-RiCoo9Ea.js} +1 -1
- package/dist/ui/assets/{index-CpP2Ap5X.js → index-BRRKsoNv.js} +1 -1
- package/dist/ui/assets/index-BzFeZyjf.css +1 -0
- package/dist/ui/assets/{index-BdvbrZNf.js → index-XoJlyTFO.js} +26 -21
- package/dist/ui/assets/{useCacheEntries-vuHEIj6E.js → useCacheEntries-SCADuxKq.js} +1 -1
- package/dist/ui/assets/useExceptions-BMGL3nir.js +1 -0
- package/dist/ui/assets/useLensApi-BYyiIIZR.js +1 -0
- package/dist/ui/assets/{useLoadMore-twYxPJ-d.js → useLoadMore-CksOcXOF.js} +1 -1
- package/dist/ui/assets/{useQueries-BYFLoUQR.js → useQueries-6nYr0oG5.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/async_context.cjs +113 -0
- package/dist/utils/async_context.d.cts +6 -1
- package/dist/utils/async_context.d.ts +6 -1
- package/dist/utils/async_context.js +102 -0
- package/dist/utils/exception.cjs +130 -0
- package/dist/utils/exception.d.cts +3 -0
- package/dist/utils/exception.d.ts +3 -0
- package/dist/utils/exception.js +91 -0
- package/dist/watchers/cache_watcher.cjs +12 -16
- package/dist/watchers/cache_watcher.js +12 -16
- package/dist/watchers/exception_watcher.cjs +108 -0
- package/dist/watchers/exception_watcher.d.cts +10 -0
- package/dist/watchers/exception_watcher.d.ts +10 -0
- package/dist/watchers/exception_watcher.js +75 -0
- package/dist/watchers/index.cjs +53 -16
- package/dist/watchers/index.d.cts +1 -0
- package/dist/watchers/index.d.ts +1 -0
- package/dist/watchers/index.js +42 -16
- package/package.json +8 -6
- package/dist/ui/assets/CacheEntriesTable-DPLre6br.js +0 -1
- package/dist/ui/assets/CacheEntryContainer-WN6LkoCR.js +0 -2
- package/dist/ui/assets/CacheEntryDetailsContainer-BhquSApO.js +0 -2
- package/dist/ui/assets/QueriesContainer-Cl6rq4dH.js +0 -2
- package/dist/ui/assets/RequestDetails-CIB7_XWh.js +0 -1
- package/dist/ui/assets/RequestsContainer-DLS17BWP.js +0 -2
- package/dist/ui/assets/TabbedDataViewer-CNSEhc6h.js +0 -1
- package/dist/ui/assets/index-C04tuZDI.css +0 -1
- package/dist/ui/assets/useLensApi-Bzmx8hps.js +0 -1
package/dist/index.js
CHANGED
|
@@ -52,6 +52,7 @@ var WatcherTypeEnum = /* @__PURE__ */ ((WatcherTypeEnum2) => {
|
|
|
52
52
|
WatcherTypeEnum2["REQUEST"] = "request";
|
|
53
53
|
WatcherTypeEnum2["QUERY"] = "query";
|
|
54
54
|
WatcherTypeEnum2["CACHE"] = "cache";
|
|
55
|
+
WatcherTypeEnum2["EXCEPTION"] = "exception";
|
|
55
56
|
return WatcherTypeEnum2;
|
|
56
57
|
})(WatcherTypeEnum || {});
|
|
57
58
|
|
|
@@ -75,10 +76,16 @@ var ApiController = class {
|
|
|
75
76
|
request.id,
|
|
76
77
|
"cache" /* CACHE */
|
|
77
78
|
);
|
|
79
|
+
const exceptions = await getStore().allByRequestId(
|
|
80
|
+
request.id,
|
|
81
|
+
"exception" /* EXCEPTION */,
|
|
82
|
+
false
|
|
83
|
+
);
|
|
78
84
|
return this.resourceResponse({
|
|
79
85
|
request,
|
|
80
86
|
queries,
|
|
81
|
-
cacheEntries
|
|
87
|
+
cacheEntries,
|
|
88
|
+
exceptions
|
|
82
89
|
});
|
|
83
90
|
}
|
|
84
91
|
static async getQueries({
|
|
@@ -110,6 +117,21 @@ var ApiController = class {
|
|
|
110
117
|
}
|
|
111
118
|
return this.resourceResponse(cacheEntry);
|
|
112
119
|
}
|
|
120
|
+
static async getExceptions({ qs }) {
|
|
121
|
+
return this.paginatedResponse(
|
|
122
|
+
await getStore().getAllExceptions(this.extractPaginationParams(qs))
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
static async getException({ params }) {
|
|
126
|
+
const exception = await getStore().find(
|
|
127
|
+
"exception" /* EXCEPTION */,
|
|
128
|
+
params.id
|
|
129
|
+
);
|
|
130
|
+
if (!exception) {
|
|
131
|
+
return this.notFoundResponse();
|
|
132
|
+
}
|
|
133
|
+
return this.resourceResponse(exception);
|
|
134
|
+
}
|
|
113
135
|
static async truncate() {
|
|
114
136
|
await getStore().truncate();
|
|
115
137
|
return this.baseResponse({}, 200, "All entries cleared");
|
|
@@ -161,6 +183,9 @@ import * as path2 from "path";
|
|
|
161
183
|
|
|
162
184
|
// src/abstracts/store.ts
|
|
163
185
|
var Store = class {
|
|
186
|
+
getAllExceptions(_paginationParams) {
|
|
187
|
+
return this.defaultMinimalPaginate();
|
|
188
|
+
}
|
|
164
189
|
stringifyData(data) {
|
|
165
190
|
if (typeof data === "string") {
|
|
166
191
|
return data;
|
|
@@ -171,6 +196,16 @@ var Store = class {
|
|
|
171
196
|
console.error(`Failed to stringify lens data: ${e}`);
|
|
172
197
|
}
|
|
173
198
|
}
|
|
199
|
+
defaultMinimalPaginate() {
|
|
200
|
+
return Promise.resolve({
|
|
201
|
+
data: [],
|
|
202
|
+
meta: {
|
|
203
|
+
currentPage: 0,
|
|
204
|
+
lastPage: 0,
|
|
205
|
+
total: 0
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
174
209
|
};
|
|
175
210
|
|
|
176
211
|
// src/stores/better_sqlite.ts
|
|
@@ -209,11 +244,14 @@ var BetterSqliteStore = class extends Store {
|
|
|
209
244
|
async getAllCacheEntries(pagination) {
|
|
210
245
|
return await this.paginate("cache" /* CACHE */, pagination);
|
|
211
246
|
}
|
|
212
|
-
async
|
|
247
|
+
async getAllExceptions(pagination) {
|
|
248
|
+
return await this.paginate("exception" /* EXCEPTION */, pagination, false);
|
|
249
|
+
}
|
|
250
|
+
async allByRequestId(requestId, type, includeFullData = true) {
|
|
213
251
|
const rows = this.connection.prepare(
|
|
214
|
-
`${this.getSelectedColumns()} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
252
|
+
`${this.getSelectedColumns(includeFullData)} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
215
253
|
).all({ type, requestId });
|
|
216
|
-
return this.mapRows(rows);
|
|
254
|
+
return this.mapRows(rows, includeFullData);
|
|
217
255
|
}
|
|
218
256
|
async paginate(type, { page, perPage }, includeFullData = true) {
|
|
219
257
|
const offset = (page - 1) * perPage;
|
|
@@ -379,8 +417,8 @@ function stripBeforeAssetsPath(url) {
|
|
|
379
417
|
const match = url.match(/assets.*/);
|
|
380
418
|
return match ? match[0] : url;
|
|
381
419
|
}
|
|
382
|
-
function prepareIgnoredPaths(
|
|
383
|
-
const normalizedPath =
|
|
420
|
+
function prepareIgnoredPaths(path4, ignoredPaths) {
|
|
421
|
+
const normalizedPath = path4.replace(/^\/+|\/+$/g, "");
|
|
384
422
|
ignoredPaths = [
|
|
385
423
|
...ignoredPaths,
|
|
386
424
|
new RegExp(`^/?${normalizedPath}(/|$)`),
|
|
@@ -389,11 +427,11 @@ function prepareIgnoredPaths(path3, ignoredPaths) {
|
|
|
389
427
|
];
|
|
390
428
|
return { ignoredPaths, normalizedPath };
|
|
391
429
|
}
|
|
392
|
-
function shouldIgnoreCurrentPath(
|
|
430
|
+
function shouldIgnoreCurrentPath(path4, ignoredPaths, onlyPaths) {
|
|
393
431
|
if (onlyPaths.length > 0) {
|
|
394
|
-
return !onlyPaths.some((pattern) => pattern.test(
|
|
432
|
+
return !onlyPaths.some((pattern) => pattern.test(path4));
|
|
395
433
|
}
|
|
396
|
-
return ignoredPaths.some((pattern) => pattern.test(
|
|
434
|
+
return ignoredPaths.some((pattern) => pattern.test(path4));
|
|
397
435
|
}
|
|
398
436
|
function prettyHrTime(hrtime, verbose = false) {
|
|
399
437
|
const seconds = hrtime[0];
|
|
@@ -476,6 +514,7 @@ var Lens = class {
|
|
|
476
514
|
requests: `/${config.basePath}/api/requests`,
|
|
477
515
|
queries: `/${config.basePath}/api/queries`,
|
|
478
516
|
cache: `/${config.basePath}/api/cache`,
|
|
517
|
+
exceptions: `/${config.basePath}/api/exceptions`,
|
|
479
518
|
truncate: `/${config.basePath}/api/truncate`
|
|
480
519
|
}
|
|
481
520
|
};
|
|
@@ -518,6 +557,16 @@ var Lens = class {
|
|
|
518
557
|
path: `${basePath}/api/cache/:id`,
|
|
519
558
|
handler: async (data) => await ApiController.getCacheEntry(data)
|
|
520
559
|
},
|
|
560
|
+
{
|
|
561
|
+
method: "GET",
|
|
562
|
+
path: `${basePath}/api/exceptions`,
|
|
563
|
+
handler: async (data) => await ApiController.getExceptions(data)
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
method: "GET",
|
|
567
|
+
path: `${basePath}/api/exceptions/:id`,
|
|
568
|
+
handler: async (data) => await ApiController.getException(data)
|
|
569
|
+
},
|
|
521
570
|
{
|
|
522
571
|
method: "DELETE",
|
|
523
572
|
path: `${basePath}/api/truncate`,
|
|
@@ -531,8 +580,8 @@ var Lens = class {
|
|
|
531
580
|
await store.initialize();
|
|
532
581
|
return store;
|
|
533
582
|
}
|
|
534
|
-
static normalizeDirName(
|
|
535
|
-
return
|
|
583
|
+
static normalizeDirName(path4) {
|
|
584
|
+
return path4.replace(/(\/packages\/)[^/]+(?=\/dist)/, "$1core");
|
|
536
585
|
}
|
|
537
586
|
};
|
|
538
587
|
|
|
@@ -598,23 +647,38 @@ var CacheWatcher = class extends Watcher {
|
|
|
598
647
|
});
|
|
599
648
|
}
|
|
600
649
|
normalizePayload(data) {
|
|
601
|
-
let
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
value
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
normalizedData.key = "";
|
|
613
|
-
}
|
|
614
|
-
if (!normalizedData["value"]) {
|
|
615
|
-
normalizedData["value"] = "";
|
|
650
|
+
let key = "";
|
|
651
|
+
let value = "";
|
|
652
|
+
if ("data" in data && typeof data.data === "object" && data.data !== null) {
|
|
653
|
+
if ("key" in data.data) {
|
|
654
|
+
key = String(data.data.key);
|
|
655
|
+
}
|
|
656
|
+
if ("value" in data.data) {
|
|
657
|
+
value = data.data.value;
|
|
658
|
+
}
|
|
659
|
+
} else if (typeof data.data === "string") {
|
|
660
|
+
value = data.data;
|
|
616
661
|
}
|
|
617
|
-
return
|
|
662
|
+
return { key, value };
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
// src/watchers/exception_watcher.ts
|
|
667
|
+
var ExceptionWatcher = class extends Watcher {
|
|
668
|
+
name = "exception" /* EXCEPTION */;
|
|
669
|
+
async log(payload) {
|
|
670
|
+
await getStore().save({
|
|
671
|
+
id: generateRandomUuid(),
|
|
672
|
+
type: "exception" /* EXCEPTION */,
|
|
673
|
+
requestId: payload.requestId,
|
|
674
|
+
timestamp: payload.createdAt,
|
|
675
|
+
data: payload,
|
|
676
|
+
minimal_data: {
|
|
677
|
+
name: payload.name,
|
|
678
|
+
message: payload.message,
|
|
679
|
+
createdAt: payload.createdAt
|
|
680
|
+
}
|
|
681
|
+
});
|
|
618
682
|
}
|
|
619
683
|
};
|
|
620
684
|
|
|
@@ -638,11 +702,104 @@ var Adapter = class {
|
|
|
638
702
|
getWatchers() {
|
|
639
703
|
return this.watchers;
|
|
640
704
|
}
|
|
641
|
-
shouldIgnorePath(
|
|
642
|
-
return shouldIgnoreCurrentPath(
|
|
705
|
+
shouldIgnorePath(path4) {
|
|
706
|
+
return shouldIgnoreCurrentPath(path4, this.ignoredPaths, this.onlyPaths);
|
|
643
707
|
}
|
|
644
708
|
};
|
|
645
709
|
|
|
710
|
+
// src/utils/exception.ts
|
|
711
|
+
var exception_exports = {};
|
|
712
|
+
__export(exception_exports, {
|
|
713
|
+
cleanStack: () => cleanStack,
|
|
714
|
+
constructErrorObject: () => constructErrorObject,
|
|
715
|
+
extractCodeFrame: () => extractCodeFrame,
|
|
716
|
+
getFileInfo: () => getFileInfo,
|
|
717
|
+
getStackTrace: () => getStackTrace
|
|
718
|
+
});
|
|
719
|
+
import StackUtils from "stack-utils";
|
|
720
|
+
import path3 from "path";
|
|
721
|
+
import { existsSync, readFileSync } from "fs";
|
|
722
|
+
import { nowISO as nowISO2 } from "@lensjs/date";
|
|
723
|
+
var stackUtils = new StackUtils({
|
|
724
|
+
cwd: process.cwd(),
|
|
725
|
+
internals: StackUtils.nodeInternals()
|
|
726
|
+
});
|
|
727
|
+
function cleanStack(stack) {
|
|
728
|
+
if (!stack) return "";
|
|
729
|
+
return stackUtils.clean(stack);
|
|
730
|
+
}
|
|
731
|
+
function getFileInfo(stack) {
|
|
732
|
+
if (!stack) {
|
|
733
|
+
return { file: "", line: 0, column: 0, function: "" };
|
|
734
|
+
}
|
|
735
|
+
const firstLine = stack.split("\n")[1] ?? "";
|
|
736
|
+
const fileInfo = stackUtils.parseLine(firstLine) ?? {
|
|
737
|
+
file: "",
|
|
738
|
+
line: 0,
|
|
739
|
+
column: 0,
|
|
740
|
+
function: ""
|
|
741
|
+
};
|
|
742
|
+
return {
|
|
743
|
+
file: fileInfo.file ? path3.resolve(process.cwd(), fileInfo.file) : "",
|
|
744
|
+
line: fileInfo.line ?? 0,
|
|
745
|
+
column: fileInfo.column ?? 0,
|
|
746
|
+
function: fileInfo.function ?? ""
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
function getStackTrace(stack) {
|
|
750
|
+
if (!stack) return [];
|
|
751
|
+
return cleanStack(stack).split("\n").filter((frame) => Boolean(frame));
|
|
752
|
+
}
|
|
753
|
+
function extractCodeFrame({
|
|
754
|
+
file,
|
|
755
|
+
line,
|
|
756
|
+
column,
|
|
757
|
+
contextLines = 6
|
|
758
|
+
}) {
|
|
759
|
+
if (!file) return null;
|
|
760
|
+
const fullPath = path3.isAbsolute(file) ? file : path3.resolve(process.cwd(), file);
|
|
761
|
+
if (!existsSync(fullPath)) return null;
|
|
762
|
+
const fileContent = readFileSync(fullPath, "utf-8");
|
|
763
|
+
const lines = fileContent.split(/\r?\n/);
|
|
764
|
+
if (line < 1 || line > lines.length) return null;
|
|
765
|
+
const start = Math.max(0, line - 1 - contextLines);
|
|
766
|
+
const end = Math.min(lines.length, line - 1 + contextLines + 1);
|
|
767
|
+
const snippet = lines.slice(start, end);
|
|
768
|
+
const relativeLine = line - 1 - start;
|
|
769
|
+
const errorLine = lines[line - 1] ?? "";
|
|
770
|
+
return {
|
|
771
|
+
file: fullPath,
|
|
772
|
+
line,
|
|
773
|
+
column,
|
|
774
|
+
context: {
|
|
775
|
+
pre: snippet.slice(0, relativeLine),
|
|
776
|
+
error: errorLine,
|
|
777
|
+
post: snippet.slice(relativeLine + 1)
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
function constructErrorObject(err) {
|
|
782
|
+
const fileInfo = getFileInfo(err.stack);
|
|
783
|
+
const codeFrame = extractCodeFrame({
|
|
784
|
+
file: fileInfo.file,
|
|
785
|
+
line: fileInfo.line,
|
|
786
|
+
column: fileInfo.column
|
|
787
|
+
});
|
|
788
|
+
return {
|
|
789
|
+
name: err.name,
|
|
790
|
+
message: err.message,
|
|
791
|
+
createdAt: nowISO2(),
|
|
792
|
+
fileInfo: {
|
|
793
|
+
file: fileInfo.file,
|
|
794
|
+
function: fileInfo.function
|
|
795
|
+
},
|
|
796
|
+
cause: err.cause ?? null,
|
|
797
|
+
trace: getStackTrace(err.stack),
|
|
798
|
+
codeFrame,
|
|
799
|
+
originalStack: codeFrame === null ? cleanStack(err.stack) : null
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
|
|
646
803
|
// src/utils/event_emitter.ts
|
|
647
804
|
import Emittery from "emittery";
|
|
648
805
|
var createEmittery = () => {
|
|
@@ -653,9 +810,24 @@ var lensEmitter = createEmittery();
|
|
|
653
810
|
// src/utils/async_context.ts
|
|
654
811
|
import { AsyncLocalStorage } from "async_hooks";
|
|
655
812
|
var lensContext = new AsyncLocalStorage();
|
|
813
|
+
var handleUncaughExceptions = (logger) => {
|
|
814
|
+
process.on("uncaughtExceptionMonitor", async (err) => {
|
|
815
|
+
await logger.log({
|
|
816
|
+
...constructErrorObject(err),
|
|
817
|
+
requestId: lensContext.getStore()?.requestId
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
process.on("uncaughtException", async (err) => {
|
|
821
|
+
await logger.log({
|
|
822
|
+
...constructErrorObject(err),
|
|
823
|
+
requestId: lensContext.getStore()?.requestId
|
|
824
|
+
});
|
|
825
|
+
});
|
|
826
|
+
};
|
|
656
827
|
export {
|
|
657
828
|
BetterSqliteStore,
|
|
658
829
|
CacheWatcher,
|
|
830
|
+
ExceptionWatcher,
|
|
659
831
|
Lens,
|
|
660
832
|
Adapter as LensAdapter,
|
|
661
833
|
Store as LensStore,
|
|
@@ -665,7 +837,9 @@ export {
|
|
|
665
837
|
WatcherTypeEnum,
|
|
666
838
|
createEmittery,
|
|
667
839
|
getStore as getLensStore,
|
|
840
|
+
handleUncaughExceptions,
|
|
668
841
|
lensContext,
|
|
669
842
|
lensEmitter,
|
|
843
|
+
exception_exports as lensExceptionUtils,
|
|
670
844
|
utils_exports as lensUtils
|
|
671
845
|
};
|
|
@@ -36,6 +36,9 @@ module.exports = __toCommonJS(better_sqlite_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/abstracts/store.ts
|
|
38
38
|
var Store = class {
|
|
39
|
+
getAllExceptions(_paginationParams) {
|
|
40
|
+
return this.defaultMinimalPaginate();
|
|
41
|
+
}
|
|
39
42
|
stringifyData(data) {
|
|
40
43
|
if (typeof data === "string") {
|
|
41
44
|
return data;
|
|
@@ -46,6 +49,16 @@ var Store = class {
|
|
|
46
49
|
console.error(`Failed to stringify lens data: ${e}`);
|
|
47
50
|
}
|
|
48
51
|
}
|
|
52
|
+
defaultMinimalPaginate() {
|
|
53
|
+
return Promise.resolve({
|
|
54
|
+
data: [],
|
|
55
|
+
meta: {
|
|
56
|
+
currentPage: 0,
|
|
57
|
+
lastPage: 0,
|
|
58
|
+
total: 0
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
49
62
|
};
|
|
50
63
|
|
|
51
64
|
// src/stores/better_sqlite.ts
|
|
@@ -84,11 +97,14 @@ var BetterSqliteStore = class extends Store {
|
|
|
84
97
|
async getAllCacheEntries(pagination) {
|
|
85
98
|
return await this.paginate("cache" /* CACHE */, pagination);
|
|
86
99
|
}
|
|
87
|
-
async
|
|
100
|
+
async getAllExceptions(pagination) {
|
|
101
|
+
return await this.paginate("exception" /* EXCEPTION */, pagination, false);
|
|
102
|
+
}
|
|
103
|
+
async allByRequestId(requestId, type, includeFullData = true) {
|
|
88
104
|
const rows = this.connection.prepare(
|
|
89
|
-
`${this.getSelectedColumns()} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
105
|
+
`${this.getSelectedColumns(includeFullData)} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
90
106
|
).all({ type, requestId });
|
|
91
|
-
return this.mapRows(rows);
|
|
107
|
+
return this.mapRows(rows, includeFullData);
|
|
92
108
|
}
|
|
93
109
|
async paginate(type, { page, perPage }, includeFullData = true) {
|
|
94
110
|
const offset = (page - 1) * perPage;
|
|
@@ -39,7 +39,15 @@ declare class BetterSqliteStore extends Store {
|
|
|
39
39
|
};
|
|
40
40
|
data: T;
|
|
41
41
|
}>;
|
|
42
|
-
|
|
42
|
+
getAllExceptions<T extends Omit<LensEntry, "data">[]>(pagination: PaginationParams): Promise<{
|
|
43
|
+
meta: {
|
|
44
|
+
total: number;
|
|
45
|
+
lastPage: number;
|
|
46
|
+
currentPage: number;
|
|
47
|
+
};
|
|
48
|
+
data: T;
|
|
49
|
+
}>;
|
|
50
|
+
allByRequestId(requestId: string, type: WatcherTypeEnum, includeFullData?: boolean): Promise<LensEntry[]>;
|
|
43
51
|
paginate<T>(type: WatcherTypeEnum, { page, perPage }: PaginationParams, includeFullData?: boolean): Promise<{
|
|
44
52
|
meta: {
|
|
45
53
|
total: number;
|
|
@@ -39,7 +39,15 @@ declare class BetterSqliteStore extends Store {
|
|
|
39
39
|
};
|
|
40
40
|
data: T;
|
|
41
41
|
}>;
|
|
42
|
-
|
|
42
|
+
getAllExceptions<T extends Omit<LensEntry, "data">[]>(pagination: PaginationParams): Promise<{
|
|
43
|
+
meta: {
|
|
44
|
+
total: number;
|
|
45
|
+
lastPage: number;
|
|
46
|
+
currentPage: number;
|
|
47
|
+
};
|
|
48
|
+
data: T;
|
|
49
|
+
}>;
|
|
50
|
+
allByRequestId(requestId: string, type: WatcherTypeEnum, includeFullData?: boolean): Promise<LensEntry[]>;
|
|
43
51
|
paginate<T>(type: WatcherTypeEnum, { page, perPage }: PaginationParams, includeFullData?: boolean): Promise<{
|
|
44
52
|
meta: {
|
|
45
53
|
total: number;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// src/abstracts/store.ts
|
|
2
2
|
var Store = class {
|
|
3
|
+
getAllExceptions(_paginationParams) {
|
|
4
|
+
return this.defaultMinimalPaginate();
|
|
5
|
+
}
|
|
3
6
|
stringifyData(data) {
|
|
4
7
|
if (typeof data === "string") {
|
|
5
8
|
return data;
|
|
@@ -10,6 +13,16 @@ var Store = class {
|
|
|
10
13
|
console.error(`Failed to stringify lens data: ${e}`);
|
|
11
14
|
}
|
|
12
15
|
}
|
|
16
|
+
defaultMinimalPaginate() {
|
|
17
|
+
return Promise.resolve({
|
|
18
|
+
data: [],
|
|
19
|
+
meta: {
|
|
20
|
+
currentPage: 0,
|
|
21
|
+
lastPage: 0,
|
|
22
|
+
total: 0
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
13
26
|
};
|
|
14
27
|
|
|
15
28
|
// src/stores/better_sqlite.ts
|
|
@@ -48,11 +61,14 @@ var BetterSqliteStore = class extends Store {
|
|
|
48
61
|
async getAllCacheEntries(pagination) {
|
|
49
62
|
return await this.paginate("cache" /* CACHE */, pagination);
|
|
50
63
|
}
|
|
51
|
-
async
|
|
64
|
+
async getAllExceptions(pagination) {
|
|
65
|
+
return await this.paginate("exception" /* EXCEPTION */, pagination, false);
|
|
66
|
+
}
|
|
67
|
+
async allByRequestId(requestId, type, includeFullData = true) {
|
|
52
68
|
const rows = this.connection.prepare(
|
|
53
|
-
`${this.getSelectedColumns()} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
69
|
+
`${this.getSelectedColumns(includeFullData)} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
54
70
|
).all({ type, requestId });
|
|
55
|
-
return this.mapRows(rows);
|
|
71
|
+
return this.mapRows(rows, includeFullData);
|
|
56
72
|
}
|
|
57
73
|
async paginate(type, { page, perPage }, includeFullData = true) {
|
|
58
74
|
const offset = (page - 1) * perPage;
|
package/dist/stores/index.cjs
CHANGED
|
@@ -36,6 +36,9 @@ module.exports = __toCommonJS(stores_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/abstracts/store.ts
|
|
38
38
|
var Store = class {
|
|
39
|
+
getAllExceptions(_paginationParams) {
|
|
40
|
+
return this.defaultMinimalPaginate();
|
|
41
|
+
}
|
|
39
42
|
stringifyData(data) {
|
|
40
43
|
if (typeof data === "string") {
|
|
41
44
|
return data;
|
|
@@ -46,6 +49,16 @@ var Store = class {
|
|
|
46
49
|
console.error(`Failed to stringify lens data: ${e}`);
|
|
47
50
|
}
|
|
48
51
|
}
|
|
52
|
+
defaultMinimalPaginate() {
|
|
53
|
+
return Promise.resolve({
|
|
54
|
+
data: [],
|
|
55
|
+
meta: {
|
|
56
|
+
currentPage: 0,
|
|
57
|
+
lastPage: 0,
|
|
58
|
+
total: 0
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
49
62
|
};
|
|
50
63
|
|
|
51
64
|
// src/stores/better_sqlite.ts
|
|
@@ -84,11 +97,14 @@ var BetterSqliteStore = class extends Store {
|
|
|
84
97
|
async getAllCacheEntries(pagination) {
|
|
85
98
|
return await this.paginate("cache" /* CACHE */, pagination);
|
|
86
99
|
}
|
|
87
|
-
async
|
|
100
|
+
async getAllExceptions(pagination) {
|
|
101
|
+
return await this.paginate("exception" /* EXCEPTION */, pagination, false);
|
|
102
|
+
}
|
|
103
|
+
async allByRequestId(requestId, type, includeFullData = true) {
|
|
88
104
|
const rows = this.connection.prepare(
|
|
89
|
-
`${this.getSelectedColumns()} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
105
|
+
`${this.getSelectedColumns(includeFullData)} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
90
106
|
).all({ type, requestId });
|
|
91
|
-
return this.mapRows(rows);
|
|
107
|
+
return this.mapRows(rows, includeFullData);
|
|
92
108
|
}
|
|
93
109
|
async paginate(type, { page, perPage }, includeFullData = true) {
|
|
94
110
|
const offset = (page - 1) * perPage;
|
package/dist/stores/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// src/abstracts/store.ts
|
|
2
2
|
var Store = class {
|
|
3
|
+
getAllExceptions(_paginationParams) {
|
|
4
|
+
return this.defaultMinimalPaginate();
|
|
5
|
+
}
|
|
3
6
|
stringifyData(data) {
|
|
4
7
|
if (typeof data === "string") {
|
|
5
8
|
return data;
|
|
@@ -10,6 +13,16 @@ var Store = class {
|
|
|
10
13
|
console.error(`Failed to stringify lens data: ${e}`);
|
|
11
14
|
}
|
|
12
15
|
}
|
|
16
|
+
defaultMinimalPaginate() {
|
|
17
|
+
return Promise.resolve({
|
|
18
|
+
data: [],
|
|
19
|
+
meta: {
|
|
20
|
+
currentPage: 0,
|
|
21
|
+
lastPage: 0,
|
|
22
|
+
total: 0
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
13
26
|
};
|
|
14
27
|
|
|
15
28
|
// src/stores/better_sqlite.ts
|
|
@@ -48,11 +61,14 @@ var BetterSqliteStore = class extends Store {
|
|
|
48
61
|
async getAllCacheEntries(pagination) {
|
|
49
62
|
return await this.paginate("cache" /* CACHE */, pagination);
|
|
50
63
|
}
|
|
51
|
-
async
|
|
64
|
+
async getAllExceptions(pagination) {
|
|
65
|
+
return await this.paginate("exception" /* EXCEPTION */, pagination, false);
|
|
66
|
+
}
|
|
67
|
+
async allByRequestId(requestId, type, includeFullData = true) {
|
|
52
68
|
const rows = this.connection.prepare(
|
|
53
|
-
`${this.getSelectedColumns()} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
69
|
+
`${this.getSelectedColumns(includeFullData)} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
54
70
|
).all({ type, requestId });
|
|
55
|
-
return this.mapRows(rows);
|
|
71
|
+
return this.mapRows(rows, includeFullData);
|
|
56
72
|
}
|
|
57
73
|
async paginate(type, { page, perPage }, includeFullData = true) {
|
|
58
74
|
const offset = (page - 1) * perPage;
|
package/dist/types/index.cjs
CHANGED
|
@@ -27,6 +27,7 @@ var WatcherTypeEnum = /* @__PURE__ */ ((WatcherTypeEnum2) => {
|
|
|
27
27
|
WatcherTypeEnum2["REQUEST"] = "request";
|
|
28
28
|
WatcherTypeEnum2["QUERY"] = "query";
|
|
29
29
|
WatcherTypeEnum2["CACHE"] = "cache";
|
|
30
|
+
WatcherTypeEnum2["EXCEPTION"] = "exception";
|
|
30
31
|
return WatcherTypeEnum2;
|
|
31
32
|
})(WatcherTypeEnum || {});
|
|
32
33
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/types/index.d.cts
CHANGED
|
@@ -33,6 +33,29 @@ type CacheEntry = {
|
|
|
33
33
|
key: string;
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
+
type ExceptionEntry = {
|
|
37
|
+
name: string;
|
|
38
|
+
message: string;
|
|
39
|
+
cause?: Record<string, any> | string | null;
|
|
40
|
+
trace?: string[];
|
|
41
|
+
requestId?: string;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
fileInfo?: {
|
|
44
|
+
file: string;
|
|
45
|
+
function: string;
|
|
46
|
+
};
|
|
47
|
+
codeFrame?: {
|
|
48
|
+
file: string;
|
|
49
|
+
line: number;
|
|
50
|
+
column: number;
|
|
51
|
+
context: {
|
|
52
|
+
pre: string[];
|
|
53
|
+
error: string;
|
|
54
|
+
post: string[];
|
|
55
|
+
};
|
|
56
|
+
} | null;
|
|
57
|
+
originalStack?: string | null;
|
|
58
|
+
};
|
|
36
59
|
type UserEntry = {
|
|
37
60
|
id: number | string;
|
|
38
61
|
name: string;
|
|
@@ -66,7 +89,8 @@ type Entry = {
|
|
|
66
89
|
declare enum WatcherTypeEnum {
|
|
67
90
|
REQUEST = "request",
|
|
68
91
|
QUERY = "query",
|
|
69
|
-
CACHE = "cache"
|
|
92
|
+
CACHE = "cache",
|
|
93
|
+
EXCEPTION = "exception"
|
|
70
94
|
}
|
|
71
95
|
type LensConfig = {
|
|
72
96
|
basePath: string;
|
|
@@ -111,4 +135,4 @@ type ApiResponse<T> = {
|
|
|
111
135
|
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
112
136
|
type RouteHttpMethod = "get" | "post" | "put" | "delete" | "patch";
|
|
113
137
|
|
|
114
|
-
export { type ApiResponse, type CacheAction, type CacheEntry, type Entry, type HttpMethod, type LensConfig, type LensEntry, type PaginationParams, type Paginator, type QueryEntry, type QueryType, type RequestEntry, type RouteDefinition, type RouteDefinitionHandler, type RouteHttpMethod, type SqlQueryType, type UserEntry, WatcherTypeEnum };
|
|
138
|
+
export { type ApiResponse, type CacheAction, type CacheEntry, type Entry, type ExceptionEntry, type HttpMethod, type LensConfig, type LensEntry, type PaginationParams, type Paginator, type QueryEntry, type QueryType, type RequestEntry, type RouteDefinition, type RouteDefinitionHandler, type RouteHttpMethod, type SqlQueryType, type UserEntry, WatcherTypeEnum };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -33,6 +33,29 @@ type CacheEntry = {
|
|
|
33
33
|
key: string;
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
+
type ExceptionEntry = {
|
|
37
|
+
name: string;
|
|
38
|
+
message: string;
|
|
39
|
+
cause?: Record<string, any> | string | null;
|
|
40
|
+
trace?: string[];
|
|
41
|
+
requestId?: string;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
fileInfo?: {
|
|
44
|
+
file: string;
|
|
45
|
+
function: string;
|
|
46
|
+
};
|
|
47
|
+
codeFrame?: {
|
|
48
|
+
file: string;
|
|
49
|
+
line: number;
|
|
50
|
+
column: number;
|
|
51
|
+
context: {
|
|
52
|
+
pre: string[];
|
|
53
|
+
error: string;
|
|
54
|
+
post: string[];
|
|
55
|
+
};
|
|
56
|
+
} | null;
|
|
57
|
+
originalStack?: string | null;
|
|
58
|
+
};
|
|
36
59
|
type UserEntry = {
|
|
37
60
|
id: number | string;
|
|
38
61
|
name: string;
|
|
@@ -66,7 +89,8 @@ type Entry = {
|
|
|
66
89
|
declare enum WatcherTypeEnum {
|
|
67
90
|
REQUEST = "request",
|
|
68
91
|
QUERY = "query",
|
|
69
|
-
CACHE = "cache"
|
|
92
|
+
CACHE = "cache",
|
|
93
|
+
EXCEPTION = "exception"
|
|
70
94
|
}
|
|
71
95
|
type LensConfig = {
|
|
72
96
|
basePath: string;
|
|
@@ -111,4 +135,4 @@ type ApiResponse<T> = {
|
|
|
111
135
|
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
|
|
112
136
|
type RouteHttpMethod = "get" | "post" | "put" | "delete" | "patch";
|
|
113
137
|
|
|
114
|
-
export { type ApiResponse, type CacheAction, type CacheEntry, type Entry, type HttpMethod, type LensConfig, type LensEntry, type PaginationParams, type Paginator, type QueryEntry, type QueryType, type RequestEntry, type RouteDefinition, type RouteDefinitionHandler, type RouteHttpMethod, type SqlQueryType, type UserEntry, WatcherTypeEnum };
|
|
138
|
+
export { type ApiResponse, type CacheAction, type CacheEntry, type Entry, type ExceptionEntry, type HttpMethod, type LensConfig, type LensEntry, type PaginationParams, type Paginator, type QueryEntry, type QueryType, type RequestEntry, type RouteDefinition, type RouteDefinitionHandler, type RouteHttpMethod, type SqlQueryType, type UserEntry, WatcherTypeEnum };
|
package/dist/types/index.js
CHANGED
|
@@ -3,6 +3,7 @@ var WatcherTypeEnum = /* @__PURE__ */ ((WatcherTypeEnum2) => {
|
|
|
3
3
|
WatcherTypeEnum2["REQUEST"] = "request";
|
|
4
4
|
WatcherTypeEnum2["QUERY"] = "query";
|
|
5
5
|
WatcherTypeEnum2["CACHE"] = "cache";
|
|
6
|
+
WatcherTypeEnum2["EXCEPTION"] = "exception";
|
|
6
7
|
return WatcherTypeEnum2;
|
|
7
8
|
})(WatcherTypeEnum || {});
|
|
8
9
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./index-
|
|
1
|
+
import{j as r}from"./index-XoJlyTFO.js";const d=({action:e})=>{const t={hit:"bg-green-100 text-green-800 dark:bg-green-600 dark:text-white",miss:"bg-amber-100 text-amber-800 dark:bg-amber-600 dark:text-white",write:"bg-blue-100 text-blue-800 dark:bg-blue-600 dark:text-white",delete:"bg-red-100 text-red-800 dark:bg-red-600 dark:text-white",clear:"bg-gray-100 text-gray-800 dark:bg-gray-600 dark:text-white"};return r.jsx("span",{className:`rounded px-2 py-1 text-sm font-semibold ${t[e]||t.clear}`,children:e})};export{d as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as a}from"./index-XoJlyTFO.js";import{L as s}from"./LoadMore-26PcNWcP.js";import{T as t}from"./Table-CGe8JwTO.js";import{g as r}from"./columns-BFxCubt5.js";import"./index-BRRKsoNv.js";import"./CacheActionBadge-3t8U516j.js";const p=({hasMoreObject:o})=>a.jsxs("div",{className:"w-full",children:[a.jsx("div",{className:"overflow-x-auto",children:a.jsx(t,{columns:r(),data:o.data})}),a.jsx(s,{paginatedPage:o})]});export{p as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CacheEntriesTable-BqLquILg.js","./index-XoJlyTFO.js","./index-BzFeZyjf.css","./LoadMore-26PcNWcP.js","./Table-CGe8JwTO.js","./columns-BFxCubt5.js","./index-BRRKsoNv.js","./CacheActionBadge-3t8U516j.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as t,j as a,_ as s}from"./index-XoJlyTFO.js";import{u as i}from"./useLoadMore-CksOcXOF.js";import{u as m}from"./useCacheEntries-SCADuxKq.js";import"./useLensApi-BYyiIIZR.js";const n=t.lazy(()=>s(()=>import("./CacheEntriesTable-BqLquILg.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url)),_=()=>{const{loadMoreItems:e,getItems:r}=m(),o=i({paginatedPage:e});return t.useEffect(()=>{r()},[]),a.jsx(n,{hasMoreObject:o})};export{_ as default};
|