nestlens 0.8.8 → 0.8.10
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/interceptors/api-response.interceptor.js +6 -1
- package/dist/core/collector.service.js +6 -2
- package/dist/core/request-context.d.ts +34 -0
- package/dist/core/request-context.js +23 -0
- package/dist/core/request-context.middleware.d.ts +16 -0
- package/dist/core/request-context.middleware.js +33 -0
- package/dist/core/storage/entry-filter.d.ts +16 -0
- package/dist/core/storage/entry-filter.js +260 -0
- package/dist/core/storage/memory.storage.js +5 -247
- package/dist/core/storage/redis.storage.js +2 -54
- package/dist/dashboard/public/assets/{BatchesPage-Da6-LE7p.js → BatchesPage-BuX1D-Qw.js} +1 -1
- package/dist/dashboard/public/assets/{CachePage-C6WIa9wE.js → CachePage-c9NdxnLF.js} +1 -1
- package/dist/dashboard/public/assets/{ClickableBadge-MXu6YkUJ.js → ClickableBadge-DIMjoLzU.js} +1 -1
- package/dist/dashboard/public/assets/{CommandsPage-LAbYZ-a3.js → CommandsPage-UA71c6cn.js} +1 -1
- package/dist/dashboard/public/assets/{DashboardPage-DK5v8C5f.js → DashboardPage-Cg4B1v71.js} +1 -1
- package/dist/dashboard/public/assets/{DumpsPage-CyXey6np.js → DumpsPage-DPjT0K-W.js} +1 -1
- package/dist/dashboard/public/assets/{EntryDetailPage-BD2PRQth.js → EntryDetailPage-_HHpZVRb.js} +1 -1
- package/dist/dashboard/public/assets/{EntrySearchInput-6EnNn0Gr.js → EntrySearchInput-Dyav5E5-.js} +1 -1
- package/dist/dashboard/public/assets/{EventsPage-Cyl11EwA.js → EventsPage-C3BjM-u_.js} +1 -1
- package/dist/dashboard/public/assets/{ExceptionsPage-CZdBOJGX.js → ExceptionsPage--aa1xm13.js} +1 -1
- package/dist/dashboard/public/assets/{GatesPage-CXEMLTV9.js → GatesPage-DCpvh5Eq.js} +1 -1
- package/dist/dashboard/public/assets/{GraphQLPage-B541mzFi.js → GraphQLPage-0dO4WQQI.js} +1 -1
- package/dist/dashboard/public/assets/{HttpClientPage-DPikBJ0q.js → HttpClientPage-Bn1Tb9mM.js} +1 -1
- package/dist/dashboard/public/assets/{JobsPage-CAD5s2bm.js → JobsPage-aSdQC9Of.js} +1 -1
- package/dist/dashboard/public/assets/{LogsPage-DSJ2-WrC.js → LogsPage-CRlOEyuz.js} +1 -1
- package/dist/dashboard/public/assets/{MailPage-Cs7Q78zr.js → MailPage-Bmfqpr8z.js} +1 -1
- package/dist/dashboard/public/assets/{ModelsPage-DIRozljj.js → ModelsPage-CzX1Bkcw.js} +1 -1
- package/dist/dashboard/public/assets/{NotificationsPage-Dqxsi_wJ.js → NotificationsPage-CNQ7ZU3Z.js} +1 -1
- package/dist/dashboard/public/assets/{PageHeader-l0rbvbEJ.js → PageHeader-Dy1i1YMN.js} +1 -1
- package/dist/dashboard/public/assets/{QueriesPage-BEkQtsGy.js → QueriesPage-BlzALGM-.js} +1 -1
- package/dist/dashboard/public/assets/{RedisPage-D55U0Vdz.js → RedisPage-fHFUgVjS.js} +1 -1
- package/dist/dashboard/public/assets/{RequestsPage-DMWkfYX0.js → RequestsPage-DZLasLTv.js} +1 -1
- package/dist/dashboard/public/assets/{SchedulePage-XR2f9XdQ.js → SchedulePage-x5dG87Qk.js} +1 -1
- package/dist/dashboard/public/assets/{ViewsPage-D0RDqTkG.js → ViewsPage-DISrSULL.js} +1 -1
- package/dist/dashboard/public/assets/{calendar-u8l0OwR3.js → calendar-Camxqdlp.js} +1 -1
- package/dist/dashboard/public/assets/{circle-check-big-Dv8ky8SZ.js → circle-check-big-oB7KFF_S.js} +1 -1
- package/dist/dashboard/public/assets/{eye-B2We_czC.js → eye-CNwth9uN.js} +1 -1
- package/dist/dashboard/public/assets/{index-BBxPq0bb.js → index-fV4VT_EH.js} +2 -2
- package/dist/dashboard/public/assets/{search-gQGNOvtD.js → search-G_aOCia0.js} +1 -1
- package/dist/dashboard/public/assets/{types-DauH_Fk6.js → types-Sj3ahDpV.js} +1 -1
- package/dist/dashboard/public/assets/{zap-C-mK4UPD.js → zap-DcjSBmCK.js} +1 -1
- package/dist/dashboard/public/index.html +1 -1
- package/dist/nestlens.module.d.ts +10 -2
- package/dist/nestlens.module.js +11 -0
- package/dist/watchers/request.watcher.js +4 -1
- package/package.json +1 -1
|
@@ -91,7 +91,6 @@ let NestLensApiResponseInterceptor = class NestLensApiResponseInterceptor {
|
|
|
91
91
|
// Handle structured controller responses
|
|
92
92
|
if (this.isControllerResponse(response)) {
|
|
93
93
|
const { data, meta, ...rest } = response;
|
|
94
|
-
// Build the response with any additional properties (like 'related').
|
|
95
94
|
// Deliberately not a nullish check: a controller answering `data: null`
|
|
96
95
|
// — "no such entry" — has provided data, and must not be answered with
|
|
97
96
|
// the surrounding object instead.
|
|
@@ -100,6 +99,12 @@ let NestLensApiResponseInterceptor = class NestLensApiResponseInterceptor {
|
|
|
100
99
|
return {
|
|
101
100
|
success: true,
|
|
102
101
|
data: responseData,
|
|
102
|
+
// Anything the controller sent alongside `data` travels with it. The
|
|
103
|
+
// comment here always said "any additional properties (like
|
|
104
|
+
// 'related')", but they were destructured out and dropped: a request's
|
|
105
|
+
// detail page asked for the queries it ran, the controller looked them
|
|
106
|
+
// up, and the envelope threw them away before the dashboard saw them.
|
|
107
|
+
...(dataProvided ? rest : {}),
|
|
103
108
|
error: null,
|
|
104
109
|
meta: {
|
|
105
110
|
timestamp: new Date().toISOString(),
|
|
@@ -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 request_context_1 = require("./request-context");
|
|
19
20
|
const storage_interface_1 = require("./storage/storage.interface");
|
|
20
21
|
const tag_service_1 = require("./tag.service");
|
|
21
22
|
const family_hash_service_1 = require("./family-hash.service");
|
|
@@ -127,7 +128,10 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
127
128
|
const entry = {
|
|
128
129
|
type,
|
|
129
130
|
payload,
|
|
130
|
-
|
|
131
|
+
// A watcher that knows the request says so; the rest are attributed from
|
|
132
|
+
// the ambient context, which is how a query recorded by TypeORM's logger
|
|
133
|
+
// ends up on the detail page of the request that ran it.
|
|
134
|
+
requestId: requestId ?? (0, request_context_1.currentRequestId)(),
|
|
131
135
|
};
|
|
132
136
|
// Apply filter
|
|
133
137
|
const shouldCollect = await this.applyFilter(entry);
|
|
@@ -155,7 +159,7 @@ let CollectorService = CollectorService_1 = class CollectorService {
|
|
|
155
159
|
const entry = {
|
|
156
160
|
type,
|
|
157
161
|
payload,
|
|
158
|
-
requestId,
|
|
162
|
+
requestId: requestId ?? (0, request_context_1.currentRequestId)(),
|
|
159
163
|
};
|
|
160
164
|
// Apply filter
|
|
161
165
|
const shouldCollect = await this.applyFilter(entry);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The request an entry belongs to, carried across async boundaries.
|
|
3
|
+
*
|
|
4
|
+
* A watcher that sits on the HTTP request can read the request object; the ones
|
|
5
|
+
* that matter most cannot. The query watcher is handed a statement by TypeORM's
|
|
6
|
+
* logger or Prisma's middleware, the cache watcher by a wrapped method — none of
|
|
7
|
+
* them are given a request, and so none of their entries carried one. Of the
|
|
8
|
+
* twenty-one places that record an entry, two passed a request id, which is why
|
|
9
|
+
* a request's detail page could show the exceptions it raised and never the
|
|
10
|
+
* queries it ran, while the documentation offered "request correlation ID" and
|
|
11
|
+
* "group related entries by request".
|
|
12
|
+
*
|
|
13
|
+
* Threading an argument through twenty-one call sites would have fixed the ones
|
|
14
|
+
* that exist. This carries the id in the ambient async context instead, so an
|
|
15
|
+
* entry recorded anywhere inside a request belongs to it — including from a
|
|
16
|
+
* watcher written next year.
|
|
17
|
+
*/
|
|
18
|
+
export interface RequestContext {
|
|
19
|
+
readonly requestId: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Runs `work` with a request context in scope.
|
|
23
|
+
*
|
|
24
|
+
* Installed as middleware rather than an interceptor on purpose: middleware
|
|
25
|
+
* calls into the rest of the request synchronously, so everything downstream —
|
|
26
|
+
* guards, interceptors, the handler, and whatever they await — runs inside the
|
|
27
|
+
* scope. An interceptor returns an Observable that Nest subscribes to after the
|
|
28
|
+
* interceptor's own frame has gone, taking the context with it.
|
|
29
|
+
*/
|
|
30
|
+
export declare const runInRequestContext: <T>(requestId: string, work: () => T) => T;
|
|
31
|
+
/** The current request's id, or `undefined` outside a request. */
|
|
32
|
+
export declare const currentRequestId: () => string | undefined;
|
|
33
|
+
/** A fresh correlation id, in the one place that decides their shape. */
|
|
34
|
+
export declare const newRequestId: () => string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newRequestId = exports.currentRequestId = exports.runInRequestContext = void 0;
|
|
4
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const storage = new node_async_hooks_1.AsyncLocalStorage();
|
|
7
|
+
/**
|
|
8
|
+
* Runs `work` with a request context in scope.
|
|
9
|
+
*
|
|
10
|
+
* Installed as middleware rather than an interceptor on purpose: middleware
|
|
11
|
+
* calls into the rest of the request synchronously, so everything downstream —
|
|
12
|
+
* guards, interceptors, the handler, and whatever they await — runs inside the
|
|
13
|
+
* scope. An interceptor returns an Observable that Nest subscribes to after the
|
|
14
|
+
* interceptor's own frame has gone, taking the context with it.
|
|
15
|
+
*/
|
|
16
|
+
const runInRequestContext = (requestId, work) => storage.run({ requestId }, work);
|
|
17
|
+
exports.runInRequestContext = runInRequestContext;
|
|
18
|
+
/** The current request's id, or `undefined` outside a request. */
|
|
19
|
+
const currentRequestId = () => storage.getStore()?.requestId;
|
|
20
|
+
exports.currentRequestId = currentRequestId;
|
|
21
|
+
/** A fresh correlation id, in the one place that decides their shape. */
|
|
22
|
+
const newRequestId = () => (0, node_crypto_1.randomUUID)();
|
|
23
|
+
exports.newRequestId = newRequestId;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NestMiddleware } from '@nestjs/common';
|
|
2
|
+
import { NestLensRequest } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Opens a request context around everything the application does for a request.
|
|
5
|
+
*
|
|
6
|
+
* Runs before guards, interceptors and the handler, so an entry recorded by any
|
|
7
|
+
* watcher — a query, a cache read, an outgoing HTTP call — can be attributed to
|
|
8
|
+
* the request that caused it without being handed one.
|
|
9
|
+
*
|
|
10
|
+
* The id is also written onto the request object, which is where the request and
|
|
11
|
+
* exception watchers already look for it, so both halves agree on one id per
|
|
12
|
+
* request.
|
|
13
|
+
*/
|
|
14
|
+
export declare class RequestContextMiddleware implements NestMiddleware {
|
|
15
|
+
use(request: NestLensRequest, _response: unknown, next: () => void): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RequestContextMiddleware = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const request_context_1 = require("./request-context");
|
|
12
|
+
/**
|
|
13
|
+
* Opens a request context around everything the application does for a request.
|
|
14
|
+
*
|
|
15
|
+
* Runs before guards, interceptors and the handler, so an entry recorded by any
|
|
16
|
+
* watcher — a query, a cache read, an outgoing HTTP call — can be attributed to
|
|
17
|
+
* the request that caused it without being handed one.
|
|
18
|
+
*
|
|
19
|
+
* The id is also written onto the request object, which is where the request and
|
|
20
|
+
* exception watchers already look for it, so both halves agree on one id per
|
|
21
|
+
* request.
|
|
22
|
+
*/
|
|
23
|
+
let RequestContextMiddleware = class RequestContextMiddleware {
|
|
24
|
+
use(request, _response, next) {
|
|
25
|
+
const requestId = request.nestlensRequestId ?? (0, request_context_1.newRequestId)();
|
|
26
|
+
request.nestlensRequestId = requestId;
|
|
27
|
+
(0, request_context_1.runInRequestContext)(requestId, next);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.RequestContextMiddleware = RequestContextMiddleware;
|
|
31
|
+
exports.RequestContextMiddleware = RequestContextMiddleware = __decorate([
|
|
32
|
+
(0, common_1.Injectable)()
|
|
33
|
+
], RequestContextMiddleware);
|
|
@@ -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;
|