@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
package/esm/server/ui-assets.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveUiRoot } from "../ui-root.mjs";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import path from "node:path";
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
4
|
|
|
5
5
|
//#region ../../packages/devtools/src/server/ui-assets.ts
|
|
6
6
|
const uiFile = (name) => () => path.join(resolveUiRoot(), name);
|
|
@@ -11,11 +11,11 @@ const uiFile = (name) => () => path.join(resolveUiRoot(), name);
|
|
|
11
11
|
const UI_ASSETS = {
|
|
12
12
|
"app.js": {
|
|
13
13
|
contentType: "text/javascript; charset=utf-8",
|
|
14
|
-
file: uiFile("app.js")
|
|
14
|
+
file: uiFile("dashboard/assets/app.js")
|
|
15
15
|
},
|
|
16
16
|
"app.css": {
|
|
17
17
|
contentType: "text/css; charset=utf-8",
|
|
18
|
-
file: uiFile("app.css")
|
|
18
|
+
file: uiFile("dashboard/assets/app.css")
|
|
19
19
|
},
|
|
20
20
|
"scalar.js": {
|
|
21
21
|
contentType: "text/javascript; charset=utf-8",
|
|
@@ -38,24 +38,46 @@ const UI_ASSETS = {
|
|
|
38
38
|
function sendFile(reply, file, contentType) {
|
|
39
39
|
reply.header("Cache-Control", "no-store").header("Content-Type", contentType).send(readFileSync(file));
|
|
40
40
|
}
|
|
41
|
+
const NOT_BUILT_HTML = "<!doctype html><title>Warlock Devtools</title><p>The devtools dashboard has not been built. Run <code>pnpm --filter @warlock.js/devtools build:ui</code>.</p>";
|
|
41
42
|
/**
|
|
42
|
-
* Serves the static dashboard: `index.html` at the
|
|
43
|
-
* whitelisted assets (`app.js`, `app.css`, the
|
|
44
|
-
* `scalar.js`, and the vendored Swagger UI files
|
|
45
|
-
*
|
|
43
|
+
* Serves the static dashboard: the built `ui/dashboard/index.html` at the
|
|
44
|
+
* dashboard root and the whitelisted assets (`app.js`, `app.css`, the
|
|
45
|
+
* vendored Scalar bundle as `scalar.js`, and the vendored Swagger UI files
|
|
46
|
+
* plus their init script). The asset name is matched against a fixed
|
|
47
|
+
* whitelist — never joined into a filesystem path — so no request can
|
|
48
|
+
* traverse outside it. Before the first `build:ui` the root answers 503 with
|
|
49
|
+
* a note that says how to build. `notFound` answers an unknown asset (the
|
|
50
|
+
* production gate passes its uniform 404, so the public asset route answers
|
|
51
|
+
* like any unknown URL of the app); without it the answer is a bare 404.
|
|
46
52
|
*/
|
|
47
|
-
function registerUiAssets(server) {
|
|
48
|
-
const serveIndex = (
|
|
49
|
-
|
|
53
|
+
function registerUiAssets(server, options = {}) {
|
|
54
|
+
const serveIndex = (request, reply) => {
|
|
55
|
+
const [pathname = "", search] = (request.originalUrl ?? request.url).split("?");
|
|
56
|
+
if (!pathname.endsWith("/")) {
|
|
57
|
+
const base = (request.routeOptions.url ?? pathname).replace(/\/+$/, "");
|
|
58
|
+
reply.code(308).header("Cache-Control", "no-store").redirect(`${base}/${search === void 0 ? "" : `?${search}`}`, 308);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const index = path.join(resolveUiRoot(), "dashboard", "index.html");
|
|
62
|
+
if (!existsSync(index)) {
|
|
63
|
+
reply.code(503).header("Cache-Control", "no-store").header("Content-Type", "text/html; charset=utf-8").send(NOT_BUILT_HTML);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
reply.header("Cache-Control", "no-store").header("Content-Type", "text/html; charset=utf-8").send(readFileSync(index));
|
|
50
67
|
};
|
|
51
68
|
server.get("/", serveIndex);
|
|
52
69
|
server.get("/assets/:name", (request, reply) => {
|
|
53
70
|
const asset = Object.hasOwn(UI_ASSETS, request.params.name) ? UI_ASSETS[request.params.name] : void 0;
|
|
54
|
-
|
|
71
|
+
const file = asset?.file();
|
|
72
|
+
if (!asset || !file || !existsSync(file)) {
|
|
73
|
+
if (options.notFound) {
|
|
74
|
+
options.notFound(request, reply);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
55
77
|
reply.code(404).header("Cache-Control", "no-store").send();
|
|
56
78
|
return;
|
|
57
79
|
}
|
|
58
|
-
sendFile(reply,
|
|
80
|
+
sendFile(reply, file, asset.contentType);
|
|
59
81
|
});
|
|
60
82
|
}
|
|
61
83
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-assets.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/ui-assets.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { FastifyInstance, FastifyReply } from \"fastify\";\nimport { resolveUiRoot } from \"../ui-root\";\n\n/**\n * Where an asset's bytes come from: a file in this package's `ui/` folder.\n */\ntype UiAsset = {\n contentType: string;\n file: () => string;\n};\n\nconst uiFile = (name: string) => () => path.join(resolveUiRoot(), name);\n\n/**\n * The only assets that can be requested. The request's asset name is looked\n * up here and never joined into a filesystem path.\n */\nconst UI_ASSETS: Record<string, UiAsset> = {\n \"app.js\": {
|
|
1
|
+
{"version":3,"file":"ui-assets.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/server/ui-assets.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\";\nimport { resolveUiRoot } from \"../ui-root\";\n\n/**\n * Where an asset's bytes come from: a file in this package's `ui/` folder.\n */\ntype UiAsset = {\n contentType: string;\n file: () => string;\n};\n\nconst uiFile = (name: string) => () => path.join(resolveUiRoot(), name);\n\n/**\n * The only assets that can be requested. The request's asset name is looked\n * up here and never joined into a filesystem path.\n */\nconst UI_ASSETS: Record<string, UiAsset> = {\n \"app.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"dashboard/assets/app.js\"),\n },\n \"app.css\": { contentType: \"text/css; charset=utf-8\", file: uiFile(\"dashboard/assets/app.css\") },\n \"scalar.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"vendor/scalar/standalone.js\"),\n },\n \"swagger-ui-bundle.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"vendor/swagger-ui/swagger-ui-bundle.js\"),\n },\n \"swagger-ui.css\": {\n contentType: \"text/css; charset=utf-8\",\n file: uiFile(\"vendor/swagger-ui/swagger-ui.css\"),\n },\n \"docs-swagger.js\": {\n contentType: \"text/javascript; charset=utf-8\",\n file: uiFile(\"docs-swagger.js\"),\n },\n};\n\n/** Sends `file` with `contentType` and no caching. */\nexport function sendFile(reply: FastifyReply, file: string, contentType: string): void {\n reply\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", contentType)\n .send(readFileSync(file));\n}\n\nconst NOT_BUILT_HTML =\n \"<!doctype html><title>Warlock Devtools</title><p>The devtools dashboard has not been built. Run <code>pnpm --filter @warlock.js/devtools build:ui</code>.</p>\";\n\n/**\n * Serves the static dashboard: the built `ui/dashboard/index.html` at the\n * dashboard root and the whitelisted assets (`app.js`, `app.css`, the\n * vendored Scalar bundle as `scalar.js`, and the vendored Swagger UI files\n * plus their init script). The asset name is matched against a fixed\n * whitelist — never joined into a filesystem path — so no request can\n * traverse outside it. Before the first `build:ui` the root answers 503 with\n * a note that says how to build. `notFound` answers an unknown asset (the\n * production gate passes its uniform 404, so the public asset route answers\n * like any unknown URL of the app); without it the answer is a bare 404.\n */\nexport function registerUiAssets(\n server: FastifyInstance,\n options: { notFound?: (request: FastifyRequest, reply: FastifyReply) => FastifyReply } = {},\n): void {\n const serveIndex = (request: FastifyRequest, reply: FastifyReply): void => {\n // The address as sent: core's server drops a trailing slash before routing.\n const [pathname = \"\", search] = (request.originalUrl ?? request.url).split(\"?\");\n\n // The page loads its assets by relative URL, so it must be served from `<path>/`. The target is built from\n // the route, never from the request, so it always stays on the dashboard path.\n if (!pathname.endsWith(\"/\")) {\n const base = (request.routeOptions.url ?? pathname).replace(/\\/+$/, \"\");\n\n reply\n .code(308)\n .header(\"Cache-Control\", \"no-store\")\n .redirect(`${base}/${search === undefined ? \"\" : `?${search}`}`, 308);\n return;\n }\n\n const index = path.join(resolveUiRoot(), \"dashboard\", \"index.html\");\n\n if (!existsSync(index)) {\n reply\n .code(503)\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", \"text/html; charset=utf-8\")\n .send(NOT_BUILT_HTML);\n return;\n }\n\n reply\n .header(\"Cache-Control\", \"no-store\")\n .header(\"Content-Type\", \"text/html; charset=utf-8\")\n .send(readFileSync(index));\n };\n\n server.get(\"/\", serveIndex);\n\n server.get<{ Params: { name: string } }>(\"/assets/:name\", (request, reply) => {\n const asset = Object.hasOwn(UI_ASSETS, request.params.name)\n ? UI_ASSETS[request.params.name]\n : undefined;\n const file = asset?.file();\n\n if (!asset || !file || !existsSync(file)) {\n if (options.notFound) {\n options.notFound(request, reply);\n return;\n }\n\n reply.code(404).header(\"Cache-Control\", \"no-store\").send();\n return;\n }\n\n sendFile(reply, file, asset.contentType);\n });\n}\n"],"mappings":";;;;;AAaA,MAAM,UAAU,eAAuB,KAAK,KAAK,cAAc,GAAG,IAAI;;;;;AAMtE,MAAM,YAAqC;CACzC,UAAU;EACR,aAAa;EACb,MAAM,OAAO,yBAAyB;CACxC;CACA,WAAW;EAAE,aAAa;EAA2B,MAAM,OAAO,0BAA0B;CAAE;CAC9F,aAAa;EACX,aAAa;EACb,MAAM,OAAO,6BAA6B;CAC5C;CACA,wBAAwB;EACtB,aAAa;EACb,MAAM,OAAO,wCAAwC;CACvD;CACA,kBAAkB;EAChB,aAAa;EACb,MAAM,OAAO,kCAAkC;CACjD;CACA,mBAAmB;EACjB,aAAa;EACb,MAAM,OAAO,iBAAiB;CAChC;AACF;;AAGA,SAAgB,SAAS,OAAqB,MAAc,aAA2B;CACrF,MACG,OAAO,iBAAiB,UAAU,CAAC,CACnC,OAAO,gBAAgB,WAAW,CAAC,CACnC,KAAK,aAAa,IAAI,CAAC;AAC5B;AAEA,MAAM,iBACJ;;;;;;;;;;;;AAaF,SAAgB,iBACd,QACA,UAAyF,CAAC,GACpF;CACN,MAAM,cAAc,SAAyB,UAA8B;EAEzE,MAAM,CAAC,WAAW,IAAI,WAAW,QAAQ,eAAe,QAAQ,IAAG,CAAE,MAAM,GAAG;EAI9E,IAAI,CAAC,SAAS,SAAS,GAAG,GAAG;GAC3B,MAAM,QAAQ,QAAQ,aAAa,OAAO,SAAQ,CAAE,QAAQ,QAAQ,EAAE;GAEtE,MACG,KAAK,GAAG,CAAC,CACT,OAAO,iBAAiB,UAAU,CAAC,CACnC,SAAS,GAAG,KAAK,GAAG,WAAW,SAAY,KAAK,IAAI,YAAY,GAAG;GACtE;EACF;EAEA,MAAM,QAAQ,KAAK,KAAK,cAAc,GAAG,aAAa,YAAY;EAElE,IAAI,CAAC,WAAW,KAAK,GAAG;GACtB,MACG,KAAK,GAAG,CAAC,CACT,OAAO,iBAAiB,UAAU,CAAC,CACnC,OAAO,gBAAgB,0BAA0B,CAAC,CAClD,KAAK,cAAc;GACtB;EACF;EAEA,MACG,OAAO,iBAAiB,UAAU,CAAC,CACnC,OAAO,gBAAgB,0BAA0B,CAAC,CAClD,KAAK,aAAa,KAAK,CAAC;CAC7B;CAEA,OAAO,IAAI,KAAK,UAAU;CAE1B,OAAO,IAAkC,kBAAkB,SAAS,UAAU;EAC5E,MAAM,QAAQ,OAAO,OAAO,WAAW,QAAQ,OAAO,IAAI,IACtD,UAAU,QAAQ,OAAO,QACzB;EACJ,MAAM,OAAO,OAAO,KAAK;EAEzB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,IAAI,GAAG;GACxC,IAAI,QAAQ,UAAU;IACpB,QAAQ,SAAS,SAAS,KAAK;IAC/B;GACF;GAEA,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,iBAAiB,UAAU,CAAC,CAAC,KAAK;GACzD;EACF;EAEA,SAAS,OAAO,MAAM,MAAM,WAAW;CACzC,CAAC;AACH"}
|
|
@@ -7,6 +7,19 @@ import { LogChannel, log } from "@warlock.js/logger";
|
|
|
7
7
|
function toDevtoolsLevel(type) {
|
|
8
8
|
return type === "fatal" ? "error" : type;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* The entry's message as text. `request.log(error)` and friends log an Error
|
|
12
|
+
* (or any value) as the message; kept as is, it reached the dashboard as `{}`.
|
|
13
|
+
*/
|
|
14
|
+
function messageText(message) {
|
|
15
|
+
if (typeof message === "string") return message;
|
|
16
|
+
if (message instanceof Error) return `${message.name}: ${message.message}`;
|
|
17
|
+
try {
|
|
18
|
+
return JSON.stringify(message) ?? String(message);
|
|
19
|
+
} catch {
|
|
20
|
+
return String(message);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
10
23
|
var DevtoolsLogChannel = class extends LogChannel {
|
|
11
24
|
constructor(collector) {
|
|
12
25
|
super();
|
|
@@ -20,7 +33,7 @@ var DevtoolsLogChannel = class extends LogChannel {
|
|
|
20
33
|
level: toDevtoolsLevel(data.type),
|
|
21
34
|
module: data.module,
|
|
22
35
|
action: data.action,
|
|
23
|
-
message: data.message,
|
|
36
|
+
message: messageText(data.message),
|
|
24
37
|
at: Date.now(),
|
|
25
38
|
context: toSafeValue(data.context)
|
|
26
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-source.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/log-source.ts"],"sourcesContent":["import { LogChannel, log, type LoggingData } from \"@warlock.js/logger\";\nimport { currentRequestId } from \"../current-request-id\";\nimport { toSafeValue } from \"../safe-value\";\nimport type { DevtoolsCollector, DevtoolsDisposer, DevtoolsLogEntry } from \"../types\";\n\n/** `LoggingData.type` includes `fatal`, which devtools folds into `error`. */\nfunction toDevtoolsLevel(type: LoggingData[\"type\"]): DevtoolsLogEntry[\"level\"] {\n return type === \"fatal\" ? \"error\" : type;\n}\n\nclass DevtoolsLogChannel extends LogChannel {\n public override name = \"devtools\";\n public active = true;\n\n public constructor(private readonly collector: DevtoolsCollector) {\n super();\n }\n\n public log(data: LoggingData): void {\n if (!this.active) return;\n\n // Already passed through the logger's redaction floor (`Logger.log`\n // applies it before invoking any channel). It is still app data, and can\n // hold live objects (a request, its socket), so a JSON-safe snapshot is\n // kept instead of the object itself.\n const entry: DevtoolsLogEntry = {\n level: toDevtoolsLevel(data.type),\n module: data.module,\n action: data.action,\n message: data.message,\n at: Date.now(),\n context: toSafeValue(data.context),\n };\n\n this.collector.addLog(currentRequestId(), entry);\n }\n}\n\n/**\n * Feeds every log entry, from `@warlock.js/logger`, into the collector by\n * registering an additional channel. `Logger` has no way to remove a\n * channel, so the disposer flag-ignores further entries instead — the\n * channel stays registered for the process's lifetime.\n */\nexport async function attachLogSource(collector: DevtoolsCollector): Promise<DevtoolsDisposer> {\n const channel = new DevtoolsLogChannel(collector);\n\n log.addChannel(channel);\n\n return () => {\n channel.active = false;\n };\n}\n"],"mappings":";;;;;;AAMA,SAAS,gBAAgB,MAAsD;CAC7E,OAAO,SAAS,UAAU,UAAU;AACtC;AAEA,IAAM,qBAAN,cAAiC,WAAW;CAI1C,AAAO,YAAY,AAAiB,WAA8B;EAChE,MAAM;EAD4B;cAHb;gBACP;CAIhB;CAEA,AAAO,IAAI,MAAyB;EAClC,IAAI,CAAC,KAAK,QAAQ;EAMlB,MAAM,QAA0B;GAC9B,OAAO,gBAAgB,KAAK,IAAI;GAChC,QAAQ,KAAK;GACb,QAAQ,KAAK;GACb,SAAS,KAAK;
|
|
1
|
+
{"version":3,"file":"log-source.mjs","names":[],"sources":["../../../../../../../../packages/devtools/src/sources/log-source.ts"],"sourcesContent":["import { LogChannel, log, type LoggingData } from \"@warlock.js/logger\";\nimport { currentRequestId } from \"../current-request-id\";\nimport { toSafeValue } from \"../safe-value\";\nimport type { DevtoolsCollector, DevtoolsDisposer, DevtoolsLogEntry } from \"../types\";\n\n/** `LoggingData.type` includes `fatal`, which devtools folds into `error`. */\nfunction toDevtoolsLevel(type: LoggingData[\"type\"]): DevtoolsLogEntry[\"level\"] {\n return type === \"fatal\" ? \"error\" : type;\n}\n\n/**\n * The entry's message as text. `request.log(error)` and friends log an Error\n * (or any value) as the message; kept as is, it reached the dashboard as `{}`.\n */\nfunction messageText(message: unknown): string {\n if (typeof message === \"string\") return message;\n if (message instanceof Error) return `${message.name}: ${message.message}`;\n\n try {\n return JSON.stringify(message) ?? String(message);\n } catch {\n return String(message);\n }\n}\n\nclass DevtoolsLogChannel extends LogChannel {\n public override name = \"devtools\";\n public active = true;\n\n public constructor(private readonly collector: DevtoolsCollector) {\n super();\n }\n\n public log(data: LoggingData): void {\n if (!this.active) return;\n\n // Already passed through the logger's redaction floor (`Logger.log`\n // applies it before invoking any channel). It is still app data, and can\n // hold live objects (a request, its socket), so a JSON-safe snapshot is\n // kept instead of the object itself.\n const entry: DevtoolsLogEntry = {\n level: toDevtoolsLevel(data.type),\n module: data.module,\n action: data.action,\n message: messageText(data.message),\n at: Date.now(),\n context: toSafeValue(data.context),\n };\n\n this.collector.addLog(currentRequestId(), entry);\n }\n}\n\n/**\n * Feeds every log entry, from `@warlock.js/logger`, into the collector by\n * registering an additional channel. `Logger` has no way to remove a\n * channel, so the disposer flag-ignores further entries instead — the\n * channel stays registered for the process's lifetime.\n */\nexport async function attachLogSource(collector: DevtoolsCollector): Promise<DevtoolsDisposer> {\n const channel = new DevtoolsLogChannel(collector);\n\n log.addChannel(channel);\n\n return () => {\n channel.active = false;\n };\n}\n"],"mappings":";;;;;;AAMA,SAAS,gBAAgB,MAAsD;CAC7E,OAAO,SAAS,UAAU,UAAU;AACtC;;;;;AAMA,SAAS,YAAY,SAA0B;CAC7C,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,IAAI,mBAAmB,OAAO,OAAO,GAAG,QAAQ,KAAK,IAAI,QAAQ;CAEjE,IAAI;EACF,OAAO,KAAK,UAAU,OAAO,KAAK,OAAO,OAAO;CAClD,QAAQ;EACN,OAAO,OAAO,OAAO;CACvB;AACF;AAEA,IAAM,qBAAN,cAAiC,WAAW;CAI1C,AAAO,YAAY,AAAiB,WAA8B;EAChE,MAAM;EAD4B;cAHb;gBACP;CAIhB;CAEA,AAAO,IAAI,MAAyB;EAClC,IAAI,CAAC,KAAK,QAAQ;EAMlB,MAAM,QAA0B;GAC9B,OAAO,gBAAgB,KAAK,IAAI;GAChC,QAAQ,KAAK;GACb,QAAQ,KAAK;GACb,SAAS,YAAY,KAAK,OAAO;GACjC,IAAI,KAAK,IAAI;GACb,SAAS,YAAY,KAAK,OAAO;EACnC;EAEA,KAAK,UAAU,OAAO,iBAAiB,GAAG,KAAK;CACjD;AACF;;;;;;;AAQA,eAAsB,gBAAgB,WAAyD;CAC7F,MAAM,UAAU,IAAI,mBAAmB,SAAS;CAEhD,IAAI,WAAW,OAAO;CAEtB,aAAa;EACX,QAAQ,SAAS;CACnB;AACF"}
|
package/esm/types.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DevtoolsAgentTraceEvent } from "./sources/agent-trace-source.mjs";
|
|
2
2
|
import { DevtoolsAiEvent } from "./sources/ai-source.mjs";
|
|
3
|
+
import { DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS, DevtoolsAccountView, DevtoolsApiErrorBody, DevtoolsAuditEntry, DevtoolsAuditType, DevtoolsAuthStepResult, DevtoolsBuiltInPanelId, DevtoolsCaptureCounters, DevtoolsCreatedInvite, DevtoolsErrorCode, DevtoolsErrorGroup, DevtoolsErrorsView, DevtoolsExplainResult, DevtoolsHealthReport, DevtoolsHealthView, DevtoolsHistogram, DevtoolsInstanceInfo, DevtoolsInstanceReport, DevtoolsInstancesView, DevtoolsInviteView, DevtoolsJobsReport, DevtoolsJobsView, DevtoolsLogRow, DevtoolsLoginInput, DevtoolsLogsView, DevtoolsMode, DevtoolsPanelInfo, DevtoolsPasswordSource, DevtoolsQueryShapeRow, DevtoolsQueryShapeStats, DevtoolsQueryStatsView, DevtoolsRecoveryCodes, DevtoolsReportLogEntry, DevtoolsResourcePoint, DevtoolsResourceSnapshot, DevtoolsResourcesView, DevtoolsRole, DevtoolsRoutePhaseStats, DevtoolsRouteStats, DevtoolsRouteStatsRow, DevtoolsRouteStatsView, DevtoolsSampleDetail, DevtoolsSampleQuery, DevtoolsSampleSummary, DevtoolsScheduleInfo, DevtoolsSessionInfo, DevtoolsSessionStage, DevtoolsSessionView, DevtoolsTotpEnrolment, DevtoolsUserListView } from "./production/contracts.mjs";
|
|
3
4
|
import { RequestLogRecord } from "@warlock.js/core";
|
|
4
5
|
//#region ../../packages/devtools/src/types.d.ts
|
|
5
6
|
/**
|
|
@@ -50,9 +51,266 @@ export type DevtoolsOptions = {
|
|
|
50
51
|
* @default false
|
|
51
52
|
*/
|
|
52
53
|
allowProxied?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Extra dashboard tabs. Each entry is a module specifier, loaded only in
|
|
56
|
+
* development, whose default export is a `DevtoolsPanelExport`: a package
|
|
57
|
+
* export such as `"@warlock.js/grimoire/devtools"` (resolved from the app
|
|
58
|
+
* root) or a path starting with `./` (relative to the app root). An entry
|
|
59
|
+
* may also be a `DevtoolsPanel` object.
|
|
60
|
+
*
|
|
61
|
+
* @default []
|
|
62
|
+
*/
|
|
63
|
+
panels?: readonly (string | DevtoolsPanel)[];
|
|
64
|
+
/**
|
|
65
|
+
* The production monitor: a signed-in dashboard at a secret path. Off
|
|
66
|
+
* unless `enabled` is `true`; read only when the app runs in production
|
|
67
|
+
* (development keeps the loopback dashboard and ignores this block).
|
|
68
|
+
* Secrets come from the environment, never from this object in source
|
|
69
|
+
* control: `DEVTOOLS_PATH`, `DEVTOOLS_ADMIN_EMAIL`, and
|
|
70
|
+
* `DEVTOOLS_ADMIN_PASSWORD` or `DEVTOOLS_SETUP_TOKEN`.
|
|
71
|
+
*
|
|
72
|
+
* @default undefined (off)
|
|
73
|
+
*/
|
|
74
|
+
production?: DevtoolsProductionOptions;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Options of the production monitor (`devtools.production`). Every value has
|
|
78
|
+
* a safe default; only `enabled` must be set, and the path and first admin
|
|
79
|
+
* come from the environment.
|
|
80
|
+
*/
|
|
81
|
+
export type DevtoolsProductionOptions = {
|
|
82
|
+
/**
|
|
83
|
+
* Turn the monitor on in production. Without it nothing is mounted and
|
|
84
|
+
* nothing is captured.
|
|
85
|
+
*
|
|
86
|
+
* @default false
|
|
87
|
+
*/
|
|
88
|
+
enabled?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* The dashboard path. Prefer the `DEVTOOLS_PATH` environment variable; at
|
|
91
|
+
* least 8 characters, never `/__warlock`.
|
|
92
|
+
*
|
|
93
|
+
* @default process.env.DEVTOOLS_PATH
|
|
94
|
+
*/
|
|
95
|
+
path?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Share of requests captured with a full timeline, 0–1. Slow and failed
|
|
98
|
+
* requests outside the sample are kept as a summary.
|
|
99
|
+
*
|
|
100
|
+
* @default 0.1
|
|
101
|
+
*/
|
|
102
|
+
sampleRate?: number;
|
|
103
|
+
/**
|
|
104
|
+
* A request at least this slow is kept even when not sampled.
|
|
105
|
+
*
|
|
106
|
+
* @default 1000
|
|
107
|
+
*/
|
|
108
|
+
slowRequestMs?: number;
|
|
109
|
+
/**
|
|
110
|
+
* A query at least this slow counts in the query statistics even outside a
|
|
111
|
+
* sampled request.
|
|
112
|
+
*
|
|
113
|
+
* @default 200
|
|
114
|
+
*/
|
|
115
|
+
slowQueryMs?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Sampled requests kept in memory per process (the live view).
|
|
118
|
+
*
|
|
119
|
+
* @default 200
|
|
120
|
+
*/
|
|
121
|
+
maxRequests?: number;
|
|
122
|
+
/**
|
|
123
|
+
* How long stored request samples are kept, in hours.
|
|
124
|
+
*
|
|
125
|
+
* @default 24
|
|
126
|
+
*/
|
|
127
|
+
requestRetentionHours?: number;
|
|
128
|
+
/**
|
|
129
|
+
* The most samples one process writes to the database per minute; the rest
|
|
130
|
+
* stay in memory only.
|
|
131
|
+
*
|
|
132
|
+
* @default 120
|
|
133
|
+
*/
|
|
134
|
+
maxStoredSamplesPerMinute?: number;
|
|
135
|
+
/**
|
|
136
|
+
* How often each process writes its report (resources, statistics, health)
|
|
137
|
+
* to the database, in ms.
|
|
138
|
+
*
|
|
139
|
+
* @default 10000
|
|
140
|
+
*/
|
|
141
|
+
reportIntervalMs?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Proxies whose `X-Forwarded-For`, `X-Forwarded-Proto` and
|
|
144
|
+
* `X-Forwarded-Host` headers are believed: IP addresses, CIDR ranges, or
|
|
145
|
+
* `"loopback"` and `"private"`. Without an entry the socket address is the
|
|
146
|
+
* client.
|
|
147
|
+
*
|
|
148
|
+
* @default []
|
|
149
|
+
*/
|
|
150
|
+
trustedProxies?: readonly string[];
|
|
151
|
+
/**
|
|
152
|
+
* Answer only requests that arrived over HTTPS (directly or through a
|
|
153
|
+
* trusted proxy). Turn off only to try the monitor on a local machine.
|
|
154
|
+
*
|
|
155
|
+
* @default true
|
|
156
|
+
*/
|
|
157
|
+
requireHttps?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* When set, only these client IPs or CIDR ranges reach the dashboard;
|
|
160
|
+
* everyone else gets a 404.
|
|
161
|
+
*
|
|
162
|
+
* @default [] (any client)
|
|
163
|
+
*/
|
|
164
|
+
allowedIps?: readonly string[];
|
|
165
|
+
/**
|
|
166
|
+
* The public origin of the app (`https://app.example.com`), used for the
|
|
167
|
+
* CSRF origin check and passkeys. Without it the request's own origin is
|
|
168
|
+
* used.
|
|
169
|
+
*
|
|
170
|
+
* @default null
|
|
171
|
+
*/
|
|
172
|
+
origin?: string;
|
|
173
|
+
/** Session lifetime. */
|
|
174
|
+
session?: {
|
|
175
|
+
/** Signed out after this many idle minutes. @default 30 */
|
|
176
|
+
idleMinutes?: number;
|
|
177
|
+
/** Signed out after this many hours whatever happens. @default 8 */
|
|
178
|
+
maxHours?: number;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Who must use a second factor (an authenticator app or a passkey).
|
|
182
|
+
*
|
|
183
|
+
* @default "admins"
|
|
184
|
+
*/
|
|
185
|
+
twoFactor?: "admins" | "everyone";
|
|
186
|
+
/** Failed sign-in limits, counted over the audit log in a sliding window. */
|
|
187
|
+
rateLimits?: {
|
|
188
|
+
/** @default 15 */
|
|
189
|
+
windowMinutes?: number;
|
|
190
|
+
/** Failures per account before it is refused for the window. @default 5 */
|
|
191
|
+
account?: number;
|
|
192
|
+
/** Failures per client IP before it is refused for the window. @default 20 */
|
|
193
|
+
ip?: number;
|
|
194
|
+
/** Failures in total before the whole dashboard answers 404 for `lockMinutes`. @default 100 */
|
|
195
|
+
global?: number;
|
|
196
|
+
/** @default 15 */
|
|
197
|
+
lockMinutes?: number;
|
|
198
|
+
};
|
|
199
|
+
/** EXPLAIN in production. */
|
|
200
|
+
explain?: {
|
|
201
|
+
/**
|
|
202
|
+
* Allow executing plans (PostgreSQL `EXPLAIN ANALYZE`, MongoDB
|
|
203
|
+
* `executionStats`). They run the query; leave off unless you accept that.
|
|
204
|
+
*
|
|
205
|
+
* @default false
|
|
206
|
+
*/
|
|
207
|
+
executing?: boolean;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Turn tabs on or off by id. Built-in tabs `mail`, `ai`, `agents`, `api`
|
|
211
|
+
* and `processes` are off in production unless set to `true`; a package
|
|
212
|
+
* panel shows only when it declares `production: true` or is set to `true`
|
|
213
|
+
* here.
|
|
214
|
+
*
|
|
215
|
+
* @default {}
|
|
216
|
+
*/
|
|
217
|
+
panels?: Readonly<Record<string, boolean>>;
|
|
218
|
+
/**
|
|
219
|
+
* Log levels the Logs tab keeps outside sampled requests.
|
|
220
|
+
*
|
|
221
|
+
* @default ["warn", "error"]
|
|
222
|
+
*/
|
|
223
|
+
logLevels?: readonly DevtoolsLogEntry["level"][];
|
|
224
|
+
/**
|
|
225
|
+
* How long audit entries are kept, in days.
|
|
226
|
+
*
|
|
227
|
+
* @default 90
|
|
228
|
+
*/
|
|
229
|
+
auditRetentionDays?: number;
|
|
230
|
+
/** Passkeys as a second factor (needs `@simplewebauthn/server`). */
|
|
231
|
+
passkeys?: {
|
|
232
|
+
/** The name authenticators show. @default "Warlock monitor" */
|
|
233
|
+
rpName?: string;
|
|
234
|
+
/** The WebAuthn relying party id. @default the host of `origin`, else of the request */
|
|
235
|
+
rpId?: string;
|
|
236
|
+
};
|
|
53
237
|
};
|
|
54
238
|
/** `DevtoolsOptions` with every default applied. */
|
|
55
|
-
export type ResolvedDevtoolsOptions = Required<Pick<DevtoolsOptions, "path" | "maxRequests" | "nPlusOneThreshold">> & Pick<DevtoolsOptions, "allowedHosts" | "allowProxied">;
|
|
239
|
+
export type ResolvedDevtoolsOptions = Required<Pick<DevtoolsOptions, "path" | "maxRequests" | "nPlusOneThreshold">> & Pick<DevtoolsOptions, "allowedHosts" | "allowProxied" | "panels" | "production">;
|
|
240
|
+
/** HTTP methods a panel data route may answer. */
|
|
241
|
+
export type DevtoolsPanelMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
242
|
+
/** What a panel data route handler receives. */
|
|
243
|
+
export type DevtoolsPanelRequest = {
|
|
244
|
+
/** Path parameters, e.g. `{ name: "checkout" }` for the route path `/flows/:name`. */
|
|
245
|
+
params: Readonly<Record<string, string>>;
|
|
246
|
+
/** Query string values; a key given more than once is an array. */
|
|
247
|
+
query: Readonly<Record<string, string | readonly string[]>>;
|
|
248
|
+
/** The parsed request body; `undefined` when there is none. */
|
|
249
|
+
body: unknown;
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* One data route of a panel, served at `<path>/api/<panel id><route path>`
|
|
253
|
+
* behind the devtools guard. The handler's return value is sent as JSON with
|
|
254
|
+
* `Cache-Control: no-store`; `undefined` sends `204`. A thrown error with a
|
|
255
|
+
* numeric `statusCode` answers that status with `{ error: message }`.
|
|
256
|
+
*/
|
|
257
|
+
export type DevtoolsPanelRoute = {
|
|
258
|
+
/** @default "GET" */
|
|
259
|
+
method?: DevtoolsPanelMethod;
|
|
260
|
+
/** `""` for the panel's base URL, or a path starting with `/` (`"/search"`, `"/flows/:name"`). */
|
|
261
|
+
path: string;
|
|
262
|
+
handler: (request: DevtoolsPanelRequest) => unknown;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* A dashboard tab added through the devtools `panels` option.
|
|
266
|
+
*
|
|
267
|
+
* The tab shows `title`. Clicking it loads `view`, a browser ES module that
|
|
268
|
+
* devtools serves at `<path>/panels/<id>/view.js`; its default export renders
|
|
269
|
+
* the panel and calls the panel's `routes`.
|
|
270
|
+
*/
|
|
271
|
+
export type DevtoolsPanel = {
|
|
272
|
+
/** Lower-case letters, digits and dashes, starting with a letter. Names the tab, the URL segment and the hash route. */
|
|
273
|
+
id: string;
|
|
274
|
+
/** The tab label. */
|
|
275
|
+
title: string;
|
|
276
|
+
/** The view module: an absolute file path or a `file:` URL. */
|
|
277
|
+
view: string | URL;
|
|
278
|
+
/** Data routes the view calls. */
|
|
279
|
+
routes?: readonly DevtoolsPanelRoute[];
|
|
280
|
+
/**
|
|
281
|
+
* Whether the panel is safe to show in the production monitor. Without it
|
|
282
|
+
* the panel is left out in production unless the project sets
|
|
283
|
+
* `production.panels[<id>]: true`. In production its GET routes are open to
|
|
284
|
+
* viewers and every other method to admins only (with the CSRF check and an
|
|
285
|
+
* audit entry).
|
|
286
|
+
*
|
|
287
|
+
* @default false
|
|
288
|
+
*/
|
|
289
|
+
production?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* More files the view loads, by served name: `{ "graph.js": "/abs/graph.js" }`
|
|
292
|
+
* is served at `<path>/panels/<id>/graph.js`, so the view can
|
|
293
|
+
* `import "./graph.js"`. Names are plain file names (no folders).
|
|
294
|
+
*/
|
|
295
|
+
assets?: Readonly<Record<string, string | URL>>;
|
|
296
|
+
};
|
|
297
|
+
/** What a panel factory receives. */
|
|
298
|
+
export type DevtoolsPanelFactoryContext = {
|
|
299
|
+
/** The app's root directory. */
|
|
300
|
+
root: string;
|
|
301
|
+
/**
|
|
302
|
+
* Where the dashboard runs. In `production` a panel must not write files
|
|
303
|
+
* or run anything costly per request. Absent means `development`.
|
|
304
|
+
*/
|
|
305
|
+
mode?: DevtoolsMode;
|
|
306
|
+
};
|
|
307
|
+
/** One panel or several. */
|
|
308
|
+
export type DevtoolsPanels = DevtoolsPanel | readonly DevtoolsPanel[];
|
|
309
|
+
/**
|
|
310
|
+
* The default export of a module listed in the devtools `panels` option: a
|
|
311
|
+
* panel, a list of panels, or a function (sync or async) that returns either.
|
|
312
|
+
*/
|
|
313
|
+
export type DevtoolsPanelExport = DevtoolsPanels | ((context: DevtoolsPanelFactoryContext) => DevtoolsPanels | Promise<DevtoolsPanels>);
|
|
56
314
|
/** A source file position, as shown next to an N+1 warning. */
|
|
57
315
|
export type DevtoolsCallerLocation = {
|
|
58
316
|
/** Absolute path, forward slashes. */
|
|
@@ -176,6 +434,10 @@ export type DevtoolsRequestSummary = {
|
|
|
176
434
|
warningCount: number;
|
|
177
435
|
/** Read from the persisted request log only: the request is no longer in memory. */
|
|
178
436
|
persisted?: true;
|
|
437
|
+
/** The instance that served the request (production monitor). */
|
|
438
|
+
instance?: string;
|
|
439
|
+
/** Kept because it was slow or failed, without a timeline: the request was not sampled (production monitor). */
|
|
440
|
+
partial?: true;
|
|
179
441
|
};
|
|
180
442
|
/**
|
|
181
443
|
* `GET <path>/api/requests/:id`: the in-memory record, or one rebuilt from
|
|
@@ -205,6 +467,13 @@ export type DevtoolsBackground = {
|
|
|
205
467
|
};
|
|
206
468
|
/** Server-sent events on `GET <path>/api/stream`. */
|
|
207
469
|
export type DevtoolsStreamEvent = {
|
|
470
|
+
type: "hello";
|
|
471
|
+
data: {
|
|
472
|
+
mode: DevtoolsMode;
|
|
473
|
+
instance: string | null;
|
|
474
|
+
role: DevtoolsRole | null;
|
|
475
|
+
};
|
|
476
|
+
} | {
|
|
208
477
|
type: "request";
|
|
209
478
|
data: DevtoolsRequestSummary;
|
|
210
479
|
} | {
|
|
@@ -261,4 +530,5 @@ export type DevtoolsCollector = {
|
|
|
261
530
|
clear(): void;
|
|
262
531
|
};
|
|
263
532
|
//#endregion
|
|
533
|
+
export type { DEVTOOLS_BUILT_IN_PANELS, DEVTOOLS_FAILURE_AUDIT_TYPES, DEVTOOLS_LATENCY_BUCKETS_MS, DevtoolsAccountView, DevtoolsApiErrorBody, DevtoolsAuditEntry, DevtoolsAuditType, DevtoolsAuthStepResult, DevtoolsBuiltInPanelId, DevtoolsCaptureCounters, DevtoolsCreatedInvite, DevtoolsErrorCode, DevtoolsErrorGroup, DevtoolsErrorsView, DevtoolsExplainResult, DevtoolsHealthReport, DevtoolsHealthView, DevtoolsHistogram, DevtoolsInstanceInfo, DevtoolsInstanceReport, DevtoolsInstancesView, DevtoolsInviteView, DevtoolsJobsReport, DevtoolsJobsView, DevtoolsLogRow, DevtoolsLoginInput, DevtoolsLogsView, DevtoolsMode, DevtoolsPanelInfo, DevtoolsPasswordSource, DevtoolsQueryShapeRow, DevtoolsQueryShapeStats, DevtoolsQueryStatsView, DevtoolsRecoveryCodes, DevtoolsReportLogEntry, DevtoolsResourcePoint, DevtoolsResourceSnapshot, DevtoolsResourcesView, DevtoolsRole, DevtoolsRoutePhaseStats, DevtoolsRouteStats, DevtoolsRouteStatsRow, DevtoolsRouteStatsView, DevtoolsSampleDetail, DevtoolsSampleQuery, DevtoolsSampleSummary, DevtoolsScheduleInfo, DevtoolsSessionInfo, DevtoolsSessionStage, DevtoolsSessionView, DevtoolsTotpEnrolment, DevtoolsUserListView };
|
|
264
534
|
//# sourceMappingURL=types.d.mts.map
|
package/esm/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../packages/devtools/src/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../packages/devtools/src/types.ts"],"mappings":";;;;;;;;;;;;;;YAiBY;;;;;;EAMV;;;;;;EAMA;;;;;;;EAOA;;;;;;;;;;EAUA;;;;;;;;;EASA;;;;;;;;;;EAUA,4BAA4B;;;;;;;;;;;EAW5B,aAAa;;;;;;;YAQH;;;;;;;EAOV;;;;;;;EAOA;;;;;;;EAOA;;;;;;EAMA;;;;;;;EAOA;;;;;;EAMA;;;;;;EAMA;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;EAQA;;EAEA;;IAEE;;IAEA;;;;;;;EAOF;;EAEA;;IAEE;;IAEA;;IAEA;;IAEA;;IAEA;;;EAGF;;;;;;;IAOE;;;;;;;;;;EAUF,SAAS,SAAS;;;;;;EAMlB,qBAAqB;;;;;;EAMrB;;EAEA;;IAEE;;IAEA;;;;YAKQ,0BAA0B,SACpC,KAAK,kEAEL,KAAK;;YAGK;;YAGA;;EAEV,QAAQ,SAAS;;EAEjB,OAAO,SAAS;;EAEhB;;;;;;;;YASU;;EAEV,SAAS;;EAET;EACA,UAAU,SAAS;;;;;;;;;YAUT;;EAEV;;EAEA;;EAEA,eAAe;;EAEf,kBAAkB;;;;;;;;;;EAUlB;;;;;;EAMA,SAAS,SAAS,wBAAwB;;;YAIhC;;EAEV;;;;;EAKA,OAAO;;;YAIG,iBAAiB,yBAAyB;;;;;YAM1C,sBACR,mBACE,SAAS,gCAAgC,iBAAiB,QAAQ;;YAG5D;;EAEV;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA,QAAQ;;;YAIE;;EAEV;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;;;;;EAMA;;EAEA,SAAS;;;YAIC;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,aAAa;;;YAIH;EACV;EACA;EACA;;;YAIU;EACV;EACA;EACA;EACA;EACA,SAAS;;;YAIC;;EAEV;EACA;EACA;;EAEA;EACA;EACA;;EAEA;EACA;EACA,QAAQ;EACR,SAAS;EACT,OAAO;EACP,MAAM;;EAEN;EACA,UAAU;;;YAIA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;;;;;;YAQU,wBAAwB;EAClC;EACA,SAAS;;;YAIC;EACV;EACA;EACA;EACA;EACA;;;;;;YAOU;EACV,SAAS;EACT,OAAO;EACP,MAAM;;;YAII;EAEN;EACA;IAAQ,MAAM;IAAc;IAAyB,MAAM;;;EAE3D;EAAiB,MAAM;;EACvB;EAAc,MAAM;;EACpB;EAAa,MAAM;;EACnB;EAAY,MAAM;;EAClB;EAAqB,MAAM;;;YAGrB;;;;;;YAOA;EACV,aAAa;IACX;IACA;IACA;IACA;IACA;;;EAGF,WACE,YACA;IAAU;IAAiB;IAAoB;IAAgB;;EAEjE,SAAS,mBAAmB,OAAO;;EAEnC,SACE,+BACA,OAAO,KAAK,iCACX;EACH,kBAAkB,+BAA+B,WAAW;EAC5D,OAAO,+BAA+B,OAAO;EAC7C,QAAQ,MAAM;EACd,gBAAgB;EAChB,WAAW,aAAa;EACxB,aAAa;EACb,QAAQ,aAAa;EACrB,SAAS;IAAW,QAAQ;IAA2B;MAAoB;EAC3E,iBAAiB;EACjB,UAAU,WAAW,OAAO,+BAA+B;EAC3D"}
|
package/esm/ui-root.mjs
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { fileURLToPath } from "node:url";
|
|
2
|
-
import path from "node:path";
|
|
3
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
4
|
|
|
5
5
|
//#region ../../packages/devtools/src/ui-root.ts
|
|
6
6
|
let cachedUiRoot;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Whether `dir` is this package's root: it has the built dashboard
|
|
9
|
+
* (`ui/dashboard/index.html`) or, before the first build, the Processes panel
|
|
10
|
+
* view (`ui/panels/processes.js`), beside a `package.json` named
|
|
11
|
+
* `@warlock.js/devtools`.
|
|
12
|
+
*/
|
|
8
13
|
function isPackageRoot(dir) {
|
|
9
|
-
const
|
|
14
|
+
const hasUi = existsSync(path.join(dir, "ui", "dashboard", "index.html")) || existsSync(path.join(dir, "ui", "panels", "processes.js"));
|
|
10
15
|
const packageJson = path.join(dir, "package.json");
|
|
11
|
-
if (!
|
|
16
|
+
if (!hasUi || !existsSync(packageJson)) return false;
|
|
12
17
|
try {
|
|
13
18
|
return JSON.parse(readFileSync(packageJson, "utf8")).name === "@warlock.js/devtools";
|
|
14
19
|
} catch {
|
|
@@ -30,7 +35,7 @@ function resolveUiRoot() {
|
|
|
30
35
|
return cachedUiRoot;
|
|
31
36
|
}
|
|
32
37
|
const parent = path.dirname(dir);
|
|
33
|
-
if (parent === dir) throw new Error("Could not locate the devtools UI directory: no ancestor of this module has
|
|
38
|
+
if (parent === dir) throw new Error("Could not locate the devtools UI directory: no ancestor of this module has ui/dashboard/index.html or ui/panels/processes.js beside a package.json named @warlock.js/devtools.");
|
|
34
39
|
dir = parent;
|
|
35
40
|
}
|
|
36
41
|
}
|
package/esm/ui-root.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-root.mjs","names":[],"sources":["../../../../../../../packages/devtools/src/ui-root.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nlet cachedUiRoot: string | undefined;\n\n
|
|
1
|
+
{"version":3,"file":"ui-root.mjs","names":[],"sources":["../../../../../../../packages/devtools/src/ui-root.ts"],"sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nlet cachedUiRoot: string | undefined;\n\n/**\n * Whether `dir` is this package's root: it has the built dashboard\n * (`ui/dashboard/index.html`) or, before the first build, the Processes panel\n * view (`ui/panels/processes.js`), beside a `package.json` named\n * `@warlock.js/devtools`.\n */\nfunction isPackageRoot(dir: string): boolean {\n const hasUi =\n existsSync(path.join(dir, \"ui\", \"dashboard\", \"index.html\")) ||\n existsSync(path.join(dir, \"ui\", \"panels\", \"processes.js\"));\n const packageJson = path.join(dir, \"package.json\");\n\n if (!hasUi || !existsSync(packageJson)) {\n return false;\n }\n\n try {\n const parsed = JSON.parse(readFileSync(packageJson, \"utf8\")) as { name?: string };\n return parsed.name === \"@warlock.js/devtools\";\n } catch {\n return false;\n }\n}\n\n/**\n * Locate this package's `ui/` directory by walking up from the current\n * module's directory. Works from `src/` in development and from the built\n * `esm/`/`cjs/` output, since both sit beside `ui/` and `package.json` at\n * the package root.\n */\nexport function resolveUiRoot(): string {\n if (cachedUiRoot) {\n return cachedUiRoot;\n }\n\n let dir = path.dirname(fileURLToPath(import.meta.url));\n\n while (true) {\n if (isPackageRoot(dir)) {\n cachedUiRoot = path.join(dir, \"ui\");\n return cachedUiRoot;\n }\n\n const parent = path.dirname(dir);\n if (parent === dir) {\n throw new Error(\n \"Could not locate the devtools UI directory: no ancestor of \" +\n \"this module has ui/dashboard/index.html or ui/panels/processes.js beside a package.json named \" +\n \"@warlock.js/devtools.\",\n );\n }\n\n dir = parent;\n }\n}\n"],"mappings":";;;;;AAIA,IAAI;;;;;;;AAQJ,SAAS,cAAc,KAAsB;CAC3C,MAAM,QACJ,WAAW,KAAK,KAAK,KAAK,MAAM,aAAa,YAAY,CAAC,KAC1D,WAAW,KAAK,KAAK,KAAK,MAAM,UAAU,cAAc,CAAC;CAC3D,MAAM,cAAc,KAAK,KAAK,KAAK,cAAc;CAEjD,IAAI,CAAC,SAAS,CAAC,WAAW,WAAW,GACnC,OAAO;CAGT,IAAI;EAEF,OADe,KAAK,MAAM,aAAa,aAAa,MAAM,CAC9C,CAAC,CAAC,SAAS;CACzB,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;AAQA,SAAgB,gBAAwB;CACtC,IAAI,cACF,OAAO;CAGT,IAAI,MAAM,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;CAErD,OAAO,MAAM;EACX,IAAI,cAAc,GAAG,GAAG;GACtB,eAAe,KAAK,KAAK,KAAK,IAAI;GAClC,OAAO;EACT;EAEA,MAAM,SAAS,KAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KACb,MAAM,IAAI,MACR,gLAGF;EAGF,MAAM;CACR;AACF"}
|