@warlock.js/devtools 5.55.0 → 5.57.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 +52 -0
- package/README.md +26 -13
- package/cjs/ai-source-DTpxumMA.cjs +381 -0
- package/cjs/ai-source-DTpxumMA.cjs.map +1 -0
- package/cjs/auth-DzU0gHDG.cjs +1655 -0
- package/cjs/auth-DzU0gHDG.cjs.map +1 -0
- package/cjs/boot-Dy5OqgTM.cjs +138 -0
- package/cjs/boot-Dy5OqgTM.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-DCfXQvw-.cjs +870 -0
- package/cjs/http-DCfXQvw-.cjs.map +1 -0
- package/cjs/index.cjs +2 -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-Rcmeitu3.cjs +318 -0
- package/cjs/panels-Rcmeitu3.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-ykxsOwob.cjs +184 -0
- package/cjs/server-ykxsOwob.cjs.map +1 -0
- package/cjs/{src-Xwm3Eel9.cjs → src-UPtTCI2j.cjs} +210 -293
- package/cjs/src-UPtTCI2j.cjs.map +1 -0
- package/cjs/store-aq207T8v.cjs +9 -0
- package/cjs/stream-route-CJTABkUy.cjs +875 -0
- package/cjs/stream-route-CJTABkUy.cjs.map +1 -0
- package/esm/devtools-connector.d.mts +16 -13
- package/esm/devtools-connector.d.mts.map +1 -1
- package/esm/devtools-connector.mjs +127 -18
- package/esm/devtools-connector.mjs.map +1 -1
- package/esm/index.d.mts +4 -2
- package/esm/index.mjs +2 -1
- package/esm/options.mjs +2 -1
- package/esm/options.mjs.map +1 -1
- package/esm/panel-tokens.d.mts +13 -0
- package/esm/panel-tokens.d.mts.map +1 -0
- package/esm/panel-tokens.mjs +45 -0
- package/esm/panel-tokens.mjs.map +1 -0
- package/esm/panels.mjs +73 -8
- package/esm/panels.mjs.map +1 -1
- package/esm/production/auth/common-passwords.mjs +303 -0
- package/esm/production/auth/common-passwords.mjs.map +1 -0
- package/esm/production/auth/default-crypto.mjs +19 -0
- package/esm/production/auth/default-crypto.mjs.map +1 -0
- package/esm/production/auth/helpers.mjs +77 -0
- package/esm/production/auth/helpers.mjs.map +1 -0
- package/esm/production/auth/index.mjs +6 -0
- package/esm/production/auth/passkeys.mjs +96 -0
- package/esm/production/auth/passkeys.mjs.map +1 -0
- package/esm/production/auth/service.mjs +1166 -0
- package/esm/production/auth/service.mjs.map +1 -0
- package/esm/production/boot.mjs +138 -0
- package/esm/production/boot.mjs.map +1 -0
- package/esm/production/capture/dev-stats.mjs +83 -0
- package/esm/production/capture/dev-stats.mjs.map +1 -0
- package/esm/production/capture/engine.mjs +442 -0
- package/esm/production/capture/engine.mjs.map +1 -0
- package/esm/production/capture/explain.mjs +271 -0
- package/esm/production/capture/explain.mjs.map +1 -0
- package/esm/production/capture/filter.mjs +24 -0
- package/esm/production/capture/filter.mjs.map +1 -0
- package/esm/production/capture/index.mjs +7 -0
- package/esm/production/capture/production-capture.mjs +134 -0
- package/esm/production/capture/production-capture.mjs.map +1 -0
- package/esm/production/capture/redact.mjs +109 -0
- package/esm/production/capture/redact.mjs.map +1 -0
- package/esm/production/capture/stats-stores.mjs +300 -0
- package/esm/production/capture/stats-stores.mjs.map +1 -0
- package/esm/production/cli/actions.mjs +151 -0
- package/esm/production/cli/actions.mjs.map +1 -0
- package/esm/production/cli/index.d.mts +17 -0
- package/esm/production/cli/index.d.mts.map +1 -0
- package/esm/production/cli/index.mjs +86 -0
- package/esm/production/cli/index.mjs.map +1 -0
- package/esm/production/contracts.d.mts +592 -0
- package/esm/production/contracts.d.mts.map +1 -0
- package/esm/production/contracts.mjs +95 -0
- package/esm/production/contracts.mjs.map +1 -0
- package/esm/production/errors.d.mts +31 -0
- package/esm/production/errors.d.mts.map +1 -0
- package/esm/production/errors.mjs +142 -0
- package/esm/production/errors.mjs.map +1 -0
- package/esm/production/http/access.mjs +124 -0
- package/esm/production/http/access.mjs.map +1 -0
- package/esm/production/http/auth-routes.mjs +280 -0
- package/esm/production/http/auth-routes.mjs.map +1 -0
- package/esm/production/http/client.mjs +57 -0
- package/esm/production/http/client.mjs.map +1 -0
- package/esm/production/http/constants.mjs +11 -0
- package/esm/production/http/constants.mjs.map +1 -0
- package/esm/production/http/context.mjs +14 -0
- package/esm/production/http/context.mjs.map +1 -0
- package/esm/production/http/cookie.mjs +39 -0
- package/esm/production/http/cookie.mjs.map +1 -0
- package/esm/production/http/headers.mjs +25 -0
- package/esm/production/http/headers.mjs.map +1 -0
- package/esm/production/http/index.mjs +10 -0
- package/esm/production/http/ip.mjs +130 -0
- package/esm/production/http/ip.mjs.map +1 -0
- package/esm/production/http/mount.mjs +300 -0
- package/esm/production/http/mount.mjs.map +1 -0
- package/esm/production/http/state.mjs +54 -0
- package/esm/production/http/state.mjs.map +1 -0
- package/esm/production/index.d.mts +6 -0
- package/esm/production/index.mjs +5 -0
- package/esm/production/insights/cap-report.mjs +67 -0
- package/esm/production/insights/cap-report.mjs.map +1 -0
- package/esm/production/insights/health.mjs +88 -0
- package/esm/production/insights/health.mjs.map +1 -0
- package/esm/production/insights/index.mjs +10 -0
- package/esm/production/insights/insights.mjs +167 -0
- package/esm/production/insights/insights.mjs.map +1 -0
- package/esm/production/insights/instance.mjs +24 -0
- package/esm/production/insights/instance.mjs.map +1 -0
- package/esm/production/insights/jobs.mjs +100 -0
- package/esm/production/insights/jobs.mjs.map +1 -0
- package/esm/production/insights/reporter.mjs +59 -0
- package/esm/production/insights/reporter.mjs.map +1 -0
- package/esm/production/insights/resources.mjs +139 -0
- package/esm/production/insights/resources.mjs.map +1 -0
- package/esm/production/insights/writer.mjs +72 -0
- package/esm/production/insights/writer.mjs.map +1 -0
- package/esm/production/openapi.mjs +52 -0
- package/esm/production/openapi.mjs.map +1 -0
- package/esm/production/options.d.mts +60 -0
- package/esm/production/options.d.mts.map +1 -0
- package/esm/production/options.mjs +170 -0
- package/esm/production/options.mjs.map +1 -0
- package/esm/production/stats/histogram.mjs +67 -0
- package/esm/production/stats/histogram.mjs.map +1 -0
- package/esm/production/stats/merge.mjs +106 -0
- package/esm/production/stats/merge.mjs.map +1 -0
- package/esm/production/store/cascade-store.mjs +322 -0
- package/esm/production/store/cascade-store.mjs.map +1 -0
- package/esm/production/store/index.mjs +5 -0
- package/esm/production/store/mapping.mjs +258 -0
- package/esm/production/store/mapping.mjs.map +1 -0
- package/esm/production/store/memory-store.mjs +291 -0
- package/esm/production/store/memory-store.mjs.map +1 -0
- package/esm/production/store/migrations.d.mts +11 -0
- package/esm/production/store/migrations.d.mts.map +1 -0
- package/esm/production/store/migrations.mjs +29 -0
- package/esm/production/store/migrations.mjs.map +1 -0
- package/esm/production/store/models/account.migration.mjs +34 -0
- package/esm/production/store/models/account.migration.mjs.map +1 -0
- package/esm/production/store/models/account.model.mjs +13 -0
- package/esm/production/store/models/account.model.mjs.map +1 -0
- package/esm/production/store/models/audit.migration.mjs +30 -0
- package/esm/production/store/models/audit.migration.mjs.map +1 -0
- package/esm/production/store/models/audit.model.mjs +13 -0
- package/esm/production/store/models/audit.model.mjs.map +1 -0
- package/esm/production/store/models/base.mjs +27 -0
- package/esm/production/store/models/base.mjs.map +1 -0
- package/esm/production/store/models/index.mjs +17 -0
- package/esm/production/store/models/invite.migration.mjs +26 -0
- package/esm/production/store/models/invite.migration.mjs.map +1 -0
- package/esm/production/store/models/invite.model.mjs +13 -0
- package/esm/production/store/models/invite.model.mjs.map +1 -0
- package/esm/production/store/models/report.migration.mjs +20 -0
- package/esm/production/store/models/report.migration.mjs.map +1 -0
- package/esm/production/store/models/report.model.mjs +13 -0
- package/esm/production/store/models/report.model.mjs.map +1 -0
- package/esm/production/store/models/sample.migration.mjs +25 -0
- package/esm/production/store/models/sample.migration.mjs.map +1 -0
- package/esm/production/store/models/sample.model.mjs +13 -0
- package/esm/production/store/models/sample.model.mjs.map +1 -0
- package/esm/production/store/models/session.migration.mjs +31 -0
- package/esm/production/store/models/session.migration.mjs.map +1 -0
- package/esm/production/store/models/session.model.mjs +13 -0
- package/esm/production/store/models/session.model.mjs.map +1 -0
- package/esm/production/store/models/state.migration.mjs +26 -0
- package/esm/production/store/models/state.migration.mjs.map +1 -0
- package/esm/production/store/models/state.model.mjs +13 -0
- package/esm/production/store/models/state.model.mjs.map +1 -0
- package/esm/query-shape.mjs +14 -1
- package/esm/query-shape.mjs.map +1 -1
- package/esm/server/explain-route.mjs +26 -1
- package/esm/server/explain-route.mjs.map +1 -1
- package/esm/server/index.mjs +9 -4
- package/esm/server/index.mjs.map +1 -1
- package/esm/server/insights-routes.mjs +62 -0
- package/esm/server/insights-routes.mjs.map +1 -0
- package/esm/server/log-routes.mjs +32 -5
- package/esm/server/log-routes.mjs.map +1 -1
- package/esm/server/openapi-routes.mjs +3 -2
- package/esm/server/openapi-routes.mjs.map +1 -1
- package/esm/server/requests-routes.mjs +125 -0
- package/esm/server/requests-routes.mjs.map +1 -1
- package/esm/server/session-routes.mjs +42 -0
- package/esm/server/session-routes.mjs.map +1 -0
- package/esm/server/stream-route.mjs +81 -11
- package/esm/server/stream-route.mjs.map +1 -1
- package/esm/server/ui-assets.mjs +34 -25
- package/esm/server/ui-assets.mjs.map +1 -1
- package/esm/sources/log-source.mjs +14 -1
- package/esm/sources/log-source.mjs.map +1 -1
- package/esm/types.d.mts +208 -3
- package/esm/types.d.mts.map +1 -1
- package/esm/ui-root.mjs +9 -4
- package/esm/ui-root.mjs.map +1 -1
- package/llms-full.txt +166 -21
- package/llms.txt +2 -2
- package/package.json +32 -8
- package/skills/SKILL.md +166 -21
- package/ui/dashboard/assets/app.css +3 -0
- package/ui/dashboard/assets/app.js +50 -0
- package/ui/dashboard/build-info.json +21 -0
- package/ui/dashboard/index.html +16 -0
- package/ui/panels/processes.js +12 -3
- package/cjs/ai-source-Dz_3tlZ5.cjs +0 -703
- package/cjs/ai-source-Dz_3tlZ5.cjs.map +0 -1
- package/cjs/server-B11ShQYE.cjs +0 -628
- package/cjs/server-B11ShQYE.cjs.map +0 -1
- package/cjs/src-Xwm3Eel9.cjs.map +0 -1
- package/ui/app.css +0 -376
- package/ui/app.js +0 -1158
- package/ui/index.html +0 -28
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
let node_fs_promises = require("node:fs/promises");
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/devtools/src/production/openapi.ts
|
|
4
|
+
/**
|
|
5
|
+
* The API tab's documents under `warlock start`. Only `warlock dev` registers
|
|
6
|
+
* core's development provider, so production builds the OpenAPI document
|
|
7
|
+
* itself from the routes this process registered, with core's own builder.
|
|
8
|
+
* Resource schemas keep generic names (`Resource1`, …) because production has
|
|
9
|
+
* no source files to read their export names from. Built once per process: the
|
|
10
|
+
* routes do not change after boot; a failed build is tried again next time.
|
|
11
|
+
*/
|
|
12
|
+
function createProductionOpenApi(core) {
|
|
13
|
+
let built;
|
|
14
|
+
const build = async () => {
|
|
15
|
+
const pkg = await readAppPackage(core.rootPath("package.json"));
|
|
16
|
+
const baseUrl = core.config.get("app.baseUrl");
|
|
17
|
+
const { document } = core.buildOpenApiDocument(core.router.list(), {
|
|
18
|
+
info: {
|
|
19
|
+
title: typeof pkg.name === "string" && pkg.name ? pkg.name : "Warlock API",
|
|
20
|
+
version: typeof pkg.version === "string" && pkg.version ? pkg.version : "0.0.0",
|
|
21
|
+
...typeof pkg.description === "string" && pkg.description ? { description: pkg.description } : {}
|
|
22
|
+
},
|
|
23
|
+
...typeof baseUrl === "string" && baseUrl ? { servers: [baseUrl] } : {},
|
|
24
|
+
validationResponse: core.config.get("validation.response", {})
|
|
25
|
+
});
|
|
26
|
+
return document;
|
|
27
|
+
};
|
|
28
|
+
const getOpenApiDocument = () => {
|
|
29
|
+
const current = built ?? build();
|
|
30
|
+
built = current;
|
|
31
|
+
current.catch(() => {
|
|
32
|
+
if (built === current) built = void 0;
|
|
33
|
+
});
|
|
34
|
+
return current;
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
getOpenApiDocument,
|
|
38
|
+
getPostmanCollection: async () => core.openApiToPostmanCollection(await getOpenApiDocument())
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function readAppPackage(file) {
|
|
42
|
+
try {
|
|
43
|
+
const parsed = JSON.parse(await (0, node_fs_promises.readFile)(file, "utf8"));
|
|
44
|
+
return parsed !== null && typeof parsed === "object" ? parsed : {};
|
|
45
|
+
} catch {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.createProductionOpenApi = createProductionOpenApi;
|
|
52
|
+
//# sourceMappingURL=openapi-CC7OAUc6.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-CC7OAUc6.cjs","names":["readFile"],"sources":["../../../../../../../packages/devtools/src/production/openapi.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\n\ntype Core = typeof import(\"@warlock.js/core\");\n\n/**\n * The API tab's documents under `warlock start`. Only `warlock dev` registers\n * core's development provider, so production builds the OpenAPI document\n * itself from the routes this process registered, with core's own builder.\n * Resource schemas keep generic names (`Resource1`, …) because production has\n * no source files to read their export names from. Built once per process: the\n * routes do not change after boot; a failed build is tried again next time.\n */\nexport function createProductionOpenApi(\n core: Pick<\n Core,\n \"router\" | \"buildOpenApiDocument\" | \"openApiToPostmanCollection\" | \"config\" | \"rootPath\"\n >,\n): { getOpenApiDocument: () => Promise<object>; getPostmanCollection: () => Promise<object> } {\n let built: Promise<object> | undefined;\n\n const build = async (): Promise<object> => {\n const pkg = await readAppPackage(core.rootPath(\"package.json\"));\n const baseUrl: unknown = core.config.get(\"app.baseUrl\");\n const { document } = core.buildOpenApiDocument(core.router.list(), {\n info: {\n title: typeof pkg.name === \"string\" && pkg.name ? pkg.name : \"Warlock API\",\n version: typeof pkg.version === \"string\" && pkg.version ? pkg.version : \"0.0.0\",\n ...(typeof pkg.description === \"string\" && pkg.description\n ? { description: pkg.description }\n : {}),\n },\n ...(typeof baseUrl === \"string\" && baseUrl ? { servers: [baseUrl] } : {}),\n validationResponse: core.config.get(\"validation.response\", {}),\n });\n\n return document;\n };\n\n const getOpenApiDocument = (): Promise<object> => {\n const current = built ?? build();\n\n built = current;\n current.catch(() => {\n if (built === current) built = undefined;\n });\n\n return current;\n };\n\n return {\n getOpenApiDocument,\n getPostmanCollection: async () =>\n core.openApiToPostmanCollection(\n (await getOpenApiDocument()) as Parameters<Core[\"openApiToPostmanCollection\"]>[0],\n ),\n };\n}\n\nasync function readAppPackage(file: string): Promise<Record<string, unknown>> {\n try {\n const parsed: unknown = JSON.parse(await readFile(file, \"utf8\"));\n\n return parsed !== null && typeof parsed === \"object\" ? (parsed as Record<string, unknown>) : {};\n } catch {\n return {};\n }\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,wBACd,MAI4F;CAC5F,IAAI;CAEJ,MAAM,QAAQ,YAA6B;EACzC,MAAM,MAAM,MAAM,eAAe,KAAK,SAAS,cAAc,CAAC;EAC9D,MAAM,UAAmB,KAAK,OAAO,IAAI,aAAa;EACtD,MAAM,EAAE,aAAa,KAAK,qBAAqB,KAAK,OAAO,KAAK,GAAG;GACjE,MAAM;IACJ,OAAO,OAAO,IAAI,SAAS,YAAY,IAAI,OAAO,IAAI,OAAO;IAC7D,SAAS,OAAO,IAAI,YAAY,YAAY,IAAI,UAAU,IAAI,UAAU;IACxE,GAAI,OAAO,IAAI,gBAAgB,YAAY,IAAI,cAC3C,EAAE,aAAa,IAAI,YAAY,IAC/B,CAAC;GACP;GACA,GAAI,OAAO,YAAY,YAAY,UAAU,EAAE,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC;GACvE,oBAAoB,KAAK,OAAO,IAAI,uBAAuB,CAAC,CAAC;EAC/D,CAAC;EAED,OAAO;CACT;CAEA,MAAM,2BAA4C;EAChD,MAAM,UAAU,SAAS,MAAM;EAE/B,QAAQ;EACR,QAAQ,YAAY;GAClB,IAAI,UAAU,SAAS,QAAQ;EACjC,CAAC;EAED,OAAO;CACT;CAEA,OAAO;EACL;EACA,sBAAsB,YACpB,KAAK,2BACF,MAAM,mBAAmB,CAC5B;CACJ;AACF;AAEA,eAAe,eAAe,MAAgD;CAC5E,IAAI;EACF,MAAM,SAAkB,KAAK,MAAM,UAAMA,2BAAS,MAAM,MAAM,CAAC;EAE/D,OAAO,WAAW,QAAQ,OAAO,WAAW,WAAY,SAAqC,CAAC;CAChG,QAAQ;EACN,OAAO,CAAC;CACV;AACF"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
const require_errors = require("./errors-CyZp5yS-.cjs");
|
|
2
|
+
const require_ip = require("./ip-DbNhPOzi.cjs");
|
|
3
|
+
|
|
4
|
+
//#region ../../packages/devtools/src/production/options.ts
|
|
5
|
+
/** The defaults `resolveProductionOptions` applies (environment values excluded). */
|
|
6
|
+
const DEVTOOLS_PRODUCTION_DEFAULTS = {
|
|
7
|
+
sampleRate: .1,
|
|
8
|
+
slowRequestMs: 1e3,
|
|
9
|
+
slowQueryMs: 200,
|
|
10
|
+
maxRequests: 200,
|
|
11
|
+
maxQueriesPerRequest: 200,
|
|
12
|
+
maxShapes: 500,
|
|
13
|
+
maxRoutes: 300,
|
|
14
|
+
maxErrorGroups: 100,
|
|
15
|
+
requestRetentionHours: 24,
|
|
16
|
+
maxStoredSamplesPerMinute: 120,
|
|
17
|
+
reportIntervalMs: 1e4,
|
|
18
|
+
requireHttps: true,
|
|
19
|
+
session: {
|
|
20
|
+
idleMinutes: 30,
|
|
21
|
+
maxHours: 8,
|
|
22
|
+
pendingMinutes: 10
|
|
23
|
+
},
|
|
24
|
+
twoFactor: "admins",
|
|
25
|
+
rateLimits: {
|
|
26
|
+
windowMinutes: 15,
|
|
27
|
+
account: 5,
|
|
28
|
+
ip: 20,
|
|
29
|
+
global: 100,
|
|
30
|
+
lockMinutes: 15
|
|
31
|
+
},
|
|
32
|
+
explain: { executing: false },
|
|
33
|
+
logLevels: ["warn", "error"],
|
|
34
|
+
auditRetentionDays: 90,
|
|
35
|
+
passkeys: { rpName: "Warlock monitor" }
|
|
36
|
+
};
|
|
37
|
+
/** The environment variables production mode reads. */
|
|
38
|
+
const DEVTOOLS_ENV = {
|
|
39
|
+
path: "DEVTOOLS_PATH",
|
|
40
|
+
adminEmail: "DEVTOOLS_ADMIN_EMAIL",
|
|
41
|
+
adminPassword: "DEVTOOLS_ADMIN_PASSWORD",
|
|
42
|
+
setupToken: "DEVTOOLS_SETUP_TOKEN"
|
|
43
|
+
};
|
|
44
|
+
const LOG_LEVELS = [
|
|
45
|
+
"debug",
|
|
46
|
+
"info",
|
|
47
|
+
"warn",
|
|
48
|
+
"error",
|
|
49
|
+
"success"
|
|
50
|
+
];
|
|
51
|
+
const PATH_CHARACTERS = /^[A-Za-z0-9._~/-]+$/;
|
|
52
|
+
const MIN_PATH_LENGTH = 8;
|
|
53
|
+
const MIN_SETUP_TOKEN_LENGTH = 32;
|
|
54
|
+
function invalid(option, expected) {
|
|
55
|
+
throw new require_errors.DevtoolsProductionConfigError("DT007", `Option "devtools.production.${option}" is not valid: ${expected}.`);
|
|
56
|
+
}
|
|
57
|
+
function present(value) {
|
|
58
|
+
return value === void 0 || value === "" ? null : value;
|
|
59
|
+
}
|
|
60
|
+
function integerAtLeastOne(option, value, fallback) {
|
|
61
|
+
if (value === void 0) return fallback;
|
|
62
|
+
if (!Number.isInteger(value) || value < 1) invalid(option, "use a whole number of 1 or more");
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
function networkList(option, value) {
|
|
66
|
+
if (value === void 0) return [];
|
|
67
|
+
if (!Array.isArray(value)) invalid(option, "use a list of IPs, CIDR ranges, \"loopback\" or \"private\"");
|
|
68
|
+
for (const entry of value) if (!require_ip.isValidNetworkEntry(entry)) invalid(option, `"${String(entry)}" is not an IP, a CIDR range, "loopback" or "private"`);
|
|
69
|
+
return [...value];
|
|
70
|
+
}
|
|
71
|
+
/** The dashboard path without a trailing slash, or a DT001/DT002 error. */
|
|
72
|
+
function resolvePath(value) {
|
|
73
|
+
const given = present(value);
|
|
74
|
+
if (given === null) throw new require_errors.DevtoolsProductionConfigError("DT001");
|
|
75
|
+
const path = given.replace(/\/+$/, "");
|
|
76
|
+
const segments = path.split("/").slice(1);
|
|
77
|
+
const lower = path.toLowerCase();
|
|
78
|
+
if (!path.startsWith("/") || path.length < MIN_PATH_LENGTH || !PATH_CHARACTERS.test(path) || segments.some((segment) => segment === "" || segment === "." || segment === "..") || lower === "/__warlock" || lower.startsWith("/__warlock/")) throw new require_errors.DevtoolsProductionConfigError("DT002");
|
|
79
|
+
return path;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Applies the defaults to `options`, reads the path and first admin from
|
|
83
|
+
* `env`, and validates everything.
|
|
84
|
+
*
|
|
85
|
+
* Throws `DevtoolsProductionConfigError`: DT001 (no path), DT002 (bad path),
|
|
86
|
+
* DT007 (an option out of range: sampleRate outside 0–1, a non-positive
|
|
87
|
+
* limit, an unknown twoFactor value, a bad CIDR, an origin that is not
|
|
88
|
+
* `https://host[:port]`), DT009 (both a password and a setup token), DT010
|
|
89
|
+
* (setup token shorter than 32 characters). DT003/DT004 (admin) are checked
|
|
90
|
+
* later by `ensureFirstAdmin`, which needs the database.
|
|
91
|
+
*/
|
|
92
|
+
function resolveProductionOptions(options, env) {
|
|
93
|
+
const given = options ?? {};
|
|
94
|
+
const defaults = DEVTOOLS_PRODUCTION_DEFAULTS;
|
|
95
|
+
const path = resolvePath(given.path ?? env[DEVTOOLS_ENV.path]);
|
|
96
|
+
const sampleRate = given.sampleRate ?? defaults.sampleRate;
|
|
97
|
+
if (typeof sampleRate !== "number" || !Number.isFinite(sampleRate) || sampleRate < 0 || sampleRate > 1) invalid("sampleRate", "use a number from 0 to 1");
|
|
98
|
+
const requireHttps = given.requireHttps ?? defaults.requireHttps;
|
|
99
|
+
if (typeof requireHttps !== "boolean") invalid("requireHttps", "use true or false");
|
|
100
|
+
const twoFactor = given.twoFactor ?? defaults.twoFactor;
|
|
101
|
+
if (twoFactor !== "admins" && twoFactor !== "everyone") invalid("twoFactor", "use \"admins\" or \"everyone\"");
|
|
102
|
+
const origin = given.origin ?? null;
|
|
103
|
+
if (origin !== null) {
|
|
104
|
+
if (typeof origin !== "string" || !(requireHttps ? /^https:\/\/[^/\s]+$/ : /^https?:\/\/[^/\s]+$/).test(origin)) invalid("origin", requireHttps ? "use an origin such as https://app.example.com, without a path or a trailing slash" : "use an origin such as http://localhost:3000, without a path or a trailing slash");
|
|
105
|
+
}
|
|
106
|
+
const panels = given.panels ?? {};
|
|
107
|
+
if (panels === null || typeof panels !== "object" || Array.isArray(panels)) invalid("panels", "use an object of tab ids and true or false");
|
|
108
|
+
for (const [id, enabled] of Object.entries(panels)) if (typeof enabled !== "boolean") invalid(`panels.${id}`, "use true or false");
|
|
109
|
+
const logLevels = given.logLevels ?? defaults.logLevels;
|
|
110
|
+
if (!Array.isArray(logLevels) || logLevels.some((level) => !LOG_LEVELS.includes(level))) invalid("logLevels", `use a list of ${LOG_LEVELS.join(", ")}`);
|
|
111
|
+
const executing = given.explain?.executing ?? defaults.explain.executing;
|
|
112
|
+
if (typeof executing !== "boolean") invalid("explain.executing", "use true or false");
|
|
113
|
+
const rpName = given.passkeys?.rpName ?? defaults.passkeys.rpName;
|
|
114
|
+
const rpId = given.passkeys?.rpId ?? null;
|
|
115
|
+
if (typeof rpName !== "string" || rpName.trim() === "") invalid("passkeys.rpName", "use a non-empty name");
|
|
116
|
+
if (rpId !== null && (typeof rpId !== "string" || rpId.trim() === "")) invalid("passkeys.rpId", "use a host name such as app.example.com");
|
|
117
|
+
const limits = given.rateLimits ?? {};
|
|
118
|
+
const session = given.session ?? {};
|
|
119
|
+
const resolved = {
|
|
120
|
+
path,
|
|
121
|
+
admin: {
|
|
122
|
+
email: present(env[DEVTOOLS_ENV.adminEmail]),
|
|
123
|
+
password: present(env[DEVTOOLS_ENV.adminPassword]),
|
|
124
|
+
setupToken: present(env[DEVTOOLS_ENV.setupToken])
|
|
125
|
+
},
|
|
126
|
+
sampleRate,
|
|
127
|
+
slowRequestMs: integerAtLeastOne("slowRequestMs", given.slowRequestMs, defaults.slowRequestMs),
|
|
128
|
+
slowQueryMs: integerAtLeastOne("slowQueryMs", given.slowQueryMs, defaults.slowQueryMs),
|
|
129
|
+
maxRequests: integerAtLeastOne("maxRequests", given.maxRequests, defaults.maxRequests),
|
|
130
|
+
maxQueriesPerRequest: defaults.maxQueriesPerRequest,
|
|
131
|
+
maxShapes: defaults.maxShapes,
|
|
132
|
+
maxRoutes: defaults.maxRoutes,
|
|
133
|
+
maxErrorGroups: defaults.maxErrorGroups,
|
|
134
|
+
requestRetentionHours: integerAtLeastOne("requestRetentionHours", given.requestRetentionHours, defaults.requestRetentionHours),
|
|
135
|
+
maxStoredSamplesPerMinute: integerAtLeastOne("maxStoredSamplesPerMinute", given.maxStoredSamplesPerMinute, defaults.maxStoredSamplesPerMinute),
|
|
136
|
+
reportIntervalMs: integerAtLeastOne("reportIntervalMs", given.reportIntervalMs, defaults.reportIntervalMs),
|
|
137
|
+
trustedProxies: networkList("trustedProxies", given.trustedProxies),
|
|
138
|
+
requireHttps,
|
|
139
|
+
allowedIps: networkList("allowedIps", given.allowedIps),
|
|
140
|
+
origin,
|
|
141
|
+
session: {
|
|
142
|
+
idleMinutes: integerAtLeastOne("session.idleMinutes", session.idleMinutes, defaults.session.idleMinutes),
|
|
143
|
+
maxHours: integerAtLeastOne("session.maxHours", session.maxHours, defaults.session.maxHours),
|
|
144
|
+
pendingMinutes: defaults.session.pendingMinutes
|
|
145
|
+
},
|
|
146
|
+
twoFactor,
|
|
147
|
+
rateLimits: {
|
|
148
|
+
windowMinutes: integerAtLeastOne("rateLimits.windowMinutes", limits.windowMinutes, defaults.rateLimits.windowMinutes),
|
|
149
|
+
account: integerAtLeastOne("rateLimits.account", limits.account, defaults.rateLimits.account),
|
|
150
|
+
ip: integerAtLeastOne("rateLimits.ip", limits.ip, defaults.rateLimits.ip),
|
|
151
|
+
global: integerAtLeastOne("rateLimits.global", limits.global, defaults.rateLimits.global),
|
|
152
|
+
lockMinutes: integerAtLeastOne("rateLimits.lockMinutes", limits.lockMinutes, defaults.rateLimits.lockMinutes)
|
|
153
|
+
},
|
|
154
|
+
explain: { executing },
|
|
155
|
+
panels: { ...panels },
|
|
156
|
+
logLevels: [...logLevels],
|
|
157
|
+
auditRetentionDays: integerAtLeastOne("auditRetentionDays", given.auditRetentionDays, defaults.auditRetentionDays),
|
|
158
|
+
passkeys: {
|
|
159
|
+
rpName,
|
|
160
|
+
rpId
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
if (resolved.admin.password !== null && resolved.admin.setupToken !== null) throw new require_errors.DevtoolsProductionConfigError("DT009");
|
|
164
|
+
if (resolved.admin.setupToken !== null && resolved.admin.setupToken.length < MIN_SETUP_TOKEN_LENGTH) throw new require_errors.DevtoolsProductionConfigError("DT010");
|
|
165
|
+
return resolved;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
//#endregion
|
|
169
|
+
Object.defineProperty(exports, "DEVTOOLS_PRODUCTION_DEFAULTS", {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function () {
|
|
172
|
+
return DEVTOOLS_PRODUCTION_DEFAULTS;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
Object.defineProperty(exports, "resolveProductionOptions", {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function () {
|
|
178
|
+
return resolveProductionOptions;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
//# sourceMappingURL=options-CWqFC5__.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-CWqFC5__.cjs","names":["DevtoolsProductionConfigError","isValidNetworkEntry"],"sources":["../../../../../../../packages/devtools/src/production/options.ts"],"sourcesContent":["import type { DevtoolsLogEntry, DevtoolsProductionOptions } from \"../types\";\nimport { DevtoolsProductionConfigError } from \"./errors\";\nimport { isValidNetworkEntry } from \"./http/ip\";\n\n/**\n * `DevtoolsProductionOptions` with every default applied and the environment\n * read. Built once at boot by `resolveProductionOptions`.\n */\nexport type ResolvedDevtoolsProductionOptions = {\n /** The dashboard path, without a trailing slash. */\n path: string;\n /** The first admin from the environment; every field `null` when unset. */\n admin: { email: string | null; password: string | null; setupToken: string | null };\n sampleRate: number;\n slowRequestMs: number;\n slowQueryMs: number;\n maxRequests: number;\n /** Queries kept per sampled request; the rest are counted in `droppedQueries`. */\n maxQueriesPerRequest: number;\n /** Query shapes kept in memory per process (least recently seen evicted). */\n maxShapes: number;\n /** Route keys kept in memory per process. */\n maxRoutes: number;\n /** Error groups kept in memory per process. */\n maxErrorGroups: number;\n requestRetentionHours: number;\n maxStoredSamplesPerMinute: number;\n reportIntervalMs: number;\n trustedProxies: readonly string[];\n requireHttps: boolean;\n allowedIps: readonly string[];\n origin: string | null;\n session: { idleMinutes: number; maxHours: number; pendingMinutes: number };\n twoFactor: \"admins\" | \"everyone\";\n rateLimits: {\n windowMinutes: number;\n account: number;\n ip: number;\n global: number;\n lockMinutes: number;\n };\n explain: { executing: boolean };\n panels: Readonly<Record<string, boolean>>;\n logLevels: readonly DevtoolsLogEntry[\"level\"][];\n auditRetentionDays: number;\n passkeys: { rpName: string; rpId: string | null };\n};\n\n/** The defaults `resolveProductionOptions` applies (environment values excluded). */\nexport const DEVTOOLS_PRODUCTION_DEFAULTS = {\n sampleRate: 0.1,\n slowRequestMs: 1000,\n slowQueryMs: 200,\n maxRequests: 200,\n maxQueriesPerRequest: 200,\n maxShapes: 500,\n maxRoutes: 300,\n maxErrorGroups: 100,\n requestRetentionHours: 24,\n maxStoredSamplesPerMinute: 120,\n reportIntervalMs: 10_000,\n requireHttps: true,\n session: { idleMinutes: 30, maxHours: 8, pendingMinutes: 10 },\n twoFactor: \"admins\",\n rateLimits: { windowMinutes: 15, account: 5, ip: 20, global: 100, lockMinutes: 15 },\n explain: { executing: false },\n logLevels: [\"warn\", \"error\"],\n auditRetentionDays: 90,\n passkeys: { rpName: \"Warlock monitor\" },\n} as const;\n\n/** The environment variables production mode reads. */\nexport const DEVTOOLS_ENV = {\n path: \"DEVTOOLS_PATH\",\n adminEmail: \"DEVTOOLS_ADMIN_EMAIL\",\n adminPassword: \"DEVTOOLS_ADMIN_PASSWORD\",\n setupToken: \"DEVTOOLS_SETUP_TOKEN\",\n} as const;\n\nconst LOG_LEVELS: readonly DevtoolsLogEntry[\"level\"][] = [\n \"debug\",\n \"info\",\n \"warn\",\n \"error\",\n \"success\",\n];\n\nconst PATH_CHARACTERS = /^[A-Za-z0-9._~/-]+$/;\nconst MIN_PATH_LENGTH = 8;\nconst MIN_SETUP_TOKEN_LENGTH = 32;\n\nfunction invalid(option: string, expected: string): never {\n throw new DevtoolsProductionConfigError(\n \"DT007\",\n `Option \"devtools.production.${option}\" is not valid: ${expected}.`,\n );\n}\n\nfunction present(value: string | undefined): string | null {\n return value === undefined || value === \"\" ? null : value;\n}\n\nfunction integerAtLeastOne(option: string, value: number | undefined, fallback: number): number {\n if (value === undefined) return fallback;\n\n if (!Number.isInteger(value) || value < 1) invalid(option, \"use a whole number of 1 or more\");\n\n return value;\n}\n\nfunction networkList(option: string, value: readonly string[] | undefined): readonly string[] {\n if (value === undefined) return [];\n\n if (!Array.isArray(value)) {\n invalid(option, 'use a list of IPs, CIDR ranges, \"loopback\" or \"private\"');\n }\n\n for (const entry of value as readonly unknown[]) {\n if (!isValidNetworkEntry(entry)) {\n invalid(option, `\"${String(entry)}\" is not an IP, a CIDR range, \"loopback\" or \"private\"`);\n }\n }\n\n return [...value];\n}\n\n/** The dashboard path without a trailing slash, or a DT001/DT002 error. */\nfunction resolvePath(value: string | undefined): string {\n const given = present(value);\n\n if (given === null) throw new DevtoolsProductionConfigError(\"DT001\");\n\n const path = given.replace(/\\/+$/, \"\");\n const segments = path.split(\"/\").slice(1);\n const lower = path.toLowerCase();\n\n if (\n !path.startsWith(\"/\") ||\n path.length < MIN_PATH_LENGTH ||\n !PATH_CHARACTERS.test(path) ||\n segments.some((segment) => segment === \"\" || segment === \".\" || segment === \"..\") ||\n lower === \"/__warlock\" ||\n lower.startsWith(\"/__warlock/\")\n ) {\n throw new DevtoolsProductionConfigError(\"DT002\");\n }\n\n return path;\n}\n\n/**\n * Applies the defaults to `options`, reads the path and first admin from\n * `env`, and validates everything.\n *\n * Throws `DevtoolsProductionConfigError`: DT001 (no path), DT002 (bad path),\n * DT007 (an option out of range: sampleRate outside 0–1, a non-positive\n * limit, an unknown twoFactor value, a bad CIDR, an origin that is not\n * `https://host[:port]`), DT009 (both a password and a setup token), DT010\n * (setup token shorter than 32 characters). DT003/DT004 (admin) are checked\n * later by `ensureFirstAdmin`, which needs the database.\n */\nexport function resolveProductionOptions(\n options: DevtoolsProductionOptions | undefined,\n env: Readonly<Record<string, string | undefined>>,\n): ResolvedDevtoolsProductionOptions {\n const given = options ?? {};\n const defaults = DEVTOOLS_PRODUCTION_DEFAULTS;\n const path = resolvePath(given.path ?? env[DEVTOOLS_ENV.path]);\n\n const sampleRate = given.sampleRate ?? defaults.sampleRate;\n\n if (\n typeof sampleRate !== \"number\" ||\n !Number.isFinite(sampleRate) ||\n sampleRate < 0 ||\n sampleRate > 1\n ) {\n invalid(\"sampleRate\", \"use a number from 0 to 1\");\n }\n\n const requireHttps: boolean = given.requireHttps ?? defaults.requireHttps;\n\n if (typeof requireHttps !== \"boolean\") invalid(\"requireHttps\", \"use true or false\");\n\n const twoFactor = given.twoFactor ?? defaults.twoFactor;\n\n if (twoFactor !== \"admins\" && twoFactor !== \"everyone\") {\n invalid(\"twoFactor\", 'use \"admins\" or \"everyone\"');\n }\n\n const origin = given.origin ?? null;\n\n if (origin !== null) {\n const pattern = requireHttps ? /^https:\\/\\/[^/\\s]+$/ : /^https?:\\/\\/[^/\\s]+$/;\n\n if (typeof origin !== \"string\" || !pattern.test(origin)) {\n invalid(\n \"origin\",\n requireHttps\n ? \"use an origin such as https://app.example.com, without a path or a trailing slash\"\n : \"use an origin such as http://localhost:3000, without a path or a trailing slash\",\n );\n }\n }\n\n const panels: Readonly<Record<string, unknown>> = given.panels ?? {};\n\n if (panels === null || typeof panels !== \"object\" || Array.isArray(panels)) {\n invalid(\"panels\", \"use an object of tab ids and true or false\");\n }\n\n for (const [id, enabled] of Object.entries(panels)) {\n if (typeof enabled !== \"boolean\") invalid(`panels.${id}`, \"use true or false\");\n }\n\n const logLevels = given.logLevels ?? defaults.logLevels;\n\n if (!Array.isArray(logLevels) || logLevels.some((level) => !LOG_LEVELS.includes(level))) {\n invalid(\"logLevels\", `use a list of ${LOG_LEVELS.join(\", \")}`);\n }\n\n const executing: boolean = given.explain?.executing ?? defaults.explain.executing;\n\n if (typeof executing !== \"boolean\") invalid(\"explain.executing\", \"use true or false\");\n\n const rpName: string = given.passkeys?.rpName ?? defaults.passkeys.rpName;\n const rpId = given.passkeys?.rpId ?? null;\n\n if (typeof rpName !== \"string\" || rpName.trim() === \"\") {\n invalid(\"passkeys.rpName\", \"use a non-empty name\");\n }\n\n if (rpId !== null && (typeof rpId !== \"string\" || rpId.trim() === \"\")) {\n invalid(\"passkeys.rpId\", \"use a host name such as app.example.com\");\n }\n\n const limits = given.rateLimits ?? {};\n const session = given.session ?? {};\n\n const resolved: ResolvedDevtoolsProductionOptions = {\n path,\n admin: {\n email: present(env[DEVTOOLS_ENV.adminEmail]),\n password: present(env[DEVTOOLS_ENV.adminPassword]),\n setupToken: present(env[DEVTOOLS_ENV.setupToken]),\n },\n sampleRate,\n slowRequestMs: integerAtLeastOne(\"slowRequestMs\", given.slowRequestMs, defaults.slowRequestMs),\n slowQueryMs: integerAtLeastOne(\"slowQueryMs\", given.slowQueryMs, defaults.slowQueryMs),\n maxRequests: integerAtLeastOne(\"maxRequests\", given.maxRequests, defaults.maxRequests),\n maxQueriesPerRequest: defaults.maxQueriesPerRequest,\n maxShapes: defaults.maxShapes,\n maxRoutes: defaults.maxRoutes,\n maxErrorGroups: defaults.maxErrorGroups,\n requestRetentionHours: integerAtLeastOne(\n \"requestRetentionHours\",\n given.requestRetentionHours,\n defaults.requestRetentionHours,\n ),\n maxStoredSamplesPerMinute: integerAtLeastOne(\n \"maxStoredSamplesPerMinute\",\n given.maxStoredSamplesPerMinute,\n defaults.maxStoredSamplesPerMinute,\n ),\n reportIntervalMs: integerAtLeastOne(\n \"reportIntervalMs\",\n given.reportIntervalMs,\n defaults.reportIntervalMs,\n ),\n trustedProxies: networkList(\"trustedProxies\", given.trustedProxies),\n requireHttps,\n allowedIps: networkList(\"allowedIps\", given.allowedIps),\n origin,\n session: {\n idleMinutes: integerAtLeastOne(\n \"session.idleMinutes\",\n session.idleMinutes,\n defaults.session.idleMinutes,\n ),\n maxHours: integerAtLeastOne(\"session.maxHours\", session.maxHours, defaults.session.maxHours),\n pendingMinutes: defaults.session.pendingMinutes,\n },\n twoFactor,\n rateLimits: {\n windowMinutes: integerAtLeastOne(\n \"rateLimits.windowMinutes\",\n limits.windowMinutes,\n defaults.rateLimits.windowMinutes,\n ),\n account: integerAtLeastOne(\"rateLimits.account\", limits.account, defaults.rateLimits.account),\n ip: integerAtLeastOne(\"rateLimits.ip\", limits.ip, defaults.rateLimits.ip),\n global: integerAtLeastOne(\"rateLimits.global\", limits.global, defaults.rateLimits.global),\n lockMinutes: integerAtLeastOne(\n \"rateLimits.lockMinutes\",\n limits.lockMinutes,\n defaults.rateLimits.lockMinutes,\n ),\n },\n explain: { executing },\n panels: { ...(panels as Readonly<Record<string, boolean>>) },\n logLevels: [...logLevels],\n auditRetentionDays: integerAtLeastOne(\n \"auditRetentionDays\",\n given.auditRetentionDays,\n defaults.auditRetentionDays,\n ),\n passkeys: { rpName, rpId },\n };\n\n if (resolved.admin.password !== null && resolved.admin.setupToken !== null) {\n throw new DevtoolsProductionConfigError(\"DT009\");\n }\n\n if (\n resolved.admin.setupToken !== null &&\n resolved.admin.setupToken.length < MIN_SETUP_TOKEN_LENGTH\n ) {\n throw new DevtoolsProductionConfigError(\"DT010\");\n }\n\n return resolved;\n}\n"],"mappings":";;;;;AAiDA,MAAa,+BAA+B;CAC1C,YAAY;CACZ,eAAe;CACf,aAAa;CACb,aAAa;CACb,sBAAsB;CACtB,WAAW;CACX,WAAW;CACX,gBAAgB;CAChB,uBAAuB;CACvB,2BAA2B;CAC3B,kBAAkB;CAClB,cAAc;CACd,SAAS;EAAE,aAAa;EAAI,UAAU;EAAG,gBAAgB;CAAG;CAC5D,WAAW;CACX,YAAY;EAAE,eAAe;EA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BAAkB,oBAAoB,QAAQ,UAAU,SAAS,QAAQ,QAAQ;GAC3F,gBAAgB,SAAS,QAAQ;EACnC;EACA;EACA,YAAY;GACV,eAAe,kBACb,4BACA,OAAO,eACP,SAAS,WAAW,aACtB;GACA,SAAS,kBAAkB,sBAAsB,OAAO,SAAS,SAAS,WAAW,OAAO;GAC5F,IAAI,kBAAkB,iBAAiB,OAAO,IAAI,SAAS,WAAW,EAAE;GACxE,QAAQ,kBAAkB,qBAAqB,OAAO,QAAQ,SAAS,WAAW,MAAM;GACxF,aAAa,kBACX,0BACA,OAAO,aACP,SAAS,WAAW,WACtB;EACF;EACA,SAAS,EAAE,UAAU;EACrB,QAAQ,EAAE,GAAI,OAA6C;EAC3D,WAAW,CAAC,GAAG,SAAS;EACxB,oBAAoB,kBAClB,sBACA,MAAM,oBACN,SAAS,kBACX;EACA,UAAU;GAAE;GAAQ;EAAK;CAC3B;CAEA,IAAI,SAAS,MAAM,aAAa,QAAQ,SAAS,MAAM,eAAe,MACpE,MAAM,IAAIA,6CAA8B,OAAO;CAGjD,IACE,SAAS,MAAM,eAAe,QAC9B,SAAS,MAAM,WAAW,SAAS,wBAEnC,MAAM,IAAIA,6CAA8B,OAAO;CAGjD,OAAO;AACT"}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-Zuuoy_Rh.cjs");
|
|
2
|
+
const require_contracts = require("./contracts-CVmplkNb.cjs");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
let node_module = require("node:module");
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
7
|
+
let node_url = require("node:url");
|
|
8
|
+
|
|
9
|
+
//#region ../../packages/devtools/src/panels.ts
|
|
10
|
+
/**
|
|
11
|
+
* Ids the dashboard already uses for its own tabs, API segments and URLs. A
|
|
12
|
+
* panel's routes live under `<path>/api/<id>`, so these would collide.
|
|
13
|
+
*/
|
|
14
|
+
const RESERVED_PANEL_IDS = /* @__PURE__ */ new Set([
|
|
15
|
+
"account",
|
|
16
|
+
"admin",
|
|
17
|
+
"agents",
|
|
18
|
+
"ai",
|
|
19
|
+
"api",
|
|
20
|
+
"assets",
|
|
21
|
+
"auth",
|
|
22
|
+
"background",
|
|
23
|
+
"docs",
|
|
24
|
+
"errors",
|
|
25
|
+
"health",
|
|
26
|
+
"instances",
|
|
27
|
+
"jobs",
|
|
28
|
+
"logs",
|
|
29
|
+
"mail",
|
|
30
|
+
"mails",
|
|
31
|
+
"panels",
|
|
32
|
+
"queries",
|
|
33
|
+
"requests",
|
|
34
|
+
"resources",
|
|
35
|
+
"routes",
|
|
36
|
+
"stream"
|
|
37
|
+
]);
|
|
38
|
+
const PANEL_ID = /^[a-z][a-z0-9-]*$/;
|
|
39
|
+
const ASSET_NAME = /^[A-Za-z0-9_][A-Za-z0-9._-]*$/;
|
|
40
|
+
const METHODS = /* @__PURE__ */ new Set([
|
|
41
|
+
"GET",
|
|
42
|
+
"POST",
|
|
43
|
+
"PUT",
|
|
44
|
+
"PATCH",
|
|
45
|
+
"DELETE"
|
|
46
|
+
]);
|
|
47
|
+
/** Content types for the files a panel may serve; anything else is sent as bytes. */
|
|
48
|
+
const CONTENT_TYPES = {
|
|
49
|
+
".js": "text/javascript; charset=utf-8",
|
|
50
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
51
|
+
".css": "text/css; charset=utf-8",
|
|
52
|
+
".json": "application/json; charset=utf-8",
|
|
53
|
+
".svg": "image/svg+xml",
|
|
54
|
+
".png": "image/png",
|
|
55
|
+
".woff2": "font/woff2"
|
|
56
|
+
};
|
|
57
|
+
/** The content type a panel file is served with, from its served name. */
|
|
58
|
+
function panelContentType(name) {
|
|
59
|
+
return CONTENT_TYPES[node_path.default.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
60
|
+
}
|
|
61
|
+
/** An absolute file path from a path or `file:` URL, or `undefined` for anything else. */
|
|
62
|
+
function toFilePath(value) {
|
|
63
|
+
if (value instanceof URL) return value.protocol === "file:" ? (0, node_url.fileURLToPath)(value) : void 0;
|
|
64
|
+
if (typeof value !== "string" || value === "") return void 0;
|
|
65
|
+
if (value.startsWith("file:")) return (0, node_url.fileURLToPath)(value);
|
|
66
|
+
return node_path.default.isAbsolute(value) ? value : void 0;
|
|
67
|
+
}
|
|
68
|
+
function isFile(file) {
|
|
69
|
+
return (0, node_fs.existsSync)(file) && (0, node_fs.statSync)(file).isFile();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validates `value` as a panel and returns it ready to mount. Throws an
|
|
73
|
+
* error that names the panel and what to change; `taken` maps the ids
|
|
74
|
+
* already registered to their titles and receives this panel's id.
|
|
75
|
+
*/
|
|
76
|
+
function checkDevtoolsPanel(value, taken) {
|
|
77
|
+
const panel = value ?? {};
|
|
78
|
+
const id = panel.id;
|
|
79
|
+
if (typeof id !== "string" || !PANEL_ID.test(id)) throw new Error(`A devtools panel needs an "id" of lower-case letters, digits and dashes that starts with a letter; got ${JSON.stringify(id)}.`);
|
|
80
|
+
if (RESERVED_PANEL_IDS.has(id)) throw new Error(`Devtools panel id "${id}" is used by the dashboard itself; give the panel another id.`);
|
|
81
|
+
const existing = taken.get(id);
|
|
82
|
+
if (existing !== void 0) throw new Error(`Devtools panel id "${id}" is already registered by the "${existing}" panel; each panel needs its own id.`);
|
|
83
|
+
if (typeof panel.title !== "string" || panel.title.trim() === "") throw new Error(`Devtools panel "${id}" needs a "title" for its tab.`);
|
|
84
|
+
const view = toFilePath(panel.view);
|
|
85
|
+
if (view === void 0) throw new Error(`Devtools panel "${id}" needs a "view": an absolute path or file: URL of its browser module.`);
|
|
86
|
+
if (!isFile(view)) throw new Error(`The view module of devtools panel "${id}" was not found at ${view}.`);
|
|
87
|
+
const seen = /* @__PURE__ */ new Set();
|
|
88
|
+
const routes = (panel.routes ?? []).map((route) => {
|
|
89
|
+
const method = route.method ?? "GET";
|
|
90
|
+
if (!METHODS.has(method)) throw new Error(`Devtools panel "${id}" has a route with method "${String(method)}"; use GET, POST, PUT, PATCH or DELETE.`);
|
|
91
|
+
if (typeof route.path !== "string" || route.path !== "" && !route.path.startsWith("/")) throw new Error(`Devtools panel "${id}" has a route path ${JSON.stringify(route.path)}; use "" or a path starting with "/".`);
|
|
92
|
+
if (typeof route.handler !== "function") throw new Error(`Devtools panel "${id}" route ${method} "${route.path}" has no handler.`);
|
|
93
|
+
if (seen.has(`${method} ${route.path}`)) throw new Error(`Devtools panel "${id}" lists route ${method} "${route.path}" twice; keep one.`);
|
|
94
|
+
seen.add(`${method} ${route.path}`);
|
|
95
|
+
return {
|
|
96
|
+
...route,
|
|
97
|
+
method
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
const assets = {};
|
|
101
|
+
for (const [name, source] of Object.entries(panel.assets ?? {})) {
|
|
102
|
+
if (!ASSET_NAME.test(name) || name === "view.js") throw new Error(`Devtools panel "${id}" has an asset named ${JSON.stringify(name)}; use a plain file name other than "view.js".`);
|
|
103
|
+
const file = toFilePath(source);
|
|
104
|
+
if (file === void 0 || !isFile(file)) throw new Error(`The asset "${name}" of devtools panel "${id}" was not found at ${String(source)}; give an absolute path or file: URL.`);
|
|
105
|
+
assets[name] = file;
|
|
106
|
+
}
|
|
107
|
+
taken.set(id, panel.title);
|
|
108
|
+
return {
|
|
109
|
+
id,
|
|
110
|
+
title: panel.title,
|
|
111
|
+
view,
|
|
112
|
+
routes,
|
|
113
|
+
assets,
|
|
114
|
+
production: panel.production === true
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** Validates a list of panels; the first invalid or duplicate one throws. */
|
|
118
|
+
function checkDevtoolsPanels(panels) {
|
|
119
|
+
const taken = /* @__PURE__ */ new Map();
|
|
120
|
+
return panels.map((panel) => checkDevtoolsPanel(panel, taken));
|
|
121
|
+
}
|
|
122
|
+
function isPlainObject(value) {
|
|
123
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
124
|
+
const prototype = Object.getPrototypeOf(value);
|
|
125
|
+
return prototype === Object.prototype || prototype === null;
|
|
126
|
+
}
|
|
127
|
+
/** What is wrong with a `[specifier, options]` entry, or `undefined` when it is valid. */
|
|
128
|
+
function tupleProblem(entry) {
|
|
129
|
+
if (entry.length !== 2) return `it has ${entry.length} item(s); use exactly [specifier, options]`;
|
|
130
|
+
if (typeof entry[0] !== "string" || entry[0] === "") return `its first item is ${JSON.stringify(entry[0])}; use the module specifier as a string`;
|
|
131
|
+
if (!isPlainObject(entry[1])) return `its second item is not a plain object; pass the options as { name: value }`;
|
|
132
|
+
}
|
|
133
|
+
/** The URL or specifier to import for a `panels` entry. */
|
|
134
|
+
function resolvePanelSpecifier(entry, root) {
|
|
135
|
+
if (entry.startsWith("./") || entry.startsWith("../") || node_path.default.isAbsolute(entry)) return (0, node_url.pathToFileURL)(node_path.default.resolve(root, entry)).href;
|
|
136
|
+
return resolveFromNodeModules(entry, root) ?? resolveWithRequire(entry, root) ?? entry;
|
|
137
|
+
}
|
|
138
|
+
/** Picks the file an `exports` target names: `import`, then `default`, then `node`. */
|
|
139
|
+
function exportTarget(target) {
|
|
140
|
+
if (typeof target === "string") return target;
|
|
141
|
+
if (Array.isArray(target)) {
|
|
142
|
+
for (const item of target) {
|
|
143
|
+
const found = exportTarget(item);
|
|
144
|
+
if (found !== void 0) return found;
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (target !== null && typeof target === "object") {
|
|
149
|
+
const conditions = target;
|
|
150
|
+
for (const condition of [
|
|
151
|
+
"import",
|
|
152
|
+
"node",
|
|
153
|
+
"default"
|
|
154
|
+
]) {
|
|
155
|
+
const found = exportTarget(conditions[condition]);
|
|
156
|
+
if (found !== void 0) return found;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Resolves a package specifier by looking it up in the `node_modules` folders
|
|
162
|
+
* above the app root and reading its `exports` map. `createRequire().resolve`
|
|
163
|
+
* cannot do this for a package that only has an `import` condition.
|
|
164
|
+
*/
|
|
165
|
+
function resolveFromNodeModules(entry, root) {
|
|
166
|
+
const parts = entry.split("/");
|
|
167
|
+
const nameLength = entry.startsWith("@") ? 2 : 1;
|
|
168
|
+
const name = parts.slice(0, nameLength).join("/");
|
|
169
|
+
const subpath = parts.length > nameLength ? `./${parts.slice(nameLength).join("/")}` : ".";
|
|
170
|
+
if (!name) return void 0;
|
|
171
|
+
let directory = node_path.default.resolve(root);
|
|
172
|
+
for (;;) {
|
|
173
|
+
const packageDirectory = node_path.default.join(directory, "node_modules", name);
|
|
174
|
+
const manifestFile = node_path.default.join(packageDirectory, "package.json");
|
|
175
|
+
if ((0, node_fs.existsSync)(manifestFile)) try {
|
|
176
|
+
const manifest = JSON.parse((0, node_fs.readFileSync)(manifestFile, "utf8"));
|
|
177
|
+
const exported = manifest.exports;
|
|
178
|
+
const map = exported !== null && typeof exported === "object" && !Array.isArray(exported) ? exported : void 0;
|
|
179
|
+
const hasSubpaths = map !== void 0 && Object.keys(map).some((key) => key.startsWith("."));
|
|
180
|
+
const target = exported === void 0 ? subpath === "." ? manifest.main ?? "index.js" : subpath : hasSubpaths ? exportTarget(map?.[subpath]) : subpath === "." ? exportTarget(exported) : void 0;
|
|
181
|
+
if (target === void 0) return void 0;
|
|
182
|
+
const file = node_path.default.resolve(packageDirectory, target);
|
|
183
|
+
return isFile(file) ? (0, node_url.pathToFileURL)(file).href : void 0;
|
|
184
|
+
} catch {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const parent = node_path.default.dirname(directory);
|
|
188
|
+
if (parent === directory) return void 0;
|
|
189
|
+
directory = parent;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
/** The `require` resolution, for packages the `node_modules` lookup does not understand. */
|
|
193
|
+
function resolveWithRequire(entry, root) {
|
|
194
|
+
try {
|
|
195
|
+
return (0, node_url.pathToFileURL)((0, node_module.createRequire)(node_path.default.join(root, "package.json")).resolve(entry)).href;
|
|
196
|
+
} catch {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** The panels a module's default export describes. */
|
|
201
|
+
async function panelsOf(exported, root, mode, panelOptions = {}) {
|
|
202
|
+
const value = typeof exported === "function" ? await exported({
|
|
203
|
+
...panelOptions,
|
|
204
|
+
root,
|
|
205
|
+
mode
|
|
206
|
+
}) : exported;
|
|
207
|
+
return Array.isArray(value) ? value : [value];
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Loads the devtools `panels` option: imports each module entry, reads its
|
|
211
|
+
* default export, and validates every panel. An entry that fails to load and
|
|
212
|
+
* a panel that is invalid or reuses an id are reported through `warn` and
|
|
213
|
+
* skipped, so one broken panel never stops the dashboard.
|
|
214
|
+
*/
|
|
215
|
+
async function loadDevtoolsPanels(entries, options) {
|
|
216
|
+
if (!Array.isArray(entries)) {
|
|
217
|
+
options.warn(`The devtools "panels" option must be a list, such as panels: ["@warlock.js/grimoire/devtools"]; got ${JSON.stringify(entries)}. No panel was added.`);
|
|
218
|
+
return [];
|
|
219
|
+
}
|
|
220
|
+
const importModule = options.importModule ?? ((specifier) => import(specifier));
|
|
221
|
+
const mode = options.mode ?? "development";
|
|
222
|
+
const taken = new Map(options.taken ?? []);
|
|
223
|
+
const panels = [];
|
|
224
|
+
for (const entry of entries) {
|
|
225
|
+
let candidates;
|
|
226
|
+
try {
|
|
227
|
+
if (Array.isArray(entry)) {
|
|
228
|
+
const problem = tupleProblem(entry);
|
|
229
|
+
if (problem !== void 0) {
|
|
230
|
+
options.warn(`Devtools panels entry ${JSON.stringify(entry)} is invalid: ${problem}. Example: ["@warlock.js/grimoire/devtools", { ttlMs: 60000 }]. The entry was not added.`);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (typeof entry === "string" || Array.isArray(entry)) {
|
|
235
|
+
const [specifier, panelOptions] = typeof entry === "string" ? [entry, void 0] : entry;
|
|
236
|
+
const module = await importModule(resolvePanelSpecifier(specifier, options.root));
|
|
237
|
+
if (module.default === void 0) throw new Error("the module has no default export");
|
|
238
|
+
candidates = await panelsOf(module.default, options.root, mode, panelOptions);
|
|
239
|
+
} else candidates = [entry];
|
|
240
|
+
} catch (error) {
|
|
241
|
+
options.warn(`Devtools panel module "${String(Array.isArray(entry) ? entry[0] : entry)}" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools "panels" option.`);
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
for (const candidate of candidates) try {
|
|
245
|
+
panels.push(checkDevtoolsPanel(candidate, taken));
|
|
246
|
+
} catch (error) {
|
|
247
|
+
options.warn(`${describe(error)} The panel was not added.`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return panels;
|
|
251
|
+
}
|
|
252
|
+
function describe(error) {
|
|
253
|
+
return error instanceof Error ? error.message : String(error);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Which tabs the production monitor shows. A built-in tab follows
|
|
257
|
+
* `DEVTOOLS_BUILT_IN_PANELS` unless `overrides[id]` says otherwise. A package
|
|
258
|
+
* panel (the Processes panel included) shows when it declares
|
|
259
|
+
* `production: true` or `overrides[id]` is `true`; `overrides[id]: false` turns
|
|
260
|
+
* any tab off.
|
|
261
|
+
*/
|
|
262
|
+
function productionPanels(packagePanels, overrides = {}) {
|
|
263
|
+
return {
|
|
264
|
+
builtIn: require_contracts.DEVTOOLS_BUILT_IN_PANELS.filter((tab) => overrides[tab.id] ?? tab.production).map((tab) => tab.id),
|
|
265
|
+
panels: packagePanels.filter((panel) => overrides[panel.id] ?? panel.production)
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* The tab list `GET api/panels` answers with: the built-in tabs in
|
|
270
|
+
* `builtIn` (default: every one), in display order, then the package panels
|
|
271
|
+
* in registration order.
|
|
272
|
+
*/
|
|
273
|
+
function listPanelInfos(panels, builtIn) {
|
|
274
|
+
const tabs = require_contracts.DEVTOOLS_BUILT_IN_PANELS.filter((tab) => builtIn === void 0 || builtIn.includes(tab.id)).map((tab) => ({
|
|
275
|
+
id: tab.id,
|
|
276
|
+
title: tab.title,
|
|
277
|
+
type: "built-in"
|
|
278
|
+
}));
|
|
279
|
+
for (const panel of panels) tabs.push({
|
|
280
|
+
id: panel.id,
|
|
281
|
+
title: panel.title,
|
|
282
|
+
type: "package"
|
|
283
|
+
});
|
|
284
|
+
return tabs;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
//#endregion
|
|
288
|
+
Object.defineProperty(exports, "checkDevtoolsPanels", {
|
|
289
|
+
enumerable: true,
|
|
290
|
+
get: function () {
|
|
291
|
+
return checkDevtoolsPanels;
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
Object.defineProperty(exports, "listPanelInfos", {
|
|
295
|
+
enumerable: true,
|
|
296
|
+
get: function () {
|
|
297
|
+
return listPanelInfos;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
Object.defineProperty(exports, "loadDevtoolsPanels", {
|
|
301
|
+
enumerable: true,
|
|
302
|
+
get: function () {
|
|
303
|
+
return loadDevtoolsPanels;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
Object.defineProperty(exports, "panelContentType", {
|
|
307
|
+
enumerable: true,
|
|
308
|
+
get: function () {
|
|
309
|
+
return panelContentType;
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
Object.defineProperty(exports, "productionPanels", {
|
|
313
|
+
enumerable: true,
|
|
314
|
+
get: function () {
|
|
315
|
+
return productionPanels;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
//# sourceMappingURL=panels-Rcmeitu3.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panels-Rcmeitu3.cjs","names":["path","fileURLToPath","existsSync","statSync","pathToFileURL","readFileSync","createRequire","DEVTOOLS_BUILT_IN_PANELS"],"sources":["../../../../../../../packages/devtools/src/panels.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { DEVTOOLS_BUILT_IN_PANELS } from \"./production/contracts\";\nimport type { DevtoolsMode, DevtoolsPanelInfo } from \"./production/contracts\";\nimport type {\n DevtoolsPanel,\n DevtoolsPanelEntry,\n DevtoolsPanelExport,\n DevtoolsPanelMethod,\n DevtoolsPanelRoute,\n} from \"./types\";\n\n/**\n * A validated panel: file paths are absolute strings and every list is\n * present, so the server never re-checks them per request.\n */\nexport type MountedDevtoolsPanel = {\n id: string;\n title: string;\n view: string;\n routes: readonly (DevtoolsPanelRoute & { method: DevtoolsPanelMethod })[];\n assets: Readonly<Record<string, string>>;\n /** Whether the panel declared itself safe for the production monitor. */\n production: boolean;\n};\n\n/**\n * Ids the dashboard already uses for its own tabs, API segments and URLs. A\n * panel's routes live under `<path>/api/<id>`, so these would collide.\n */\nconst RESERVED_PANEL_IDS = new Set([\n \"account\",\n \"admin\",\n \"agents\",\n \"ai\",\n \"api\",\n \"assets\",\n \"auth\",\n \"background\",\n \"docs\",\n \"errors\",\n \"health\",\n \"instances\",\n \"jobs\",\n \"logs\",\n \"mail\",\n \"mails\",\n \"panels\",\n \"queries\",\n \"requests\",\n \"resources\",\n \"routes\",\n \"stream\",\n]);\n\nconst PANEL_ID = /^[a-z][a-z0-9-]*$/;\nconst ASSET_NAME = /^[A-Za-z0-9_][A-Za-z0-9._-]*$/;\nconst METHODS = new Set<DevtoolsPanelMethod>([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"]);\n\n/** Content types for the files a panel may serve; anything else is sent as bytes. */\nconst CONTENT_TYPES: Record<string, string> = {\n \".js\": \"text/javascript; charset=utf-8\",\n \".mjs\": \"text/javascript; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".json\": \"application/json; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".woff2\": \"font/woff2\",\n};\n\n/** The content type a panel file is served with, from its served name. */\nexport function panelContentType(name: string): string {\n return CONTENT_TYPES[path.extname(name).toLowerCase()] ?? \"application/octet-stream\";\n}\n\n/** An absolute file path from a path or `file:` URL, or `undefined` for anything else. */\nfunction toFilePath(value: unknown): string | undefined {\n if (value instanceof URL) return value.protocol === \"file:\" ? fileURLToPath(value) : undefined;\n if (typeof value !== \"string\" || value === \"\") return undefined;\n if (value.startsWith(\"file:\")) return fileURLToPath(value);\n\n return path.isAbsolute(value) ? value : undefined;\n}\n\nfunction isFile(file: string): boolean {\n return existsSync(file) && statSync(file).isFile();\n}\n\n/**\n * Validates `value` as a panel and returns it ready to mount. Throws an\n * error that names the panel and what to change; `taken` maps the ids\n * already registered to their titles and receives this panel's id.\n */\nexport function checkDevtoolsPanel(\n value: unknown,\n taken: Map<string, string>,\n): MountedDevtoolsPanel {\n const panel = (value ?? {}) as Partial<DevtoolsPanel>;\n const id = panel.id;\n\n if (typeof id !== \"string\" || !PANEL_ID.test(id)) {\n throw new Error(\n `A devtools panel needs an \"id\" of lower-case letters, digits and dashes that starts with a letter; got ${JSON.stringify(id)}.`,\n );\n }\n\n if (RESERVED_PANEL_IDS.has(id)) {\n throw new Error(\n `Devtools panel id \"${id}\" is used by the dashboard itself; give the panel another id.`,\n );\n }\n\n const existing = taken.get(id);\n\n if (existing !== undefined) {\n throw new Error(\n `Devtools panel id \"${id}\" is already registered by the \"${existing}\" panel; each panel needs its own id.`,\n );\n }\n\n if (typeof panel.title !== \"string\" || panel.title.trim() === \"\") {\n throw new Error(`Devtools panel \"${id}\" needs a \"title\" for its tab.`);\n }\n\n const view = toFilePath(panel.view);\n\n if (view === undefined) {\n throw new Error(\n `Devtools panel \"${id}\" needs a \"view\": an absolute path or file: URL of its browser module.`,\n );\n }\n\n if (!isFile(view)) {\n throw new Error(`The view module of devtools panel \"${id}\" was not found at ${view}.`);\n }\n\n // Two routes on one method and path would make the server refuse to start.\n const seen = new Set<string>();\n const routes = (panel.routes ?? []).map((route) => {\n const method = route.method ?? \"GET\";\n\n if (!METHODS.has(method)) {\n throw new Error(\n `Devtools panel \"${id}\" has a route with method \"${String(method)}\"; use GET, POST, PUT, PATCH or DELETE.`,\n );\n }\n\n if (typeof route.path !== \"string\" || (route.path !== \"\" && !route.path.startsWith(\"/\"))) {\n throw new Error(\n `Devtools panel \"${id}\" has a route path ${JSON.stringify(route.path)}; use \"\" or a path starting with \"/\".`,\n );\n }\n\n if (typeof route.handler !== \"function\") {\n throw new Error(`Devtools panel \"${id}\" route ${method} \"${route.path}\" has no handler.`);\n }\n\n if (seen.has(`${method} ${route.path}`)) {\n throw new Error(\n `Devtools panel \"${id}\" lists route ${method} \"${route.path}\" twice; keep one.`,\n );\n }\n\n seen.add(`${method} ${route.path}`);\n\n return { ...route, method };\n });\n\n const assets: Record<string, string> = {};\n\n for (const [name, source] of Object.entries(panel.assets ?? {})) {\n if (!ASSET_NAME.test(name) || name === \"view.js\") {\n throw new Error(\n `Devtools panel \"${id}\" has an asset named ${JSON.stringify(name)}; use a plain file name other than \"view.js\".`,\n );\n }\n\n const file = toFilePath(source);\n\n if (file === undefined || !isFile(file)) {\n throw new Error(\n `The asset \"${name}\" of devtools panel \"${id}\" was not found at ${String(source)}; give an absolute path or file: URL.`,\n );\n }\n\n assets[name] = file;\n }\n\n taken.set(id, panel.title);\n\n return { id, title: panel.title, view, routes, assets, production: panel.production === true };\n}\n\n/** Validates a list of panels; the first invalid or duplicate one throws. */\nexport function checkDevtoolsPanels(panels: readonly unknown[]): MountedDevtoolsPanel[] {\n const taken = new Map<string, string>();\n\n return panels.map((panel) => checkDevtoolsPanel(panel, taken));\n}\n\n/** Hooks `loadDevtoolsPanels` uses; replaced in specs. */\nexport type LoadDevtoolsPanelsOptions = {\n /** The app's root directory: bare specifiers resolve from here, `./` paths are relative to it. */\n root: string;\n /** Receives one line per entry that could not be loaded or was rejected. */\n warn: (message: string) => void;\n /** Ids already taken (the built-in panels), mapped to their titles. */\n taken?: ReadonlyMap<string, string>;\n /** Imports a module URL or specifier; defaults to a dynamic `import()`. */\n importModule?: (specifier: string) => Promise<unknown>;\n /** Where the dashboard runs; panel factories receive it as `context.mode`. @default \"development\" */\n mode?: DevtoolsMode;\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return false;\n\n const prototype = Object.getPrototypeOf(value);\n\n return prototype === Object.prototype || prototype === null;\n}\n\n/** What is wrong with a `[specifier, options]` entry, or `undefined` when it is valid. */\nfunction tupleProblem(entry: readonly unknown[]): string | undefined {\n if (entry.length !== 2) {\n return `it has ${entry.length} item(s); use exactly [specifier, options]`;\n }\n\n if (typeof entry[0] !== \"string\" || entry[0] === \"\") {\n return `its first item is ${JSON.stringify(entry[0])}; use the module specifier as a string`;\n }\n\n if (!isPlainObject(entry[1])) {\n return `its second item is not a plain object; pass the options as { name: value }`;\n }\n\n return undefined;\n}\n\n/** The URL or specifier to import for a `panels` entry. */\nfunction resolvePanelSpecifier(entry: string, root: string): string {\n if (entry.startsWith(\"./\") || entry.startsWith(\"../\") || path.isAbsolute(entry)) {\n return pathToFileURL(path.resolve(root, entry)).href;\n }\n\n return resolveFromNodeModules(entry, root) ?? resolveWithRequire(entry, root) ?? entry;\n}\n\n/** Picks the file an `exports` target names: `import`, then `default`, then `node`. */\nfunction exportTarget(target: unknown): string | undefined {\n if (typeof target === \"string\") return target;\n\n if (Array.isArray(target)) {\n for (const item of target) {\n const found = exportTarget(item);\n\n if (found !== undefined) return found;\n }\n\n return undefined;\n }\n\n if (target !== null && typeof target === \"object\") {\n const conditions = target as Record<string, unknown>;\n\n for (const condition of [\"import\", \"node\", \"default\"]) {\n const found = exportTarget(conditions[condition]);\n\n if (found !== undefined) return found;\n }\n }\n\n return undefined;\n}\n\n/**\n * Resolves a package specifier by looking it up in the `node_modules` folders\n * above the app root and reading its `exports` map. `createRequire().resolve`\n * cannot do this for a package that only has an `import` condition.\n */\nfunction resolveFromNodeModules(entry: string, root: string): string | undefined {\n const parts = entry.split(\"/\");\n const nameLength = entry.startsWith(\"@\") ? 2 : 1;\n const name = parts.slice(0, nameLength).join(\"/\");\n const subpath = parts.length > nameLength ? `./${parts.slice(nameLength).join(\"/\")}` : \".\";\n\n if (!name) return undefined;\n\n let directory = path.resolve(root);\n\n for (;;) {\n const packageDirectory = path.join(directory, \"node_modules\", name);\n const manifestFile = path.join(packageDirectory, \"package.json\");\n\n if (existsSync(manifestFile)) {\n try {\n const manifest = JSON.parse(readFileSync(manifestFile, \"utf8\")) as {\n exports?: unknown;\n main?: string;\n };\n const exported = manifest.exports;\n const map =\n exported !== null && typeof exported === \"object\" && !Array.isArray(exported)\n ? (exported as Record<string, unknown>)\n : undefined;\n const hasSubpaths =\n map !== undefined && Object.keys(map).some((key) => key.startsWith(\".\"));\n const target =\n exported === undefined\n ? subpath === \".\"\n ? (manifest.main ?? \"index.js\")\n : subpath\n : hasSubpaths\n ? exportTarget(map?.[subpath])\n : subpath === \".\"\n ? exportTarget(exported)\n : undefined;\n\n if (target === undefined) return undefined;\n\n const file = path.resolve(packageDirectory, target);\n\n return isFile(file) ? pathToFileURL(file).href : undefined;\n } catch {\n return undefined;\n }\n }\n\n const parent = path.dirname(directory);\n\n if (parent === directory) return undefined;\n\n directory = parent;\n }\n}\n\n/** The `require` resolution, for packages the `node_modules` lookup does not understand. */\nfunction resolveWithRequire(entry: string, root: string): string | undefined {\n try {\n return pathToFileURL(createRequire(path.join(root, \"package.json\")).resolve(entry)).href;\n } catch {\n return undefined;\n }\n}\n\n/** The panels a module's default export describes. */\nasync function panelsOf(\n exported: DevtoolsPanelExport,\n root: string,\n mode: DevtoolsMode,\n panelOptions: Readonly<Record<string, unknown>> = {},\n): Promise<readonly unknown[]> {\n const value =\n typeof exported === \"function\" ? await exported({ ...panelOptions, root, mode }) : exported;\n\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Loads the devtools `panels` option: imports each module entry, reads its\n * default export, and validates every panel. An entry that fails to load and\n * a panel that is invalid or reuses an id are reported through `warn` and\n * skipped, so one broken panel never stops the dashboard.\n */\nexport async function loadDevtoolsPanels(\n entries: readonly DevtoolsPanelEntry[],\n options: LoadDevtoolsPanelsOptions,\n): Promise<MountedDevtoolsPanel[]> {\n // `src/config/devtools.ts` is a plain object with no types: a single string would be read letter by letter.\n if (!Array.isArray(entries as unknown)) {\n options.warn(\n `The devtools \"panels\" option must be a list, such as panels: [\"@warlock.js/grimoire/devtools\"]; got ${JSON.stringify(entries)}. No panel was added.`,\n );\n\n return [];\n }\n\n const importModule = options.importModule ?? ((specifier: string) => import(specifier));\n const mode = options.mode ?? \"development\";\n const taken = new Map<string, string>(options.taken ?? []);\n const panels: MountedDevtoolsPanel[] = [];\n\n for (const entry of entries) {\n let candidates: readonly unknown[];\n\n try {\n if (Array.isArray(entry as unknown)) {\n const problem = tupleProblem(entry as readonly unknown[]);\n\n if (problem !== undefined) {\n options.warn(\n `Devtools panels entry ${JSON.stringify(entry)} is invalid: ${problem}. Example: [\"@warlock.js/grimoire/devtools\", { ttlMs: 60000 }]. The entry was not added.`,\n );\n continue;\n }\n }\n\n if (typeof entry === \"string\" || Array.isArray(entry as unknown)) {\n const [specifier, panelOptions] =\n typeof entry === \"string\"\n ? [entry, undefined]\n : (entry as readonly [string, Record<string, unknown>]);\n const module = (await importModule(resolvePanelSpecifier(specifier, options.root))) as {\n default?: DevtoolsPanelExport;\n };\n\n if (module.default === undefined) {\n throw new Error(\"the module has no default export\");\n }\n\n candidates = await panelsOf(module.default, options.root, mode, panelOptions);\n } else {\n candidates = [entry];\n }\n } catch (error) {\n options.warn(\n `Devtools panel module \"${String(Array.isArray(entry as unknown) ? (entry as readonly unknown[])[0] : entry)}\" could not be loaded: ${describe(error)}. Check that it is installed and listed correctly in the devtools \"panels\" option.`,\n );\n continue;\n }\n\n for (const candidate of candidates) {\n try {\n panels.push(checkDevtoolsPanel(candidate, taken));\n } catch (error) {\n options.warn(`${describe(error)} The panel was not added.`);\n }\n }\n }\n\n return panels;\n}\n\nfunction describe(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** What `productionPanels` decides. */\nexport type DevtoolsProductionPanels = {\n /** Built-in tab ids shown, in display order. */\n builtIn: string[];\n /** Package panels shown. */\n panels: MountedDevtoolsPanel[];\n};\n\n/**\n * Which tabs the production monitor shows. A built-in tab follows\n * `DEVTOOLS_BUILT_IN_PANELS` unless `overrides[id]` says otherwise. A package\n * panel (the Processes panel included) shows when it declares\n * `production: true` or `overrides[id]` is `true`; `overrides[id]: false` turns\n * any tab off.\n */\nexport function productionPanels(\n packagePanels: readonly MountedDevtoolsPanel[],\n overrides: Readonly<Record<string, boolean>> = {},\n): DevtoolsProductionPanels {\n const builtIn = DEVTOOLS_BUILT_IN_PANELS.filter((tab) => overrides[tab.id] ?? tab.production).map(\n (tab) => tab.id,\n );\n const panels = packagePanels.filter((panel) => overrides[panel.id] ?? panel.production);\n\n return { builtIn, panels };\n}\n\n/**\n * The tab list `GET api/panels` answers with: the built-in tabs in\n * `builtIn` (default: every one), in display order, then the package panels\n * in registration order.\n */\nexport function listPanelInfos(\n panels: readonly Pick<MountedDevtoolsPanel, \"id\" | \"title\">[],\n builtIn?: readonly string[],\n): DevtoolsPanelInfo[] {\n const tabs: DevtoolsPanelInfo[] = DEVTOOLS_BUILT_IN_PANELS.filter(\n (tab) => builtIn === undefined || builtIn.includes(tab.id),\n ).map((tab) => ({ id: tab.id, title: tab.title, type: \"built-in\" as const }));\n\n for (const panel of panels)\n tabs.push({ id: panel.id, title: panel.title, type: \"package\" as const });\n\n return tabs;\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,MAAM,qCAAqB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,WAAW;AACj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