@warlock.js/devtools 5.54.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 +36 -0
- package/README.md +26 -13
- package/cjs/{ai-source-CSPh1HqJ.cjs → ai-source-DTpxumMA.cjs} +54 -3
- package/cjs/{ai-source-CSPh1HqJ.cjs.map → ai-source-DTpxumMA.cjs.map} +1 -1
- 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-BzuntLcd.cjs → src-Ce-3Lniv.cjs} +171 -308
- 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 -12
- package/esm/devtools-connector.d.mts.map +1 -1
- package/esm/devtools-connector.mjs +137 -18
- package/esm/devtools-connector.mjs.map +1 -1
- package/esm/index.d.mts +3 -2
- package/esm/options.mjs +3 -1
- package/esm/options.mjs.map +1 -1
- package/esm/panels.mjs +267 -0
- package/esm/panels.mjs.map +1 -0
- package/esm/process-panel.mjs +20 -1
- package/esm/process-panel.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 +16 -6
- 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/panel-routes.mjs +44 -0
- package/esm/server/panel-routes.mjs.map +1 -0
- 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 -12
- 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 +271 -1
- package/esm/types.d.mts.map +1 -1
- package/esm/ui-root.mjs +11 -6
- package/esm/ui-root.mjs.map +1 -1
- package/llms-full.txt +208 -19
- package/llms.txt +2 -2
- package/package.json +32 -8
- package/skills/SKILL.md +208 -19
- 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/ui/panels/processes.js +15 -0
- package/cjs/server-BlQshJLE.cjs +0 -658
- package/cjs/server-BlQshJLE.cjs.map +0 -1
- package/cjs/src-BzuntLcd.cjs.map +0 -1
- package/esm/server/process-routes.mjs +0 -11
- package/esm/server/process-routes.mjs.map +0 -1
- package/ui/app.css +0 -376
- package/ui/app.js +0 -1054
- package/ui/index.html +0 -28
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { DevtoolsApiError } from "../production/errors.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/devtools/src/server/insights-routes.ts
|
|
4
|
+
const QUERY_SORTS = [
|
|
5
|
+
"total",
|
|
6
|
+
"p95",
|
|
7
|
+
"count",
|
|
8
|
+
"n+1"
|
|
9
|
+
];
|
|
10
|
+
const ROUTE_SORTS = [
|
|
11
|
+
"total",
|
|
12
|
+
"p95",
|
|
13
|
+
"count",
|
|
14
|
+
"errors"
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Reads `?instance=&sort=&limit=`. A sort outside `sorts` or a limit that is
|
|
18
|
+
* not a whole number from 1 to 500 answers `input.invalid`.
|
|
19
|
+
*/
|
|
20
|
+
function parseInsightQuery(query, sorts) {
|
|
21
|
+
const result = { instance: query.instance || "all" };
|
|
22
|
+
if (sorts && query.sort !== void 0 && query.sort !== "") {
|
|
23
|
+
if (!sorts.includes(query.sort)) throw new DevtoolsApiError("input.invalid");
|
|
24
|
+
result.sort = query.sort;
|
|
25
|
+
}
|
|
26
|
+
if (query.limit !== void 0 && query.limit !== "") {
|
|
27
|
+
const limit = Number(query.limit);
|
|
28
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 500) throw new DevtoolsApiError("input.invalid");
|
|
29
|
+
result.limit = limit;
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The read-only routes of the Resources, Queries (statistics), Routes
|
|
35
|
+
* (statistics), Health, Errors, Logs (production) and Jobs tabs, over
|
|
36
|
+
* `deps.insights`: `GET /api/instances`, `/api/resources`,
|
|
37
|
+
* `/api/queries/stats`, `/api/routes/stats`, `/api/health`, `/api/errors`,
|
|
38
|
+
* `/api/jobs`. Each takes `?instance=<id|all>` (default `all`). Without
|
|
39
|
+
* `deps.insights` nothing is registered.
|
|
40
|
+
*/
|
|
41
|
+
function registerInsightsRoutes(server, deps) {
|
|
42
|
+
const insights = deps.insights;
|
|
43
|
+
if (!insights) return;
|
|
44
|
+
const route = (path, sorts, read) => {
|
|
45
|
+
server.get(path, async (request, reply) => {
|
|
46
|
+
const query = parseInsightQuery(request.query, sorts);
|
|
47
|
+
reply.header("Cache-Control", "no-store");
|
|
48
|
+
return read(query);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
route("/api/instances", void 0, () => insights.instances());
|
|
52
|
+
route("/api/resources", void 0, (query) => insights.resources(query));
|
|
53
|
+
route("/api/queries/stats", QUERY_SORTS, (query) => insights.queryStats(query));
|
|
54
|
+
route("/api/routes/stats", ROUTE_SORTS, (query) => insights.routeStats(query));
|
|
55
|
+
route("/api/health", void 0, (query) => insights.health(query));
|
|
56
|
+
route("/api/errors", void 0, (query) => insights.errors(query));
|
|
57
|
+
route("/api/jobs", void 0, (query) => insights.jobs(query));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { parseInsightQuery, registerInsightsRoutes };
|
|
62
|
+
//# sourceMappingURL=insights-routes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insights-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/insights-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { DevtoolsApiError } from \"../production/errors\";\nimport type { DevtoolsInsightQuery, DevtoolsInsights } from \"../production/insights/types\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\ntype InsightsQuerystring = { instance?: string; sort?: string; limit?: string };\n\nconst QUERY_SORTS = [\"total\", \"p95\", \"count\", \"n+1\"] as const;\nconst ROUTE_SORTS = [\"total\", \"p95\", \"count\", \"errors\"] as const;\n\n/**\n * Reads `?instance=&sort=&limit=`. A sort outside `sorts` or a limit that is\n * not a whole number from 1 to 500 answers `input.invalid`.\n */\nexport function parseInsightQuery(\n query: InsightsQuerystring,\n sorts?: readonly string[],\n): DevtoolsInsightQuery {\n const result: DevtoolsInsightQuery = { instance: query.instance || \"all\" };\n\n if (sorts && query.sort !== undefined && query.sort !== \"\") {\n if (!sorts.includes(query.sort)) throw new DevtoolsApiError(\"input.invalid\");\n\n result.sort = query.sort;\n }\n\n if (query.limit !== undefined && query.limit !== \"\") {\n const limit = Number(query.limit);\n\n if (!Number.isInteger(limit) || limit < 1 || limit > 500) {\n throw new DevtoolsApiError(\"input.invalid\");\n }\n\n result.limit = limit;\n }\n\n return result;\n}\n\n/**\n * The read-only routes of the Resources, Queries (statistics), Routes\n * (statistics), Health, Errors, Logs (production) and Jobs tabs, over\n * `deps.insights`: `GET /api/instances`, `/api/resources`,\n * `/api/queries/stats`, `/api/routes/stats`, `/api/health`, `/api/errors`,\n * `/api/jobs`. Each takes `?instance=<id|all>` (default `all`). Without\n * `deps.insights` nothing is registered.\n */\nexport function registerInsightsRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n const insights: DevtoolsInsights | undefined = deps.insights;\n\n if (!insights) return;\n\n const route = (\n path: string,\n sorts: readonly string[] | undefined,\n read: (query: DevtoolsInsightQuery) => Promise<unknown>,\n ): void => {\n server.get<{ Querystring: InsightsQuerystring }>(path, async (request, reply) => {\n const query = parseInsightQuery(request.query, sorts);\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return read(query);\n });\n };\n\n route(\"/api/instances\", undefined, () => insights.instances());\n route(\"/api/resources\", undefined, (query) => insights.resources(query));\n route(\"/api/queries/stats\", QUERY_SORTS, (query) => insights.queryStats(query));\n route(\"/api/routes/stats\", ROUTE_SORTS, (query) => insights.routeStats(query));\n route(\"/api/health\", undefined, (query) => insights.health(query));\n route(\"/api/errors\", undefined, (query) => insights.errors(query));\n route(\"/api/jobs\", undefined, (query) => insights.jobs(query));\n}\n"],"mappings":";;;AAOA,MAAM,cAAc;CAAC;CAAS;CAAO;CAAS;AAAK;AACnD,MAAM,cAAc;CAAC;CAAS;CAAO;CAAS;AAAQ;;;;;AAMtD,SAAgB,kBACd,OACA,OACsB;CACtB,MAAM,SAA+B,EAAE,UAAU,MAAM,YAAY,MAAM;CAEzE,IAAI,SAAS,MAAM,SAAS,UAAa,MAAM,SAAS,IAAI;EAC1D,IAAI,CAAC,MAAM,SAAS,MAAM,IAAI,GAAG,MAAM,IAAI,iBAAiB,eAAe;EAE3E,OAAO,OAAO,MAAM;CACtB;CAEA,IAAI,MAAM,UAAU,UAAa,MAAM,UAAU,IAAI;EACnD,MAAM,QAAQ,OAAO,MAAM,KAAK;EAEhC,IAAI,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,KAAK,QAAQ,KACnD,MAAM,IAAI,iBAAiB,eAAe;EAG5C,OAAO,QAAQ;CACjB;CAEA,OAAO;AACT;;;;;;;;;AAUA,SAAgB,uBACd,QACA,MACM;CACN,MAAM,WAAyC,KAAK;CAEpD,IAAI,CAAC,UAAU;CAEf,MAAM,SACJ,MACA,OACA,SACS;EACT,OAAO,IAA0C,MAAM,OAAO,SAAS,UAAU;GAC/E,MAAM,QAAQ,kBAAkB,QAAQ,OAAO,KAAK;GAEpD,MAAM,OAAO,iBAAiB,UAAU;GAExC,OAAO,KAAK,KAAK;EACnB,CAAC;CACH;CAEA,MAAM,kBAAkB,cAAiB,SAAS,UAAU,CAAC;CAC7D,MAAM,kBAAkB,SAAY,UAAU,SAAS,UAAU,KAAK,CAAC;CACvE,MAAM,sBAAsB,cAAc,UAAU,SAAS,WAAW,KAAK,CAAC;CAC9E,MAAM,qBAAqB,cAAc,UAAU,SAAS,WAAW,KAAK,CAAC;CAC7E,MAAM,eAAe,SAAY,UAAU,SAAS,OAAO,KAAK,CAAC;CACjE,MAAM,eAAe,SAAY,UAAU,SAAS,OAAO,KAAK,CAAC;CACjE,MAAM,aAAa,SAAY,UAAU,SAAS,KAAK,KAAK,CAAC;AAC/D"}
|
|
@@ -1,10 +1,37 @@
|
|
|
1
|
+
import { parseInsightQuery } from "./insights-routes.mjs";
|
|
2
|
+
|
|
1
3
|
//#region ../../packages/devtools/src/server/log-routes.ts
|
|
2
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Registers the log listing route, filterable by `level` and `module`. In
|
|
6
|
+
* production it answers from the insights (every instance, no `context`);
|
|
7
|
+
* in development it answers from the collector's logs, which keep `context`.
|
|
8
|
+
*/
|
|
3
9
|
function registerLogRoutes(server, deps) {
|
|
4
|
-
server.get("/api/logs", async (request) =>
|
|
5
|
-
level
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
server.get("/api/logs", async (request, reply) => {
|
|
11
|
+
const { level, module } = request.query;
|
|
12
|
+
if (deps.mode === "production" && deps.insights) {
|
|
13
|
+
const query = parseInsightQuery(request.query);
|
|
14
|
+
reply.header("Cache-Control", "no-store");
|
|
15
|
+
return deps.insights.logs({
|
|
16
|
+
...query,
|
|
17
|
+
...level ? { level } : {},
|
|
18
|
+
...module ? { module } : {}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return deps.collector.listLogs({
|
|
22
|
+
level,
|
|
23
|
+
module
|
|
24
|
+
}).map((entry) => ({
|
|
25
|
+
level: entry.level,
|
|
26
|
+
module: entry.module,
|
|
27
|
+
action: entry.action,
|
|
28
|
+
message: entry.message,
|
|
29
|
+
at: entry.at,
|
|
30
|
+
requestId: null,
|
|
31
|
+
instance: null,
|
|
32
|
+
context: entry.context
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
8
35
|
}
|
|
9
36
|
|
|
10
37
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/log-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport type { DevtoolsLogEntry } from \"../types\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\ntype LogsQuery = {
|
|
1
|
+
{"version":3,"file":"log-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/log-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport type { DevtoolsLogRow } from \"../production/contracts\";\nimport type { DevtoolsLogEntry } from \"../types\";\nimport { parseInsightQuery } from \"./insights-routes\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\ntype LogsQuery = {\n level?: DevtoolsLogEntry[\"level\"];\n module?: string;\n instance?: string;\n limit?: string;\n};\n\n/**\n * Registers the log listing route, filterable by `level` and `module`. In\n * production it answers from the insights (every instance, no `context`);\n * in development it answers from the collector's logs, which keep `context`.\n */\nexport function registerLogRoutes(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get<{ Querystring: LogsQuery }>(\"/api/logs\", async (request, reply) => {\n const { level, module } = request.query;\n\n if (deps.mode === \"production\" && deps.insights) {\n const query = parseInsightQuery(request.query);\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.insights.logs({\n ...query,\n ...(level ? { level } : {}),\n ...(module ? { module } : {}),\n });\n }\n\n const rows: DevtoolsLogRow[] = deps.collector.listLogs({ level, module }).map((entry) => ({\n level: entry.level,\n module: entry.module,\n action: entry.action,\n message: entry.message,\n at: entry.at,\n requestId: null,\n instance: null,\n context: entry.context,\n }));\n\n return rows;\n });\n}\n"],"mappings":";;;;;;;;AAkBA,SAAgB,kBAAkB,QAAyB,MAAqC;CAC9F,OAAO,IAAgC,aAAa,OAAO,SAAS,UAAU;EAC5E,MAAM,EAAE,OAAO,WAAW,QAAQ;EAElC,IAAI,KAAK,SAAS,gBAAgB,KAAK,UAAU;GAC/C,MAAM,QAAQ,kBAAkB,QAAQ,KAAK;GAE7C,MAAM,OAAO,iBAAiB,UAAU;GAExC,OAAO,KAAK,SAAS,KAAK;IACxB,GAAG;IACH,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;IACzB,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;GAC7B,CAAC;EACH;EAaA,OAX+B,KAAK,UAAU,SAAS;GAAE;GAAO;EAAO,CAAC,CAAC,CAAC,KAAK,WAAW;GACxF,OAAO,MAAM;GACb,QAAQ,MAAM;GACd,QAAQ,MAAM;GACd,SAAS,MAAM;GACf,IAAI,MAAM;GACV,WAAW;GACX,UAAU;GACV,SAAS,MAAM;EACjB,EAEU;CACZ,CAAC;AACH"}
|
|
@@ -23,11 +23,12 @@ function registerOpenApiRoutes(server, deps) {
|
|
|
23
23
|
reply.header("Cache-Control", "no-store");
|
|
24
24
|
return deps.getPostmanCollection();
|
|
25
25
|
});
|
|
26
|
+
const frameable = (reply) => reply.header("X-Frame-Options", "SAMEORIGIN").header("Content-Security-Policy", "frame-ancestors 'self'");
|
|
26
27
|
server.get("/docs", (_request, reply) => {
|
|
27
|
-
sendFile(reply, path.join(resolveUiRoot(), "docs.html"), "text/html; charset=utf-8");
|
|
28
|
+
sendFile(frameable(reply), path.join(resolveUiRoot(), "docs.html"), "text/html; charset=utf-8");
|
|
28
29
|
});
|
|
29
30
|
server.get("/docs/swagger", (_request, reply) => {
|
|
30
|
-
sendFile(reply, path.join(resolveUiRoot(), "docs-swagger.html"), "text/html; charset=utf-8");
|
|
31
|
+
sendFile(frameable(reply), path.join(resolveUiRoot(), "docs-swagger.html"), "text/html; charset=utf-8");
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/openapi-routes.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { FastifyInstance } from \"fastify\";\nimport { resolveUiRoot } from \"../ui-root\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\nimport { sendFile } from \"./ui-assets\";\n\n/**\n * Registers the API docs: `GET /api/openapi.json` returns the document core\n * builds from the registered routes (`deps.getOpenApiDocument`), and\n * `GET /docs` serves the page that renders it with Scalar and\n * `GET /docs/swagger` the same document in Swagger UI;\n * `GET /api/postman.json` returns the Postman collection core builds\n * (`deps.getPostmanCollection`). The pages use relative URLs, so it works under whatever base path the dashboard is\n * mounted on.\n */\nexport function registerOpenApiRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n server.get(\"/api/openapi.json\", async (_request, reply) => {\n if (!deps.getOpenApiDocument) {\n return reply.code(503).header(\"Cache-Control\", \"no-store\").send({\n error: \"The OpenAPI document is not available: the host did not provide a generator.\",\n });\n }\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.getOpenApiDocument();\n });\n\n server.get(\"/api/postman.json\", async (_request, reply) => {\n if (!deps.getPostmanCollection) {\n return reply.code(503).header(\"Cache-Control\", \"no-store\").send({\n error: \"The Postman collection is not available: the host did not provide a generator.\",\n });\n }\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.getPostmanCollection();\n });\n\n server.get(\"/docs\", (_request, reply) => {\n sendFile(reply, path.join(resolveUiRoot(), \"docs.html\"), \"text/html; charset=utf-8\");\n });\n\n server.get(\"/docs/swagger\", (_request, reply) => {\n sendFile(reply
|
|
1
|
+
{"version":3,"file":"openapi-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/openapi-routes.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { FastifyInstance, FastifyReply } from \"fastify\";\nimport { resolveUiRoot } from \"../ui-root\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\nimport { sendFile } from \"./ui-assets\";\n\n/**\n * Registers the API docs: `GET /api/openapi.json` returns the document core\n * builds from the registered routes (`deps.getOpenApiDocument`), and\n * `GET /docs` serves the page that renders it with Scalar and\n * `GET /docs/swagger` the same document in Swagger UI;\n * `GET /api/postman.json` returns the Postman collection core builds\n * (`deps.getPostmanCollection`). The pages use relative URLs, so it works under whatever base path the dashboard is\n * mounted on.\n */\nexport function registerOpenApiRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n server.get(\"/api/openapi.json\", async (_request, reply) => {\n if (!deps.getOpenApiDocument) {\n return reply.code(503).header(\"Cache-Control\", \"no-store\").send({\n error: \"The OpenAPI document is not available: the host did not provide a generator.\",\n });\n }\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.getOpenApiDocument();\n });\n\n server.get(\"/api/postman.json\", async (_request, reply) => {\n if (!deps.getPostmanCollection) {\n return reply.code(503).header(\"Cache-Control\", \"no-store\").send({\n error: \"The Postman collection is not available: the host did not provide a generator.\",\n });\n }\n\n reply.header(\"Cache-Control\", \"no-store\");\n\n return deps.getPostmanCollection();\n });\n\n // The API tab shows these pages in a frame. The app's own headers (core's security headers forbid framing) are\n // replaced on the reply; production sets its full docs policy on top.\n const frameable = (reply: FastifyReply): FastifyReply =>\n reply\n .header(\"X-Frame-Options\", \"SAMEORIGIN\")\n .header(\"Content-Security-Policy\", \"frame-ancestors 'self'\");\n\n server.get(\"/docs\", (_request, reply) => {\n sendFile(frameable(reply), path.join(resolveUiRoot(), \"docs.html\"), \"text/html; charset=utf-8\");\n });\n\n server.get(\"/docs/swagger\", (_request, reply) => {\n sendFile(\n frameable(reply),\n path.join(resolveUiRoot(), \"docs-swagger.html\"),\n \"text/html; charset=utf-8\",\n );\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,sBACd,QACA,MACM;CACN,OAAO,IAAI,qBAAqB,OAAO,UAAU,UAAU;EACzD,IAAI,CAAC,KAAK,oBACR,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,iBAAiB,UAAU,CAAC,CAAC,KAAK,EAC9D,OAAO,+EACT,CAAC;EAGH,MAAM,OAAO,iBAAiB,UAAU;EAExC,OAAO,KAAK,mBAAmB;CACjC,CAAC;CAED,OAAO,IAAI,qBAAqB,OAAO,UAAU,UAAU;EACzD,IAAI,CAAC,KAAK,sBACR,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,iBAAiB,UAAU,CAAC,CAAC,KAAK,EAC9D,OAAO,iFACT,CAAC;EAGH,MAAM,OAAO,iBAAiB,UAAU;EAExC,OAAO,KAAK,qBAAqB;CACnC,CAAC;CAID,MAAM,aAAa,UACjB,MACG,OAAO,mBAAmB,YAAY,CAAC,CACvC,OAAO,2BAA2B,wBAAwB;CAE/D,OAAO,IAAI,UAAU,UAAU,UAAU;EACvC,SAAS,UAAU,KAAK,GAAG,KAAK,KAAK,cAAc,GAAG,WAAW,GAAG,0BAA0B;CAChG,CAAC;CAED,OAAO,IAAI,kBAAkB,UAAU,UAAU;EAC/C,SACE,UAAU,KAAK,GACf,KAAK,KAAK,cAAc,GAAG,mBAAmB,GAC9C,0BACF;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { panelContentType } from "../panels.mjs";
|
|
2
|
+
import { sendFile } from "./ui-assets.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../packages/devtools/src/server/panel-routes.ts
|
|
5
|
+
/**
|
|
6
|
+
* Mounts each panel's data routes at `/api/<id><route path>` and its view
|
|
7
|
+
* module and assets at `/panels/<id>/<name>`. Callers register this inside
|
|
8
|
+
* the devtools scope, so the guard covers every one of them. A file is
|
|
9
|
+
* served only when its name is listed by the panel; the request never
|
|
10
|
+
* becomes a filesystem path.
|
|
11
|
+
*/
|
|
12
|
+
function registerPanelRoutes(server, panels) {
|
|
13
|
+
const byId = new Map(panels.map((panel) => [panel.id, panel]));
|
|
14
|
+
for (const panel of panels) for (const route of panel.routes) server.route({
|
|
15
|
+
method: route.method,
|
|
16
|
+
url: `/api/${panel.id}${route.path}`,
|
|
17
|
+
handler: async (request, reply) => {
|
|
18
|
+
const input = {
|
|
19
|
+
params: request.params ?? {},
|
|
20
|
+
query: request.query ?? {},
|
|
21
|
+
body: request.body
|
|
22
|
+
};
|
|
23
|
+
const result = await route.handler(input);
|
|
24
|
+
reply.header("cache-control", "no-store");
|
|
25
|
+
if (result === void 0) return reply.code(204).send();
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
server.get("/panels/:id/:name", (request, reply) => {
|
|
30
|
+
const panel = byId.get(request.params.id);
|
|
31
|
+
const name = request.params.name;
|
|
32
|
+
const file = panel === void 0 ? void 0 : name === "view.js" ? panel.view : Object.hasOwn(panel.assets, name) ? panel.assets[name] : void 0;
|
|
33
|
+
if (file === void 0) {
|
|
34
|
+
reply.code(404).header("Cache-Control", "no-store").send();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
reply.header("X-Content-Type-Options", "nosniff");
|
|
38
|
+
sendFile(reply, file, panelContentType(name));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { registerPanelRoutes };
|
|
44
|
+
//# sourceMappingURL=panel-routes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/panel-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { type MountedDevtoolsPanel, panelContentType } from \"../panels\";\nimport type { DevtoolsPanelRequest } from \"../types\";\nimport { sendFile } from \"./ui-assets\";\n\n/**\n * Mounts each panel's data routes at `/api/<id><route path>` and its view\n * module and assets at `/panels/<id>/<name>`. Callers register this inside\n * the devtools scope, so the guard covers every one of them. A file is\n * served only when its name is listed by the panel; the request never\n * becomes a filesystem path.\n */\nexport function registerPanelRoutes(\n server: FastifyInstance,\n panels: readonly MountedDevtoolsPanel[],\n): void {\n const byId = new Map(panels.map((panel) => [panel.id, panel]));\n\n for (const panel of panels) {\n for (const route of panel.routes) {\n server.route({\n method: route.method,\n url: `/api/${panel.id}${route.path}`,\n handler: async (request, reply) => {\n const input: DevtoolsPanelRequest = {\n params: (request.params ?? {}) as Record<string, string>,\n query: (request.query ?? {}) as Record<string, string | string[]>,\n body: request.body,\n };\n const result = await route.handler(input);\n\n reply.header(\"cache-control\", \"no-store\");\n\n if (result === undefined) return reply.code(204).send();\n\n return result;\n },\n });\n }\n }\n\n server.get<{ Params: { id: string; name: string } }>(\"/panels/:id/:name\", (request, reply) => {\n const panel = byId.get(request.params.id);\n const name = request.params.name;\n const file =\n panel === undefined\n ? undefined\n : name === \"view.js\"\n ? panel.view\n : Object.hasOwn(panel.assets, name)\n ? panel.assets[name]\n : undefined;\n\n if (file === undefined) {\n reply.code(404).header(\"Cache-Control\", \"no-store\").send();\n return;\n }\n\n reply.header(\"X-Content-Type-Options\", \"nosniff\");\n sendFile(reply, file, panelContentType(name));\n });\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,oBACd,QACA,QACM;CACN,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC;CAE7D,KAAK,MAAM,SAAS,QAClB,KAAK,MAAM,SAAS,MAAM,QACxB,OAAO,MAAM;EACX,QAAQ,MAAM;EACd,KAAK,QAAQ,MAAM,KAAK,MAAM;EAC9B,SAAS,OAAO,SAAS,UAAU;GACjC,MAAM,QAA8B;IAClC,QAAS,QAAQ,UAAU,CAAC;IAC5B,OAAQ,QAAQ,SAAS,CAAC;IAC1B,MAAM,QAAQ;GAChB;GACA,MAAM,SAAS,MAAM,MAAM,QAAQ,KAAK;GAExC,MAAM,OAAO,iBAAiB,UAAU;GAExC,IAAI,WAAW,QAAW,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;GAEtD,OAAO;EACT;CACF,CAAC;CAIL,OAAO,IAA8C,sBAAsB,SAAS,UAAU;EAC5F,MAAM,QAAQ,KAAK,IAAI,QAAQ,OAAO,EAAE;EACxC,MAAM,OAAO,QAAQ,OAAO;EAC5B,MAAM,OACJ,UAAU,SACN,SACA,SAAS,YACP,MAAM,OACN,OAAO,OAAO,MAAM,QAAQ,IAAI,IAC9B,MAAM,OAAO,QACb;EAEV,IAAI,SAAS,QAAW;GACtB,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,iBAAiB,UAAU,CAAC,CAAC,KAAK;GACzD;EACF;EAEA,MAAM,OAAO,0BAA0B,SAAS;EAChD,SAAS,OAAO,MAAM,iBAAiB,IAAI,CAAC;CAC9C,CAAC;AACH"}
|
|
@@ -1,6 +1,127 @@
|
|
|
1
|
+
import { DevtoolsApiError } from "../production/errors.mjs";
|
|
1
2
|
import { filterFromQuery, hasFilter, mergeRequestHistory, recordToDetail, summaryToRow } from "../request-history.mjs";
|
|
2
3
|
|
|
3
4
|
//#region ../../packages/devtools/src/server/requests-routes.ts
|
|
5
|
+
const STATUS_FILTER = /^(?:[1-5]\d\d|[1-5]xx)$/i;
|
|
6
|
+
const METHOD_FILTER = /^[A-Za-z]{1,16}$/;
|
|
7
|
+
const RELATIVE_SINCE = /^(\d+)(s|m|h|d)$/;
|
|
8
|
+
const UNIT_MS = {
|
|
9
|
+
s: 1e3,
|
|
10
|
+
m: 6e4,
|
|
11
|
+
h: 36e5,
|
|
12
|
+
d: 864e5
|
|
13
|
+
};
|
|
14
|
+
const DEFAULT_SAMPLE_LIMIT = 200;
|
|
15
|
+
const MAX_SAMPLE_LIMIT = 1e3;
|
|
16
|
+
/** A time bound as epoch ms: a number, an ISO date, or (for `since`) a duration back such as `15m`. */
|
|
17
|
+
function parseTimeBound(value, allowRelative) {
|
|
18
|
+
if (/^\d+$/.test(value)) return Number(value);
|
|
19
|
+
const relative = allowRelative ? RELATIVE_SINCE.exec(value) : null;
|
|
20
|
+
if (relative) return Date.now() - Number(relative[1]) * UNIT_MS[relative[2]];
|
|
21
|
+
const parsed = Date.parse(value);
|
|
22
|
+
if (Number.isNaN(parsed)) throw new DevtoolsApiError("request.invalid-filter");
|
|
23
|
+
return parsed;
|
|
24
|
+
}
|
|
25
|
+
/** The stored-sample filter in a `GET /api/requests` query string; throws `request.invalid-filter`. */
|
|
26
|
+
function sampleFilterFromQuery(query, filter, fallbackLimit) {
|
|
27
|
+
const result = { limit: Math.min(MAX_SAMPLE_LIMIT, filter.limit ?? fallbackLimit) };
|
|
28
|
+
if (filter.status !== void 0) {
|
|
29
|
+
const status = String(filter.status);
|
|
30
|
+
if (!STATUS_FILTER.test(status)) throw new DevtoolsApiError("request.invalid-filter");
|
|
31
|
+
result.status = status.toLowerCase();
|
|
32
|
+
}
|
|
33
|
+
if (filter.method !== void 0) {
|
|
34
|
+
if (!METHOD_FILTER.test(String(filter.method))) throw new DevtoolsApiError("request.invalid-filter");
|
|
35
|
+
result.method = String(filter.method);
|
|
36
|
+
}
|
|
37
|
+
if (filter.route !== void 0) result.route = String(filter.route);
|
|
38
|
+
if (filter.q !== void 0) result.q = String(filter.q);
|
|
39
|
+
if (filter.since !== void 0) result.since = parseTimeBound(String(filter.since), true);
|
|
40
|
+
if (filter.until !== void 0) result.until = parseTimeBound(String(filter.until), false);
|
|
41
|
+
const instance = query.instance;
|
|
42
|
+
if (typeof instance === "string" && instance.trim() !== "" && instance !== "all") result.instance = instance.trim();
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
function sendApiError(reply, error) {
|
|
46
|
+
reply.code(error.statusCode).send(error.toBody());
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Production: the same four routes over the request source (stored samples
|
|
50
|
+
* and this process's memory), merged with the persisted request log the way
|
|
51
|
+
* development merges it with the ring buffer.
|
|
52
|
+
*/
|
|
53
|
+
function registerProductionRequestsRoutes(server, deps) {
|
|
54
|
+
const source = deps.requests;
|
|
55
|
+
if (!source) return;
|
|
56
|
+
server.get("/api/requests", async (request, reply) => {
|
|
57
|
+
const { requestLog, options } = deps;
|
|
58
|
+
try {
|
|
59
|
+
const filter = filterFromQuery(request.query);
|
|
60
|
+
const sampleFilter = sampleFilterFromQuery(request.query, filter, DEFAULT_SAMPLE_LIMIT);
|
|
61
|
+
const limit = Math.min(MAX_SAMPLE_LIMIT, filter.limit ?? options.maxRequests);
|
|
62
|
+
let persisted = [];
|
|
63
|
+
if (requestLog) try {
|
|
64
|
+
requestLog.compile(filter);
|
|
65
|
+
persisted = await requestLog.list({
|
|
66
|
+
...filter,
|
|
67
|
+
limit
|
|
68
|
+
});
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error instanceof Error && /^Invalid /.test(error.message)) throw new DevtoolsApiError("request.invalid-filter");
|
|
71
|
+
}
|
|
72
|
+
const samples = await source.list({
|
|
73
|
+
...sampleFilter,
|
|
74
|
+
limit
|
|
75
|
+
});
|
|
76
|
+
return mergeRequestHistory(samples, persisted, limit);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error instanceof DevtoolsApiError) {
|
|
79
|
+
sendApiError(reply, error);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
server.get("/api/requests/:id", async (request, reply) => {
|
|
86
|
+
const { id } = request.params;
|
|
87
|
+
const persisted = await deps.requestLog?.get(id).catch(() => void 0);
|
|
88
|
+
const found = await source.get(id);
|
|
89
|
+
if (found) {
|
|
90
|
+
if ("phases" in found) return persisted ? {
|
|
91
|
+
...found,
|
|
92
|
+
record: persisted
|
|
93
|
+
} : found;
|
|
94
|
+
if (persisted) return {
|
|
95
|
+
...recordToDetail(persisted),
|
|
96
|
+
...found.instance === void 0 ? {} : { instance: found.instance },
|
|
97
|
+
partial: true
|
|
98
|
+
};
|
|
99
|
+
return found;
|
|
100
|
+
}
|
|
101
|
+
if (!persisted) {
|
|
102
|
+
sendApiError(reply, new DevtoolsApiError("request.not-found"));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
return recordToDetail(persisted);
|
|
106
|
+
});
|
|
107
|
+
server.get("/api/requests/:id/curl", async (request, reply) => {
|
|
108
|
+
const { id } = request.params;
|
|
109
|
+
const baseUrl = `${request.protocol}://${request.headers.host ?? "localhost"}`;
|
|
110
|
+
const persisted = await deps.requestLog?.get(id).catch(() => void 0);
|
|
111
|
+
if (persisted && deps.requestLog) return { curl: deps.requestLog.curl(persisted, baseUrl) };
|
|
112
|
+
const found = await source.get(id);
|
|
113
|
+
if (!found) {
|
|
114
|
+
sendApiError(reply, new DevtoolsApiError("request.not-found"));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
return { curl: `curl -X ${found.method} '${baseUrl}${found.path.replace(/'/g, `'\\''`)}'` };
|
|
118
|
+
});
|
|
119
|
+
server.delete("/api/requests", async (_request, reply) => {
|
|
120
|
+
await source.clear();
|
|
121
|
+
deps.collector.clear();
|
|
122
|
+
reply.code(204).send();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
4
125
|
/**
|
|
5
126
|
* Registers the request list, single-request detail, "copy as curl", and
|
|
6
127
|
* clear routes.
|
|
@@ -11,6 +132,10 @@ import { filterFromQuery, hasFilter, mergeRequestHistory, recordToDetail, summar
|
|
|
11
132
|
* and `limit` query parameters.
|
|
12
133
|
*/
|
|
13
134
|
function registerRequestsRoutes(server, deps) {
|
|
135
|
+
if (deps.requests) {
|
|
136
|
+
registerProductionRequestsRoutes(server, deps);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
14
139
|
server.get("/api/requests", async (request, reply) => {
|
|
15
140
|
const { requestLog, collector, options } = deps;
|
|
16
141
|
if (!requestLog) return collector.listRequests();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/requests-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport {\n filterFromQuery,\n hasFilter,\n mergeRequestHistory,\n recordToDetail,\n summaryToRow,\n} from \"../request-history\";\nimport type { DevtoolsRequestDetail } from \"../types\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/**\n * Registers the request list, single-request detail, \"copy as curl\", and\n * clear routes.\n *\n * With core's persistent request log available, the list and the detail also\n * read the JSON-lines history, so requests survive a restart. The list\n * accepts `status` (404 or 5xx), `route`, `method`, `since`, `until`, `q`\n * and `limit` query parameters.\n */\nexport function registerRequestsRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n server.get<{ Querystring: Record<string, unknown> }>(\"/api/requests\", async (request, reply) => {\n const { requestLog, collector, options } = deps;\n\n if (!requestLog) return collector.listRequests();\n\n try {\n const filter = filterFromQuery(request.query);\n const matches = requestLog.compile(filter);\n const live = hasFilter(filter)\n ? collector.listRequests().filter((summary) => matches(summaryToRow(summary)))\n : collector.listRequests();\n const limit = filter.limit ?? options.maxRequests;\n const persisted = await requestLog.list({ ...filter, limit });\n\n return mergeRequestHistory(live, persisted, limit);\n } catch (error) {\n // A bad filter value is the caller's mistake; a read failure leaves the live list.\n if (error instanceof Error && /^Invalid /.test(error.message)) {\n reply.code(400).send({ error: error.message });\n return;\n }\n\n return collector.listRequests();\n }\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id\", async (request, reply) => {\n const { id } = request.params;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n const found = deps.collector.getRequest(id);\n\n if (found) {\n const detail: DevtoolsRequestDetail = persisted ? { ...found, record: persisted } : found;\n\n return detail;\n }\n\n if (!persisted) {\n reply.code(404).send();\n return;\n }\n\n return recordToDetail(persisted);\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id/curl\", async (request, reply) => {\n const { id } = request.params;\n const baseUrl = `${request.protocol}://${request.headers.host ?? \"localhost\"}`;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n\n if (persisted && deps.requestLog) return { curl: deps.requestLog.curl(persisted, baseUrl) };\n\n // Without a persisted record only the method and path are known.\n const live = deps.collector.getRequest(id);\n\n if (!live) {\n reply.code(404).send();\n return;\n }\n\n return { curl: `curl -X ${live.method} '${baseUrl}${live.path.replace(/'/g, `'\\\\''`)}'` };\n });\n\n server.delete(\"/api/requests\", async (_request, reply) => {\n deps.collector.clear();\n if (deps.ai?.available) deps.ai.store.clear();\n reply.code(204).send();\n });\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,SAAgB,uBACd,QACA,MACM;CACN,OAAO,IAA8C,iBAAiB,OAAO,SAAS,UAAU;EAC9F,MAAM,EAAE,YAAY,WAAW,YAAY;EAE3C,IAAI,CAAC,YAAY,OAAO,UAAU,aAAa;EAE/C,IAAI;GACF,MAAM,SAAS,gBAAgB,QAAQ,KAAK;GAC5C,MAAM,UAAU,WAAW,QAAQ,MAAM;GACzC,MAAM,OAAO,UAAU,MAAM,IACzB,UAAU,aAAa,CAAC,CAAC,QAAQ,YAAY,QAAQ,aAAa,OAAO,C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KAAK,QAAQ,MAAM,OAAO,EAAE,GAAG;CAC1F,CAAC;CAED,OAAO,OAAO,iBAAiB,OAAO,UAAU,UAAU;EACxD,KAAK,UAAU,MAAM;EACrB,IAAI,KAAK,IAAI,WAAW,KAAK,GAAG,MAAM,MAAM;EAC5C,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;CACvB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"requests-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/requests-routes.ts"],"sourcesContent":["import type { RequestLogFilter } from \"@warlock.js/core\";\nimport type { FastifyInstance, FastifyReply } from \"fastify\";\nimport { DevtoolsApiError } from \"../production/errors\";\nimport type { DevtoolsSampleFilter } from \"../production/store/types\";\nimport {\n filterFromQuery,\n hasFilter,\n mergeRequestHistory,\n recordToDetail,\n summaryToRow,\n} from \"../request-history\";\nimport type { DevtoolsRequestDetail } from \"../types\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\nconst STATUS_FILTER = /^(?:[1-5]\\d\\d|[1-5]xx)$/i;\nconst METHOD_FILTER = /^[A-Za-z]{1,16}$/;\nconst RELATIVE_SINCE = /^(\\d+)(s|m|h|d)$/;\nconst UNIT_MS = { s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000 } as const;\nconst DEFAULT_SAMPLE_LIMIT = 200;\nconst MAX_SAMPLE_LIMIT = 1000;\n\n/** A time bound as epoch ms: a number, an ISO date, or (for `since`) a duration back such as `15m`. */\nfunction parseTimeBound(value: string, allowRelative: boolean): number {\n if (/^\\d+$/.test(value)) return Number(value);\n\n const relative = allowRelative ? RELATIVE_SINCE.exec(value) : null;\n\n if (relative) {\n return Date.now() - Number(relative[1]) * UNIT_MS[relative[2] as keyof typeof UNIT_MS];\n }\n\n const parsed = Date.parse(value);\n\n if (Number.isNaN(parsed)) throw new DevtoolsApiError(\"request.invalid-filter\");\n\n return parsed;\n}\n\n/** The stored-sample filter in a `GET /api/requests` query string; throws `request.invalid-filter`. */\nfunction sampleFilterFromQuery(\n query: Record<string, unknown>,\n filter: RequestLogFilter,\n fallbackLimit: number,\n): DevtoolsSampleFilter {\n const result: DevtoolsSampleFilter = {\n limit: Math.min(MAX_SAMPLE_LIMIT, filter.limit ?? fallbackLimit),\n };\n\n if (filter.status !== undefined) {\n const status = String(filter.status);\n\n if (!STATUS_FILTER.test(status)) throw new DevtoolsApiError(\"request.invalid-filter\");\n\n result.status = status.toLowerCase();\n }\n\n if (filter.method !== undefined) {\n if (!METHOD_FILTER.test(String(filter.method))) {\n throw new DevtoolsApiError(\"request.invalid-filter\");\n }\n\n result.method = String(filter.method);\n }\n\n if (filter.route !== undefined) result.route = String(filter.route);\n if (filter.q !== undefined) result.q = String(filter.q);\n if (filter.since !== undefined) result.since = parseTimeBound(String(filter.since), true);\n if (filter.until !== undefined) result.until = parseTimeBound(String(filter.until), false);\n\n const instance = query.instance;\n\n if (typeof instance === \"string\" && instance.trim() !== \"\" && instance !== \"all\") {\n result.instance = instance.trim();\n }\n\n return result;\n}\n\nfunction sendApiError(reply: FastifyReply, error: DevtoolsApiError): void {\n reply.code(error.statusCode).send(error.toBody());\n}\n\n/**\n * Production: the same four routes over the request source (stored samples\n * and this process's memory), merged with the persisted request log the way\n * development merges it with the ring buffer.\n */\nfunction registerProductionRequestsRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n const source = deps.requests;\n\n if (!source) return;\n\n server.get<{ Querystring: Record<string, unknown> }>(\"/api/requests\", async (request, reply) => {\n const { requestLog, options } = deps;\n\n try {\n const filter = filterFromQuery(request.query);\n const sampleFilter = sampleFilterFromQuery(request.query, filter, DEFAULT_SAMPLE_LIMIT);\n const limit = Math.min(MAX_SAMPLE_LIMIT, filter.limit ?? options.maxRequests);\n let persisted: Awaited<ReturnType<NonNullable<typeof requestLog>[\"list\"]>> = [];\n\n if (requestLog) {\n try {\n requestLog.compile(filter);\n persisted = await requestLog.list({ ...filter, limit });\n } catch (error) {\n // A bad filter value is the caller's mistake; a read failure leaves the samples.\n if (error instanceof Error && /^Invalid /.test(error.message)) {\n throw new DevtoolsApiError(\"request.invalid-filter\");\n }\n }\n }\n\n const samples = await source.list({ ...sampleFilter, limit });\n\n return mergeRequestHistory(samples, persisted, limit);\n } catch (error) {\n if (error instanceof DevtoolsApiError) {\n sendApiError(reply, error);\n return;\n }\n\n throw error;\n }\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id\", async (request, reply) => {\n const { id } = request.params;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n const found = await source.get(id);\n\n if (found) {\n const hasTimeline = \"phases\" in found;\n\n if (hasTimeline) return persisted ? { ...found, record: persisted } : found;\n\n // A slow or failed request that was not sampled: the summary, plus what the log kept.\n if (persisted) {\n return {\n ...recordToDetail(persisted),\n ...(found.instance === undefined ? {} : { instance: found.instance }),\n partial: true,\n };\n }\n\n return found;\n }\n\n if (!persisted) {\n sendApiError(reply, new DevtoolsApiError(\"request.not-found\"));\n return;\n }\n\n return recordToDetail(persisted);\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id/curl\", async (request, reply) => {\n const { id } = request.params;\n const baseUrl = `${request.protocol}://${request.headers.host ?? \"localhost\"}`;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n\n if (persisted && deps.requestLog) return { curl: deps.requestLog.curl(persisted, baseUrl) };\n\n const found = await source.get(id);\n\n if (!found) {\n sendApiError(reply, new DevtoolsApiError(\"request.not-found\"));\n return;\n }\n\n return { curl: `curl -X ${found.method} '${baseUrl}${found.path.replace(/'/g, `'\\\\''`)}'` };\n });\n\n server.delete(\"/api/requests\", async (_request, reply) => {\n await source.clear();\n deps.collector.clear();\n reply.code(204).send();\n });\n}\n\n/**\n * Registers the request list, single-request detail, \"copy as curl\", and\n * clear routes.\n *\n * With core's persistent request log available, the list and the detail also\n * read the JSON-lines history, so requests survive a restart. The list\n * accepts `status` (404 or 5xx), `route`, `method`, `since`, `until`, `q`\n * and `limit` query parameters.\n */\nexport function registerRequestsRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n): void {\n if (deps.requests) {\n registerProductionRequestsRoutes(server, deps);\n return;\n }\n\n server.get<{ Querystring: Record<string, unknown> }>(\"/api/requests\", async (request, reply) => {\n const { requestLog, collector, options } = deps;\n\n if (!requestLog) return collector.listRequests();\n\n try {\n const filter = filterFromQuery(request.query);\n const matches = requestLog.compile(filter);\n const live = hasFilter(filter)\n ? collector.listRequests().filter((summary) => matches(summaryToRow(summary)))\n : collector.listRequests();\n const limit = filter.limit ?? options.maxRequests;\n const persisted = await requestLog.list({ ...filter, limit });\n\n return mergeRequestHistory(live, persisted, limit);\n } catch (error) {\n // A bad filter value is the caller's mistake; a read failure leaves the live list.\n if (error instanceof Error && /^Invalid /.test(error.message)) {\n reply.code(400).send({ error: error.message });\n return;\n }\n\n return collector.listRequests();\n }\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id\", async (request, reply) => {\n const { id } = request.params;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n const found = deps.collector.getRequest(id);\n\n if (found) {\n const detail: DevtoolsRequestDetail = persisted ? { ...found, record: persisted } : found;\n\n return detail;\n }\n\n if (!persisted) {\n reply.code(404).send();\n return;\n }\n\n return recordToDetail(persisted);\n });\n\n server.get<{ Params: { id: string } }>(\"/api/requests/:id/curl\", async (request, reply) => {\n const { id } = request.params;\n const baseUrl = `${request.protocol}://${request.headers.host ?? \"localhost\"}`;\n const persisted = await deps.requestLog?.get(id).catch(() => undefined);\n\n if (persisted && deps.requestLog) return { curl: deps.requestLog.curl(persisted, baseUrl) };\n\n // Without a persisted record only the method and path are known.\n const live = deps.collector.getRequest(id);\n\n if (!live) {\n reply.code(404).send();\n return;\n }\n\n return { curl: `curl -X ${live.method} '${baseUrl}${live.path.replace(/'/g, `'\\\\''`)}'` };\n });\n\n server.delete(\"/api/requests\", async (_request, reply) => {\n deps.collector.clear();\n if (deps.ai?.available) deps.ai.store.clear();\n reply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MAAS;EAEtE,IAAI,aAAa,KAAK,YAAY,OAAO,EAAE,MAAM,KAAK,WAAW,KAAK,WAAW,OAAO,EAAE;EAG1F,MAAM,OAAO,KAAK,UAAU,WAAW,EAAE;EAEzC,IAAI,CAAC,MAAM;GACT,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;GACrB;EACF;EAEA,OAAO,EAAE,MAAM,WAAW,KAAK,OAAO,IAAI,UAAU,KAAK,KAAK,QAAQ,MAAM,OAAO,EAAE,GAAG;CAC1F,CAAC;CAED,OAAO,OAAO,iBAAiB,OAAO,UAAU,UAAU;EACxD,KAAK,UAAU,MAAM;EACrB,IAAI,KAAK,IAAI,WAAW,KAAK,GAAG,MAAM,MAAM;EAC5C,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;CACvB,CAAC;AACH"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { listPanelInfos } from "../panels.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/devtools/src/server/session-routes.ts
|
|
4
|
+
/**
|
|
5
|
+
* The session view of the development dashboard: there are no accounts, the
|
|
6
|
+
* loopback guard is the access control, and the visitor is an admin.
|
|
7
|
+
*/
|
|
8
|
+
function developmentSessionView(deps) {
|
|
9
|
+
return {
|
|
10
|
+
mode: "development",
|
|
11
|
+
stage: "active",
|
|
12
|
+
account: null,
|
|
13
|
+
role: "admin",
|
|
14
|
+
csrf: null,
|
|
15
|
+
expiresAt: null,
|
|
16
|
+
instance: deps.instance ?? null,
|
|
17
|
+
methods: null
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** The tabs `GET api/panels` lists: the built-in tabs in `deps.builtInPanels` (default all), then the package panels. */
|
|
21
|
+
function panelInfos(deps, panels) {
|
|
22
|
+
return listPanelInfos(panels, deps.builtInPanels);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Registers `GET /api/auth/session` (the development view: signed in as an
|
|
26
|
+
* admin, no accounts) and `GET /api/panels`, so the same dashboard shell
|
|
27
|
+
* works in both modes. Production answers these from its own mount.
|
|
28
|
+
*/
|
|
29
|
+
function registerSessionRoutes(server, deps, panels) {
|
|
30
|
+
server.get("/api/auth/session", async (_request, reply) => {
|
|
31
|
+
reply.header("Cache-Control", "no-store");
|
|
32
|
+
return developmentSessionView(deps);
|
|
33
|
+
});
|
|
34
|
+
server.get("/api/panels", async (_request, reply) => {
|
|
35
|
+
reply.header("Cache-Control", "no-store");
|
|
36
|
+
return panelInfos(deps, panels);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { developmentSessionView, panelInfos, registerSessionRoutes };
|
|
42
|
+
//# sourceMappingURL=session-routes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-routes.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/session-routes.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport { listPanelInfos, type MountedDevtoolsPanel } from \"../panels\";\nimport type { DevtoolsPanelInfo, DevtoolsSessionView } from \"../production/contracts\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\n/**\n * The session view of the development dashboard: there are no accounts, the\n * loopback guard is the access control, and the visitor is an admin.\n */\nexport function developmentSessionView(deps: MountDevtoolsRoutesDeps): DevtoolsSessionView {\n return {\n mode: \"development\",\n stage: \"active\",\n account: null,\n role: \"admin\",\n csrf: null,\n expiresAt: null,\n instance: deps.instance ?? null,\n methods: null,\n };\n}\n\n/** The tabs `GET api/panels` lists: the built-in tabs in `deps.builtInPanels` (default all), then the package panels. */\nexport function panelInfos(\n deps: MountDevtoolsRoutesDeps,\n panels: readonly Pick<MountedDevtoolsPanel, \"id\" | \"title\">[],\n): DevtoolsPanelInfo[] {\n return listPanelInfos(panels, deps.builtInPanels);\n}\n\n/**\n * Registers `GET /api/auth/session` (the development view: signed in as an\n * admin, no accounts) and `GET /api/panels`, so the same dashboard shell\n * works in both modes. Production answers these from its own mount.\n */\nexport function registerSessionRoutes(\n server: FastifyInstance,\n deps: MountDevtoolsRoutesDeps,\n panels: readonly MountedDevtoolsPanel[],\n): void {\n server.get(\"/api/auth/session\", async (_request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n\n return developmentSessionView(deps);\n });\n\n server.get(\"/api/panels\", async (_request, reply) => {\n reply.header(\"Cache-Control\", \"no-store\");\n\n return panelInfos(deps, panels);\n });\n}\n"],"mappings":";;;;;;;AASA,SAAgB,uBAAuB,MAAoD;CACzF,OAAO;EACL,MAAM;EACN,OAAO;EACP,SAAS;EACT,MAAM;EACN,MAAM;EACN,WAAW;EACX,UAAU,KAAK,YAAY;EAC3B,SAAS;CACX;AACF;;AAGA,SAAgB,WACd,MACA,QACqB;CACrB,OAAO,eAAe,QAAQ,KAAK,aAAa;AAClD;;;;;;AAOA,SAAgB,sBACd,QACA,MACA,QACM;CACN,OAAO,IAAI,qBAAqB,OAAO,UAAU,UAAU;EACzD,MAAM,OAAO,iBAAiB,UAAU;EAExC,OAAO,uBAAuB,IAAI;CACpC,CAAC;CAED,OAAO,IAAI,eAAe,OAAO,UAAU,UAAU;EACnD,MAAM,OAAO,iBAAiB,UAAU;EAExC,OAAO,WAAW,MAAM,MAAM;CAChC,CAAC;AACH"}
|
|
@@ -1,37 +1,107 @@
|
|
|
1
1
|
//#region ../../packages/devtools/src/server/stream-route.ts
|
|
2
2
|
const PING_INTERVAL_MS = 15e3;
|
|
3
|
+
/** How long a browser waits before it reconnects a dropped stream. */
|
|
4
|
+
const RETRY_MS = 5e3;
|
|
5
|
+
/** The log entry as the production stream sends it: no context (it may hold values). */
|
|
6
|
+
function withoutContext(entry) {
|
|
7
|
+
return {
|
|
8
|
+
level: entry.level,
|
|
9
|
+
module: entry.module,
|
|
10
|
+
action: entry.action,
|
|
11
|
+
message: entry.message,
|
|
12
|
+
at: entry.at
|
|
13
|
+
};
|
|
14
|
+
}
|
|
3
15
|
/**
|
|
4
16
|
* Registers the SSE stream: one `event: <type>\ndata: <json>\n\n` frame per
|
|
5
17
|
* collector event, plus a `: ping` comment every 15s to keep intermediaries
|
|
6
18
|
* from closing an idle connection. The reply is hijacked so Fastify never
|
|
7
19
|
* tries to serialize or close the response itself.
|
|
20
|
+
*
|
|
21
|
+
* The first frames are `retry: 5000` and an `event: hello` with the mode,
|
|
22
|
+
* instance and role. In production (`deps.streamSession` set) the session and
|
|
23
|
+
* the open state are checked again at every ping and the stream ends when
|
|
24
|
+
* either fails; log entries carry no context; mail, AI and agent events flow
|
|
25
|
+
* only when those tabs are enabled.
|
|
8
26
|
*/
|
|
9
27
|
function registerStreamRoute(server, deps) {
|
|
10
28
|
server.get("/api/stream", async (request, reply) => {
|
|
29
|
+
const session = deps.streamSession ? await deps.streamSession(request) : null;
|
|
30
|
+
const enabled = new Set(deps.builtInPanels ?? []);
|
|
31
|
+
const instanceId = deps.instance?.id;
|
|
32
|
+
const mode = deps.mode ?? "development";
|
|
11
33
|
reply.hijack();
|
|
12
34
|
const res = reply.raw;
|
|
13
35
|
res.writeHead(200, {
|
|
36
|
+
...session?.headers,
|
|
14
37
|
"Content-Type": "text/event-stream",
|
|
15
38
|
"Cache-Control": "no-store",
|
|
16
|
-
Connection: "keep-alive"
|
|
39
|
+
Connection: "keep-alive",
|
|
40
|
+
"X-Accel-Buffering": "no"
|
|
17
41
|
});
|
|
42
|
+
const write = (frame) => {
|
|
43
|
+
if (!res.writableEnded && !res.destroyed) res.write(frame);
|
|
44
|
+
};
|
|
45
|
+
write(`retry: ${RETRY_MS}\n\n`);
|
|
46
|
+
const hello = {
|
|
47
|
+
mode,
|
|
48
|
+
instance: instanceId ?? null,
|
|
49
|
+
role: session?.role ?? (mode === "development" ? "admin" : null)
|
|
50
|
+
};
|
|
51
|
+
write(`event: hello\ndata: ${JSON.stringify(hello)}\n\n`);
|
|
18
52
|
const dispose = deps.collector.subscribe((event) => {
|
|
19
|
-
|
|
53
|
+
if (event.type === "hello") return;
|
|
54
|
+
if (session !== null) {
|
|
55
|
+
if (event.type === "mail" && !enabled.has("mail")) return;
|
|
56
|
+
if (event.type === "log") {
|
|
57
|
+
if (!session.logLevels.includes(event.data.level)) return;
|
|
58
|
+
const row = withoutContext(event.data);
|
|
59
|
+
write(`event: log\ndata: ${JSON.stringify(instanceId !== void 0 ? {
|
|
60
|
+
...row,
|
|
61
|
+
instance: instanceId
|
|
62
|
+
} : row)}\n\n`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const data = event.type === "request" && instanceId !== void 0 ? {
|
|
67
|
+
...event.data,
|
|
68
|
+
instance: instanceId
|
|
69
|
+
} : event.data;
|
|
70
|
+
write(`event: ${event.type}\ndata: ${JSON.stringify(data)}\n\n`);
|
|
20
71
|
});
|
|
21
|
-
const
|
|
22
|
-
|
|
72
|
+
const aiAllowed = session === null || enabled.has("ai");
|
|
73
|
+
const agentsAllowed = session === null || enabled.has("agents");
|
|
74
|
+
const disposeAi = aiAllowed && deps.ai?.available ? deps.ai.subscribe((event) => {
|
|
75
|
+
write(`event: ai\ndata: ${JSON.stringify(event)}\n\n`);
|
|
23
76
|
}) : void 0;
|
|
24
|
-
const disposeAgentTraces = deps.agentTraces?.subscribe((event) => {
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
77
|
+
const disposeAgentTraces = agentsAllowed ? deps.agentTraces?.subscribe((event) => {
|
|
78
|
+
write(`event: agent-trace\ndata: ${JSON.stringify(event)}\n\n`);
|
|
79
|
+
}) : void 0;
|
|
80
|
+
let closed = false;
|
|
81
|
+
const close = () => {
|
|
82
|
+
if (closed) return;
|
|
83
|
+
closed = true;
|
|
30
84
|
clearInterval(pingTimer);
|
|
31
85
|
dispose();
|
|
32
86
|
disposeAi?.();
|
|
33
87
|
disposeAgentTraces?.();
|
|
34
|
-
|
|
88
|
+
session?.release();
|
|
89
|
+
if (!res.writableEnded && !res.destroyed) res.end();
|
|
90
|
+
};
|
|
91
|
+
const pingTimer = setInterval(() => {
|
|
92
|
+
if (session === null) {
|
|
93
|
+
write(": ping\n\n");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
session.revalidate().then((stillValid) => {
|
|
97
|
+
if (closed) return;
|
|
98
|
+
if (stillValid) write(": ping\n\n");
|
|
99
|
+
else close();
|
|
100
|
+
}, () => close());
|
|
101
|
+
}, PING_INTERVAL_MS);
|
|
102
|
+
pingTimer.unref();
|
|
103
|
+
request.raw.on("close", close);
|
|
104
|
+
res.on("error", close);
|
|
35
105
|
});
|
|
36
106
|
}
|
|
37
107
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-route.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/stream-route.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport type { MountDevtoolsRoutesDeps } from \"./types\";\n\nconst PING_INTERVAL_MS = 15_000;\n\n/**\n * Registers the SSE stream: one `event: <type>\\ndata: <json>\\n\\n` frame per\n * collector event, plus a `: ping` comment every 15s to keep intermediaries\n * from closing an idle connection. The reply is hijacked so Fastify never\n * tries to serialize or close the response itself.\n */\nexport function registerStreamRoute(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get(\"/api/stream\", async (request, reply) => {\n reply.hijack();\n const res = reply.raw;\n\n res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-store\",\n Connection: \"keep-alive\",\n });\n\n const dispose = deps.collector.subscribe((event) => {\n
|
|
1
|
+
{"version":3,"file":"stream-route.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/stream-route.ts"],"sourcesContent":["import type { FastifyInstance } from \"fastify\";\nimport type { DevtoolsStreamSession, MountDevtoolsRoutesDeps } from \"./types\";\nimport type { DevtoolsLogEntry, DevtoolsStreamEvent } from \"../types\";\n\nconst PING_INTERVAL_MS = 15_000;\n\n/** How long a browser waits before it reconnects a dropped stream. */\nconst RETRY_MS = 5000;\n\n/** The log entry as the production stream sends it: no context (it may hold values). */\nfunction withoutContext(entry: DevtoolsLogEntry): DevtoolsLogEntry {\n return {\n level: entry.level,\n module: entry.module,\n action: entry.action,\n message: entry.message,\n at: entry.at,\n };\n}\n\n/**\n * Registers the SSE stream: one `event: <type>\\ndata: <json>\\n\\n` frame per\n * collector event, plus a `: ping` comment every 15s to keep intermediaries\n * from closing an idle connection. The reply is hijacked so Fastify never\n * tries to serialize or close the response itself.\n *\n * The first frames are `retry: 5000` and an `event: hello` with the mode,\n * instance and role. In production (`deps.streamSession` set) the session and\n * the open state are checked again at every ping and the stream ends when\n * either fails; log entries carry no context; mail, AI and agent events flow\n * only when those tabs are enabled.\n */\nexport function registerStreamRoute(server: FastifyInstance, deps: MountDevtoolsRoutesDeps): void {\n server.get(\"/api/stream\", async (request, reply) => {\n // Opening first, so a refused stream (`stream.too-many`) is a normal JSON error.\n const session: DevtoolsStreamSession | null = deps.streamSession\n ? await deps.streamSession(request)\n : null;\n const enabled = new Set(deps.builtInPanels ?? []);\n const instanceId = deps.instance?.id;\n const mode = deps.mode ?? \"development\";\n\n reply.hijack();\n const res = reply.raw;\n\n res.writeHead(200, {\n ...session?.headers,\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-store\",\n Connection: \"keep-alive\",\n \"X-Accel-Buffering\": \"no\",\n });\n\n const write = (frame: string): void => {\n if (!res.writableEnded && !res.destroyed) res.write(frame);\n };\n\n write(`retry: ${RETRY_MS}\\n\\n`);\n\n const hello: Extract<DevtoolsStreamEvent, { type: \"hello\" }>[\"data\"] = {\n mode,\n instance: instanceId ?? null,\n role: session?.role ?? (mode === \"development\" ? \"admin\" : null),\n };\n\n write(`event: hello\\ndata: ${JSON.stringify(hello)}\\n\\n`);\n\n const dispose = deps.collector.subscribe((event) => {\n if (event.type === \"hello\") return;\n\n if (session !== null) {\n if (event.type === \"mail\" && !enabled.has(\"mail\")) return;\n\n if (event.type === \"log\") {\n if (!session.logLevels.includes(event.data.level)) return;\n\n const row = withoutContext(event.data);\n\n write(\n `event: log\\ndata: ${JSON.stringify(instanceId !== undefined ? { ...row, instance: instanceId } : row)}\\n\\n`,\n );\n return;\n }\n }\n\n const data =\n event.type === \"request\" && instanceId !== undefined\n ? { ...event.data, instance: instanceId }\n : event.data;\n\n write(`event: ${event.type}\\ndata: ${JSON.stringify(data)}\\n\\n`);\n });\n\n const aiAllowed = session === null || enabled.has(\"ai\");\n const agentsAllowed = session === null || enabled.has(\"agents\");\n\n const disposeAi =\n aiAllowed && deps.ai?.available\n ? deps.ai.subscribe((event) => {\n write(`event: ai\\ndata: ${JSON.stringify(event)}\\n\\n`);\n })\n : undefined;\n\n const disposeAgentTraces = agentsAllowed\n ? deps.agentTraces?.subscribe((event) => {\n write(`event: agent-trace\\ndata: ${JSON.stringify(event)}\\n\\n`);\n })\n : undefined;\n\n let closed = false;\n\n const close = (): void => {\n if (closed) return;\n\n closed = true;\n clearInterval(pingTimer);\n dispose();\n disposeAi?.();\n disposeAgentTraces?.();\n session?.release();\n\n if (!res.writableEnded && !res.destroyed) res.end();\n };\n\n const pingTimer = setInterval(() => {\n if (session === null) {\n write(\": ping\\n\\n\");\n return;\n }\n\n session.revalidate().then(\n (stillValid) => {\n if (closed) return;\n\n if (stillValid) write(\": ping\\n\\n\");\n else close();\n },\n () => close(),\n );\n }, PING_INTERVAL_MS);\n pingTimer.unref();\n\n request.raw.on(\"close\", close);\n res.on(\"error\", close);\n });\n}\n"],"mappings":";AAIA,MAAM,mBAAmB;;AAGzB,MAAM,WAAW;;AAGjB,SAAS,eAAe,OAA2C;CACjE,OAAO;EACL,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,IAAI,MAAM;CACZ;AACF;;;;;;;;;;;;;AAcA,SAAgB,oBAAoB,QAAyB,MAAqC;CAChG,OAAO,IAAI,eAAe,OAAO,SAAS,UAAU;EAElD,MAAM,UAAwC,KAAK,gBAC/C,MAAM,KAAK,cAAc,OAA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