nestlens 0.8.12 → 0.9.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/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/dto/api-response.dto.d.ts +0 -8
- package/dist/api/dto/api-response.dto.js +0 -33
- package/dist/api/dto/cursor-query.dto.d.ts +5 -0
- package/dist/api/dto/cursor-query.dto.js +1 -0
- package/dist/api/dto/index.d.ts +0 -2
- package/dist/api/dto/index.js +0 -2
- package/dist/api/dto/transformers/query-transformers.d.ts +0 -4
- package/dist/api/dto/transformers/query-transformers.js +0 -7
- package/dist/api/dto/transformers/query-validators.d.ts +12 -0
- package/dist/api/dto/transformers/query-validators.js +22 -5
- package/dist/api/route-path.js +19 -1
- package/dist/core/collector.service.d.ts +12 -1
- package/dist/core/collector.service.js +37 -5
- package/dist/core/data-masker.service.d.ts +10 -0
- package/dist/core/data-masker.service.js +8 -1
- 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-D8PKMRJK.js +1 -0
- package/dist/dashboard/public/assets/BatchesPage-DT5Mywoo.js +1 -0
- package/dist/dashboard/public/assets/CacheDetailView-BKg5s6do.js +6 -0
- package/dist/dashboard/public/assets/CachePage-Dv0sIWfb.js +1 -0
- package/dist/dashboard/public/assets/CommandDetailView-34Fp3Zse.js +1 -0
- package/dist/dashboard/public/assets/CommandsPage-DfJBmcAu.js +1 -0
- package/dist/dashboard/public/assets/CopyButton-CVTvd0EZ.js +3 -0
- package/dist/dashboard/public/assets/{DashboardPage-DF6wLAIo.js → DashboardPage-Bl0QYNJ5.js} +2 -2
- package/dist/dashboard/public/assets/DataTable-DNJpoFzh.js +53 -0
- package/dist/dashboard/public/assets/DetailRow-CouZ8riB.js +1 -0
- package/dist/dashboard/public/assets/DumpDetailView-B6-Nre38.js +11 -0
- package/dist/dashboard/public/assets/DumpsPage-Cd0B4s9o.js +1 -0
- package/dist/dashboard/public/assets/EntryDetailPage-QTrST2MQ.js +27 -0
- package/dist/dashboard/public/assets/EntrySearchInput-DqIRbpja.js +1 -0
- package/dist/dashboard/public/assets/EventDetailView-2SmuXgrJ.js +1 -0
- package/dist/dashboard/public/assets/EventsPage-DCpLnIob.js +1 -0
- package/dist/dashboard/public/assets/ExceptionDetailView-DxGim-Jg.js +8 -0
- package/dist/dashboard/public/assets/ExceptionsPage-Qa60iwA4.js +6 -0
- package/dist/dashboard/public/assets/GateDetailView-DFVtRPBk.js +6 -0
- package/dist/dashboard/public/assets/GatesPage-DHGIZzbG.js +1 -0
- package/dist/dashboard/public/assets/GraphQLDetailView-DvHekddm.js +6 -0
- package/dist/dashboard/public/assets/GraphQLPage-Cft-KFpI.js +6 -0
- package/dist/dashboard/public/assets/HttpClientDetailView-qU0JPxsC.js +1 -0
- package/dist/dashboard/public/assets/HttpClientPage-Kxa5nm75.js +1 -0
- package/dist/dashboard/public/assets/JobDetailView-BfAICIc4.js +6 -0
- package/dist/dashboard/public/assets/JobsPage-BpBk0bYd.js +1 -0
- package/dist/dashboard/public/assets/LogDetailView-CdSLEf4Q.js +1 -0
- package/dist/dashboard/public/assets/LogsPage-CaCtKQZ0.js +1 -0
- package/dist/dashboard/public/assets/MailDetailView-BiBUkOXW.js +9 -0
- package/dist/dashboard/public/assets/MailPage-DAkydOVp.js +1 -0
- package/dist/dashboard/public/assets/ModelDetailView-CXCgDnpy.js +1 -0
- package/dist/dashboard/public/assets/ModelsPage-BwK3r0-I.js +1 -0
- package/dist/dashboard/public/assets/NotificationDetailView-Bljgzgiz.js +1 -0
- package/dist/dashboard/public/assets/NotificationsPage-DMGpuTU-.js +1 -0
- package/dist/dashboard/public/assets/PageHeader-BAc6Jvef.js +1 -0
- package/dist/dashboard/public/assets/QueriesPage-DPls44cD.js +1 -0
- package/dist/dashboard/public/assets/QueryDetailView-BEwgxDtv.js +29 -0
- package/dist/dashboard/public/assets/RedisDetailView-Ds3Hzc8m.js +1 -0
- package/dist/dashboard/public/assets/RedisPage-DhAhXwAd.js +1 -0
- package/dist/dashboard/public/assets/RequestDetailView-BwTcMKOH.js +1 -0
- package/dist/dashboard/public/assets/RequestsPage-CIHqEF5P.js +1 -0
- package/dist/dashboard/public/assets/ScheduleDetailView-2RmRtcvM.js +1 -0
- package/dist/dashboard/public/assets/SchedulePage-D3MuXtV1.js +1 -0
- package/dist/dashboard/public/assets/UserCard-Cbu0ICp6.js +1 -0
- package/dist/dashboard/public/assets/ViewDetailView-rCONPvjG.js +1 -0
- package/dist/dashboard/public/assets/ViewsPage-CW5aN_D5.js +1 -0
- package/dist/dashboard/public/assets/badgeColors-DQ_P_DOX.js +1 -0
- package/dist/dashboard/public/assets/{calendar-DOXgQvoy.js → calendar-DcK1CETU.js} +1 -1
- package/dist/dashboard/public/assets/circle-alert-CgZfn5uS.js +6 -0
- package/dist/dashboard/public/assets/{circle-check-big-Bs8iwE6r.js → circle-check-big-1S8vooWx.js} +1 -1
- package/dist/dashboard/public/assets/circle-x-BOe5goDy.js +6 -0
- package/dist/dashboard/public/assets/{eye-BjAVlTOb.js → eye-PnSIQ7GH.js} +1 -1
- package/dist/dashboard/public/assets/index-B9BCPNKv.css +1 -0
- package/dist/dashboard/public/assets/index-DyvNu-oR.js +361 -0
- package/dist/dashboard/public/assets/{search-0RwEOnAF.js → search-D9V4itpU.js} +1 -1
- package/dist/dashboard/public/assets/send-DOt7lNQl.js +6 -0
- package/dist/dashboard/public/assets/timer-CZxO8Y_Q.js +6 -0
- package/dist/dashboard/public/assets/types-DZUckfsW.js +1 -0
- package/dist/dashboard/public/assets/users-9cJRsfQV.js +6 -0
- package/dist/dashboard/public/assets/{zap-ozodPZ3e.js → zap-B0E2zzJ8.js} +1 -1
- package/dist/dashboard/public/index.html +2 -2
- package/dist/nestlens.config.d.ts +0 -13
- package/dist/nestlens.module.js +13 -0
- package/dist/watchers/query/types.d.ts +0 -5
- package/dist/watchers/query/types.js +0 -13
- package/package.json +51 -10
- package/dist/api/dto/filters/batch-filters.dto.d.ts +0 -4
- package/dist/api/dto/filters/batch-filters.dto.js +0 -31
- package/dist/api/dto/filters/cache-filters.dto.d.ts +0 -3
- package/dist/api/dto/filters/cache-filters.dto.js +0 -24
- package/dist/api/dto/filters/command-filters.dto.d.ts +0 -4
- package/dist/api/dto/filters/command-filters.dto.js +0 -31
- package/dist/api/dto/filters/common-filters.dto.d.ts +0 -4
- package/dist/api/dto/filters/common-filters.dto.js +0 -29
- package/dist/api/dto/filters/dump-filters.dto.d.ts +0 -5
- package/dist/api/dto/filters/dump-filters.dto.js +0 -38
- package/dist/api/dto/filters/event-filters.dto.d.ts +0 -3
- package/dist/api/dto/filters/event-filters.dto.js +0 -24
- package/dist/api/dto/filters/exception-filters.dto.d.ts +0 -4
- package/dist/api/dto/filters/exception-filters.dto.js +0 -30
- package/dist/api/dto/filters/gate-filters.dto.d.ts +0 -4
- package/dist/api/dto/filters/gate-filters.dto.js +0 -31
- package/dist/api/dto/filters/graphql-filters.dto.d.ts +0 -6
- package/dist/api/dto/filters/graphql-filters.dto.js +0 -43
- package/dist/api/dto/filters/http-client-filters.dto.d.ts +0 -6
- package/dist/api/dto/filters/http-client-filters.dto.js +0 -10
- package/dist/api/dto/filters/index.d.ts +0 -20
- package/dist/api/dto/filters/index.js +0 -36
- package/dist/api/dto/filters/job-filters.dto.d.ts +0 -5
- package/dist/api/dto/filters/job-filters.dto.js +0 -38
- package/dist/api/dto/filters/log-filters.dto.d.ts +0 -4
- package/dist/api/dto/filters/log-filters.dto.js +0 -31
- package/dist/api/dto/filters/mail-filters.dto.d.ts +0 -3
- package/dist/api/dto/filters/mail-filters.dto.js +0 -24
- package/dist/api/dto/filters/model-filters.dto.d.ts +0 -5
- package/dist/api/dto/filters/model-filters.dto.js +0 -38
- package/dist/api/dto/filters/notification-filters.dto.d.ts +0 -4
- package/dist/api/dto/filters/notification-filters.dto.js +0 -31
- package/dist/api/dto/filters/query-filters.dto.d.ts +0 -5
- package/dist/api/dto/filters/query-filters.dto.js +0 -37
- package/dist/api/dto/filters/redis-filters.dto.d.ts +0 -4
- package/dist/api/dto/filters/redis-filters.dto.js +0 -31
- package/dist/api/dto/filters/request-filters.dto.d.ts +0 -8
- package/dist/api/dto/filters/request-filters.dto.js +0 -58
- package/dist/api/dto/filters/schedule-filters.dto.d.ts +0 -4
- package/dist/api/dto/filters/schedule-filters.dto.js +0 -31
- package/dist/api/dto/filters/view-filters.dto.d.ts +0 -4
- package/dist/api/dto/filters/view-filters.dto.js +0 -31
- package/dist/api/dto/pagination.dto.d.ts +0 -12
- package/dist/api/dto/pagination.dto.js +0 -81
- package/dist/core/input-validator.d.ts +0 -61
- package/dist/core/input-validator.js +0 -141
- package/dist/dashboard/public/assets/BatchesPage-CfKKM_7T.js +0 -1
- package/dist/dashboard/public/assets/CachePage-D-0-LS48.js +0 -1
- package/dist/dashboard/public/assets/ClickableBadge-Cm2obiA-.js +0 -1
- package/dist/dashboard/public/assets/CommandsPage-Kt35tHzp.js +0 -1
- package/dist/dashboard/public/assets/DumpsPage-F6tHPx1A.js +0 -1
- package/dist/dashboard/public/assets/EntryDetailPage-6jAej2HO.js +0 -126
- package/dist/dashboard/public/assets/EntrySearchInput-DCrG1xhu.js +0 -1
- package/dist/dashboard/public/assets/EventsPage-fh4ucpAD.js +0 -1
- package/dist/dashboard/public/assets/ExceptionsPage-CUUHUqmB.js +0 -6
- package/dist/dashboard/public/assets/GatesPage-CygTmC_O.js +0 -1
- package/dist/dashboard/public/assets/GraphQLPage-Da957Pvf.js +0 -6
- package/dist/dashboard/public/assets/HttpClientPage-DimC0ow-.js +0 -1
- package/dist/dashboard/public/assets/JobsPage-ZwD2zSMX.js +0 -1
- package/dist/dashboard/public/assets/LogsPage-DWgOb1ho.js +0 -1
- package/dist/dashboard/public/assets/MailPage-BbwcbjgO.js +0 -1
- package/dist/dashboard/public/assets/ModelsPage-Byl4KdOI.js +0 -1
- package/dist/dashboard/public/assets/NotificationsPage-DD62t7Ba.js +0 -1
- package/dist/dashboard/public/assets/PageHeader-CothD0Ar.js +0 -1
- package/dist/dashboard/public/assets/QueriesPage-Bb86qDZB.js +0 -1
- package/dist/dashboard/public/assets/RedisPage-DyhlhPno.js +0 -1
- package/dist/dashboard/public/assets/RequestsPage-BBjRdVuK.js +0 -1
- package/dist/dashboard/public/assets/SchedulePage-DL2d_nRi.js +0 -1
- package/dist/dashboard/public/assets/ViewsPage-BTnVSgHO.js +0 -1
- package/dist/dashboard/public/assets/index-BvhIlCeL.js +0 -361
- package/dist/dashboard/public/assets/index-FAG28XEI.css +0 -1
- package/dist/dashboard/public/assets/types-DjCa11Sv.js +0 -53
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))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OnModuleDestroy } from '@nestjs/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { Entry, EntryType } from '../types';
|
|
4
|
+
import { DataMaskerService } from './data-masker.service';
|
|
4
5
|
import { StorageInterface } from './storage/storage.interface';
|
|
5
6
|
import { TagService } from './tag.service';
|
|
6
7
|
import { FamilyHashService } from './family-hash.service';
|
|
@@ -8,6 +9,7 @@ import { NestLensConfig } from '../nestlens.config';
|
|
|
8
9
|
export declare class CollectorService implements OnModuleDestroy {
|
|
9
10
|
private readonly storage;
|
|
10
11
|
private readonly config;
|
|
12
|
+
private readonly dataMasker?;
|
|
11
13
|
private readonly tagService?;
|
|
12
14
|
private readonly familyHashService?;
|
|
13
15
|
private readonly logger;
|
|
@@ -42,7 +44,7 @@ export declare class CollectorService implements OnModuleDestroy {
|
|
|
42
44
|
/** Observable that emits every entry right after it is persisted. */
|
|
43
45
|
get entryStream$(): Observable<Entry>;
|
|
44
46
|
private emit;
|
|
45
|
-
constructor(storage: StorageInterface, config: NestLensConfig, tagService?: TagService | undefined, familyHashService?: FamilyHashService | undefined);
|
|
47
|
+
constructor(storage: StorageInterface, config: NestLensConfig, dataMasker?: DataMaskerService | undefined, tagService?: TagService | undefined, familyHashService?: FamilyHashService | undefined);
|
|
46
48
|
/**
|
|
47
49
|
* Apply filter to an entry
|
|
48
50
|
*/
|
|
@@ -85,6 +87,15 @@ export declare class CollectorService implements OnModuleDestroy {
|
|
|
85
87
|
* Save entries with retry logic
|
|
86
88
|
*/
|
|
87
89
|
private saveWithRetry;
|
|
90
|
+
/**
|
|
91
|
+
* Masks an entry's payload on its way in.
|
|
92
|
+
*
|
|
93
|
+
* Here rather than in each watcher: this is the one place every entry passes
|
|
94
|
+
* through, so a payload cannot reach storage — or the live tail, or a webhook
|
|
95
|
+
* — unmasked because a watcher forgot. It is also the flow the architecture
|
|
96
|
+
* note has always described: watcher → collect() → DataMasker → storage.
|
|
97
|
+
*/
|
|
98
|
+
private mask;
|
|
88
99
|
/**
|
|
89
100
|
* Flush buffer to storage
|
|
90
101
|
*/
|
|
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.CollectorService = void 0;
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const rxjs_1 = require("rxjs");
|
|
19
|
+
const data_masker_service_1 = require("./data-masker.service");
|
|
19
20
|
const request_context_1 = require("./request-context");
|
|
20
21
|
const storage_interface_1 = require("./storage/storage.interface");
|
|
21
22
|
const tag_service_1 = require("./tag.service");
|
|
@@ -31,9 +32,10 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
31
32
|
// (SSE, alerting) is responsible for swallowing its own errors.
|
|
32
33
|
this.entrySubject.next(entry);
|
|
33
34
|
}
|
|
34
|
-
constructor(storage, config, tagService, familyHashService) {
|
|
35
|
+
constructor(storage, config, dataMasker, tagService, familyHashService) {
|
|
35
36
|
this.storage = storage;
|
|
36
37
|
this.config = config;
|
|
38
|
+
this.dataMasker = dataMasker;
|
|
37
39
|
this.tagService = tagService;
|
|
38
40
|
this.familyHashService = familyHashService;
|
|
39
41
|
this.logger = new common_1.Logger(CollectorService_1.name);
|
|
@@ -133,12 +135,14 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
133
135
|
// ends up on the detail page of the request that ran it.
|
|
134
136
|
requestId: requestId ?? (0, request_context_1.currentRequestId)(),
|
|
135
137
|
};
|
|
136
|
-
//
|
|
138
|
+
// The filter callback runs in the application's own process against its own
|
|
139
|
+
// data, so it sees the entry as recorded; what gets buffered — and from
|
|
140
|
+
// there stored, streamed and posted to webhooks — is masked.
|
|
137
141
|
const shouldCollect = await this.applyFilter(entry);
|
|
138
142
|
if (!shouldCollect) {
|
|
139
143
|
return;
|
|
140
144
|
}
|
|
141
|
-
this.buffer.push(entry);
|
|
145
|
+
this.buffer.push(this.mask(entry));
|
|
142
146
|
this.enforceBufferLimit();
|
|
143
147
|
// Flush if buffer is full — unless storage is already failing, in which
|
|
144
148
|
// case the periodic timer retries and the caller is not made to wait.
|
|
@@ -167,7 +171,7 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
167
171
|
return null;
|
|
168
172
|
}
|
|
169
173
|
try {
|
|
170
|
-
const savedEntry = await this.storage.save(entry);
|
|
174
|
+
const savedEntry = await this.storage.save(this.mask(entry));
|
|
171
175
|
// Apply auto-tagging and family hash after saving
|
|
172
176
|
await this.applyAutoTagging(savedEntry);
|
|
173
177
|
this.emit(savedEntry);
|
|
@@ -223,6 +227,26 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
223
227
|
// This should never be reached, but TypeScript needs it
|
|
224
228
|
throw new Error('Unreachable code');
|
|
225
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Masks an entry's payload on its way in.
|
|
232
|
+
*
|
|
233
|
+
* Here rather than in each watcher: this is the one place every entry passes
|
|
234
|
+
* through, so a payload cannot reach storage — or the live tail, or a webhook
|
|
235
|
+
* — unmasked because a watcher forgot. It is also the flow the architecture
|
|
236
|
+
* note has always described: watcher → collect() → DataMasker → storage.
|
|
237
|
+
*/
|
|
238
|
+
mask(entry) {
|
|
239
|
+
if (!this.dataMasker) {
|
|
240
|
+
return entry;
|
|
241
|
+
}
|
|
242
|
+
const masked = this.dataMasker.maskBody(entry.payload);
|
|
243
|
+
// An exception's stack is part of its payload and is the one field the
|
|
244
|
+
// masker treats by shape rather than by name.
|
|
245
|
+
if (masked && typeof masked === 'object' && typeof masked.stack === 'string') {
|
|
246
|
+
masked.stack = this.dataMasker.sanitizeStackTrace(masked.stack);
|
|
247
|
+
}
|
|
248
|
+
return { ...entry, payload: masked };
|
|
249
|
+
}
|
|
226
250
|
/**
|
|
227
251
|
* Flush buffer to storage
|
|
228
252
|
*/
|
|
@@ -291,6 +315,12 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
291
315
|
this.logger.error(`Flush timer error: ${err}`);
|
|
292
316
|
});
|
|
293
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?.();
|
|
294
324
|
}
|
|
295
325
|
/**
|
|
296
326
|
* Stop flush timer and flush remaining entries
|
|
@@ -317,6 +347,8 @@ exports.CollectorService = CollectorService = CollectorService_1 = __decorate([
|
|
|
317
347
|
__param(1, (0, common_1.Inject)(nestlens_config_1.NESTLENS_CONFIG)),
|
|
318
348
|
__param(2, (0, common_1.Optional)()),
|
|
319
349
|
__param(3, (0, common_1.Optional)()),
|
|
320
|
-
|
|
350
|
+
__param(4, (0, common_1.Optional)()),
|
|
351
|
+
__metadata("design:paramtypes", [Object, Object, data_masker_service_1.DataMaskerService,
|
|
352
|
+
tag_service_1.TagService,
|
|
321
353
|
family_hash_service_1.FamilyHashService])
|
|
322
354
|
], CollectorService);
|
|
@@ -12,13 +12,23 @@ export interface DataMaskerConfig {
|
|
|
12
12
|
maskReplacement?: string;
|
|
13
13
|
/** Whether to sanitize stack traces in production */
|
|
14
14
|
sanitizeStackTraces?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* How much of a stack trace to keep, as documented under
|
|
17
|
+
* `security.stackTraceSanitization`.
|
|
18
|
+
*
|
|
19
|
+
* `none` keeps it whole, `partial` drops absolute paths and keeps the first
|
|
20
|
+
* frames, `full` removes it. Overrides `sanitizeStackTraces` when given.
|
|
21
|
+
*/
|
|
22
|
+
stackTraceSanitization?: StackTraceSanitization;
|
|
15
23
|
}
|
|
24
|
+
export type StackTraceSanitization = 'none' | 'partial' | 'full';
|
|
16
25
|
export declare class DataMaskerService {
|
|
17
26
|
private readonly sensitiveHeaders;
|
|
18
27
|
private readonly sensitiveParams;
|
|
19
28
|
private readonly sensitiveUserFields;
|
|
20
29
|
private readonly maskReplacement;
|
|
21
30
|
private readonly sanitizeStackTraces;
|
|
31
|
+
private readonly stackTraceSanitization;
|
|
22
32
|
private readonly isProduction;
|
|
23
33
|
constructor(config?: DataMaskerConfig);
|
|
24
34
|
/**
|
|
@@ -103,6 +103,8 @@ let DataMaskerService = class DataMaskerService {
|
|
|
103
103
|
this.sensitiveUserFields = userFields.map(normalizeFieldName);
|
|
104
104
|
this.maskReplacement = config?.maskReplacement ?? DEFAULT_MASK;
|
|
105
105
|
this.sanitizeStackTraces = config?.sanitizeStackTraces ?? true;
|
|
106
|
+
this.stackTraceSanitization =
|
|
107
|
+
config?.stackTraceSanitization ?? (this.sanitizeStackTraces ? 'partial' : 'none');
|
|
106
108
|
this.isProduction = process.env.NODE_ENV === 'production';
|
|
107
109
|
}
|
|
108
110
|
/**
|
|
@@ -203,7 +205,12 @@ let DataMaskerService = class DataMaskerService {
|
|
|
203
205
|
if (!stack) {
|
|
204
206
|
return undefined;
|
|
205
207
|
}
|
|
206
|
-
if (
|
|
208
|
+
if (this.stackTraceSanitization === 'full') {
|
|
209
|
+
return undefined;
|
|
210
|
+
}
|
|
211
|
+
// `partial` is about what leaves a production machine; in development the
|
|
212
|
+
// paths are the useful part.
|
|
213
|
+
if (this.stackTraceSanitization === 'none' || !this.isProduction) {
|
|
207
214
|
return stack;
|
|
208
215
|
}
|
|
209
216
|
// In production, simplify the stack trace
|
|
@@ -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>;
|
|
@@ -51,6 +51,18 @@ const common_1 = require("@nestjs/common");
|
|
|
51
51
|
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
|
52
52
|
const fs = __importStar(require("fs"));
|
|
53
53
|
const path = __importStar(require("path"));
|
|
54
|
+
const tag_normalization_1 = require("./tag-normalization");
|
|
55
|
+
/**
|
|
56
|
+
* The on-disk schema this version writes, recorded in `PRAGMA user_version`.
|
|
57
|
+
*
|
|
58
|
+
* 1 the original table: id, type, request_id, payload, created_at
|
|
59
|
+
* 2 adds family_hash and resolved_at
|
|
60
|
+
*
|
|
61
|
+
* Bump it whenever the schema changes, alongside the migration that performs
|
|
62
|
+
* the change. Files written before versioning read as 0 and are migrated the
|
|
63
|
+
* same way — the column probing below has always been idempotent.
|
|
64
|
+
*/
|
|
65
|
+
const SCHEMA_VERSION = 2;
|
|
54
66
|
let SqliteStorage = SqliteStorage_1 = class SqliteStorage {
|
|
55
67
|
constructor(filename = '.cache/nestlens.db') {
|
|
56
68
|
this.filename = filename;
|
|
@@ -68,7 +80,27 @@ let SqliteStorage = SqliteStorage_1 = class SqliteStorage {
|
|
|
68
80
|
onModuleInit() {
|
|
69
81
|
// Already initialized in constructor
|
|
70
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Reads the schema version, and says so when the file is from the future.
|
|
85
|
+
*
|
|
86
|
+
* A SQLite file outlives the package that wrote it: it sits on disk across
|
|
87
|
+
* upgrades, and across downgrades. Migrating forward is handled by probing
|
|
88
|
+
* for missing columns, which is idempotent and needs no version — but that
|
|
89
|
+
* only ever adds. Nothing could tell that a file had been written by a newer
|
|
90
|
+
* NestLens, where a column this version has never heard of may be carrying
|
|
91
|
+
* meaning, and the entries would simply read back short.
|
|
92
|
+
*/
|
|
93
|
+
readSchemaVersion() {
|
|
94
|
+
const version = this.db.pragma('user_version', { simple: true });
|
|
95
|
+
const parsed = typeof version === 'number' ? version : Number(version);
|
|
96
|
+
if (parsed > SCHEMA_VERSION) {
|
|
97
|
+
this.logger.warn(`${this.filename} was written by a newer NestLens (schema ${parsed}, this version reads ${SCHEMA_VERSION}). ` +
|
|
98
|
+
'It will be read as far as this version understands it; upgrade NestLens, or point `storage.sqlite.filename` at a new file.');
|
|
99
|
+
}
|
|
100
|
+
return parsed;
|
|
101
|
+
}
|
|
71
102
|
initializeDatabase() {
|
|
103
|
+
const version = this.readSchemaVersion();
|
|
72
104
|
// Create main entries table (base schema without new columns)
|
|
73
105
|
this.db.exec(`
|
|
74
106
|
CREATE TABLE IF NOT EXISTS nestlens_entries (
|
|
@@ -106,6 +138,11 @@ let SqliteStorage = SqliteStorage_1 = class SqliteStorage {
|
|
|
106
138
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
107
139
|
);
|
|
108
140
|
`);
|
|
141
|
+
// Stamped last, so a run that dies midway through leaves the file marked
|
|
142
|
+
// with the version it still is rather than the one it was becoming.
|
|
143
|
+
if (version < SCHEMA_VERSION) {
|
|
144
|
+
this.db.pragma(`user_version = ${SCHEMA_VERSION}`);
|
|
145
|
+
}
|
|
109
146
|
this.logger.log(`Database initialized: ${this.filename}`);
|
|
110
147
|
}
|
|
111
148
|
migrateDatabase() {
|
|
@@ -173,12 +210,16 @@ let SqliteStorage = SqliteStorage_1 = class SqliteStorage {
|
|
|
173
210
|
sql += ' AND request_id = ?';
|
|
174
211
|
params.push(filter.requestId);
|
|
175
212
|
}
|
|
213
|
+
// `datetime()` on both sides: SQLite writes CURRENT_TIMESTAMP as
|
|
214
|
+
// "2026-08-12 21:55:45" and a Date arrives as "2026-08-12T21:25:45.292Z",
|
|
215
|
+
// so comparing them as text compares a space against a "T" — every row
|
|
216
|
+
// from today or earlier reads as older than any cutoff today. See prune().
|
|
176
217
|
if (filter.from) {
|
|
177
|
-
sql += ' AND created_at >= ?';
|
|
218
|
+
sql += ' AND datetime(created_at) >= datetime(?)';
|
|
178
219
|
params.push(filter.from.toISOString());
|
|
179
220
|
}
|
|
180
221
|
if (filter.to) {
|
|
181
|
-
sql += ' AND created_at <= ?';
|
|
222
|
+
sql += ' AND datetime(created_at) <= datetime(?)';
|
|
182
223
|
params.push(filter.to.toISOString());
|
|
183
224
|
}
|
|
184
225
|
// id breaks ties so rows written in the same millisecond page consistently.
|
|
@@ -314,13 +355,23 @@ let SqliteStorage = SqliteStorage_1 = class SqliteStorage {
|
|
|
314
355
|
unresolvedExceptions: aggregateRow.unresolved_exceptions,
|
|
315
356
|
};
|
|
316
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Both sides go through `datetime()` before they are compared.
|
|
360
|
+
*
|
|
361
|
+
* SQLite stores `CURRENT_TIMESTAMP` as `2026-08-12 21:55:45` and a JavaScript
|
|
362
|
+
* Date arrives as `2026-08-12T21:25:45.292Z`. Compared as text — which is
|
|
363
|
+
* what `created_at < ?` does — the eleventh character decides: a space sorts
|
|
364
|
+
* before a "T", so every row whose date is the cutoff's date or earlier reads
|
|
365
|
+
* as older than the cutoff whatever its time. Pruning anything therefore
|
|
366
|
+
* pruned everything recorded that day, including entries seconds old.
|
|
367
|
+
*/
|
|
317
368
|
async prune(before) {
|
|
318
|
-
const stmt = this.db.prepare('DELETE FROM nestlens_entries WHERE created_at < ?');
|
|
369
|
+
const stmt = this.db.prepare('DELETE FROM nestlens_entries WHERE datetime(created_at) < datetime(?)');
|
|
319
370
|
const result = stmt.run(before.toISOString());
|
|
320
371
|
return result.changes;
|
|
321
372
|
}
|
|
322
373
|
async pruneByType(type, before) {
|
|
323
|
-
const stmt = this.db.prepare('DELETE FROM nestlens_entries WHERE type = ? AND created_at < ?');
|
|
374
|
+
const stmt = this.db.prepare('DELETE FROM nestlens_entries WHERE type = ? AND datetime(created_at) < datetime(?)');
|
|
324
375
|
const result = stmt.run(type, before.toISOString());
|
|
325
376
|
return result.changes;
|
|
326
377
|
}
|
|
@@ -903,7 +954,8 @@ let SqliteStorage = SqliteStorage_1 = class SqliteStorage {
|
|
|
903
954
|
return rows.map((row) => this.rowToEntry(row));
|
|
904
955
|
}
|
|
905
956
|
// ==================== Monitored Tags ====================
|
|
906
|
-
async addMonitoredTag(
|
|
957
|
+
async addMonitoredTag(rawTag) {
|
|
958
|
+
const tag = (0, tag_normalization_1.normalizeTag)(rawTag);
|
|
907
959
|
const stmt = this.db.prepare(`
|
|
908
960
|
INSERT OR IGNORE INTO nestlens_monitored_tags (tag)
|
|
909
961
|
VALUES (?)
|
|
@@ -919,11 +971,11 @@ let SqliteStorage = SqliteStorage_1 = class SqliteStorage {
|
|
|
919
971
|
createdAt: row.created_at,
|
|
920
972
|
};
|
|
921
973
|
}
|
|
922
|
-
async removeMonitoredTag(
|
|
974
|
+
async removeMonitoredTag(rawTag) {
|
|
923
975
|
const stmt = this.db.prepare(`
|
|
924
976
|
DELETE FROM nestlens_monitored_tags WHERE tag = ?
|
|
925
977
|
`);
|
|
926
|
-
stmt.run(
|
|
978
|
+
stmt.run((0, tag_normalization_1.normalizeTag)(rawTag));
|
|
927
979
|
}
|
|
928
980
|
async getMonitoredTags() {
|
|
929
981
|
const stmt = this.db.prepare(`
|
|
@@ -56,8 +56,34 @@ async function createMemoryStorage(config) {
|
|
|
56
56
|
const storage = new MemoryStorage(config.memory);
|
|
57
57
|
await storage.initialize();
|
|
58
58
|
logger.log('Using in-memory storage');
|
|
59
|
+
warnIfClustered();
|
|
59
60
|
return storage;
|
|
60
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Says so when in-memory storage is running in one of several processes.
|
|
64
|
+
*
|
|
65
|
+
* The default storage lives in the process that recorded the entry, and a
|
|
66
|
+
* clustered application answers each request from whichever worker was free.
|
|
67
|
+
* The dashboard then shows one worker's entries, a refresh shows another's, and
|
|
68
|
+
* entries appear to come and go at random — a confusing thing to debug with a
|
|
69
|
+
* debugging tool. Nothing is broken; the driver simply cannot see across
|
|
70
|
+
* processes.
|
|
71
|
+
*
|
|
72
|
+
* Only same-host clustering is detectable from inside the process. Several
|
|
73
|
+
* replicas of a container have exactly the same problem and no way to know it,
|
|
74
|
+
* which is why the documentation covers the topology rather than this warning.
|
|
75
|
+
*
|
|
76
|
+
* Read from the environment rather than from `node:cluster`: `isWorker` is
|
|
77
|
+
* defined as `NODE_UNIQUE_ID !== undefined`, and loading the cluster module to
|
|
78
|
+
* ask leaves a handle open that outlives the process's work. `NODE_APP_INSTANCE`
|
|
79
|
+
* covers PM2, which sets it in fork mode as well as in cluster mode.
|
|
80
|
+
*/
|
|
81
|
+
function warnIfClustered() {
|
|
82
|
+
if (!process.env.NODE_UNIQUE_ID && !process.env.NODE_APP_INSTANCE)
|
|
83
|
+
return;
|
|
84
|
+
logger.warn('In-memory storage in a clustered process: each worker keeps its own entries, so the dashboard ' +
|
|
85
|
+
'shows only the worker that answered the request. Use the sqlite or redis driver for one shared view.');
|
|
86
|
+
}
|
|
61
87
|
/**
|
|
62
88
|
* Creates a SQLite storage instance.
|
|
63
89
|
* Requires better-sqlite3 to be installed.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One spelling for a tag, whichever way it was typed.
|
|
3
|
+
*
|
|
4
|
+
* Entry tags have always been stored upper-cased, so that `slow` and `SLOW`
|
|
5
|
+
* count as one tag rather than two. Monitored tags were stored verbatim, and
|
|
6
|
+
* the two are compared: `getMonitoredTagsWithCounts` looks a monitored tag up
|
|
7
|
+
* in the counts keyed by entry tag. Monitoring `checkout` therefore reported
|
|
8
|
+
* zero entries no matter how many carried it, on every backend.
|
|
9
|
+
*/
|
|
10
|
+
export declare const normalizeTag: (tag: string) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeTag = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* One spelling for a tag, whichever way it was typed.
|
|
6
|
+
*
|
|
7
|
+
* Entry tags have always been stored upper-cased, so that `slow` and `SLOW`
|
|
8
|
+
* count as one tag rather than two. Monitored tags were stored verbatim, and
|
|
9
|
+
* the two are compared: `getMonitoredTagsWithCounts` looks a monitored tag up
|
|
10
|
+
* in the counts keyed by entry tag. Monitoring `checkout` therefore reported
|
|
11
|
+
* zero entries no matter how many carried it, on every backend.
|
|
12
|
+
*/
|
|
13
|
+
const normalizeTag = (tag) => tag.toUpperCase();
|
|
14
|
+
exports.normalizeTag = normalizeTag;
|
package/dist/core/tag.service.js
CHANGED
|
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.TagService = void 0;
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const storage_interface_1 = require("./storage/storage.interface");
|
|
19
|
+
const tag_normalization_1 = require("./storage/tag-normalization");
|
|
19
20
|
/**
|
|
20
21
|
* Service for managing tags and auto-tagging entries
|
|
21
22
|
*/
|
|
@@ -591,10 +592,12 @@ let TagService = TagService_1 = class TagService {
|
|
|
591
592
|
async getMonitoredTagsWithCounts() {
|
|
592
593
|
const monitoredTags = await this.storage.getMonitoredTags();
|
|
593
594
|
const allTags = await this.storage.getAllTags();
|
|
594
|
-
|
|
595
|
+
// Both sides are normalised here as well as on the way in, so a tag stored
|
|
596
|
+
// before monitored tags were normalised still finds its count.
|
|
597
|
+
const tagCountMap = new Map(allTags.map((t) => [(0, tag_normalization_1.normalizeTag)(t.tag), t.count]));
|
|
595
598
|
return monitoredTags.map((tag) => ({
|
|
596
599
|
...tag,
|
|
597
|
-
count: tagCountMap.get(tag.tag) ?? 0,
|
|
600
|
+
count: tagCountMap.get((0, tag_normalization_1.normalizeTag)(tag.tag)) ?? 0,
|
|
598
601
|
}));
|
|
599
602
|
}
|
|
600
603
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,L as o,A as y,C as u}from"./index-DyvNu-oR.js";import{p as n,f as v}from"./badgeColors-DQ_P_DOX.js";import{D as r,f as k}from"./DetailRow-CouZ8riB.js";import{C as m}from"./types-DZUckfsW.js";import{C as w}from"./CopyButton-CVTvd0EZ.js";import{C as g}from"./circle-x-BOe5goDy.js";import{C as j}from"./circle-alert-CgZfn5uS.js";import{C}from"./circle-check-big-1S8vooWx.js";import"./vendor-DBTT3jXp.js";import"./EntryDetailPage-QTrST2MQ.js";import"./search-D9V4itpU.js";const p={completed:{icon:C,color:"text-green-500",bg:"bg-green-100 dark:bg-green-900/30"},partial:{icon:j,color:"text-yellow-500",bg:"bg-yellow-100 dark:bg-yellow-900/30"},failed:{icon:g,color:"text-red-500",bg:"bg-red-100 dark:bg-red-900/30"}};function h(a){return a?a<1024?`${a}B`:a<1024*1024?`${(a/1024).toFixed(1)}KB`:a<1024*1024*1024?`${(a/(1024*1024)).toFixed(1)}MB`:`${(a/(1024*1024*1024)).toFixed(1)}GB`:"-"}function E({entry:a}){const{payload:s,createdAt:c}=a,t=p[s.status]||p.completed,f=t.icon,{processedItems:x,totalItems:d,failedItems:l}=s,i=d>0?Math.round(x/d*100):0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:`p-2 ${t.bg} rounded-lg`,children:e.jsx(o,{className:`h-5 w-5 ${t.color}`})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white font-mono",children:s.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Batch Operation"})]})]}),e.jsx(w,{text:s.name,label:"Copy batch name"})]})}),e.jsxs("div",{className:`grid ${s.memory!==void 0?"grid-cols-2 md:grid-cols-5":"grid-cols-2 md:grid-cols-4"} divide-x divide-gray-200 dark:divide-gray-700`,children:[e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(f,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Status"})]}),e.jsx("p",{className:`text-lg font-bold ${t.color}`,children:s.status.toUpperCase()})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(y,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Progress"})]}),e.jsxs("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:[i,e.jsx("span",{className:"text-sm font-normal text-gray-500 dark:text-gray-400",children:"%"})]})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(u,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Duration"})]}),e.jsxs("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:[s.duration,e.jsx("span",{className:"text-sm font-normal text-gray-500 dark:text-gray-400",children:"ms"})]})]}),l>0&&e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(g,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Failed"})]}),e.jsx("p",{className:"text-lg font-bold text-red-600 dark:text-red-400",children:l})]}),s.memory!==void 0&&e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(o,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Memory"})]}),e.jsx("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:h(s.memory)})]})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Details"})}),e.jsx("div",{className:"p-4",children:e.jsxs("dl",{className:"divide-y-0",children:[e.jsx(r,{label:"Time",value:e.jsxs("span",{children:[k(n(c),"MMMM do yyyy, h:mm:ss a")," ",e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["(",v(n(c),{addSuffix:!0}),")"]})]})}),e.jsx(r,{label:"Name",value:e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white",children:s.name})}),s.operation&&e.jsx(r,{label:"Operation",value:e.jsx(m,{listType:"batches",filterType:"operations",filterValue:s.operation,children:s.operation})}),e.jsx(r,{label:"Status",value:e.jsx(m,{listType:"batches",filterType:"statuses",filterValue:s.status,children:s.status.toUpperCase()})}),e.jsx(r,{label:"Progress",value:e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-mono",children:[x," / ",d," (",i,"%)"]}),e.jsx("div",{className:"mt-2 w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2",children:e.jsx("div",{className:"bg-blue-600 dark:bg-blue-500 h-2 rounded-full transition-all",style:{width:`${i}%`}})})]})}),l>0&&e.jsx(r,{label:"Failed Items",value:e.jsx("span",{className:"text-red-600 dark:text-red-400 font-mono",children:l})}),e.jsx(r,{label:"Duration",value:`${s.duration}ms`}),s.batchSize&&e.jsx(r,{label:"Batch Size",value:s.batchSize}),s.memory!==void 0&&e.jsx(r,{label:"Memory",value:h(s.memory)})]})})]}),s.errors&&s.errors.length>0&&e.jsxs("div",{className:"card border-red-200 dark:border-red-800",children:[e.jsx("div",{className:"px-4 py-3 border-b border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-900/20",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(j,{className:"h-5 w-5 text-red-500"}),e.jsxs("h2",{className:"text-lg font-semibold text-red-700 dark:text-red-400",children:["Errors (",s.errors.length,")"]})]})}),e.jsx("div",{className:"divide-y divide-red-200 dark:divide-red-800",children:s.errors.map((N,b)=>e.jsx("div",{className:"p-4 bg-red-50/50 dark:bg-red-900/10",children:e.jsx("pre",{className:"text-sm text-red-600 dark:text-red-400 font-mono whitespace-pre-wrap overflow-x-auto",children:N})},b))})]})]})}export{E as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t,L as d}from"./index-DyvNu-oR.js";import{e as D,b as F}from"./vendor-DBTT3jXp.js";import{f as M,p as T}from"./badgeColors-DQ_P_DOX.js";import{u as A,P as L,N as R,L as $}from"./PageHeader-BAc6Jvef.js";import{u as I,q as H,C as c}from"./types-DZUckfsW.js";import{T as s,D as S,b as W}from"./DataTable-DNJpoFzh.js";function K(){const h=D(),{addFilter:o,clearAll:p,serverFilters:u,headerFilters:x,hasFilters:m}=I("batches"),{entries:g,loading:y,refreshing:i,newEntriesCount:f,hasMore:j,loadMore:b,loadNew:k,autoRefreshEnabled:C,live:N,setAutoRefresh:w,meta:n,isHighlighted:E}=A({type:"batch",limit:50,filters:u}),l=g.filter(e=>H(e)),v=F.useMemo(()=>[{key:"name",header:"Name",minWidth:"200px",render:e=>t.jsx(s,{mono:!0,truncate:!0,maxWidth:"250px",children:e.payload.name})},{key:"operation",header:"Operation",width:"150px",render:e=>{const a=e.payload.operation;return a?t.jsx(c,{onClick:r=>{r.stopPropagation(),o("operations",a)},children:a}):t.jsx(s,{secondary:!0,children:"-"})}},{key:"progress",header:"Progress",width:"150px",render:e=>{const{processedItems:a,totalItems:r}=e.payload,B=r>0?Math.round(a/r*100):0;return t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(s,{children:`${a}/${r}`}),t.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",B,"%)"]})]})}},{key:"status",header:"Status",width:"120px",render:e=>t.jsx(c,{onClick:a=>{a.stopPropagation(),o("statuses",e.payload.status)},children:e.payload.status.toUpperCase()})},{key:"duration",header:"Duration",width:"100px",align:"right",render:e=>e.payload.duration?t.jsx(S,{ms:e.payload.duration}):t.jsx(s,{secondary:!0,children:"-"})},{key:"time",header:"Time",width:"170px",align:"right",render:e=>t.jsx(s,{secondary:!0,className:"text-xs",children:M(T(e.createdAt),{addSuffix:!0})})}],[o]);if(y&&l.length===0)return t.jsx("div",{className:"flex items-center justify-center h-64",role:"status","aria-label":"Loading...",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary-600"})});const P=m?"pt-28":"pt-16";return t.jsxs("div",{children:[t.jsx(L,{title:"Batches",icon:d,iconColor:"text-blue-600 dark:text-blue-400",count:l.length,totalCount:n==null?void 0:n.total,refreshing:i,autoRefreshEnabled:C,live:N,onAutoRefreshToggle:w,filters:x,onClearAllFilters:p}),t.jsxs("div",{className:`${P} space-y-4 transition-all duration-200`,children:[t.jsx(R,{count:f,onClick:k,loading:i}),t.jsx(W,{columns:v,data:l,keyExtractor:e=>e.id,onRowClick:e=>h(`/batches/${e.id}`),rowClassName:e=>E(e.id)?"highlight-new":"",emptyMessage:"No batch operations recorded yet",emptyIcon:t.jsx(d,{className:"h-8 w-8 text-gray-400 dark:text-gray-500"})}),t.jsx($,{hasMore:j,onClick:b,loading:i})]})]})}export{K as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as h,j as e,D as d,C as g}from"./index-DyvNu-oR.js";import{p as o,f as p}from"./badgeColors-DQ_P_DOX.js";import{D as t,f as b}from"./DetailRow-CouZ8riB.js";import{C as x}from"./types-DZUckfsW.js";import{u as j,C as y,T as f}from"./EntryDetailPage-QTrST2MQ.js";import{C as u}from"./CopyButton-CVTvd0EZ.js";import{C as N}from"./circle-check-big-1S8vooWx.js";import{C as v}from"./circle-x-BOe5goDy.js";import{T as k}from"./timer-CZxO8Y_Q.js";import"./vendor-DBTT3jXp.js";import"./search-D9V4itpU.js";/**
|
|
2
|
+
* @license lucide-react v0.468.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const T=h("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),n={get:{label:"GET",color:"text-green-500",bg:"bg-green-100 dark:bg-green-900/30"},set:{label:"SET",color:"text-blue-500",bg:"bg-blue-100 dark:bg-blue-900/30"},del:{label:"DELETE",color:"text-red-500",bg:"bg-red-100 dark:bg-red-900/30"},clear:{label:"CLEAR",color:"text-orange-500",bg:"bg-orange-100 dark:bg-orange-900/30"}};function m(s){return s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m`:s<86400?`${Math.floor(s/3600)}h`:`${Math.floor(s/86400)}d`}function K({entry:s}){const{payload:a,createdAt:i}=s,l=j(),r=n[a.operation]||n.get,c=a.value!==void 0?[{id:"value",label:"Value",content:e.jsx(y,{data:a.value,toolbarState:l.state,searchBar:l.SearchBar,maxHeight:400})}]:[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:`p-2 ${r.bg} rounded-lg`,children:e.jsx(d,{className:`h-5 w-5 ${r.color}`})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r.label}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Cache Operation"})]})]}),e.jsx(u,{text:a.key,label:"Copy cache key"})]})}),e.jsxs("div",{className:`grid ${a.operation==="get"?"grid-cols-2 md:grid-cols-4":"grid-cols-2 md:grid-cols-3"} divide-x divide-gray-200 dark:divide-gray-700`,children:[e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(d,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Operation"})]}),e.jsx("p",{className:`text-lg font-bold ${r.color}`,children:r.label})]}),a.operation==="get"&&e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[a.hit?e.jsx(N,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Result"})]}),e.jsx("p",{className:`text-lg font-bold ${a.hit?"text-green-600 dark:text-green-400":"text-gray-500 dark:text-gray-400"}`,children:a.hit?"HIT":"MISS"})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(g,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Duration"})]}),e.jsxs("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:[a.duration,e.jsx("span",{className:"text-sm font-normal text-gray-500 dark:text-gray-400",children:"ms"})]})]}),a.ttl!==void 0&&e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(k,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"TTL"})]}),e.jsx("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:m(a.ttl)})]})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Details"})}),e.jsx("div",{className:"p-4",children:e.jsxs("dl",{className:"divide-y-0",children:[e.jsx(t,{label:"Time",value:e.jsxs("span",{children:[b(o(i),"MMMM do yyyy, h:mm:ss a")," ",e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["(",p(o(i),{addSuffix:!0}),")"]})]})}),e.jsx(t,{label:"Operation",value:e.jsx(x,{listType:"cache",filterType:"operations",filterValue:a.operation,children:a.operation.toUpperCase()})}),e.jsx(t,{label:"Key",value:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(T,{className:"h-4 w-4 text-gray-400 flex-shrink-0"}),e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white break-all",children:a.key})]})}),a.operation==="get"&&e.jsx(t,{label:"Result",value:e.jsx(x,{listType:"cache",filterType:"tags",filterValue:a.hit?"hit":"miss",children:a.hit?"HIT":"MISS"})}),e.jsx(t,{label:"Duration",value:`${a.duration}ms`}),a.ttl!==void 0&&e.jsx(t,{label:"TTL",value:`${a.ttl}s (${m(a.ttl)})`})]})})]}),c.length>0&&e.jsx(f,{tabs:c,defaultTab:"value",hashKey:"cache",headerRight:e.jsx(l.Toolbar,{data:a.value})})]})}export{K as default};
|