@brickkit/cli 0.16.0-beta.2 → 0.16.0-beta.4
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/README.md +22 -0
- package/dashboard-dist/{api-reference-FojtkYBA.js → api-reference-CA1ejOhs.js} +71 -71
- package/dashboard-dist/app.css +1 -1
- package/dashboard-dist/app.js +12 -12
- package/dashboard-dist/{client-Cnm0Im6o.js → client-C0YCIB2j.js} +1 -1
- package/dashboard-dist/{core-SiSejpN2.js → core-CPETvDaW.js} +1 -1
- package/dashboard-dist/{docs-D1HrRL0z.js → docs-e44llMgQ.js} +2 -2
- package/dashboard-dist/kit.js +1 -1
- package/dashboard-dist/popover-CPp8Bc7H.js +1 -0
- package/dashboard-dist/theme.css +51 -39
- package/dist/bin.js +2 -1
- package/dist/bin.js.map +1 -1
- package/dist/build.js +6 -1
- package/dist/build.js.map +1 -1
- package/dist/dashboard-host.js +2595 -898
- package/dist/dashboard-host.js.map +1 -1
- package/dist/dashboard-protocol.js +4 -0
- package/dist/dashboard-protocol.js.map +1 -1
- package/dist/dashboard.d.ts +3 -3
- package/dist/dev-telemetry.js +2 -2
- package/dist/dev-telemetry.js.map +1 -1
- package/dist/package.js +5 -0
- package/dist/package.js.map +1 -0
- package/dist/production-dashboard.js +1 -0
- package/dist/production-dashboard.js.map +1 -1
- package/dist/project.js +2 -3
- package/dist/project.js.map +1 -1
- package/dist/vite.js +1 -0
- package/dist/vite.js.map +1 -1
- package/inspector-dist/client/assets/{app-Wfnqu2Ic.css → app-Dla3cd5X.css} +51 -40
- package/inspector-dist/client/assets/{manifest-cfc09adc.js → manifest-3c342844.js} +1 -1
- package/inspector-dist/client/assets/{root-CVescmwt.css → root-Cnc-DXen.css} +51 -40
- package/inspector-dist/server/assets/{app-DUrMEdTr.js → app-p2-vDk3q.js} +51 -17
- package/inspector-dist/server/assets/{functions-CvYRS9L5.js → functions-BIXA0YFQ.js} +2 -2
- package/inspector-dist/server/assets/{serialization-BMjuH1Dy.js → serialization-D4H52Sdp.js} +1 -1
- package/inspector-dist/server/assets/{token-CXQG49kq.js → token-70XLMYnj.js} +1 -1
- package/inspector-dist/server/assets/{token-B03I2FMb.js → token-Bro5a25u.js} +1 -1
- package/inspector-dist/server/assets/token-util-9OFaOQxs.js +3 -0
- package/inspector-dist/server/assets/{ws-transport-CMidAEKi.js → ws-transport-DALQS5qP.js} +1 -1
- package/inspector-dist/server/index.js +1 -1
- package/package.json +2 -2
- package/dashboard-dist/PopoverPopup-CiI2avT_.js +0 -1
- package/dashboard-dist/popover-Da7zBKDq.js +0 -1
- package/inspector-dist/server/assets/token-util-DQqrmFHy.js +0 -3
- /package/inspector-dist/client/assets/{root-CVhM1JOR.js → root-C12dyylt.js} +0 -0
|
@@ -1 +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 \"schedules\",\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 /**\n * Served by the production dashboard; `\"extension\"`: only when it has one;\n * `\"inspector\"`: only with `dashboard.inspector` and a running inspector.\n */\n production: boolean | \"extension\" | \"inspector\";\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`.\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: \"inspector\",\n view: \"workflows\",\n },\n /** The app's schedules, served beside the workflow inspector: list them, run one now. */\n schedules: {\n path: \"/api/schedules\",\n prefix: true,\n methods: [\"GET\", \"POST\"],\n production: \"inspector\",\n view: \"schedules\",\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\nexport const viewsWithout = (\n served: (route: RouteName) => boolean,\n): ViewName[] => [\n ...new Set(\n (Object.entries(ROUTES) as [RouteName, RouteSpec][]).flatMap(\n ([name, route]) => (route.view && !served(name) ? [route.view] : []),\n ),\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\nexport const INSPECTOR_READ_ONLY_HEADER = \"x-brick-inspector-read-only\";\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 monitoring dashboard of `brick start`. */\n mode: \"dev\" | \"production\";\n hiddenViews: ViewName[];\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\n/** How a schedule fires: its cron expression and time zone, or its interval (`every 6h`). */\nexport function describeSchedule(schedule: {\n cron?: string;\n timeZone?: string;\n every?: number;\n}): string {\n if (schedule.cron)\n return schedule.timeZone && schedule.timeZone !== \"UTC\"\n ? `${schedule.cron} (${schedule.timeZone})`\n : schedule.cron;\n const ms = schedule.every ?? 0;\n for (const [unit, size] of [\n [\"d\", 86_400_000],\n [\"h\", 3_600_000],\n [\"m\", 60_000],\n [\"s\", 1000],\n ] as const)\n if (ms % size === 0) return `every ${ms / size}${unit}`;\n return `every ${ms}ms`;\n}\n"],"mappings":";;AAoFA,MAAM,MAAM,CAAC,KAAK;;;;;;AAOlB,MAAa,SAAS;;CAEpB,QAAQ;EAAE,MAAM;EAAY,SAAS,CAAC,OAAO,MAAM;EAAG,YAAY;CAAK;CACvE,OAAO;EAAE,MAAM;EAAK,SAAS;EAAK,YAAY;CAAK;CACnD,QAAQ;EAAE,MAAM;EAAW,QAAQ;EAAM,SAAS;EAAK,YAAY;CAAK;;CAExE,KAAK;EAAE,MAAM;EAAQ,QAAQ;EAAM,YAAY;CAAY;CAC3D,OAAO;EAAE,MAAM;EAAc,SAAS;EAAK,YAAY;CAAK;CAC5D,QAAQ;EAAE,MAAM;EAAe,SAAS;EAAK,YAAY;CAAK;CAC9D,SAAS;EACP,MAAM;EACN,QAAQ;EACR,SAAS;EACT,YAAY;CACd;CACA,MAAM;EACJ,MAAM;EACN,QAAQ;EACR,SAAS;EACT,YAAY;EACZ,MAAM;CACR;CACA,SAAS;EACP,MAAM;EACN,SAAS;EACT,YAAY;EACZ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,GAAG;AACrB"}
|
|
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 \"schedules\",\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 /**\n * Served by the production dashboard; `\"extension\"`: only when it has one;\n * `\"inspector\"`: only with `dashboard.inspector` and a running inspector.\n */\n production: boolean | \"extension\" | \"inspector\" | \"mcp\";\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`.\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: \"inspector\",\n view: \"workflows\",\n },\n /** The app's schedules, served beside the workflow inspector: list them, run one now. */\n schedules: {\n path: \"/api/schedules\",\n prefix: true,\n methods: [\"GET\", \"POST\"],\n production: \"inspector\",\n view: \"schedules\",\n },\n mcp: { path: \"/mcp\", production: \"mcp\" },\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\nexport const viewsWithout = (\n served: (route: RouteName) => boolean,\n): ViewName[] => [\n ...new Set(\n (Object.entries(ROUTES) as [RouteName, RouteSpec][]).flatMap(\n ([name, route]) => (route.view && !served(name) ? [route.view] : []),\n ),\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\nexport const INSPECTOR_READ_ONLY_HEADER = \"x-brick-inspector-read-only\";\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 monitoring dashboard of `brick start`. */\n mode: \"dev\" | \"production\";\n hiddenViews: ViewName[];\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\n/** How a schedule fires: its cron expression and time zone, or its interval (`every 6h`). */\nexport function describeSchedule(schedule: {\n cron?: string;\n timeZone?: string;\n every?: number;\n}): string {\n if (schedule.cron)\n return schedule.timeZone && schedule.timeZone !== \"UTC\"\n ? `${schedule.cron} (${schedule.timeZone})`\n : schedule.cron;\n const ms = schedule.every ?? 0;\n for (const [unit, size] of [\n [\"d\", 86_400_000],\n [\"h\", 3_600_000],\n [\"m\", 60_000],\n [\"s\", 1000],\n ] as const)\n if (ms % size === 0) return `every ${ms / size}${unit}`;\n return `every ${ms}ms`;\n}\n"],"mappings":";;AAoFA,MAAM,MAAM,CAAC,KAAK;;;;;;AAOlB,MAAa,SAAS;;CAEpB,QAAQ;EAAE,MAAM;EAAY,SAAS,CAAC,OAAO,MAAM;EAAG,YAAY;CAAK;CACvE,OAAO;EAAE,MAAM;EAAK,SAAS;EAAK,YAAY;CAAK;CACnD,QAAQ;EAAE,MAAM;EAAW,QAAQ;EAAM,SAAS;EAAK,YAAY;CAAK;;CAExE,KAAK;EAAE,MAAM;EAAQ,QAAQ;EAAM,YAAY;CAAY;CAC3D,OAAO;EAAE,MAAM;EAAc,SAAS;EAAK,YAAY;CAAK;CAC5D,QAAQ;EAAE,MAAM;EAAe,SAAS;EAAK,YAAY;CAAK;CAC9D,SAAS;EACP,MAAM;EACN,QAAQ;EACR,SAAS;EACT,YAAY;CACd;CACA,MAAM;EACJ,MAAM;EACN,QAAQ;EACR,SAAS;EACT,YAAY;EACZ,MAAM;CACR;CACA,SAAS;EACP,MAAM;EACN,SAAS;EACT,YAAY;EACZ,MAAM;CACR;;CAEA,OAAO;EAAE,MAAM;EAAc,YAAY;EAAO,MAAM;CAAO;;CAE7D,WAAW;EACT,MAAM;EACN,QAAQ;EACR,YAAY;EACZ,MAAM;CACR;;CAEA,WAAW;EACT,MAAM;EACN,QAAQ;EACR,SAAS,CAAC,OAAO,MAAM;EACvB,YAAY;EACZ,MAAM;CACR;CACA,KAAK;EAAE,MAAM;EAAQ,YAAY;CAAM;CACvC,QAAQ;EACN,MAAM;EACN,SAAS,CAAC,MAAM;EAChB,YAAY;EACZ,MAAM;CACR;CACA,SAAS;EACP,MAAM;EACN,SAAS,CAAC,MAAM;EAChB,YAAY;EACZ,MAAM;CACR;AACF;;AAKA,SAAgB,WACd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OAAO;AACT;;AAGA,MAAa,YAAY,SACvB,GAAG,OAAO,OAAO,KAAK,GAAG;;;;;;;AAoB3B,MAAa,iBAAiB;CAC5B;EAAE,WAAW;EAAS,MAAM;EAAY,QAAQ;CAAQ;CACxD;EACE,WAAW;EACX,MAAM;EACN,QAAQ;CACV;CACA;EACE,WAAW;EACX,MAAM;EACN,QAAQ;CACV;CACA;EAAE,WAAW;EAAa,MAAM;EAAgB,QAAQ;CAAW;CACnE;EACE,WAAW;EACX,MAAM;EACN,QAAQ;CACV;CAEA;EAAE,WAAW;EAA2B,MAAM;CAAS;AACzD;;AAoBA,MAAa,oBAAoB;;AAWjC,MAAa,cAAc;CAAE,QAAQ;CAAK,UAAU;CAAK,SAAS;AAAI;;AAsQtE,SAAgB,iBAAiB,UAItB;CACT,IAAI,SAAS,MACX,OAAO,SAAS,YAAY,SAAS,aAAa,QAC9C,GAAG,SAAS,KAAK,IAAI,SAAS,SAAS,KACvC,SAAS;CACf,MAAM,KAAK,SAAS,SAAS;CAC7B,KAAK,MAAM,CAAC,MAAM,SAAS;EACzB,CAAC,KAAK,KAAU;EAChB,CAAC,KAAK,IAAS;EACf,CAAC,KAAK,GAAM;EACZ,CAAC,KAAK,GAAI;CACZ,GACE,IAAI,KAAK,SAAS,GAAG,OAAO,SAAS,KAAK,OAAO;CACnD,OAAO,SAAS,GAAG;AACrB"}
|
package/dist/dashboard.d.ts
CHANGED
|
@@ -175,9 +175,9 @@ export declare function useAppQuery<T>(query: ((signal: AbortSignal) => Promise<
|
|
|
175
175
|
*/
|
|
176
176
|
export declare function useAppFetch<T = unknown>(path: string | null, init?: RequestInit): AppFetchResult<T>;
|
|
177
177
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
178
|
+
* The landing page's card: a square, 1px-bordered surface on the card color,
|
|
179
|
+
* built on the shadcn Card with its radius and ring removed. A `title` is a
|
|
180
|
+
* heading row across the top.
|
|
181
181
|
*/
|
|
182
182
|
export declare function Panel({ className, children, title, ...props }: Omit<ComponentProps<"div">, "title"> & {
|
|
183
183
|
title?: ReactNode;
|
package/dist/dev-telemetry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as sendToSupervisor } from "./dev-protocol.js";
|
|
2
2
|
import { GLOBAL_SYMBOL } from "@brickkit/core";
|
|
3
|
-
import { SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
3
|
+
import { ROOT_CONTEXT, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
4
4
|
import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks";
|
|
5
5
|
import { W3CTraceContextPropagator } from "@opentelemetry/core";
|
|
6
6
|
import { TracerProvider } from "@opentelemetry/sdk-trace";
|
|
@@ -133,7 +133,7 @@ var RecordBatcher = class {
|
|
|
133
133
|
if (this.#records.length === 0) return;
|
|
134
134
|
const records = this.#records;
|
|
135
135
|
this.#records = [];
|
|
136
|
-
this.#send(records);
|
|
136
|
+
context.with(ROOT_CONTEXT, () => this.#send(records));
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
var SupervisorSpanProcessor = class {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-telemetry.js","names":[],"sources":["../src/dev-telemetry.ts"],"sourcesContent":["import {\n context,\n propagation,\n SpanStatusCode,\n trace,\n type Attributes,\n type HrTime,\n} from \"@opentelemetry/api\";\nimport { AsyncLocalStorageContextManager } from \"@opentelemetry/context-async-hooks\";\nimport { W3CTraceContextPropagator } from \"@opentelemetry/core\";\nimport {\n TracerProvider,\n type ReadableSpan,\n type Span,\n type SpanProcessor,\n} from \"@opentelemetry/sdk-trace\";\nimport { GLOBAL_SYMBOL } from \"@brickkit/core\";\nimport type {\n SerializedError,\n TelemetryRecord,\n WorkerErrorPhase,\n} from \"./dashboard-protocol\";\nimport { sendToSupervisor } from \"./dev-protocol\";\n\n/** Read by @brickkit/core's logger; see `createLogger` there. */\nconst LOG_CAPTURE = Symbol.for(GLOBAL_SYMBOL.logsCapture);\n/** Core's function that records a line on the running span; see `recordActive` there. */\nconst LOG_RECORD = Symbol.for(GLOBAL_SYMBOL.logsRecord);\nconst CONSOLE_CAPTURED = Symbol.for(\"brickkit.console.captured\");\n\nconst CONSOLE_LEVELS = {\n log: \"info\",\n info: \"info\",\n warn: \"warn\",\n error: \"error\",\n debug: \"debug\",\n} as const;\n\nconst MAX_TEXT_LENGTH = 500;\nconst MAX_STACK_LENGTH = 4000;\nconst FLUSH_DELAY_MS = 20;\nconst MAX_BATCH_SIZE = 200;\n\n/**\n * Register the tracer provider, context manager, and W3C trace context\n * propagator. Span records are batched and passed to `onRecords`. Returns false\n * when another tracer provider was already registered, in which case\n * `onRecords` never runs.\n */\nexport function installTracing(\n onRecords: (records: TelemetryRecord[]) => void,\n): boolean {\n const batcher = new RecordBatcher(onRecords);\n const registered = trace.setGlobalTracerProvider(\n new TracerProvider({\n spanProcessors: [new SupervisorSpanProcessor(batcher)],\n }),\n );\n context.setGlobalContextManager(\n new AsyncLocalStorageContextManager().enable(),\n );\n propagation.setGlobalPropagator(new W3CTraceContextPropagator());\n // From here the dashboard shows what actions and tools log, as span events,\n // so @brickkit/core stops printing it. The key is shared by name because the\n // app and the dev server may each hold their own copy of core.\n if (registered) {\n (globalThis as Record<symbol, unknown>)[LOG_CAPTURE] = true;\n captureConsole();\n }\n return registered;\n}\n\ntype Restore = () => void;\n\n/**\n * Send `console.log`, `info`, `warn`, `error`, and `debug` to the dashboard\n * while a traced request is running, as `ctx.logger` does, so code that logs\n * with `console` needs no change. Lines logged outside a request print as\n * usual. Only a dashboard turns this on, `brick dev`'s or the monitoring one\n * of `brick start`: with neither, the console is left alone. Calling it again\n * does nothing; the returned function puts the console back.\n */\nexport function captureConsole(): Restore {\n const target = console as unknown as Record<string | symbol, unknown>;\n const existing = target[CONSOLE_CAPTURED];\n if (typeof existing === \"function\") return existing as Restore;\n\n const globals = globalThis as Record<symbol, unknown>;\n const originals = new Map<string, (...args: unknown[]) => void>();\n for (const [method, level] of Object.entries(CONSOLE_LEVELS)) {\n const original = target[method] as (...args: unknown[]) => void;\n originals.set(method, original);\n target[method] = function (this: unknown, ...args: unknown[]) {\n const record = globals[LOG_RECORD];\n if (\n globals[LOG_CAPTURE] === true &&\n typeof record === \"function\" &&\n record(level, args) === true\n )\n return;\n original.apply(this, args);\n };\n }\n const restore: Restore = () => {\n for (const [method, original] of originals) target[method] = original;\n delete target[CONSOLE_CAPTURED];\n };\n target[CONSOLE_CAPTURED] = restore;\n return restore;\n}\n\n/**\n * Install tracing in the dev worker, so spans from apps built with\n * `brick({ telemetry: true })` reach the supervisor and join callers' traces.\n * Call before the app entry is imported.\n */\nexport function installWorkerTelemetry(): void {\n installTracing((records) => {\n void sendToSupervisor({ type: \"brick:telemetry\", records });\n });\n}\n\nexport function reportWorkerError(\n phase: WorkerErrorPhase,\n error: unknown,\n): Promise<void> {\n return sendToSupervisor({\n type: \"brick:error\",\n phase,\n error: serializeError(error),\n });\n}\n\nfunction serializeError(error: unknown): SerializedError {\n if (error instanceof Error) {\n return {\n name: error.name,\n message: truncate(error.message),\n stack:\n error.stack === undefined\n ? undefined\n : truncate(error.stack, MAX_STACK_LENGTH),\n };\n }\n return { name: \"Error\", message: truncate(String(error)) };\n}\n\nfunction truncate(text: string, limit = MAX_TEXT_LENGTH): string {\n return text.length > limit ? `${text.slice(0, limit)}…` : text;\n}\n\nfunction toMs(time: HrTime): number {\n return time[0] * 1000 + time[1] / 1e6;\n}\n\nfunction statusName(code: SpanStatusCode): \"unset\" | \"ok\" | \"error\" {\n if (code === SpanStatusCode.ERROR) return \"error\";\n if (code === SpanStatusCode.OK) return \"ok\";\n return \"unset\";\n}\n\nfunction boundAttributes(attributes: Attributes | undefined): Attributes {\n const bounded: Attributes = {};\n for (const [key, value] of Object.entries(attributes ?? {})) {\n bounded[key] =\n typeof value === \"string\" ? truncate(value, MAX_STACK_LENGTH) : value;\n }\n return bounded;\n}\n\nclass RecordBatcher {\n #records: TelemetryRecord[] = [];\n #timer: ReturnType<typeof setTimeout> | undefined;\n readonly #send: (records: TelemetryRecord[]) => void;\n\n constructor(send: (records: TelemetryRecord[]) => void) {\n this.#send = send;\n }\n\n push(record: TelemetryRecord): void {\n this.#records.push(record);\n if (this.#records.length >= MAX_BATCH_SIZE) this.flush();\n else this.#timer ??= setTimeout(() => this.flush(), FLUSH_DELAY_MS);\n }\n\n flush(): void {\n clearTimeout(this.#timer);\n this.#timer = undefined;\n if (this.#records.length === 0) return;\n const records = this.#records;\n this.#records = [];\n this.#send(records);\n }\n}\n\nclass SupervisorSpanProcessor implements SpanProcessor {\n readonly #batcher: RecordBatcher;\n\n constructor(batcher: RecordBatcher) {\n this.#batcher = batcher;\n }\n\n onStart(span: Span): void {\n const { traceId, spanId } = span.spanContext();\n this.#batcher.push({\n phase: \"start\",\n traceId,\n spanId,\n parentSpanId: span.parentSpanContext?.spanId,\n name: span.name,\n startMs: toMs(span.startTime),\n attributes: boundAttributes(span.attributes),\n });\n }\n\n onEnd(span: ReadableSpan): void {\n const { traceId, spanId } = span.spanContext();\n this.#batcher.push({\n phase: \"end\",\n traceId,\n spanId,\n name: span.name,\n endMs: toMs(span.endTime),\n status: statusName(span.status.code),\n statusMessage: span.status.message,\n attributes: boundAttributes(span.attributes),\n events: span.events.map((event) => ({\n name: event.name,\n timeMs: toMs(event.time),\n attributes: boundAttributes(event.attributes),\n })),\n });\n }\n\n async forceFlush(): Promise<void> {\n this.#batcher.flush();\n }\n\n async shutdown(): Promise<void> {\n this.#batcher.flush();\n }\n}\n"],"mappings":";;;;;;;;AAyBA,MAAM,cAAc,OAAO,IAAI,cAAc,WAAW;;AAExD,MAAM,aAAa,OAAO,IAAI,cAAc,UAAU;AACtD,MAAM,mBAAmB,OAAO,IAAI,2BAA2B;AAE/D,MAAM,iBAAiB;CACrB,KAAK;CACL,MAAM;CACN,MAAM;CACN,OAAO;CACP,OAAO;AACT;AAEA,MAAM,kBAAkB;AACxB,MAA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,YAAY,SAAwB;EAClC,KAAK,WAAW;CAClB;CAEA,QAAQ,MAAkB;EACxB,MAAM,EAAE,SAAS,WAAW,KAAK,YAAY;EAC7C,KAAK,SAAS,KAAK;GACjB,OAAO;GACP;GACA;GACA,cAAc,KAAK,mBAAmB;GACtC,MAAM,KAAK;GACX,SAAS,KAAK,KAAK,SAAS;GAC5B,YAAY,gBAAgB,KAAK,UAAU;EAC7C,CAAC;CACH;CAEA,MAAM,MAA0B;EAC9B,MAAM,EAAE,SAAS,WAAW,KAAK,YAAY;EAC7C,KAAK,SAAS,KAAK;GACjB,OAAO;GACP;GACA;GACA,MAAM,KAAK;GACX,OAAO,KAAK,KAAK,OAAO;GACxB,QAAQ,WAAW,KAAK,OAAO,IAAI;GACnC,eAAe,KAAK,OAAO;GAC3B,YAAY,gBAAgB,KAAK,UAAU;GAC3C,QAAQ,KAAK,OAAO,KAAK,WAAW;IAClC,MAAM,MAAM;IACZ,QAAQ,KAAK,MAAM,IAAI;IACvB,YAAY,gBAAgB,MAAM,UAAU;GAC9C,EAAE;EACJ,CAAC;CACH;CAEA,MAAM,aAA4B;EAChC,KAAK,SAAS,MAAM;CACtB;CAEA,MAAM,WAA0B;EAC9B,KAAK,SAAS,MAAM;CACtB;AACF"}
|
|
1
|
+
{"version":3,"file":"dev-telemetry.js","names":[],"sources":["../src/dev-telemetry.ts"],"sourcesContent":["import {\n context,\n propagation,\n ROOT_CONTEXT,\n SpanStatusCode,\n trace,\n type Attributes,\n type HrTime,\n} from \"@opentelemetry/api\";\nimport { AsyncLocalStorageContextManager } from \"@opentelemetry/context-async-hooks\";\nimport { W3CTraceContextPropagator } from \"@opentelemetry/core\";\nimport {\n TracerProvider,\n type ReadableSpan,\n type Span,\n type SpanProcessor,\n} from \"@opentelemetry/sdk-trace\";\nimport { GLOBAL_SYMBOL } from \"@brickkit/core\";\nimport type {\n SerializedError,\n TelemetryRecord,\n WorkerErrorPhase,\n} from \"./dashboard-protocol\";\nimport { sendToSupervisor } from \"./dev-protocol\";\n\n/** Read by @brickkit/core's logger; see `createLogger` there. */\nconst LOG_CAPTURE = Symbol.for(GLOBAL_SYMBOL.logsCapture);\n/** Core's function that records a line on the running span; see `recordActive` there. */\nconst LOG_RECORD = Symbol.for(GLOBAL_SYMBOL.logsRecord);\nconst CONSOLE_CAPTURED = Symbol.for(\"brickkit.console.captured\");\n\nconst CONSOLE_LEVELS = {\n log: \"info\",\n info: \"info\",\n warn: \"warn\",\n error: \"error\",\n debug: \"debug\",\n} as const;\n\nconst MAX_TEXT_LENGTH = 500;\nconst MAX_STACK_LENGTH = 4000;\nconst FLUSH_DELAY_MS = 20;\nconst MAX_BATCH_SIZE = 200;\n\n/**\n * Register the tracer provider, context manager, and W3C trace context\n * propagator. Span records are batched and passed to `onRecords`. Returns false\n * when another tracer provider was already registered, in which case\n * `onRecords` never runs.\n */\nexport function installTracing(\n onRecords: (records: TelemetryRecord[]) => void,\n): boolean {\n const batcher = new RecordBatcher(onRecords);\n const registered = trace.setGlobalTracerProvider(\n new TracerProvider({\n spanProcessors: [new SupervisorSpanProcessor(batcher)],\n }),\n );\n context.setGlobalContextManager(\n new AsyncLocalStorageContextManager().enable(),\n );\n propagation.setGlobalPropagator(new W3CTraceContextPropagator());\n // From here the dashboard shows what actions and tools log, as span events,\n // so @brickkit/core stops printing it. The key is shared by name because the\n // app and the dev server may each hold their own copy of core.\n if (registered) {\n (globalThis as Record<symbol, unknown>)[LOG_CAPTURE] = true;\n captureConsole();\n }\n return registered;\n}\n\ntype Restore = () => void;\n\n/**\n * Send `console.log`, `info`, `warn`, `error`, and `debug` to the dashboard\n * while a traced request is running, as `ctx.logger` does, so code that logs\n * with `console` needs no change. Lines logged outside a request print as\n * usual. Only a dashboard turns this on, `brick dev`'s or the monitoring one\n * of `brick start`: with neither, the console is left alone. Calling it again\n * does nothing; the returned function puts the console back.\n */\nexport function captureConsole(): Restore {\n const target = console as unknown as Record<string | symbol, unknown>;\n const existing = target[CONSOLE_CAPTURED];\n if (typeof existing === \"function\") return existing as Restore;\n\n const globals = globalThis as Record<symbol, unknown>;\n const originals = new Map<string, (...args: unknown[]) => void>();\n for (const [method, level] of Object.entries(CONSOLE_LEVELS)) {\n const original = target[method] as (...args: unknown[]) => void;\n originals.set(method, original);\n target[method] = function (this: unknown, ...args: unknown[]) {\n const record = globals[LOG_RECORD];\n if (\n globals[LOG_CAPTURE] === true &&\n typeof record === \"function\" &&\n record(level, args) === true\n )\n return;\n original.apply(this, args);\n };\n }\n const restore: Restore = () => {\n for (const [method, original] of originals) target[method] = original;\n delete target[CONSOLE_CAPTURED];\n };\n target[CONSOLE_CAPTURED] = restore;\n return restore;\n}\n\n/**\n * Install tracing in the dev worker, so spans from apps built with\n * `brick({ telemetry: true })` reach the supervisor and join callers' traces.\n * Call before the app entry is imported.\n */\nexport function installWorkerTelemetry(): void {\n installTracing((records) => {\n void sendToSupervisor({ type: \"brick:telemetry\", records });\n });\n}\n\nexport function reportWorkerError(\n phase: WorkerErrorPhase,\n error: unknown,\n): Promise<void> {\n return sendToSupervisor({\n type: \"brick:error\",\n phase,\n error: serializeError(error),\n });\n}\n\nfunction serializeError(error: unknown): SerializedError {\n if (error instanceof Error) {\n return {\n name: error.name,\n message: truncate(error.message),\n stack:\n error.stack === undefined\n ? undefined\n : truncate(error.stack, MAX_STACK_LENGTH),\n };\n }\n return { name: \"Error\", message: truncate(String(error)) };\n}\n\nfunction truncate(text: string, limit = MAX_TEXT_LENGTH): string {\n return text.length > limit ? `${text.slice(0, limit)}…` : text;\n}\n\nfunction toMs(time: HrTime): number {\n return time[0] * 1000 + time[1] / 1e6;\n}\n\nfunction statusName(code: SpanStatusCode): \"unset\" | \"ok\" | \"error\" {\n if (code === SpanStatusCode.ERROR) return \"error\";\n if (code === SpanStatusCode.OK) return \"ok\";\n return \"unset\";\n}\n\nfunction boundAttributes(attributes: Attributes | undefined): Attributes {\n const bounded: Attributes = {};\n for (const [key, value] of Object.entries(attributes ?? {})) {\n bounded[key] =\n typeof value === \"string\" ? truncate(value, MAX_STACK_LENGTH) : value;\n }\n return bounded;\n}\n\nclass RecordBatcher {\n #records: TelemetryRecord[] = [];\n #timer: ReturnType<typeof setTimeout> | undefined;\n readonly #send: (records: TelemetryRecord[]) => void;\n\n constructor(send: (records: TelemetryRecord[]) => void) {\n this.#send = send;\n }\n\n push(record: TelemetryRecord): void {\n this.#records.push(record);\n if (this.#records.length >= MAX_BATCH_SIZE) this.flush();\n else this.#timer ??= setTimeout(() => this.flush(), FLUSH_DELAY_MS);\n }\n\n flush(): void {\n clearTimeout(this.#timer);\n this.#timer = undefined;\n if (this.#records.length === 0) return;\n const records = this.#records;\n this.#records = [];\n context.with(ROOT_CONTEXT, () => this.#send(records));\n }\n}\n\nclass SupervisorSpanProcessor implements SpanProcessor {\n readonly #batcher: RecordBatcher;\n\n constructor(batcher: RecordBatcher) {\n this.#batcher = batcher;\n }\n\n onStart(span: Span): void {\n const { traceId, spanId } = span.spanContext();\n this.#batcher.push({\n phase: \"start\",\n traceId,\n spanId,\n parentSpanId: span.parentSpanContext?.spanId,\n name: span.name,\n startMs: toMs(span.startTime),\n attributes: boundAttributes(span.attributes),\n });\n }\n\n onEnd(span: ReadableSpan): void {\n const { traceId, spanId } = span.spanContext();\n this.#batcher.push({\n phase: \"end\",\n traceId,\n spanId,\n name: span.name,\n endMs: toMs(span.endTime),\n status: statusName(span.status.code),\n statusMessage: span.status.message,\n attributes: boundAttributes(span.attributes),\n events: span.events.map((event) => ({\n name: event.name,\n timeMs: toMs(event.time),\n attributes: boundAttributes(event.attributes),\n })),\n });\n }\n\n async forceFlush(): Promise<void> {\n this.#batcher.flush();\n }\n\n async shutdown(): Promise<void> {\n this.#batcher.flush();\n }\n}\n"],"mappings":";;;;;;;;AA0BA,MAAM,cAAc,OAAO,IAAI,cAAc,WAAW;;AAExD,MAAM,aAAa,OAAO,IAAI,cAAc,UAAU;AACtD,MAAM,mBAAmB,OAAO,IAAI,2BAA2B;AAE/D,MAAM,iBAAiB;CACr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K,WAAW,CAAC;EACjB,QAAQ,KAAK,oBAAoB,KAAK,MAAM,OAAO,CAAC;CACtD;AACF;AAEA,IAAM,0BAAN,MAAuD;CAC5C;CAET,YAAY,SAAwB;EAClC,KAAK,WAAW;CAClB;CAEA,QAAQ,MAAkB;EACxB,MAAM,EAAE,SAAS,WAAW,KAAK,YAAY;EAC7C,KAAK,SAAS,KAAK;GACjB,OAAO;GACP;GACA;GACA,cAAc,KAAK,mBAAmB;GACtC,MAAM,KAAK;GACX,SAAS,KAAK,KAAK,SAAS;GAC5B,YAAY,gBAAgB,KAAK,UAAU;EAC7C,CAAC;CACH;CAEA,MAAM,MAA0B;EAC9B,MAAM,EAAE,SAAS,WAAW,KAAK,YAAY;EAC7C,KAAK,SAAS,KAAK;GACjB,OAAO;GACP;GACA;GACA,MAAM,KAAK;GACX,OAAO,KAAK,KAAK,OAAO;GACxB,QAAQ,WAAW,KAAK,OAAO,IAAI;GACnC,eAAe,KAAK,OAAO;GAC3B,YAAY,gBAAgB,KAAK,UAAU;GAC3C,QAAQ,KAAK,OAAO,KAAK,WAAW;IAClC,MAAM,MAAM;IACZ,QAAQ,KAAK,MAAM,IAAI;IACvB,YAAY,gBAAgB,MAAM,UAAU;GAC9C,EAAE;EACJ,CAAC;CACH;CAEA,MAAM,aAA4B;EAChC,KAAK,SAAS,MAAM;CACtB;CAEA,MAAM,WAA0B;EAC9B,KAAK,SAAS,MAAM;CACtB;AACF"}
|
package/dist/package.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -42,6 +42,7 @@ async function startProductionDashboard(app, options) {
|
|
|
42
42
|
portHint: "Set dashboard.port in brick() to another.",
|
|
43
43
|
auth: config.auth,
|
|
44
44
|
inspector: config.inspector,
|
|
45
|
+
mcp: config.mcp,
|
|
45
46
|
dashboard: options.dashboard,
|
|
46
47
|
plugins: app.definition.plugins,
|
|
47
48
|
appUrl: `http://127.0.0.1:${options.appPort}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"production-dashboard.js","names":[],"sources":["../src/production-dashboard.ts"],"sourcesContent":["import { getGlobalRegistry, type BrickApp } from \"@brickkit/core\";\nimport type { DashboardExtensionOptions } from \"./dashboard-extension\";\nimport { openDashboard } from \"./dashboard-host\";\nimport { startInspector, type Inspector } from \"./dev-inspector\";\nimport { installTracing } from \"./dev-telemetry\";\n\nexport interface ProductionDashboard {\n readonly host: string;\n readonly port: number;\n stop(): void;\n}\n\n/**\n * Serve the monitoring dashboard an app asks for with `brick({ dashboard })`,\n * in the process that serves the app. It listens on a port of its own, so it\n * stays up when the app's routes do not answer, and its `/_health` tells an\n * uptime monitor whether the app does. From here on `ctx.logger` and `console`\n * lines written during a request go to the dashboard, not the console.\n *\n * With `dashboard.inspector` it also serves the workflow inspector and the\n * schedules, on a loopback port only the dashboard knows, for the Workflows\n * and Schedules views. An app with neither, or an inspector that cannot start,\n * costs those views and a warning, nothing else.\n *\n * Call it before the app starts listening. Returns undefined when the app\n * asks for no dashboard, or when it cannot start (the app runs on without it,\n * and says so). A configuration that would leave the dashboard open to others\n * throws instead: the app must not start unprotected.\n */\nexport async function startProductionDashboard(\n app: BrickApp,\n options: {\n /** The port the app listens on, for the health probe. */\n appPort: number;\n /** Where `.brick/` history is kept; the working folder by default. */\n directory?: string;\n warn?: (message: string) => void;\n /**\n * The project's extension (source, or the folder `brick build` wrote) and\n * theme. The app's plugins' extensions join it, from source or as the\n * folder holds them. Only pages marked `production: true` are shown.\n */\n dashboard?: DashboardExtensionOptions;\n },\n): Promise<ProductionDashboard | undefined> {\n const config = app.definition.dashboard;\n if (!config) return undefined;\n const warn = options.warn ?? ((message) => console.warn(message));\n const host = config.host ?? \"127.0.0.1\";\n let inspector: Inspector | undefined;\n if (config.inspector) {\n try {\n inspector = await startInspector(app);\n if (!inspector)\n warn(\n \"[Brick-TS] dashboard.inspector is on, but the app has no workflows and no schedules, so there is nothing for it to show.\",\n );\n } catch (error) {\n warn(\n `[Brick-TS] Could not start the workflow inspector, so the dashboard has no Schedules and Workflows views: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n const started = await openDashboard({\n directory: options.directory ?? process.cwd(),\n historyDays: config.historyDays ?? 0,\n warn,\n port: config.port,\n host,\n mode: \"production\",\n portHint: \"Set dashboard.port in brick() to another.\",\n auth: config.auth,\n inspector: config.inspector,\n dashboard: options.dashboard,\n plugins: app.definition.plugins,\n appUrl: `http://127.0.0.1:${options.appPort}`,\n probe: async () => {\n const response = await fetch(\n `http://127.0.0.1:${options.appPort}/_health`,\n { signal: AbortSignal.timeout(2000) },\n );\n return response.ok;\n },\n }).catch((error: unknown) => {\n inspector?.stop();\n throw error;\n });\n if (!started) {\n inspector?.stop();\n return undefined;\n }\n const { store } = started;\n if (inspector) store.setInspector(inspector);\n\n const registered = installTracing((records) =>\n store.ingest(records, store.latestGeneration),\n );\n if (!registered) {\n warn(\n \"[Brick-TS] Another tracer provider is already registered, so the dashboard will show no requests or logs.\",\n );\n }\n const generation = store.startGeneration(\"application started\");\n store.setArchitecture(\n getGlobalRegistry().exportArchitecture(app.definition),\n generation,\n );\n return {\n host,\n port: started.port,\n stop() {\n inspector?.stop();\n started.stop();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,yBACpB,KACA,SAa0C;CAC1C,MAAM,SAAS,IAAI,WAAW;CAC9B,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,MAAM,OAAO,QAAQ,UAAU,YAAY,QAAQ,KAAK,OAAO;CAC/D,MAAM,OAAO,OAAO,QAAQ;CAC5B,IAAI;CACJ,IAAI,OAAO,WACT,IAAI;EACF,YAAY,MAAM,eAAe,GAAG;EACpC,IAAI,CAAC,WACH,KACE,0HACF;CACJ,SAAS,OAAO;EACd,KACE,6GAA6G,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACpK;CACF;CAEF,MAAM,UAAU,MAAM,cAAc;EAClC,WAAW,QAAQ,aAAa,QAAQ,IAAI;EAC5C,aAAa,OAAO,eAAe;EACnC;EACA,MAAM,OAAO;EACb;EACA,MAAM;EACN,UAAU;EACV,MAAM,OAAO;EACb,WAAW,OAAO;EAClB,WAAW,QAAQ;EACnB,SAAS,IAAI,WAAW;EACxB,QAAQ,oBAAoB,QAAQ;EACpC,OAAO,YAAY;GAKjB,QAAO,MAJgB,MACrB,oBAAoB,QAAQ,QAAQ,WACpC,EAAE,QAAQ,YAAY,QAAQ,GAAI,EAAE,CACtC,EAAA,CACgB;EAClB;CACF,CAAC,CAAC,CAAC,OAAO,UAAmB;EAC3B,WAAW,KAAK;EAChB,MAAM;CACR,CAAC;CACD,IAAI,CAAC,SAAS;EACZ,WAAW,KAAK;EAChB;CACF;CACA,MAAM,EAAE,UAAU;CAClB,IAAI,WAAW,MAAM,aAAa,SAAS;CAK3C,IAAI,CAHe,gBAAgB,YACjC,MAAM,OAAO,SAAS,MAAM,gBAAgB,CAEhC,GACZ,KACE,2GACF;CAEF,MAAM,aAAa,MAAM,gBAAgB,qBAAqB;CAC9D,MAAM,gBACJ,kBAAkB,CAAC,CAAC,mBAAmB,IAAI,UAAU,GACrD,UACF;CACA,OAAO;EACL;EACA,MAAM,QAAQ;EACd,OAAO;GACL,WAAW,KAAK;GAChB,QAAQ,KAAK;EACf;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"production-dashboard.js","names":[],"sources":["../src/production-dashboard.ts"],"sourcesContent":["import { getGlobalRegistry, type BrickApp } from \"@brickkit/core\";\nimport type { DashboardExtensionOptions } from \"./dashboard-extension\";\nimport { openDashboard } from \"./dashboard-host\";\nimport { startInspector, type Inspector } from \"./dev-inspector\";\nimport { installTracing } from \"./dev-telemetry\";\n\nexport interface ProductionDashboard {\n readonly host: string;\n readonly port: number;\n stop(): void;\n}\n\n/**\n * Serve the monitoring dashboard an app asks for with `brick({ dashboard })`,\n * in the process that serves the app. It listens on a port of its own, so it\n * stays up when the app's routes do not answer, and its `/_health` tells an\n * uptime monitor whether the app does. From here on `ctx.logger` and `console`\n * lines written during a request go to the dashboard, not the console.\n *\n * With `dashboard.inspector` it also serves the workflow inspector and the\n * schedules, on a loopback port only the dashboard knows, for the Workflows\n * and Schedules views. An app with neither, or an inspector that cannot start,\n * costs those views and a warning, nothing else.\n *\n * Call it before the app starts listening. Returns undefined when the app\n * asks for no dashboard, or when it cannot start (the app runs on without it,\n * and says so). A configuration that would leave the dashboard open to others\n * throws instead: the app must not start unprotected.\n */\nexport async function startProductionDashboard(\n app: BrickApp,\n options: {\n /** The port the app listens on, for the health probe. */\n appPort: number;\n /** Where `.brick/` history is kept; the working folder by default. */\n directory?: string;\n warn?: (message: string) => void;\n /**\n * The project's extension (source, or the folder `brick build` wrote) and\n * theme. The app's plugins' extensions join it, from source or as the\n * folder holds them. Only pages marked `production: true` are shown.\n */\n dashboard?: DashboardExtensionOptions;\n },\n): Promise<ProductionDashboard | undefined> {\n const config = app.definition.dashboard;\n if (!config) return undefined;\n const warn = options.warn ?? ((message) => console.warn(message));\n const host = config.host ?? \"127.0.0.1\";\n let inspector: Inspector | undefined;\n if (config.inspector) {\n try {\n inspector = await startInspector(app);\n if (!inspector)\n warn(\n \"[Brick-TS] dashboard.inspector is on, but the app has no workflows and no schedules, so there is nothing for it to show.\",\n );\n } catch (error) {\n warn(\n `[Brick-TS] Could not start the workflow inspector, so the dashboard has no Schedules and Workflows views: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n const started = await openDashboard({\n directory: options.directory ?? process.cwd(),\n historyDays: config.historyDays ?? 0,\n warn,\n port: config.port,\n host,\n mode: \"production\",\n portHint: \"Set dashboard.port in brick() to another.\",\n auth: config.auth,\n inspector: config.inspector,\n mcp: config.mcp,\n dashboard: options.dashboard,\n plugins: app.definition.plugins,\n appUrl: `http://127.0.0.1:${options.appPort}`,\n probe: async () => {\n const response = await fetch(\n `http://127.0.0.1:${options.appPort}/_health`,\n { signal: AbortSignal.timeout(2000) },\n );\n return response.ok;\n },\n }).catch((error: unknown) => {\n inspector?.stop();\n throw error;\n });\n if (!started) {\n inspector?.stop();\n return undefined;\n }\n const { store } = started;\n if (inspector) store.setInspector(inspector);\n\n const registered = installTracing((records) =>\n store.ingest(records, store.latestGeneration),\n );\n if (!registered) {\n warn(\n \"[Brick-TS] Another tracer provider is already registered, so the dashboard will show no requests or logs.\",\n );\n }\n const generation = store.startGeneration(\"application started\");\n store.setArchitecture(\n getGlobalRegistry().exportArchitecture(app.definition),\n generation,\n );\n return {\n host,\n port: started.port,\n stop() {\n inspector?.stop();\n started.stop();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,yBACpB,KACA,SAa0C;CAC1C,MAAM,SAAS,IAAI,WAAW;CAC9B,IAAI,CAAC,QAAQ,OAAO,KAAA;CACpB,MAAM,OAAO,QAAQ,UAAU,YAAY,QAAQ,KAAK,OAAO;CAC/D,MAAM,OAAO,OAAO,QAAQ;CAC5B,IAAI;CACJ,IAAI,OAAO,WACT,IAAI;EACF,YAAY,MAAM,eAAe,GAAG;EACpC,IAAI,CAAC,WACH,KACE,0HACF;CACJ,SAAS,OAAO;EACd,KACE,6GAA6G,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACpK;CACF;CAEF,MAAM,UAAU,MAAM,cAAc;EAClC,WAAW,QAAQ,aAAa,QAAQ,IAAI;EAC5C,aAAa,OAAO,eAAe;EACnC;EACA,MAAM,OAAO;EACb;EACA,MAAM;EACN,UAAU;EACV,MAAM,OAAO;EACb,WAAW,OAAO;EAClB,KAAK,OAAO;EACZ,WAAW,QAAQ;EACnB,SAAS,IAAI,WAAW;EACxB,QAAQ,oBAAoB,QAAQ;EACpC,OAAO,YAAY;GAKjB,QAAO,MAJgB,MACrB,oBAAoB,QAAQ,QAAQ,WACpC,EAAE,QAAQ,YAAY,QAAQ,GAAI,EAAE,CACtC,EAAA,CACgB;EAClB;CACF,CAAC,CAAC,CAAC,OAAO,UAAmB;EAC3B,WAAW,KAAK;EAChB,MAAM;CACR,CAAC;CACD,IAAI,CAAC,SAAS;EACZ,WAAW,KAAK;EAChB;CACF;CACA,MAAM,EAAE,UAAU;CAClB,IAAI,WAAW,MAAM,aAAa,SAAS;CAK3C,IAAI,CAHe,gBAAgB,YACjC,MAAM,OAAO,SAAS,MAAM,gBAAgB,CAEhC,GACZ,KACE,2GACF;CAEF,MAAM,aAAa,MAAM,gBAAgB,qBAAqB;CAC9D,MAAM,gBACJ,kBAAkB,CAAC,CAAC,mBAAmB,IAAI,UAAU,GACrD,UACF;CACA,OAAO;EACL;EACA,MAAM,QAAQ;EACd,OAAO;GACL,WAAW,KAAK;GAChB,QAAQ,KAAK;EACf;CACF;AACF"}
|
package/dist/project.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { n as ConfigError, s as PROJECT_DEFAULTS } from "./config2.js";
|
|
2
2
|
import { a as TEST_FILE, i as MANIFEST_FILE, n as DEFINITION_FILE } from "./definitions.js";
|
|
3
|
+
import { t as version } from "./package.js";
|
|
3
4
|
import { readdirSync } from "node:fs";
|
|
4
5
|
import { basename, dirname, relative, resolve, sep } from "node:path";
|
|
5
6
|
import { STANDARD_ERRORS, isControlEvent, kebabCase } from "@brickkit/core/client";
|
|
@@ -213,8 +214,6 @@ function memberCall(node) {
|
|
|
213
214
|
property: callee.property.name
|
|
214
215
|
};
|
|
215
216
|
}
|
|
216
|
-
// package.json
|
|
217
|
-
var version = "0.16.0-beta.2";
|
|
218
217
|
// src/lint/rules/checks.ts
|
|
219
218
|
const MANIFEST_STEM = MANIFEST_FILE.replace(/\.ts$/, "");
|
|
220
219
|
/** This release's range, for the `brick` field example: `^0.12.0`. */
|
|
@@ -1084,6 +1083,6 @@ function projectRules(project) {
|
|
|
1084
1083
|
ignore: [...lint.ignore ?? [], `${settings.generated}/**`]
|
|
1085
1084
|
};
|
|
1086
1085
|
}
|
|
1087
|
-
export { rules as a, resolveRules as i, PRESETS as n,
|
|
1086
|
+
export { rules as a, resolveRules as i, PRESETS as n, serviceFolders as o, fileRules as r, projectRules as t };
|
|
1088
1087
|
|
|
1089
1088
|
//# sourceMappingURL=project.js.map
|