nestlens 0.8.7 → 0.8.9

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.
Files changed (41) hide show
  1. package/dist/core/collector.service.d.ts +24 -0
  2. package/dist/core/collector.service.js +50 -4
  3. package/dist/core/data-masker.service.d.ts +0 -4
  4. package/dist/core/data-masker.service.js +35 -13
  5. package/dist/core/storage/entry-filter.d.ts +16 -0
  6. package/dist/core/storage/entry-filter.js +260 -0
  7. package/dist/core/storage/memory.storage.js +5 -247
  8. package/dist/core/storage/redis.storage.js +2 -54
  9. package/dist/dashboard/public/assets/{BatchesPage-K-GVuQzn.js → BatchesPage-B-FM-KDo.js} +1 -1
  10. package/dist/dashboard/public/assets/{CachePage-RGNHXHUE.js → CachePage-DdiQfS9v.js} +1 -1
  11. package/dist/dashboard/public/assets/{ClickableBadge-DI8HUq7L.js → ClickableBadge-Vyx_sMAl.js} +1 -1
  12. package/dist/dashboard/public/assets/{CommandsPage-BF1CuS10.js → CommandsPage-zJMqAMw2.js} +1 -1
  13. package/dist/dashboard/public/assets/{DashboardPage-o0PZXAPY.js → DashboardPage-8LH8ftoZ.js} +1 -1
  14. package/dist/dashboard/public/assets/{DumpsPage-CHMS4UV4.js → DumpsPage-zoJtOb34.js} +1 -1
  15. package/dist/dashboard/public/assets/{EntryDetailPage-cT17hE64.js → EntryDetailPage-DFx3gg0C.js} +1 -1
  16. package/dist/dashboard/public/assets/{EntrySearchInput-CKGgY5b-.js → EntrySearchInput-BjzlyOoC.js} +1 -1
  17. package/dist/dashboard/public/assets/{EventsPage-CCkEbATc.js → EventsPage-CWYR4iMv.js} +1 -1
  18. package/dist/dashboard/public/assets/{ExceptionsPage-C7vOil3f.js → ExceptionsPage-BRBxnFaw.js} +1 -1
  19. package/dist/dashboard/public/assets/{GatesPage-eT6uFw9r.js → GatesPage-Db4jOQJV.js} +1 -1
  20. package/dist/dashboard/public/assets/{GraphQLPage-B6EdZJZe.js → GraphQLPage-B3rSuWjG.js} +1 -1
  21. package/dist/dashboard/public/assets/{HttpClientPage-DH-GXvvy.js → HttpClientPage-ax2dQyNU.js} +1 -1
  22. package/dist/dashboard/public/assets/{JobsPage-dCk-N0lR.js → JobsPage-DgrC3Sj1.js} +1 -1
  23. package/dist/dashboard/public/assets/{LogsPage-DW62eIrs.js → LogsPage-BBlP-X7a.js} +1 -1
  24. package/dist/dashboard/public/assets/{MailPage-ChVdQjzk.js → MailPage-CoNbEq1o.js} +1 -1
  25. package/dist/dashboard/public/assets/{ModelsPage-FccL3wGR.js → ModelsPage-DWb7rn2b.js} +1 -1
  26. package/dist/dashboard/public/assets/{NotificationsPage-cgZvRRHd.js → NotificationsPage-DCLX_IJt.js} +1 -1
  27. package/dist/dashboard/public/assets/{PageHeader-C6kJfDuB.js → PageHeader-gzCjMnIq.js} +1 -1
  28. package/dist/dashboard/public/assets/{QueriesPage-BiypBC-V.js → QueriesPage-3UzIdKwS.js} +1 -1
  29. package/dist/dashboard/public/assets/{RedisPage-CN_RkaRR.js → RedisPage-CkCLM4ax.js} +1 -1
  30. package/dist/dashboard/public/assets/{RequestsPage-BXw3UZS9.js → RequestsPage-Dj4eX2lV.js} +1 -1
  31. package/dist/dashboard/public/assets/{SchedulePage-CWlODox3.js → SchedulePage-egoitltq.js} +1 -1
  32. package/dist/dashboard/public/assets/{ViewsPage-BTMZNYvV.js → ViewsPage-HadbKX46.js} +1 -1
  33. package/dist/dashboard/public/assets/{calendar-By5epGU4.js → calendar-BsVc-vvl.js} +1 -1
  34. package/dist/dashboard/public/assets/{circle-check-big-FekinZ31.js → circle-check-big-D8hxmLVs.js} +1 -1
  35. package/dist/dashboard/public/assets/{eye-DYGHPhI8.js → eye-DoP8A5L_.js} +1 -1
  36. package/dist/dashboard/public/assets/{index-DCW7FY90.js → index-NYfiXmMn.js} +2 -2
  37. package/dist/dashboard/public/assets/{search-Cfqjc5Kw.js → search-C8zDS2B0.js} +1 -1
  38. package/dist/dashboard/public/assets/{types-CVHwYdEn.js → types-DrGQDdvv.js} +1 -1
  39. package/dist/dashboard/public/assets/{zap-BihpCVDn.js → zap-DXGDS502.js} +1 -1
  40. package/dist/dashboard/public/index.html +1 -1
  41. package/package.json +1 -1
