@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.cjs
CHANGED
|
@@ -32,6 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
BetterSqliteStore: () => BetterSqliteStore,
|
|
34
34
|
CacheWatcher: () => CacheWatcher,
|
|
35
|
+
ExceptionWatcher: () => ExceptionWatcher,
|
|
35
36
|
Lens: () => Lens,
|
|
36
37
|
LensAdapter: () => Adapter,
|
|
37
38
|
LensStore: () => Store,
|
|
@@ -41,8 +42,10 @@ __export(index_exports, {
|
|
|
41
42
|
WatcherTypeEnum: () => WatcherTypeEnum,
|
|
42
43
|
createEmittery: () => createEmittery,
|
|
43
44
|
getLensStore: () => getStore,
|
|
45
|
+
handleUncaughExceptions: () => handleUncaughExceptions,
|
|
44
46
|
lensContext: () => lensContext,
|
|
45
47
|
lensEmitter: () => lensEmitter,
|
|
48
|
+
lensExceptionUtils: () => exception_exports,
|
|
46
49
|
lensUtils: () => utils_exports
|
|
47
50
|
});
|
|
48
51
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -95,6 +98,7 @@ var WatcherTypeEnum = /* @__PURE__ */ ((WatcherTypeEnum2) => {
|
|
|
95
98
|
WatcherTypeEnum2["REQUEST"] = "request";
|
|
96
99
|
WatcherTypeEnum2["QUERY"] = "query";
|
|
97
100
|
WatcherTypeEnum2["CACHE"] = "cache";
|
|
101
|
+
WatcherTypeEnum2["EXCEPTION"] = "exception";
|
|
98
102
|
return WatcherTypeEnum2;
|
|
99
103
|
})(WatcherTypeEnum || {});
|
|
100
104
|
|
|
@@ -118,10 +122,16 @@ var ApiController = class {
|
|
|
118
122
|
request.id,
|
|
119
123
|
"cache" /* CACHE */
|
|
120
124
|
);
|
|
125
|
+
const exceptions = await getStore().allByRequestId(
|
|
126
|
+
request.id,
|
|
127
|
+
"exception" /* EXCEPTION */,
|
|
128
|
+
false
|
|
129
|
+
);
|
|
121
130
|
return this.resourceResponse({
|
|
122
131
|
request,
|
|
123
132
|
queries,
|
|
124
|
-
cacheEntries
|
|
133
|
+
cacheEntries,
|
|
134
|
+
exceptions
|
|
125
135
|
});
|
|
126
136
|
}
|
|
127
137
|
static async getQueries({
|
|
@@ -153,6 +163,21 @@ var ApiController = class {
|
|
|
153
163
|
}
|
|
154
164
|
return this.resourceResponse(cacheEntry);
|
|
155
165
|
}
|
|
166
|
+
static async getExceptions({ qs }) {
|
|
167
|
+
return this.paginatedResponse(
|
|
168
|
+
await getStore().getAllExceptions(this.extractPaginationParams(qs))
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
static async getException({ params }) {
|
|
172
|
+
const exception = await getStore().find(
|
|
173
|
+
"exception" /* EXCEPTION */,
|
|
174
|
+
params.id
|
|
175
|
+
);
|
|
176
|
+
if (!exception) {
|
|
177
|
+
return this.notFoundResponse();
|
|
178
|
+
}
|
|
179
|
+
return this.resourceResponse(exception);
|
|
180
|
+
}
|
|
156
181
|
static async truncate() {
|
|
157
182
|
await getStore().truncate();
|
|
158
183
|
return this.baseResponse({}, 200, "All entries cleared");
|
|
@@ -204,6 +229,9 @@ var path2 = __toESM(require("path"), 1);
|
|
|
204
229
|
|
|
205
230
|
// src/abstracts/store.ts
|
|
206
231
|
var Store = class {
|
|
232
|
+
getAllExceptions(_paginationParams) {
|
|
233
|
+
return this.defaultMinimalPaginate();
|
|
234
|
+
}
|
|
207
235
|
stringifyData(data) {
|
|
208
236
|
if (typeof data === "string") {
|
|
209
237
|
return data;
|
|
@@ -214,6 +242,16 @@ var Store = class {
|
|
|
214
242
|
console.error(`Failed to stringify lens data: ${e}`);
|
|
215
243
|
}
|
|
216
244
|
}
|
|
245
|
+
defaultMinimalPaginate() {
|
|
246
|
+
return Promise.resolve({
|
|
247
|
+
data: [],
|
|
248
|
+
meta: {
|
|
249
|
+
currentPage: 0,
|
|
250
|
+
lastPage: 0,
|
|
251
|
+
total: 0
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
217
255
|
};
|
|
218
256
|
|
|
219
257
|
// src/stores/better_sqlite.ts
|
|
@@ -252,11 +290,14 @@ var BetterSqliteStore = class extends Store {
|
|
|
252
290
|
async getAllCacheEntries(pagination) {
|
|
253
291
|
return await this.paginate("cache" /* CACHE */, pagination);
|
|
254
292
|
}
|
|
255
|
-
async
|
|
293
|
+
async getAllExceptions(pagination) {
|
|
294
|
+
return await this.paginate("exception" /* EXCEPTION */, pagination, false);
|
|
295
|
+
}
|
|
296
|
+
async allByRequestId(requestId, type, includeFullData = true) {
|
|
256
297
|
const rows = this.connection.prepare(
|
|
257
|
-
`${this.getSelectedColumns()} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
298
|
+
`${this.getSelectedColumns(includeFullData)} FROM ${TABLE_NAME} WHERE type = $type AND lens_entry_id = $requestId ORDER BY created_at DESC`
|
|
258
299
|
).all({ type, requestId });
|
|
259
|
-
return this.mapRows(rows);
|
|
300
|
+
return this.mapRows(rows, includeFullData);
|
|
260
301
|
}
|
|
261
302
|
async paginate(type, { page, perPage }, includeFullData = true) {
|
|
262
303
|
const offset = (page - 1) * perPage;
|
|
@@ -422,8 +463,8 @@ function stripBeforeAssetsPath(url) {
|
|
|
422
463
|
const match = url.match(/assets.*/);
|
|
423
464
|
return match ? match[0] : url;
|
|
424
465
|
}
|
|
425
|
-
function prepareIgnoredPaths(
|
|
426
|
-
const normalizedPath =
|
|
466
|
+
function prepareIgnoredPaths(path4, ignoredPaths) {
|
|
467
|
+
const normalizedPath = path4.replace(/^\/+|\/+$/g, "");
|
|
427
468
|
ignoredPaths = [
|
|
428
469
|
...ignoredPaths,
|
|
429
470
|
new RegExp(`^/?${normalizedPath}(/|$)`),
|
|
@@ -432,11 +473,11 @@ function prepareIgnoredPaths(path3, ignoredPaths) {
|
|
|
432
473
|
];
|
|
433
474
|
return { ignoredPaths, normalizedPath };
|
|
434
475
|
}
|
|
435
|
-
function shouldIgnoreCurrentPath(
|
|
476
|
+
function shouldIgnoreCurrentPath(path4, ignoredPaths, onlyPaths) {
|
|
436
477
|
if (onlyPaths.length > 0) {
|
|
437
|
-
return !onlyPaths.some((pattern) => pattern.test(
|
|
478
|
+
return !onlyPaths.some((pattern) => pattern.test(path4));
|
|
438
479
|
}
|
|
439
|
-
return ignoredPaths.some((pattern) => pattern.test(
|
|
480
|
+
return ignoredPaths.some((pattern) => pattern.test(path4));
|
|
440
481
|
}
|
|
441
482
|
function prettyHrTime(hrtime, verbose = false) {
|
|
442
483
|
const seconds = hrtime[0];
|
|
@@ -520,6 +561,7 @@ var Lens = class {
|
|
|
520
561
|
requests: `/${config.basePath}/api/requests`,
|
|
521
562
|
queries: `/${config.basePath}/api/queries`,
|
|
522
563
|
cache: `/${config.basePath}/api/cache`,
|
|
564
|
+
exceptions: `/${config.basePath}/api/exceptions`,
|
|
523
565
|
truncate: `/${config.basePath}/api/truncate`
|
|
524
566
|
}
|
|
525
567
|
};
|
|
@@ -562,6 +604,16 @@ var Lens = class {
|
|
|
562
604
|
path: `${basePath}/api/cache/:id`,
|
|
563
605
|
handler: async (data) => await ApiController.getCacheEntry(data)
|
|
564
606
|
},
|
|
607
|
+
{
|
|
608
|
+
method: "GET",
|
|
609
|
+
path: `${basePath}/api/exceptions`,
|
|
610
|
+
handler: async (data) => await ApiController.getExceptions(data)
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
method: "GET",
|
|
614
|
+
path: `${basePath}/api/exceptions/:id`,
|
|
615
|
+
handler: async (data) => await ApiController.getException(data)
|
|
616
|
+
},
|
|
565
617
|
{
|
|
566
618
|
method: "DELETE",
|
|
567
619
|
path: `${basePath}/api/truncate`,
|
|
@@ -575,8 +627,8 @@ var Lens = class {
|
|
|
575
627
|
await store.initialize();
|
|
576
628
|
return store;
|
|
577
629
|
}
|
|
578
|
-
static normalizeDirName(
|
|
579
|
-
return
|
|
630
|
+
static normalizeDirName(path4) {
|
|
631
|
+
return path4.replace(/(\/packages\/)[^/]+(?=\/dist)/, "$1core");
|
|
580
632
|
}
|
|
581
633
|
};
|
|
582
634
|
|
|
@@ -642,23 +694,38 @@ var CacheWatcher = class extends Watcher {
|
|
|
642
694
|
});
|
|
643
695
|
}
|
|
644
696
|
normalizePayload(data) {
|
|
645
|
-
let
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
value
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
normalizedData.key = "";
|
|
657
|
-
}
|
|
658
|
-
if (!normalizedData["value"]) {
|
|
659
|
-
normalizedData["value"] = "";
|
|
697
|
+
let key = "";
|
|
698
|
+
let value = "";
|
|
699
|
+
if ("data" in data && typeof data.data === "object" && data.data !== null) {
|
|
700
|
+
if ("key" in data.data) {
|
|
701
|
+
key = String(data.data.key);
|
|
702
|
+
}
|
|
703
|
+
if ("value" in data.data) {
|
|
704
|
+
value = data.data.value;
|
|
705
|
+
}
|
|
706
|
+
} else if (typeof data.data === "string") {
|
|
707
|
+
value = data.data;
|
|
660
708
|
}
|
|
661
|
-
return
|
|
709
|
+
return { key, value };
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
// src/watchers/exception_watcher.ts
|
|
714
|
+
var ExceptionWatcher = class extends Watcher {
|
|
715
|
+
name = "exception" /* EXCEPTION */;
|
|
716
|
+
async log(payload) {
|
|
717
|
+
await getStore().save({
|
|
718
|
+
id: generateRandomUuid(),
|
|
719
|
+
type: "exception" /* EXCEPTION */,
|
|
720
|
+
requestId: payload.requestId,
|
|
721
|
+
timestamp: payload.createdAt,
|
|
722
|
+
data: payload,
|
|
723
|
+
minimal_data: {
|
|
724
|
+
name: payload.name,
|
|
725
|
+
message: payload.message,
|
|
726
|
+
createdAt: payload.createdAt
|
|
727
|
+
}
|
|
728
|
+
});
|
|
662
729
|
}
|
|
663
730
|
};
|
|
664
731
|
|
|
@@ -682,11 +749,104 @@ var Adapter = class {
|
|
|
682
749
|
getWatchers() {
|
|
683
750
|
return this.watchers;
|
|
684
751
|
}
|
|
685
|
-
shouldIgnorePath(
|
|
686
|
-
return shouldIgnoreCurrentPath(
|
|
752
|
+
shouldIgnorePath(path4) {
|
|
753
|
+
return shouldIgnoreCurrentPath(path4, this.ignoredPaths, this.onlyPaths);
|
|
687
754
|
}
|
|
688
755
|
};
|
|
689
756
|
|
|
757
|
+
// src/utils/exception.ts
|
|
758
|
+
var exception_exports = {};
|
|
759
|
+
__export(exception_exports, {
|
|
760
|
+
cleanStack: () => cleanStack,
|
|
761
|
+
constructErrorObject: () => constructErrorObject,
|
|
762
|
+
extractCodeFrame: () => extractCodeFrame,
|
|
763
|
+
getFileInfo: () => getFileInfo,
|
|
764
|
+
getStackTrace: () => getStackTrace
|
|
765
|
+
});
|
|
766
|
+
var import_stack_utils = __toESM(require("stack-utils"), 1);
|
|
767
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
768
|
+
var import_node_fs = require("fs");
|
|
769
|
+
var import_date2 = require("@lensjs/date");
|
|
770
|
+
var stackUtils = new import_stack_utils.default({
|
|
771
|
+
cwd: process.cwd(),
|
|
772
|
+
internals: import_stack_utils.default.nodeInternals()
|
|
773
|
+
});
|
|
774
|
+
function cleanStack(stack) {
|
|
775
|
+
if (!stack) return "";
|
|
776
|
+
return stackUtils.clean(stack);
|
|
777
|
+
}
|
|
778
|
+
function getFileInfo(stack) {
|
|
779
|
+
if (!stack) {
|
|
780
|
+
return { file: "", line: 0, column: 0, function: "" };
|
|
781
|
+
}
|
|
782
|
+
const firstLine = stack.split("\n")[1] ?? "";
|
|
783
|
+
const fileInfo = stackUtils.parseLine(firstLine) ?? {
|
|
784
|
+
file: "",
|
|
785
|
+
line: 0,
|
|
786
|
+
column: 0,
|
|
787
|
+
function: ""
|
|
788
|
+
};
|
|
789
|
+
return {
|
|
790
|
+
file: fileInfo.file ? import_node_path.default.resolve(process.cwd(), fileInfo.file) : "",
|
|
791
|
+
line: fileInfo.line ?? 0,
|
|
792
|
+
column: fileInfo.column ?? 0,
|
|
793
|
+
function: fileInfo.function ?? ""
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
function getStackTrace(stack) {
|
|
797
|
+
if (!stack) return [];
|
|
798
|
+
return cleanStack(stack).split("\n").filter((frame) => Boolean(frame));
|
|
799
|
+
}
|
|
800
|
+
function extractCodeFrame({
|
|
801
|
+
file,
|
|
802
|
+
line,
|
|
803
|
+
column,
|
|
804
|
+
contextLines = 6
|
|
805
|
+
}) {
|
|
806
|
+
if (!file) return null;
|
|
807
|
+
const fullPath = import_node_path.default.isAbsolute(file) ? file : import_node_path.default.resolve(process.cwd(), file);
|
|
808
|
+
if (!(0, import_node_fs.existsSync)(fullPath)) return null;
|
|
809
|
+
const fileContent = (0, import_node_fs.readFileSync)(fullPath, "utf-8");
|
|
810
|
+
const lines = fileContent.split(/\r?\n/);
|
|
811
|
+
if (line < 1 || line > lines.length) return null;
|
|
812
|
+
const start = Math.max(0, line - 1 - contextLines);
|
|
813
|
+
const end = Math.min(lines.length, line - 1 + contextLines + 1);
|
|
814
|
+
const snippet = lines.slice(start, end);
|
|
815
|
+
const relativeLine = line - 1 - start;
|
|
816
|
+
const errorLine = lines[line - 1] ?? "";
|
|
817
|
+
return {
|
|
818
|
+
file: fullPath,
|
|
819
|
+
line,
|
|
820
|
+
column,
|
|
821
|
+
context: {
|
|
822
|
+
pre: snippet.slice(0, relativeLine),
|
|
823
|
+
error: errorLine,
|
|
824
|
+
post: snippet.slice(relativeLine + 1)
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function constructErrorObject(err) {
|
|
829
|
+
const fileInfo = getFileInfo(err.stack);
|
|
830
|
+
const codeFrame = extractCodeFrame({
|
|
831
|
+
file: fileInfo.file,
|
|
832
|
+
line: fileInfo.line,
|
|
833
|
+
column: fileInfo.column
|
|
834
|
+
});
|
|
835
|
+
return {
|
|
836
|
+
name: err.name,
|
|
837
|
+
message: err.message,
|
|
838
|
+
createdAt: (0, import_date2.nowISO)(),
|
|
839
|
+
fileInfo: {
|
|
840
|
+
file: fileInfo.file,
|
|
841
|
+
function: fileInfo.function
|
|
842
|
+
},
|
|
843
|
+
cause: err.cause ?? null,
|
|
844
|
+
trace: getStackTrace(err.stack),
|
|
845
|
+
codeFrame,
|
|
846
|
+
originalStack: codeFrame === null ? cleanStack(err.stack) : null
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
|
|
690
850
|
// src/utils/event_emitter.ts
|
|
691
851
|
var import_emittery = __toESM(require("emittery"), 1);
|
|
692
852
|
var createEmittery = () => {
|
|
@@ -697,10 +857,25 @@ var lensEmitter = createEmittery();
|
|
|
697
857
|
// src/utils/async_context.ts
|
|
698
858
|
var import_async_hooks = require("async_hooks");
|
|
699
859
|
var lensContext = new import_async_hooks.AsyncLocalStorage();
|
|
860
|
+
var handleUncaughExceptions = (logger) => {
|
|
861
|
+
process.on("uncaughtExceptionMonitor", async (err) => {
|
|
862
|
+
await logger.log({
|
|
863
|
+
...constructErrorObject(err),
|
|
864
|
+
requestId: lensContext.getStore()?.requestId
|
|
865
|
+
});
|
|
866
|
+
});
|
|
867
|
+
process.on("uncaughtException", async (err) => {
|
|
868
|
+
await logger.log({
|
|
869
|
+
...constructErrorObject(err),
|
|
870
|
+
requestId: lensContext.getStore()?.requestId
|
|
871
|
+
});
|
|
872
|
+
});
|
|
873
|
+
};
|
|
700
874
|
// Annotate the CommonJS export names for ESM import in node:
|
|
701
875
|
0 && (module.exports = {
|
|
702
876
|
BetterSqliteStore,
|
|
703
877
|
CacheWatcher,
|
|
878
|
+
ExceptionWatcher,
|
|
704
879
|
Lens,
|
|
705
880
|
LensAdapter,
|
|
706
881
|
LensStore,
|
|
@@ -710,7 +885,9 @@ var lensContext = new import_async_hooks.AsyncLocalStorage();
|
|
|
710
885
|
WatcherTypeEnum,
|
|
711
886
|
createEmittery,
|
|
712
887
|
getLensStore,
|
|
888
|
+
handleUncaughExceptions,
|
|
713
889
|
lensContext,
|
|
714
890
|
lensEmitter,
|
|
891
|
+
lensExceptionUtils,
|
|
715
892
|
lensUtils
|
|
716
893
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -3,14 +3,16 @@ export { default as BetterSqliteStore } from './stores/better_sqlite.cjs';
|
|
|
3
3
|
export { default as QueryWatcher } from './watchers/query_watcher.cjs';
|
|
4
4
|
export { default as RequestWatcher } from './watchers/request_watcher.cjs';
|
|
5
5
|
export { default as CacheWatcher } from './watchers/cache_watcher.cjs';
|
|
6
|
-
export {
|
|
6
|
+
export { default as ExceptionWatcher } from './watchers/exception_watcher.cjs';
|
|
7
|
+
export { ApiResponse, CacheAction, CacheEntry, Entry, ExceptionEntry, HttpMethod, LensConfig, LensEntry, PaginationParams, Paginator, QueryEntry, QueryType, RequestEntry, RouteDefinition, RouteDefinitionHandler, RouteHttpMethod, SqlQueryType, UserEntry, WatcherTypeEnum } from './types/index.cjs';
|
|
7
8
|
export { default as LensAdapter } from './abstracts/adapter.cjs';
|
|
8
9
|
export { default as LensStore } from './abstracts/store.cjs';
|
|
9
10
|
export { default as LensWatcher } from './core/watcher.cjs';
|
|
10
11
|
export { getStore as getLensStore } from './context/context.cjs';
|
|
11
12
|
export { i as lensUtils } from './index-DiLfwsvc.cjs';
|
|
13
|
+
export { e as lensExceptionUtils } from './exception-C69UCHPk.cjs';
|
|
12
14
|
export { createEmittery, lensEmitter } from './utils/event_emitter.cjs';
|
|
13
|
-
export { lensContext } from './utils/async_context.cjs';
|
|
15
|
+
export { handleUncaughExceptions, lensContext } from './utils/async_context.cjs';
|
|
14
16
|
import 'libsql';
|
|
15
17
|
import 'sql-formatter';
|
|
16
18
|
import 'emittery';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,14 +3,16 @@ export { default as BetterSqliteStore } from './stores/better_sqlite.js';
|
|
|
3
3
|
export { default as QueryWatcher } from './watchers/query_watcher.js';
|
|
4
4
|
export { default as RequestWatcher } from './watchers/request_watcher.js';
|
|
5
5
|
export { default as CacheWatcher } from './watchers/cache_watcher.js';
|
|
6
|
-
export {
|
|
6
|
+
export { default as ExceptionWatcher } from './watchers/exception_watcher.js';
|
|
7
|
+
export { ApiResponse, CacheAction, CacheEntry, Entry, ExceptionEntry, HttpMethod, LensConfig, LensEntry, PaginationParams, Paginator, QueryEntry, QueryType, RequestEntry, RouteDefinition, RouteDefinitionHandler, RouteHttpMethod, SqlQueryType, UserEntry, WatcherTypeEnum } from './types/index.js';
|
|
7
8
|
export { default as LensAdapter } from './abstracts/adapter.js';
|
|
8
9
|
export { default as LensStore } from './abstracts/store.js';
|
|
9
10
|
export { default as LensWatcher } from './core/watcher.js';
|
|
10
11
|
export { getStore as getLensStore } from './context/context.js';
|
|
11
12
|
export { i as lensUtils } from './index-DiLfwsvc.js';
|
|
13
|
+
export { e as lensExceptionUtils } from './exception-3AZsPtAg.js';
|
|
12
14
|
export { createEmittery, lensEmitter } from './utils/event_emitter.js';
|
|
13
|
-
export { lensContext } from './utils/async_context.js';
|
|
15
|
+
export { handleUncaughExceptions, lensContext } from './utils/async_context.js';
|
|
14
16
|
import 'libsql';
|
|
15
17
|
import 'sql-formatter';
|
|
16
18
|
import 'emittery';
|