@warlock.js/devtools 5.60.0 → 5.61.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/CHANGELOG.md +13 -0
- package/cjs/{boot-Dg5YZGGR.cjs → boot-D0nF-7w3.cjs} +6 -5
- package/cjs/{boot-Dg5YZGGR.cjs.map → boot-D0nF-7w3.cjs.map} +1 -1
- package/cjs/{capture-CBgONYhk.cjs → capture-D2k0GnBN.cjs} +21 -420
- package/cjs/capture-D2k0GnBN.cjs.map +1 -0
- package/cjs/{collector-CJbQbzzK.cjs → collector-BfC4v87v.cjs} +4 -46
- package/cjs/collector-BfC4v87v.cjs.map +1 -0
- package/cjs/errors-DNQ-g49I.cjs.map +1 -1
- package/cjs/{http-DCVCf44M.cjs → http-1nnpAoI7.cjs} +10 -4
- package/cjs/http-1nnpAoI7.cjs.map +1 -0
- package/cjs/index.cjs +1 -1
- package/cjs/{insights-CFof59kF.cjs → insights-COA3u37q.cjs} +53 -21
- package/cjs/insights-COA3u37q.cjs.map +1 -0
- package/cjs/query-shape-DShKQa0x.cjs +45 -0
- package/cjs/query-shape-DShKQa0x.cjs.map +1 -0
- package/cjs/redact-DQ28mDzr.cjs +533 -0
- package/cjs/redact-DQ28mDzr.cjs.map +1 -0
- package/cjs/{server-CC5DpObz.cjs → server-DLT3uPef.cjs} +2 -2
- package/cjs/{server-CC5DpObz.cjs.map → server-DLT3uPef.cjs.map} +1 -1
- package/cjs/{src-VyOjEEAo.cjs → src-BZiSv8A1.cjs} +9 -6
- package/cjs/src-BZiSv8A1.cjs.map +1 -0
- package/cjs/{stream-route-DFHuIWgg.cjs → stream-route-B6WAjbPG.cjs} +5 -8
- package/cjs/stream-route-B6WAjbPG.cjs.map +1 -0
- package/esm/devtools-connector.d.mts.map +1 -1
- package/esm/devtools-connector.mjs +4 -1
- package/esm/devtools-connector.mjs.map +1 -1
- package/esm/index.d.mts +2 -2
- package/esm/production/boot.mjs +1 -0
- package/esm/production/boot.mjs.map +1 -1
- package/esm/production/contracts.d.mts +17 -4
- package/esm/production/contracts.d.mts.map +1 -1
- package/esm/production/contracts.mjs.map +1 -1
- package/esm/production/http/mount.mjs +8 -2
- package/esm/production/http/mount.mjs.map +1 -1
- package/esm/production/http/share.mjs.map +1 -1
- package/esm/production/index.d.mts +2 -2
- package/esm/production/insights/jobs.mjs +45 -11
- package/esm/production/insights/jobs.mjs.map +1 -1
- package/esm/server/panel-routes.mjs.map +1 -1
- package/esm/server/ui-assets.mjs +4 -7
- package/esm/server/ui-assets.mjs.map +1 -1
- package/esm/types.d.mts +2 -2
- package/llms-full.txt +22 -22
- package/package.json +8 -8
- package/skills/SKILL.md +22 -22
- package/ui/dashboard/assets/app.css +1 -1
- package/ui/dashboard/assets/app.js +2 -2
- package/ui/dashboard/build-info.json +7 -7
- package/cjs/capture-CBgONYhk.cjs.map +0 -1
- package/cjs/collector-CJbQbzzK.cjs.map +0 -1
- package/cjs/histogram-CkoVizdf.cjs +0 -102
- package/cjs/histogram-CkoVizdf.cjs.map +0 -1
- package/cjs/http-DCVCf44M.cjs.map +0 -1
- package/cjs/insights-CFof59kF.cjs.map +0 -1
- package/cjs/src-VyOjEEAo.cjs.map +0 -1
- package/cjs/stream-route-DFHuIWgg.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ All notable changes to `@warlock.js/devtools` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
|
|
6
6
|
|
|
7
|
+
## 5.61.0 - 2026-11-20
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- The Jobs tab shows each schedule's last duration, last error, runs, failures and recent runs, and the job counts (waiting, active, delayed, failed, completed) of each queue. "Counts not available" appears only for a queue driver without `counts()`.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Closed production monitor URLs answer exactly like any unknown URL of the app, including a web site's `route_not_found` answer (JSON and document), instead of Fastify's default 404. The app's global rate limit applies to them as to any unknown URL (same `x-ratelimit-*` headers, same 429), and an error of the app's catch-all gets the app's own error answer.
|
|
16
|
+
- The Jobs tab finds the active queue driver; before, it could not and always said the queue was not available.
|
|
17
|
+
- Error messages in the Jobs tab (last error, recent runs) are scrubbed like request errors: quoted values, emails and documents are removed.
|
|
18
|
+
- The Queries tab works when production mode is enabled only through `devtoolsConnector` options; `queryEvents: true` is no longer needed.
|
|
19
|
+
|
|
7
20
|
## 5.60.0 - 2026-11-19
|
|
8
21
|
|
|
9
22
|
### Added
|
|
@@ -81,9 +81,9 @@ async function bootProductionDevtools(input) {
|
|
|
81
81
|
const [{ createCascadeStore }, authModule, captureModule, insightsModule, httpModule] = await Promise.all([
|
|
82
82
|
Promise.resolve().then(() => require("./store-EFn4wp0T.cjs")),
|
|
83
83
|
Promise.resolve().then(() => require("./auth-ChHh5E7j.cjs")),
|
|
84
|
-
Promise.resolve().then(() => require("./capture-
|
|
85
|
-
Promise.resolve().then(() => require("./insights-
|
|
86
|
-
Promise.resolve().then(() => require("./http-
|
|
84
|
+
Promise.resolve().then(() => require("./capture-D2k0GnBN.cjs")),
|
|
85
|
+
Promise.resolve().then(() => require("./insights-COA3u37q.cjs")),
|
|
86
|
+
Promise.resolve().then(() => require("./http-1nnpAoI7.cjs"))
|
|
87
87
|
]);
|
|
88
88
|
const store = await createCascadeStore({ shares: production.share.enabled });
|
|
89
89
|
await store.verify();
|
|
@@ -156,7 +156,7 @@ async function bootProductionDevtools(input) {
|
|
|
156
156
|
stops.push(() => aiWiring.reports.dispose());
|
|
157
157
|
if (typeof core.excludeFromRequestLog === "function") stops.push(core.excludeFromRequestLog(production.path));
|
|
158
158
|
if (builtIn.includes("mail")) {
|
|
159
|
-
const { attachMailSource } = await Promise.resolve().then(() => require("./src-
|
|
159
|
+
const { attachMailSource } = await Promise.resolve().then(() => require("./src-BZiSv8A1.cjs")).then((n) => n.mail_source_exports);
|
|
160
160
|
stops.push(await attachMailSource(capture.collector));
|
|
161
161
|
}
|
|
162
162
|
httpModule.mountProductionDevtools(server, {
|
|
@@ -177,6 +177,7 @@ async function bootProductionDevtools(input) {
|
|
|
177
177
|
builtInPanels: builtIn,
|
|
178
178
|
state,
|
|
179
179
|
warn,
|
|
180
|
+
...typeof core.answerUnknownUrl === "function" ? { answerUnknownUrl: core.answerUnknownUrl } : {},
|
|
180
181
|
hmac: (value) => crypto.hmac(value)
|
|
181
182
|
});
|
|
182
183
|
publishMounted(production.path);
|
|
@@ -201,4 +202,4 @@ async function bootProductionDevtools(input) {
|
|
|
201
202
|
|
|
202
203
|
//#endregion
|
|
203
204
|
exports.bootProductionDevtools = bootProductionDevtools;
|
|
204
|
-
//# sourceMappingURL=boot-
|
|
205
|
+
//# sourceMappingURL=boot-D0nF-7w3.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot-Dg5YZGGR.cjs","names":["DEVTOOLS_MOUNTED_KEY","loadAiFeed","attachAiReports","resolveDevtoolsAiOptions","toAiUnavailableView","describeAiUnavailable","resolveProductionOptions","DevtoolsProductionConfigError","productionPanels"],"sources":["../../../../../../../packages/devtools/src/production/boot.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport {\n attachAiReports,\n DEVTOOLS_MOUNTED_KEY,\n type DevtoolsAiReports,\n loadAiFeed,\n} from \"../ai/attach\";\nimport { resolveDevtoolsAiOptions } from \"../ai/options\";\nimport { type MountedDevtoolsPanel, productionPanels } from \"../panels\";\nimport type { MountDevtoolsRoutesDeps } from \"../server/types\";\nimport type { ResolvedDevtoolsOptions } from \"../types\";\nimport { DevtoolsProductionConfigError } from \"./errors\";\nimport type { DevtoolsInsights } from \"./insights/types\";\nimport { resolveProductionOptions } from \"./options\";\nimport { describeAiUnavailable, toAiUnavailableView } from \"../sources/ai-source\";\n\n/** What the connector hands production boot. */\nexport type BootProductionDevtoolsInput = {\n options: ResolvedDevtoolsOptions;\n env: Readonly<Record<string, string | undefined>>;\n server: FastifyInstance;\n /** Package panels loaded with `mode: \"production\"` (not yet filtered). */\n panels: readonly MountedDevtoolsPanel[];\n /** The route deps the connector builds for development, reused (requestLog, listRoutes, ai, …). */\n routes: Omit<MountDevtoolsRoutesDeps, \"collector\" | \"options\" | \"isDevelopment\">;\n /** Reads one config value (`encryption.key`); defaults to core's `config.get`. */\n readConfig?: (key: string) => unknown;\n /** Called once the shared insights exist (panels read captured error counts through them). */\n onInsights?: (insights: DevtoolsInsights) => void;\n log: {\n info(module: string, action: string, message: string): unknown;\n warn(module: string, action: string, message: string): unknown;\n error(module: string, action: string, message: string): unknown;\n };\n};\n\nconst AI_REPORT_TABS: readonly string[] = [\"ai-reports\", \"ai-models\", \"ai-errors\"];\n\n/** Tells other packages (Panoptic) that devtools is mounted here and where. */\nfunction publishMounted(path: string): void {\n (globalThis as Record<symbol, unknown>)[DEVTOOLS_MOUNTED_KEY] = { path, mode: \"production\" };\n}\n\nfunction clearMounted(): void {\n delete (globalThis as Record<symbol, unknown>)[DEVTOOLS_MOUNTED_KEY];\n}\n\n/**\n * Loads the AI feed and starts this process's rollup writer (every process of\n * a deployment adds into the same table). Never throws: a failure leaves the\n * AI report tabs answering their unavailable view.\n */\nasync function attachProductionAi(\n options: ResolvedDevtoolsOptions,\n warn: (message: string) => void,\n): Promise<{ feedAvailable: boolean; reports: DevtoolsAiReports }> {\n const loaded = await loadAiFeed();\n\n if (\"unavailable\" in loaded) {\n return { feedAvailable: false, reports: { ...loaded.unavailable, async dispose() {} } };\n }\n\n try {\n return {\n feedAvailable: true,\n reports: await attachAiReports({\n feed: loaded.feed,\n options: resolveDevtoolsAiOptions(options.ai, \"production\"),\n warn,\n }),\n };\n } catch (error) {\n warn(`AI reports could not start: ${error instanceof Error ? error.message : String(error)}`);\n\n return {\n feedAvailable: true,\n reports: { ...toAiUnavailableView(describeAiUnavailable(\"reports-off\")), async dispose() {} },\n };\n }\n}\n\n/** `/ops-…`: the first part of the path, enough to recognise it and not enough to use it. */\nexport function maskDashboardPath(path: string): string {\n const match = /^\\/[A-Za-z]{1,8}-/.exec(path);\n\n return `${match ? match[0] : \"/\"}…`;\n}\n\n/** The key core encrypts with: 64 hex characters. */\nfunction hasEncryptionKey(value: unknown): boolean {\n return typeof value === \"string\" && /^[0-9a-fA-F]{64}$/.test(value);\n}\n\n/**\n * Starts the production monitor, in this order: resolve options (env) →\n * check `encryption.key` (DT006) → cascade store (DT005) → `store.verify()`\n * (DT008) → `ensureFirstAdmin()` (DT003/DT004) → instance info → capture\n * (attach hooks) → resource monitor, health history, jobs reader → local\n * reporter → report writer → shared insights → `excludeFromRequestLog(path)`\n * → mount. Logs one line with the path masked (`/ops-…`), never the full path.\n * Any `DevtoolsProductionConfigError` propagates: the app does not boot.\n *\n * Returns the disposer the connector calls at shutdown (flush samples, stop\n * timers, detach hooks).\n */\nexport async function bootProductionDevtools(\n input: BootProductionDevtoolsInput,\n): Promise<() => Promise<void>> {\n const { options, env, server, log } = input;\n const production = resolveProductionOptions(options.production, env);\n const core = await import(\"@warlock.js/core\");\n const readConfig = input.readConfig ?? ((key: string) => core.config.get(key));\n\n if (!hasEncryptionKey(readConfig(\"encryption.key\"))) {\n throw new DevtoolsProductionConfigError(\"DT006\");\n }\n\n const [{ createCascadeStore }, authModule, captureModule, insightsModule, httpModule] =\n await Promise.all([\n import(\"./store\"),\n import(\"./auth\"),\n import(\"./capture\"),\n import(\"./insights\"),\n import(\"./http\"),\n ]);\n\n const store = await createCascadeStore({ shares: production.share.enabled });\n\n await store.verify();\n\n const warn = (message: string): void => {\n log.warn(\"devtools\", \"production\", message);\n };\n if (production.twoFactor === \"off\") {\n warn(\n 'Two-factor sign-in is off for the dashboard (production.twoFactor is \"off\"): anyone with a password can sign in. Set it to \"admins\" or \"everyone\" to require an authenticator app or passkey.',\n );\n }\n\n const instance = insightsModule.createInstanceInfo();\n const [crypto, passkeys] = await Promise.all([\n authModule.defaultDevtoolsCrypto(),\n authModule.loadDevtoolsPasskeys(),\n ]);\n const auth = authModule.createDevtoolsAuth({\n store,\n options: production,\n instance,\n crypto,\n passkeys,\n warn,\n });\n\n await auth.ensureFirstAdmin();\n\n const isDashboardPath = (path: string): boolean =>\n path === production.path || path.startsWith(`${production.path}/`);\n const capture = captureModule.createProductionCapture({\n options,\n production,\n instance,\n store,\n isDashboardPath,\n warn,\n });\n const stops: (() => unknown)[] = [];\n\n try {\n stops.push(await capture.attach());\n\n const resources = insightsModule.createResourceMonitor();\n const health = insightsModule.createHealthHistory();\n\n resources.start();\n health.start();\n stops.push(\n () => resources.stop(),\n () => health.stop(),\n );\n\n const reporter = insightsModule.createLocalReporter({\n instance,\n resources,\n health,\n jobs: insightsModule.createJobsReader(),\n queries: capture.queries,\n routes: capture.routes,\n errors: capture.errors,\n logs: capture.logs,\n counters: () => capture.counters(),\n });\n const writer = insightsModule.startReportWriter({ reporter, store, production, warn });\n\n stops.push(() => writer.stop());\n\n const insights = insightsModule.createSharedInsights({\n store,\n reporter,\n sampleRate: production.sampleRate,\n });\n input.onInsights?.(insights);\n\n const state = httpModule.createDashboardState(store, production.path);\n const { builtIn: shownTabs, panels } = productionPanels(input.panels, production.panels);\n\n // The AI report tabs are listed only when the app has the AI feed (Panoptic), unless the project turned one on.\n // With every report tab turned off, no totals are written (and no missing-table warning is logged).\n const aiWiring = shownTabs.some((tab) => AI_REPORT_TABS.includes(tab))\n ? await attachProductionAi(options, warn)\n : {\n feedAvailable: false,\n reports: {\n ...toAiUnavailableView(describeAiUnavailable(\"reports-off\")),\n async dispose() {},\n },\n };\n const builtIn = aiWiring.feedAvailable\n ? shownTabs\n : shownTabs.filter((tab) => !AI_REPORT_TABS.includes(tab) || production.panels[tab] === true);\n\n stops.push(() => aiWiring.reports.dispose());\n\n // The dashboard's own requests are not worth a line in the request log, and its sign-in bodies must not reach it.\n if (typeof core.excludeFromRequestLog === \"function\") {\n stops.push(core.excludeFromRequestLog(production.path));\n }\n\n // Mail previews exist only when the project turned that tab on.\n if (builtIn.includes(\"mail\")) {\n const { attachMailSource } = await import(\"../sources/mail-source\");\n\n stops.push(await attachMailSource(capture.collector));\n }\n\n httpModule.mountProductionDevtools(server, {\n routes: {\n ...input.routes,\n aiReports: aiWiring.reports,\n collector: capture.collector,\n options,\n isDevelopment: () => false,\n },\n production,\n store,\n auth,\n capture,\n insights,\n instance,\n panels,\n builtInPanels: builtIn,\n state,\n warn,\n hmac: (value) => crypto.hmac(value),\n });\n\n publishMounted(production.path);\n stops.push(clearMounted);\n\n log.info(\n \"devtools\",\n \"ready\",\n `devtools production monitor mounted at ${maskDashboardPath(production.path)} (DEVTOOLS_PATH)`,\n );\n } catch (error) {\n for (const stop of stops.splice(0).reverse()) {\n try {\n void Promise.resolve(stop()).catch(() => undefined);\n } catch {\n // Cleanup after a failed boot must not hide the real error.\n }\n }\n\n void capture.dispose().catch(() => undefined);\n\n throw error;\n }\n\n // Returns the promise of the stops so the connector can wait for the final AI totals flush.\n return () => {\n const finished: Promise<unknown>[] = [];\n\n for (const stop of stops.splice(0).reverse()) {\n try {\n finished.push(Promise.resolve(stop()).catch(() => undefined));\n } catch {\n // Shutdown continues past a failing step.\n }\n }\n\n finished.push(capture.dispose().catch(() => undefined));\n\n return Promise.all(finished).then(() => undefined);\n };\n}\n"],"mappings":";;;;;AAoCA,MAAM,iBAAoC;CAAC;CAAc;CAAa;AAAW;;AAGjF,SAAS,eAAe,MAAoB;CAC1C,AAAC,WAAuCA,uCAAwB;EAAE;EAAM,MAAM;CAAa;AAC7F;AAEA,SAAS,eAAqB;CAC5B,OAAQ,WAAuCA;AACjD;;;;;;AAOA,eAAe,mBACb,SACA,MACiE;CACjE,MAAM,SAAS,MAAMC,0BAAW;CAEhC,IAAI,iBAAiB,QACnB,OAAO;EAAE,eAAe;EAAO,SAAS;GAAE,GAAG,OAAO;GAAa,MAAM,UAAU,CAAC;EAAE;CAAE;CAGxF,IAAI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,QAAQ,CAAC,CAAC,YAAY,MAAS,CAAC;EAEtD,OAAO,QAAQ,IAAI,QAAQ,CAAC,CAAC,WAAW,MAAS;CACnD;AACF"}
|
|
1
|
+
{"version":3,"file":"boot-D0nF-7w3.cjs","names":["DEVTOOLS_MOUNTED_KEY","loadAiFeed","attachAiReports","resolveDevtoolsAiOptions","toAiUnavailableView","describeAiUnavailable","resolveProductionOptions","DevtoolsProductionConfigError","productionPanels"],"sources":["../../../../../../../packages/devtools/src/production/boot.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport {\n attachAiReports,\n DEVTOOLS_MOUNTED_KEY,\n type DevtoolsAiReports,\n loadAiFeed,\n} from \"../ai/attach\";\nimport { resolveDevtoolsAiOptions } from \"../ai/options\";\nimport { type MountedDevtoolsPanel, productionPanels } from \"../panels\";\nimport type { MountDevtoolsRoutesDeps } from \"../server/types\";\nimport type { ResolvedDevtoolsOptions } from \"../types\";\nimport { DevtoolsProductionConfigError } from \"./errors\";\nimport type { DevtoolsInsights } from \"./insights/types\";\nimport { resolveProductionOptions } from \"./options\";\nimport { describeAiUnavailable, toAiUnavailableView } from \"../sources/ai-source\";\n\n/** What the connector hands production boot. */\nexport type BootProductionDevtoolsInput = {\n options: ResolvedDevtoolsOptions;\n env: Readonly<Record<string, string | undefined>>;\n server: FastifyInstance;\n /** Package panels loaded with `mode: \"production\"` (not yet filtered). */\n panels: readonly MountedDevtoolsPanel[];\n /** The route deps the connector builds for development, reused (requestLog, listRoutes, ai, …). */\n routes: Omit<MountDevtoolsRoutesDeps, \"collector\" | \"options\" | \"isDevelopment\">;\n /** Reads one config value (`encryption.key`); defaults to core's `config.get`. */\n readConfig?: (key: string) => unknown;\n /** Called once the shared insights exist (panels read captured error counts through them). */\n onInsights?: (insights: DevtoolsInsights) => void;\n log: {\n info(module: string, action: string, message: string): unknown;\n warn(module: string, action: string, message: string): unknown;\n error(module: string, action: string, message: string): unknown;\n };\n};\n\nconst AI_REPORT_TABS: readonly string[] = [\"ai-reports\", \"ai-models\", \"ai-errors\"];\n\n/** Tells other packages (Panoptic) that devtools is mounted here and where. */\nfunction publishMounted(path: string): void {\n (globalThis as Record<symbol, unknown>)[DEVTOOLS_MOUNTED_KEY] = { path, mode: \"production\" };\n}\n\nfunction clearMounted(): void {\n delete (globalThis as Record<symbol, unknown>)[DEVTOOLS_MOUNTED_KEY];\n}\n\n/**\n * Loads the AI feed and starts this process's rollup writer (every process of\n * a deployment adds into the same table). Never throws: a failure leaves the\n * AI report tabs answering their unavailable view.\n */\nasync function attachProductionAi(\n options: ResolvedDevtoolsOptions,\n warn: (message: string) => void,\n): Promise<{ feedAvailable: boolean; reports: DevtoolsAiReports }> {\n const loaded = await loadAiFeed();\n\n if (\"unavailable\" in loaded) {\n return { feedAvailable: false, reports: { ...loaded.unavailable, async dispose() {} } };\n }\n\n try {\n return {\n feedAvailable: true,\n reports: await attachAiReports({\n feed: loaded.feed,\n options: resolveDevtoolsAiOptions(options.ai, \"production\"),\n warn,\n }),\n };\n } catch (error) {\n warn(`AI reports could not start: ${error instanceof Error ? error.message : String(error)}`);\n\n return {\n feedAvailable: true,\n reports: { ...toAiUnavailableView(describeAiUnavailable(\"reports-off\")), async dispose() {} },\n };\n }\n}\n\n/** `/ops-…`: the first part of the path, enough to recognise it and not enough to use it. */\nexport function maskDashboardPath(path: string): string {\n const match = /^\\/[A-Za-z]{1,8}-/.exec(path);\n\n return `${match ? match[0] : \"/\"}…`;\n}\n\n/** The key core encrypts with: 64 hex characters. */\nfunction hasEncryptionKey(value: unknown): boolean {\n return typeof value === \"string\" && /^[0-9a-fA-F]{64}$/.test(value);\n}\n\n/**\n * Starts the production monitor, in this order: resolve options (env) →\n * check `encryption.key` (DT006) → cascade store (DT005) → `store.verify()`\n * (DT008) → `ensureFirstAdmin()` (DT003/DT004) → instance info → capture\n * (attach hooks) → resource monitor, health history, jobs reader → local\n * reporter → report writer → shared insights → `excludeFromRequestLog(path)`\n * → mount. Logs one line with the path masked (`/ops-…`), never the full path.\n * Any `DevtoolsProductionConfigError` propagates: the app does not boot.\n *\n * Returns the disposer the connector calls at shutdown (flush samples, stop\n * timers, detach hooks).\n */\nexport async function bootProductionDevtools(\n input: BootProductionDevtoolsInput,\n): Promise<() => Promise<void>> {\n const { options, env, server, log } = input;\n const production = resolveProductionOptions(options.production, env);\n const core = await import(\"@warlock.js/core\");\n const readConfig = input.readConfig ?? ((key: string) => core.config.get(key));\n\n if (!hasEncryptionKey(readConfig(\"encryption.key\"))) {\n throw new DevtoolsProductionConfigError(\"DT006\");\n }\n\n const [{ createCascadeStore }, authModule, captureModule, insightsModule, httpModule] =\n await Promise.all([\n import(\"./store\"),\n import(\"./auth\"),\n import(\"./capture\"),\n import(\"./insights\"),\n import(\"./http\"),\n ]);\n\n const store = await createCascadeStore({ shares: production.share.enabled });\n\n await store.verify();\n\n const warn = (message: string): void => {\n log.warn(\"devtools\", \"production\", message);\n };\n if (production.twoFactor === \"off\") {\n warn(\n 'Two-factor sign-in is off for the dashboard (production.twoFactor is \"off\"): anyone with a password can sign in. Set it to \"admins\" or \"everyone\" to require an authenticator app or passkey.',\n );\n }\n\n const instance = insightsModule.createInstanceInfo();\n const [crypto, passkeys] = await Promise.all([\n authModule.defaultDevtoolsCrypto(),\n authModule.loadDevtoolsPasskeys(),\n ]);\n const auth = authModule.createDevtoolsAuth({\n store,\n options: production,\n instance,\n crypto,\n passkeys,\n warn,\n });\n\n await auth.ensureFirstAdmin();\n\n const isDashboardPath = (path: string): boolean =>\n path === production.path || path.startsWith(`${production.path}/`);\n const capture = captureModule.createProductionCapture({\n options,\n production,\n instance,\n store,\n isDashboardPath,\n warn,\n });\n const stops: (() => unknown)[] = [];\n\n try {\n stops.push(await capture.attach());\n\n const resources = insightsModule.createResourceMonitor();\n const health = insightsModule.createHealthHistory();\n\n resources.start();\n health.start();\n stops.push(\n () => resources.stop(),\n () => health.stop(),\n );\n\n const reporter = insightsModule.createLocalReporter({\n instance,\n resources,\n health,\n jobs: insightsModule.createJobsReader(),\n queries: capture.queries,\n routes: capture.routes,\n errors: capture.errors,\n logs: capture.logs,\n counters: () => capture.counters(),\n });\n const writer = insightsModule.startReportWriter({ reporter, store, production, warn });\n\n stops.push(() => writer.stop());\n\n const insights = insightsModule.createSharedInsights({\n store,\n reporter,\n sampleRate: production.sampleRate,\n });\n input.onInsights?.(insights);\n\n const state = httpModule.createDashboardState(store, production.path);\n const { builtIn: shownTabs, panels } = productionPanels(input.panels, production.panels);\n\n // The AI report tabs are listed only when the app has the AI feed (Panoptic), unless the project turned one on.\n // With every report tab turned off, no totals are written (and no missing-table warning is logged).\n const aiWiring = shownTabs.some((tab) => AI_REPORT_TABS.includes(tab))\n ? await attachProductionAi(options, warn)\n : {\n feedAvailable: false,\n reports: {\n ...toAiUnavailableView(describeAiUnavailable(\"reports-off\")),\n async dispose() {},\n },\n };\n const builtIn = aiWiring.feedAvailable\n ? shownTabs\n : shownTabs.filter((tab) => !AI_REPORT_TABS.includes(tab) || production.panels[tab] === true);\n\n stops.push(() => aiWiring.reports.dispose());\n\n // The dashboard's own requests are not worth a line in the request log, and its sign-in bodies must not reach it.\n if (typeof core.excludeFromRequestLog === \"function\") {\n stops.push(core.excludeFromRequestLog(production.path));\n }\n\n // Mail previews exist only when the project turned that tab on.\n if (builtIn.includes(\"mail\")) {\n const { attachMailSource } = await import(\"../sources/mail-source\");\n\n stops.push(await attachMailSource(capture.collector));\n }\n\n httpModule.mountProductionDevtools(server, {\n routes: {\n ...input.routes,\n aiReports: aiWiring.reports,\n collector: capture.collector,\n options,\n isDevelopment: () => false,\n },\n production,\n store,\n auth,\n capture,\n insights,\n instance,\n panels,\n builtInPanels: builtIn,\n state,\n warn,\n ...(typeof core.answerUnknownUrl === \"function\"\n ? { answerUnknownUrl: core.answerUnknownUrl }\n : {}),\n hmac: (value) => crypto.hmac(value),\n });\n\n publishMounted(production.path);\n stops.push(clearMounted);\n\n log.info(\n \"devtools\",\n \"ready\",\n `devtools production monitor mounted at ${maskDashboardPath(production.path)} (DEVTOOLS_PATH)`,\n );\n } catch (error) {\n for (const stop of stops.splice(0).reverse()) {\n try {\n void Promise.resolve(stop()).catch(() => undefined);\n } catch {\n // Cleanup after a failed boot must not hide the real error.\n }\n }\n\n void capture.dispose().catch(() => undefined);\n\n throw error;\n }\n\n // Returns the promise of the stops so the connector can wait for the final AI totals flush.\n return () => {\n const finished: Promise<unknown>[] = [];\n\n for (const stop of stops.splice(0).reverse()) {\n try {\n finished.push(Promise.resolve(stop()).catch(() => undefined));\n } catch {\n // Shutdown continues past a failing step.\n }\n }\n\n finished.push(capture.dispose().catch(() => undefined));\n\n return Promise.all(finished).then(() => undefined);\n };\n}\n"],"mappings":";;;;;AAoCA,MAAM,iBAAoC;CAAC;CAAc;CAAa;AAAW;;AAGjF,SAAS,eAAe,MAAoB;CAC1C,AAAC,WAAuCA,uCAAwB;EAAE;EAAM,MAAM;CAAa;AAC7F;AAEA,SAAS,eAAqB;CAC5B,OAAQ,WAAuCA;AACjD;;;;;;AAOA,eAAe,mBACb,SACA,MACiE;CACjE,MAAM,SAAS,MAAMC,0BAAW;CAEhC,IAAI,iBAAiB,QACnB,OAAO;EAAE,eAAe;EAAO,SAAS;GAAE,GAAG,OAAO;GAAa,MAAM,UAAU,CAAC;EAAE;CAAE;CAGxF,IAAI;EACF,OAAO;GACL,eAAe;GACf,SAAS,MAAMC,+BAAgB;IAC7B,MAAM,OAAO;IACb,SAASC,wCAAyB,QAAQ,IAAI,YAAY;IAC1D;GACF,CAAC;EACH;CACF,SAAS,OAAO;EACd,KAAK,+BAA+B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;EAE5F,OAAO;GACL,eAAe;GACf,SAAS;IAAE,GAAGC,oCAAoBC,sCAAsB,aAAa,CAAC;IAAG,MAAM,UAAU,CAAC;GAAE;EAC9F;CACF;AACF;;AAGA,SAAgB,kBAAkB,MAAsB;CACtD,MAAM,QAAQ,oBAAoB,KAAK,IAAI;CAE3C,OAAO,GA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ACtD;EAEA,WAAW,wBAAwB,QAAQ;GACzC,QAAQ;IACN,GAAG,MAAM;IACT,WAAW,SAAS;IACpB,WAAW,QAAQ;IACnB;IACA,qBAAqB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,eAAe;GACf;GACA;GACA,GAAI,OAAO,KAAK,qBAAqB,aACjC,EAAE,kBAAkB,KAAK,iBAAiB,IAC1C,CAAC;GACL,OAAO,UAAU,OAAO,KAAK,KAAK;EACpC,CAAC;EAED,eAAe,WAAW,IAAI;EAC9B,MAAM,KAAK,YAAY;EAEvB,IAAI,KACF,YACA,SACA,0CAA0C,kBAAkB,WAAW,IAAI,EAAE,iBAC/E;CACF,SAAS,OAAO;EACd,KAAK,MAAM,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,QAAQ,GACzC,IAAI;GACF,AAAK,QAAQ,QAAQ,KAAK,CAAC,CAAC,CAAC,YAAY,MAAS;EACpD,QAAQ,CAER;EAGF,AAAK,QAAQ,QAAQ,CAAC,CAAC,YAAY,MAAS;EAE5C,MAAM;CACR;CAGA,aAAa;EACX,MAAM,WAA+B,CAAC;EAEtC,KAAK,MAAM,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,QAAQ,GACzC,IAAI;GACF,SAAS,KAAK,QAAQ,QAAQ,KAAK,CAAC,CAAC,CAAC,YAAY,MAAS,CAAC;EAC9D,QAAQ,CAER;EAGF,SAAS,KAAK,QAAQ,QAAQ,CAAC,CAAC,YAAY,MAAS,CAAC;EAEtD,OAAO,QAAQ,IAAI,QAAQ,CAAC,CAAC,WAAW,MAAS;CACnD;AACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_errors = require("./errors-DNQ-g49I.cjs");
|
|
2
|
-
const require_collector = require("./collector-
|
|
3
|
-
const
|
|
2
|
+
const require_collector = require("./collector-BfC4v87v.cjs");
|
|
3
|
+
const require_query_shape = require("./query-shape-DShKQa0x.cjs");
|
|
4
|
+
const require_redact = require("./redact-DQ28mDzr.cjs");
|
|
4
5
|
let _warlock_js_logger = require("@warlock.js/logger");
|
|
5
6
|
|
|
6
7
|
//#region ../../packages/devtools/src/production/capture/dev-stats.ts
|
|
@@ -347,406 +348,6 @@ function createShapeExplainer(input) {
|
|
|
347
348
|
};
|
|
348
349
|
}
|
|
349
350
|
|
|
350
|
-
//#endregion
|
|
351
|
-
//#region ../../packages/devtools/src/production/capture/stats-stores.ts
|
|
352
|
-
const SHAPE_MAX$1 = 2e3;
|
|
353
|
-
const MESSAGE_MAX = 500;
|
|
354
|
-
const STACK_MAX = 4e3;
|
|
355
|
-
const LOG_MESSAGE_MAX$3 = 1e3;
|
|
356
|
-
const PHASES_PER_ROUTE = 30;
|
|
357
|
-
const MONGO_EXPLAINABLE = /* @__PURE__ */ new Set([
|
|
358
|
-
"find",
|
|
359
|
-
"aggregate",
|
|
360
|
-
"count"
|
|
361
|
-
]);
|
|
362
|
-
const SQL_START = /^(?:\s|--[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/)*(select|with)\b/i;
|
|
363
|
-
/** Whether a normalized query shape can be explained (a Postgres `SELECT`/`WITH`, or a MongoDB `find`/`aggregate`/`count`). */
|
|
364
|
-
function isExplainableShape(driver, shape) {
|
|
365
|
-
if (driver === "postgres") return SQL_START.test(shape);
|
|
366
|
-
const space = shape.indexOf(" ");
|
|
367
|
-
const head = space === -1 ? shape : shape.slice(0, space);
|
|
368
|
-
const command = head.slice(head.lastIndexOf(".") + 1);
|
|
369
|
-
return MONGO_EXPLAINABLE.has(command);
|
|
370
|
-
}
|
|
371
|
-
const shapeIds = /* @__PURE__ */ new Map();
|
|
372
|
-
const SHAPE_ID_CACHE = 2e3;
|
|
373
|
-
/** `shortId` of a query shape, remembered: the same few hundred shapes arrive over and over. */
|
|
374
|
-
function shapeIdOf(shape) {
|
|
375
|
-
let id = shapeIds.get(shape);
|
|
376
|
-
if (id === void 0) {
|
|
377
|
-
if (shapeIds.size >= SHAPE_ID_CACHE) shapeIds.clear();
|
|
378
|
-
id = require_histogram.shortId(shape);
|
|
379
|
-
shapeIds.set(shape, id);
|
|
380
|
-
}
|
|
381
|
-
return id;
|
|
382
|
-
}
|
|
383
|
-
function truncate(value, maximum) {
|
|
384
|
-
return value.length > maximum ? value.slice(0, maximum) : value;
|
|
385
|
-
}
|
|
386
|
-
function copyHistogram(histogram) {
|
|
387
|
-
return {
|
|
388
|
-
...histogram,
|
|
389
|
-
counts: [...histogram.counts]
|
|
390
|
-
};
|
|
391
|
-
}
|
|
392
|
-
/** Bounded per-shape query statistics. */
|
|
393
|
-
function createQueryStats(limits) {
|
|
394
|
-
const entries = /* @__PURE__ */ new Map();
|
|
395
|
-
let evictedCount = 0;
|
|
396
|
-
const touch = (shape, driver, connection, at) => {
|
|
397
|
-
const id = shapeIdOf(shape);
|
|
398
|
-
let entry = entries.get(id);
|
|
399
|
-
if (entry) {
|
|
400
|
-
entries.delete(id);
|
|
401
|
-
entry.stats.lastSeen = Math.max(entry.stats.lastSeen, at);
|
|
402
|
-
} else entry = {
|
|
403
|
-
example: void 0,
|
|
404
|
-
stats: {
|
|
405
|
-
id,
|
|
406
|
-
shape: truncate(shape, SHAPE_MAX$1),
|
|
407
|
-
driver,
|
|
408
|
-
connection,
|
|
409
|
-
count: 0,
|
|
410
|
-
errors: 0,
|
|
411
|
-
histogram: require_histogram.createHistogram(),
|
|
412
|
-
nPlusOne: {
|
|
413
|
-
requests: 0,
|
|
414
|
-
maxPerRequest: 0
|
|
415
|
-
},
|
|
416
|
-
slowest: null,
|
|
417
|
-
firstSeen: at,
|
|
418
|
-
lastSeen: at,
|
|
419
|
-
explainable: isExplainableShape(driver, shape)
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
entries.set(id, entry);
|
|
423
|
-
while (entries.size > limits.maxShapes) {
|
|
424
|
-
const oldest = entries.keys().next().value;
|
|
425
|
-
entries.delete(oldest);
|
|
426
|
-
evictedCount++;
|
|
427
|
-
}
|
|
428
|
-
return entry;
|
|
429
|
-
};
|
|
430
|
-
return {
|
|
431
|
-
record(query) {
|
|
432
|
-
const entry = touch(query.shape, query.driver, query.connection, query.at);
|
|
433
|
-
entry.stats.count++;
|
|
434
|
-
if (query.failed) entry.stats.errors++;
|
|
435
|
-
require_histogram.recordDuration(entry.stats.histogram, query.durationMs);
|
|
436
|
-
const slowest = entry.stats.slowest;
|
|
437
|
-
if (!slowest || query.durationMs > slowest.durationMs) entry.stats.slowest = {
|
|
438
|
-
durationMs: query.durationMs,
|
|
439
|
-
at: query.at,
|
|
440
|
-
route: query.route,
|
|
441
|
-
requestId: query.requestId,
|
|
442
|
-
instance: limits.instance
|
|
443
|
-
};
|
|
444
|
-
},
|
|
445
|
-
recordNPlusOne(shape, count) {
|
|
446
|
-
const known = entries.get(shapeIdOf(shape))?.stats;
|
|
447
|
-
const entry = touch(shape, known?.driver ?? "postgres", known?.connection ?? "", Date.now());
|
|
448
|
-
entry.stats.nPlusOne.requests++;
|
|
449
|
-
if (count > entry.stats.nPlusOne.maxPerRequest) entry.stats.nPlusOne.maxPerRequest = count;
|
|
450
|
-
},
|
|
451
|
-
rememberExample(query) {
|
|
452
|
-
const entry = touch(query.shape, query.driver, query.connection, query.startedAt);
|
|
453
|
-
if (!entry.example || query.durationMs > entry.example.durationMs) entry.example = {
|
|
454
|
-
...query,
|
|
455
|
-
...query.bindings === void 0 ? {} : { bindings: [...query.bindings] }
|
|
456
|
-
};
|
|
457
|
-
const slowest = entry.stats.slowest;
|
|
458
|
-
if (!slowest || query.durationMs > slowest.durationMs) entry.stats.slowest = {
|
|
459
|
-
durationMs: query.durationMs,
|
|
460
|
-
at: query.startedAt,
|
|
461
|
-
route: null,
|
|
462
|
-
requestId: null,
|
|
463
|
-
instance: limits.instance
|
|
464
|
-
};
|
|
465
|
-
},
|
|
466
|
-
example(shapeId) {
|
|
467
|
-
return entries.get(shapeId)?.example;
|
|
468
|
-
},
|
|
469
|
-
snapshot(limit) {
|
|
470
|
-
return [...entries.values()].map(({ stats }) => stats).sort((a, b) => b.histogram.sumMs - a.histogram.sumMs).slice(0, Math.max(0, limit)).map((stats) => ({
|
|
471
|
-
...stats,
|
|
472
|
-
histogram: copyHistogram(stats.histogram),
|
|
473
|
-
nPlusOne: { ...stats.nPlusOne },
|
|
474
|
-
slowest: stats.slowest ? { ...stats.slowest } : null
|
|
475
|
-
}));
|
|
476
|
-
},
|
|
477
|
-
evicted: () => evictedCount,
|
|
478
|
-
clear() {
|
|
479
|
-
entries.clear();
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
/** Bounded per-route statistics. */
|
|
484
|
-
function createRouteStats(limits) {
|
|
485
|
-
const entries = /* @__PURE__ */ new Map();
|
|
486
|
-
let evictedCount = 0;
|
|
487
|
-
return {
|
|
488
|
-
record(request) {
|
|
489
|
-
const route = request.route === "" ? "(unmatched)" : request.route;
|
|
490
|
-
const key = `${request.method} ${route}`;
|
|
491
|
-
let entry = entries.get(key);
|
|
492
|
-
if (entry) entries.delete(key);
|
|
493
|
-
else entry = {
|
|
494
|
-
phases: /* @__PURE__ */ new Map(),
|
|
495
|
-
stats: {
|
|
496
|
-
key,
|
|
497
|
-
method: request.method,
|
|
498
|
-
route,
|
|
499
|
-
count: 0,
|
|
500
|
-
errors: 0,
|
|
501
|
-
histogram: require_histogram.createHistogram(),
|
|
502
|
-
phases: [],
|
|
503
|
-
slowest: null
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
entries.set(key, entry);
|
|
507
|
-
while (entries.size > limits.maxRoutes) {
|
|
508
|
-
entries.delete(entries.keys().next().value);
|
|
509
|
-
evictedCount++;
|
|
510
|
-
}
|
|
511
|
-
entry.stats.count++;
|
|
512
|
-
if (request.failed) entry.stats.errors++;
|
|
513
|
-
require_histogram.recordDuration(entry.stats.histogram, request.durationMs);
|
|
514
|
-
const slowest = entry.stats.slowest;
|
|
515
|
-
if (!slowest || request.durationMs > slowest.durationMs) entry.stats.slowest = {
|
|
516
|
-
durationMs: request.durationMs,
|
|
517
|
-
at: request.at,
|
|
518
|
-
requestId: request.requestId,
|
|
519
|
-
instance: limits.instance
|
|
520
|
-
};
|
|
521
|
-
for (const phase of request.phases) {
|
|
522
|
-
let stats = entry.phases.get(phase.name);
|
|
523
|
-
if (!stats) {
|
|
524
|
-
if (entry.phases.size >= PHASES_PER_ROUTE) {
|
|
525
|
-
let smallest;
|
|
526
|
-
for (const [name, candidate] of entry.phases) if (smallest === void 0 || candidate.sumMs < (entry.phases.get(smallest)?.sumMs ?? 0)) smallest = name;
|
|
527
|
-
if (smallest !== void 0) entry.phases.delete(smallest);
|
|
528
|
-
}
|
|
529
|
-
stats = {
|
|
530
|
-
name: phase.name,
|
|
531
|
-
count: 0,
|
|
532
|
-
sumMs: 0,
|
|
533
|
-
maxMs: 0
|
|
534
|
-
};
|
|
535
|
-
entry.phases.set(phase.name, stats);
|
|
536
|
-
}
|
|
537
|
-
const duration = Number.isFinite(phase.durationMs) ? Math.max(0, phase.durationMs) : 0;
|
|
538
|
-
stats.count++;
|
|
539
|
-
stats.sumMs += duration;
|
|
540
|
-
if (duration > stats.maxMs) stats.maxMs = duration;
|
|
541
|
-
}
|
|
542
|
-
},
|
|
543
|
-
snapshot(limit) {
|
|
544
|
-
return [...entries.values()].sort((a, b) => b.stats.histogram.sumMs - a.stats.histogram.sumMs).slice(0, Math.max(0, limit)).map(({ stats, phases }) => ({
|
|
545
|
-
...stats,
|
|
546
|
-
histogram: copyHistogram(stats.histogram),
|
|
547
|
-
slowest: stats.slowest ? { ...stats.slowest } : null,
|
|
548
|
-
phases: [...phases.values()].sort((a, b) => b.sumMs - a.sumMs).slice(0, PHASES_PER_ROUTE).map((phase) => ({ ...phase }))
|
|
549
|
-
}));
|
|
550
|
-
},
|
|
551
|
-
evicted: () => evictedCount,
|
|
552
|
-
clear() {
|
|
553
|
-
entries.clear();
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
const QUOTED$1 = /'(?:''|[^'])*'|"(?:\\.|[^"\\])*"/g;
|
|
558
|
-
const UUID = /\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/gi;
|
|
559
|
-
const EMAIL$1 = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g;
|
|
560
|
-
const HEX_ID = /\b0x[0-9a-f]+\b|\b(?=[0-9a-f]*\d)[0-9a-f]{8,}\b/gi;
|
|
561
|
-
/** A random id of letters and digits (request ids, tokens): 16+ characters with both. */
|
|
562
|
-
const TOKEN_ID = /\b(?=[A-Za-z0-9_-]*\d)(?=[A-Za-z0-9_-]*[A-Za-z])[A-Za-z0-9_-]{16,}\b/g;
|
|
563
|
-
const NUMBER = /\d+(?:\.\d+)?/g;
|
|
564
|
-
/**
|
|
565
|
-
* Replaces the parts of an error message that change between occurrences
|
|
566
|
-
* (quoted strings, emails, UUIDs, hex ids, random ids such as request ids,
|
|
567
|
-
* numbers) so equal errors group.
|
|
568
|
-
*/
|
|
569
|
-
function normalizeErrorMessage(message) {
|
|
570
|
-
return message.replace(QUOTED$1, "<str>").replace(UUID, "<uuid>").replace(EMAIL$1, "<email>").replace(HEX_ID, "<hex>").replace(TOKEN_ID, "<id>").replace(NUMBER, "<n>");
|
|
571
|
-
}
|
|
572
|
-
/** Bounded error groups. */
|
|
573
|
-
function createErrorGroups(limits) {
|
|
574
|
-
const groups = /* @__PURE__ */ new Map();
|
|
575
|
-
let evictedCount = 0;
|
|
576
|
-
return {
|
|
577
|
-
record(input) {
|
|
578
|
-
const id = require_histogram.shortId(`${input.source}\n${input.name ?? ""}\n${normalizeErrorMessage(input.message)}\n${input.route ?? ""}`);
|
|
579
|
-
const known = groups.get(id);
|
|
580
|
-
const message = truncate(input.message, MESSAGE_MAX);
|
|
581
|
-
const stack = input.stack === null ? null : truncate(input.stack, STACK_MAX);
|
|
582
|
-
if (known) {
|
|
583
|
-
groups.delete(id);
|
|
584
|
-
known.count++;
|
|
585
|
-
known.message = message;
|
|
586
|
-
known.lastSeen = Math.max(known.lastSeen, input.at);
|
|
587
|
-
known.lastRequestId = input.requestId;
|
|
588
|
-
known.status = input.status ?? known.status;
|
|
589
|
-
if (stack !== null) known.stack = stack;
|
|
590
|
-
groups.set(id, known);
|
|
591
|
-
} else groups.set(id, {
|
|
592
|
-
id,
|
|
593
|
-
message,
|
|
594
|
-
name: input.name,
|
|
595
|
-
source: input.source,
|
|
596
|
-
route: input.route,
|
|
597
|
-
status: input.status,
|
|
598
|
-
count: 1,
|
|
599
|
-
firstSeen: input.at,
|
|
600
|
-
lastSeen: input.at,
|
|
601
|
-
lastRequestId: input.requestId,
|
|
602
|
-
stack
|
|
603
|
-
});
|
|
604
|
-
while (groups.size > limits.maxGroups) {
|
|
605
|
-
groups.delete(groups.keys().next().value);
|
|
606
|
-
evictedCount++;
|
|
607
|
-
}
|
|
608
|
-
},
|
|
609
|
-
snapshot(limit) {
|
|
610
|
-
return [...groups.values()].sort((a, b) => b.lastSeen - a.lastSeen).slice(0, Math.max(0, limit)).map((group) => ({ ...group }));
|
|
611
|
-
},
|
|
612
|
-
evicted: () => evictedCount,
|
|
613
|
-
clear() {
|
|
614
|
-
groups.clear();
|
|
615
|
-
}
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
/** Recent warn/error log entries, bounded. */
|
|
619
|
-
function createRecentLogs(limits) {
|
|
620
|
-
const entries = [];
|
|
621
|
-
return {
|
|
622
|
-
record(entry) {
|
|
623
|
-
entries.push({
|
|
624
|
-
...entry,
|
|
625
|
-
message: truncate(entry.message, LOG_MESSAGE_MAX$3)
|
|
626
|
-
});
|
|
627
|
-
while (entries.length > limits.maxEntries) entries.shift();
|
|
628
|
-
},
|
|
629
|
-
snapshot(limit, filter = {}) {
|
|
630
|
-
const module = filter.module?.toLowerCase();
|
|
631
|
-
const result = [];
|
|
632
|
-
for (let index = entries.length - 1; index >= 0 && result.length < limit; index--) {
|
|
633
|
-
const entry = entries[index];
|
|
634
|
-
if (filter.level && entry.level !== filter.level) continue;
|
|
635
|
-
if (module && !entry.module.toLowerCase().includes(module)) continue;
|
|
636
|
-
result.push({ ...entry });
|
|
637
|
-
}
|
|
638
|
-
return result;
|
|
639
|
-
},
|
|
640
|
-
clear() {
|
|
641
|
-
entries.length = 0;
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
//#endregion
|
|
647
|
-
//#region ../../packages/devtools/src/production/capture/redact.ts
|
|
648
|
-
const SHAPE_MAX = 2e3;
|
|
649
|
-
const ERROR_MAX = 500;
|
|
650
|
-
const QUERY_ERROR_MAX = 300;
|
|
651
|
-
const LOG_MESSAGE_MAX$2 = 1e3;
|
|
652
|
-
const QUOTED = /'(?:''|[^'])*'|"(?:\\.|[^"\\])*"/g;
|
|
653
|
-
const BRACES = /\{[^{}]*\}/g;
|
|
654
|
-
const EMAIL = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g;
|
|
655
|
-
/**
|
|
656
|
-
* Error text without the values a driver or a handler put in it (a duplicate
|
|
657
|
-
* key message carries the key): quoted strings, emails and `{ … }` documents
|
|
658
|
-
* become `?`, then the text is cut to `max` characters.
|
|
659
|
-
*/
|
|
660
|
-
function scrubErrorText(text, max) {
|
|
661
|
-
return truncate(text.replace(QUOTED, "?").replace(EMAIL, "?").replace(BRACES, "{?}"), max);
|
|
662
|
-
}
|
|
663
|
-
/** A database error message without the values the driver quoted in it. */
|
|
664
|
-
function scrubQueryError(message) {
|
|
665
|
-
return scrubErrorText(message, QUERY_ERROR_MAX);
|
|
666
|
-
}
|
|
667
|
-
function redactQuery(query) {
|
|
668
|
-
const shape = truncate(query.shape || require_collector.queryShape(query), SHAPE_MAX);
|
|
669
|
-
const sample = {
|
|
670
|
-
id: query.id,
|
|
671
|
-
connection: query.connection,
|
|
672
|
-
driver: query.driver,
|
|
673
|
-
sql: shape,
|
|
674
|
-
shape,
|
|
675
|
-
shapeId: shapeIdOf(query.shape || shape),
|
|
676
|
-
startedAt: query.startedAt,
|
|
677
|
-
durationMs: query.durationMs
|
|
678
|
-
};
|
|
679
|
-
if (query.collection !== void 0) sample.collection = query.collection;
|
|
680
|
-
if (query.command !== void 0) sample.command = query.command;
|
|
681
|
-
if (query.rowCount !== void 0) sample.rowCount = query.rowCount;
|
|
682
|
-
if (query.error !== void 0) sample.error = scrubQueryError(query.error);
|
|
683
|
-
return sample;
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Turns a sampled request into a stored sample with every value removed: SQL
|
|
687
|
-
* replaced by its shape, no bindings, no Mongo pipeline, no log context, no
|
|
688
|
-
* phase attributes, cache operations reduced to counts, no caller paths.
|
|
689
|
-
* Headers, bodies, query strings and parameters are not part of a request
|
|
690
|
-
* record and never appear.
|
|
691
|
-
*/
|
|
692
|
-
function toStoredSample(request, instance, droppedQueries) {
|
|
693
|
-
const path = request.path.split("?")[0] ?? request.path;
|
|
694
|
-
const summary = {
|
|
695
|
-
id: request.id,
|
|
696
|
-
method: request.method,
|
|
697
|
-
path,
|
|
698
|
-
startedAt: request.startedAt,
|
|
699
|
-
queryCount: request.queries.length + droppedQueries,
|
|
700
|
-
warningCount: request.warnings.length,
|
|
701
|
-
instance
|
|
702
|
-
};
|
|
703
|
-
if (request.route !== void 0) summary.route = request.route;
|
|
704
|
-
if (request.status !== void 0) summary.status = request.status;
|
|
705
|
-
if (request.durationMs !== void 0) summary.durationMs = request.durationMs;
|
|
706
|
-
let hits = 0;
|
|
707
|
-
let misses = 0;
|
|
708
|
-
let writes = 0;
|
|
709
|
-
for (const operation of request.cache) if (operation.type === "hit") hits++;
|
|
710
|
-
else if (operation.type === "miss") misses++;
|
|
711
|
-
else if (operation.type === "set") writes++;
|
|
712
|
-
const detail = {
|
|
713
|
-
...summary,
|
|
714
|
-
phases: request.phases.map((phase) => ({
|
|
715
|
-
name: phase.name,
|
|
716
|
-
startedAt: phase.startedAt,
|
|
717
|
-
durationMs: phase.durationMs
|
|
718
|
-
})),
|
|
719
|
-
queries: request.queries.map(redactQuery),
|
|
720
|
-
cache: {
|
|
721
|
-
hits,
|
|
722
|
-
misses,
|
|
723
|
-
writes
|
|
724
|
-
},
|
|
725
|
-
logs: request.logs.map((entry) => ({
|
|
726
|
-
level: entry.level,
|
|
727
|
-
module: entry.module,
|
|
728
|
-
action: entry.action,
|
|
729
|
-
message: truncate(entry.message, LOG_MESSAGE_MAX$2),
|
|
730
|
-
at: entry.at
|
|
731
|
-
})),
|
|
732
|
-
warnings: request.warnings.map((warning) => ({
|
|
733
|
-
type: warning.type,
|
|
734
|
-
message: warning.message,
|
|
735
|
-
shape: truncate(warning.shape, SHAPE_MAX),
|
|
736
|
-
count: warning.count
|
|
737
|
-
})),
|
|
738
|
-
droppedQueries
|
|
739
|
-
};
|
|
740
|
-
if (request.error !== void 0) detail.error = scrubErrorText(request.error, ERROR_MAX);
|
|
741
|
-
return {
|
|
742
|
-
id: request.id,
|
|
743
|
-
instance,
|
|
744
|
-
startedAt: request.startedAt,
|
|
745
|
-
summary,
|
|
746
|
-
detail
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
|
|
750
351
|
//#endregion
|
|
751
352
|
//#region ../../packages/devtools/src/production/capture/filter.ts
|
|
752
353
|
/** Whether a stored sample's row passes a request filter (the same rules as the store). */
|
|
@@ -793,7 +394,7 @@ function errorMessage(error) {
|
|
|
793
394
|
}
|
|
794
395
|
/** A request's error message as the monitor keeps it: without the values in it (see `scrubErrorText`). */
|
|
795
396
|
function requestErrorMessage(error) {
|
|
796
|
-
return scrubErrorText(errorMessage(error), REQUEST_ERROR_MAX);
|
|
397
|
+
return require_redact.scrubErrorText(errorMessage(error), REQUEST_ERROR_MAX);
|
|
797
398
|
}
|
|
798
399
|
function touchesMonitorTables(event) {
|
|
799
400
|
return event.sql !== void 0 && event.sql.includes("devtools_") || event.collection !== void 0 && event.collection.startsWith("devtools_");
|
|
@@ -813,16 +414,16 @@ function createCaptureEngine(deps) {
|
|
|
813
414
|
...deps.options,
|
|
814
415
|
maxRequests: production.maxRequests
|
|
815
416
|
});
|
|
816
|
-
const queries = createQueryStats({
|
|
417
|
+
const queries = require_redact.createQueryStats({
|
|
817
418
|
maxShapes: production.maxShapes,
|
|
818
419
|
instance: instance.id
|
|
819
420
|
});
|
|
820
|
-
const routes = createRouteStats({
|
|
421
|
+
const routes = require_redact.createRouteStats({
|
|
821
422
|
maxRoutes: production.maxRoutes,
|
|
822
423
|
instance: instance.id
|
|
823
424
|
});
|
|
824
|
-
const errors = createErrorGroups({ maxGroups: production.maxErrorGroups });
|
|
825
|
-
const logs = createRecentLogs({ maxEntries: 200 });
|
|
425
|
+
const errors = require_redact.createErrorGroups({ maxGroups: production.maxErrorGroups });
|
|
426
|
+
const logs = require_redact.createRecentLogs({ maxEntries: 200 });
|
|
826
427
|
const active = /* @__PURE__ */ new Map();
|
|
827
428
|
const recent = /* @__PURE__ */ new Map();
|
|
828
429
|
const pending = [];
|
|
@@ -900,7 +501,7 @@ function createCaptureEngine(deps) {
|
|
|
900
501
|
source: "request",
|
|
901
502
|
message: error === void 0 ? `HTTP ${status}` : requestErrorMessage(error),
|
|
902
503
|
name: error instanceof Error ? error.name : null,
|
|
903
|
-
stack: error instanceof Error && error.stack !== void 0 ? scrubErrorText(error.stack, REQUEST_STACK_MAX) : null,
|
|
504
|
+
stack: error instanceof Error && error.stack !== void 0 ? require_redact.scrubErrorText(error.stack, REQUEST_STACK_MAX) : null,
|
|
904
505
|
route: route ?? null,
|
|
905
506
|
status: status ?? null,
|
|
906
507
|
requestId: request.requestId,
|
|
@@ -933,7 +534,7 @@ function createCaptureEngine(deps) {
|
|
|
933
534
|
});
|
|
934
535
|
for (const warning of settled.warnings) queries.recordNPlusOne(warning.shape, warning.count);
|
|
935
536
|
recordRequestError(request, result, route);
|
|
936
|
-
enqueue(toStoredSample(settled, instance.id, state.dropped));
|
|
537
|
+
enqueue(require_redact.toStoredSample(settled, instance.id, state.dropped));
|
|
937
538
|
};
|
|
938
539
|
const finishUnsampled = (request, result) => {
|
|
939
540
|
if (deps.isDashboardPath(request.path)) return;
|
|
@@ -989,13 +590,13 @@ function createCaptureEngine(deps) {
|
|
|
989
590
|
if (event.command !== void 0) input.command = event.command;
|
|
990
591
|
if (event.pipeline !== void 0) input.pipeline = event.pipeline;
|
|
991
592
|
if (event.rowCount !== void 0) input.rowCount = event.rowCount;
|
|
992
|
-
if (event.error !== void 0) input.error = scrubQueryError(errorMessage(event.error));
|
|
593
|
+
if (event.error !== void 0) input.error = require_redact.scrubQueryError(errorMessage(event.error));
|
|
993
594
|
return input;
|
|
994
595
|
};
|
|
995
596
|
const exampleOf = (event) => ({
|
|
996
597
|
...queryInput(event),
|
|
997
598
|
id: `x${++exampleSequence}`,
|
|
998
|
-
shape:
|
|
599
|
+
shape: require_query_shape.queryShape(event)
|
|
999
600
|
});
|
|
1000
601
|
const recordQuery = (query, route, requestId) => {
|
|
1001
602
|
queries.record({
|
|
@@ -1041,7 +642,7 @@ function createCaptureEngine(deps) {
|
|
|
1041
642
|
const live = collector.getRequest(id);
|
|
1042
643
|
if (!live) return null;
|
|
1043
644
|
const dropped = active.get(id)?.dropped ?? 0;
|
|
1044
|
-
const sample = toStoredSample(live, instance.id, dropped);
|
|
645
|
+
const sample = require_redact.toStoredSample(live, instance.id, dropped);
|
|
1045
646
|
return sample.detail ?? sample.summary;
|
|
1046
647
|
},
|
|
1047
648
|
async clear() {
|
|
@@ -1124,7 +725,7 @@ function createCaptureEngine(deps) {
|
|
|
1124
725
|
const wanted = logLevels.has(entry.level);
|
|
1125
726
|
const state = requestId === void 0 ? void 0 : active.get(requestId);
|
|
1126
727
|
if (!wanted && !state) return;
|
|
1127
|
-
const message = truncate(entry.message, LOG_MESSAGE_MAX$1);
|
|
728
|
+
const message = require_redact.truncate(entry.message, LOG_MESSAGE_MAX$1);
|
|
1128
729
|
const kept = {
|
|
1129
730
|
level: entry.level,
|
|
1130
731
|
module: entry.module,
|
|
@@ -1283,7 +884,7 @@ function createProductionCapture(deps) {
|
|
|
1283
884
|
level,
|
|
1284
885
|
module: data.module,
|
|
1285
886
|
action: data.action,
|
|
1286
|
-
message: level === "error" ? scrubErrorText(text, LOG_MESSAGE_MAX) : text,
|
|
887
|
+
message: level === "error" ? require_redact.scrubErrorText(text, LOG_MESSAGE_MAX) : text,
|
|
1287
888
|
at: Date.now()
|
|
1288
889
|
});
|
|
1289
890
|
}
|
|
@@ -1332,11 +933,11 @@ function createProductionCapture(deps) {
|
|
|
1332
933
|
|
|
1333
934
|
//#endregion
|
|
1334
935
|
exports.attachDevelopmentStats = attachDevelopmentStats;
|
|
1335
|
-
exports.createErrorGroups = createErrorGroups;
|
|
936
|
+
exports.createErrorGroups = require_redact.createErrorGroups;
|
|
1336
937
|
exports.createProductionCapture = createProductionCapture;
|
|
1337
|
-
exports.createQueryStats = createQueryStats;
|
|
1338
|
-
exports.createRecentLogs = createRecentLogs;
|
|
1339
|
-
exports.createRouteStats = createRouteStats;
|
|
938
|
+
exports.createQueryStats = require_redact.createQueryStats;
|
|
939
|
+
exports.createRecentLogs = require_redact.createRecentLogs;
|
|
940
|
+
exports.createRouteStats = require_redact.createRouteStats;
|
|
1340
941
|
exports.createShapeExplainer = createShapeExplainer;
|
|
1341
|
-
exports.toStoredSample = toStoredSample;
|
|
1342
|
-
//# sourceMappingURL=capture-
|
|
942
|
+
exports.toStoredSample = require_redact.toStoredSample;
|
|
943
|
+
//# sourceMappingURL=capture-D2k0GnBN.cjs.map
|