@lensjs/core 2.0.0 → 2.1.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.
- 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 +207 -29
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +204 -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-CK7JdKoE.js} +1 -1
- package/dist/ui/assets/CacheEntriesTable-C5HcgCZI.js +1 -0
- package/dist/ui/assets/CacheEntryContainer-C0no2_6_.js +2 -0
- package/dist/ui/assets/{CacheEntryDetails-CHt_pNTk.js → CacheEntryDetails-D9Xy7d9u.js} +1 -1
- package/dist/ui/assets/CacheEntryDetailsContainer-BcwliP55.js +2 -0
- package/dist/ui/assets/ExceptionContainer-CQalcd8x.js +2 -0
- package/dist/ui/assets/ExceptionDetails-BbIFoM7M.js +16 -0
- package/dist/ui/assets/ExceptionDetailsContainer-fajmF7id.js +2 -0
- package/dist/ui/assets/ExceptionTable-DY3mmGT4.js +1 -0
- package/dist/ui/assets/{LoadMore-DHOrhPsi.js → LoadMore-CJh7FLbl.js} +1 -1
- package/dist/ui/assets/QueriesContainer-DWTsKzEk.js +2 -0
- package/dist/ui/assets/{QueryDetailsContainer-eoLkgEjj.js → QueryDetailsContainer-7CA9a5de.js} +7 -7
- package/dist/ui/assets/{QueryTable-BXSzT-Cm.js → QueryTable-pn7Ayura.js} +1 -1
- package/dist/ui/assets/RequestDetails-CYSM4og8.js +1 -0
- package/dist/ui/assets/{RequestDetailsContainer-BaH6fUK7.js → RequestDetailsContainer-BECT0XJh.js} +2 -2
- package/dist/ui/assets/RequestsContainer-DLkjpX67.js +2 -0
- package/dist/ui/assets/{RequetsTable-B51VXisk.js → RequetsTable-Cgas07Fe.js} +1 -1
- package/dist/ui/assets/{StatusCode-DVhX11V3.js → StatusCode-C5lihzKZ.js} +1 -1
- package/dist/ui/assets/TabbedDataViewer-BUMQ0QVm.js +1 -0
- package/dist/ui/assets/{Table-D1Kpw7PA.js → Table-BesHc4Lc.js} +1 -1
- package/dist/ui/assets/columns-C1CwS8yE.js +1 -0
- package/dist/ui/assets/{columns-jYfhBxOM.js → columns-CULxhcpY.js} +1 -1
- package/dist/ui/assets/{columns-BIDLCW64.js → columns-gYFQU5qH.js} +1 -1
- package/dist/ui/assets/index-B2QCOgug.css +1 -0
- package/dist/ui/assets/{index-CpP2Ap5X.js → index-BRRKsoNv.js} +1 -1
- package/dist/ui/assets/{index-BdvbrZNf.js → index-PEcJ5nx0.js} +26 -21
- package/dist/ui/assets/{useCacheEntries-vuHEIj6E.js → useCacheEntries-jbGe2CRY.js} +1 -1
- package/dist/ui/assets/useExceptions-uYUhAW-J.js +1 -0
- package/dist/ui/assets/useLensApi-BsDmB7vx.js +1 -0
- package/dist/ui/assets/{useLoadMore-twYxPJ-d.js → useLoadMore-sLsrekV5.js} +1 -1
- package/dist/ui/assets/{useQueries-BYFLoUQR.js → useQueries-DJE91mYq.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/utils/index.cjs +1 -0
- package/dist/utils/index.js +1 -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,21 +417,22 @@ 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}(/|$)`),
|
|
387
425
|
/^\/?lens-config$/,
|
|
426
|
+
/^\/?favicon\.ico$/,
|
|
388
427
|
/^\/\.well-known\//
|
|
389
428
|
];
|
|
390
429
|
return { ignoredPaths, normalizedPath };
|
|
391
430
|
}
|
|
392
|
-
function shouldIgnoreCurrentPath(
|
|
431
|
+
function shouldIgnoreCurrentPath(path4, ignoredPaths, onlyPaths) {
|
|
393
432
|
if (onlyPaths.length > 0) {
|
|
394
|
-
return !onlyPaths.some((pattern) => pattern.test(
|
|
433
|
+
return !onlyPaths.some((pattern) => pattern.test(path4));
|
|
395
434
|
}
|
|
396
|
-
return ignoredPaths.some((pattern) => pattern.test(
|
|
435
|
+
return ignoredPaths.some((pattern) => pattern.test(path4));
|
|
397
436
|
}
|
|
398
437
|
function prettyHrTime(hrtime, verbose = false) {
|
|
399
438
|
const seconds = hrtime[0];
|
|
@@ -476,6 +515,7 @@ var Lens = class {
|
|
|
476
515
|
requests: `/${config.basePath}/api/requests`,
|
|
477
516
|
queries: `/${config.basePath}/api/queries`,
|
|
478
517
|
cache: `/${config.basePath}/api/cache`,
|
|
518
|
+
exceptions: `/${config.basePath}/api/exceptions`,
|
|
479
519
|
truncate: `/${config.basePath}/api/truncate`
|
|
480
520
|
}
|
|
481
521
|
};
|
|
@@ -518,6 +558,16 @@ var Lens = class {
|
|
|
518
558
|
path: `${basePath}/api/cache/:id`,
|
|
519
559
|
handler: async (data) => await ApiController.getCacheEntry(data)
|
|
520
560
|
},
|
|
561
|
+
{
|
|
562
|
+
method: "GET",
|
|
563
|
+
path: `${basePath}/api/exceptions`,
|
|
564
|
+
handler: async (data) => await ApiController.getExceptions(data)
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
method: "GET",
|
|
568
|
+
path: `${basePath}/api/exceptions/:id`,
|
|
569
|
+
handler: async (data) => await ApiController.getException(data)
|
|
570
|
+
},
|
|
521
571
|
{
|
|
522
572
|
method: "DELETE",
|
|
523
573
|
path: `${basePath}/api/truncate`,
|
|
@@ -531,8 +581,8 @@ var Lens = class {
|
|
|
531
581
|
await store.initialize();
|
|
532
582
|
return store;
|
|
533
583
|
}
|
|
534
|
-
static normalizeDirName(
|
|
535
|
-
return
|
|
584
|
+
static normalizeDirName(path4) {
|
|
585
|
+
return path4.replace(/(\/packages\/)[^/]+(?=\/dist)/, "$1core");
|
|
536
586
|
}
|
|
537
587
|
};
|
|
538
588
|
|
|
@@ -598,23 +648,38 @@ var CacheWatcher = class extends Watcher {
|
|
|
598
648
|
});
|
|
599
649
|
}
|
|
600
650
|
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"] = "";
|
|
651
|
+
let key = "";
|
|
652
|
+
let value = "";
|
|
653
|
+
if ("data" in data && typeof data.data === "object" && data.data !== null) {
|
|
654
|
+
if ("key" in data.data) {
|
|
655
|
+
key = String(data.data.key);
|
|
656
|
+
}
|
|
657
|
+
if ("value" in data.data) {
|
|
658
|
+
value = data.data.value;
|
|
659
|
+
}
|
|
660
|
+
} else if (typeof data.data === "string") {
|
|
661
|
+
value = data.data;
|
|
616
662
|
}
|
|
617
|
-
return
|
|
663
|
+
return { key, value };
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
// src/watchers/exception_watcher.ts
|
|
668
|
+
var ExceptionWatcher = class extends Watcher {
|
|
669
|
+
name = "exception" /* EXCEPTION */;
|
|
670
|
+
async log(payload) {
|
|
671
|
+
await getStore().save({
|
|
672
|
+
id: generateRandomUuid(),
|
|
673
|
+
type: "exception" /* EXCEPTION */,
|
|
674
|
+
requestId: payload.requestId,
|
|
675
|
+
timestamp: payload.createdAt,
|
|
676
|
+
data: payload,
|
|
677
|
+
minimal_data: {
|
|
678
|
+
name: payload.name,
|
|
679
|
+
message: payload.message,
|
|
680
|
+
createdAt: payload.createdAt
|
|
681
|
+
}
|
|
682
|
+
});
|
|
618
683
|
}
|
|
619
684
|
};
|
|
620
685
|
|
|
@@ -638,11 +703,104 @@ var Adapter = class {
|
|
|
638
703
|
getWatchers() {
|
|
639
704
|
return this.watchers;
|
|
640
705
|
}
|
|
641
|
-
shouldIgnorePath(
|
|
642
|
-
return shouldIgnoreCurrentPath(
|
|
706
|
+
shouldIgnorePath(path4) {
|
|
707
|
+
return shouldIgnoreCurrentPath(path4, this.ignoredPaths, this.onlyPaths);
|
|
643
708
|
}
|
|
644
709
|
};
|
|
645
710
|
|
|
711
|
+
// src/utils/exception.ts
|
|
712
|
+
var exception_exports = {};
|
|
713
|
+
__export(exception_exports, {
|
|
714
|
+
cleanStack: () => cleanStack,
|
|
715
|
+
constructErrorObject: () => constructErrorObject,
|
|
716
|
+
extractCodeFrame: () => extractCodeFrame,
|
|
717
|
+
getFileInfo: () => getFileInfo,
|
|
718
|
+
getStackTrace: () => getStackTrace
|
|
719
|
+
});
|
|
720
|
+
import StackUtils from "stack-utils";
|
|
721
|
+
import path3 from "path";
|
|
722
|
+
import { existsSync, readFileSync } from "fs";
|
|
723
|
+
import { nowISO as nowISO2 } from "@lensjs/date";
|
|
724
|
+
var stackUtils = new StackUtils({
|
|
725
|
+
cwd: process.cwd(),
|
|
726
|
+
internals: StackUtils.nodeInternals()
|
|
727
|
+
});
|
|
728
|
+
function cleanStack(stack) {
|
|
729
|
+
if (!stack) return "";
|
|
730
|
+
return stackUtils.clean(stack);
|
|
731
|
+
}
|
|
732
|
+
function getFileInfo(stack) {
|
|
733
|
+
if (!stack) {
|
|
734
|
+
return { file: "", line: 0, column: 0, function: "" };
|
|
735
|
+
}
|
|
736
|
+
const firstLine = stack.split("\n")[1] ?? "";
|
|
737
|
+
const fileInfo = stackUtils.parseLine(firstLine) ?? {
|
|
738
|
+
file: "",
|
|
739
|
+
line: 0,
|
|
740
|
+
column: 0,
|
|
741
|
+
function: ""
|
|
742
|
+
};
|
|
743
|
+
return {
|
|
744
|
+
file: fileInfo.file ? path3.resolve(process.cwd(), fileInfo.file) : "",
|
|
745
|
+
line: fileInfo.line ?? 0,
|
|
746
|
+
column: fileInfo.column ?? 0,
|
|
747
|
+
function: fileInfo.function ?? ""
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
function getStackTrace(stack) {
|
|
751
|
+
if (!stack) return [];
|
|
752
|
+
return cleanStack(stack).split("\n").filter((frame) => Boolean(frame));
|
|
753
|
+
}
|
|
754
|
+
function extractCodeFrame({
|
|
755
|
+
file,
|
|
756
|
+
line,
|
|
757
|
+
column,
|
|
758
|
+
contextLines = 6
|
|
759
|
+
}) {
|
|
760
|
+
if (!file) return null;
|
|
761
|
+
const fullPath = path3.isAbsolute(file) ? file : path3.resolve(process.cwd(), file);
|
|
762
|
+
if (!existsSync(fullPath)) return null;
|
|
763
|
+
const fileContent = readFileSync(fullPath, "utf-8");
|
|
764
|
+
const lines = fileContent.split(/\r?\n/);
|
|
765
|
+
if (line < 1 || line > lines.length) return null;
|
|
766
|
+
const start = Math.max(0, line - 1 - contextLines);
|
|
767
|
+
const end = Math.min(lines.length, line - 1 + contextLines + 1);
|
|
768
|
+
const snippet = lines.slice(start, end);
|
|
769
|
+
const relativeLine = line - 1 - start;
|
|
770
|
+
const errorLine = lines[line - 1] ?? "";
|
|
771
|
+
return {
|
|
772
|
+
file: fullPath,
|
|
773
|
+
line,
|
|
774
|
+
column,
|
|
775
|
+
context: {
|
|
776
|
+
pre: snippet.slice(0, relativeLine),
|
|
777
|
+
error: errorLine,
|
|
778
|
+
post: snippet.slice(relativeLine + 1)
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
function constructErrorObject(err) {
|
|
783
|
+
const fileInfo = getFileInfo(err.stack);
|
|
784
|
+
const codeFrame = extractCodeFrame({
|
|
785
|
+
file: fileInfo.file,
|
|
786
|
+
line: fileInfo.line,
|
|
787
|
+
column: fileInfo.column
|
|
788
|
+
});
|
|
789
|
+
return {
|
|
790
|
+
name: err.name,
|
|
791
|
+
message: err.message,
|
|
792
|
+
createdAt: nowISO2(),
|
|
793
|
+
fileInfo: {
|
|
794
|
+
file: fileInfo.file,
|
|
795
|
+
function: fileInfo.function
|
|
796
|
+
},
|
|
797
|
+
cause: err.cause ?? null,
|
|
798
|
+
trace: getStackTrace(err.stack),
|
|
799
|
+
codeFrame,
|
|
800
|
+
originalStack: codeFrame === null ? cleanStack(err.stack) : null
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
|
|
646
804
|
// src/utils/event_emitter.ts
|
|
647
805
|
import Emittery from "emittery";
|
|
648
806
|
var createEmittery = () => {
|
|
@@ -653,9 +811,24 @@ var lensEmitter = createEmittery();
|
|
|
653
811
|
// src/utils/async_context.ts
|
|
654
812
|
import { AsyncLocalStorage } from "async_hooks";
|
|
655
813
|
var lensContext = new AsyncLocalStorage();
|
|
814
|
+
var handleUncaughExceptions = (logger) => {
|
|
815
|
+
process.on("uncaughtExceptionMonitor", async (err) => {
|
|
816
|
+
await logger.log({
|
|
817
|
+
...constructErrorObject(err),
|
|
818
|
+
requestId: lensContext.getStore()?.requestId
|
|
819
|
+
});
|
|
820
|
+
});
|
|
821
|
+
process.on("uncaughtException", async (err) => {
|
|
822
|
+
await logger.log({
|
|
823
|
+
...constructErrorObject(err),
|
|
824
|
+
requestId: lensContext.getStore()?.requestId
|
|
825
|
+
});
|
|
826
|
+
});
|
|
827
|
+
};
|
|
656
828
|
export {
|
|
657
829
|
BetterSqliteStore,
|
|
658
830
|
CacheWatcher,
|
|
831
|
+
ExceptionWatcher,
|
|
659
832
|
Lens,
|
|
660
833
|
Adapter as LensAdapter,
|
|
661
834
|
Store as LensStore,
|
|
@@ -665,7 +838,9 @@ export {
|
|
|
665
838
|
WatcherTypeEnum,
|
|
666
839
|
createEmittery,
|
|
667
840
|
getStore as getLensStore,
|
|
841
|
+
handleUncaughExceptions,
|
|
668
842
|
lensContext,
|
|
669
843
|
lensEmitter,
|
|
844
|
+
exception_exports as lensExceptionUtils,
|
|
670
845
|
utils_exports as lensUtils
|
|
671
846
|
};
|
|
@@ -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-PEcJ5nx0.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-PEcJ5nx0.js";import{L as s}from"./LoadMore-CJh7FLbl.js";import{T as t}from"./Table-BesHc4Lc.js";import{g as r}from"./columns-gYFQU5qH.js";import"./index-BRRKsoNv.js";import"./CacheActionBadge-CK7JdKoE.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};
|