@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.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,21 +463,22 @@ 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}(/|$)`),
|
|
430
471
|
/^\/?lens-config$/,
|
|
472
|
+
/^\/?favicon\.ico$/,
|
|
431
473
|
/^\/\.well-known\//
|
|
432
474
|
];
|
|
433
475
|
return { ignoredPaths, normalizedPath };
|
|
434
476
|
}
|
|
435
|
-
function shouldIgnoreCurrentPath(
|
|
477
|
+
function shouldIgnoreCurrentPath(path4, ignoredPaths, onlyPaths) {
|
|
436
478
|
if (onlyPaths.length > 0) {
|
|
437
|
-
return !onlyPaths.some((pattern) => pattern.test(
|
|
479
|
+
return !onlyPaths.some((pattern) => pattern.test(path4));
|
|
438
480
|
}
|
|
439
|
-
return ignoredPaths.some((pattern) => pattern.test(
|
|
481
|
+
return ignoredPaths.some((pattern) => pattern.test(path4));
|
|
440
482
|
}
|
|
441
483
|
function prettyHrTime(hrtime, verbose = false) {
|
|
442
484
|
const seconds = hrtime[0];
|
|
@@ -520,6 +562,7 @@ var Lens = class {
|
|
|
520
562
|
requests: `/${config.basePath}/api/requests`,
|
|
521
563
|
queries: `/${config.basePath}/api/queries`,
|
|
522
564
|
cache: `/${config.basePath}/api/cache`,
|
|
565
|
+
exceptions: `/${config.basePath}/api/exceptions`,
|
|
523
566
|
truncate: `/${config.basePath}/api/truncate`
|
|
524
567
|
}
|
|
525
568
|
};
|
|
@@ -562,6 +605,16 @@ var Lens = class {
|
|
|
562
605
|
path: `${basePath}/api/cache/:id`,
|
|
563
606
|
handler: async (data) => await ApiController.getCacheEntry(data)
|
|
564
607
|
},
|
|
608
|
+
{
|
|
609
|
+
method: "GET",
|
|
610
|
+
path: `${basePath}/api/exceptions`,
|
|
611
|
+
handler: async (data) => await ApiController.getExceptions(data)
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
method: "GET",
|
|
615
|
+
path: `${basePath}/api/exceptions/:id`,
|
|
616
|
+
handler: async (data) => await ApiController.getException(data)
|
|
617
|
+
},
|
|
565
618
|
{
|
|
566
619
|
method: "DELETE",
|
|
567
620
|
path: `${basePath}/api/truncate`,
|
|
@@ -575,8 +628,8 @@ var Lens = class {
|
|
|
575
628
|
await store.initialize();
|
|
576
629
|
return store;
|
|
577
630
|
}
|
|
578
|
-
static normalizeDirName(
|
|
579
|
-
return
|
|
631
|
+
static normalizeDirName(path4) {
|
|
632
|
+
return path4.replace(/(\/packages\/)[^/]+(?=\/dist)/, "$1core");
|
|
580
633
|
}
|
|
581
634
|
};
|
|
582
635
|
|
|
@@ -642,23 +695,38 @@ var CacheWatcher = class extends Watcher {
|
|
|
642
695
|
});
|
|
643
696
|
}
|
|
644
697
|
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"] = "";
|
|
698
|
+
let key = "";
|
|
699
|
+
let value = "";
|
|
700
|
+
if ("data" in data && typeof data.data === "object" && data.data !== null) {
|
|
701
|
+
if ("key" in data.data) {
|
|
702
|
+
key = String(data.data.key);
|
|
703
|
+
}
|
|
704
|
+
if ("value" in data.data) {
|
|
705
|
+
value = data.data.value;
|
|
706
|
+
}
|
|
707
|
+
} else if (typeof data.data === "string") {
|
|
708
|
+
value = data.data;
|
|
660
709
|
}
|
|
661
|
-
return
|
|
710
|
+
return { key, value };
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
// src/watchers/exception_watcher.ts
|
|
715
|
+
var ExceptionWatcher = class extends Watcher {
|
|
716
|
+
name = "exception" /* EXCEPTION */;
|
|
717
|
+
async log(payload) {
|
|
718
|
+
await getStore().save({
|
|
719
|
+
id: generateRandomUuid(),
|
|
720
|
+
type: "exception" /* EXCEPTION */,
|
|
721
|
+
requestId: payload.requestId,
|
|
722
|
+
timestamp: payload.createdAt,
|
|
723
|
+
data: payload,
|
|
724
|
+
minimal_data: {
|
|
725
|
+
name: payload.name,
|
|
726
|
+
message: payload.message,
|
|
727
|
+
createdAt: payload.createdAt
|
|
728
|
+
}
|
|
729
|
+
});
|
|
662
730
|
}
|
|
663
731
|
};
|
|
664
732
|
|
|
@@ -682,11 +750,104 @@ var Adapter = class {
|
|
|
682
750
|
getWatchers() {
|
|
683
751
|
return this.watchers;
|
|
684
752
|
}
|
|
685
|
-
shouldIgnorePath(
|
|
686
|
-
return shouldIgnoreCurrentPath(
|
|
753
|
+
shouldIgnorePath(path4) {
|
|
754
|
+
return shouldIgnoreCurrentPath(path4, this.ignoredPaths, this.onlyPaths);
|
|
687
755
|
}
|
|
688
756
|
};
|
|
689
757
|
|
|
758
|
+
// src/utils/exception.ts
|
|
759
|
+
var exception_exports = {};
|
|
760
|
+
__export(exception_exports, {
|
|
761
|
+
cleanStack: () => cleanStack,
|
|
762
|
+
constructErrorObject: () => constructErrorObject,
|
|
763
|
+
extractCodeFrame: () => extractCodeFrame,
|
|
764
|
+
getFileInfo: () => getFileInfo,
|
|
765
|
+
getStackTrace: () => getStackTrace
|
|
766
|
+
});
|
|
767
|
+
var import_stack_utils = __toESM(require("stack-utils"), 1);
|
|
768
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
769
|
+
var import_node_fs = require("fs");
|
|
770
|
+
var import_date2 = require("@lensjs/date");
|
|
771
|
+
var stackUtils = new import_stack_utils.default({
|
|
772
|
+
cwd: process.cwd(),
|
|
773
|
+
internals: import_stack_utils.default.nodeInternals()
|
|
774
|
+
});
|
|
775
|
+
function cleanStack(stack) {
|
|
776
|
+
if (!stack) return "";
|
|
777
|
+
return stackUtils.clean(stack);
|
|
778
|
+
}
|
|
779
|
+
function getFileInfo(stack) {
|
|
780
|
+
if (!stack) {
|
|
781
|
+
return { file: "", line: 0, column: 0, function: "" };
|
|
782
|
+
}
|
|
783
|
+
const firstLine = stack.split("\n")[1] ?? "";
|
|
784
|
+
const fileInfo = stackUtils.parseLine(firstLine) ?? {
|
|
785
|
+
file: "",
|
|
786
|
+
line: 0,
|
|
787
|
+
column: 0,
|
|
788
|
+
function: ""
|
|
789
|
+
};
|
|
790
|
+
return {
|
|
791
|
+
file: fileInfo.file ? import_node_path.default.resolve(process.cwd(), fileInfo.file) : "",
|
|
792
|
+
line: fileInfo.line ?? 0,
|
|
793
|
+
column: fileInfo.column ?? 0,
|
|
794
|
+
function: fileInfo.function ?? ""
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
function getStackTrace(stack) {
|
|
798
|
+
if (!stack) return [];
|
|
799
|
+
return cleanStack(stack).split("\n").filter((frame) => Boolean(frame));
|
|
800
|
+
}
|
|
801
|
+
function extractCodeFrame({
|
|
802
|
+
file,
|
|
803
|
+
line,
|
|
804
|
+
column,
|
|
805
|
+
contextLines = 6
|
|
806
|
+
}) {
|
|
807
|
+
if (!file) return null;
|
|
808
|
+
const fullPath = import_node_path.default.isAbsolute(file) ? file : import_node_path.default.resolve(process.cwd(), file);
|
|
809
|
+
if (!(0, import_node_fs.existsSync)(fullPath)) return null;
|
|
810
|
+
const fileContent = (0, import_node_fs.readFileSync)(fullPath, "utf-8");
|
|
811
|
+
const lines = fileContent.split(/\r?\n/);
|
|
812
|
+
if (line < 1 || line > lines.length) return null;
|
|
813
|
+
const start = Math.max(0, line - 1 - contextLines);
|
|
814
|
+
const end = Math.min(lines.length, line - 1 + contextLines + 1);
|
|
815
|
+
const snippet = lines.slice(start, end);
|
|
816
|
+
const relativeLine = line - 1 - start;
|
|
817
|
+
const errorLine = lines[line - 1] ?? "";
|
|
818
|
+
return {
|
|
819
|
+
file: fullPath,
|
|
820
|
+
line,
|
|
821
|
+
column,
|
|
822
|
+
context: {
|
|
823
|
+
pre: snippet.slice(0, relativeLine),
|
|
824
|
+
error: errorLine,
|
|
825
|
+
post: snippet.slice(relativeLine + 1)
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function constructErrorObject(err) {
|
|
830
|
+
const fileInfo = getFileInfo(err.stack);
|
|
831
|
+
const codeFrame = extractCodeFrame({
|
|
832
|
+
file: fileInfo.file,
|
|
833
|
+
line: fileInfo.line,
|
|
834
|
+
column: fileInfo.column
|
|
835
|
+
});
|
|
836
|
+
return {
|
|
837
|
+
name: err.name,
|
|
838
|
+
message: err.message,
|
|
839
|
+
createdAt: (0, import_date2.nowISO)(),
|
|
840
|
+
fileInfo: {
|
|
841
|
+
file: fileInfo.file,
|
|
842
|
+
function: fileInfo.function
|
|
843
|
+
},
|
|
844
|
+
cause: err.cause ?? null,
|
|
845
|
+
trace: getStackTrace(err.stack),
|
|
846
|
+
codeFrame,
|
|
847
|
+
originalStack: codeFrame === null ? cleanStack(err.stack) : null
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
|
|
690
851
|
// src/utils/event_emitter.ts
|
|
691
852
|
var import_emittery = __toESM(require("emittery"), 1);
|
|
692
853
|
var createEmittery = () => {
|
|
@@ -697,10 +858,25 @@ var lensEmitter = createEmittery();
|
|
|
697
858
|
// src/utils/async_context.ts
|
|
698
859
|
var import_async_hooks = require("async_hooks");
|
|
699
860
|
var lensContext = new import_async_hooks.AsyncLocalStorage();
|
|
861
|
+
var handleUncaughExceptions = (logger) => {
|
|
862
|
+
process.on("uncaughtExceptionMonitor", async (err) => {
|
|
863
|
+
await logger.log({
|
|
864
|
+
...constructErrorObject(err),
|
|
865
|
+
requestId: lensContext.getStore()?.requestId
|
|
866
|
+
});
|
|
867
|
+
});
|
|
868
|
+
process.on("uncaughtException", async (err) => {
|
|
869
|
+
await logger.log({
|
|
870
|
+
...constructErrorObject(err),
|
|
871
|
+
requestId: lensContext.getStore()?.requestId
|
|
872
|
+
});
|
|
873
|
+
});
|
|
874
|
+
};
|
|
700
875
|
// Annotate the CommonJS export names for ESM import in node:
|
|
701
876
|
0 && (module.exports = {
|
|
702
877
|
BetterSqliteStore,
|
|
703
878
|
CacheWatcher,
|
|
879
|
+
ExceptionWatcher,
|
|
704
880
|
Lens,
|
|
705
881
|
LensAdapter,
|
|
706
882
|
LensStore,
|
|
@@ -710,7 +886,9 @@ var lensContext = new import_async_hooks.AsyncLocalStorage();
|
|
|
710
886
|
WatcherTypeEnum,
|
|
711
887
|
createEmittery,
|
|
712
888
|
getLensStore,
|
|
889
|
+
handleUncaughExceptions,
|
|
713
890
|
lensContext,
|
|
714
891
|
lensEmitter,
|
|
892
|
+
lensExceptionUtils,
|
|
715
893
|
lensUtils
|
|
716
894
|
});
|
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';
|