@@ -15,6 +15,26 @@ export declare class CollectorService implements OnModuleDestroy {
15
15
  private flushTimer;
16
16
  private readonly BUFFER_SIZE;
17
17
  private readonly FLUSH_INTERVAL;
18
+ /**
19
+ * How many entries may wait for a storage that is not answering.
20
+ *
21
+ * Failed entries used to go back into the buffer with nothing bounding it, so
22
+ * an unreachable database turned into unbounded growth inside the application
23
+ * being watched — a debugging tool causing the outage it is there to explain.
24
+ * Ten flushes' worth is enough to ride out a blip; past that the oldest go,
25
+ * because NestLens's data is disposable and the application's memory is not.
26
+ */
27
+ private readonly MAX_BUFFERED_ENTRIES;
28
+ /**
29
+ * Set while storage is failing, so `collect()` stops flushing inline.
30
+ *
31
+ * Every entry arriving past the buffer threshold used to start its own flush,
32
+ * three attempts with backoff, awaited on the caller's path: ~200ms added to
33
+ * each monitored operation for as long as storage was down. The timer keeps
34
+ * retrying once a second instead.
35
+ */
36
+ private storageIsFailing;
37
+ private droppedEntries;
18
38
  private isPaused;
19
39
  private pausedAt?;
20
40
  private pauseReason?;
@@ -69,6 +89,10 @@ export declare class CollectorService implements OnModuleDestroy {
69
89
  * Flush buffer to storage
70
90
  */
71
91
  flush(): Promise<void>;
92
+ /**
93
+ * Keeps the buffer within its bound, dropping the oldest entries first.
94
+ */
95
+ private enforceBufferLimit;
72
96
  /**
73
97
  * Start periodic flush timer
74
98
  */
@@ -40,6 +40,26 @@ let CollectorService = CollectorService_1 = class CollectorService {
40
40
  this.flushTimer = null;
41
41
  this.BUFFER_SIZE = 100;
42
42
  this.FLUSH_INTERVAL = 1000; // 1 second
43
+ /**
44
+ * How many entries may wait for a storage that is not answering.
45
+ *
46
+ * Failed entries used to go back into the buffer with nothing bounding it, so
47
+ * an unreachable database turned into unbounded growth inside the application
48
+ * being watched — a debugging tool causing the outage it is there to explain.
49
+ * Ten flushes' worth is enough to ride out a blip; past that the oldest go,
50
+ * because NestLens's data is disposable and the application's memory is not.
51
+ */
52
+ this.MAX_BUFFERED_ENTRIES = 1000;
53
+ /**
54
+ * Set while storage is failing, so `collect()` stops flushing inline.
55
+ *
56
+ * Every entry arriving past the buffer threshold used to start its own flush,
57
+ * three attempts with backoff, awaited on the caller's path: ~200ms added to
58
+ * each monitored operation for as long as storage was down. The timer keeps
59
+ * retrying once a second instead.
60
+ */
61
+ this.storageIsFailing = false;
62
+ this.droppedEntries = 0;
43
63
  this.isPaused = false;
44
64
  // Real-time stream of persisted entries. Powers the SSE live-tail and the
45
65
  // alerting service. Entries are emitted after they have been saved (so they
@@ -115,8 +135,10 @@ let CollectorService = CollectorService_1 = class CollectorService {
115
135
  return;
116
136
  }
117
137
  this.buffer.push(entry);
118
- // Flush if buffer is full
119
- if (this.buffer.length >= this.BUFFER_SIZE) {
138
+ this.enforceBufferLimit();
139
+ // Flush if buffer is full — unless storage is already failing, in which
140
+ // case the periodic timer retries and the caller is not made to wait.
141
+ if (this.buffer.length >= this.BUFFER_SIZE && !this.storageIsFailing) {
120
142
  await this.flush();
121
143
  }
122
144
  }
@@ -225,12 +247,36 @@ let CollectorService = CollectorService_1 = class CollectorService {
225
247
  await Promise.all(savedEntries.map((entry) => this.applyAutoTagging(entry)));
226
248
  // Notify real-time subscribers (SSE, alerting) after persistence
227
249
  savedEntries.forEach((entry) => this.emit(entry));
250
+ if (this.storageIsFailing) {
251
+ this.storageIsFailing = false;
252
+ this.logger.log(this.droppedEntries > 0
253
+ ? `Storage is answering again (${this.droppedEntries} entries were dropped meanwhile)`
254
+ : 'Storage is answering again');
255
+ this.droppedEntries = 0;
256
+ }
228
257
  }
229
258
  catch (error) {
230
- this.logger.error(`Failed to flush entries: ${error}`);
231
- // Put entries back in buffer
259
+ // Reported once per outage rather than once per second.
260
+ if (!this.storageIsFailing) {
261
+ this.logger.error(`Failed to flush entries, will keep retrying: ${error}`);
262
+ this.storageIsFailing = true;
263
+ }
264
+ // Put entries back in buffer, oldest first, and let the limit decide what
265
+ // survives if storage stays down.
232
266
  this.buffer = [...entries, ...this.buffer];
267
+ this.enforceBufferLimit();
268
+ }
269
+ }
270
+ /**
271
+ * Keeps the buffer within its bound, dropping the oldest entries first.
272
+ */
273
+ enforceBufferLimit() {
274
+ const overflow = this.buffer.length - this.MAX_BUFFERED_ENTRIES;
275
+ if (overflow <= 0) {
276
+ return;
233
277
  }
278
+ this.buffer.splice(0, overflow);
279
+ this.droppedEntries += overflow;
234
280
  }
235
281
  /**
236
282
  * Start periodic flush timer
@@ -13,10 +13,6 @@ export interface DataMaskerConfig {
13
13
  /** Whether to sanitize stack traces in production */
14
14
  sanitizeStackTraces?: boolean;
15
15
  }
16
- /**
17
- * Service for masking sensitive data in entries.
18
- * Prevents sensitive information from being stored or displayed.
19
- */
20
16
  export declare class DataMaskerService {
21
17
  private readonly sensitiveHeaders;
22
18
  private readonly sensitiveParams;
@@ -67,14 +67,40 @@ const DEFAULT_MASK = '***REDACTED***';
67
67
  * Service for masking sensitive data in entries.
68
68
  * Prevents sensitive information from being stored or displayed.
69
69
  */
70
+ /**
71
+ * A field name reduced to letters and digits, lower case.
72
+ *
73
+ * `access_token`, `access-token` and `accessToken` are the same field written
74
+ * three ways, and a payload uses whichever the framework or the author
75
+ * preferred. Comparing the reduced forms means the term list does not have to
76
+ * enumerate them.
77
+ */
78
+ const normalizeFieldName = (name) => name.toLowerCase().replace(/[^a-z0-9]/g, '');
79
+ /**
80
+ * Whether a field name contains any of the terms.
81
+ *
82
+ * Containment rather than equality: the list held `password`, and payloads hold
83
+ * `confirmPassword`, `currentPassword`, `passwordConfirmation`. Every one of
84
+ * those went to storage and to the dashboard in the clear, as did
85
+ * `accessToken`, `refreshToken`, `clientSecret` and `stripeSecretKey` — the
86
+ * names real payloads actually use.
87
+ *
88
+ * It masks more than it strictly must — `tokenCount` goes too — which is the
89
+ * right direction for something recording production traffic. A field that
90
+ * should be readable can be kept by narrowing the configured list.
91
+ */
92
+ const matchesSensitiveTerm = (fieldName, terms) => {
93
+ const normalized = normalizeFieldName(fieldName);
94
+ return terms.some((term) => term.length > 0 && normalized.includes(term));
95
+ };
70
96
  let DataMaskerService = class DataMaskerService {
71
97
  constructor(config) {
72
98
  const headers = [...DEFAULT_SENSITIVE_HEADERS, ...(config?.sensitiveHeaders ?? [])];
73
99
  const params = [...DEFAULT_SENSITIVE_PARAMS, ...(config?.sensitiveParams ?? [])];
74
100
  const userFields = [...DEFAULT_SENSITIVE_USER_FIELDS, ...(config?.sensitiveUserFields ?? [])];
75
- this.sensitiveHeaders = new Set(headers.map((h) => h.toLowerCase()));
76
- this.sensitiveParams = new Set(params.map((p) => p.toLowerCase()));
77
- this.sensitiveUserFields = new Set(userFields.map((f) => f.toLowerCase()));
101
+ this.sensitiveHeaders = headers.map(normalizeFieldName);
102
+ this.sensitiveParams = params.map(normalizeFieldName);
103
+ this.sensitiveUserFields = userFields.map(normalizeFieldName);
78
104
  this.maskReplacement = config?.maskReplacement ?? DEFAULT_MASK;
79
105
  this.sanitizeStackTraces = config?.sanitizeStackTraces ?? true;
80
106
  this.isProduction = process.env.NODE_ENV === 'production';
@@ -88,8 +114,7 @@ let DataMaskerService = class DataMaskerService {
88
114
  }
89
115
  const masked = {};
90
116
  for (const [key, value] of Object.entries(headers)) {
91
- const lowerKey = key.toLowerCase();
92
- if (this.sensitiveHeaders.has(lowerKey)) {
117
+ if (matchesSensitiveTerm(key, this.sensitiveHeaders)) {
93
118
  masked[key] = this.maskReplacement;
94
119
  }
95
120
  else {
@@ -129,8 +154,7 @@ let DataMaskerService = class DataMaskerService {
129
154
  maskObject(obj) {
130
155
  const masked = {};
131
156
  for (const [key, value] of Object.entries(obj)) {
132
- const lowerKey = key.toLowerCase();
133
- if (this.sensitiveParams.has(lowerKey)) {
157
+ if (matchesSensitiveTerm(key, this.sensitiveParams)) {
134
158
  masked[key] = this.maskReplacement;
135
159
  }
136
160
  else if (value !== null && typeof value === 'object') {
@@ -159,8 +183,7 @@ let DataMaskerService = class DataMaskerService {
159
183
  const masked = {};
160
184
  const userObj = user;
161
185
  for (const [key, value] of Object.entries(userObj)) {
162
- const lowerKey = key.toLowerCase();
163
- if (this.sensitiveUserFields.has(lowerKey)) {
186
+ if (matchesSensitiveTerm(key, this.sensitiveUserFields)) {
164
187
  masked[key] = this.maskReplacement;
165
188
  }
166
189
  else if (value !== null && typeof value === 'object') {
@@ -197,10 +220,9 @@ let DataMaskerService = class DataMaskerService {
197
220
  * Check if a key is sensitive.
198
221
  */
199
222
  isSensitiveKey(key) {
200
- const lowerKey = key.toLowerCase();
201
- return (this.sensitiveHeaders.has(lowerKey) ||
202
- this.sensitiveParams.has(lowerKey) ||
203
- this.sensitiveUserFields.has(lowerKey));
223
+ return (matchesSensitiveTerm(key, this.sensitiveHeaders) ||
224
+ matchesSensitiveTerm(key, this.sensitiveParams) ||
225
+ matchesSensitiveTerm(key, this.sensitiveUserFields));
204
226
  }
205
227
  /**
206
228
  * Get the mask replacement string.
@@ -0,0 +1,16 @@
1
+ import { CursorPaginationParams, StoredEntry } from '../../types';
2
+ /**
3
+ * Whether a stored entry satisfies a set of dashboard filters.
4
+ *
5
+ * One implementation on purpose. MemoryStorage and RedisStorage each filter in
6
+ * JavaScript over hydrated entries, and each used to carry its own copy of
7
+ * these rules — the Redis copy said "apply the same filter logic as
8
+ * MemoryStorage" while implementing nine of the forty-four. Filtering by
9
+ * method, path, status, IP or tag on Redis did nothing at all: the badge click
10
+ * changed the URL and the list came back untouched, with no error to notice.
11
+ *
12
+ * Tags are read from the entry rather than from a storage's own index, so both
13
+ * callers hydrate before filtering and the rules stay independent of where the
14
+ * entries came from.
15
+ */
16
+ export declare const matchesEntryFilters: (entry: StoredEntry, filters: CursorPaginationParams["filters"]) => boolean;
@@ -0,0 +1,260 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.matchesEntryFilters = void 0;
4
+ /**
5
+ * Whether a stored entry satisfies a set of dashboard filters.
6
+ *
7
+ * One implementation on purpose. MemoryStorage and RedisStorage each filter in
8
+ * JavaScript over hydrated entries, and each used to carry its own copy of
9
+ * these rules — the Redis copy said "apply the same filter logic as
10
+ * MemoryStorage" while implementing nine of the forty-four. Filtering by
11
+ * method, path, status, IP or tag on Redis did nothing at all: the badge click
12
+ * changed the URL and the list came back untouched, with no error to notice.
13
+ *
14
+ * Tags are read from the entry rather than from a storage's own index, so both
15
+ * callers hydrate before filtering and the rules stay independent of where the
16
+ * entries came from.
17
+ */
18
+ const matchesEntryFilters = (entry, filters) => {
19
+ if (!filters)
20
+ return true;
21
+ const payload = entry.payload;
22
+ // Log filters
23
+ if (filters.levels?.length && entry.type === 'log') {
24
+ if (!filters.levels.includes(payload.level))
25
+ return false;
26
+ }
27
+ if (filters.contexts?.length && entry.type === 'log') {
28
+ if (!filters.contexts.includes(payload.context))
29
+ return false;
30
+ }
31
+ // Query filters
32
+ if (filters.queryTypes?.length && entry.type === 'query') {
33
+ const query = payload.query || '';
34
+ if (!filters.queryTypes.some((qt) => query.toUpperCase().startsWith(qt)))
35
+ return false;
36
+ }
37
+ if (filters.sources?.length) {
38
+ if (!filters.sources.includes(payload.source))
39
+ return false;
40
+ }
41
+ if (filters.slow !== undefined && entry.type === 'query') {
42
+ if (payload.slow !== filters.slow)
43
+ return false;
44
+ }
45
+ // Exception filters
46
+ if (filters.names?.length && entry.type === 'exception') {
47
+ const name = payload.name;
48
+ if (!filters.names.some((n) => name?.includes(n)))
49
+ return false;
50
+ }
51
+ if (filters.resolved !== undefined) {
52
+ const isResolved = !!entry.resolvedAt;
53
+ if (isResolved !== filters.resolved)
54
+ return false;
55
+ }
56
+ // Request filters
57
+ if (filters.methods?.length) {
58
+ const method = payload.method || payload.request?.method;
59
+ if (!method || !filters.methods.includes(method))
60
+ return false;
61
+ }
62
+ if (filters.paths?.length) {
63
+ const path = payload.path || payload.request?.url || '';
64
+ if (!filters.paths.some((p) => {
65
+ const pattern = p.replace(/\*/g, '.*');
66
+ return new RegExp(pattern).test(path);
67
+ }))
68
+ return false;
69
+ }
70
+ if (filters.statuses?.length) {
71
+ const status = payload.statusCode;
72
+ const hasErr = filters.statuses.includes('ERR');
73
+ const numericStatuses = filters.statuses.filter((s) => s !== 'ERR');
74
+ if (status === undefined || status === null) {
75
+ if (!hasErr)
76
+ return false;
77
+ }
78
+ else {
79
+ if (!numericStatuses.includes(status))
80
+ return false;
81
+ }
82
+ }
83
+ if (filters.hostnames?.length) {
84
+ const host = payload.headers?.host ||
85
+ payload.headers?.Host ||
86
+ payload.hostname;
87
+ if (!host || !filters.hostnames.some((h) => host.includes(h)))
88
+ return false;
89
+ }
90
+ if (filters.controllers?.length) {
91
+ if (!filters.controllers.includes(payload.controllerAction))
92
+ return false;
93
+ }
94
+ if (filters.ips?.length) {
95
+ if (!filters.ips.includes(payload.ip))
96
+ return false;
97
+ }
98
+ // Event filters
99
+ if (filters.eventNames?.length && entry.type === 'event') {
100
+ const name = payload.name;
101
+ if (!filters.eventNames.some((n) => name?.includes(n)))
102
+ return false;
103
+ }
104
+ // Schedule filters
105
+ if (filters.scheduleStatuses?.length && entry.type === 'schedule') {
106
+ if (!filters.scheduleStatuses.includes(payload.status))
107
+ return false;
108
+ }
109
+ if (filters.scheduleNames?.length && entry.type === 'schedule') {
110
+ const name = payload.name;
111
+ if (!filters.scheduleNames.some((n) => name?.includes(n)))
112
+ return false;
113
+ }
114
+ // Job filters
115
+ if (filters.jobStatuses?.length && entry.type === 'job') {
116
+ if (!filters.jobStatuses.includes(payload.status))
117
+ return false;
118
+ }
119
+ if (filters.jobNames?.length && entry.type === 'job') {
120
+ const name = payload.name;
121
+ if (!filters.jobNames.some((n) => name?.includes(n)))
122
+ return false;
123
+ }
124
+ if (filters.queues?.length && entry.type === 'job') {
125
+ if (!filters.queues.includes(payload.queue))
126
+ return false;
127
+ }
128
+ // Cache filters
129
+ if (filters.cacheOperations?.length && entry.type === 'cache') {
130
+ if (!filters.cacheOperations.includes(payload.operation))
131
+ return false;
132
+ }
133
+ // Mail filters
134
+ if (filters.mailStatuses?.length && entry.type === 'mail') {
135
+ if (!filters.mailStatuses.includes(payload.status))
136
+ return false;
137
+ }
138
+ // Redis filters
139
+ if (filters.redisStatuses?.length && entry.type === 'redis') {
140
+ if (!filters.redisStatuses.includes(payload.status))
141
+ return false;
142
+ }
143
+ if (filters.redisCommands?.length && entry.type === 'redis') {
144
+ if (!filters.redisCommands.includes(payload.command))
145
+ return false;
146
+ }
147
+ // Model filters
148
+ if (filters.modelActions?.length && entry.type === 'model') {
149
+ if (!filters.modelActions.includes(payload.action))
150
+ return false;
151
+ }
152
+ if (filters.entities?.length && entry.type === 'model') {
153
+ if (!filters.entities.includes(payload.entity))
154
+ return false;
155
+ }
156
+ if (filters.modelSources?.length && entry.type === 'model') {
157
+ if (!filters.modelSources.includes(payload.source))
158
+ return false;
159
+ }
160
+ // Notification filters
161
+ if (filters.notificationTypes?.length && entry.type === 'notification') {
162
+ if (!filters.notificationTypes.includes(payload.type))
163
+ return false;
164
+ }
165
+ if (filters.notificationStatuses?.length && entry.type === 'notification') {
166
+ if (!filters.notificationStatuses.includes(payload.status))
167
+ return false;
168
+ }
169
+ // View filters
170
+ if (filters.viewFormats?.length && entry.type === 'view') {
171
+ if (!filters.viewFormats.includes(payload.format))
172
+ return false;
173
+ }
174
+ if (filters.viewStatuses?.length && entry.type === 'view') {
175
+ if (!filters.viewStatuses.includes(payload.status))
176
+ return false;
177
+ }
178
+ // Command filters
179
+ if (filters.commandStatuses?.length && entry.type === 'command') {
180
+ if (!filters.commandStatuses.includes(payload.status))
181
+ return false;
182
+ }
183
+ if (filters.commandNames?.length && entry.type === 'command') {
184
+ const name = payload.name;
185
+ if (!filters.commandNames.some((n) => name?.includes(n)))
186
+ return false;
187
+ }
188
+ // Gate filters
189
+ if (filters.gateNames?.length && entry.type === 'gate') {
190
+ const gate = payload.gate;
191
+ if (!filters.gateNames.some((n) => gate?.includes(n)))
192
+ return false;
193
+ }
194
+ if (filters.gateResults?.length && entry.type === 'gate') {
195
+ const allowed = payload.allowed;
196
+ const result = allowed ? 'allowed' : 'denied';
197
+ if (!filters.gateResults.includes(result))
198
+ return false;
199
+ }
200
+ // Batch filters
201
+ if (filters.batchStatuses?.length && entry.type === 'batch') {
202
+ if (!filters.batchStatuses.includes(payload.status))
203
+ return false;
204
+ }
205
+ if (filters.batchOperations?.length && entry.type === 'batch') {
206
+ if (!filters.batchOperations.includes(payload.operation))
207
+ return false;
208
+ }
209
+ // Dump filters
210
+ if (filters.dumpStatuses?.length && entry.type === 'dump') {
211
+ if (!filters.dumpStatuses.includes(payload.status))
212
+ return false;
213
+ }
214
+ if (filters.dumpOperations?.length && entry.type === 'dump') {
215
+ if (!filters.dumpOperations.includes(payload.operation))
216
+ return false;
217
+ }
218
+ if (filters.dumpFormats?.length && entry.type === 'dump') {
219
+ if (!filters.dumpFormats.includes(payload.format))
220
+ return false;
221
+ }
222
+ // GraphQL filters
223
+ if (filters.operationTypes?.length && entry.type === 'graphql') {
224
+ if (!filters.operationTypes.includes(payload.operationType))
225
+ return false;
226
+ }
227
+ if (filters.operationNames?.length && entry.type === 'graphql') {
228
+ const opName = payload.operationName;
229
+ if (!filters.operationNames.some((n) => opName?.includes(n)))
230
+ return false;
231
+ }
232
+ if (filters.hasErrors !== undefined && entry.type === 'graphql') {
233
+ if (payload.hasErrors !== filters.hasErrors)
234
+ return false;
235
+ }
236
+ if (filters.hasN1 !== undefined && entry.type === 'graphql') {
237
+ const n1Array = payload.potentialN1;
238
+ const hasN1 = n1Array && n1Array.length > 0;
239
+ if (hasN1 !== filters.hasN1)
240
+ return false;
241
+ }
242
+ // Tag filter (case-insensitive)
243
+ if (filters.tags?.length) {
244
+ // Normalize both sides to uppercase for case-insensitive matching
245
+ const entryTags = (entry.tags ?? []).map((t) => t.toUpperCase());
246
+ const normalizedFilterTags = filters.tags.map((t) => t.toUpperCase());
247
+ if (!normalizedFilterTags.some((t) => entryTags.includes(t)))
248
+ return false;
249
+ }
250
+ // Search filter (matches payload content or entry tags)
251
+ if (filters.search) {
252
+ const term = filters.search.toLowerCase();
253
+ const payloadStr = JSON.stringify(payload).toLowerCase();
254
+ const tagMatch = (entry.tags ?? []).some((t) => t.toLowerCase().includes(term));
255
+ if (!payloadStr.includes(term) && !tagMatch)
256
+ return false;
257
+ }
258
+ return true;
259
+ };
260
+ exports.matchesEntryFilters = matchesEntryFilters;