@brickkit/cli 0.11.0 → 0.13.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/dashboard-dist/CollapsiblePanel-CbUysOp5.js +2 -0
- package/dashboard-dist/CompositeRoot-D4sRkYq3.js +1 -0
- package/dashboard-dist/Geist-Variable.woff2 +0 -0
- package/dashboard-dist/GeistMono-Variable.woff2 +0 -0
- package/dashboard-dist/PopoverPopup-CiI2avT_.js +1 -0
- package/dashboard-dist/api-reference-mT9VNcPb.js +265 -0
- package/dashboard-dist/app.css +2 -2
- package/dashboard-dist/app.js +12 -13
- package/dashboard-dist/ccount-CcG1m-Yh.js +1 -0
- package/dashboard-dist/client-CwATkLJa.js +1 -0
- package/dashboard-dist/core-BEUWp6B5.js +1 -0
- package/dashboard-dist/docs-BRrtyxDB.js +4 -0
- package/dashboard-dist/docs.css +1 -1
- package/dashboard-dist/kit.js +1 -1
- package/dashboard-dist/popover-Bj9x-88h.js +1 -0
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +309 -211
- package/dist/bin.js.map +1 -1
- package/dist/build.js +463 -0
- package/dist/build.js.map +1 -0
- package/dist/client-contract-file.js +356 -1
- package/dist/client-contract-file.js.map +1 -0
- package/dist/compiler.d.ts +12 -3
- package/dist/compiler.js +1 -1
- package/dist/compiler2.js +13 -7
- package/dist/compiler2.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.js +1 -252
- package/dist/config2.d.ts +122 -0
- package/dist/config2.js +207 -0
- package/dist/config2.js.map +1 -0
- package/dist/dashboard-extension.d.ts +3 -2
- package/dist/{dev-telemetry-store.js → dashboard-host.js} +1381 -1432
- package/dist/dashboard-host.js.map +1 -0
- package/dist/dashboard-protocol.js +189 -0
- package/dist/dashboard-protocol.js.map +1 -0
- package/dist/dashboard.d.ts +8 -135
- package/dist/definitions.js +33 -0
- package/dist/definitions.js.map +1 -0
- package/dist/dev-application.js +34 -0
- package/dist/dev-application.js.map +1 -0
- package/dist/dev-protocol.js +21 -0
- package/dist/dev-protocol.js.map +1 -0
- package/dist/dev-reporter.d.ts +0 -2
- package/dist/dev-reporter.js +3 -3
- package/dist/dev-reporter.js.map +1 -1
- package/dist/dev-telemetry.js +8 -24
- package/dist/dev-telemetry.js.map +1 -1
- package/dist/dev-worker.js +80 -21
- package/dist/dev-worker.js.map +1 -1
- package/dist/index.d.ts +18 -87
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -0
- package/dist/lint/oxlint.d.ts +0 -2
- package/dist/lint/oxlint.js +6 -5
- package/dist/lint/oxlint.js.map +1 -1
- package/dist/own-module.js +7 -0
- package/dist/own-module.js.map +1 -0
- package/dist/plugin.d.ts +6 -11
- package/dist/plugin.js +6 -42
- package/dist/plugin.js.map +1 -1
- package/dist/production-dashboard.d.ts +2 -0
- package/dist/production-dashboard.js +51 -0
- package/dist/production-dashboard.js.map +1 -0
- package/dist/production-dashboard2.d.ts +34 -0
- package/dist/{presets.js → project.js} +107 -113
- package/dist/project.js.map +1 -0
- package/dist/serve.d.ts +24 -0
- package/dist/serve.js +1 -0
- package/dist/serve2.js +49 -0
- package/dist/serve2.js.map +1 -0
- package/dist/vite.d.ts +0 -2
- package/dist/vite.js +28 -51
- package/dist/vite.js.map +1 -1
- package/dist/workflows.d.ts +2 -4
- package/dist/workflows2.js +60 -39
- package/dist/workflows2.js.map +1 -1
- package/inspector-dist/client/assets/api.rpc-BvRk9kiK.js +0 -0
- package/inspector-dist/client/assets/api.stream._streamId-BvRk9kiK.js +0 -0
- package/inspector-dist/client/assets/app-CeSwVsRm.css +2 -0
- package/inspector-dist/client/assets/dist-BK8w6xOr.js +3930 -0
- package/inspector-dist/client/assets/dist-CG2aVufI.js +197 -0
- package/inspector-dist/client/assets/entry.client-D9jbgmTR.js +9391 -0
- package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-CfRnuITN.js +34 -0
- package/inspector-dist/client/assets/home-hwPlkNhv.js +4034 -0
- package/inspector-dist/client/assets/jsx-runtime-CPEah4WQ.js +7084 -0
- package/inspector-dist/client/assets/manifest-0e76e9ac.js +1 -0
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-ZDR2PNY_.js +1 -0
- package/inspector-dist/client/assets/root-ChBNTZd2.css +2 -0
- package/inspector-dist/client/assets/root-SLeEf-sT.js +320 -0
- package/inspector-dist/client/assets/run-detail-DYbVkIFH.js +1871 -0
- package/inspector-dist/client/assets/tabs-CaJisoyb.js +73751 -0
- package/inspector-dist/client/assets/tabs-L5XKzOpP.css +1 -0
- package/inspector-dist/client/assets/zstd-browser-decoder-D94wmfAU.js +41 -0
- package/inspector-dist/server/assets/app-DGlfWVUI.js +99330 -0
- package/inspector-dist/server/assets/chunk-RLXIAIE6-F0SJZlei.js +42975 -0
- package/inspector-dist/server/assets/dist-BCbwm6jl.js +10325 -0
- package/inspector-dist/server/assets/dist-CG2aVufI.js +197 -0
- package/inspector-dist/server/assets/dist-Ce0I2PUv.js +1137 -0
- package/inspector-dist/server/assets/dist-DY0UlahA.js +1642 -0
- package/inspector-dist/server/assets/encryption-DdQgC8Rk.js +886 -0
- package/inspector-dist/server/assets/event-metadata-n7E4zEmT.js +145 -0
- package/inspector-dist/server/assets/functions-CNVQtbgg.js +1170 -0
- package/inspector-dist/server/assets/global-singleton-D8sIN5du.js +80 -0
- package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-CWRzMxYD.js +34 -0
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-D0v0ngVr.js +1 -0
- package/inspector-dist/server/assets/parse-Begau9cA.js +469 -0
- package/inspector-dist/server/assets/rolldown-runtime-C1I3wEg2.js +43 -0
- package/inspector-dist/server/assets/serialization-format-BbuGfHog.js +476 -0
- package/inspector-dist/server/assets/token-BgMmJNP5.js +60 -0
- package/inspector-dist/server/assets/token-BrUX0bxz.js +55 -0
- package/inspector-dist/server/assets/token-util-DZN32qmT.js +455 -0
- package/inspector-dist/server/assets/wrapper-CIC3w0oC.js +3624 -0
- package/inspector-dist/server/assets/ws-transport-CxTYB11n.js +29476 -0
- package/inspector-dist/server/assets/zstd-browser-decoder-D7bCXbGg.js +38 -0
- package/inspector-dist/server/index.js +1 -58
- package/package.json +39 -28
- package/vite-client.d.ts +1 -1
- package/dashboard-dist/CollapsiblePanel-BX79_W-b.js +0 -2
- package/dashboard-dist/CompositeRoot-xzybXjnx.js +0 -1
- package/dashboard-dist/PopoverPopup-CvlmC7EL.js +0 -1
- package/dashboard-dist/api-reference-BcAYVYwJ.js +0 -260
- package/dashboard-dist/core-BGO9JZ1r.js +0 -1
- package/dashboard-dist/docs-DHikPD2v.js +0 -4
- package/dashboard-dist/popover-DG498XHH.js +0 -1
- package/dist/app-entry.js +0 -1
- package/dist/app-entry2.js +0 -19
- package/dist/app-entry2.js.map +0 -1
- package/dist/bin.d.ts.map +0 -1
- package/dist/client-contract-file2.js +0 -34
- package/dist/client-contract-file2.js.map +0 -1
- package/dist/client-contract.js +0 -1
- package/dist/client-contract2.js +0 -294
- package/dist/client-contract2.js.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/dashboard-extension.d.ts.map +0 -1
- package/dist/dev-reporter.d.ts.map +0 -1
- package/dist/dev-telemetry-store.js.map +0 -1
- package/dist/emit.d.ts +0 -7
- package/dist/emit.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lint/oxlint.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/presets.js.map +0 -1
- package/dist/runner.js +0 -523
- package/dist/runner.js.map +0 -1
- package/dist/vite.d.ts.map +0 -1
- package/dist/workflows.d.ts.map +0 -1
- package/inspector-dist/client/assets/api.rpc-l0sNRNKZ.js +0 -1
- package/inspector-dist/client/assets/api.stream._streamId-l0sNRNKZ.js +0 -1
- package/inspector-dist/client/assets/app-CvoGgWcV.css +0 -1
- package/inspector-dist/client/assets/entry.client-BJ6G3n5t.js +0 -11697
- package/inspector-dist/client/assets/highlighted-body-B3W2YXNL-C-3wZnxf.js +0 -19
- package/inspector-dist/client/assets/home-CSKAS4P2.js +0 -4979
- package/inspector-dist/client/assets/index-DECCyMR0.js +0 -4482
- package/inspector-dist/client/assets/index-Dot7CgrA.js +0 -9837
- package/inspector-dist/client/assets/index-HqNj_XIX.js +0 -200
- package/inspector-dist/client/assets/manifest-139c9319.js +0 -1
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-DC0K8uTy.js +0 -58626
- package/inspector-dist/client/assets/mermaid-3ZIDBTTL-F88p7PFX.css +0 -1
- package/inspector-dist/client/assets/root-BMHd_XHz.css +0 -1
- package/inspector-dist/client/assets/root-cbi6iYwg.js +0 -305
- package/inspector-dist/client/assets/run-detail-CWoGxu_0.css +0 -1
- package/inspector-dist/client/assets/run-detail-Cc7tSGNq.js +0 -6237
- package/inspector-dist/client/assets/world-config-context-BAD1QCrR.js +0 -26
- package/inspector-dist/client/assets/zstd-browser-decoder-BQoRpP7L.js +0 -28
- package/inspector-dist/server/assets/app-DUP5RybL.js +0 -174880
- package/inspector-dist/server/assets/highlighted-body-B3W2YXNL-D2g4hL2-.js +0 -71
- package/inspector-dist/server/assets/index-BfLBLRRi.js +0 -204
- package/inspector-dist/server/assets/index-BzrGWk7J.js +0 -1164
- package/inspector-dist/server/assets/index-D71yP6AL.js +0 -191
- package/inspector-dist/server/assets/index-wGSWRns3.js +0 -1296
- package/inspector-dist/server/assets/mermaid-3ZIDBTTL-DsvuKoEV.js +0 -58
- package/inspector-dist/server/assets/token-ClUZZwXl.js +0 -95
- package/inspector-dist/server/assets/token-util-DSxMZ6nI.js +0 -33
- package/inspector-dist/server/assets/wrapper-B3vstpCO.js +0 -67
- package/inspector-dist/server/assets/zstd-browser-decoder-Dn82m2BU.js +0 -77
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { ATTR, SPAN } from "@brickkit/core/client";
|
|
2
|
+
// src/dashboard-protocol.ts
|
|
3
|
+
const GET = ["GET"];
|
|
4
|
+
/**
|
|
5
|
+
* Every route the dashboard serves. The server dispatches from this table and
|
|
6
|
+
* the page builds its URLs from it. Production serves only what is marked
|
|
7
|
+
* `production`: the shell, live state and stored history. Nothing that
|
|
8
|
+
* changes the app or reaches into it, and nothing from the project's source.
|
|
9
|
+
*/
|
|
10
|
+
const ROUTES = {
|
|
11
|
+
/** Open to everyone: uptime monitors cannot sign in. */
|
|
12
|
+
health: {
|
|
13
|
+
path: "/_health",
|
|
14
|
+
methods: ["GET", "HEAD"],
|
|
15
|
+
production: true
|
|
16
|
+
},
|
|
17
|
+
shell: {
|
|
18
|
+
path: "/",
|
|
19
|
+
methods: GET,
|
|
20
|
+
production: true
|
|
21
|
+
},
|
|
22
|
+
assets: {
|
|
23
|
+
path: "/assets",
|
|
24
|
+
prefix: true,
|
|
25
|
+
methods: GET,
|
|
26
|
+
production: true
|
|
27
|
+
},
|
|
28
|
+
/** The app itself, for an extension's `appFetch`. */
|
|
29
|
+
app: {
|
|
30
|
+
path: "/app",
|
|
31
|
+
prefix: true,
|
|
32
|
+
production: "extension"
|
|
33
|
+
},
|
|
34
|
+
state: {
|
|
35
|
+
path: "/api/state",
|
|
36
|
+
methods: GET,
|
|
37
|
+
production: true
|
|
38
|
+
},
|
|
39
|
+
events: {
|
|
40
|
+
path: "/api/events",
|
|
41
|
+
methods: GET,
|
|
42
|
+
production: true
|
|
43
|
+
},
|
|
44
|
+
history: {
|
|
45
|
+
path: "/api/history",
|
|
46
|
+
prefix: true,
|
|
47
|
+
methods: GET,
|
|
48
|
+
production: true
|
|
49
|
+
},
|
|
50
|
+
docs: {
|
|
51
|
+
path: "/api/docs",
|
|
52
|
+
prefix: true,
|
|
53
|
+
methods: GET,
|
|
54
|
+
production: false,
|
|
55
|
+
view: "docs"
|
|
56
|
+
},
|
|
57
|
+
openapi: {
|
|
58
|
+
path: "/api/openapi",
|
|
59
|
+
methods: GET,
|
|
60
|
+
production: false,
|
|
61
|
+
view: "apis"
|
|
62
|
+
},
|
|
63
|
+
/** Try it in the APIs view; the app is another origin. */
|
|
64
|
+
proxy: {
|
|
65
|
+
path: "/api/proxy",
|
|
66
|
+
production: false,
|
|
67
|
+
view: "apis"
|
|
68
|
+
},
|
|
69
|
+
/** The workflow inspector the app serves on a port of its own. */
|
|
70
|
+
workflows: {
|
|
71
|
+
path: "/workflows",
|
|
72
|
+
prefix: true,
|
|
73
|
+
production: false,
|
|
74
|
+
view: "workflows"
|
|
75
|
+
},
|
|
76
|
+
ingest: {
|
|
77
|
+
path: "/api/ingest",
|
|
78
|
+
methods: ["POST"],
|
|
79
|
+
production: false,
|
|
80
|
+
csrf: true
|
|
81
|
+
},
|
|
82
|
+
restart: {
|
|
83
|
+
path: "/api/restart",
|
|
84
|
+
methods: ["POST"],
|
|
85
|
+
production: false,
|
|
86
|
+
csrf: true
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
/** The route a request is for, or undefined when none answers it. */
|
|
90
|
+
function matchRoute(method, pathname) {
|
|
91
|
+
for (const [name, route] of Object.entries(ROUTES)) if ((pathname === route.path || route.prefix === true && pathname.startsWith(`${route.path}/`)) && (!route.methods || route.methods.includes(method ?? ""))) return name;
|
|
92
|
+
}
|
|
93
|
+
new Set(Object.values(ROUTES).flatMap((route) => route.view && route.production === false ? [route.view] : []));
|
|
94
|
+
/** The Docs tab's data: tree, search, compiled pages, files, components. */
|
|
95
|
+
const DOCS_PATHS = {
|
|
96
|
+
info: ROUTES.docs.path,
|
|
97
|
+
search: `${ROUTES.docs.path}/search`,
|
|
98
|
+
components: `${ROUTES.docs.path}/components.js`,
|
|
99
|
+
page: `${ROUTES.docs.path}/page`,
|
|
100
|
+
files: `${ROUTES.docs.path}/files`
|
|
101
|
+
};
|
|
102
|
+
/** A path segment as written, when it is not valid percent-encoding. */
|
|
103
|
+
function decode(value) {
|
|
104
|
+
try {
|
|
105
|
+
return decodeURIComponent(value);
|
|
106
|
+
} catch {
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A page address, `#/<segments>#<anchor>`, each part encoded. Every view's
|
|
112
|
+
* links are built with it, and the page's `parseRoute` reads them back.
|
|
113
|
+
*/
|
|
114
|
+
const hashHref = (segments, anchor) => `#/${encodePath(segments)}${anchor ? `#${encodeURIComponent(anchor)}` : ""}`;
|
|
115
|
+
/** The page's address of a docs page, optionally at one of its headings. */
|
|
116
|
+
const docsHref = (path, anchor) => hashHref(["docs", ...path], anchor);
|
|
117
|
+
const encodePath = (path) => path.map(encodeURIComponent).join("/");
|
|
118
|
+
/** Where a file in the docs folder is served, by its path inside it. */
|
|
119
|
+
const docsFileUrl = (path) => `${DOCS_PATHS.files}/${encodePath(path.split("/"))}`;
|
|
120
|
+
/** Whether a link names a scheme (`https:`, `mailto:`) and so leaves the dashboard. */
|
|
121
|
+
const isExternalHref = (href) => /^[a-z][a-z\d+.-]*:/i.test(href);
|
|
122
|
+
/**
|
|
123
|
+
* Sent with every request that changes something (restart, ingest). A page on
|
|
124
|
+
* another site cannot send it without a preflight, which the server never
|
|
125
|
+
* answers.
|
|
126
|
+
*/
|
|
127
|
+
const CSRF_HEADER = "x-brick-dashboard";
|
|
128
|
+
/** The header that proves a request to the workflow inspector comes from the dashboard. */
|
|
129
|
+
const INSPECTOR_TOKEN_HEADER = "x-brick-inspector";
|
|
130
|
+
/** The files the shell loads from `ROUTES.assets.path`. `app.*` come from the dashboard's build. */
|
|
131
|
+
const ASSETS = {
|
|
132
|
+
app: "app.js",
|
|
133
|
+
appCss: "app.css",
|
|
134
|
+
/** The project's extension, or the list of parts when plugins have one too. */
|
|
135
|
+
extension: "extension.js",
|
|
136
|
+
extensionCss: "extension.css",
|
|
137
|
+
/** The project's theme tokens; see `themeCss`. */
|
|
138
|
+
theme: "brick-theme.css"
|
|
139
|
+
};
|
|
140
|
+
/** Where an asset is served. */
|
|
141
|
+
const assetUrl = (file) => `${ROUTES.assets.path}/${file}`;
|
|
142
|
+
/**
|
|
143
|
+
* What the dashboard supplies to the project's docs components and dashboard
|
|
144
|
+
* extension, so there is one copy of React and of the UI kit on the page: the
|
|
145
|
+
* bundler leaves `specifier` external, the shell's import map points it at
|
|
146
|
+
* `/assets/<file>`, and `file` hands over the page's `globalThis.__brickDashboard[global]`.
|
|
147
|
+
*/
|
|
148
|
+
const SHARED_MODULES = [
|
|
149
|
+
{
|
|
150
|
+
specifier: "react",
|
|
151
|
+
file: "react.js",
|
|
152
|
+
global: "React"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
specifier: "react/jsx-runtime",
|
|
156
|
+
file: "react-jsx-runtime.js",
|
|
157
|
+
global: "jsxRuntime"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
specifier: "react/jsx-dev-runtime",
|
|
161
|
+
file: "react-jsx-runtime.js",
|
|
162
|
+
global: "jsxRuntime"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
specifier: "react-dom",
|
|
166
|
+
file: "react-dom.js",
|
|
167
|
+
global: "ReactDOM"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
specifier: "react-dom/client",
|
|
171
|
+
file: "react-dom-client.js",
|
|
172
|
+
global: "ReactDOMClient"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
specifier: "@brickkit/cli/dashboard",
|
|
176
|
+
file: "kit.js"
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
/** Where the page keeps the chosen theme; the shell applies it before first paint. */
|
|
180
|
+
const THEME_STORAGE_KEY = "brick-dashboard-theme";
|
|
181
|
+
/** How many of each the live state keeps, on the server and on the page. */
|
|
182
|
+
const LIVE_LIMITS = {
|
|
183
|
+
traces: 200,
|
|
184
|
+
failures: 200,
|
|
185
|
+
reloads: 100
|
|
186
|
+
};
|
|
187
|
+
export { INSPECTOR_TOKEN_HEADER as a, SHARED_MODULES as c, assetUrl as d, decode as f, matchRoute as g, isExternalHref as h, DOCS_PATHS as i, SPAN as l, docsHref as m, ATTR as n, LIVE_LIMITS as o, docsFileUrl as p, CSRF_HEADER as r, ROUTES as s, ASSETS as t, THEME_STORAGE_KEY as u };
|
|
188
|
+
|
|
189
|
+
//# sourceMappingURL=dashboard-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-protocol.js","names":[],"sources":["../src/dashboard-protocol.ts"],"sourcesContent":["import type { Attributes } from \"@opentelemetry/api\";\nimport type { ArchitectureSchema } from \"@brickkit/core\";\n\n/*\n * What the dashboard server and its page agree on: the routes, headers, event\n * names and the data they carry. Types and constants only, so the page can\n * import it without the server's code.\n */\n\n// ---------------------------------------------------------------------------\n// Span records: what the app's tracer reports, over IPC or `/api/ingest`\n\nexport interface SpanEventRecord {\n name: string;\n timeMs: number;\n attributes: Attributes;\n}\n\nexport interface SpanStartRecord {\n phase: \"start\";\n traceId: string;\n spanId: string;\n parentSpanId?: string;\n name: string;\n startMs: number;\n attributes: Attributes;\n}\n\nexport interface SpanEndRecord {\n phase: \"end\";\n traceId: string;\n spanId: string;\n name: string;\n endMs: number;\n status: \"unset\" | \"ok\" | \"error\";\n statusMessage?: string;\n attributes: Attributes;\n events: SpanEventRecord[];\n}\n\nexport type TelemetryRecord = SpanStartRecord | SpanEndRecord;\n\nexport type WorkerErrorPhase = \"startup\" | \"uncaught\" | \"unhandled-rejection\";\n\nexport interface SerializedError {\n name: string;\n message: string;\n stack?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Routes\n\n/** The dashboard's built-in views; `#/<view>/…` opens one. */\nexport const VIEW_NAMES = [\n \"requests\",\n \"logs\",\n \"overview\",\n \"apis\",\n \"docs\",\n \"workflows\",\n \"errors\",\n \"reloads\",\n] as const;\nexport type ViewName = (typeof VIEW_NAMES)[number];\n\ninterface RouteSpec {\n path: string;\n /** Also answers every path below `path`. */\n prefix?: boolean;\n /** The methods it answers; any when absent. */\n methods?: readonly string[];\n /** Served by the production dashboard; `\"extension\"`: only when it has one. */\n production: boolean | \"extension\";\n /** The page's view that needs it; a view whose routes production lacks is hidden there. */\n view?: ViewName;\n /** It changes something, so the request must carry `CSRF_HEADER`. */\n csrf?: true;\n}\n\nconst GET = [\"GET\"] as const;\n\n/**\n * Every route the dashboard serves. The server dispatches from this table and\n * the page builds its URLs from it. Production serves only what is marked\n * `production`: the shell, live state and stored history. Nothing that\n * changes the app or reaches into it, and nothing from the project's source.\n */\nexport const ROUTES = {\n /** Open to everyone: uptime monitors cannot sign in. */\n health: { path: \"/_health\", methods: [\"GET\", \"HEAD\"], production: true },\n shell: { path: \"/\", methods: GET, production: true },\n assets: { path: \"/assets\", prefix: true, methods: GET, production: true },\n /** The app itself, for an extension's `appFetch`. */\n app: { path: \"/app\", prefix: true, production: \"extension\" },\n state: { path: \"/api/state\", methods: GET, production: true },\n events: { path: \"/api/events\", methods: GET, production: true },\n history: {\n path: \"/api/history\",\n prefix: true,\n methods: GET,\n production: true,\n },\n docs: {\n path: \"/api/docs\",\n prefix: true,\n methods: GET,\n production: false,\n view: \"docs\",\n },\n openapi: {\n path: \"/api/openapi\",\n methods: GET,\n production: false,\n view: \"apis\",\n },\n /** Try it in the APIs view; the app is another origin. */\n proxy: { path: \"/api/proxy\", production: false, view: \"apis\" },\n /** The workflow inspector the app serves on a port of its own. */\n workflows: {\n path: \"/workflows\",\n prefix: true,\n production: false,\n view: \"workflows\",\n },\n ingest: {\n path: \"/api/ingest\",\n methods: [\"POST\"],\n production: false,\n csrf: true,\n },\n restart: {\n path: \"/api/restart\",\n methods: [\"POST\"],\n production: false,\n csrf: true,\n },\n} as const satisfies Record<string, RouteSpec>;\n\nexport type RouteName = keyof typeof ROUTES;\n\n/** The route a request is for, or undefined when none answers it. */\nexport function matchRoute(\n method: string | undefined,\n pathname: string,\n): RouteName | undefined {\n for (const [name, route] of Object.entries(ROUTES) as [\n RouteName,\n RouteSpec,\n ][]) {\n const at =\n pathname === route.path ||\n (route.prefix === true && pathname.startsWith(`${route.path}/`));\n if (at && (!route.methods || route.methods.includes(method ?? \"\")))\n return name;\n }\n return undefined;\n}\n\n/** Views the production dashboard hides: they need a route it does not serve. */\nexport const PRODUCTION_HIDDEN_VIEWS: ReadonlySet<string> = new Set<ViewName>(\n Object.values(ROUTES as Record<RouteName, RouteSpec>).flatMap((route) =>\n route.view && route.production === false ? [route.view] : [],\n ),\n);\n\n/** What each history query endpoint answers, as JSON. */\nexport interface HistoryResponses {\n summary: HistorySummary;\n traces: { total: number; traces: HistoryTrace[] };\n facets: HistoryFacets;\n volume: VolumeBucket[];\n}\n\n/** The history endpoints: the JSON queries, and `export` (CSV). */\nexport type HistoryEndpoint = keyof HistoryResponses | \"export\";\n\n/** A history query's address; with no endpoint, what the history holds. */\nexport const historyUrl = (\n endpoint?: HistoryEndpoint,\n params?: URLSearchParams,\n): string =>\n `${ROUTES.history.path}${endpoint ? `/${endpoint}` : \"\"}${params ? `?${params}` : \"\"}`;\n\nexport const historyTraceUrl = (traceId: string): string =>\n `${historyUrl(\"traces\")}/${encodeURIComponent(traceId)}`;\n\n/** The Docs tab's data: tree, search, compiled pages, files, components. */\nexport const DOCS_PATHS = {\n info: ROUTES.docs.path,\n search: `${ROUTES.docs.path}/search`,\n components: `${ROUTES.docs.path}/components.js`,\n page: `${ROUTES.docs.path}/page`,\n files: `${ROUTES.docs.path}/files`,\n} as const;\n\n/** A path segment as written, when it is not valid percent-encoding. */\nexport function decode(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\n/**\n * A page address, `#/<segments>#<anchor>`, each part encoded. Every view's\n * links are built with it, and the page's `parseRoute` reads them back.\n */\nexport const hashHref = (segments: string[], anchor?: string): string =>\n `#/${encodePath(segments)}${anchor ? `#${encodeURIComponent(anchor)}` : \"\"}`;\n\n/** The page's address of a docs page, optionally at one of its headings. */\nexport const docsHref = (path: string[], anchor?: string): string =>\n hashHref([\"docs\", ...path], anchor);\n\nconst encodePath = (path: string[]): string =>\n path.map(encodeURIComponent).join(\"/\");\n\n/** Where a file in the docs folder is served, by its path inside it. */\nexport const docsFileUrl = (path: string): string =>\n `${DOCS_PATHS.files}/${encodePath(path.split(\"/\"))}`;\n\n/** Where a compiled docs page is served, by its slugs. */\nexport const docsPageUrl = (path: string[]): string =>\n `${DOCS_PATHS.page}/${encodePath(path)}`;\n\n/** Where the docs search answers `query`. */\nexport const docsSearchUrl = (query: string): string =>\n `${DOCS_PATHS.search}?q=${encodeURIComponent(query)}`;\n\n/** Whether a link names a scheme (`https:`, `mailto:`) and so leaves the dashboard. */\nexport const isExternalHref = (href: string): boolean =>\n /^[a-z][a-z\\d+.-]*:/i.test(href);\n\n/**\n * Sent with every request that changes something (restart, ingest). A page on\n * another site cannot send it without a preflight, which the server never\n * answers.\n */\nexport const CSRF_HEADER = \"x-brick-dashboard\";\nexport const CSRF_VALUE = \"1\";\n\n/** The header that proves a request to the workflow inspector comes from the dashboard. */\nexport const INSPECTOR_TOKEN_HEADER = \"x-brick-inspector\";\n\n/** What a process that cannot share memory with the dashboard posts to `/api/ingest`. */\nexport interface IngestPayload {\n /** Span records, of the newest generation. */\n records?: TelemetryRecord[];\n /** A notice that the app loaded: a new generation begins. */\n worker?: string;\n}\n\n// ---------------------------------------------------------------------------\n// The shell and its assets\n\n/** The files the shell loads from `ROUTES.assets.path`. `app.*` come from the dashboard's build. */\nexport const ASSETS = {\n app: \"app.js\",\n appCss: \"app.css\",\n /** The project's extension, or the list of parts when plugins have one too. */\n extension: \"extension.js\",\n extensionCss: \"extension.css\",\n /** The project's theme tokens; see `themeCss`. */\n theme: \"brick-theme.css\",\n} as const;\n\n/** Where an asset is served. */\nexport const assetUrl = (file: string): string =>\n `${ROUTES.assets.path}/${file}`;\n\n/**\n * What the shell tells the page in its markup: a `<meta name=\"brick-extension\"\n * data-revision data-src>` for the extension, and the theme's `<link>`.\n */\nexport const SHELL = {\n extensionMeta: 'meta[name=\"brick-extension\"]',\n themeLink: \"link[data-brick-theme]\",\n} as const;\n\n// ---------------------------------------------------------------------------\n// Modules the page shares with the project's own\n\n/**\n * What the dashboard supplies to the project's docs components and dashboard\n * extension, so there is one copy of React and of the UI kit on the page: the\n * bundler leaves `specifier` external, the shell's import map points it at\n * `/assets/<file>`, and `file` hands over the page's `globalThis.__brickDashboard[global]`.\n */\nexport const SHARED_MODULES = [\n { specifier: \"react\", file: \"react.js\", global: \"React\" },\n {\n specifier: \"react/jsx-runtime\",\n file: \"react-jsx-runtime.js\",\n global: \"jsxRuntime\",\n },\n {\n specifier: \"react/jsx-dev-runtime\",\n file: \"react-jsx-runtime.js\",\n global: \"jsxRuntime\",\n },\n { specifier: \"react-dom\", file: \"react-dom.js\", global: \"ReactDOM\" },\n {\n specifier: \"react-dom/client\",\n file: \"react-dom-client.js\",\n global: \"ReactDOMClient\",\n },\n // The UI kit is a module of the dashboard's own build.\n { specifier: \"@brickkit/cli/dashboard\", file: \"kit.js\" },\n] as const;\n\nexport type SharedGlobal = Extract<\n (typeof SHARED_MODULES)[number],\n { global: string }\n>[\"global\"];\n\n/**\n * One of several dashboard extensions (the app's and its plugins'), as\n * `/assets/extension.js` lists them in `export const parts`.\n */\nexport interface ExtensionPart {\n name: string;\n /** Relative to `extension.js`. */\n src: string;\n /** A plugin's: its pages without a place go under a section named after it. */\n plugin: boolean;\n}\n\n/** Where the page keeps the chosen theme; the shell applies it before first paint. */\nexport const THEME_STORAGE_KEY = \"brick-dashboard-theme\";\n\n// ---------------------------------------------------------------------------\n// Span names and attribute keys core sets, read here and on the page\n\nexport { SPAN, ATTR } from \"@brickkit/core/client\";\n\n// ---------------------------------------------------------------------------\n// Live data\n\n/** How many of each the live state keeps, on the server and on the page. */\nexport const LIVE_LIMITS = { traces: 200, failures: 200, reloads: 100 };\n\nexport type SpanOutcome = \"running\" | \"ok\" | \"error\" | \"interrupted\";\n\nexport interface TraceSpan {\n spanId: string;\n parentSpanId?: string;\n name: string;\n startMs: number;\n endMs?: number;\n status: SpanOutcome;\n statusMessage?: string;\n attributes: Attributes;\n events: SpanEventRecord[];\n}\n\nexport interface TraceSummary {\n traceId: string;\n name: string;\n method?: string;\n route?: string;\n /** The request's actual path, which differs from a wildcard route template. */\n path?: string;\n httpStatus?: number;\n generation: number;\n startMs: number;\n endMs?: number;\n durationMs?: number;\n status: SpanOutcome;\n truncated: boolean;\n /** The service and action that handled the request, when it ran one. */\n service?: string;\n action?: string;\n /** Why it failed, when it did. */\n message?: string;\n spans: TraceSpan[];\n}\n\nexport interface FailureSummary {\n id: number;\n at: number;\n phase: \"request\" | WorkerErrorPhase;\n code: string;\n message: string;\n status?: number;\n stack?: string;\n traceId?: string;\n route?: string;\n service?: string;\n action?: string;\n generation: number;\n}\n\nexport type ReloadKind = \"started\" | \"restarting\" | \"exited\" | \"contract-ready\";\n\nexport interface ReloadSummary {\n id: number;\n at: number;\n kind: ReloadKind;\n generation: number;\n detail?: string;\n}\n\n/** Services, actions, and routes of the application as last started. */\nexport interface ArchitectureSnapshot {\n generation: number;\n schema: ArchitectureSchema;\n}\n\n/** The OpenAPI documents the app offers, for the dashboard's APIs view. */\nexport interface ApiSnapshot {\n /** Changes each time the documents are replaced, so views know to reload. */\n revision: number;\n /** Where the app listens; Try it in the APIs view sends requests here. */\n appUrl?: string;\n /** Names of the documents, in order. */\n titles: string[];\n}\n\n/** What the dashboard knows about the app's developer documentation. */\nexport type DocsSnapshot =\n | {\n status: \"ready\";\n /** Changes whenever the pages change, so the Docs tab reloads. */\n revision: number;\n title: string;\n /** Whether the project supplied components of its own. */\n components: boolean;\n }\n /** The packages the docs need are not installed. */\n | { status: \"missing\"; packages: string[]; message: string }\n /** Why the docs cannot be shown. */\n | { status: \"error\"; message: string };\n\n/** The project's dashboard extension as last built. */\nexport interface ExtensionBuild {\n revision: number;\n /** Why the last build failed. */\n error?: string;\n}\n\nexport type DevTelemetryEvent =\n | { type: \"trace\"; trace: TraceSummary }\n | { type: \"failure\"; failure: FailureSummary }\n | { type: \"reload\"; reload: ReloadSummary }\n | { type: \"architecture\"; architecture: ArchitectureSnapshot }\n | { type: \"api\"; api: ApiSnapshot }\n | { type: \"docs\"; docs: DocsSnapshot | null }\n | { type: \"inspector\"; inspector: boolean };\n\nexport interface DevTelemetrySnapshot {\n traces: TraceSummary[];\n failures: FailureSummary[];\n reloads: ReloadSummary[];\n architecture: ArchitectureSnapshot | null;\n api: ApiSnapshot | null;\n /** Null when the app has no `documentation`. */\n docs: DocsSnapshot | null;\n /** Whether the app serves the workflow inspector the dashboard can show. */\n inspector: boolean;\n}\n\n/** `/api/state`, and the first event of `/api/events`: the store's snapshot and the server's own fields. */\nexport interface DashboardSnapshot extends DevTelemetrySnapshot {\n /** Whether the host can restart the app; the page shows the button. */\n canRestart: boolean;\n /** Days of requests kept on disk; zero when history is off. */\n historyDays: number;\n /** `production` is the read-only monitoring dashboard of `brick start`. */\n mode: \"dev\" | \"production\";\n /** The project's extension; null when it has none. */\n extension: ExtensionBuild | null;\n}\n\n/** The server-sent events of `/api/events`, by name, with the data each carries. */\nexport type DashboardEvents = {\n snapshot: DashboardSnapshot;\n /** A rebuilt extension: the page reloads to run it. */\n extension: ExtensionBuild | null;\n} & { [E in DevTelemetryEvent as E[\"type\"]]: E };\n\n/** The store's event names; each event is sent under its `type`. */\nexport const TELEMETRY_EVENTS = Object.keys({\n trace: true,\n failure: true,\n reload: true,\n architecture: true,\n api: true,\n docs: true,\n inspector: true,\n} satisfies Record<\n DevTelemetryEvent[\"type\"],\n true\n>) as DevTelemetryEvent[\"type\"][];\n\n// ---------------------------------------------------------------------------\n// Stored history\n\n/** A finished request without its spans; fetch the full trace by id. */\nexport type HistoryTrace = Omit<TraceSummary, \"spans\"> & {\n /** \"GET /api/page/:id\" when the method and route are known, else the span name. */\n endpoint: string;\n};\n\n/** How a request ended: a 5xx or crash, a 4xx, or neither. */\nexport type Outcome = \"ok\" | \"client\" | \"server\";\n\n/** Rows in one page of `/api/history/traces`, unless the query asks for another number. */\nexport const HISTORY_PAGE_SIZE = 100;\n\nexport interface VolumeBucket {\n start: number;\n ok: number;\n client: number;\n server: number;\n}\n\n/** The numbers behind the cards at the top of the log, for what matches. */\nexport interface HistorySummary {\n total: number;\n clientErrors: number;\n serverErrors: number;\n medianMs: number;\n p95Ms: number;\n}\n\nexport interface FacetValue {\n value: string;\n count: number;\n}\n\n/** What is in the range, counted for each filter as if it were not applied. */\nexport interface HistoryFacets {\n outcome: FacetValue[];\n method: FacetValue[];\n service: FacetValue[];\n endpoint: FacetValue[];\n}\n\nexport interface HistoryInfo {\n days: number;\n count: number;\n oldestMs?: number;\n}\n\n// ---------------------------------------------------------------------------\n// Docs\n\n/** One entry of the docs sidebar. */\nexport type DocsNode =\n | { type: \"page\"; name: string; url: string; description?: string }\n | {\n type: \"folder\";\n name: string;\n index?: { name: string; url: string };\n children: DocsNode[];\n defaultOpen?: boolean;\n }\n | { type: \"separator\"; name?: string };\n\nexport interface DocsTree {\n name: string;\n children: DocsNode[];\n}\n\nexport interface DocsHeading {\n title: string;\n url: string;\n depth: number;\n}\n\n/** A page ready to run in the browser. */\nexport interface DocsPage {\n title: string;\n description?: string;\n /** The file, relative to the docs folder. */\n path: string;\n slugs: string[];\n toc: DocsHeading[];\n /** MDX compiled to a function body; see `runMdx` in the dashboard. */\n code: string;\n /** Set instead of `code` when the page does not compile. */\n error?: string;\n}\n\nexport interface DocsSearchHit {\n id: string;\n type: \"page\" | \"heading\" | \"text\";\n content: string;\n /** Route within the docs, with a `#heading` when the hit is inside a page. */\n url: string;\n}\n\nexport interface DocsInfo {\n tree: DocsTree;\n /** Whether the project supplied components of its own. */\n components: boolean;\n revision: number;\n}\n"],"mappings":"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"}
|