@warlock.js/devtools 5.55.0 → 5.56.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 +29 -0
- package/README.md +26 -13
- package/cjs/ai-source-DTpxumMA.cjs +381 -0
- package/cjs/ai-source-DTpxumMA.cjs.map +1 -0
- package/cjs/auth-DzU0gHDG.cjs +1655 -0
- package/cjs/auth-DzU0gHDG.cjs.map +1 -0
- package/cjs/boot-BQi0Etor.cjs +138 -0
- package/cjs/boot-BQi0Etor.cjs.map +1 -0
- package/cjs/capture-CqIiaznN.cjs +1342 -0
- package/cjs/capture-CqIiaznN.cjs.map +1 -0
- package/cjs/cascade-store-pHjKeSFm.cjs +863 -0
- package/cjs/cascade-store-pHjKeSFm.cjs.map +1 -0
- package/cjs/collector-CJbQbzzK.cjs +271 -0
- package/cjs/collector-CJbQbzzK.cjs.map +1 -0
- package/cjs/contracts-CVmplkNb.cjs +112 -0
- package/cjs/contracts-CVmplkNb.cjs.map +1 -0
- package/cjs/current-request-id-BoJJb3y7.cjs +37 -0
- package/cjs/current-request-id-BoJJb3y7.cjs.map +1 -0
- package/cjs/errors-CyZp5yS-.cjs +177 -0
- package/cjs/errors-CyZp5yS-.cjs.map +1 -0
- package/cjs/histogram-BaI-PnCv.cjs +102 -0
- package/cjs/histogram-BaI-PnCv.cjs.map +1 -0
- package/cjs/http-CabcUwBx.cjs +870 -0
- package/cjs/http-CabcUwBx.cjs.map +1 -0
- package/cjs/index.cjs +1 -1
- package/cjs/insights-BKtqxdnP.cjs +811 -0
- package/cjs/insights-BKtqxdnP.cjs.map +1 -0
- package/cjs/ip-DbNhPOzi.cjs +153 -0
- package/cjs/ip-DbNhPOzi.cjs.map +1 -0
- package/cjs/migrations-w7GMsrQw.cjs +297 -0
- package/cjs/migrations-w7GMsrQw.cjs.map +1 -0
- package/cjs/openapi-CC7OAUc6.cjs +52 -0
- package/cjs/openapi-CC7OAUc6.cjs.map +1 -0
- package/cjs/options-CWqFC5__.cjs +181 -0
- package/cjs/options-CWqFC5__.cjs.map +1 -0
- package/cjs/panels-B0dAfGbJ.cjs +298 -0
- package/cjs/panels-B0dAfGbJ.cjs.map +1 -0
- package/cjs/process-panel-DEOnLxoT.cjs +48 -0
- package/cjs/process-panel-DEOnLxoT.cjs.map +1 -0
- package/cjs/production/index.cjs +238 -0
- package/cjs/production/index.cjs.map +1 -0
- package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +52 -0
- package/cjs/server-B6xdeKS8.cjs +184 -0
- package/cjs/server-B6xdeKS8.cjs.map +1 -0
- package/cjs/{src-Xwm3Eel9.cjs → src-Ce-3Lniv.cjs} +163 -295
- package/cjs/src-Ce-3Lniv.cjs.map +1 -0
- package/cjs/store-aq207T8v.cjs +9 -0
- package/cjs/stream-route-BGJa-zQu.cjs +875 -0
- package/cjs/stream-route-BGJa-zQu.cjs.map +1 -0
- package/esm/devtools-connector.d.mts +16 -13
- package/esm/devtools-connector.d.mts.map +1 -1
- package/esm/devtools-connector.mjs +127 -18
- package/esm/devtools-connector.mjs.map +1 -1
- package/esm/index.d.mts +3 -2
- package/esm/options.mjs +2 -1
- package/esm/options.mjs.map +1 -1
- package/esm/panels.mjs +50 -5
- package/esm/panels.mjs.map +1 -1
- package/esm/production/auth/common-passwords.mjs +303 -0
- package/esm/production/auth/common-passwords.mjs.map +1 -0
- package/esm/production/auth/default-crypto.mjs +19 -0
- package/esm/production/auth/default-crypto.mjs.map +1 -0
- package/esm/production/auth/helpers.mjs +77 -0
- package/esm/production/auth/helpers.mjs.map +1 -0
- package/esm/production/auth/index.mjs +6 -0
- package/esm/production/auth/passkeys.mjs +96 -0
- package/esm/production/auth/passkeys.mjs.map +1 -0
- package/esm/production/auth/service.mjs +1166 -0
- package/esm/production/auth/service.mjs.map +1 -0
- package/esm/production/boot.mjs +138 -0
- package/esm/production/boot.mjs.map +1 -0
- package/esm/production/capture/dev-stats.mjs +83 -0
- package/esm/production/capture/dev-stats.mjs.map +1 -0
- package/esm/production/capture/engine.mjs +442 -0
- package/esm/production/capture/engine.mjs.map +1 -0
- package/esm/production/capture/explain.mjs +271 -0
- package/esm/production/capture/explain.mjs.map +1 -0
- package/esm/production/capture/filter.mjs +24 -0
- package/esm/production/capture/filter.mjs.map +1 -0
- package/esm/production/capture/index.mjs +7 -0
- package/esm/production/capture/production-capture.mjs +134 -0
- package/esm/production/capture/production-capture.mjs.map +1 -0
- package/esm/production/capture/redact.mjs +109 -0
- package/esm/production/capture/redact.mjs.map +1 -0
- package/esm/production/capture/stats-stores.mjs +300 -0
- package/esm/production/capture/stats-stores.mjs.map +1 -0
- package/esm/production/cli/actions.mjs +151 -0
- package/esm/production/cli/actions.mjs.map +1 -0
- package/esm/production/cli/index.d.mts +17 -0
- package/esm/production/cli/index.d.mts.map +1 -0
- package/esm/production/cli/index.mjs +86 -0
- package/esm/production/cli/index.mjs.map +1 -0
- package/esm/production/contracts.d.mts +592 -0
- package/esm/production/contracts.d.mts.map +1 -0
- package/esm/production/contracts.mjs +95 -0
- package/esm/production/contracts.mjs.map +1 -0
- package/esm/production/errors.d.mts +31 -0
- package/esm/production/errors.d.mts.map +1 -0
- package/esm/production/errors.mjs +142 -0
- package/esm/production/errors.mjs.map +1 -0
- package/esm/production/http/access.mjs +124 -0
- package/esm/production/http/access.mjs.map +1 -0
- package/esm/production/http/auth-routes.mjs +280 -0
- package/esm/production/http/auth-routes.mjs.map +1 -0
- package/esm/production/http/client.mjs +57 -0
- package/esm/production/http/client.mjs.map +1 -0
- package/esm/production/http/constants.mjs +11 -0
- package/esm/production/http/constants.mjs.map +1 -0
- package/esm/production/http/context.mjs +14 -0
- package/esm/production/http/context.mjs.map +1 -0
- package/esm/production/http/cookie.mjs +39 -0
- package/esm/production/http/cookie.mjs.map +1 -0
- package/esm/production/http/headers.mjs +25 -0
- package/esm/production/http/headers.mjs.map +1 -0
- package/esm/production/http/index.mjs +10 -0
- package/esm/production/http/ip.mjs +130 -0
- package/esm/production/http/ip.mjs.map +1 -0
- package/esm/production/http/mount.mjs +300 -0
- package/esm/production/http/mount.mjs.map +1 -0
- package/esm/production/http/state.mjs +54 -0
- package/esm/production/http/state.mjs.map +1 -0
- package/esm/production/index.d.mts +6 -0
- package/esm/production/index.mjs +5 -0
- package/esm/production/insights/cap-report.mjs +67 -0
- package/esm/production/insights/cap-report.mjs.map +1 -0
- package/esm/production/insights/health.mjs +88 -0
- package/esm/production/insights/health.mjs.map +1 -0
- package/esm/production/insights/index.mjs +10 -0
- package/esm/production/insights/insights.mjs +167 -0
- package/esm/production/insights/insights.mjs.map +1 -0
- package/esm/production/insights/instance.mjs +24 -0
- package/esm/production/insights/instance.mjs.map +1 -0
- package/esm/production/insights/jobs.mjs +100 -0
- package/esm/production/insights/jobs.mjs.map +1 -0
- package/esm/production/insights/reporter.mjs +59 -0
- package/esm/production/insights/reporter.mjs.map +1 -0
- package/esm/production/insights/resources.mjs +139 -0
- package/esm/production/insights/resources.mjs.map +1 -0
- package/esm/production/insights/writer.mjs +72 -0
- package/esm/production/insights/writer.mjs.map +1 -0
- package/esm/production/openapi.mjs +52 -0
- package/esm/production/openapi.mjs.map +1 -0
- package/esm/production/options.d.mts +60 -0
- package/esm/production/options.d.mts.map +1 -0
- package/esm/production/options.mjs +170 -0
- package/esm/production/options.mjs.map +1 -0
- package/esm/production/stats/histogram.mjs +67 -0
- package/esm/production/stats/histogram.mjs.map +1 -0
- package/esm/production/stats/merge.mjs +106 -0
- package/esm/production/stats/merge.mjs.map +1 -0
- package/esm/production/store/cascade-store.mjs +322 -0
- package/esm/production/store/cascade-store.mjs.map +1 -0
- package/esm/production/store/index.mjs +5 -0
- package/esm/production/store/mapping.mjs +258 -0
- package/esm/production/store/mapping.mjs.map +1 -0
- package/esm/production/store/memory-store.mjs +291 -0
- package/esm/production/store/memory-store.mjs.map +1 -0
- package/esm/production/store/migrations.d.mts +11 -0
- package/esm/production/store/migrations.d.mts.map +1 -0
- package/esm/production/store/migrations.mjs +29 -0
- package/esm/production/store/migrations.mjs.map +1 -0
- package/esm/production/store/models/account.migration.mjs +34 -0
- package/esm/production/store/models/account.migration.mjs.map +1 -0
- package/esm/production/store/models/account.model.mjs +13 -0
- package/esm/production/store/models/account.model.mjs.map +1 -0
- package/esm/production/store/models/audit.migration.mjs +30 -0
- package/esm/production/store/models/audit.migration.mjs.map +1 -0
- package/esm/production/store/models/audit.model.mjs +13 -0
- package/esm/production/store/models/audit.model.mjs.map +1 -0
- package/esm/production/store/models/base.mjs +27 -0
- package/esm/production/store/models/base.mjs.map +1 -0
- package/esm/production/store/models/index.mjs +17 -0
- package/esm/production/store/models/invite.migration.mjs +26 -0
- package/esm/production/store/models/invite.migration.mjs.map +1 -0
- package/esm/production/store/models/invite.model.mjs +13 -0
- package/esm/production/store/models/invite.model.mjs.map +1 -0
- package/esm/production/store/models/report.migration.mjs +20 -0
- package/esm/production/store/models/report.migration.mjs.map +1 -0
- package/esm/production/store/models/report.model.mjs +13 -0
- package/esm/production/store/models/report.model.mjs.map +1 -0
- package/esm/production/store/models/sample.migration.mjs +25 -0
- package/esm/production/store/models/sample.migration.mjs.map +1 -0
- package/esm/production/store/models/sample.model.mjs +13 -0
- package/esm/production/store/models/sample.model.mjs.map +1 -0
- package/esm/production/store/models/session.migration.mjs +31 -0
- package/esm/production/store/models/session.migration.mjs.map +1 -0
- package/esm/production/store/models/session.model.mjs +13 -0
- package/esm/production/store/models/session.model.mjs.map +1 -0
- package/esm/production/store/models/state.migration.mjs +26 -0
- package/esm/production/store/models/state.migration.mjs.map +1 -0
- package/esm/production/store/models/state.model.mjs +13 -0
- package/esm/production/store/models/state.model.mjs.map +1 -0
- package/esm/query-shape.mjs +14 -1
- package/esm/query-shape.mjs.map +1 -1
- package/esm/server/explain-route.mjs +26 -1
- package/esm/server/explain-route.mjs.map +1 -1
- package/esm/server/index.mjs +9 -4
- package/esm/server/index.mjs.map +1 -1
- package/esm/server/insights-routes.mjs +62 -0
- package/esm/server/insights-routes.mjs.map +1 -0
- package/esm/server/log-routes.mjs +32 -5
- package/esm/server/log-routes.mjs.map +1 -1
- package/esm/server/openapi-routes.mjs +3 -2
- package/esm/server/openapi-routes.mjs.map +1 -1
- package/esm/server/requests-routes.mjs +125 -0
- package/esm/server/requests-routes.mjs.map +1 -1
- package/esm/server/session-routes.mjs +42 -0
- package/esm/server/session-routes.mjs.map +1 -0
- package/esm/server/stream-route.mjs +81 -11
- package/esm/server/stream-route.mjs.map +1 -1
- package/esm/server/ui-assets.mjs +34 -25
- package/esm/server/ui-assets.mjs.map +1 -1
- package/esm/sources/log-source.mjs +14 -1
- package/esm/sources/log-source.mjs.map +1 -1
- package/esm/types.d.mts +202 -1
- package/esm/types.d.mts.map +1 -1
- package/esm/ui-root.mjs +9 -4
- package/esm/ui-root.mjs.map +1 -1
- package/llms-full.txt +159 -21
- package/llms.txt +2 -2
- package/package.json +32 -8
- package/skills/SKILL.md +159 -21
- package/ui/dashboard/assets/app.css +3 -0
- package/ui/dashboard/assets/app.js +50 -0
- package/ui/dashboard/build-info.json +21 -0
- package/ui/dashboard/index.html +15 -0
- package/cjs/ai-source-Dz_3tlZ5.cjs +0 -703
- package/cjs/ai-source-Dz_3tlZ5.cjs.map +0 -1
- package/cjs/server-B11ShQYE.cjs +0 -628
- package/cjs/server-B11ShQYE.cjs.map +0 -1
- package/cjs/src-Xwm3Eel9.cjs.map +0 -1
- package/ui/app.css +0 -376
- package/ui/app.js +0 -1158
- package/ui/index.html +0 -28
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insights-BKtqxdnP.cjs","names":["mergeHistograms","histogramQuantile","histogramMean","os","cluster","constants","v8","monitorEventLoopDelay","performance","PerformanceObserver"],"sources":["../../../../../../../packages/devtools/src/production/stats/merge.ts","../../../../../../../packages/devtools/src/production/insights/cap-report.ts","../../../../../../../packages/devtools/src/production/insights/health.ts","../../../../../../../packages/devtools/src/production/insights/insights.ts","../../../../../../../packages/devtools/src/production/insights/instance.ts","../../../../../../../packages/devtools/src/production/insights/jobs.ts","../../../../../../../packages/devtools/src/production/insights/reporter.ts","../../../../../../../packages/devtools/src/production/insights/resources.ts","../../../../../../../packages/devtools/src/production/insights/writer.ts"],"sourcesContent":["import type {\n DevtoolsErrorGroup,\n DevtoolsQueryShapeStats,\n DevtoolsRoutePhaseStats,\n DevtoolsRouteStats,\n} from \"../contracts\";\nimport { mergeHistograms } from \"./histogram\";\n\n/** The later of two \"slowest\" records. */\nfunction slower<T extends { durationMs: number }>(a: T | null, b: T | null): T | null {\n if (a === null) return b;\n if (b === null) return a;\n\n return b.durationMs > a.durationMs ? b : a;\n}\n\n/**\n * Merges the query statistics several instances reported: one row per shape\n * id, counts and histograms summed, the slowest example kept, `instances`\n * listing who reported it. Order: highest total time first.\n */\nexport function mergeQueryShapeStats(\n reports: readonly { instance: string; shapes: readonly DevtoolsQueryShapeStats[] }[],\n): (DevtoolsQueryShapeStats & { instances: string[] })[] {\n const merged = new Map<string, DevtoolsQueryShapeStats & { instances: string[] }>();\n\n for (const { instance, shapes } of reports) {\n for (const shape of shapes) {\n const current = merged.get(shape.id);\n\n if (!current) {\n merged.set(shape.id, { ...structuredClone(shape), instances: [instance] });\n continue;\n }\n\n current.count += shape.count;\n current.errors += shape.errors;\n current.histogram = mergeHistograms([current.histogram, shape.histogram]);\n current.nPlusOne = {\n requests: current.nPlusOne.requests + shape.nPlusOne.requests,\n maxPerRequest: Math.max(current.nPlusOne.maxPerRequest, shape.nPlusOne.maxPerRequest),\n };\n current.slowest = slower(current.slowest, shape.slowest);\n current.firstSeen = Math.min(current.firstSeen, shape.firstSeen);\n current.lastSeen = Math.max(current.lastSeen, shape.lastSeen);\n current.explainable = current.explainable || shape.explainable;\n\n if (!current.instances.includes(instance)) current.instances.push(instance);\n }\n }\n\n return [...merged.values()].sort((a, b) => b.histogram.sumMs - a.histogram.sumMs);\n}\n\n/** Merges phase lists by name (counts and sums added, max kept), slowest total first, at most 30. */\nfunction mergePhases(\n lists: readonly (readonly DevtoolsRoutePhaseStats[])[],\n): DevtoolsRoutePhaseStats[] {\n const merged = new Map<string, DevtoolsRoutePhaseStats>();\n\n for (const list of lists) {\n for (const phase of list) {\n const current = merged.get(phase.name);\n\n if (!current) {\n merged.set(phase.name, { ...phase });\n continue;\n }\n\n current.count += phase.count;\n current.sumMs += phase.sumMs;\n current.maxMs = Math.max(current.maxMs, phase.maxMs);\n }\n }\n\n return [...merged.values()].sort((a, b) => b.sumMs - a.sumMs).slice(0, 30);\n}\n\n/** Merges route statistics by key, like `mergeQueryShapeStats`. */\nexport function mergeRouteStats(\n reports: readonly { instance: string; routes: readonly DevtoolsRouteStats[] }[],\n): (DevtoolsRouteStats & { instances: string[] })[] {\n const merged = new Map<string, DevtoolsRouteStats & { instances: string[] }>();\n\n for (const { instance, routes } of reports) {\n for (const route of routes) {\n const current = merged.get(route.key);\n\n if (!current) {\n merged.set(route.key, { ...structuredClone(route), instances: [instance] });\n continue;\n }\n\n current.count += route.count;\n current.errors += route.errors;\n current.histogram = mergeHistograms([current.histogram, route.histogram]);\n current.phases = mergePhases([current.phases, route.phases]);\n current.slowest = slower(current.slowest, route.slowest);\n\n if (!current.instances.includes(instance)) current.instances.push(instance);\n }\n }\n\n return [...merged.values()].sort((a, b) => b.histogram.sumMs - a.histogram.sumMs);\n}\n\n/** Merges error groups by id: counts added, the newest message/stack kept. Newest first. */\nexport function mergeErrorGroups(\n reports: readonly { instance: string; errors: readonly DevtoolsErrorGroup[] }[],\n): (DevtoolsErrorGroup & { instances: string[] })[] {\n const merged = new Map<string, DevtoolsErrorGroup & { instances: string[] }>();\n\n for (const { instance, errors } of reports) {\n for (const group of errors) {\n const current = merged.get(group.id);\n\n if (!current) {\n merged.set(group.id, { ...structuredClone(group), instances: [instance] });\n continue;\n }\n\n const newer = group.lastSeen > current.lastSeen;\n\n current.count += group.count;\n current.firstSeen = Math.min(current.firstSeen, group.firstSeen);\n\n if (newer) {\n current.lastSeen = group.lastSeen;\n current.message = group.message;\n current.stack = group.stack;\n current.status = group.status;\n current.lastRequestId = group.lastRequestId;\n }\n\n if (!current.instances.includes(instance)) current.instances.push(instance);\n }\n }\n\n return [...merged.values()].sort((a, b) => b.lastSeen - a.lastSeen);\n}\n","import type { DevtoolsInstanceReport } from \"../contracts\";\n\ntype ListSetter = (report: DevtoolsInstanceReport, keep: number) => DevtoolsInstanceReport;\n\nconst sizeOf = (report: DevtoolsInstanceReport): number =>\n Buffer.byteLength(JSON.stringify(report), \"utf8\");\n\n/** The lists to trim, in order, with how to cut each one to its first `keep` entries. */\nconst LISTS: { length(report: DevtoolsInstanceReport): number; cut: ListSetter }[] = [\n { length: (r) => r.logs.length, cut: (r, keep) => ({ ...r, logs: r.logs.slice(0, keep) }) },\n { length: (r) => r.errors.length, cut: (r, keep) => ({ ...r, errors: r.errors.slice(0, keep) }) },\n { length: (r) => r.routes.length, cut: (r, keep) => ({ ...r, routes: r.routes.slice(0, keep) }) },\n {\n length: (r) => r.queries.length,\n cut: (r, keep) => ({ ...r, queries: r.queries.slice(0, keep) }),\n },\n {\n length: (r) => r.resources.history.length,\n cut: (r, keep) => ({\n ...r,\n resources: { ...r.resources, history: r.resources.history.slice(0, keep) },\n }),\n },\n];\n\n/**\n * Trims a report's lists from the end until its JSON is at most `maxBytes`\n * (default 256 KB): logs first, then errors, routes, queries and the\n * resource history. A report that already fits is returned unchanged.\n */\nexport function capReportSize(\n report: DevtoolsInstanceReport,\n maxBytes = 262_144,\n): DevtoolsInstanceReport {\n let current = report;\n\n for (const list of LISTS) {\n if (sizeOf(current) <= maxBytes) return current;\n\n // The largest number of entries to keep that fits (0 when none does).\n let low = 0;\n let high = list.length(current);\n\n while (low < high) {\n const middle = Math.ceil((low + high) / 2);\n\n if (sizeOf(list.cut(current, middle)) <= maxBytes) low = middle;\n else high = middle - 1;\n }\n\n current = list.cut(current, low);\n }\n\n return current;\n}\n","import type { DevtoolsHealthReport } from \"../contracts\";\nimport type { DevtoolsHealthStatusReader } from \"./readiness\";\nimport type { DevtoolsHealthHistory } from \"./types\";\n\n/** While the app boots, the first check is tried again this often. */\nconst BOOT_RETRY_MS = 1000;\n\n/** Core's readiness, imported on first use so devtools never loads core at import time. */\nconst coreReadiness: DevtoolsHealthStatusReader = async () => {\n const { health, Application } = await import(\"@warlock.js/core\");\n\n // The monitor starts while the app boots, when readiness is `error` with no failed check.\n if (!Application.isBooted && !Application.isShuttingDown) return null;\n\n return health.readiness();\n};\n\n/** Readiness checks every `intervalMs` (default 30000), 60 history entries. */\nexport function createHealthHistory(\n options: { intervalMs?: number; size?: number; readiness?: DevtoolsHealthStatusReader } = {},\n): DevtoolsHealthHistory {\n const intervalMs = options.intervalMs ?? 30_000;\n const size = Math.max(1, options.size ?? 60);\n const readiness = options.readiness ?? coreReadiness;\n\n let status: DevtoolsHealthReport[\"status\"] = \"unknown\";\n let checkedAt: number | null = null;\n let checks: Record<string, boolean> = {};\n const history: DevtoolsHealthReport[\"history\"] = [];\n let timer: ReturnType<typeof setInterval> | undefined;\n let retry: ReturnType<typeof setTimeout> | undefined;\n let running: Promise<DevtoolsHealthReport> | undefined;\n\n function report(): DevtoolsHealthReport {\n return {\n status,\n checkedAt,\n checks: { ...checks },\n history: history.map((e) => ({ ...e, failed: [...e.failed] })),\n };\n }\n\n async function run(): Promise<DevtoolsHealthReport> {\n try {\n const result = await readiness();\n\n if (result === null) {\n // Still booting: nothing to record yet. Until the first answer, try again soon instead of a whole interval later.\n if (timer && checkedAt === null && retry === undefined) {\n retry = setTimeout(() => {\n retry = undefined;\n void check();\n }, BOOT_RETRY_MS);\n retry.unref();\n }\n\n return report();\n }\n\n const now = Date.now();\n const failed = Object.entries(result.checks ?? {})\n .filter(([, passed]) => !passed)\n .map(([name]) => name);\n\n status = result.status;\n checkedAt = now;\n checks = { ...(result.checks ?? {}) };\n history.push({ at: now, status: result.status, failed });\n\n if (history.length > size) history.splice(0, history.length - size);\n } catch {\n // Readiness could not be read (core not loaded yet): keep the last answer.\n if (checkedAt === null) status = \"unknown\";\n }\n\n return report();\n }\n\n function check(): Promise<DevtoolsHealthReport> {\n running ??= run().finally(() => {\n running = undefined;\n });\n\n return running;\n }\n\n return {\n start() {\n if (timer) return;\n\n void check();\n timer = setInterval(() => void check(), intervalMs);\n timer.unref();\n },\n\n stop() {\n if (timer) clearInterval(timer);\n if (retry) clearTimeout(retry);\n\n timer = undefined;\n retry = undefined;\n },\n\n check,\n report,\n };\n}\n","import type { DevtoolsInstanceInfo, DevtoolsInstanceReport, DevtoolsLogRow } from \"../contracts\";\nimport {\n histogramMean,\n histogramQuantile,\n mergeErrorGroups,\n mergeQueryShapeStats,\n mergeRouteStats,\n} from \"../stats\";\nimport type { DevtoolsStore } from \"../store/types\";\nimport type { DevtoolsInsightQuery, DevtoolsInsights, DevtoolsLocalReporter } from \"./types\";\n\nexport const DEFAULT_INSIGHT_LIMIT = 100;\nexport const MAX_INSIGHT_LIMIT = 500;\n\n/** Reports fresher than this are merged into the views. */\nconst FRESH_MS = 60_000;\n/** The instances list reaches back this far. */\nconst INSTANCES_MS = 5 * 60_000;\n\ntype ReportLoader = (windowMs: number) => Promise<DevtoolsInstanceReport[]>;\n\nfunction limitOf(query: DevtoolsInsightQuery): number {\n const limit = query.limit ?? DEFAULT_INSIGHT_LIMIT;\n\n return Math.min(MAX_INSIGHT_LIMIT, Math.max(1, Math.floor(limit)));\n}\n\nfunction matches(value: string, needle: string | undefined): boolean {\n return !needle || value.toLowerCase().includes(needle.toLowerCase());\n}\n\nfunction infoOf(report: DevtoolsInstanceReport): DevtoolsInstanceInfo {\n return { ...report.instance, seenAt: report.at };\n}\n\nfunction build(load: ReportLoader, sampleRateOf: (reports: DevtoolsInstanceReport[]) => number) {\n /** The fresh reports of the selected instance(s). */\n async function select(\n query: DevtoolsInsightQuery,\n windowMs = FRESH_MS,\n ): Promise<DevtoolsInstanceReport[]> {\n const reports = await load(windowMs);\n\n return query.instance === \"all\"\n ? reports\n : reports.filter((report) => report.instance.id === query.instance);\n }\n\n const insights: DevtoolsInsights = {\n async instances() {\n const reports = await load(INSTANCES_MS);\n const infos = reports.map(infoOf).sort((a, b) => b.seenAt - a.seenAt);\n\n return { current: current(reports), instances: infos };\n },\n\n async resources(query) {\n const reports = await select(query);\n\n return {\n instances: reports.map((report) => ({\n instance: infoOf(report),\n snapshot: report.resources.snapshot,\n history: report.resources.history,\n })),\n };\n },\n\n async queryStats(query) {\n const reports = await select(query);\n const sort = query.sort ?? \"total\";\n const rows = mergeQueryShapeStats(\n reports.map((report) => ({ instance: report.instance.id, shapes: report.queries })),\n ).map((shape) => ({\n ...shape,\n p50Ms: histogramQuantile(shape.histogram, 0.5),\n p95Ms: histogramQuantile(shape.histogram, 0.95),\n meanMs: histogramMean(shape.histogram),\n }));\n\n const key: Record<string, (row: (typeof rows)[number]) => number> = {\n total: (row) => row.histogram.sumMs,\n p95: (row) => row.p95Ms,\n count: (row) => row.count,\n \"n+1\": (row) => row.nPlusOne.requests * 1e6 + row.nPlusOne.maxPerRequest,\n };\n const by = key[sort] ?? key.total!;\n\n return {\n shapes: rows.sort((a, b) => by(b) - by(a)).slice(0, limitOf(query)),\n sampleRate: sampleRateOf(reports),\n instanceCount: reports.length,\n evicted: reports.reduce((sum, report) => sum + report.capture.evictedShapes, 0),\n };\n },\n\n async routeStats(query) {\n const reports = await select(query);\n const sort = query.sort ?? \"total\";\n const rows = mergeRouteStats(\n reports.map((report) => ({ instance: report.instance.id, routes: report.routes })),\n ).map((route) => ({\n ...route,\n p50Ms: histogramQuantile(route.histogram, 0.5),\n p95Ms: histogramQuantile(route.histogram, 0.95),\n meanMs: histogramMean(route.histogram),\n }));\n\n const key: Record<string, (row: (typeof rows)[number]) => number> = {\n total: (row) => row.histogram.sumMs,\n p95: (row) => row.p95Ms,\n count: (row) => row.count,\n errors: (row) => row.errors,\n };\n const by = key[sort] ?? key.total!;\n\n return {\n routes: rows.sort((a, b) => by(b) - by(a)).slice(0, limitOf(query)),\n sampleRate: sampleRateOf(reports),\n instanceCount: reports.length,\n };\n },\n\n async health(query) {\n const reports = await select(query);\n\n return {\n instances: reports.map((report) => ({ instance: infoOf(report), report: report.health })),\n };\n },\n\n async errors(query) {\n const reports = await select(query);\n const groups = mergeErrorGroups(\n reports.map((report) => ({ instance: report.instance.id, errors: report.errors })),\n );\n\n return { groups: groups.slice(0, limitOf(query)) };\n },\n\n async logs(query) {\n const reports = await select(query);\n const rows: DevtoolsLogRow[] = [];\n\n for (const report of reports) {\n for (const entry of report.logs) {\n if (!matches(entry.level, query.level) || !matches(entry.module, query.module)) continue;\n\n rows.push({ ...entry, instance: report.instance.id });\n }\n }\n\n return rows.sort((a, b) => b.at - a.at).slice(0, limitOf(query));\n },\n\n async jobs(query) {\n const reports = await select(query);\n\n return {\n instances: reports.map((report) => ({ instance: infoOf(report), report: report.jobs })),\n };\n },\n };\n\n let currentId = \"\";\n\n function current(reports: DevtoolsInstanceReport[]): string {\n return currentId || reports[0]?.instance.id || \"\";\n }\n\n return {\n insights,\n setCurrent(id: string) {\n currentId = id;\n },\n };\n}\n\n/** The sample rate the counts come from: the lowest any selected instance used (1 when none). */\nfunction lowestRate(reports: DevtoolsInstanceReport[]): number {\n return reports.length === 0 ? 1 : Math.min(...reports.map((r) => r.capture.sampleRate));\n}\n\n/** Development insights: this process only. */\nexport function createLocalInsights(reporter: DevtoolsLocalReporter): DevtoolsInsights {\n const { insights, setCurrent } = build(async () => [await reporter.snapshot()], lowestRate);\n\n setCurrent(reporter.instance.id);\n\n return insights;\n}\n\n/** Production insights: merged instance reports from the store plus this process live. */\nexport function createSharedInsights(input: {\n store: DevtoolsStore;\n reporter: DevtoolsLocalReporter;\n sampleRate: number;\n}): DevtoolsInsights {\n const { store, reporter, sampleRate } = input;\n\n const { insights, setCurrent } = build(\n async (windowMs) => {\n const live = await reporter.snapshot();\n let stored: DevtoolsInstanceReport[] = [];\n\n try {\n stored = await store.reports.list(live.at - windowMs);\n } catch {\n // The database is unreachable: show this process alone rather than nothing.\n }\n\n // The answering instance is always taken live, never from its stored row.\n return [live, ...stored.filter((report) => report.instance.id !== live.instance.id)];\n },\n () => sampleRate,\n );\n\n setCurrent(reporter.instance.id);\n\n return insights;\n}\n","import cluster from \"node:cluster\";\nimport os from \"node:os\";\nimport type { DevtoolsInstanceInfo } from \"../contracts\";\n\n/** This process's identity (host, pid, pm2/cluster worker, start time). */\nexport function createInstanceInfo(now: number = Date.now()): DevtoolsInstanceInfo {\n const host = os.hostname();\n const pid = process.pid;\n const worker =\n process.env.NODE_APP_INSTANCE ||\n process.env.pm_id ||\n (cluster.worker ? String(cluster.worker.id) : null);\n\n return {\n id: `${host}:${pid}:${now.toString(36)}`,\n label: worker === null ? `${host} pid ${pid}` : `${host} #${worker}`,\n host,\n pid,\n worker,\n startedAt: now,\n seenAt: now,\n nodeVersion: process.version,\n };\n}\n","import type { DevtoolsJobsReport, DevtoolsScheduleInfo } from \"../contracts\";\nimport type { DevtoolsJobsReader } from \"./types\";\n\n/** The shape of a scheduler job this reader needs (duck-typed: the packages stay optional). */\ntype SchedulerJobLike = {\n name: string;\n cronExpression?: string | null;\n intervals?: { every?: { type?: string; value?: number } };\n isRunning?: boolean;\n lastRun?: { valueOf(): number } | null;\n nextRun?: { valueOf(): number } | null;\n};\n\n/** Where the jobs come from; replaced in specs. Each returns `null` when its package is absent. */\nexport type DevtoolsJobsLoaders = {\n scheduler(): Promise<readonly SchedulerJobLike[] | null>;\n queue(): Promise<{ name: string; counts: Record<string, number> }[] | null>;\n};\n\nconst SCHEDULER_KEY = Symbol.for(\"warlock.scheduler.running\");\n\n/** Imports an optional package by name; `null` when it is not installed. */\nasync function importOptional(name: string): Promise<Record<string, unknown> | null> {\n try {\n return (await import(/* @vite-ignore */ name)) as Record<string, unknown>;\n } catch {\n return null;\n }\n}\n\nconst defaultLoaders: DevtoolsJobsLoaders = {\n async scheduler() {\n if (!(await importOptional(\"@warlock.js/scheduler\"))) return null;\n\n const running = (globalThis as Record<symbol, unknown>)[SCHEDULER_KEY] as\n | Iterable<{ list?: () => readonly SchedulerJobLike[] }>\n | undefined;\n const jobs: SchedulerJobLike[] = [];\n\n for (const scheduler of running ?? []) {\n if (typeof scheduler.list === \"function\") jobs.push(...scheduler.list());\n }\n\n return jobs;\n },\n\n async queue() {\n const queue = await importOptional(\"@warlock.js/queue\");\n const current = queue?.currentQueueDriver as (() => unknown) | undefined;\n const driver = current?.() as\n | {\n running?: () => string[];\n counts?: (queue: string) => Promise<Record<string, number>>;\n }\n | undefined;\n\n if (!driver || typeof driver.counts !== \"function\" || typeof driver.running !== \"function\") {\n return null;\n }\n\n const queues: { name: string; counts: Record<string, number> }[] = [];\n\n for (const name of driver.running()) {\n queues.push({ name, counts: await driver.counts(name) });\n }\n\n return queues;\n },\n};\n\nfunction readableInterval(job: SchedulerJobLike): string | null {\n const every = job.intervals?.every;\n\n if (!every?.type) return null;\n\n const value = every.value ?? 1;\n const unit = every.type.replace(/s$/, \"\");\n\n return value === 1 ? `every ${unit}` : `every ${value} ${unit}s`;\n}\n\nfunction toSchedule(job: SchedulerJobLike): DevtoolsScheduleInfo {\n return {\n name: job.name,\n cron: job.cronExpression ?? null,\n interval: readableInterval(job),\n isRunning: job.isRunning === true,\n lastRunAt: job.lastRun ? Number(job.lastRun.valueOf()) : null,\n nextRunAt: job.nextRun ? Number(job.nextRun.valueOf()) : null,\n // The scheduler keeps no per-run history; these stay empty.\n lastDurationMs: null,\n lastError: null,\n runs: 0,\n failures: 0,\n };\n}\n\n/**\n * Reads the scheduler's jobs and the queue's counts when those packages are\n * installed. A part that is absent or fails reports `available: false` with\n * nothing else; the reader itself never throws.\n */\nexport function createJobsReader(loaders: Partial<DevtoolsJobsLoaders> = {}): DevtoolsJobsReader {\n const source = { ...defaultLoaders, ...loaders };\n\n return async () => {\n const report: DevtoolsJobsReport = {\n available: { scheduler: false, queue: false },\n schedules: [],\n queues: [],\n };\n\n try {\n const jobs = await source.scheduler();\n\n if (jobs) {\n report.available.scheduler = true;\n report.schedules = jobs.map(toSchedule);\n }\n } catch {\n report.available.scheduler = false;\n report.schedules = [];\n }\n\n try {\n const queues = await source.queue();\n\n if (queues) {\n report.available.queue = true;\n report.queues = queues;\n }\n } catch {\n report.available.queue = false;\n report.queues = [];\n }\n\n return report;\n };\n}\n","import type {\n DevtoolsCaptureCounters,\n DevtoolsInstanceInfo,\n DevtoolsInstanceReport,\n DevtoolsJobsReport,\n} from \"../contracts\";\nimport type {\n DevtoolsErrorGroups,\n DevtoolsProductionCapture,\n DevtoolsQueryStats,\n DevtoolsRecentLogs,\n DevtoolsRouteStatsStore,\n} from \"../capture/types\";\nimport type {\n DevtoolsHealthHistory,\n DevtoolsJobsReader,\n DevtoolsLocalReporter,\n DevtoolsResourceMonitor,\n} from \"./types\";\n\nconst emptyJobs = (): DevtoolsJobsReport => ({\n available: { scheduler: false, queue: false },\n schedules: [],\n queues: [],\n});\n\n/** This process's report from its parts (production: from the capture; development: from the dev stats). */\nexport function createLocalReporter(parts: {\n instance: DevtoolsInstanceInfo;\n resources: DevtoolsResourceMonitor;\n health: DevtoolsHealthHistory;\n jobs: DevtoolsJobsReader;\n queries: DevtoolsQueryStats;\n routes: DevtoolsRouteStatsStore;\n errors: DevtoolsErrorGroups;\n logs: DevtoolsRecentLogs;\n counters: DevtoolsProductionCapture[\"counters\"] | null;\n now?: () => number;\n}): DevtoolsLocalReporter {\n const now = parts.now ?? Date.now;\n\n return {\n instance: parts.instance,\n\n async snapshot() {\n const at = now();\n let jobs: DevtoolsJobsReport;\n\n try {\n jobs = await parts.jobs();\n } catch {\n jobs = emptyJobs();\n }\n\n const capture: DevtoolsCaptureCounters = parts.counters\n ? parts.counters()\n : {\n sampleRate: 1,\n requests: 0,\n sampled: 0,\n keptUnsampled: 0,\n stored: 0,\n droppedStored: 0,\n evictedShapes: parts.queries.evicted(),\n evictedRoutes: parts.routes.evicted(),\n evictedErrors: parts.errors.evicted(),\n droppedQueries: 0,\n };\n\n const report: DevtoolsInstanceReport = {\n instance: { ...parts.instance, seenAt: at },\n at,\n resources: { snapshot: parts.resources.snapshot(), history: parts.resources.history() },\n queries: parts.queries.snapshot(200),\n routes: parts.routes.snapshot(200),\n errors: parts.errors.snapshot(50),\n logs: parts.logs.snapshot(50),\n health: parts.health.report(),\n jobs,\n capture,\n };\n\n return report;\n },\n };\n}\n","import {\n constants,\n monitorEventLoopDelay,\n performance,\n PerformanceObserver,\n} from \"node:perf_hooks\";\nimport v8 from \"node:v8\";\nimport type { DevtoolsResourcePoint, DevtoolsResourceSnapshot } from \"../contracts\";\nimport type { DevtoolsResourceMonitor } from \"./types\";\n\ntype GcKind = keyof DevtoolsResourceSnapshot[\"gcByKind\"];\n\n/** The readings a monitor takes; replaced by fakes in specs. */\nexport type DevtoolsResourceSources = {\n now(): number;\n memoryUsage(): { rss: number; heapUsed: number; heapTotal: number; external: number };\n /** Microseconds, as `process.cpuUsage()`. */\n cpuUsage(): { user: number; system: number };\n heapLimit(): number;\n uptime(): number;\n /** Nanoseconds, as a `perf_hooks` interval histogram. */\n eventLoopDelay(): {\n enable(): unknown;\n disable(): unknown;\n reset(): void;\n percentile(percentile: number): number;\n readonly max: number;\n };\n eventLoopUtilization(): { idle: number; active: number };\n /** Calls `onGc` for every collection; returns the function that stops observing. */\n observeGc(onGc: (kind: GcKind, durationMs: number) => void): () => void;\n};\n\nfunction gcKindName(kind: number | undefined): GcKind {\n if (kind === constants.NODE_PERFORMANCE_GC_MAJOR) return \"major\";\n if (kind === constants.NODE_PERFORMANCE_GC_INCREMENTAL) return \"incremental\";\n if (kind === constants.NODE_PERFORMANCE_GC_WEAKCB) return \"weakcb\";\n\n return \"minor\";\n}\n\nconst defaultSources: DevtoolsResourceSources = {\n now: () => Date.now(),\n memoryUsage: () => process.memoryUsage(),\n cpuUsage: () => process.cpuUsage(),\n heapLimit: () => v8.getHeapStatistics().heap_size_limit,\n uptime: () => process.uptime(),\n eventLoopDelay: () => monitorEventLoopDelay({ resolution: 20 }),\n eventLoopUtilization: () => performance.eventLoopUtilization(),\n observeGc(onGc) {\n const observer = new PerformanceObserver((list) => {\n for (const entry of list.getEntries()) {\n const detail = (entry as unknown as { detail?: { kind?: number }; kind?: number }).detail;\n const kind = detail?.kind ?? (entry as unknown as { kind?: number }).kind;\n\n onGc(gcKindName(kind), entry.duration);\n }\n });\n\n observer.observe({ entryTypes: [\"gc\"] });\n\n return () => observer.disconnect();\n },\n};\n\n/** Nanoseconds to milliseconds; a histogram with no samples reports 0. */\nfunction nsToMs(value: number): number {\n return Number.isFinite(value) && value > 0 && value < 1e15 ? value / 1e6 : 0;\n}\n\n/** Resource sampling every `intervalMs` (default 5000), `historySize` points (default 120). */\nexport function createResourceMonitor(\n options: {\n intervalMs?: number;\n historySize?: number;\n sources?: Partial<DevtoolsResourceSources>;\n } = {},\n): DevtoolsResourceMonitor {\n const intervalMs = options.intervalMs ?? 5000;\n const historySize = Math.max(1, options.historySize ?? 120);\n const sources: DevtoolsResourceSources = { ...defaultSources, ...options.sources };\n\n const loopDelay = sources.eventLoopDelay();\n const points: DevtoolsResourcePoint[] = [];\n const gcByKind: DevtoolsResourceSnapshot[\"gcByKind\"] = {\n minor: { count: 0, pauseMs: 0 },\n major: { count: 0, pauseMs: 0 },\n incremental: { count: 0, pauseMs: 0 },\n weakcb: { count: 0, pauseMs: 0 },\n };\n let gcCountSince = 0;\n let gcPauseSince = 0;\n let lastAt = sources.now();\n let lastCpu = sources.cpuUsage();\n let lastElu = sources.eventLoopUtilization();\n let timer: ReturnType<typeof setInterval> | undefined;\n let stopGc: (() => void) | undefined;\n\n function sample(): DevtoolsResourcePoint {\n const at = sources.now();\n const memory = sources.memoryUsage();\n const cpu = sources.cpuUsage();\n const elu = sources.eventLoopUtilization();\n const wallMs = at - lastAt;\n const cpuMs = (cpu.user + cpu.system - lastCpu.user - lastCpu.system) / 1000;\n const active = elu.active - lastElu.active;\n const idle = elu.idle - lastElu.idle;\n\n const point: DevtoolsResourcePoint = {\n at,\n rssBytes: memory.rss,\n heapUsedBytes: memory.heapUsed,\n heapTotalBytes: memory.heapTotal,\n externalBytes: memory.external,\n cpuPercent: wallMs > 0 ? Math.max(0, (cpuMs / wallMs) * 100) : 0,\n eventLoopDelayP50Ms: nsToMs(loopDelay.percentile(50)),\n eventLoopDelayP99Ms: nsToMs(loopDelay.percentile(99)),\n eventLoopDelayMaxMs: nsToMs(loopDelay.max),\n eventLoopUtilization: active + idle > 0 ? active / (active + idle) : 0,\n gcCount: gcCountSince,\n gcPauseMs: gcPauseSince,\n };\n\n loopDelay.reset();\n lastAt = at;\n lastCpu = cpu;\n lastElu = elu;\n gcCountSince = 0;\n gcPauseSince = 0;\n\n points.push(point);\n\n if (points.length > historySize) points.splice(0, points.length - historySize);\n\n return { ...point };\n }\n\n return {\n start() {\n if (timer) return;\n\n lastAt = sources.now();\n lastCpu = sources.cpuUsage();\n lastElu = sources.eventLoopUtilization();\n loopDelay.enable();\n stopGc = sources.observeGc((kind, durationMs) => {\n gcCountSince++;\n gcPauseSince += durationMs;\n gcByKind[kind].count++;\n gcByKind[kind].pauseMs += durationMs;\n });\n timer = setInterval(sample, intervalMs);\n timer.unref();\n },\n\n stop() {\n if (timer) clearInterval(timer);\n\n timer = undefined;\n stopGc?.();\n stopGc = undefined;\n loopDelay.disable();\n },\n\n sample,\n\n snapshot() {\n const latest = points[points.length - 1] ?? sample();\n\n return {\n ...latest,\n heapLimitBytes: sources.heapLimit(),\n uptimeSeconds: sources.uptime(),\n gcByKind: structuredClone(gcByKind),\n };\n },\n\n history() {\n return points.map((point) => ({ ...point }));\n },\n };\n}\n","import type { ResolvedDevtoolsProductionOptions } from \"../options\";\nimport type { DevtoolsStore } from \"../store/types\";\nimport { capReportSize } from \"./cap-report\";\nimport type { DevtoolsLocalReporter, DevtoolsReportWriter } from \"./types\";\n\nconst HOUSEKEEPING_INTERVAL_MS = 10 * 60_000;\nconst REPORT_MAX_AGE_MS = 5 * 60_000;\nconst WARN_EVERY_MS = 60_000;\n\n/**\n * Writes the report every `production.reportIntervalMs`, and every 10\n * minutes prunes: reports unseen for 5 minutes, samples older than\n * `requestRetentionHours`, expired sessions and invites, audit entries older\n * than `auditRetentionDays`. Timers are `unref`ed; a failed write is logged\n * once per minute, never thrown.\n */\nexport function startReportWriter(input: {\n reporter: DevtoolsLocalReporter;\n store: DevtoolsStore;\n production: ResolvedDevtoolsProductionOptions;\n warn?: (message: string) => void;\n}): DevtoolsReportWriter {\n const { reporter, store, production, warn } = input;\n let stopped = false;\n let lastWarnAt = Number.NEGATIVE_INFINITY;\n let pending: Promise<void> = Promise.resolve();\n\n function fail(what: string, error: unknown): void {\n const now = Date.now();\n\n if (!warn || now - lastWarnAt < WARN_EVERY_MS) return;\n\n lastWarnAt = now;\n\n const reason = error instanceof Error ? error.message : String(error);\n\n warn(`Devtools could not ${what}: ${reason}. It will try again.`);\n }\n\n async function write(): Promise<void> {\n if (stopped) return;\n\n try {\n await store.reports.write(capReportSize(await reporter.snapshot()));\n } catch (error) {\n fail(\"write this instance's report to the database\", error);\n }\n }\n\n async function housekeeping(): Promise<void> {\n if (stopped) return;\n\n const now = Date.now();\n const steps: [string, () => Promise<unknown>][] = [\n [\"remove old instance reports\", () => store.reports.prune(now - REPORT_MAX_AGE_MS)],\n [\n \"remove old request samples\",\n () => store.samples.prune(now - production.requestRetentionHours * 3_600_000),\n ],\n [\"remove expired sessions\", () => store.sessions.removeExpired(now)],\n [\"remove expired invites\", () => store.invites.removeExpired(now)],\n [\n \"remove old audit entries\",\n () => store.audit.prune(now - production.auditRetentionDays * 86_400_000),\n ],\n ];\n\n for (const [what, step] of steps) {\n try {\n await step();\n } catch (error) {\n fail(what, error);\n }\n }\n }\n\n function enqueue(task: () => Promise<void>): Promise<void> {\n pending = pending.then(task);\n\n return pending;\n }\n\n const writeTimer = setInterval(() => void enqueue(write), production.reportIntervalMs);\n const housekeepingTimer = setInterval(() => void enqueue(housekeeping), HOUSEKEEPING_INTERVAL_MS);\n\n writeTimer.unref();\n housekeepingTimer.unref();\n void enqueue(write);\n\n return {\n writeNow: () => enqueue(write),\n\n async st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AEb,IAAI;GACF,MAAM,MAAM,QAAQ,MAAM,cAAc,MAAM,SAAS,SAAS,CAAC,CAAC;EACpE,SAAS,OAAO;GACd,KAAK,gDAAgD,KAAK;EAC5D;CACF;CAEA,eAAe,eAA8B;EAC3C,IAAI,SAAS;EAEb,MAAM,MAAM,KAAK,IAAI;EACrB,MAAM,QAA4C;GAChD,CAAC,qCAAqC,MAAM,QAAQ,MAAM,MAAM,iBAAiB,CAAC;GAClF,CACE,oCACM,MAAM,QAAQ,MAAM,MAAM,WAAW,wBAAwB,IAAS,CAC9E;GACA,CAAC,iCAAiC,MAAM,SAAS,cAAc,GAAG,CAAC;GACnE,CAAC,gCAAgC,MAAM,QAAQ,cAAc,GAAG,CAAC;GACjE,CACE,kCACM,MAAM,MAAM,MAAM,MAAM,WAAW,qBAAqB,KAAU,CAC1E;EACF;EAEA,KAAK,MAAM,CAAC,MAAM,SAAS,OACzB,IAAI;GACF,MAAM,KAAK;EACb,SAAS,OAAO;GACd,KAAK,MAAM,KAAK;EAClB;CAEJ;CAEA,SAAS,QAAQ,MAA0C;EACzD,UAAU,QAAQ,KAAK,IAAI;EAE3B,OAAO;CACT;CAEA,MAAM,aAAa,kBAAkB,KAAK,QAAQ,KAAK,GAAG,WAAW,gBAAgB;CACrF,MAAM,oBAAoB,kBAAkB,KAAK,QAAQ,YAAY,GAAG,wBAAwB;CAEhG,WAAW,MAAM;CACjB,kBAAkB,MAAM;CACxB,AAAK,QAAQ,KAAK;CAElB,OAAO;EACL,gBAAgB,QAAQ,KAAK;EAE7B,MAAM,OAAO;GACX,UAAU;GACV,cAAc,UAAU;GACxB,cAAc,iBAAiB;GAC/B,MAAM;EACR;CACF;AACF"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
let node_net = require("node:net");
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/devtools/src/production/http/ip.ts
|
|
4
|
+
/** The IPv4 ranges `"private"` stands for (private networks and link-local). */
|
|
5
|
+
const PRIVATE_V4 = [
|
|
6
|
+
["10.0.0.0", 8],
|
|
7
|
+
["172.16.0.0", 12],
|
|
8
|
+
["192.168.0.0", 16],
|
|
9
|
+
["169.254.0.0", 16]
|
|
10
|
+
];
|
|
11
|
+
/** The IPv6 ranges `"private"` stands for (unique local and link-local). */
|
|
12
|
+
const PRIVATE_V6 = [["fc00::", 7], ["fe80::", 10]];
|
|
13
|
+
const MAPPED_PREFIX = /^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i;
|
|
14
|
+
/**
|
|
15
|
+
* An address in its plain form: an IPv4-mapped IPv6 address (`::ffff:1.2.3.4`)
|
|
16
|
+
* becomes `1.2.3.4`, a zone id (`fe80::1%eth0`) is dropped, and the letters of
|
|
17
|
+
* an IPv6 address are lower case. Anything that is not an IP is returned
|
|
18
|
+
* unchanged.
|
|
19
|
+
*/
|
|
20
|
+
function normalizeIp(address) {
|
|
21
|
+
const value = address.trim();
|
|
22
|
+
const zone = value.indexOf("%");
|
|
23
|
+
const bare = zone === -1 ? value : value.slice(0, zone);
|
|
24
|
+
const mapped = MAPPED_PREFIX.exec(bare);
|
|
25
|
+
if (mapped?.[1] !== void 0 && (0, node_net.isIP)(mapped[1]) === 4) return mapped[1];
|
|
26
|
+
return (0, node_net.isIP)(bare) === 6 ? bare.toLowerCase() : bare;
|
|
27
|
+
}
|
|
28
|
+
/** Splits `a.b.c.d/24` into its address and prefix length, or `null` when it is not a CIDR. */
|
|
29
|
+
function parseCidr(entry) {
|
|
30
|
+
const slash = entry.indexOf("/");
|
|
31
|
+
if (slash === -1) return null;
|
|
32
|
+
const address = normalizeIp(entry.slice(0, slash));
|
|
33
|
+
const text = entry.slice(slash + 1);
|
|
34
|
+
const family = (0, node_net.isIP)(address);
|
|
35
|
+
if (family === 0 || !/^\d{1,3}$/.test(text)) return null;
|
|
36
|
+
const prefix = Number(text);
|
|
37
|
+
if (family !== 4 && family !== 6) return null;
|
|
38
|
+
return prefix <= (family === 4 ? 32 : 128) ? {
|
|
39
|
+
address,
|
|
40
|
+
prefix,
|
|
41
|
+
family
|
|
42
|
+
} : null;
|
|
43
|
+
}
|
|
44
|
+
/** Whether `entry` is an IP, a CIDR range, `"loopback"` or `"private"`. */
|
|
45
|
+
function isValidNetworkEntry(entry) {
|
|
46
|
+
if (typeof entry !== "string") return false;
|
|
47
|
+
if (entry === "loopback" || entry === "private") return true;
|
|
48
|
+
return (0, node_net.isIP)(normalizeIp(entry)) !== 0 || parseCidr(entry) !== null;
|
|
49
|
+
}
|
|
50
|
+
const compiled = /* @__PURE__ */ new WeakMap();
|
|
51
|
+
function compile(entries) {
|
|
52
|
+
const cached = compiled.get(entries);
|
|
53
|
+
if (cached) return cached;
|
|
54
|
+
const list = new node_net.BlockList();
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
if (entry === "loopback") {
|
|
57
|
+
list.addSubnet("127.0.0.0", 8, "ipv4");
|
|
58
|
+
list.addAddress("::1", "ipv6");
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (entry === "private") {
|
|
62
|
+
for (const [address, prefix] of PRIVATE_V4) list.addSubnet(address, prefix, "ipv4");
|
|
63
|
+
for (const [address, prefix] of PRIVATE_V6) list.addSubnet(address, prefix, "ipv6");
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const cidr = parseCidr(entry);
|
|
67
|
+
if (cidr) {
|
|
68
|
+
list.addSubnet(cidr.address, cidr.prefix, cidr.family === 4 ? "ipv4" : "ipv6");
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const address = normalizeIp(entry);
|
|
72
|
+
const family = (0, node_net.isIP)(address);
|
|
73
|
+
if (family !== 0) list.addAddress(address, family === 4 ? "ipv4" : "ipv6");
|
|
74
|
+
}
|
|
75
|
+
compiled.set(entries, list);
|
|
76
|
+
return list;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Whether `address` matches an entry: an IP, a CIDR, `"loopback"` or
|
|
80
|
+
* `"private"` (10/8, 172.16/12, 192.168/16, 169.254/16, fc00::/7, fe80::/10).
|
|
81
|
+
* IPv4-mapped IPv6 addresses are unwrapped on both sides.
|
|
82
|
+
*/
|
|
83
|
+
function ipMatches(address, entries) {
|
|
84
|
+
if (entries.length === 0) return false;
|
|
85
|
+
const ip = normalizeIp(address);
|
|
86
|
+
const family = (0, node_net.isIP)(ip);
|
|
87
|
+
if (family === 0) return false;
|
|
88
|
+
return compile(entries).check(ip, family === 4 ? "ipv4" : "ipv6");
|
|
89
|
+
}
|
|
90
|
+
/** The eight 16-bit groups of an IPv6 address, or `null` when it is not one. */
|
|
91
|
+
function ipv6Groups(address) {
|
|
92
|
+
if ((0, node_net.isIP)(address) !== 6) return null;
|
|
93
|
+
const text = address.replace(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/, (_, a, b, c, d) => `${(Number(a) << 8 | Number(b)).toString(16)}:${(Number(c) << 8 | Number(d)).toString(16)}`);
|
|
94
|
+
const parse = (part) => part === "" ? [] : part.split(":").map((group) => parseInt(group, 16));
|
|
95
|
+
const [head = "", rest] = text.split("::");
|
|
96
|
+
const left = parse(head);
|
|
97
|
+
const right = rest === void 0 ? [] : parse(rest);
|
|
98
|
+
const zeros = Array.from({ length: Math.max(0, 8 - left.length - right.length) }, () => 0);
|
|
99
|
+
return [
|
|
100
|
+
...left,
|
|
101
|
+
...zeros,
|
|
102
|
+
...right
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The client an address counts as for the sign-in rate limits. An IPv4
|
|
107
|
+
* address counts as itself (an IPv4-mapped IPv6 address as its IPv4 address),
|
|
108
|
+
* an IPv6 address by its /64 network, because one host is usually given a
|
|
109
|
+
* whole /64 and can change the rest at will. Anything else is returned as is.
|
|
110
|
+
*/
|
|
111
|
+
function rateLimitClient(address) {
|
|
112
|
+
const ip = normalizeIp(address);
|
|
113
|
+
const groups = ipv6Groups(ip);
|
|
114
|
+
if (groups === null) return ip;
|
|
115
|
+
if (groups.slice(0, 5).every((group) => group === 0) && groups[5] === 65535) {
|
|
116
|
+
const high = groups[6] ?? 0;
|
|
117
|
+
const low = groups[7] ?? 0;
|
|
118
|
+
return [
|
|
119
|
+
high >> 8,
|
|
120
|
+
high & 255,
|
|
121
|
+
low >> 8,
|
|
122
|
+
low & 255
|
|
123
|
+
].join(".");
|
|
124
|
+
}
|
|
125
|
+
return `${groups.slice(0, 4).map((group) => group.toString(16)).join(":")}::/64`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
Object.defineProperty(exports, "ipMatches", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () {
|
|
132
|
+
return ipMatches;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
Object.defineProperty(exports, "isValidNetworkEntry", {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
get: function () {
|
|
138
|
+
return isValidNetworkEntry;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
Object.defineProperty(exports, "normalizeIp", {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
get: function () {
|
|
144
|
+
return normalizeIp;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(exports, "rateLimitClient", {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
get: function () {
|
|
150
|
+
return rateLimitClient;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=ip-DbNhPOzi.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip-DbNhPOzi.cjs","names":["isIP","BlockList"],"sources":["../../../../../../../packages/devtools/src/production/http/ip.ts"],"sourcesContent":["import { BlockList, isIP } from \"node:net\";\n\n/** The IPv4 ranges `\"private\"` stands for (private networks and link-local). */\nconst PRIVATE_V4: readonly (readonly [string, number])[] = [\n [\"10.0.0.0\", 8],\n [\"172.16.0.0\", 12],\n [\"192.168.0.0\", 16],\n [\"169.254.0.0\", 16],\n];\n\n/** The IPv6 ranges `\"private\"` stands for (unique local and link-local). */\nconst PRIVATE_V6: readonly (readonly [string, number])[] = [\n [\"fc00::\", 7],\n [\"fe80::\", 10],\n];\n\nconst MAPPED_PREFIX = /^::ffff:(\\d{1,3}(?:\\.\\d{1,3}){3})$/i;\n\n/**\n * An address in its plain form: an IPv4-mapped IPv6 address (`::ffff:1.2.3.4`)\n * becomes `1.2.3.4`, a zone id (`fe80::1%eth0`) is dropped, and the letters of\n * an IPv6 address are lower case. Anything that is not an IP is returned\n * unchanged.\n */\nexport function normalizeIp(address: string): string {\n const value = address.trim();\n const zone = value.indexOf(\"%\");\n const bare = zone === -1 ? value : value.slice(0, zone);\n const mapped = MAPPED_PREFIX.exec(bare);\n\n if (mapped?.[1] !== undefined && isIP(mapped[1]) === 4) return mapped[1];\n\n return isIP(bare) === 6 ? bare.toLowerCase() : bare;\n}\n\n/** Splits `a.b.c.d/24` into its address and prefix length, or `null` when it is not a CIDR. */\nfunction parseCidr(entry: string): { address: string; prefix: number; family: 4 | 6 } | null {\n const slash = entry.indexOf(\"/\");\n\n if (slash === -1) return null;\n\n const address = normalizeIp(entry.slice(0, slash));\n const text = entry.slice(slash + 1);\n const family = isIP(address);\n\n if (family === 0 || !/^\\d{1,3}$/.test(text)) return null;\n\n const prefix = Number(text);\n\n if (family !== 4 && family !== 6) return null;\n\n return prefix <= (family === 4 ? 32 : 128) ? { address, prefix, family } : null;\n}\n\n/** Whether `entry` is an IP, a CIDR range, `\"loopback\"` or `\"private\"`. */\nexport function isValidNetworkEntry(entry: unknown): entry is string {\n if (typeof entry !== \"string\") return false;\n if (entry === \"loopback\" || entry === \"private\") return true;\n\n return isIP(normalizeIp(entry)) !== 0 || parseCidr(entry) !== null;\n}\n\nconst compiled = new WeakMap<readonly string[], BlockList>();\n\nfunction compile(entries: readonly string[]): BlockList {\n const cached = compiled.get(entries);\n\n if (cached) return cached;\n\n const list = new BlockList();\n\n for (const entry of entries) {\n if (entry === \"loopback\") {\n list.addSubnet(\"127.0.0.0\", 8, \"ipv4\");\n list.addAddress(\"::1\", \"ipv6\");\n continue;\n }\n\n if (entry === \"private\") {\n for (const [address, prefix] of PRIVATE_V4) list.addSubnet(address, prefix, \"ipv4\");\n for (const [address, prefix] of PRIVATE_V6) list.addSubnet(address, prefix, \"ipv6\");\n continue;\n }\n\n const cidr = parseCidr(entry);\n\n if (cidr) {\n list.addSubnet(cidr.address, cidr.prefix, cidr.family === 4 ? \"ipv4\" : \"ipv6\");\n continue;\n }\n\n const address = normalizeIp(entry);\n const family = isIP(address);\n\n if (family !== 0) list.addAddress(address, family === 4 ? \"ipv4\" : \"ipv6\");\n }\n\n compiled.set(entries, list);\n\n return list;\n}\n\n/**\n * Whether `address` matches an entry: an IP, a CIDR, `\"loopback\"` or\n * `\"private\"` (10/8, 172.16/12, 192.168/16, 169.254/16, fc00::/7, fe80::/10).\n * IPv4-mapped IPv6 addresses are unwrapped on both sides.\n */\nexport function ipMatches(address: string, entries: readonly string[]): boolean {\n if (entries.length === 0) return false;\n\n const ip = normalizeIp(address);\n const family = isIP(ip);\n\n if (family === 0) return false;\n\n return compile(entries).check(ip, family === 4 ? \"ipv4\" : \"ipv6\");\n}\n\n/** The eight 16-bit groups of an IPv6 address, or `null` when it is not one. */\nfunction ipv6Groups(address: string): number[] | null {\n if (isIP(address) !== 6) return null;\n\n // A trailing dotted IPv4 part (`::ffff:1.2.3.4`, `64:ff9b::1.2.3.4`) becomes two hex groups.\n const text = address.replace(\n /(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/,\n (_, a, b, c, d) =>\n `${((Number(a) << 8) | Number(b)).toString(16)}:${((Number(c) << 8) | Number(d)).toString(16)}`,\n );\n const parse = (part: string) =>\n part === \"\" ? [] : part.split(\":\").map((group) => parseInt(group, 16));\n const [head = \"\", rest] = text.split(\"::\");\n const left = parse(head);\n const right = rest === undefined ? [] : parse(rest);\n const zeros = Array.from({ length: Math.max(0, 8 - left.length - right.length) }, () => 0);\n\n return [...left, ...zeros, ...right];\n}\n\n/**\n * The client an address counts as for the sign-in rate limits. An IPv4\n * address counts as itself (an IPv4-mapped IPv6 address as its IPv4 address),\n * an IPv6 address by its /64 network, because one host is usually given a\n * whole /64 and can change the rest at will. Anything else is returned as is.\n */\nexport function rateLimitClient(address: string): string {\n const ip = normalizeIp(address);\n const groups = ipv6Groups(ip);\n\n if (groups === null) return ip;\n\n // ::ffff:a.b.c.d written any other way (0:0:0:0:0:ffff:…, hex groups).\n if (groups.slice(0, 5).every((group) => group === 0) && groups[5] === 0xffff) {\n const high = groups[6] ?? 0;\n const low = groups[7] ?? 0;\n\n return [high >> 8, high & 0xff, low >> 8, low & 0xff].join(\".\");\n }\n\n return `${groups\n .slice(0, 4)\n .map((group) => group.toString(16))\n .join(\":\")}::/64`;\n}\n"],"mappings":";;;;AAGA,MAAM,aAAqD;CACzD,CAAC,YAAY,CAAC;CACd,CAAC,cAAc,EAAE;CACjB,CAAC,eAAe,EAAE;CAClB,CAAC,eAAe,EAAE;AACpB;;AAGA,MAAM,aAAqD,CACzD,CAAC,UAAU,CAAC,GACZ,CAAC,UAAU,EAAE,CACf;AAEA,MAAM,gBAAgB;;;;;;;AAQtB,SAAgB,YAAY,SAAyB;CACnD,MAAM,QAAQ,QAAQ,KAAK;CAC3B,MAAM,OAAO,MAAM,QAAQ,GAAG;CAC9B,MAAM,OAAO,SAAS,KAAK,QAAQ,MAAM,MAAM,GAAG,IAAI;CACtD,MAAM,SAAS,cAAc,KAAK,IAAI;CAEtC,IAAI,SAAS,OAAO,cAAaA,eAAK,OAAO,EAAE,MAAM,GAAG,OAAO,OAAO;CAEtE,WAAOA,eAAK,IAAI,MAAM,IAAI,KAAK,YAAY,IAAI;AACjD;;AAGA,SAAS,UAAU,OAA0E;CAC3F,MAAM,QAAQ,MAAM,QAAQ,GAAG;CAE/B,IAAI,UAAU,IAAI,OAAO;CAEzB,MAAM,UAAU,YAAY,MAAM,MAAM,GAAG,KAAK,CAAC;C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O,OAAO,MAAM;EAC1B,MAAM,MAAM,OAAO,MAAM;EAEzB,OAAO;GAAC,QAAQ;GAAG,OAAO;GAAM,OAAO;GAAG,MAAM;EAAI,CAAC,CAAC,KAAK,GAAG;CAChE;CAEA,OAAO,GAAG,OACP,MAAM,GAAG,CAAC,CAAC,CACX,KAAK,UAAU,MAAM,SAAS,EAAE,CAAC,CAAC,CAClC,KAAK,GAAG,EAAE;AACf"}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-Zuuoy_Rh.cjs");
|
|
2
|
+
let _warlock_js_cascade = require("@warlock.js/cascade");
|
|
3
|
+
|
|
4
|
+
//#region ../../packages/devtools/src/production/store/models/base.ts
|
|
5
|
+
/**
|
|
6
|
+
* Settings shared by the monitor's tables. Ids are supplied by the store
|
|
7
|
+
* (random uuids, or `"state"`), times are plain epoch-millisecond columns the
|
|
8
|
+
* store writes itself, and a removal is always permanent: sessions, invites
|
|
9
|
+
* and samples must not be copied into a trash table.
|
|
10
|
+
*/
|
|
11
|
+
var DevtoolsRowModel = class extends _warlock_js_cascade.Model {
|
|
12
|
+
static {
|
|
13
|
+
this.autoGenerateId = false;
|
|
14
|
+
}
|
|
15
|
+
static {
|
|
16
|
+
this.createdAtColumn = false;
|
|
17
|
+
}
|
|
18
|
+
static {
|
|
19
|
+
this.updatedAtColumn = false;
|
|
20
|
+
}
|
|
21
|
+
static {
|
|
22
|
+
this.deleteStrategy = "permanent";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region ../../packages/devtools/src/production/store/models/account.model.ts
|
|
28
|
+
/** A row of `devtools_accounts`. */
|
|
29
|
+
var DevtoolsAccountRow = class extends DevtoolsRowModel {
|
|
30
|
+
static {
|
|
31
|
+
this.table = "devtools_accounts";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../../packages/devtools/src/production/store/models/account.migration.ts
|
|
37
|
+
const DevtoolsAccountsMigration = (0, _warlock_js_cascade.migrate)(DevtoolsAccountRow, {
|
|
38
|
+
name: "devtoolsAccounts",
|
|
39
|
+
up() {
|
|
40
|
+
this.createTableIfNotExists();
|
|
41
|
+
this.string("id", 64).primary().unique();
|
|
42
|
+
this.string("email", 320).unique();
|
|
43
|
+
this.string("role", 16);
|
|
44
|
+
this.text("password_hash");
|
|
45
|
+
this.string("password_source", 32);
|
|
46
|
+
this.boolean("must_change_password").default(false);
|
|
47
|
+
this.text("totp_secret").nullable();
|
|
48
|
+
this.bigInteger("totp_enabled_at").nullable();
|
|
49
|
+
this.bigInteger("totp_last_step").nullable();
|
|
50
|
+
this.json("recovery_codes");
|
|
51
|
+
this.json("passkeys");
|
|
52
|
+
this.bigInteger("failures_reset_at").nullable();
|
|
53
|
+
this.bigInteger("created_at");
|
|
54
|
+
this.bigInteger("updated_at");
|
|
55
|
+
this.bigInteger("last_login_at").nullable();
|
|
56
|
+
this.string("created_by", 64).nullable();
|
|
57
|
+
this.integer("version").default(1);
|
|
58
|
+
},
|
|
59
|
+
down() {
|
|
60
|
+
this.dropTableIfExists();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region ../../packages/devtools/src/production/store/models/audit.model.ts
|
|
66
|
+
/** A row of `devtools_audit`. */
|
|
67
|
+
var DevtoolsAuditRow = class extends DevtoolsRowModel {
|
|
68
|
+
static {
|
|
69
|
+
this.table = "devtools_audit";
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region ../../packages/devtools/src/production/store/models/audit.migration.ts
|
|
75
|
+
const DevtoolsAuditMigration = (0, _warlock_js_cascade.migrate)(DevtoolsAuditRow, {
|
|
76
|
+
name: "devtoolsAudit",
|
|
77
|
+
up() {
|
|
78
|
+
this.createTableIfNotExists();
|
|
79
|
+
this.string("id", 64).primary().unique();
|
|
80
|
+
this.string("type", 64);
|
|
81
|
+
this.bigInteger("occurred_at").index();
|
|
82
|
+
this.string("account_id", 64).nullable();
|
|
83
|
+
this.string("email", 320).nullable();
|
|
84
|
+
this.string("ip", 64).nullable();
|
|
85
|
+
this.string("ip_bucket", 64).nullable();
|
|
86
|
+
this.string("user_agent", 255).nullable();
|
|
87
|
+
this.json("detail");
|
|
88
|
+
this.string("ref", 16);
|
|
89
|
+
this.index(["type", "occurred_at"]);
|
|
90
|
+
this.index(["ip_bucket", "occurred_at"]);
|
|
91
|
+
this.index(["account_id", "occurred_at"]);
|
|
92
|
+
},
|
|
93
|
+
down() {
|
|
94
|
+
this.dropTableIfExists();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region ../../packages/devtools/src/production/store/models/invite.model.ts
|
|
100
|
+
/** A row of `devtools_invites`. */
|
|
101
|
+
var DevtoolsInviteRow = class extends DevtoolsRowModel {
|
|
102
|
+
static {
|
|
103
|
+
this.table = "devtools_invites";
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region ../../packages/devtools/src/production/store/models/invite.migration.ts
|
|
109
|
+
const DevtoolsInvitesMigration = (0, _warlock_js_cascade.migrate)(DevtoolsInviteRow, {
|
|
110
|
+
name: "devtoolsInvites",
|
|
111
|
+
up() {
|
|
112
|
+
this.createTableIfNotExists();
|
|
113
|
+
this.string("id", 64).primary().unique();
|
|
114
|
+
this.string("token_hash", 64).unique();
|
|
115
|
+
this.string("email", 320);
|
|
116
|
+
this.string("role", 16);
|
|
117
|
+
this.string("created_by", 64).nullable();
|
|
118
|
+
this.bigInteger("created_at");
|
|
119
|
+
this.bigInteger("expires_at").index();
|
|
120
|
+
this.bigInteger("used_at").nullable();
|
|
121
|
+
this.string("account_id", 64).nullable();
|
|
122
|
+
},
|
|
123
|
+
down() {
|
|
124
|
+
this.dropTableIfExists();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region ../../packages/devtools/src/production/store/models/report.model.ts
|
|
130
|
+
/** A row of `devtools_reports`. */
|
|
131
|
+
var DevtoolsReportRow = class extends DevtoolsRowModel {
|
|
132
|
+
static {
|
|
133
|
+
this.table = "devtools_reports";
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region ../../packages/devtools/src/production/store/models/report.migration.ts
|
|
139
|
+
const DevtoolsReportsMigration = (0, _warlock_js_cascade.migrate)(DevtoolsReportRow, {
|
|
140
|
+
name: "devtoolsReports",
|
|
141
|
+
up() {
|
|
142
|
+
this.createTableIfNotExists();
|
|
143
|
+
this.string("id", 64).primary().unique();
|
|
144
|
+
this.bigInteger("seen_at").index();
|
|
145
|
+
this.longText("data");
|
|
146
|
+
},
|
|
147
|
+
down() {
|
|
148
|
+
this.dropTableIfExists();
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region ../../packages/devtools/src/production/store/models/sample.model.ts
|
|
154
|
+
/** A row of `devtools_samples`. */
|
|
155
|
+
var DevtoolsSampleRow = class extends DevtoolsRowModel {
|
|
156
|
+
static {
|
|
157
|
+
this.table = "devtools_samples";
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region ../../packages/devtools/src/production/store/models/sample.migration.ts
|
|
163
|
+
const DevtoolsSamplesMigration = (0, _warlock_js_cascade.migrate)(DevtoolsSampleRow, {
|
|
164
|
+
name: "devtoolsSamples",
|
|
165
|
+
up() {
|
|
166
|
+
this.createTableIfNotExists();
|
|
167
|
+
this.string("id", 64).primary().unique();
|
|
168
|
+
this.string("instance", 128).index();
|
|
169
|
+
this.bigInteger("started_at").index();
|
|
170
|
+
this.integer("status").nullable().index();
|
|
171
|
+
this.string("method", 16);
|
|
172
|
+
this.text("path");
|
|
173
|
+
this.json("summary");
|
|
174
|
+
this.longText("detail").nullable();
|
|
175
|
+
},
|
|
176
|
+
down() {
|
|
177
|
+
this.dropTableIfExists();
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region ../../packages/devtools/src/production/store/models/session.model.ts
|
|
183
|
+
/** A row of `devtools_sessions`. */
|
|
184
|
+
var DevtoolsSessionRow = class extends DevtoolsRowModel {
|
|
185
|
+
static {
|
|
186
|
+
this.table = "devtools_sessions";
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region ../../packages/devtools/src/production/store/models/session.migration.ts
|
|
192
|
+
const DevtoolsSessionsMigration = (0, _warlock_js_cascade.migrate)(DevtoolsSessionRow, {
|
|
193
|
+
name: "devtoolsSessions",
|
|
194
|
+
up() {
|
|
195
|
+
this.createTableIfNotExists();
|
|
196
|
+
this.string("id", 64).primary().unique();
|
|
197
|
+
this.string("token_hash", 64).unique();
|
|
198
|
+
this.string("account_id", 64).index();
|
|
199
|
+
this.string("stage", 32);
|
|
200
|
+
this.string("csrf_secret", 128);
|
|
201
|
+
this.bigInteger("created_at");
|
|
202
|
+
this.bigInteger("last_seen_at");
|
|
203
|
+
this.bigInteger("expires_at").index();
|
|
204
|
+
this.string("ip", 64).nullable();
|
|
205
|
+
this.string("user_agent", 255).nullable();
|
|
206
|
+
this.text("pending_totp_secret").nullable();
|
|
207
|
+
this.text("challenge").nullable();
|
|
208
|
+
this.bigInteger("challenge_expires_at").nullable();
|
|
209
|
+
this.integer("version").default(1);
|
|
210
|
+
},
|
|
211
|
+
down() {
|
|
212
|
+
this.dropTableIfExists();
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region ../../packages/devtools/src/production/store/models/state.model.ts
|
|
218
|
+
/** A row of `devtools_state`. */
|
|
219
|
+
var DevtoolsStateRow = class extends DevtoolsRowModel {
|
|
220
|
+
static {
|
|
221
|
+
this.table = "devtools_state";
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region ../../packages/devtools/src/production/store/models/state.migration.ts
|
|
227
|
+
const DevtoolsStateMigration = (0, _warlock_js_cascade.migrate)(DevtoolsStateRow, {
|
|
228
|
+
name: "devtoolsState",
|
|
229
|
+
up() {
|
|
230
|
+
this.createTableIfNotExists();
|
|
231
|
+
this.string("id", 64).primary().unique();
|
|
232
|
+
this.boolean("disabled").default(false);
|
|
233
|
+
this.string("disabled_path_hash", 64).nullable();
|
|
234
|
+
this.bigInteger("disabled_at").nullable();
|
|
235
|
+
this.string("disabled_by", 64).nullable();
|
|
236
|
+
this.bigInteger("locked_until").nullable();
|
|
237
|
+
this.bigInteger("failures_reset_at").nullable();
|
|
238
|
+
this.bigInteger("updated_at");
|
|
239
|
+
this.integer("version").default(0);
|
|
240
|
+
},
|
|
241
|
+
down() {
|
|
242
|
+
this.dropTableIfExists();
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region ../../packages/devtools/src/production/store/models/index.ts
|
|
248
|
+
var models_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
249
|
+
DevtoolsAccountRow: () => DevtoolsAccountRow,
|
|
250
|
+
DevtoolsAccountsMigration: () => DevtoolsAccountsMigration,
|
|
251
|
+
DevtoolsAuditMigration: () => DevtoolsAuditMigration,
|
|
252
|
+
DevtoolsAuditRow: () => DevtoolsAuditRow,
|
|
253
|
+
DevtoolsInviteRow: () => DevtoolsInviteRow,
|
|
254
|
+
DevtoolsInvitesMigration: () => DevtoolsInvitesMigration,
|
|
255
|
+
DevtoolsReportRow: () => DevtoolsReportRow,
|
|
256
|
+
DevtoolsReportsMigration: () => DevtoolsReportsMigration,
|
|
257
|
+
DevtoolsRowModel: () => DevtoolsRowModel,
|
|
258
|
+
DevtoolsSampleRow: () => DevtoolsSampleRow,
|
|
259
|
+
DevtoolsSamplesMigration: () => DevtoolsSamplesMigration,
|
|
260
|
+
DevtoolsSessionRow: () => DevtoolsSessionRow,
|
|
261
|
+
DevtoolsSessionsMigration: () => DevtoolsSessionsMigration,
|
|
262
|
+
DevtoolsStateMigration: () => DevtoolsStateMigration,
|
|
263
|
+
DevtoolsStateRow: () => DevtoolsStateRow
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region ../../packages/devtools/src/production/store/migrations.ts
|
|
268
|
+
/**
|
|
269
|
+
* The migrations of the production monitor's tables/collections:
|
|
270
|
+
* `devtools_accounts`, `devtools_sessions`, `devtools_invites`,
|
|
271
|
+
* `devtools_audit`, `devtools_state`, `devtools_samples`, `devtools_reports`.
|
|
272
|
+
* An app lists them in `warlock.config.ts > database.migrations`.
|
|
273
|
+
*/
|
|
274
|
+
const devtoolsMigrations = [
|
|
275
|
+
DevtoolsAccountsMigration,
|
|
276
|
+
DevtoolsSessionsMigration,
|
|
277
|
+
DevtoolsInvitesMigration,
|
|
278
|
+
DevtoolsAuditMigration,
|
|
279
|
+
DevtoolsStateMigration,
|
|
280
|
+
DevtoolsSamplesMigration,
|
|
281
|
+
DevtoolsReportsMigration
|
|
282
|
+
];
|
|
283
|
+
|
|
284
|
+
//#endregion
|
|
285
|
+
Object.defineProperty(exports, "devtoolsMigrations", {
|
|
286
|
+
enumerable: true,
|
|
287
|
+
get: function () {
|
|
288
|
+
return devtoolsMigrations;
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
Object.defineProperty(exports, "models_exports", {
|
|
292
|
+
enumerable: true,
|
|
293
|
+
get: function () {
|
|
294
|
+
return models_exports;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
//# sourceMappingURL=migrations-w7GMsrQw.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrations-w7GMsrQw.cjs","names":["Model","migrate","migrate","migrate","migrate","migrate","migrate","migrate"],"sources":["../../../../../../../packages/devtools/src/production/store/models/base.ts","../../../../../../../packages/devtools/src/production/store/models/account.model.ts","../../../../../../../packages/devtools/src/production/store/models/account.migration.ts","../../../../../../../packages/devtools/src/production/store/models/audit.model.ts","../../../../../../../packages/devtools/src/production/store/models/audit.migration.ts","../../../../../../../packages/devtools/src/production/store/models/invite.model.ts","../../../../../../../packages/devtools/src/production/store/models/invite.migration.ts","../../../../../../../packages/devtools/src/production/store/models/report.model.ts","../../../../../../../packages/devtools/src/production/store/models/report.migration.ts","../../../../../../../packages/devtools/src/production/store/models/sample.model.ts","../../../../../../../packages/devtools/src/production/store/models/sample.migration.ts","../../../../../../../packages/devtools/src/production/store/models/session.model.ts","../../../../../../../packages/devtools/src/production/store/models/session.migration.ts","../../../../../../../packages/devtools/src/production/store/models/state.model.ts","../../../../../../../packages/devtools/src/production/store/models/state.migration.ts","../../../../../../../packages/devtools/src/production/store/models/index.ts","../../../../../../../packages/devtools/src/production/store/migrations.ts"],"sourcesContent":["import { Model } from \"@warlock.js/cascade\";\n\n/**\n * Settings shared by the monitor's tables. Ids are supplied by the store\n * (random uuids, or `\"state\"`), times are plain epoch-millisecond columns the\n * store writes itself, and a removal is always permanent: sessions, invites\n * and samples must not be copied into a trash table.\n */\nexport abstract class DevtoolsRowModel extends Model {\n public static autoGenerateId = false;\n\n public static createdAtColumn = false as const;\n\n public static updatedAtColumn = false as const;\n\n public static deleteStrategy = \"permanent\" as const;\n}\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_accounts`. */\nexport class DevtoolsAccountRow extends DevtoolsRowModel {\n public static table = \"devtools_accounts\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsAccountRow } from \"./account.model\";\n\nexport const DevtoolsAccountsMigration = migrate(DevtoolsAccountRow, {\n name: \"devtoolsAccounts\",\n up() {\n this.createTableIfNotExists();\n\n // The id is a string the store supplies; `unique` also covers MongoDB,\n // which ignores primary keys.\n this.string(\"id\", 64).primary().unique();\n\n this.string(\"email\", 320).unique();\n this.string(\"role\", 16);\n this.text(\"password_hash\");\n this.string(\"password_source\", 32);\n this.boolean(\"must_change_password\").default(false);\n this.text(\"totp_secret\").nullable();\n this.bigInteger(\"totp_enabled_at\").nullable();\n this.bigInteger(\"totp_last_step\").nullable();\n this.json(\"recovery_codes\");\n this.json(\"passkeys\");\n this.bigInteger(\"failures_reset_at\").nullable();\n this.bigInteger(\"created_at\");\n this.bigInteger(\"updated_at\");\n this.bigInteger(\"last_login_at\").nullable();\n this.string(\"created_by\", 64).nullable();\n this.integer(\"version\").default(1);\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_audit`. */\nexport class DevtoolsAuditRow extends DevtoolsRowModel {\n public static table = \"devtools_audit\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsAuditRow } from \"./audit.model\";\n\nexport const DevtoolsAuditMigration = migrate(DevtoolsAuditRow, {\n name: \"devtoolsAudit\",\n up() {\n this.createTableIfNotExists();\n\n // The id is a string the store supplies; `unique` also covers MongoDB,\n // which ignores primary keys.\n this.string(\"id\", 64).primary().unique();\n\n this.string(\"type\", 64);\n this.bigInteger(\"occurred_at\").index();\n this.string(\"account_id\", 64).nullable();\n this.string(\"email\", 320).nullable();\n this.string(\"ip\", 64).nullable();\n // The per-IP sign-in limit counts by this: the address, or its /64 for IPv6.\n this.string(\"ip_bucket\", 64).nullable();\n this.string(\"user_agent\", 255).nullable();\n this.json(\"detail\");\n this.string(\"ref\", 16);\n\n this.index([\"type\", \"occurred_at\"]);\n this.index([\"ip_bucket\", \"occurred_at\"]);\n this.index([\"account_id\", \"occurred_at\"]);\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_invites`. */\nexport class DevtoolsInviteRow extends DevtoolsRowModel {\n public static table = \"devtools_invites\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsInviteRow } from \"./invite.model\";\n\nexport const DevtoolsInvitesMigration = migrate(DevtoolsInviteRow, {\n name: \"devtoolsInvites\",\n up() {\n this.createTableIfNotExists();\n\n // The id is a string the store supplies; `unique` also covers MongoDB,\n // which ignores primary keys.\n this.string(\"id\", 64).primary().unique();\n\n this.string(\"token_hash\", 64).unique();\n this.string(\"email\", 320);\n this.string(\"role\", 16);\n this.string(\"created_by\", 64).nullable();\n this.bigInteger(\"created_at\");\n this.bigInteger(\"expires_at\").index();\n this.bigInteger(\"used_at\").nullable();\n this.string(\"account_id\", 64).nullable();\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_reports`. */\nexport class DevtoolsReportRow extends DevtoolsRowModel {\n public static table = \"devtools_reports\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsReportRow } from \"./report.model\";\n\nexport const DevtoolsReportsMigration = migrate(DevtoolsReportRow, {\n name: \"devtoolsReports\",\n up() {\n this.createTableIfNotExists();\n\n // The id is a string the store supplies; `unique` also covers MongoDB,\n // which ignores primary keys.\n this.string(\"id\", 64).primary().unique();\n\n this.bigInteger(\"seen_at\").index();\n // JSON text, up to 256 KB.\n this.longText(\"data\");\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_samples`. */\nexport class DevtoolsSampleRow extends DevtoolsRowModel {\n public static table = \"devtools_samples\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsSampleRow } from \"./sample.model\";\n\nexport const DevtoolsSamplesMigration = migrate(DevtoolsSampleRow, {\n name: \"devtoolsSamples\",\n up() {\n this.createTableIfNotExists();\n\n // The id is a string the store supplies; `unique` also covers MongoDB,\n // which ignores primary keys.\n this.string(\"id\", 64).primary().unique();\n\n this.string(\"instance\", 128).index();\n this.bigInteger(\"started_at\").index();\n this.integer(\"status\").nullable().index();\n this.string(\"method\", 16);\n this.text(\"path\");\n this.json(\"summary\");\n // JSON text: request data may hold keys MongoDB cannot store as field names.\n this.longText(\"detail\").nullable();\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_sessions`. */\nexport class DevtoolsSessionRow extends DevtoolsRowModel {\n public static table = \"devtools_sessions\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsSessionRow } from \"./session.model\";\n\nexport const DevtoolsSessionsMigration = migrate(DevtoolsSessionRow, {\n name: \"devtoolsSessions\",\n up() {\n this.createTableIfNotExists();\n\n // The id is a string the store supplies; `unique` also covers MongoDB,\n // which ignores primary keys.\n this.string(\"id\", 64).primary().unique();\n\n this.string(\"token_hash\", 64).unique();\n this.string(\"account_id\", 64).index();\n this.string(\"stage\", 32);\n this.string(\"csrf_secret\", 128);\n this.bigInteger(\"created_at\");\n this.bigInteger(\"last_seen_at\");\n this.bigInteger(\"expires_at\").index();\n this.string(\"ip\", 64).nullable();\n this.string(\"user_agent\", 255).nullable();\n this.text(\"pending_totp_secret\").nullable();\n this.text(\"challenge\").nullable();\n this.bigInteger(\"challenge_expires_at\").nullable();\n this.integer(\"version\").default(1);\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","import { DevtoolsRowModel } from \"./base\";\n\n/** A row of `devtools_state`. */\nexport class DevtoolsStateRow extends DevtoolsRowModel {\n public static table = \"devtools_state\";\n}\n","import { migrate } from \"@warlock.js/cascade\";\nimport { DevtoolsStateRow } from \"./state.model\";\n\nexport const DevtoolsStateMigration = migrate(DevtoolsStateRow, {\n name: \"devtoolsState\",\n up() {\n this.createTableIfNotExists();\n\n // The id is a string the store supplies; `unique` also covers MongoDB,\n // which ignores primary keys.\n this.string(\"id\", 64).primary().unique();\n\n this.boolean(\"disabled\").default(false);\n this.string(\"disabled_path_hash\", 64).nullable();\n this.bigInteger(\"disabled_at\").nullable();\n this.string(\"disabled_by\", 64).nullable();\n this.bigInteger(\"locked_until\").nullable();\n this.bigInteger(\"failures_reset_at\").nullable();\n this.bigInteger(\"updated_at\");\n this.integer(\"version\").default(0);\n },\n down() {\n this.dropTableIfExists();\n },\n});\n","export { DevtoolsRowModel } from \"./base\";\nexport { DevtoolsAccountsMigration } from \"./account.migration\";\nexport { DevtoolsAccountRow } from \"./account.model\";\nexport { DevtoolsAuditMigration } from \"./audit.migration\";\nexport { DevtoolsAuditRow } from \"./audit.model\";\nexport { DevtoolsInvitesMigration } from \"./invite.migration\";\nexport { DevtoolsInviteRow } from \"./invite.model\";\nexport { DevtoolsReportsMigration } from \"./report.migration\";\nexport { DevtoolsReportRow } from \"./report.model\";\nexport { DevtoolsSamplesMigration } from \"./sample.migration\";\nexport { DevtoolsSampleRow } from \"./sample.model\";\nexport { DevtoolsSessionsMigration } from \"./session.migration\";\nexport { DevtoolsSessionRow } from \"./session.model\";\nexport { DevtoolsStateMigration } from \"./state.migration\";\nexport { DevtoolsStateRow } from \"./state.model\";\n","import type { MigrationConstructor } from \"@warlock.js/cascade\";\nimport {\n DevtoolsAccountsMigration,\n DevtoolsAuditMigration,\n DevtoolsInvitesMigration,\n DevtoolsReportsMigration,\n DevtoolsSamplesMigration,\n DevtoolsSessionsMigration,\n DevtoolsStateMigration,\n} from \"./models\";\n\n/**\n * The migrations of the production monitor's tables/collections:\n * `devtools_accounts`, `devtools_sessions`, `devtools_invites`,\n * `devtools_audit`, `devtools_state`, `devtools_samples`, `devtools_reports`.\n * An app lists them in `warlock.config.ts > database.migrations`.\n */\nexport const devtoolsMigrations: readonly MigrationConstructor[] = [\n DevtoolsAccountsMigration,\n DevtoolsSessionsMigration,\n DevtoolsInvitesMigration,\n DevtoolsAuditMigration,\n DevtoolsStateMigration,\n DevtoolsSamplesMigration,\n DevtoolsReportsMigration,\n];\n"],"mappings":";;;;;;;;;;AAQA,IAAsB,mBAAtB,cAA+CA,0BAAM;;wBACpB;;;yBAEC;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