@warlock.js/devtools 5.59.0 → 5.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/cjs/{app-versions-DfpPZOI2.cjs → app-versions-C_ZyzuvD.cjs} +1 -116
- package/cjs/app-versions-C_ZyzuvD.cjs.map +1 -0
- package/cjs/attach-D5aMqUnA.cjs +1342 -0
- package/cjs/attach-D5aMqUnA.cjs.map +1 -0
- package/cjs/{auth-B3wyjJnQ.cjs → auth-ChHh5E7j.cjs} +6 -6
- package/cjs/{auth-B3wyjJnQ.cjs.map → auth-ChHh5E7j.cjs.map} +1 -1
- package/cjs/{boot-nczSvJ_F.cjs → boot-D0nF-7w3.cjs} +78 -14
- package/cjs/boot-D0nF-7w3.cjs.map +1 -0
- package/cjs/{capture-CuyT8Vab.cjs → capture-D2k0GnBN.cjs} +23 -422
- package/cjs/capture-D2k0GnBN.cjs.map +1 -0
- package/cjs/{cascade-store-CuRRYzt_.cjs → cascade-store-DUT2Laha.cjs} +3 -3
- package/cjs/{cascade-store-CuRRYzt_.cjs.map → cascade-store-DUT2Laha.cjs.map} +1 -1
- package/cjs/{collector-CJbQbzzK.cjs → collector-BfC4v87v.cjs} +4 -46
- package/cjs/collector-BfC4v87v.cjs.map +1 -0
- package/cjs/{current-request-id-CeQhRz9Q.cjs → current-request-id-Badec-TH.cjs} +2 -2
- package/cjs/{current-request-id-CeQhRz9Q.cjs.map → current-request-id-Badec-TH.cjs.map} +1 -1
- package/cjs/{errors-BadbSDX8.cjs → errors-DNQ-g49I.cjs} +198 -1
- package/cjs/errors-DNQ-g49I.cjs.map +1 -0
- package/cjs/extract-8kaX_cUV.cjs +1103 -0
- package/cjs/extract-8kaX_cUV.cjs.map +1 -0
- package/cjs/{http-Biauhqi0.cjs → http-1nnpAoI7.cjs} +33 -10
- package/cjs/http-1nnpAoI7.cjs.map +1 -0
- package/cjs/index.cjs +1 -1
- package/cjs/{insights-BjJA6Ret.cjs → insights-COA3u37q.cjs} +54 -22
- package/cjs/insights-COA3u37q.cjs.map +1 -0
- package/cjs/migrations-BQdNOL5_.cjs +30 -0
- package/cjs/migrations-BQdNOL5_.cjs.map +1 -0
- package/cjs/{migrations-BP4cYTGo.cjs → models-DF1agAm4.cjs} +106 -24
- package/cjs/models-DF1agAm4.cjs.map +1 -0
- package/cjs/{process-panel-DskSA7Cm.cjs → process-panel-D3D9Y_dc.cjs} +4 -4
- package/cjs/{process-panel-DskSA7Cm.cjs.map → process-panel-D3D9Y_dc.cjs.map} +1 -1
- package/cjs/production/index.cjs +4 -4
- package/cjs/query-shape-DShKQa0x.cjs +45 -0
- package/cjs/query-shape-DShKQa0x.cjs.map +1 -0
- package/cjs/redact-DQ28mDzr.cjs +533 -0
- package/cjs/redact-DQ28mDzr.cjs.map +1 -0
- package/cjs/runs-DECWPGnq.cjs +390 -0
- package/cjs/runs-DECWPGnq.cjs.map +1 -0
- package/cjs/{server-D3XRbSSb.cjs → server-DLT3uPef.cjs} +8 -7
- package/cjs/{server-D3XRbSSb.cjs.map → server-DLT3uPef.cjs.map} +1 -1
- package/cjs/{src-QcNghoYN.cjs → src-BZiSv8A1.cjs} +182 -24
- package/cjs/src-BZiSv8A1.cjs.map +1 -0
- package/cjs/{store-CNFv3wVp.cjs → store-EFn4wp0T.cjs} +2 -2
- package/cjs/{stream-route-BqyAlfxQ.cjs → stream-route-B6WAjbPG.cjs} +111 -22
- package/cjs/stream-route-B6WAjbPG.cjs.map +1 -0
- package/esm/ai/attach.mjs +92 -0
- package/esm/ai/attach.mjs.map +1 -0
- package/esm/ai/options.mjs +31 -0
- package/esm/ai/options.mjs.map +1 -0
- package/esm/ai/reports/aggregate.mjs +330 -0
- package/esm/ai/reports/aggregate.mjs.map +1 -0
- package/esm/ai/reports/evaluate.mjs +108 -0
- package/esm/ai/reports/evaluate.mjs.map +1 -0
- package/esm/ai/reports/range.mjs +121 -0
- package/esm/ai/reports/range.mjs.map +1 -0
- package/esm/ai/reports/runs.d.mts +2 -0
- package/esm/ai/reports/runs.mjs +212 -0
- package/esm/ai/reports/runs.mjs.map +1 -0
- package/esm/ai/reports/service.mjs +132 -0
- package/esm/ai/reports/service.mjs.map +1 -0
- package/esm/ai/rollup/cascade-store.mjs +84 -0
- package/esm/ai/rollup/cascade-store.mjs.map +1 -0
- package/esm/ai/rollup/categories.mjs +67 -0
- package/esm/ai/rollup/categories.mjs.map +1 -0
- package/esm/ai/rollup/extract.mjs +225 -0
- package/esm/ai/rollup/extract.mjs.map +1 -0
- package/esm/ai/rollup/file-store.mjs +147 -0
- package/esm/ai/rollup/file-store.mjs.map +1 -0
- package/esm/ai/rollup/histogram.mjs +42 -0
- package/esm/ai/rollup/histogram.mjs.map +1 -0
- package/esm/ai/rollup/increment-error.mjs +19 -0
- package/esm/ai/rollup/increment-error.mjs.map +1 -0
- package/esm/ai/rollup/index.mjs +9 -0
- package/esm/ai/rollup/mapping.mjs +69 -0
- package/esm/ai/rollup/mapping.mjs.map +1 -0
- package/esm/ai/rollup/memory-store.mjs +26 -0
- package/esm/ai/rollup/memory-store.mjs.map +1 -0
- package/esm/ai/rollup/writer.mjs +113 -0
- package/esm/ai/rollup/writer.mjs.map +1 -0
- package/esm/ai/types.d.mts +29 -0
- package/esm/ai/types.d.mts.map +1 -0
- package/esm/devtools-connector.d.mts.map +1 -1
- package/esm/devtools-connector.mjs +58 -3
- package/esm/devtools-connector.mjs.map +1 -1
- package/esm/index.d.mts +3 -2
- package/esm/options.mjs +4 -0
- package/esm/options.mjs.map +1 -1
- package/esm/production/boot.mjs +70 -3
- package/esm/production/boot.mjs.map +1 -1
- package/esm/production/contracts.d.mts +388 -6
- package/esm/production/contracts.d.mts.map +1 -1
- package/esm/production/contracts.mjs +64 -2
- package/esm/production/contracts.mjs.map +1 -1
- package/esm/production/errors.mjs +8 -0
- package/esm/production/errors.mjs.map +1 -1
- package/esm/production/http/access.mjs +6 -0
- package/esm/production/http/access.mjs.map +1 -1
- package/esm/production/http/mount.mjs +21 -2
- package/esm/production/http/mount.mjs.map +1 -1
- package/esm/production/http/share.mjs.map +1 -1
- package/esm/production/index.d.mts +2 -2
- package/esm/production/insights/jobs.mjs +45 -11
- package/esm/production/insights/jobs.mjs.map +1 -1
- package/esm/production/store/migrations.d.mts +1 -1
- package/esm/production/store/migrations.d.mts.map +1 -1
- package/esm/production/store/migrations.mjs +4 -2
- package/esm/production/store/migrations.mjs.map +1 -1
- package/esm/production/store/models/ai-rollup.migration.mjs +48 -0
- package/esm/production/store/models/ai-rollup.migration.mjs.map +1 -0
- package/esm/production/store/models/ai-rollup.model.mjs +13 -0
- package/esm/production/store/models/ai-rollup.model.mjs.map +1 -0
- package/esm/production/store/models/index.mjs +3 -1
- package/esm/server/ai-report-routes.mjs +72 -0
- package/esm/server/ai-report-routes.mjs.map +1 -0
- package/esm/server/ai-routes.mjs +22 -1
- package/esm/server/ai-routes.mjs.map +1 -1
- package/esm/server/index.mjs +2 -0
- package/esm/server/index.mjs.map +1 -1
- package/esm/server/panel-routes.mjs.map +1 -1
- package/esm/server/ui-assets.mjs +4 -7
- package/esm/server/ui-assets.mjs.map +1 -1
- package/esm/sources/agent-trace-source.d.mts.map +1 -1
- package/esm/sources/agent-trace-source.mjs.map +1 -1
- package/esm/sources/ai-source.d.mts +2 -0
- package/esm/sources/ai-source.d.mts.map +1 -1
- package/esm/sources/ai-source.mjs +58 -17
- package/esm/sources/ai-source.mjs.map +1 -1
- package/esm/types.d.mts +13 -3
- package/esm/types.d.mts.map +1 -1
- package/llms-full.txt +61 -22
- package/package.json +8 -8
- package/skills/SKILL.md +61 -22
- package/ui/dashboard/assets/app.css +1 -1
- package/ui/dashboard/assets/app.js +12 -5
- package/ui/dashboard/build-info.json +7 -7
- package/cjs/ai-source-BdvMfyKw.cjs +0 -448
- package/cjs/ai-source-BdvMfyKw.cjs.map +0 -1
- package/cjs/app-versions-DfpPZOI2.cjs.map +0 -1
- package/cjs/boot-nczSvJ_F.cjs.map +0 -1
- package/cjs/capture-CuyT8Vab.cjs.map +0 -1
- package/cjs/collector-CJbQbzzK.cjs.map +0 -1
- package/cjs/errors-BadbSDX8.cjs.map +0 -1
- package/cjs/histogram-DTOGnNBW.cjs +0 -102
- package/cjs/histogram-DTOGnNBW.cjs.map +0 -1
- package/cjs/http-Biauhqi0.cjs.map +0 -1
- package/cjs/insights-BjJA6Ret.cjs.map +0 -1
- package/cjs/migrations-BP4cYTGo.cjs.map +0 -1
- package/cjs/options-B9FHbRAJ.cjs +0 -205
- package/cjs/options-B9FHbRAJ.cjs.map +0 -1
- package/cjs/panels-D1ITm-jc.cjs +0 -384
- package/cjs/panels-D1ITm-jc.cjs.map +0 -1
- package/cjs/src-QcNghoYN.cjs.map +0 -1
- package/cjs/stream-route-BqyAlfxQ.cjs.map +0 -1
package/cjs/options-B9FHbRAJ.cjs
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
const require_errors = require("./errors-BadbSDX8.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
|
-
passwords: {
|
|
26
|
-
minLength: 8,
|
|
27
|
-
rejectCommon: true
|
|
28
|
-
},
|
|
29
|
-
rateLimits: {
|
|
30
|
-
windowMinutes: 15,
|
|
31
|
-
account: 5,
|
|
32
|
-
ip: 20,
|
|
33
|
-
global: 100,
|
|
34
|
-
lockMinutes: 15
|
|
35
|
-
},
|
|
36
|
-
explain: { executing: false },
|
|
37
|
-
logLevels: ["warn", "error"],
|
|
38
|
-
auditRetentionDays: 90,
|
|
39
|
-
passkeys: { rpName: "Warlock monitor" },
|
|
40
|
-
share: {
|
|
41
|
-
enabled: false,
|
|
42
|
-
maxDays: 30
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
/** The environment variables production mode reads. */
|
|
46
|
-
const DEVTOOLS_ENV = {
|
|
47
|
-
path: "DEVTOOLS_PATH",
|
|
48
|
-
adminEmail: "DEVTOOLS_ADMIN_EMAIL",
|
|
49
|
-
adminPassword: "DEVTOOLS_ADMIN_PASSWORD",
|
|
50
|
-
setupToken: "DEVTOOLS_SETUP_TOKEN"
|
|
51
|
-
};
|
|
52
|
-
const LOG_LEVELS = [
|
|
53
|
-
"debug",
|
|
54
|
-
"info",
|
|
55
|
-
"warn",
|
|
56
|
-
"error",
|
|
57
|
-
"success"
|
|
58
|
-
];
|
|
59
|
-
const PATH_CHARACTERS = /^[A-Za-z0-9._~/-]+$/;
|
|
60
|
-
const MIN_PATH_LENGTH = 8;
|
|
61
|
-
const MIN_SETUP_TOKEN_LENGTH = 32;
|
|
62
|
-
function invalid(option, expected) {
|
|
63
|
-
throw new require_errors.DevtoolsProductionConfigError("DT007", `Option "devtools.production.${option}" is not valid: ${expected}.`);
|
|
64
|
-
}
|
|
65
|
-
function present(value) {
|
|
66
|
-
return value === void 0 || value === "" ? null : value;
|
|
67
|
-
}
|
|
68
|
-
function integerAtLeastOne(option, value, fallback) {
|
|
69
|
-
if (value === void 0) return fallback;
|
|
70
|
-
if (!Number.isInteger(value) || value < 1) invalid(option, "use a whole number of 1 or more");
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
function networkList(option, value) {
|
|
74
|
-
if (value === void 0) return [];
|
|
75
|
-
if (!Array.isArray(value)) invalid(option, "use a list of IPs, CIDR ranges, \"loopback\" or \"private\"");
|
|
76
|
-
for (const entry of value) if (!require_ip.isValidNetworkEntry(entry)) invalid(option, `"${String(entry)}" is not an IP, a CIDR range, "loopback" or "private"`);
|
|
77
|
-
return [...value];
|
|
78
|
-
}
|
|
79
|
-
/** The dashboard path without a trailing slash, or a DT001/DT002 error. */
|
|
80
|
-
function resolvePath(value) {
|
|
81
|
-
const given = present(value);
|
|
82
|
-
if (given === null) throw new require_errors.DevtoolsProductionConfigError("DT001");
|
|
83
|
-
const path = given.replace(/\/+$/, "");
|
|
84
|
-
const segments = path.split("/").slice(1);
|
|
85
|
-
const lower = path.toLowerCase();
|
|
86
|
-
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");
|
|
87
|
-
return path;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Applies the defaults to `options`, reads the path and first admin from
|
|
91
|
-
* `env`, and validates everything.
|
|
92
|
-
*
|
|
93
|
-
* Throws `DevtoolsProductionConfigError`: DT001 (no path), DT002 (bad path),
|
|
94
|
-
* DT007 (an option out of range: sampleRate outside 0–1, share.maxDays outside 1–365, a non-positive
|
|
95
|
-
* limit, an unknown twoFactor value, a bad CIDR, an origin that is not
|
|
96
|
-
* `https://host[:port]`), DT009 (both a password and a setup token), DT010
|
|
97
|
-
* (setup token shorter than 32 characters). DT003/DT004 (admin) are checked
|
|
98
|
-
* later by `ensureFirstAdmin`, which needs the database.
|
|
99
|
-
*/
|
|
100
|
-
function resolveProductionOptions(options, env) {
|
|
101
|
-
const given = options ?? {};
|
|
102
|
-
const defaults = DEVTOOLS_PRODUCTION_DEFAULTS;
|
|
103
|
-
const path = resolvePath(given.path ?? env[DEVTOOLS_ENV.path]);
|
|
104
|
-
const sampleRate = given.sampleRate ?? defaults.sampleRate;
|
|
105
|
-
if (typeof sampleRate !== "number" || !Number.isFinite(sampleRate) || sampleRate < 0 || sampleRate > 1) invalid("sampleRate", "use a number from 0 to 1");
|
|
106
|
-
const requireHttps = given.requireHttps ?? defaults.requireHttps;
|
|
107
|
-
if (typeof requireHttps !== "boolean") invalid("requireHttps", "use true or false");
|
|
108
|
-
const twoFactor = given.twoFactor ?? defaults.twoFactor;
|
|
109
|
-
if (twoFactor !== "off" && twoFactor !== "admins" && twoFactor !== "everyone") invalid("twoFactor", "use \"off\", \"admins\" or \"everyone\"");
|
|
110
|
-
const minLength = given.passwords?.minLength ?? defaults.passwords.minLength;
|
|
111
|
-
if (!Number.isInteger(minLength) || minLength < 8 || minLength > 72) invalid("passwords.minLength", "use a whole number from 8 to 72 (passwords are limited to 72 bytes, so a longer minimum would refuse every password)");
|
|
112
|
-
const rejectCommon = given.passwords?.rejectCommon ?? defaults.passwords.rejectCommon;
|
|
113
|
-
if (typeof rejectCommon !== "boolean") invalid("passwords.rejectCommon", "use true or false");
|
|
114
|
-
const origin = given.origin ?? null;
|
|
115
|
-
if (origin !== null) {
|
|
116
|
-
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");
|
|
117
|
-
}
|
|
118
|
-
const panels = given.panels ?? {};
|
|
119
|
-
if (panels === null || typeof panels !== "object" || Array.isArray(panels)) invalid("panels", "use an object of tab ids and true or false");
|
|
120
|
-
for (const [id, enabled] of Object.entries(panels)) if (typeof enabled !== "boolean") invalid(`panels.${id}`, "use true or false");
|
|
121
|
-
const logLevels = given.logLevels ?? defaults.logLevels;
|
|
122
|
-
if (!Array.isArray(logLevels) || logLevels.some((level) => !LOG_LEVELS.includes(level))) invalid("logLevels", `use a list of ${LOG_LEVELS.join(", ")}`);
|
|
123
|
-
const executing = given.explain?.executing ?? defaults.explain.executing;
|
|
124
|
-
if (typeof executing !== "boolean") invalid("explain.executing", "use true or false");
|
|
125
|
-
const rpName = given.passkeys?.rpName ?? defaults.passkeys.rpName;
|
|
126
|
-
const rpId = given.passkeys?.rpId ?? null;
|
|
127
|
-
if (typeof rpName !== "string" || rpName.trim() === "") invalid("passkeys.rpName", "use a non-empty name");
|
|
128
|
-
if (rpId !== null && (typeof rpId !== "string" || rpId.trim() === "")) invalid("passkeys.rpId", "use a host name such as app.example.com");
|
|
129
|
-
const shareEnabled = given.share?.enabled ?? defaults.share.enabled;
|
|
130
|
-
const shareMaxDays = given.share?.maxDays ?? defaults.share.maxDays;
|
|
131
|
-
if (typeof shareEnabled !== "boolean") invalid("share.enabled", "use true or false");
|
|
132
|
-
if (!Number.isInteger(shareMaxDays) || shareMaxDays < 1 || shareMaxDays > 365) invalid("share.maxDays", "use a whole number of days from 1 to 365");
|
|
133
|
-
const limits = given.rateLimits ?? {};
|
|
134
|
-
const session = given.session ?? {};
|
|
135
|
-
const resolved = {
|
|
136
|
-
path,
|
|
137
|
-
admin: {
|
|
138
|
-
email: present(env[DEVTOOLS_ENV.adminEmail]),
|
|
139
|
-
password: present(env[DEVTOOLS_ENV.adminPassword]),
|
|
140
|
-
setupToken: present(env[DEVTOOLS_ENV.setupToken])
|
|
141
|
-
},
|
|
142
|
-
sampleRate,
|
|
143
|
-
slowRequestMs: integerAtLeastOne("slowRequestMs", given.slowRequestMs, defaults.slowRequestMs),
|
|
144
|
-
slowQueryMs: integerAtLeastOne("slowQueryMs", given.slowQueryMs, defaults.slowQueryMs),
|
|
145
|
-
maxRequests: integerAtLeastOne("maxRequests", given.maxRequests, defaults.maxRequests),
|
|
146
|
-
maxQueriesPerRequest: defaults.maxQueriesPerRequest,
|
|
147
|
-
maxShapes: defaults.maxShapes,
|
|
148
|
-
maxRoutes: defaults.maxRoutes,
|
|
149
|
-
maxErrorGroups: defaults.maxErrorGroups,
|
|
150
|
-
requestRetentionHours: integerAtLeastOne("requestRetentionHours", given.requestRetentionHours, defaults.requestRetentionHours),
|
|
151
|
-
maxStoredSamplesPerMinute: integerAtLeastOne("maxStoredSamplesPerMinute", given.maxStoredSamplesPerMinute, defaults.maxStoredSamplesPerMinute),
|
|
152
|
-
reportIntervalMs: integerAtLeastOne("reportIntervalMs", given.reportIntervalMs, defaults.reportIntervalMs),
|
|
153
|
-
trustedProxies: networkList("trustedProxies", given.trustedProxies),
|
|
154
|
-
requireHttps,
|
|
155
|
-
allowedIps: networkList("allowedIps", given.allowedIps),
|
|
156
|
-
origin,
|
|
157
|
-
session: {
|
|
158
|
-
idleMinutes: integerAtLeastOne("session.idleMinutes", session.idleMinutes, defaults.session.idleMinutes),
|
|
159
|
-
maxHours: integerAtLeastOne("session.maxHours", session.maxHours, defaults.session.maxHours),
|
|
160
|
-
pendingMinutes: defaults.session.pendingMinutes
|
|
161
|
-
},
|
|
162
|
-
twoFactor,
|
|
163
|
-
passwords: {
|
|
164
|
-
minLength,
|
|
165
|
-
rejectCommon
|
|
166
|
-
},
|
|
167
|
-
rateLimits: {
|
|
168
|
-
windowMinutes: integerAtLeastOne("rateLimits.windowMinutes", limits.windowMinutes, defaults.rateLimits.windowMinutes),
|
|
169
|
-
account: integerAtLeastOne("rateLimits.account", limits.account, defaults.rateLimits.account),
|
|
170
|
-
ip: integerAtLeastOne("rateLimits.ip", limits.ip, defaults.rateLimits.ip),
|
|
171
|
-
global: integerAtLeastOne("rateLimits.global", limits.global, defaults.rateLimits.global),
|
|
172
|
-
lockMinutes: integerAtLeastOne("rateLimits.lockMinutes", limits.lockMinutes, defaults.rateLimits.lockMinutes)
|
|
173
|
-
},
|
|
174
|
-
explain: { executing },
|
|
175
|
-
panels: { ...panels },
|
|
176
|
-
logLevels: [...logLevels],
|
|
177
|
-
auditRetentionDays: integerAtLeastOne("auditRetentionDays", given.auditRetentionDays, defaults.auditRetentionDays),
|
|
178
|
-
passkeys: {
|
|
179
|
-
rpName,
|
|
180
|
-
rpId
|
|
181
|
-
},
|
|
182
|
-
share: {
|
|
183
|
-
enabled: shareEnabled,
|
|
184
|
-
maxDays: shareMaxDays
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
if (resolved.admin.password !== null && resolved.admin.setupToken !== null) throw new require_errors.DevtoolsProductionConfigError("DT009");
|
|
188
|
-
if (resolved.admin.setupToken !== null && resolved.admin.setupToken.length < MIN_SETUP_TOKEN_LENGTH) throw new require_errors.DevtoolsProductionConfigError("DT010");
|
|
189
|
-
return resolved;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
//#endregion
|
|
193
|
-
Object.defineProperty(exports, "DEVTOOLS_PRODUCTION_DEFAULTS", {
|
|
194
|
-
enumerable: true,
|
|
195
|
-
get: function () {
|
|
196
|
-
return DEVTOOLS_PRODUCTION_DEFAULTS;
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
Object.defineProperty(exports, "resolveProductionOptions", {
|
|
200
|
-
enumerable: true,
|
|
201
|
-
get: function () {
|
|
202
|
-
return resolveProductionOptions;
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
//# sourceMappingURL=options-B9FHbRAJ.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options-B9FHbRAJ.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: \"off\" | \"admins\" | \"everyone\";\n passwords: { minLength: number; rejectCommon: boolean };\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 /** Read-only share links. */\n share: { enabled: boolean; maxDays: number };\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 passwords: { minLength: 8, rejectCommon: true },\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 share: { enabled: false, maxDays: 30 },\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, share.maxDays outside 1–365, 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 !== \"off\" && twoFactor !== \"admins\" && twoFactor !== \"everyone\") {\n invalid(\"twoFactor\", 'use \"off\", \"admins\" or \"everyone\"');\n }\n\n const minLength: number = given.passwords?.minLength ?? defaults.passwords.minLength;\n\n if (!Number.isInteger(minLength) || minLength < 8 || minLength > 72) {\n invalid(\n \"passwords.minLength\",\n \"use a whole number from 8 to 72 (passwords are limited to 72 bytes, so a longer minimum would refuse every password)\",\n );\n }\n\n const rejectCommon: boolean = given.passwords?.rejectCommon ?? defaults.passwords.rejectCommon;\n\n if (typeof rejectCommon !== \"boolean\") invalid(\"passwords.rejectCommon\", \"use true or false\");\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 shareEnabled: boolean = given.share?.enabled ?? defaults.share.enabled;\n const shareMaxDays: number = given.share?.maxDays ?? defaults.share.maxDays;\n\n if (typeof shareEnabled !== \"boolean\") invalid(\"share.enabled\", \"use true or false\");\n\n if (!Number.isInteger(shareMaxDays) || shareMaxDays < 1 || shareMaxDays > 365) {\n invalid(\"share.maxDays\", \"use a whole number of days from 1 to 365\");\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 passwords: { minLength, rejectCommon },\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 share: { enabled: shareEnabled, maxDays: shareMaxDays },\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":";;;;;AAoDA,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,WAAW;EAAE,WAAW;EAAG,cAAc;CAAK;CAC9C,YAAY;EAAE,eAAe;EAAI,SAAS;EAAG,IAAI;EAAI,QAAQ;EAAK,aAAa;CAAG;CAClF,SAAS,EAAE,WAAW,MAAM;CAC5B,WAAW,CAAC,QAAQ,OAAO;CAC3B,oBAAoB;CACpB,UAAU,EAAE,QAAQ,kBAAkB;CACtC,OAAO;EAAE,SAAS;EAAO,SAAS;CAAG;AACvC;;AAGA,MAAa,eAAe;CAC1B,MAAM;CACN,YAAY;CACZ,eAAe;CAC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|
-
let node_fs = require("node:fs");
|
|
3
|
-
let node_module = require("node:module");
|
|
4
|
-
let node_path = require("node:path");
|
|
5
|
-
node_path = require_app_versions.__toESM(node_path, 1);
|
|
6
|
-
let node_url = require("node:url");
|
|
7
|
-
|
|
8
|
-
//#region ../../packages/devtools/src/panels.ts
|
|
9
|
-
/** The extensions a panel serves from `files` when it lists none. */
|
|
10
|
-
const DEFAULT_PANEL_FILE_EXTENSIONS = [
|
|
11
|
-
".png",
|
|
12
|
-
".jpg",
|
|
13
|
-
".jpeg",
|
|
14
|
-
".webp",
|
|
15
|
-
".gif"
|
|
16
|
-
];
|
|
17
|
-
/** Extensions a panel may never serve from `files`: a browser runs or renders them as a page. */
|
|
18
|
-
const BLOCKED_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
19
|
-
".svg",
|
|
20
|
-
".html",
|
|
21
|
-
".htm",
|
|
22
|
-
".js",
|
|
23
|
-
".mjs"
|
|
24
|
-
]);
|
|
25
|
-
/**
|
|
26
|
-
* Ids the dashboard already uses for its own tabs, API segments and URLs. A
|
|
27
|
-
* panel's routes live under `<path>/api/<id>`, so these would collide.
|
|
28
|
-
*/
|
|
29
|
-
const RESERVED_PANEL_IDS = /* @__PURE__ */ new Set([
|
|
30
|
-
"account",
|
|
31
|
-
"admin",
|
|
32
|
-
"agents",
|
|
33
|
-
"ai",
|
|
34
|
-
"api",
|
|
35
|
-
"assets",
|
|
36
|
-
"auth",
|
|
37
|
-
"background",
|
|
38
|
-
"docs",
|
|
39
|
-
"errors",
|
|
40
|
-
"health",
|
|
41
|
-
"instances",
|
|
42
|
-
"jobs",
|
|
43
|
-
"logs",
|
|
44
|
-
"mail",
|
|
45
|
-
"mails",
|
|
46
|
-
"panels",
|
|
47
|
-
"queries",
|
|
48
|
-
"requests",
|
|
49
|
-
"resources",
|
|
50
|
-
"routes",
|
|
51
|
-
"share",
|
|
52
|
-
"stream"
|
|
53
|
-
]);
|
|
54
|
-
const PANEL_ID = /^[a-z][a-z0-9-]*$/;
|
|
55
|
-
const ASSET_NAME = /^[A-Za-z0-9_][A-Za-z0-9._-]*$/;
|
|
56
|
-
const METHODS = /* @__PURE__ */ new Set([
|
|
57
|
-
"GET",
|
|
58
|
-
"POST",
|
|
59
|
-
"PUT",
|
|
60
|
-
"PATCH",
|
|
61
|
-
"DELETE"
|
|
62
|
-
]);
|
|
63
|
-
/** Content types for the files a panel may serve; anything else is sent as bytes. */
|
|
64
|
-
const CONTENT_TYPES = {
|
|
65
|
-
".js": "text/javascript; charset=utf-8",
|
|
66
|
-
".mjs": "text/javascript; charset=utf-8",
|
|
67
|
-
".css": "text/css; charset=utf-8",
|
|
68
|
-
".json": "application/json; charset=utf-8",
|
|
69
|
-
".svg": "image/svg+xml",
|
|
70
|
-
".png": "image/png",
|
|
71
|
-
".jpg": "image/jpeg",
|
|
72
|
-
".jpeg": "image/jpeg",
|
|
73
|
-
".webp": "image/webp",
|
|
74
|
-
".gif": "image/gif",
|
|
75
|
-
".woff2": "font/woff2"
|
|
76
|
-
};
|
|
77
|
-
/** The content type a panel file is served with, from its served name. */
|
|
78
|
-
function panelContentType(name) {
|
|
79
|
-
return CONTENT_TYPES[node_path.default.extname(name).toLowerCase()] ?? "application/octet-stream";
|
|
80
|
-
}
|
|
81
|
-
/** An absolute file path from a path or `file:` URL, or `undefined` for anything else. */
|
|
82
|
-
function toFilePath(value) {
|
|
83
|
-
if (value instanceof URL) return value.protocol === "file:" ? (0, node_url.fileURLToPath)(value) : void 0;
|
|
84
|
-
if (typeof value !== "string" || value === "") return void 0;
|
|
85
|
-
if (value.startsWith("file:")) return (0, node_url.fileURLToPath)(value);
|
|
86
|
-
return node_path.default.isAbsolute(value) ? value : void 0;
|
|
87
|
-
}
|
|
88
|
-
function isFile(file) {
|
|
89
|
-
return (0, node_fs.existsSync)(file) && (0, node_fs.statSync)(file).isFile();
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Validates `value` as a panel and returns it ready to mount. Throws an
|
|
93
|
-
* error that names the panel and what to change; `taken` maps the ids
|
|
94
|
-
* already registered to their titles and receives this panel's id.
|
|
95
|
-
*/
|
|
96
|
-
function checkDevtoolsPanel(value, taken) {
|
|
97
|
-
const panel = value ?? {};
|
|
98
|
-
const id = panel.id;
|
|
99
|
-
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)}.`);
|
|
100
|
-
if (RESERVED_PANEL_IDS.has(id)) throw new Error(`Devtools panel id "${id}" is used by the dashboard itself; give the panel another id.`);
|
|
101
|
-
const existing = taken.get(id);
|
|
102
|
-
if (existing !== void 0) throw new Error(`Devtools panel id "${id}" is already registered by the "${existing}" panel; each panel needs its own id.`);
|
|
103
|
-
if (typeof panel.title !== "string" || panel.title.trim() === "") throw new Error(`Devtools panel "${id}" needs a "title" for its tab.`);
|
|
104
|
-
const view = toFilePath(panel.view);
|
|
105
|
-
if (view === void 0) throw new Error(`Devtools panel "${id}" needs a "view": an absolute path or file: URL of its browser module.`);
|
|
106
|
-
if (!isFile(view)) throw new Error(`The view module of devtools panel "${id}" was not found at ${view}.`);
|
|
107
|
-
const seen = /* @__PURE__ */ new Set();
|
|
108
|
-
const routes = (panel.routes ?? []).map((route) => {
|
|
109
|
-
const method = route.method ?? "GET";
|
|
110
|
-
if (!METHODS.has(method)) throw new Error(`Devtools panel "${id}" has a route with method "${String(method)}"; use GET, POST, PUT, PATCH or DELETE.`);
|
|
111
|
-
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 "/".`);
|
|
112
|
-
if (typeof route.handler !== "function") throw new Error(`Devtools panel "${id}" route ${method} "${route.path}" has no handler.`);
|
|
113
|
-
if (seen.has(`${method} ${route.path}`)) throw new Error(`Devtools panel "${id}" lists route ${method} "${route.path}" twice; keep one.`);
|
|
114
|
-
seen.add(`${method} ${route.path}`);
|
|
115
|
-
return {
|
|
116
|
-
...route,
|
|
117
|
-
method
|
|
118
|
-
};
|
|
119
|
-
});
|
|
120
|
-
const assets = {};
|
|
121
|
-
for (const [name, source] of Object.entries(panel.assets ?? {})) {
|
|
122
|
-
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".`);
|
|
123
|
-
const file = toFilePath(source);
|
|
124
|
-
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.`);
|
|
125
|
-
assets[name] = file;
|
|
126
|
-
}
|
|
127
|
-
const files = checkPanelFiles(id, panel.files);
|
|
128
|
-
const share = checkPanelShare(id, panel.share, routes, assets, files !== null);
|
|
129
|
-
taken.set(id, panel.title);
|
|
130
|
-
return {
|
|
131
|
-
id,
|
|
132
|
-
title: panel.title,
|
|
133
|
-
view,
|
|
134
|
-
routes,
|
|
135
|
-
assets,
|
|
136
|
-
files,
|
|
137
|
-
share,
|
|
138
|
-
production: panel.production === true
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
const FILE_EXTENSION = /^\.[a-z0-9]{1,16}$/;
|
|
142
|
-
/** Validates `files`; `null` when the panel declares none. */
|
|
143
|
-
function checkPanelFiles(id, value) {
|
|
144
|
-
if (value === void 0 || value === null) return null;
|
|
145
|
-
if (typeof value !== "object") throw new Error(`Devtools panel "${id}" has files that is not an object; use { dir: "/absolute/folder" }.`);
|
|
146
|
-
const dir = toFilePath(value.dir);
|
|
147
|
-
if (dir === void 0) throw new Error(`Devtools panel "${id}" needs files.dir to be an absolute path or a file: URL; got ${String(value.dir)}.`);
|
|
148
|
-
const given = value.extensions;
|
|
149
|
-
if (given !== void 0 && (!Array.isArray(given) || given.length === 0)) throw new Error(`Devtools panel "${id}" has files.extensions that is not a list; use [".png", ".jpg"] or leave it out.`);
|
|
150
|
-
for (const extension of given ?? []) {
|
|
151
|
-
if (typeof extension !== "string" || !FILE_EXTENSION.test(extension)) throw new Error(`Devtools panel "${id}" has files.extensions entry ${JSON.stringify(extension)}; use lower-case extensions that start with a dot, such as ".png".`);
|
|
152
|
-
if (BLOCKED_FILE_EXTENSIONS.has(extension)) throw new Error(`Devtools panel "${id}" lists files.extensions entry "${extension}", which can run as a page or script in the browser; remove it (images such as .png, .jpg, .webp and .gif are fine).`);
|
|
153
|
-
}
|
|
154
|
-
return {
|
|
155
|
-
dir,
|
|
156
|
-
extensions: [...given ?? DEFAULT_PANEL_FILE_EXTENSIONS]
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
/** Validates `share` against the panel's own routes, assets and files. */
|
|
160
|
-
function checkPanelShare(id, value, routes, assets, hasFiles) {
|
|
161
|
-
if (value === void 0 || value === null) return null;
|
|
162
|
-
if (typeof value !== "object") throw new Error(`Devtools panel "${id}" has share that is not an object; use { view, routes }.`);
|
|
163
|
-
const view = toFilePath(value.view);
|
|
164
|
-
if (view === void 0) throw new Error(`Devtools panel "${id}" needs share.view: an absolute path or file: URL of the shared view module.`);
|
|
165
|
-
if (!isFile(view)) throw new Error(`The share.view module of devtools panel "${id}" was not found at ${view}.`);
|
|
166
|
-
if (!Array.isArray(value.routes)) throw new Error(`Devtools panel "${id}" needs share.routes: a list of the paths of its GET routes the shared page may call.`);
|
|
167
|
-
const getPaths = routes.filter((route) => route.method === "GET").map((route) => route.path);
|
|
168
|
-
for (const route of value.routes) if (typeof route !== "string" || !getPaths.includes(route)) throw new Error(`Devtools panel "${id}" lists share.routes entry ${JSON.stringify(route)}, which is not the path of one of its GET routes${getPaths.length > 0 ? `; use one of ${getPaths.map((path) => JSON.stringify(path)).join(", ")}` : " (the panel has no GET routes)"}.`);
|
|
169
|
-
for (const name of value.assets ?? []) if (typeof name !== "string" || !Object.hasOwn(assets, name)) throw new Error(`Devtools panel "${id}" lists share.assets entry ${JSON.stringify(name)}, which is not a name in its assets; use one of ${Object.keys(assets).join(", ") || "(the panel has no assets)"}.`);
|
|
170
|
-
const files = value.files === true;
|
|
171
|
-
if (value.files !== void 0 && typeof value.files !== "boolean") throw new Error(`Devtools panel "${id}" needs share.files to be true or false.`);
|
|
172
|
-
if (files && !hasFiles) throw new Error(`Devtools panel "${id}" sets share.files, but the panel has no files folder; add files: { dir } or remove share.files.`);
|
|
173
|
-
return {
|
|
174
|
-
view,
|
|
175
|
-
routes: [...value.routes],
|
|
176
|
-
assets: [...value.assets ?? []],
|
|
177
|
-
files
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
/** Validates a list of panels; the first invalid or duplicate one throws. */
|
|
181
|
-
function checkDevtoolsPanels(panels) {
|
|
182
|
-
const taken = /* @__PURE__ */ new Map();
|
|
183
|
-
return panels.map((panel) => checkDevtoolsPanel(panel, taken));
|
|
184
|
-
}
|
|
185
|
-
function isPlainObject(value) {
|
|
186
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
187
|
-
const prototype = Object.getPrototypeOf(value);
|
|
188
|
-
return prototype === Object.prototype || prototype === null;
|
|
189
|
-
}
|
|
190
|
-
/** What is wrong with a `[specifier, options]` entry, or `undefined` when it is valid. */
|
|
191
|
-
function tupleProblem(entry) {
|
|
192
|
-
if (entry.length !== 2) return `it has ${entry.length} item(s); use exactly [specifier, options]`;
|
|
193
|
-
if (typeof entry[0] !== "string" || entry[0] === "") return `its first item is ${JSON.stringify(entry[0])}; use the module specifier as a string`;
|
|
194
|
-
if (!isPlainObject(entry[1])) return `its second item is not a plain object; pass the options as { name: value }`;
|
|
195
|
-
}
|
|
196
|
-
/** The URL or specifier to import for a `panels` entry. */
|
|
197
|
-
function resolvePanelSpecifier(entry, root) {
|
|
198
|
-
if (entry.startsWith("./") || entry.startsWith("../") || node_path.default.isAbsolute(entry)) return (0, node_url.pathToFileURL)(node_path.default.resolve(root, entry)).href;
|
|
199
|
-
return resolveFromNodeModules(entry, root) ?? resolveWithRequire(entry, root) ?? entry;
|
|
200
|
-
}
|
|
201
|
-
/** Picks the file an `exports` target names: `import`, then `default`, then `node`. */
|
|
202
|
-
function exportTarget(target) {
|
|
203
|
-
if (typeof target === "string") return target;
|
|
204
|
-
if (Array.isArray(target)) {
|
|
205
|
-
for (const item of target) {
|
|
206
|
-
const found = exportTarget(item);
|
|
207
|
-
if (found !== void 0) return found;
|
|
208
|
-
}
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
if (target !== null && typeof target === "object") {
|
|
212
|
-
const conditions = target;
|
|
213
|
-
for (const condition of [
|
|
214
|
-
"import",
|
|
215
|
-
"node",
|
|
216
|
-
"default"
|
|
217
|
-
]) {
|
|
218
|
-
const found = exportTarget(conditions[condition]);
|
|
219
|
-
if (found !== void 0) return found;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Resolves a package specifier by looking it up in the `node_modules` folders
|
|
225
|
-
* above the app root and reading its `exports` map. `createRequire().resolve`
|
|
226
|
-
* cannot do this for a package that only has an `import` condition.
|
|
227
|
-
*/
|
|
228
|
-
function resolveFromNodeModules(entry, root) {
|
|
229
|
-
const parts = entry.split("/");
|
|
230
|
-
const nameLength = entry.startsWith("@") ? 2 : 1;
|
|
231
|
-
const name = parts.slice(0, nameLength).join("/");
|
|
232
|
-
const subpath = parts.length > nameLength ? `./${parts.slice(nameLength).join("/")}` : ".";
|
|
233
|
-
if (!name) return void 0;
|
|
234
|
-
let directory = node_path.default.resolve(root);
|
|
235
|
-
for (;;) {
|
|
236
|
-
const packageDirectory = node_path.default.join(directory, "node_modules", name);
|
|
237
|
-
const manifestFile = node_path.default.join(packageDirectory, "package.json");
|
|
238
|
-
if ((0, node_fs.existsSync)(manifestFile)) try {
|
|
239
|
-
const manifest = JSON.parse((0, node_fs.readFileSync)(manifestFile, "utf8"));
|
|
240
|
-
const exported = manifest.exports;
|
|
241
|
-
const map = exported !== null && typeof exported === "object" && !Array.isArray(exported) ? exported : void 0;
|
|
242
|
-
const hasSubpaths = map !== void 0 && Object.keys(map).some((key) => key.startsWith("."));
|
|
243
|
-
const target = exported === void 0 ? subpath === "." ? manifest.main ?? "index.js" : subpath : hasSubpaths ? exportTarget(map?.[subpath]) : subpath === "." ? exportTarget(exported) : void 0;
|
|
244
|
-
if (target === void 0) return void 0;
|
|
245
|
-
const file = node_path.default.resolve(packageDirectory, target);
|
|
246
|
-
return isFile(file) ? (0, node_url.pathToFileURL)(file).href : void 0;
|
|
247
|
-
} catch {
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
const parent = node_path.default.dirname(directory);
|
|
251
|
-
if (parent === directory) return void 0;
|
|
252
|
-
directory = parent;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
/** The `require` resolution, for packages the `node_modules` lookup does not understand. */
|
|
256
|
-
function resolveWithRequire(entry, root) {
|
|
257
|
-
try {
|
|
258
|
-
return (0, node_url.pathToFileURL)((0, node_module.createRequire)(node_path.default.join(root, "package.json")).resolve(entry)).href;
|
|
259
|
-
} catch {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
/** The panels a module's default export describes. */
|
|
264
|
-
async function panelsOf(exported, root, mode, panelOptions = {}, errors) {
|
|
265
|
-
const value = typeof exported === "function" ? await exported({
|
|
266
|
-
...panelOptions,
|
|
267
|
-
root,
|
|
268
|
-
mode,
|
|
269
|
-
...errors ? { errors } : {}
|
|
270
|
-
}) : exported;
|
|
271
|
-
return Array.isArray(value) ? value : [value];
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Loads the devtools `panels` option: imports each module entry, reads its
|
|
275
|
-
* default export, and validates every panel. An entry that fails to load and
|
|
276
|
-
* a panel that is invalid or reuses an id are reported through `warn` and
|
|
277
|
-
* skipped, so one broken panel never stops the dashboard.
|
|
278
|
-
*/
|
|
279
|
-
async function loadDevtoolsPanels(entries, options) {
|
|
280
|
-
if (!Array.isArray(entries)) {
|
|
281
|
-
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.`);
|
|
282
|
-
return [];
|
|
283
|
-
}
|
|
284
|
-
const importModule = options.importModule ?? ((specifier) => import(specifier));
|
|
285
|
-
const mode = options.mode ?? "development";
|
|
286
|
-
const taken = new Map(options.taken ?? []);
|
|
287
|
-
const panels = [];
|
|
288
|
-
for (const entry of entries) {
|
|
289
|
-
let candidates;
|
|
290
|
-
try {
|
|
291
|
-
if (Array.isArray(entry)) {
|
|
292
|
-
const problem = tupleProblem(entry);
|
|
293
|
-
if (problem !== void 0) {
|
|
294
|
-
options.warn(`Devtools panels entry ${JSON.stringify(entry)} is invalid: ${problem}. Example: ["@warlock.js/grimoire/devtools", { ttlMs: 60000 }]. The entry was not added.`);
|
|
295
|
-
continue;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
if (typeof entry === "string" || Array.isArray(entry)) {
|
|
299
|
-
const [specifier, panelOptions] = typeof entry === "string" ? [entry, void 0] : entry;
|
|
300
|
-
const module = await importModule(resolvePanelSpecifier(specifier, options.root));
|
|
301
|
-
if (module.default === void 0) throw new Error("the module has no default export");
|
|
302
|
-
candidates = await panelsOf(module.default, options.root, mode, panelOptions, options.errors);
|
|
303
|
-
} else candidates = [entry];
|
|
304
|
-
} catch (error) {
|
|
305
|
-
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.`);
|
|
306
|
-
continue;
|
|
307
|
-
}
|
|
308
|
-
for (const candidate of candidates) try {
|
|
309
|
-
panels.push(checkDevtoolsPanel(candidate, taken));
|
|
310
|
-
} catch (error) {
|
|
311
|
-
options.warn(`${describe(error)} The panel was not added.`);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return panels;
|
|
315
|
-
}
|
|
316
|
-
function describe(error) {
|
|
317
|
-
return error instanceof Error ? error.message : String(error);
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Which tabs the production monitor shows. A built-in tab follows
|
|
321
|
-
* `DEVTOOLS_BUILT_IN_PANELS` unless `overrides[id]` says otherwise. A package
|
|
322
|
-
* panel (the Processes panel included) shows when it declares
|
|
323
|
-
* `production: true` or `overrides[id]` is `true`; `overrides[id]: false` turns
|
|
324
|
-
* any tab off.
|
|
325
|
-
*/
|
|
326
|
-
function productionPanels(packagePanels, overrides = {}) {
|
|
327
|
-
return {
|
|
328
|
-
builtIn: require_app_versions.DEVTOOLS_BUILT_IN_PANELS.filter((tab) => overrides[tab.id] ?? tab.production).map((tab) => tab.id),
|
|
329
|
-
panels: packagePanels.filter((panel) => overrides[panel.id] ?? panel.production)
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* The tab list `GET api/panels` answers with: the built-in tabs in
|
|
334
|
-
* `builtIn` (default: every one), in display order, then the package panels
|
|
335
|
-
* in registration order.
|
|
336
|
-
*/
|
|
337
|
-
function listPanelInfos(panels, builtIn) {
|
|
338
|
-
const tabs = require_app_versions.DEVTOOLS_BUILT_IN_PANELS.filter((tab) => builtIn === void 0 || builtIn.includes(tab.id)).map((tab) => ({
|
|
339
|
-
id: tab.id,
|
|
340
|
-
title: tab.title,
|
|
341
|
-
type: "built-in",
|
|
342
|
-
shareable: false
|
|
343
|
-
}));
|
|
344
|
-
for (const panel of panels) tabs.push({
|
|
345
|
-
id: panel.id,
|
|
346
|
-
title: panel.title,
|
|
347
|
-
type: "package",
|
|
348
|
-
shareable: panel.share !== void 0 && panel.share !== null
|
|
349
|
-
});
|
|
350
|
-
return tabs;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
//#endregion
|
|
354
|
-
Object.defineProperty(exports, "checkDevtoolsPanels", {
|
|
355
|
-
enumerable: true,
|
|
356
|
-
get: function () {
|
|
357
|
-
return checkDevtoolsPanels;
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
Object.defineProperty(exports, "listPanelInfos", {
|
|
361
|
-
enumerable: true,
|
|
362
|
-
get: function () {
|
|
363
|
-
return listPanelInfos;
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
Object.defineProperty(exports, "loadDevtoolsPanels", {
|
|
367
|
-
enumerable: true,
|
|
368
|
-
get: function () {
|
|
369
|
-
return loadDevtoolsPanels;
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
Object.defineProperty(exports, "panelContentType", {
|
|
373
|
-
enumerable: true,
|
|
374
|
-
get: function () {
|
|
375
|
-
return panelContentType;
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
Object.defineProperty(exports, "productionPanels", {
|
|
379
|
-
enumerable: true,
|
|
380
|
-
get: function () {
|
|
381
|
-
return productionPanels;
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
//# sourceMappingURL=panels-D1ITm-jc.cjs.map
|