nestlens 0.8.13 → 0.9.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/dist/api/content-encoding.d.ts +20 -0
- package/dist/api/content-encoding.js +92 -0
- package/dist/api/dashboard.controller.d.ts +37 -5
- package/dist/api/dashboard.controller.js +114 -28
- package/dist/api/route-path.js +19 -1
- package/dist/core/collector.service.js +6 -0
- package/dist/core/pruning.service.js +4 -1
- package/dist/core/storage/index.js +4 -3
- package/dist/core/storage/memory.storage.d.ts +2 -2
- package/dist/core/storage/memory.storage.js +5 -3
- package/dist/core/storage/redis.storage.d.ts +2 -2
- package/dist/core/storage/redis.storage.js +5 -3
- package/dist/core/storage/sqlite.storage.d.ts +23 -2
- package/dist/core/storage/sqlite.storage.js +59 -7
- package/dist/core/storage/storage.factory.js +26 -0
- package/dist/core/storage/tag-normalization.d.ts +10 -0
- package/dist/core/storage/tag-normalization.js +14 -0
- package/dist/core/tag.service.js +5 -2
- package/dist/dashboard/public/assets/BatchDetailView-D5HvA77t.js +1 -0
- package/dist/dashboard/public/assets/BatchesPage-DuRRA37y.js +1 -0
- package/dist/dashboard/public/assets/CacheDetailView-1UxogliV.js +6 -0
- package/dist/dashboard/public/assets/CachePage-BW4xXkPr.js +1 -0
- package/dist/dashboard/public/assets/CommandDetailView-BpgW7Td3.js +1 -0
- package/dist/dashboard/public/assets/CommandsPage-ds87Sc7B.js +1 -0
- package/dist/dashboard/public/assets/CopyButton-CVcLaHry.js +3 -0
- package/dist/dashboard/public/assets/{DashboardPage-BxTgQDmh.js → DashboardPage-DNHQ3XIO.js} +2 -2
- package/dist/dashboard/public/assets/DataTable-DBtrADsk.js +53 -0
- package/dist/dashboard/public/assets/DetailRow-C0vUMqsn.js +1 -0
- package/dist/dashboard/public/assets/DumpDetailView-DpIq0X3G.js +11 -0
- package/dist/dashboard/public/assets/DumpsPage-BEMRyaRD.js +1 -0
- package/dist/dashboard/public/assets/EntryDetailPage-CIQyW46e.js +27 -0
- package/dist/dashboard/public/assets/EntrySearchInput-_mfQ0GTh.js +1 -0
- package/dist/dashboard/public/assets/EventDetailView-P73VP_Fy.js +1 -0
- package/dist/dashboard/public/assets/EventsPage-CGVLTNsT.js +1 -0
- package/dist/dashboard/public/assets/ExceptionDetailView-BGARMi0L.js +8 -0
- package/dist/dashboard/public/assets/ExceptionsPage-D0QFk7Th.js +6 -0
- package/dist/dashboard/public/assets/GateDetailView-qlS8o8Vj.js +6 -0
- package/dist/dashboard/public/assets/GatesPage-DRAeMoww.js +1 -0
- package/dist/dashboard/public/assets/GraphQLDetailView-DxhebEpl.js +6 -0
- package/dist/dashboard/public/assets/GraphQLPage-DFvzS6gG.js +6 -0
- package/dist/dashboard/public/assets/HttpClientDetailView-Ce86dSVL.js +1 -0
- package/dist/dashboard/public/assets/HttpClientPage-DF8GOfV0.js +1 -0
- package/dist/dashboard/public/assets/JobDetailView-Ddwlj0Oz.js +6 -0
- package/dist/dashboard/public/assets/JobsPage-Bd0RuywX.js +1 -0
- package/dist/dashboard/public/assets/LogDetailView-C-TzEuYz.js +1 -0
- package/dist/dashboard/public/assets/LogsPage-BIKUhnPY.js +1 -0
- package/dist/dashboard/public/assets/MailDetailView-DTL0Ys2p.js +9 -0
- package/dist/dashboard/public/assets/MailPage-DFT9mR2h.js +1 -0
- package/dist/dashboard/public/assets/ModelDetailView-D3-lYlRT.js +1 -0
- package/dist/dashboard/public/assets/ModelsPage-C1020vlQ.js +1 -0
- package/dist/dashboard/public/assets/NotificationDetailView-D3SwDytA.js +1 -0
- package/dist/dashboard/public/assets/NotificationsPage-B9od-UaX.js +1 -0
- package/dist/dashboard/public/assets/PageHeader-D5AT-Mxc.js +1 -0
- package/dist/dashboard/public/assets/QueriesPage-DhewLYn5.js +1 -0
- package/dist/dashboard/public/assets/QueryDetailView-YBMinBib.js +29 -0
- package/dist/dashboard/public/assets/RedisDetailView-BRcONsdJ.js +1 -0
- package/dist/dashboard/public/assets/RedisPage-Bya5L8h1.js +1 -0
- package/dist/dashboard/public/assets/RequestDetailView-BY1-cZjR.js +1 -0
- package/dist/dashboard/public/assets/RequestsPage-DNnN4EV_.js +1 -0
- package/dist/dashboard/public/assets/ScheduleDetailView-Bm_xNamm.js +1 -0
- package/dist/dashboard/public/assets/SchedulePage-BPSF96Cq.js +1 -0
- package/dist/dashboard/public/assets/UserCard-BUmnN8l-.js +1 -0
- package/dist/dashboard/public/assets/ViewDetailView-DrMVO93F.js +1 -0
- package/dist/dashboard/public/assets/ViewsPage-CP7MTNTk.js +1 -0
- package/dist/dashboard/public/assets/badgeColors-DQ_P_DOX.js +1 -0
- package/dist/dashboard/public/assets/{calendar-DfnYRiPH.js → calendar-DaXjWGJG.js} +1 -1
- package/dist/dashboard/public/assets/circle-alert-BoSdc5v7.js +6 -0
- package/dist/dashboard/public/assets/{circle-check-big-CdzBeD3-.js → circle-check-big-pHbbgVmy.js} +1 -1
- package/dist/dashboard/public/assets/circle-x-CBdlQncP.js +6 -0
- package/dist/dashboard/public/assets/{eye-BwC2X41m.js → eye-RDdYWiOL.js} +1 -1
- package/dist/dashboard/public/assets/format-BlNP-apw.js +1 -0
- package/dist/dashboard/public/assets/index-B9BCPNKv.css +1 -0
- package/dist/dashboard/public/assets/index-DSn-BKqm.js +361 -0
- package/dist/dashboard/public/assets/{search-CyCRC3Aj.js → search-BZHB1sYK.js} +1 -1
- package/dist/dashboard/public/assets/send-CqQmINCf.js +6 -0
- package/dist/dashboard/public/assets/timer-ytyQLcvS.js +6 -0
- package/dist/dashboard/public/assets/types-Rt2vyU68.js +1 -0
- package/dist/dashboard/public/assets/users-CgFaJMH4.js +6 -0
- package/dist/dashboard/public/assets/{zap-yEefbKzX.js → zap-BHRzQYJO.js} +1 -1
- package/dist/dashboard/public/index.html +2 -2
- package/package.json +52 -11
- package/dist/dashboard/public/assets/BatchesPage-DEz38KR5.js +0 -1
- package/dist/dashboard/public/assets/CachePage-CZxLvTJq.js +0 -1
- package/dist/dashboard/public/assets/ClickableBadge-DVTcykCM.js +0 -1
- package/dist/dashboard/public/assets/CommandsPage-DnUHcHF_.js +0 -1
- package/dist/dashboard/public/assets/DumpsPage-DNXepzfv.js +0 -1
- package/dist/dashboard/public/assets/EntryDetailPage-0WBhBUsh.js +0 -126
- package/dist/dashboard/public/assets/EntrySearchInput-BKjIppvt.js +0 -1
- package/dist/dashboard/public/assets/EventsPage-xPiqDte_.js +0 -1
- package/dist/dashboard/public/assets/ExceptionsPage-ZJNqTX3Q.js +0 -6
- package/dist/dashboard/public/assets/GatesPage-CdvK6bSz.js +0 -1
- package/dist/dashboard/public/assets/GraphQLPage-DaLLpAf8.js +0 -6
- package/dist/dashboard/public/assets/HttpClientPage-e8BqONkc.js +0 -1
- package/dist/dashboard/public/assets/JobsPage-CjHsAC5o.js +0 -1
- package/dist/dashboard/public/assets/LogsPage-ny3e-b51.js +0 -1
- package/dist/dashboard/public/assets/MailPage-dpbs1DH3.js +0 -1
- package/dist/dashboard/public/assets/ModelsPage-DZaU9bdR.js +0 -1
- package/dist/dashboard/public/assets/NotificationsPage-xKjgSJyj.js +0 -1
- package/dist/dashboard/public/assets/PageHeader-yPvqJXYA.js +0 -1
- package/dist/dashboard/public/assets/QueriesPage-DsMLeBtH.js +0 -1
- package/dist/dashboard/public/assets/RedisPage-Daw6beWw.js +0 -1
- package/dist/dashboard/public/assets/RequestsPage-CDMXEx7M.js +0 -1
- package/dist/dashboard/public/assets/SchedulePage-CkbyutFW.js +0 -1
- package/dist/dashboard/public/assets/ViewsPage-B7fHFzy2.js +0 -1
- package/dist/dashboard/public/assets/format-PC0kH-TG.js +0 -1
- package/dist/dashboard/public/assets/index-DDZJvSAq.css +0 -1
- package/dist/dashboard/public/assets/index-jX7JpX7L.js +0 -361
- package/dist/dashboard/public/assets/types-C1scQJYx.js +0 -53
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** The encodings the dashboard can produce, best first. */
|
|
2
|
+
export type ContentEncoding = 'br' | 'gzip';
|
|
3
|
+
/**
|
|
4
|
+
* Below this, compression is a loss: the gzip and brotli framing costs tens of
|
|
5
|
+
* bytes, and a small body often comes back larger than it went in.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MIN_COMPRESSED_BYTES = 1024;
|
|
8
|
+
export declare const isCompressible: (contentType: string, byteLength: number) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Picks the encoding to answer with, or `undefined` for the bytes as they are.
|
|
11
|
+
*
|
|
12
|
+
* `q=0` is a refusal, not a weak preference — `gzip;q=0` means the client would
|
|
13
|
+
* rather have the file uncompressed, and a proxy that ignores that serves a body
|
|
14
|
+
* the client cannot read. `*` stands in for anything not named.
|
|
15
|
+
*
|
|
16
|
+
* An equal preference is broken in brotli's favour: at the quality used here it
|
|
17
|
+
* is both smaller and faster to produce than gzip.
|
|
18
|
+
*/
|
|
19
|
+
export declare const negotiateEncoding: (header?: string) => ContentEncoding | undefined;
|
|
20
|
+
export declare const compress: (payload: Buffer, encoding: ContentEncoding) => Promise<Buffer>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compress = exports.negotiateEncoding = exports.isCompressible = exports.MIN_COMPRESSED_BYTES = void 0;
|
|
4
|
+
const node_zlib_1 = require("node:zlib");
|
|
5
|
+
const node_util_1 = require("node:util");
|
|
6
|
+
const brotliAsync = (0, node_util_1.promisify)(node_zlib_1.brotliCompress);
|
|
7
|
+
const gzipAsync = (0, node_util_1.promisify)(node_zlib_1.gzip);
|
|
8
|
+
const SUPPORTED = ['br', 'gzip'];
|
|
9
|
+
/**
|
|
10
|
+
* Brotli quality, chosen by measurement rather than by the default.
|
|
11
|
+
*
|
|
12
|
+
* The largest bundled chunk (452 KB of JavaScript) compresses like this:
|
|
13
|
+
*
|
|
14
|
+
* gzip level 6 106.8 KB 9.0 ms
|
|
15
|
+
* brotli quality 4 103.7 KB 7.8 ms
|
|
16
|
+
* brotli quality 5 95.7 KB 5.8 ms ← chosen
|
|
17
|
+
* brotli quality 6 94.1 KB 9.8 ms
|
|
18
|
+
* brotli quality 11 84.8 KB 614.2 ms
|
|
19
|
+
*
|
|
20
|
+
* Quality 5 is smaller *and* faster than gzip; quality 11 buys another 11 KB for
|
|
21
|
+
* a hundredfold cost. NestLens runs inside the application it observes, so a
|
|
22
|
+
* measurable stall on first load is the one thing worth avoiding — and every
|
|
23
|
+
* compression here also runs off the event loop, on zlib's thread pool.
|
|
24
|
+
*/
|
|
25
|
+
const BROTLI_QUALITY = 5;
|
|
26
|
+
/**
|
|
27
|
+
* Below this, compression is a loss: the gzip and brotli framing costs tens of
|
|
28
|
+
* bytes, and a small body often comes back larger than it went in.
|
|
29
|
+
*/
|
|
30
|
+
exports.MIN_COMPRESSED_BYTES = 1024;
|
|
31
|
+
/**
|
|
32
|
+
* Types whose bytes still contain redundancy.
|
|
33
|
+
*
|
|
34
|
+
* Images, fonts and archives are already compressed by their own formats —
|
|
35
|
+
* running them through brotli spends CPU to produce something the same size or
|
|
36
|
+
* slightly bigger. WOFF2 in particular is brotli internally.
|
|
37
|
+
*/
|
|
38
|
+
const COMPRESSIBLE_TYPE = /^(?:text\/|application\/(?:javascript|json|manifest\+json)|image\/svg\+xml)/;
|
|
39
|
+
const isCompressible = (contentType, byteLength) => byteLength >= exports.MIN_COMPRESSED_BYTES && COMPRESSIBLE_TYPE.test(contentType);
|
|
40
|
+
exports.isCompressible = isCompressible;
|
|
41
|
+
/** `token;q=0.5, other` → `{ token: 0.5, other: 1 }`. */
|
|
42
|
+
const parsePreferences = (header) => {
|
|
43
|
+
const preferences = new Map();
|
|
44
|
+
for (const entry of header.split(',')) {
|
|
45
|
+
const [token, ...parameters] = entry.trim().split(';');
|
|
46
|
+
if (!token)
|
|
47
|
+
continue;
|
|
48
|
+
const quality = parameters
|
|
49
|
+
.map((parameter) => parameter.trim())
|
|
50
|
+
.find((parameter) => parameter.startsWith('q='));
|
|
51
|
+
const parsed = quality ? Number.parseFloat(quality.slice(2)) : 1;
|
|
52
|
+
preferences.set(token.trim().toLowerCase(), Number.isFinite(parsed) ? parsed : 0);
|
|
53
|
+
}
|
|
54
|
+
return preferences;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Picks the encoding to answer with, or `undefined` for the bytes as they are.
|
|
58
|
+
*
|
|
59
|
+
* `q=0` is a refusal, not a weak preference — `gzip;q=0` means the client would
|
|
60
|
+
* rather have the file uncompressed, and a proxy that ignores that serves a body
|
|
61
|
+
* the client cannot read. `*` stands in for anything not named.
|
|
62
|
+
*
|
|
63
|
+
* An equal preference is broken in brotli's favour: at the quality used here it
|
|
64
|
+
* is both smaller and faster to produce than gzip.
|
|
65
|
+
*/
|
|
66
|
+
const negotiateEncoding = (header) => {
|
|
67
|
+
if (!header)
|
|
68
|
+
return undefined;
|
|
69
|
+
const preferences = parsePreferences(header);
|
|
70
|
+
const wildcard = preferences.get('*');
|
|
71
|
+
const qualityOf = (encoding) => preferences.get(encoding) ?? wildcard ?? 0;
|
|
72
|
+
let best;
|
|
73
|
+
let bestQuality = 0;
|
|
74
|
+
for (const encoding of SUPPORTED) {
|
|
75
|
+
const quality = qualityOf(encoding);
|
|
76
|
+
if (quality > bestQuality) {
|
|
77
|
+
best = encoding;
|
|
78
|
+
bestQuality = quality;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return best;
|
|
82
|
+
};
|
|
83
|
+
exports.negotiateEncoding = negotiateEncoding;
|
|
84
|
+
const compress = (payload, encoding) => encoding === 'br'
|
|
85
|
+
? brotliAsync(payload, {
|
|
86
|
+
params: {
|
|
87
|
+
[node_zlib_1.constants.BROTLI_PARAM_QUALITY]: BROTLI_QUALITY,
|
|
88
|
+
[node_zlib_1.constants.BROTLI_PARAM_SIZE_HINT]: payload.length,
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
: gzipAsync(payload);
|
|
92
|
+
exports.compress = compress;
|
|
@@ -6,10 +6,30 @@ export declare class DashboardController {
|
|
|
6
6
|
private readonly httpAdapterHost;
|
|
7
7
|
private readonly dashboardPath;
|
|
8
8
|
private readonly fileCache;
|
|
9
|
+
/**
|
|
10
|
+
* Compressed asset bodies, keyed by file and encoding.
|
|
11
|
+
*
|
|
12
|
+
* Only files read off disk are cached here. `index.html` is rebuilt per
|
|
13
|
+
* request with the mount point injected, and under `trustProxy` that mount
|
|
14
|
+
* point comes from a header — caching by its value would let a caller grow
|
|
15
|
+
* this map without limit. It stays below the compression threshold anyway.
|
|
16
|
+
*/
|
|
17
|
+
private readonly compressedCache;
|
|
18
|
+
/** Bundled directories, listed once: the bundle cannot change while the process runs. */
|
|
19
|
+
private readonly directoryListings;
|
|
9
20
|
constructor(config: NestLensConfig, applicationConfig: ApplicationConfig, httpAdapterHost: HttpAdapterHost);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
/**
|
|
22
|
+
* What a bundled file may be called.
|
|
23
|
+
*
|
|
24
|
+
* Vite emits `index-Bu05f2IL.js`, `nestlens-icon.svg` and nothing stranger.
|
|
25
|
+
* Checking the name before it reaches `resolve()` means a traversal attempt
|
|
26
|
+
* never becomes a path at all — the containment check below stays as the
|
|
27
|
+
* second line, not the only one.
|
|
28
|
+
*/
|
|
29
|
+
private static readonly SAFE_FILENAME;
|
|
30
|
+
serveAssets(filename: string, res: unknown, acceptEncoding?: string): Promise<void>;
|
|
31
|
+
serveStaticFile(filename: string, res: unknown, acceptEncoding?: string): Promise<void>;
|
|
32
|
+
serveDashboard(res: unknown, forwarded?: string, acceptEncoding?: string): Promise<void>;
|
|
13
33
|
/**
|
|
14
34
|
* Every other path under the mount point belongs to the SPA's client-side
|
|
15
35
|
* router, so it gets index.html and React decides what to render — including
|
|
@@ -21,7 +41,7 @@ export declare class DashboardController {
|
|
|
21
41
|
* {@link SpaRouteRegistrar} replaces it with whichever form the adapter in use
|
|
22
42
|
* actually wants, before Nest resolves routes.
|
|
23
43
|
*/
|
|
24
|
-
serveSpaRoute(res: unknown, forwarded?: string): void
|
|
44
|
+
serveSpaRoute(res: unknown, forwarded?: string, acceptEncoding?: string): Promise<void>;
|
|
25
45
|
/**
|
|
26
46
|
* The dashboard bundle is built once but can be mounted anywhere, so the
|
|
27
47
|
* mount point is injected into `index.html` at request time: `<base>` resolves
|
|
@@ -29,7 +49,7 @@ export declare class DashboardController {
|
|
|
29
49
|
* SPA where to put its router basename and API calls.
|
|
30
50
|
*/
|
|
31
51
|
private sendIndexHtml;
|
|
32
|
-
private
|
|
52
|
+
private sendResolvedFile;
|
|
33
53
|
/**
|
|
34
54
|
* Reads a bundled file once and keeps it in memory.
|
|
35
55
|
*
|
|
@@ -52,6 +72,7 @@ export declare class DashboardController {
|
|
|
52
72
|
* response keeps NestLens's own surface out of that pipeline.
|
|
53
73
|
*/
|
|
54
74
|
private send;
|
|
75
|
+
private compressed;
|
|
55
76
|
/**
|
|
56
77
|
* Where the dashboard actually lives, from the browser's point of view.
|
|
57
78
|
*
|
|
@@ -68,6 +89,17 @@ export declare class DashboardController {
|
|
|
68
89
|
*/
|
|
69
90
|
private mountPoint;
|
|
70
91
|
private injectBasePath;
|
|
92
|
+
/**
|
|
93
|
+
* The name of a bundled file, or a 404.
|
|
94
|
+
*
|
|
95
|
+
* The request selects from what is on disk rather than describing a path: the
|
|
96
|
+
* directory is listed once, and the value returned here is the entry from
|
|
97
|
+
* that listing, not the string the caller sent. A traversal cannot be
|
|
98
|
+
* expressed, because nothing the caller writes is ever joined to a directory.
|
|
99
|
+
*
|
|
100
|
+
* The containment check below stays as the second line — this is the first.
|
|
101
|
+
*/
|
|
102
|
+
private bundledFile;
|
|
71
103
|
/**
|
|
72
104
|
* Resolve a path inside the dashboard directory, rejecting anything that
|
|
73
105
|
* escapes it (path traversal) or does not exist.
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
+
var DashboardController_1;
|
|
14
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
16
|
exports.DashboardController = void 0;
|
|
16
17
|
const common_1 = require("@nestjs/common");
|
|
@@ -20,8 +21,10 @@ const core_1 = require("@nestjs/core");
|
|
|
20
21
|
const nestlens_config_1 = require("../nestlens.config");
|
|
21
22
|
const api_guard_1 = require("./api.guard");
|
|
22
23
|
const route_path_1 = require("./route-path");
|
|
24
|
+
const content_encoding_1 = require("./content-encoding");
|
|
23
25
|
/** Set by reverse proxies that serve the application under a stripped path. */
|
|
24
26
|
const FORWARDED_PREFIX_HEADER = 'x-forwarded-prefix';
|
|
27
|
+
const ACCEPT_ENCODING_HEADER = 'accept-encoding';
|
|
25
28
|
/**
|
|
26
29
|
* Cache policies for the bundled dashboard.
|
|
27
30
|
*
|
|
@@ -61,24 +64,35 @@ const MIME_TYPES = {
|
|
|
61
64
|
};
|
|
62
65
|
// The prefix here is only the default; `NestLensModule.forRoot()` rewrites it
|
|
63
66
|
// from `config.path` before Nest resolves routes.
|
|
64
|
-
let DashboardController = class DashboardController {
|
|
67
|
+
let DashboardController = DashboardController_1 = class DashboardController {
|
|
65
68
|
constructor(config, applicationConfig, httpAdapterHost) {
|
|
66
69
|
this.config = config;
|
|
67
70
|
this.applicationConfig = applicationConfig;
|
|
68
71
|
this.httpAdapterHost = httpAdapterHost;
|
|
69
72
|
this.fileCache = new Map();
|
|
73
|
+
/**
|
|
74
|
+
* Compressed asset bodies, keyed by file and encoding.
|
|
75
|
+
*
|
|
76
|
+
* Only files read off disk are cached here. `index.html` is rebuilt per
|
|
77
|
+
* request with the mount point injected, and under `trustProxy` that mount
|
|
78
|
+
* point comes from a header — caching by its value would let a caller grow
|
|
79
|
+
* this map without limit. It stays below the compression threshold anyway.
|
|
80
|
+
*/
|
|
81
|
+
this.compressedCache = new Map();
|
|
82
|
+
/** Bundled directories, listed once: the bundle cannot change while the process runs. */
|
|
83
|
+
this.directoryListings = new Map();
|
|
70
84
|
// Dashboard static files are bundled in dist/dashboard/public
|
|
71
85
|
this.dashboardPath = (0, path_1.join)(__dirname, '..', 'dashboard', 'public');
|
|
72
86
|
}
|
|
73
|
-
serveAssets(filename, res) {
|
|
74
|
-
this.
|
|
87
|
+
serveAssets(filename, res, acceptEncoding) {
|
|
88
|
+
return this.sendResolvedFile(res, this.bundledFile('assets', filename, 'Asset not found'), IMMUTABLE, acceptEncoding);
|
|
75
89
|
}
|
|
76
90
|
// Favicon and other root-level static files.
|
|
77
|
-
serveStaticFile(filename, res) {
|
|
78
|
-
this.
|
|
91
|
+
serveStaticFile(filename, res, acceptEncoding) {
|
|
92
|
+
return this.sendResolvedFile(res, this.bundledFile('', `${filename}.svg`, 'File not found'), NO_CACHE, acceptEncoding);
|
|
79
93
|
}
|
|
80
|
-
serveDashboard(res, forwarded) {
|
|
81
|
-
this.sendIndexHtml(res, forwarded);
|
|
94
|
+
serveDashboard(res, forwarded, acceptEncoding) {
|
|
95
|
+
return this.sendIndexHtml(res, forwarded, acceptEncoding);
|
|
82
96
|
}
|
|
83
97
|
/**
|
|
84
98
|
* Every other path under the mount point belongs to the SPA's client-side
|
|
@@ -91,8 +105,8 @@ let DashboardController = class DashboardController {
|
|
|
91
105
|
* {@link SpaRouteRegistrar} replaces it with whichever form the adapter in use
|
|
92
106
|
* actually wants, before Nest resolves routes.
|
|
93
107
|
*/
|
|
94
|
-
serveSpaRoute(res, forwarded) {
|
|
95
|
-
this.sendIndexHtml(res, forwarded);
|
|
108
|
+
serveSpaRoute(res, forwarded, acceptEncoding) {
|
|
109
|
+
return this.sendIndexHtml(res, forwarded, acceptEncoding);
|
|
96
110
|
}
|
|
97
111
|
/**
|
|
98
112
|
* The dashboard bundle is built once but can be mounted anywhere, so the
|
|
@@ -100,14 +114,13 @@ let DashboardController = class DashboardController {
|
|
|
100
114
|
* the bundle's relative asset URLs, and `window.__NESTLENS_BASE__` tells the
|
|
101
115
|
* SPA where to put its router basename and API calls.
|
|
102
116
|
*/
|
|
103
|
-
sendIndexHtml(res, forwardedPrefix) {
|
|
117
|
+
sendIndexHtml(res, forwardedPrefix, acceptEncoding) {
|
|
104
118
|
const absolutePath = this.resolveDashboardFile('index.html', 'Dashboard not found');
|
|
105
119
|
const html = this.injectBasePath(this.readCached(absolutePath).toString('utf8'), forwardedPrefix);
|
|
106
|
-
this.send(res, html, MIME_TYPES['.html'], NO_CACHE);
|
|
120
|
+
return this.send(res, html, MIME_TYPES['.html'], NO_CACHE, acceptEncoding);
|
|
107
121
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.send(res, this.readCached(absolutePath), this.contentTypeFor(absolutePath), cacheControl);
|
|
122
|
+
sendResolvedFile(res, absolutePath, cacheControl, acceptEncoding) {
|
|
123
|
+
return this.send(res, this.readCached(absolutePath), this.contentTypeFor(absolutePath), cacheControl, acceptEncoding, absolutePath);
|
|
111
124
|
}
|
|
112
125
|
/**
|
|
113
126
|
* Reads a bundled file once and keeps it in memory.
|
|
@@ -125,9 +138,18 @@ let DashboardController = class DashboardController {
|
|
|
125
138
|
const cached = this.fileCache.get(absolutePath);
|
|
126
139
|
if (cached)
|
|
127
140
|
return cached;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
141
|
+
// A file that vanished after the listing was taken is a 404, not a 500:
|
|
142
|
+
// the bundle ships inside the package and is not supposed to move, but an
|
|
143
|
+
// upgrade that replaces it under a running process should not surface as a
|
|
144
|
+
// server error.
|
|
145
|
+
try {
|
|
146
|
+
const contents = (0, fs_1.readFileSync)(absolutePath);
|
|
147
|
+
this.fileCache.set(absolutePath, contents);
|
|
148
|
+
return contents;
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
throw new common_1.NotFoundException('File not found');
|
|
152
|
+
}
|
|
131
153
|
}
|
|
132
154
|
/**
|
|
133
155
|
* Writes the response directly instead of returning it.
|
|
@@ -137,17 +159,38 @@ let DashboardController = class DashboardController {
|
|
|
137
159
|
* this HTML into JSON — the dashboard then loads nothing. Taking over the
|
|
138
160
|
* response keeps NestLens's own surface out of that pipeline.
|
|
139
161
|
*/
|
|
140
|
-
send(res, body, contentType, cacheControl) {
|
|
162
|
+
async send(res, body, contentType, cacheControl, acceptEncoding, cacheKey) {
|
|
141
163
|
const adapter = this.httpAdapterHost.httpAdapter;
|
|
142
|
-
const
|
|
164
|
+
const raw = Buffer.isBuffer(body) ? body : Buffer.from(body, 'utf8');
|
|
165
|
+
const encoding = (0, content_encoding_1.isCompressible)(contentType, raw.length)
|
|
166
|
+
? (0, content_encoding_1.negotiateEncoding)(acceptEncoding)
|
|
167
|
+
: undefined;
|
|
168
|
+
const payload = encoding ? await this.compressed(raw, encoding, cacheKey) : raw;
|
|
143
169
|
adapter.setHeader(res, 'Content-Type', contentType);
|
|
144
170
|
adapter.setHeader(res, 'Cache-Control', cacheControl);
|
|
171
|
+
// Set whether or not this particular response was compressed: the body a
|
|
172
|
+
// shared cache stores depends on the request's Accept-Encoding either way,
|
|
173
|
+
// and `immutable` tells that cache to keep it for a year.
|
|
174
|
+
adapter.setHeader(res, 'Vary', 'Accept-Encoding');
|
|
175
|
+
if (encoding)
|
|
176
|
+
adapter.setHeader(res, 'Content-Encoding', encoding);
|
|
145
177
|
// A raw Buffer cannot go through `reply()`: Express treats any object as
|
|
146
178
|
// JSON and serialises it to `{"type":"Buffer","data":[...]}`, which turns
|
|
147
179
|
// every script and font into garbage. StreamableFile is the shape both
|
|
148
180
|
// adapters special-case for binary payloads.
|
|
149
181
|
adapter.reply(res, new common_1.StreamableFile(payload, { length: payload.length }), 200);
|
|
150
182
|
}
|
|
183
|
+
async compressed(raw, encoding, cacheKey) {
|
|
184
|
+
if (!cacheKey)
|
|
185
|
+
return (0, content_encoding_1.compress)(raw, encoding);
|
|
186
|
+
const key = `${cacheKey}|${encoding}`;
|
|
187
|
+
const cached = this.compressedCache.get(key);
|
|
188
|
+
if (cached)
|
|
189
|
+
return cached;
|
|
190
|
+
const compressedBody = await (0, content_encoding_1.compress)(raw, encoding);
|
|
191
|
+
this.compressedCache.set(key, compressedBody);
|
|
192
|
+
return compressedBody;
|
|
193
|
+
}
|
|
151
194
|
/**
|
|
152
195
|
* Where the dashboard actually lives, from the browser's point of view.
|
|
153
196
|
*
|
|
@@ -183,6 +226,36 @@ let DashboardController = class DashboardController {
|
|
|
183
226
|
`<script>window.__NESTLENS_BASE__=${JSON.stringify(baseHref)}</script>`;
|
|
184
227
|
return html.replace('<head>', `<head>${injection}`);
|
|
185
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* The name of a bundled file, or a 404.
|
|
231
|
+
*
|
|
232
|
+
* The request selects from what is on disk rather than describing a path: the
|
|
233
|
+
* directory is listed once, and the value returned here is the entry from
|
|
234
|
+
* that listing, not the string the caller sent. A traversal cannot be
|
|
235
|
+
* expressed, because nothing the caller writes is ever joined to a directory.
|
|
236
|
+
*
|
|
237
|
+
* The containment check below stays as the second line — this is the first.
|
|
238
|
+
*/
|
|
239
|
+
bundledFile(directory, filename, notFoundMessage) {
|
|
240
|
+
if (!DashboardController_1.SAFE_FILENAME.test(filename) || filename.includes('..')) {
|
|
241
|
+
throw new common_1.NotFoundException(notFoundMessage);
|
|
242
|
+
}
|
|
243
|
+
let listing = this.directoryListings.get(directory);
|
|
244
|
+
if (!listing) {
|
|
245
|
+
const root = (0, path_1.resolve)(this.dashboardPath);
|
|
246
|
+
const absoluteDirectory = directory === '' ? root : (0, path_1.join)(root, directory);
|
|
247
|
+
listing = new Map(((0, fs_1.existsSync)(absoluteDirectory) ? (0, fs_1.readdirSync)(absoluteDirectory) : []).map((name) => [
|
|
248
|
+
name,
|
|
249
|
+
(0, path_1.join)(absoluteDirectory, name),
|
|
250
|
+
]));
|
|
251
|
+
this.directoryListings.set(directory, listing);
|
|
252
|
+
}
|
|
253
|
+
const found = listing.get(filename);
|
|
254
|
+
if (!found) {
|
|
255
|
+
throw new common_1.NotFoundException(notFoundMessage);
|
|
256
|
+
}
|
|
257
|
+
return found;
|
|
258
|
+
}
|
|
186
259
|
/**
|
|
187
260
|
* Resolve a path inside the dashboard directory, rejecting anything that
|
|
188
261
|
* escapes it (path traversal) or does not exist.
|
|
@@ -203,39 +276,52 @@ let DashboardController = class DashboardController {
|
|
|
203
276
|
}
|
|
204
277
|
};
|
|
205
278
|
exports.DashboardController = DashboardController;
|
|
279
|
+
/**
|
|
280
|
+
* What a bundled file may be called.
|
|
281
|
+
*
|
|
282
|
+
* Vite emits `index-Bu05f2IL.js`, `nestlens-icon.svg` and nothing stranger.
|
|
283
|
+
* Checking the name before it reaches `resolve()` means a traversal attempt
|
|
284
|
+
* never becomes a path at all — the containment check below stays as the
|
|
285
|
+
* second line, not the only one.
|
|
286
|
+
*/
|
|
287
|
+
DashboardController.SAFE_FILENAME = /^[A-Za-z0-9._-]+$/;
|
|
206
288
|
__decorate([
|
|
207
289
|
(0, common_1.Get)('assets/:filename'),
|
|
208
290
|
__param(0, (0, common_1.Param)('filename')),
|
|
209
291
|
__param(1, (0, common_1.Res)()),
|
|
292
|
+
__param(2, (0, common_1.Headers)(ACCEPT_ENCODING_HEADER)),
|
|
210
293
|
__metadata("design:type", Function),
|
|
211
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
212
|
-
__metadata("design:returntype",
|
|
294
|
+
__metadata("design:paramtypes", [String, Object, String]),
|
|
295
|
+
__metadata("design:returntype", Promise)
|
|
213
296
|
], DashboardController.prototype, "serveAssets", null);
|
|
214
297
|
__decorate([
|
|
215
298
|
(0, common_1.Get)(':filename.svg'),
|
|
216
299
|
__param(0, (0, common_1.Param)('filename')),
|
|
217
300
|
__param(1, (0, common_1.Res)()),
|
|
301
|
+
__param(2, (0, common_1.Headers)(ACCEPT_ENCODING_HEADER)),
|
|
218
302
|
__metadata("design:type", Function),
|
|
219
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
220
|
-
__metadata("design:returntype",
|
|
303
|
+
__metadata("design:paramtypes", [String, Object, String]),
|
|
304
|
+
__metadata("design:returntype", Promise)
|
|
221
305
|
], DashboardController.prototype, "serveStaticFile", null);
|
|
222
306
|
__decorate([
|
|
223
307
|
(0, common_1.Get)(),
|
|
224
308
|
__param(0, (0, common_1.Res)()),
|
|
225
309
|
__param(1, (0, common_1.Headers)(FORWARDED_PREFIX_HEADER)),
|
|
310
|
+
__param(2, (0, common_1.Headers)(ACCEPT_ENCODING_HEADER)),
|
|
226
311
|
__metadata("design:type", Function),
|
|
227
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
228
|
-
__metadata("design:returntype",
|
|
312
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
313
|
+
__metadata("design:returntype", Promise)
|
|
229
314
|
], DashboardController.prototype, "serveDashboard", null);
|
|
230
315
|
__decorate([
|
|
231
316
|
(0, common_1.Get)('*'),
|
|
232
317
|
__param(0, (0, common_1.Res)()),
|
|
233
318
|
__param(1, (0, common_1.Headers)(FORWARDED_PREFIX_HEADER)),
|
|
319
|
+
__param(2, (0, common_1.Headers)(ACCEPT_ENCODING_HEADER)),
|
|
234
320
|
__metadata("design:type", Function),
|
|
235
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
236
|
-
__metadata("design:returntype",
|
|
321
|
+
__metadata("design:paramtypes", [Object, String, String]),
|
|
322
|
+
__metadata("design:returntype", Promise)
|
|
237
323
|
], DashboardController.prototype, "serveSpaRoute", null);
|
|
238
|
-
exports.DashboardController = DashboardController = __decorate([
|
|
324
|
+
exports.DashboardController = DashboardController = DashboardController_1 = __decorate([
|
|
239
325
|
(0, common_1.Controller)('nestlens'),
|
|
240
326
|
(0, common_1.UseGuards)(api_guard_1.NestLensGuard),
|
|
241
327
|
__param(0, (0, common_1.Inject)(nestlens_config_1.NESTLENS_CONFIG)),
|
package/dist/api/route-path.js
CHANGED
|
@@ -33,6 +33,15 @@ exports.toBaseHref = toBaseHref;
|
|
|
33
33
|
* needs cleaning is not one worth trusting.
|
|
34
34
|
*/
|
|
35
35
|
const SAFE_FORWARDED_PREFIX = /^\/[A-Za-z0-9\-._~/]*$/;
|
|
36
|
+
/**
|
|
37
|
+
* Longest header value worth examining.
|
|
38
|
+
*
|
|
39
|
+
* A mount prefix is a path segment or two; nothing legitimate approaches this.
|
|
40
|
+
* The cap exists because everything below runs on a value anyone can send, and
|
|
41
|
+
* a header can carry kilobytes: trimming and stripping trailing slashes on
|
|
42
|
+
* megabytes of input is work done on behalf of the sender.
|
|
43
|
+
*/
|
|
44
|
+
const MAX_FORWARDED_PREFIX_LENGTH = 256;
|
|
36
45
|
/**
|
|
37
46
|
* Normalizes an `X-Forwarded-Prefix` header into `/tools` form, or `''` when it
|
|
38
47
|
* is absent or unusable.
|
|
@@ -54,7 +63,16 @@ const toForwardedPrefix = (header) => {
|
|
|
54
63
|
// itself is not something to guess about.
|
|
55
64
|
if (typeof header !== 'string')
|
|
56
65
|
return '';
|
|
57
|
-
|
|
66
|
+
if (header.length > MAX_FORWARDED_PREFIX_LENGTH)
|
|
67
|
+
return '';
|
|
68
|
+
// Trailing slashes are stripped by index rather than by regex: `/\/+$/` walks
|
|
69
|
+
// backwards from every position on a value made of slashes, which is quadratic
|
|
70
|
+
// in the length of a header the caller chooses.
|
|
71
|
+
const trimmed = header.trim();
|
|
72
|
+
let end = trimmed.length;
|
|
73
|
+
while (end > 0 && trimmed[end - 1] === '/')
|
|
74
|
+
end -= 1;
|
|
75
|
+
const candidate = trimmed.slice(0, end);
|
|
58
76
|
if (candidate.length === 0)
|
|
59
77
|
return '';
|
|
60
78
|
if (!SAFE_FORWARDED_PREFIX.test(candidate))
|
|
@@ -315,6 +315,12 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
315
315
|
this.logger.error(`Flush timer error: ${err}`);
|
|
316
316
|
});
|
|
317
317
|
}, this.FLUSH_INTERVAL);
|
|
318
|
+
// A debugging tool must never be the reason a process stays alive. Without
|
|
319
|
+
// this the flush timer keeps Node's event loop open for as long as NestLens
|
|
320
|
+
// is loaded: an application that finishes its work waits forever, and so
|
|
321
|
+
// did the test suite — which is how a hung CI job billed six hours instead
|
|
322
|
+
// of failing.
|
|
323
|
+
this.flushTimer.unref?.();
|
|
318
324
|
}
|
|
319
325
|
/**
|
|
320
326
|
* Stop flush timer and flush remaining entries
|
|
@@ -53,8 +53,11 @@ let PruningService = PruningService_1 = class PruningService {
|
|
|
53
53
|
startPruning(intervalMinutes) {
|
|
54
54
|
// Run immediately on startup
|
|
55
55
|
this.prune();
|
|
56
|
-
// Then run on interval
|
|
56
|
+
// Then run on interval. Unreferenced for the same reason as the collector's
|
|
57
|
+
// flush timer: pruning is maintenance, and maintenance must not hold a
|
|
58
|
+
// process open.
|
|
57
59
|
this.intervalId = setInterval(() => this.prune(), intervalMinutes * 60 * 1000);
|
|
60
|
+
this.intervalId.unref?.();
|
|
58
61
|
}
|
|
59
62
|
async prune() {
|
|
60
63
|
const maxAgeHours = this.positiveOrDefault(this.config.pruning?.maxAge, 24, 'maxAge');
|
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "MemoryStorage", { enumerable: true, get: functio
|
|
|
29
29
|
// import { createStorage } from 'nestlens';
|
|
30
30
|
// const storage = await createStorage({ driver: 'sqlite' });
|
|
31
31
|
//
|
|
32
|
-
// Or import
|
|
33
|
-
//
|
|
34
|
-
// import {
|
|
32
|
+
// Or import the class from its own entry point, which is what the package's
|
|
33
|
+
// `exports` map publishes it as:
|
|
34
|
+
// import { SqliteStorage } from 'nestlens/storage/sqlite';
|
|
35
|
+
// import { RedisStorage } from 'nestlens/storage/redis';
|
|
@@ -37,8 +37,8 @@ export declare class MemoryStorage implements StorageInterface, OnModuleDestroy
|
|
|
37
37
|
getEntryTags(entryId: number): Promise<string[]>;
|
|
38
38
|
getAllTags(): Promise<TagWithCount[]>;
|
|
39
39
|
findByTags(tags: string[], logic?: 'AND' | 'OR', limit?: number): Promise<Entry[]>;
|
|
40
|
-
addMonitoredTag(
|
|
41
|
-
removeMonitoredTag(
|
|
40
|
+
addMonitoredTag(rawTag: string): Promise<MonitoredTag>;
|
|
41
|
+
removeMonitoredTag(rawTag: string): Promise<void>;
|
|
42
42
|
getMonitoredTags(): Promise<MonitoredTag[]>;
|
|
43
43
|
resolveEntry(id: number): Promise<void>;
|
|
44
44
|
unresolveEntry(id: number): Promise<void>;
|
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.MemoryStorage = void 0;
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
15
|
const entry_filter_1 = require("./entry-filter");
|
|
16
|
+
const tag_normalization_1 = require("./tag-normalization");
|
|
16
17
|
/**
|
|
17
18
|
* In-memory storage implementation for NestLens.
|
|
18
19
|
* Zero dependencies, works everywhere including Docker.
|
|
@@ -341,7 +342,8 @@ let MemoryStorage = MemoryStorage_1 = class MemoryStorage {
|
|
|
341
342
|
return this.hydrateEntriesWithTags(entries);
|
|
342
343
|
}
|
|
343
344
|
// ==================== Monitored Tags ====================
|
|
344
|
-
async addMonitoredTag(
|
|
345
|
+
async addMonitoredTag(rawTag) {
|
|
346
|
+
const tag = (0, tag_normalization_1.normalizeTag)(rawTag);
|
|
345
347
|
const existing = this.monitoredTags.get(tag);
|
|
346
348
|
if (existing) {
|
|
347
349
|
return existing;
|
|
@@ -354,8 +356,8 @@ let MemoryStorage = MemoryStorage_1 = class MemoryStorage {
|
|
|
354
356
|
this.monitoredTags.set(tag, monitored);
|
|
355
357
|
return monitored;
|
|
356
358
|
}
|
|
357
|
-
async removeMonitoredTag(
|
|
358
|
-
this.monitoredTags.delete(
|
|
359
|
+
async removeMonitoredTag(rawTag) {
|
|
360
|
+
this.monitoredTags.delete((0, tag_normalization_1.normalizeTag)(rawTag));
|
|
359
361
|
}
|
|
360
362
|
async getMonitoredTags() {
|
|
361
363
|
return Array.from(this.monitoredTags.values()).sort((a, b) => a.tag.localeCompare(b.tag));
|
|
@@ -51,8 +51,8 @@ export declare class RedisStorage implements StorageInterface, OnModuleDestroy {
|
|
|
51
51
|
getEntryTags(entryId: number): Promise<string[]>;
|
|
52
52
|
getAllTags(): Promise<TagWithCount[]>;
|
|
53
53
|
findByTags(tags: string[], logic?: 'AND' | 'OR', limit?: number): Promise<Entry[]>;
|
|
54
|
-
addMonitoredTag(
|
|
55
|
-
removeMonitoredTag(
|
|
54
|
+
addMonitoredTag(rawTag: string): Promise<MonitoredTag>;
|
|
55
|
+
removeMonitoredTag(rawTag: string): Promise<void>;
|
|
56
56
|
getMonitoredTags(): Promise<MonitoredTag[]>;
|
|
57
57
|
resolveEntry(id: number): Promise<void>;
|
|
58
58
|
unresolveEntry(id: number): Promise<void>;
|
|
@@ -46,6 +46,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
46
46
|
exports.RedisStorage = void 0;
|
|
47
47
|
const common_1 = require("@nestjs/common");
|
|
48
48
|
const entry_filter_1 = require("./entry-filter");
|
|
49
|
+
const tag_normalization_1 = require("./tag-normalization");
|
|
49
50
|
/**
|
|
50
51
|
* Redis storage implementation for NestLens.
|
|
51
52
|
* Requires ioredis to be installed.
|
|
@@ -544,7 +545,8 @@ let RedisStorage = RedisStorage_1 = class RedisStorage {
|
|
|
544
545
|
return this.hydrateEntriesWithTags(sorted);
|
|
545
546
|
}
|
|
546
547
|
// ==================== Monitored Tags ====================
|
|
547
|
-
async addMonitoredTag(
|
|
548
|
+
async addMonitoredTag(rawTag) {
|
|
549
|
+
const tag = (0, tag_normalization_1.normalizeTag)(rawTag);
|
|
548
550
|
const client = this.getClient();
|
|
549
551
|
const existing = await client.hget(this.key('monitored'), tag);
|
|
550
552
|
if (existing) {
|
|
@@ -559,9 +561,9 @@ let RedisStorage = RedisStorage_1 = class RedisStorage {
|
|
|
559
561
|
await client.hset(this.key('monitored'), tag, JSON.stringify(monitored));
|
|
560
562
|
return monitored;
|
|
561
563
|
}
|
|
562
|
-
async removeMonitoredTag(
|
|
564
|
+
async removeMonitoredTag(rawTag) {
|
|
563
565
|
const client = this.getClient();
|
|
564
|
-
await client.hdel(this.key('monitored'),
|
|
566
|
+
await client.hdel(this.key('monitored'), (0, tag_normalization_1.normalizeTag)(rawTag));
|
|
565
567
|
}
|
|
566
568
|
async getMonitoredTags() {
|
|
567
569
|
const client = this.getClient();
|
|
@@ -7,6 +7,17 @@ export declare class SqliteStorage implements StorageInterface, OnModuleInit, On
|
|
|
7
7
|
private db;
|
|
8
8
|
constructor(filename?: string);
|
|
9
9
|
onModuleInit(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Reads the schema version, and says so when the file is from the future.
|
|
12
|
+
*
|
|
13
|
+
* A SQLite file outlives the package that wrote it: it sits on disk across
|
|
14
|
+
* upgrades, and across downgrades. Migrating forward is handled by probing
|
|
15
|
+
* for missing columns, which is idempotent and needs no version — but that
|
|
16
|
+
* only ever adds. Nothing could tell that a file had been written by a newer
|
|
17
|
+
* NestLens, where a column this version has never heard of may be carrying
|
|
18
|
+
* meaning, and the entries would simply read back short.
|
|
19
|
+
*/
|
|
20
|
+
private readSchemaVersion;
|
|
10
21
|
private initializeDatabase;
|
|
11
22
|
private migrateDatabase;
|
|
12
23
|
initialize(): Promise<void>;
|
|
@@ -21,6 +32,16 @@ export declare class SqliteStorage implements StorageInterface, OnModuleInit, On
|
|
|
21
32
|
findById(id: number): Promise<Entry | null>;
|
|
22
33
|
count(type?: EntryType): Promise<number>;
|
|
23
34
|
getStats(): Promise<EntryStats>;
|
|
35
|
+
/**
|
|
36
|
+
* Both sides go through `datetime()` before they are compared.
|
|
37
|
+
*
|
|
38
|
+
* SQLite stores `CURRENT_TIMESTAMP` as `2026-08-12 21:55:45` and a JavaScript
|
|
39
|
+
* Date arrives as `2026-08-12T21:25:45.292Z`. Compared as text — which is
|
|
40
|
+
* what `created_at < ?` does — the eleventh character decides: a space sorts
|
|
41
|
+
* before a "T", so every row whose date is the cutoff's date or earlier reads
|
|
42
|
+
* as older than the cutoff whatever its time. Pruning anything therefore
|
|
43
|
+
* pruned everything recorded that day, including entries seconds old.
|
|
44
|
+
*/
|
|
24
45
|
prune(before: Date): Promise<number>;
|
|
25
46
|
pruneByType(type: EntryType, before: Date): Promise<number>;
|
|
26
47
|
/**
|
|
@@ -43,8 +64,8 @@ export declare class SqliteStorage implements StorageInterface, OnModuleInit, On
|
|
|
43
64
|
getEntryTags(entryId: number): Promise<string[]>;
|
|
44
65
|
getAllTags(): Promise<TagWithCount[]>;
|
|
45
66
|
findByTags(tags: string[], logic?: 'AND' | 'OR', limit?: number): Promise<Entry[]>;
|
|
46
|
-
addMonitoredTag(
|
|
47
|
-
removeMonitoredTag(
|
|
67
|
+
addMonitoredTag(rawTag: string): Promise<MonitoredTag>;
|
|
68
|
+
removeMonitoredTag(rawTag: string): Promise<void>;
|
|
48
69
|
getMonitoredTags(): Promise<MonitoredTag[]>;
|
|
49
70
|
resolveEntry(id: number): Promise<void>;
|
|
50
71
|
unresolveEntry(id: number): Promise<void>;
|