@coreframe/dashboard 0.3.7 → 0.3.8
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 +28 -12
- package/dist/package/api/client.d.ts +16 -0
- package/dist/package/api/client.js +1 -0
- package/dist/package/api/contract.d.ts +74 -0
- package/dist/package/api/contract.js +1 -0
- package/dist/package/api/dispatcher.js +1 -0
- package/dist/package/api/error-mapping.js +1 -0
- package/dist/package/api/errors.d.ts +13 -0
- package/dist/package/api/errors.js +1 -0
- package/dist/package/api/paths.js +1 -0
- package/dist/package/api/rouzer.js +1 -0
- package/dist/package/api/validation.js +1 -0
- package/dist/package/app/routes.js +1 -1
- package/dist/package/app/shell.d.ts +0 -1
- package/dist/package/build.d.ts +13 -18
- package/dist/package/build.js +3 -3
- package/dist/package/config.d.ts +37 -14
- package/dist/package/config.js +1 -1
- package/dist/package/host-policy.js +1 -0
- package/dist/package/index.d.ts +1 -1
- package/dist/package/plugin-api.d.ts +4 -59
- package/dist/package/plugin-api.js +1 -1
- package/dist/package/plugins/diagnostics/api/contract.d.ts +13 -0
- package/dist/package/plugins/diagnostics/api/contract.js +1 -0
- package/dist/package/plugins/diagnostics/api/local.d.ts +7 -4
- package/dist/package/plugins/diagnostics/api/local.js +1 -1
- package/dist/package/plugins/diagnostics/api/worker.d.ts +5 -4
- package/dist/package/plugins/diagnostics/api/worker.js +1 -1
- package/dist/package/plugins/diagnostics/index.d.ts +12 -18
- package/dist/package/plugins/diagnostics/index.js +1 -1
- package/dist/package/plugins/diagnostics/web/queries.js +1 -1
- package/dist/package/server.d.ts +7 -4
- package/dist/package/server.js +1 -1
- package/dist/package/worker.d.ts +12 -3
- package/dist/package/worker.js +1 -1
- package/package.json +4 -12
- package/dist/package/plugins/diagnostics/api/client.d.ts +0 -27
- package/dist/package/plugins/diagnostics/api/client.js +0 -1
- package/dist/package/plugins/diagnostics/api/handlers.d.ts +0 -14
- package/dist/package/plugins/diagnostics/api/handlers.js +0 -1
- package/dist/package/plugins/diagnostics/api/routes.d.ts +0 -12
- package/dist/package/plugins/diagnostics/api/routes.js +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Reusable composition, shell, plugin, and authenticated runtime boundaries for an
|
|
|
4
4
|
Coreframe dashboard.
|
|
5
5
|
|
|
6
6
|
Generated applications own a second client-only React Router application under `dashboard`. Coreframe
|
|
7
|
-
provides the document, client bootstrap,
|
|
7
|
+
provides the document, client bootstrap, shell adapters, and virtual build modules; the
|
|
8
8
|
application keeps its plugin selection and pages. The normal `pnpm dev`, `pnpm typecheck`, `pnpm
|
|
9
9
|
build`, and `pnpm preview` workflows supervise, generate, and build that application. Its production
|
|
10
10
|
assets are merged into `dist/client/__dashboard` and remain mounted at `/__dashboard`.
|
|
@@ -22,12 +22,12 @@ export default defineDashboardConfig({
|
|
|
22
22
|
})
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
Removing `diagnostics()` removes
|
|
26
|
-
are never discovered or installed at runtime.
|
|
25
|
+
Removing `diagnostics()` removes the feature's root navigation entry and its runtime operations.
|
|
26
|
+
Plugins are never discovered or installed at runtime.
|
|
27
27
|
|
|
28
28
|
Add app-owned routes at `dashboard/pages/<slug>/route.tsx`. An optional adjacent `page.yaml` may
|
|
29
29
|
define `title` and `description`. Build-time composition validates slugs, metadata, route modules,
|
|
30
|
-
identifiers, and paths before generating the React Router route
|
|
30
|
+
identifiers, and paths before generating the React Router route graph and navigation manifest.
|
|
31
31
|
|
|
32
32
|
The generated dashboard does not need route adapters, a document root, a query-client module, or an
|
|
33
33
|
entry file. Keep those defaults in the package unless the dashboard build contract itself must
|
|
@@ -49,18 +49,34 @@ Sculpted, Rouzer, Zod, TanStack Query, and Worker conventions as the main Corefr
|
|
|
49
49
|
Coreframe contributes the responsive navigation shell and default client/query runtime without
|
|
50
50
|
imposing a page-content component API.
|
|
51
51
|
|
|
52
|
-
Plugin APIs are
|
|
53
|
-
`/__dashboard/api/plugins/<plugin-id
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
Plugin APIs expose named `queries` and `commands`. Queries are `GET` operations and commands are
|
|
53
|
+
`POST` operations below `/__dashboard/api/plugins/<plugin-id>/`; Rouzer is an internal transport and
|
|
54
|
+
validation detail. A plugin page derives its client directly from the same operation contract, so it
|
|
55
|
+
does not use a browser registry or hand-built API URL.
|
|
56
|
+
|
|
57
|
+
The `@coreframe/dashboard/api` entry contains the operation contract, implementation types, safe
|
|
58
|
+
operation errors, and browser client. Host adapters keep the Rouzer dispatcher, transport validation,
|
|
59
|
+
error mapping, and request policy internal. Generated registrations carry the contract and its
|
|
60
|
+
implementation factory; the contract's `id` is the registration identity.
|
|
61
|
+
|
|
62
|
+
Plugins contribute one root navigation entry and one browser page module. Nested feature pages stay
|
|
63
|
+
inside that page module. Package-owned build descriptors select local and deployed implementation
|
|
64
|
+
modules independently; omitting the deployed implementation makes a feature explicitly local-only.
|
|
65
|
+
Target-specific modules are never listed in application configuration or imported into the wrong
|
|
66
|
+
bundle.
|
|
67
|
+
|
|
68
|
+
The dashboard host owns authentication, same-origin or CSRF protection, and request identity. Every
|
|
69
|
+
authenticated dashboard user is the superuser for every installed plugin. Operations receive only a
|
|
70
|
+
sanitized actor, request ID, cancellation signal, and target-specific host data; dashboard
|
|
71
|
+
credentials, Worker bindings, environment secrets, and the raw request remain outside the plugin
|
|
72
|
+
contract. Typed operation errors expose safe error codes, and a failed local initialization can be
|
|
73
|
+
retried without restarting the host.
|
|
58
74
|
|
|
59
75
|
## Built-in diagnostics
|
|
60
76
|
|
|
61
77
|
The diagnostics plugin preserves the full local production-readiness inspection and provides a
|
|
62
|
-
reduced deployed view. Its page is a normal
|
|
63
|
-
|
|
78
|
+
reduced deployed view. Its page is a normal module and its browser data uses a typed operation client
|
|
79
|
+
with TanStack Query. Local collection may use Node.js through its narrow host data; deployed
|
|
64
80
|
collection never receives ambient Worker bindings or raw configuration values.
|
|
65
81
|
|
|
66
82
|
Useful package checks:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DashboardOperationInput, DashboardOperationOutput, DashboardPluginApi } from "./contract.js";
|
|
2
|
+
|
|
3
|
+
//#region src/api/client.d.ts
|
|
4
|
+
type DashboardClientRequestOptions = Omit<RequestInit, "body" | "method">;
|
|
5
|
+
type DashboardClientOperation<Operation> = [DashboardOperationInput<Operation>] extends [undefined] ? (options?: DashboardClientRequestOptions) => Promise<DashboardOperationOutput<Operation>> : (input: DashboardOperationInput<Operation>, options?: DashboardClientRequestOptions) => Promise<DashboardOperationOutput<Operation>>;
|
|
6
|
+
type DashboardPluginClient<Api extends DashboardPluginApi> = {
|
|
7
|
+
readonly queries: { [Key in keyof Api["queries"]]: DashboardClientOperation<Api["queries"][Key]> };
|
|
8
|
+
readonly commands: { [Key in keyof Api["commands"]]: DashboardClientOperation<Api["commands"][Key]> };
|
|
9
|
+
};
|
|
10
|
+
/** Creates the typed client for one plugin without a browser registry or hand-built API URL. */
|
|
11
|
+
declare function createDashboardPluginClient<Api extends DashboardPluginApi>(api: Api, options?: {
|
|
12
|
+
baseURL?: string;
|
|
13
|
+
fetch?: typeof fetch;
|
|
14
|
+
}): DashboardPluginClient<Api>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { DashboardClientRequestOptions, DashboardPluginClient, createDashboardPluginClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{throwDashboardResponseError as e}from"./error-mapping.js";import{getDefaultPluginApiURL as t}from"./paths.js";import{createRouzerRoutes as n}from"./rouzer.js";import{createClient as r}from"rouzer";function i(i,o={}){return a(i,r({baseURL:o.baseURL??t(i.id),headers:{"content-type":`application/json`},onJsonError:e,routes:n(i),fetch:o.fetch}))}function a(e,t){let n=t;return{queries:Object.fromEntries(Object.entries(e.queries).map(([e,t])=>[e,t.input===void 0?t=>n.queries[e](void 0,t):(t,r)=>n.queries[e](t,r)])),commands:Object.fromEntries(Object.entries(e.commands).map(([e,t])=>[e,t.input===void 0?t=>n.commands[e](void 0,t):(t,r)=>n.commands[e](t,r)]))}}export{i as createDashboardPluginClient};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/api/contract.d.ts
|
|
4
|
+
type DashboardOperationKind = "query" | "command";
|
|
5
|
+
/** A named, typed read operation exposed by a dashboard plugin. */
|
|
6
|
+
interface DashboardQuery<Input = undefined, Output = unknown> {
|
|
7
|
+
readonly kind: "query";
|
|
8
|
+
readonly input?: z.ZodType<Input>;
|
|
9
|
+
readonly output?: z.ZodType<Output>;
|
|
10
|
+
}
|
|
11
|
+
/** A named, typed write operation exposed by a dashboard plugin. */
|
|
12
|
+
interface DashboardCommand<Input = undefined, Output = unknown> {
|
|
13
|
+
readonly kind: "command";
|
|
14
|
+
readonly input?: z.ZodType<Input>;
|
|
15
|
+
readonly output?: z.ZodType<Output>;
|
|
16
|
+
}
|
|
17
|
+
type DashboardQueryMap = Record<string, DashboardQuery<any, any>>;
|
|
18
|
+
type DashboardCommandMap = Record<string, DashboardCommand<any, any>>;
|
|
19
|
+
interface DashboardOperationDefinitionOptions<Input, Output> {
|
|
20
|
+
/** Optional Zod schema for query parameters or command JSON input. */
|
|
21
|
+
input?: z.ZodType<Input>;
|
|
22
|
+
/** Optional Zod schema used to validate the implementation result. */
|
|
23
|
+
output?: z.ZodType<Output>;
|
|
24
|
+
}
|
|
25
|
+
/** Defines a query descriptor without exposing Rouzer to plugin implementations. */
|
|
26
|
+
declare function defineDashboardQuery<Output = unknown>(options?: DashboardOperationDefinitionOptions<undefined, Output>): DashboardQuery<undefined, Output>;
|
|
27
|
+
declare function defineDashboardQuery<Input, Output>(options: DashboardOperationDefinitionOptions<Input, Output>): DashboardQuery<Input, Output>;
|
|
28
|
+
/** Defines a command descriptor without exposing Rouzer to plugin implementations. */
|
|
29
|
+
declare function defineDashboardCommand<Output = unknown>(options?: DashboardOperationDefinitionOptions<undefined, Output>): DashboardCommand<undefined, Output>;
|
|
30
|
+
declare function defineDashboardCommand<Input, Output>(options: DashboardOperationDefinitionOptions<Input, Output>): DashboardCommand<Input, Output>;
|
|
31
|
+
interface DashboardPluginApi<Id extends string = string, Queries extends DashboardQueryMap = DashboardQueryMap, Commands extends DashboardCommandMap = DashboardCommandMap> {
|
|
32
|
+
readonly id: Id;
|
|
33
|
+
readonly queries: Queries;
|
|
34
|
+
readonly commands: Commands;
|
|
35
|
+
}
|
|
36
|
+
/** Defines the operation contract shared by a plugin page and its runtime targets. */
|
|
37
|
+
declare function defineDashboardApi<const Id extends string, const Queries extends DashboardQueryMap, const Commands extends DashboardCommandMap>(api: {
|
|
38
|
+
id: Id;
|
|
39
|
+
queries: Queries;
|
|
40
|
+
commands: Commands;
|
|
41
|
+
}): DashboardPluginApi<Id, Queries, Commands>;
|
|
42
|
+
interface DashboardSuperuser {
|
|
43
|
+
readonly type: "superuser";
|
|
44
|
+
readonly id: "dashboard";
|
|
45
|
+
}
|
|
46
|
+
/** Request data deliberately made available to every plugin operation. */
|
|
47
|
+
interface DashboardRequestContext<HostData extends object> {
|
|
48
|
+
readonly actor: DashboardSuperuser;
|
|
49
|
+
readonly requestId: string;
|
|
50
|
+
readonly signal: AbortSignal;
|
|
51
|
+
readonly host: Readonly<HostData>;
|
|
52
|
+
}
|
|
53
|
+
/** Context available while a target implementation is initialized. */
|
|
54
|
+
interface DashboardInitializationContext<HostData extends object> {
|
|
55
|
+
readonly host: Readonly<HostData>;
|
|
56
|
+
readonly signal: AbortSignal;
|
|
57
|
+
}
|
|
58
|
+
type DashboardOperationInput<Operation> = Operation extends DashboardQuery<infer Input, any> ? Input : Operation extends DashboardCommand<infer Input, any> ? Input : never;
|
|
59
|
+
type DashboardOperationOutput<Operation> = Operation extends DashboardQuery<any, infer Output> ? Output : Operation extends DashboardCommand<any, infer Output> ? Output : never;
|
|
60
|
+
type OperationHandler<Operation, HostData extends object> = [DashboardOperationInput<Operation>] extends [undefined] ? (context: DashboardRequestContext<HostData>) => DashboardOperationOutput<Operation> | PromiseLike<DashboardOperationOutput<Operation>> : (context: DashboardRequestContext<HostData>, input: DashboardOperationInput<Operation>) => DashboardOperationOutput<Operation> | PromiseLike<DashboardOperationOutput<Operation>>;
|
|
61
|
+
type DashboardPluginImplementation<Api extends DashboardPluginApi, HostData extends object> = {
|
|
62
|
+
readonly queries: { [Key in keyof Api["queries"]]: OperationHandler<Api["queries"][Key], HostData> };
|
|
63
|
+
readonly commands: { [Key in keyof Api["commands"]]: OperationHandler<Api["commands"][Key], HostData> };
|
|
64
|
+
};
|
|
65
|
+
type DashboardPluginImplementationFactory<Api extends DashboardPluginApi, HostData extends object> = (context: DashboardInitializationContext<HostData>) => DashboardPluginImplementation<Api, HostData> | PromiseLike<DashboardPluginImplementation<Api, HostData>>;
|
|
66
|
+
/** Keeps implementation functions checked against the operation contract. */
|
|
67
|
+
declare function defineDashboardPluginImplementation<Api extends DashboardPluginApi, HostData extends object>(api: Api, implementation: DashboardPluginImplementation<Api, HostData>): DashboardPluginImplementation<Api, HostData>;
|
|
68
|
+
/** The generated runtime registration for one plugin operation contract. */
|
|
69
|
+
interface DashboardPluginRegistration<HostData extends object, Api extends DashboardPluginApi = DashboardPluginApi> {
|
|
70
|
+
readonly api: Api;
|
|
71
|
+
readonly createImplementation: DashboardPluginImplementationFactory<Api, HostData>;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { DashboardCommand, DashboardCommandMap, DashboardInitializationContext, DashboardOperationDefinitionOptions, DashboardOperationInput, DashboardOperationKind, DashboardOperationOutput, DashboardPluginApi, DashboardPluginImplementation, DashboardPluginImplementationFactory, DashboardPluginRegistration, DashboardQuery, DashboardQueryMap, DashboardRequestContext, DashboardSuperuser, defineDashboardApi, defineDashboardCommand, defineDashboardPluginImplementation, defineDashboardQuery };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{assertDashboardPluginApi as e,assertDashboardPluginImplementation as t}from"./validation.js";function n(e={}){return{kind:`query`,...e}}function r(e={}){return{kind:`command`,...e}}function i(t){return e(t),t}function a(e,n){return t(e,n),n}export{i as defineDashboardApi,r as defineDashboardCommand,a as defineDashboardPluginImplementation,n as defineDashboardQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DashboardOperationError as e}from"./errors.js";import{operationErrorStatus as t}from"./error-mapping.js";import{dashboardPluginApiPath as n}from"./paths.js";import{createRouzerRoutes as r}from"./rouzer.js";import{assertDashboardPluginApi as i,assertDashboardPluginImplementation as a}from"./validation.js";import{createRouter as o,toFetchHandler as s}from"rouzer";function c(e,t){let n=new Map;for(let r of e){i(r.api);let e=r.api.id;if(n.has(e))throw Error(`Duplicate dashboard plugin id "${e}".`);n.set(e,l(r,t))}return async(e,t)=>{let r=m(new URL(e.url).pathname),i=r?n.get(r):void 0;return i?i.handle(e,t):h({error:{code:`not_found`}},404)}}function l(i,c){let l,d=new WeakMap,p=(e,t)=>{let n=d.get(e);if(n)return n;let r=t??c.host;if(!r)throw Error(`Dashboard plugin "${i.api.id}" is missing host data.`);let a=f(e,r,c.getRequestId);return d.set(e,a),a},m=e=>{let t=l??=Promise.resolve(i.createImplementation({host:e.host,signal:e.signal})).then(e=>{a(i.api,e);let t=s(o({basePath:`${n}/${i.api.id}/`}).use(r(i.api),u(i.api,e,p)));return async e=>t(e)});return t.catch(e=>{throw l===t&&(l=void 0),new g(e)})};return{async handle(n,r){try{let e=p(n,r),t=await(await m(e))(n);return t.status===400?h({error:{code:`invalid_input`}},400):t}catch(n){return n instanceof e?h({error:{code:n.code}},t(n.code)):(c.onError?.(i.api.id,_(n)),n instanceof g?h({error:{code:`unavailable`}},503):h({error:{code:`internal`}},500))}}}}function u(e,t,n){return{queries:Object.fromEntries(Object.entries(e.queries).map(([e,r])=>[e,i=>d(r,t.queries[e],n(i.request),i.query)])),commands:Object.fromEntries(Object.entries(e.commands).map(([e,r])=>[e,i=>d(r,t.commands[e],n(i.request),i.body)]))}}async function d(e,t,n,r){let i=e.input===void 0?await t(n):await t(n,r);return e.output?e.output.parse(i):i}function f(e,t,n){let r=n?.(e)?.trim()??e.headers.get(`x-request-id`)?.trim();return{actor:p,requestId:r&&r.length<=128?r:crypto.randomUUID(),signal:e.signal,host:t}}const p=Object.freeze({type:`superuser`,id:`dashboard`});function m(e){if(!e.startsWith(`/__dashboard/api/plugins/`))return;let t=e.slice(n.length+1),r=t.indexOf(`/`);return r>0?t.slice(0,r):void 0}function h(e,t){return Response.json(e,{headers:{"cache-control":`no-store`},status:t})}var g=class extends Error{cause;constructor(e){super(`Dashboard plugin initialization failed.`),this.name=`DashboardPluginInitializationError`,this.cause=e}};function _(e){return e instanceof g?e.cause:e}export{c as createDashboardPluginDispatcher};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DashboardOperationError as e,isDashboardOperationErrorBody as t}from"./errors.js";async function n(n){let r=n.status===400?`invalid_input`:`internal`;if(n.headers.get(`content-type`)?.includes(`application/json`)){let e=await n.json().catch(()=>void 0),i=e&&typeof e==`object`&&`error`in e?e.error:void 0;t(i)&&(r=i.code)}throw new e(r)}function r(e){switch(e){case`invalid_input`:return 400;case`not_found`:return 404;case`conflict`:return 409;case`unavailable`:return 503;case`internal`:return 500}}export{r as operationErrorStatus,n as throwDashboardResponseError};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/api/errors.d.ts
|
|
2
|
+
type DashboardOperationErrorCode = "invalid_input" | "not_found" | "conflict" | "unavailable" | "internal";
|
|
3
|
+
interface DashboardOperationErrorBody {
|
|
4
|
+
readonly code: DashboardOperationErrorCode;
|
|
5
|
+
}
|
|
6
|
+
/** A safe, typed failure that a plugin operation may deliberately return to its caller. */
|
|
7
|
+
declare class DashboardOperationError extends Error {
|
|
8
|
+
readonly code: DashboardOperationErrorCode;
|
|
9
|
+
constructor(code: DashboardOperationErrorCode);
|
|
10
|
+
}
|
|
11
|
+
declare function dashboardOperationError(code: DashboardOperationErrorCode): DashboardOperationError;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { DashboardOperationError, DashboardOperationErrorBody, DashboardOperationErrorCode, dashboardOperationError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={invalid_input:`The dashboard request was invalid.`,not_found:`The requested dashboard resource was not found.`,conflict:`The dashboard operation could not be completed.`,unavailable:`The dashboard operation is temporarily unavailable.`,internal:`The dashboard operation failed.`};var t=class extends Error{code;constructor(t){super(e[t]),this.name=`DashboardOperationError`,this.code=t}};function n(e){return new t(e)}function r(t){return typeof t==`object`&&!!t&&`code`in t&&typeof t.code==`string`&&t.code in e}export{t as DashboardOperationError,n as dashboardOperationError,r as isDashboardOperationErrorBody};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`/__dashboard/api/plugins`;function t(t){let n=globalThis.location===void 0?void 0:globalThis.location.origin;if(!n)throw Error(`A dashboard API baseURL is required outside a browser.`);return new URL(`${e}/${t}/`,n).href}export{e as dashboardPluginApiPath,t as getDefaultPluginApiURL};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$type as e}from"rouzer";import*as t from"rouzer/http";function n(e){let n=Object.fromEntries(Object.entries(e.queries).map(([e,t])=>[e,r(`query`,e,t)])),i=Object.fromEntries(Object.entries(e.commands).map(([e,t])=>[e,r(`command`,e,t)]));return{queries:t.resource(`queries`,n),commands:t.resource(`commands`,i)}}function r(n,r,i){let a=i.input?n===`query`?{query:i.input,response:e()}:{body:i.input,response:e()}:{response:e()};return n===`query`?t.get(r,a):t.post(r,a)}export{n as createRouzerRoutes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,t=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u;function n(e){if(!e||typeof e!=`object`)throw Error(`Dashboard plugin API is missing.`);let t=e;s(t.id??``),a(t.queries,`queries`,`query`),a(t.commands,`commands`,`command`)}function r(e,t){if(!t||typeof t!=`object`)throw Error(`Dashboard plugin "${e.id}" did not create an implementation.`);let n=t;i(e.queries,n.queries,`queries`,e.id),i(e.commands,n.commands,`commands`,e.id)}function i(e,t,n,r){if(!t||typeof t!=`object`)throw Error(`Dashboard plugin "${r}" is missing ${n} implementations.`);let i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length||i.some(e=>typeof t[e]!=`function`)||a.some(t=>!e[t]))throw Error(`Dashboard plugin "${r}" has an invalid ${n} implementation map.`)}function a(e,t,n){if(!e||typeof e!=`object`)throw Error(`Dashboard plugin API is missing ${t}.`);for(let[r,i]of Object.entries(e)){if(!i||typeof i!=`object`||i.kind!==n)throw Error(`Dashboard ${t} operation "${r}" has the wrong kind.`);o(r)}}function o(e){if(!t.test(e))throw Error(`Dashboard operation name "${e}" must start with a letter or number and contain only letters, numbers, underscores, and hyphens.`)}function s(t){if(!e.test(t))throw Error(`Dashboard plugin id "${t}" must contain only lowercase letters, numbers, and single hyphens.`)}export{n as assertDashboardPluginApi,r as assertDashboardPluginImplementation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{composeDashboardManifest as e,composeDashboardRoutes as t,discoverDashboardPages as n,resolveDashboardRouteModules as r}from"../build.js";import{join as i,resolve as a}from"node:path";import{
|
|
1
|
+
import{composeDashboardManifest as e,composeDashboardRoutes as t,discoverDashboardPages as n,resolveDashboardRouteModules as r}from"../build.js";import{join as i,resolve as a}from"node:path";import{pathToFileURL as o}from"node:url";const s=process.cwd(),c=a(s,`..`),l=r(e((await import(o(i(s,`dashboard.config.ts`)).href)).default,await n({dashboardDirectory:s}),{environment:process.env.DEPLOY_ENV?`deployed`:`local`}),{dashboardDirectory:s,projectRoot:c}),u=e=>`./${e}.js`;var d=t(l,{shellRoute:u(`shell`),indexRoute:u(`index-route`),emptyRoute:u(`empty`),notFoundRoute:u(`not-found`)});export{d as default};
|
package/dist/package/build.d.ts
CHANGED
|
@@ -32,28 +32,23 @@ interface DashboardRouteConfigEntry {
|
|
|
32
32
|
file: string;
|
|
33
33
|
children?: DashboardRouteConfigEntry[];
|
|
34
34
|
}
|
|
35
|
-
type
|
|
36
|
-
interface
|
|
35
|
+
type DashboardPluginTarget = "local" | "deployed";
|
|
36
|
+
interface DashboardPluginTargetEntry {
|
|
37
37
|
pluginId: string;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
interface DashboardRuntimeApiRegistryEntry extends DashboardBrowserApiRegistryEntry {
|
|
41
|
-
handlersModule: string;
|
|
42
|
-
capabilityModule: string;
|
|
43
|
-
}
|
|
44
|
-
interface DashboardApiRegistries {
|
|
45
|
-
browser: DashboardBrowserApiRegistryEntry[];
|
|
46
|
-
local: DashboardRuntimeApiRegistryEntry[];
|
|
47
|
-
worker: DashboardRuntimeApiRegistryEntry[];
|
|
38
|
+
apiModule: string;
|
|
39
|
+
implementationModule: string;
|
|
48
40
|
}
|
|
49
41
|
/** Discovers immediate `pages/<slug>/route.tsx` app contributions. */
|
|
50
42
|
declare function discoverDashboardPages(options?: DiscoverDashboardPagesOptions): Promise<DashboardPageContribution[]>;
|
|
51
|
-
/** Normalizes plugin and app contributions into deterministic navigation order. */
|
|
43
|
+
/** Normalizes plugin root navigation and app contributions into deterministic navigation order. */
|
|
52
44
|
declare function composeDashboardManifest(config: DashboardConfig, appPages: readonly DashboardPageContribution[], options?: ComposeDashboardManifestOptions): DashboardPageManifestEntry[];
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Selects the package-owned implementation module for one runtime target. The browser never
|
|
47
|
+
* receives this list: browser pages import their own operation contract directly.
|
|
48
|
+
*/
|
|
49
|
+
declare function composeDashboardPluginTarget(config: DashboardConfig, target: DashboardPluginTarget): DashboardPluginTargetEntry[];
|
|
50
|
+
/** Renders a virtual module for exactly one runtime target. */
|
|
51
|
+
declare function renderDashboardPluginTargetModule(entries: readonly DashboardPluginTargetEntry[]): string;
|
|
57
52
|
/**
|
|
58
53
|
* Creates ordinary React Router framework-mode route config for an app-owned dashboard. All file
|
|
59
54
|
* references remain app-controlled route modules.
|
|
@@ -68,4 +63,4 @@ declare class DashboardCompositionError extends Error {
|
|
|
68
63
|
constructor(file: string, message: string, cause?: unknown);
|
|
69
64
|
}
|
|
70
65
|
//#endregion
|
|
71
|
-
export { ComposeDashboardManifestOptions,
|
|
66
|
+
export { ComposeDashboardManifestOptions, DashboardCompositionError, type DashboardPageManifestEntry, DashboardPluginTarget, DashboardPluginTargetEntry, DashboardRouteCompositionOptions, DashboardRouteConfigEntry, DiscoverDashboardPagesOptions, ResolveDashboardRouteModulesOptions, composeDashboardManifest, composeDashboardPluginTarget, composeDashboardRoutes, discoverDashboardPages, renderDashboardPluginTargetModule, resolveDashboardModuleReference, resolveDashboardRouteModules };
|
package/dist/package/build.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)}\n\nexport const
|
|
3
|
-
`)}\n]\n`}function
|
|
1
|
+
import{getDashboardPluginBuild as e}from"./config.js";import{createRequire as t}from"node:module";import{readFile as n,readdir as r}from"node:fs/promises";import{isAbsolute as i,join as a,resolve as o}from"node:path";import{parseDocument as s}from"yaml";import{z as c}from"zod";const l=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u,u=c.object({title:c.string().trim().min(1,`title must not be empty`).optional(),description:c.string().trim().min(1,`description must not be empty`).optional()}).strict(),d=c.object({id:c.string(),path:c.string(),title:c.string(),description:c.string().optional(),routeModule:c.string(),environments:c.array(c.enum([`local`,`deployed`])).optional()}).strict(),f=c.string().trim().min(1,`module reference must not be empty`),p=c.object({path:c.string(),title:c.string(),description:c.string().optional(),environments:c.array(c.enum([`local`,`deployed`])).optional()}).strict(),m=c.object({document:f.optional(),plugins:c.array(c.object({id:c.string(),navigation:p,pageModule:f,api:c.unknown().optional()}).strict()).optional()}).strict();async function h(e={}){let t=a(o(e.dashboardDirectory??a(process.cwd(),`dashboard`)),`pages`),i;try{i=await r(t,{withFileTypes:!0})}catch(e){if(N(e)&&e.code===`ENOENT`)return[];throw new S(t,`could not read the pages directory`,e)}let s=i.filter(e=>e.isDirectory()&&!e.name.startsWith(`.`)).sort((e,t)=>M(e.name,t.name));return Promise.all(s.map(async({name:e})=>{let r=a(t,e);A(e,r,`page directory`);let i=a(r,`route.tsx`);try{await n(i)}catch(e){throw N(e)&&e.code===`ENOENT`?new S(i,`missing required React Router route.tsx`):new S(i,`could not read route.tsx`,e)}let o=await C(a(r,`page.yaml`));return{id:e,path:e,title:o?.title??j(e),...o?.description?{description:o.description}:{},routeModule:`pages/${e}/route.tsx`}}))}function g(e,t,n={}){let r=n.environment??`local`,i=new Set,a=[],o=O(e);for(let e of o.plugins??[]){if(A(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),i.has(e.id))throw new S(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);i.add(e.id);let t=T(e,`plugin`,r);t&&a.push(t)}let s=t.map(e=>({page:e,normalizedPage:w(e,`app`)})).sort((e,t)=>M(e.normalizedPage.path,t.normalizedPage.path));for(let{page:e,normalizedPage:t}of s)D(e,r)&&a.push(t);return E(a),a}function _(e,t){let n=O(e),r=new Set,i=[];for(let e of n.plugins??[]){if(A(e.id,`dashboard.config.ts plugin "${e.id}"`,`plugin id`),r.has(e.id))throw new S(`dashboard.config.ts`,`duplicate plugin id "${e.id}"`);if(r.add(e.id),!e.api)continue;let n=k(e,`dashboard API`),a=t===`local`?n.localImplementationModule:n.deployedImplementationModule;a&&i.push({pluginId:e.id,apiModule:n.apiModule,implementationModule:a})}return i}function v(e){let t=[],n=[];for(let[r,i]of e.entries())t.push(`import { api as api${r} } from ${JSON.stringify(i.apiModule)}`,`import { createImplementation as createImplementation${r} } from ${JSON.stringify(i.implementationModule)}`),n.push(`{ api: api${r}, createImplementation: createImplementation${r} }`);return`${t.join(`
|
|
2
|
+
`)}\n\nexport const dashboardPlugins = [\n${n.map(e=>` ${e},`).join(`
|
|
3
|
+
`)}\n]\n`}function y(e,t){let n=[e.length>0?{index:!0,file:t.indexRoute}:{index:!0,file:t.emptyRoute},...e.map(e=>({id:`dashboard-page-${e.id}`,path:e.path,file:e.routeModule})),...t.notFoundRoute?[{path:`*`,file:t.notFoundRoute}]:[]];return[{id:`dashboard-shell`,file:t.shellRoute,children:n}]}function b(e,t={}){let n=o(t.dashboardDirectory??a(process.cwd(),`dashboard`));return e.map(e=>({...e,routeModule:e.source===`app`?o(n,e.routeModule):x(e.routeModule,t)}))}function x(e,n={}){let r=o(n.dashboardDirectory??a(process.cwd(),`dashboard`)),s=t(a(o(n.projectRoot??a(r,`..`)),`package.json`));if(i(e)||e.startsWith(`.`))return o(r,e);try{return s.resolve(e)}catch(t){throw new S(e,`could not resolve dashboard module`,t)}}var S=class extends Error{file;constructor(e,t,n){super(`${e}: ${t}`,{cause:n}),this.name=`DashboardCompositionError`,this.file=e}};async function C(e){let t;try{t=await n(e,`utf8`)}catch(t){if(N(t)&&t.code===`ENOENT`)return;throw new S(e,`could not read page metadata`,t)}let r=s(t,{prettyErrors:!0,strict:!0,uniqueKeys:!0});if(r.errors.length>0)throw new S(e,r.errors[0]?.message??`invalid YAML`);let i=u.safeParse(r.toJS());if(!i.success)throw new S(e,c.prettifyError(i.error));return i.data}function w(e,t,n){let r=t===`plugin`?`dashboard.config.ts plugin "${n??`unknown`}" page "${e.id}"`:e.routeModule,i=d.safeParse(e);if(!i.success)throw new S(r,c.prettifyError(i.error));let a=i.data;A(a.id,r,`page id`),A(a.path,r,`page path`);let o=a.title.trim();if(!o)throw new S(r,`page title must not be empty`);if(!a.routeModule.trim())throw new S(r,`page routeModule must not be empty`);let s=a.description?.trim();if(a.description!==void 0&&!s)throw new S(r,`page description must not be empty`);return{id:a.id,path:a.path,title:o,...s?{description:s}:{},routeModule:a.routeModule,source:t,...n?{pluginId:n}:{}}}function T(e,t,n){let r=`dashboard.config.ts plugin "${e.id}"`,i=p.safeParse(e.navigation);if(!i.success)throw new S(r,c.prettifyError(i.error));let a=i.data;if(A(e.id,r,`plugin id`),A(a.path,r,`navigation path`),!a.title.trim())throw new S(r,`navigation title must not be empty`);if(a.description!==void 0&&!a.description.trim())throw new S(r,`navigation description must not be empty`);if(!e.pageModule.trim())throw new S(r,`pageModule must not be empty`);if(!(a.environments&&!a.environments.includes(n))){if(e.api){let t=k(e,`dashboard API`);if(n===`local`&&!t.localImplementationModule||n===`deployed`&&!t.deployedImplementationModule)return}return w({id:e.id,path:a.path,title:a.title,...a.description?{description:a.description}:{},routeModule:e.pageModule,...a.environments?{environments:a.environments}:{}},t,e.id)}}function E(e){let t=new Map,n=new Map;for(let r of e){let e=t.get(r.id);if(e)throw new S(r.routeModule,`duplicate page id "${r.id}" also contributed by ${e.routeModule}`);t.set(r.id,r);let i=n.get(r.path);if(i)throw new S(r.routeModule,`duplicate page path "${r.path}" also contributed by ${i.routeModule}`);n.set(r.path,r)}}function D(e,t){return e.environments?e.environments.includes(t):!0}function O(e){let t=m.safeParse(e);if(!t.success)throw new S(`dashboard.config.ts`,c.prettifyError(t.error));return e}function k(t,n){let r=e(t);if(!r)throw new S(`dashboard.config.ts plugin "${t.id}"`,`${n} is missing its package-owned build descriptor`);if(t.api&&t.api.id!==t.id)throw new S(`dashboard.config.ts plugin "${t.id}"`,`API id "${t.api.id}" does not match the plugin id`);for(let e of[`apiModule`,`localImplementationModule`]){let n=r[e];if(typeof n!=`string`||!n.trim())throw new S(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "${e}" must be a non-empty module reference`)}if(r.deployedImplementationModule!==void 0&&(typeof r.deployedImplementationModule!=`string`||!r.deployedImplementationModule.trim()))throw new S(`dashboard.config.ts plugin "${t.id}"`,`build descriptor field "deployedImplementationModule" must be a non-empty module reference`);return r}function A(e,t,n){if(!l.test(e))throw new S(t,`${n} "${e}" must contain only lowercase letters, numbers, and single hyphens`)}function j(e){let t=e.split(`-`).join(` `);return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function M(e,t){return e<t?-1:+(e>t)}function N(e){return e instanceof Error&&`code`in e}export{S as DashboardCompositionError,g as composeDashboardManifest,_ as composeDashboardPluginTarget,y as composeDashboardRoutes,h as discoverDashboardPages,v as renderDashboardPluginTargetModule,x as resolveDashboardModuleReference,b as resolveDashboardRouteModules};
|
package/dist/package/config.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DashboardPluginApi } from "./api/contract.js";
|
|
2
|
+
|
|
1
3
|
//#region src/config.d.ts
|
|
2
4
|
type DashboardEnvironment = "local" | "deployed";
|
|
3
5
|
interface DashboardPageContribution {
|
|
@@ -12,22 +14,37 @@ interface DashboardPageContribution {
|
|
|
12
14
|
/** Environments where the page can be included. Defaults to both. */
|
|
13
15
|
environments?: readonly DashboardEnvironment[];
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
/** The one root navigation item contributed by a dashboard plugin. */
|
|
18
|
+
interface DashboardPluginNavigation {
|
|
19
|
+
/** Top-level URL segment below `/__dashboard/`. */
|
|
20
|
+
path: string;
|
|
21
|
+
title: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
/** Environments where the feature is available. Defaults to both. */
|
|
24
|
+
environments?: readonly DashboardEnvironment[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build-only module references owned by a plugin package. This descriptor is attached to a plugin
|
|
28
|
+
* as a non-enumerable symbol so application configuration contains one feature descriptor rather
|
|
29
|
+
* than a public list of target-specific module paths.
|
|
30
|
+
*/
|
|
31
|
+
interface DashboardPluginBuild {
|
|
32
|
+
/** Module exporting the plugin's operation contract as `api`. */
|
|
33
|
+
apiModule: string;
|
|
34
|
+
/** Module exporting the local implementation factory as `createImplementation`. */
|
|
35
|
+
localImplementationModule: string;
|
|
36
|
+
/** Optional Worker implementation factory. Omit to make the plugin local-only. */
|
|
37
|
+
deployedImplementationModule?: string;
|
|
24
38
|
}
|
|
25
39
|
interface DashboardPlugin {
|
|
26
40
|
/** Stable plugin identity. It must be a lowercase, URL-safe slug. */
|
|
27
41
|
id: string;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
/** Exactly one root navigation entry for the feature. */
|
|
43
|
+
navigation: DashboardPluginNavigation;
|
|
44
|
+
/** Browser page module. Nested feature pages belong inside this module. */
|
|
45
|
+
pageModule: string;
|
|
46
|
+
/** Optional operation contract shared by the browser and runtime targets. */
|
|
47
|
+
api?: DashboardPluginApi;
|
|
31
48
|
}
|
|
32
49
|
interface DashboardConfig {
|
|
33
50
|
plugins?: readonly DashboardPlugin[];
|
|
@@ -46,7 +63,13 @@ interface DashboardPageManifestEntry {
|
|
|
46
63
|
}
|
|
47
64
|
/** Defines trusted dashboard composition evaluated by Coreframe at development and build time. */
|
|
48
65
|
declare function defineDashboardConfig<const Config extends DashboardConfig>(config: Config): Config;
|
|
49
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Defines a reusable dashboard feature. The optional build descriptor is package-owned and is not
|
|
68
|
+
* enumerable from application configuration, while Vite can still select one target at a time.
|
|
69
|
+
*/
|
|
70
|
+
declare function defineDashboardPlugin<const Plugin extends DashboardPlugin, const Build extends DashboardPluginBuild>(plugin: Plugin, build: Build): Plugin;
|
|
50
71
|
declare function defineDashboardPlugin<const Plugin extends DashboardPlugin>(plugin: Plugin): Plugin;
|
|
72
|
+
/** @internal Used by the dashboard build composer to read package-owned target metadata. */
|
|
73
|
+
declare function getDashboardPluginBuild(plugin: DashboardPlugin): DashboardPluginBuild | undefined;
|
|
51
74
|
//#endregion
|
|
52
|
-
export { DashboardConfig, DashboardEnvironment, DashboardPageContribution, DashboardPageManifestEntry, DashboardPlugin,
|
|
75
|
+
export { DashboardConfig, DashboardEnvironment, DashboardPageContribution, DashboardPageManifestEntry, DashboardPlugin, DashboardPluginBuild, DashboardPluginNavigation, defineDashboardConfig, defineDashboardPlugin, getDashboardPluginBuild };
|
package/dist/package/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=Symbol.for(`coreframe.dashboard.plugin-build`);function t(e){return e}function n(t,n){return n&&Object.defineProperty(t,e,{configurable:!1,enumerable:!1,value:Object.freeze({...n}),writable:!1}),t}function r(t){return t[e]}export{t as defineDashboardConfig,n as defineDashboardPlugin,r as getDashboardPluginBuild};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DashboardRequestError as e}from"./request-error.js";function t(e){return e.headers.get(`x-request-id`)?.trim()||crypto.randomUUID()}function n(e,t,n){return e===`GET`||e===`HEAD`?!0:t!=null&&t===n}function r(t){let n=t.headers.host;if(!n)throw new e(`Dashboard request host is missing.`,403);let r;try{r=new URL(`http://${n}`).hostname}catch{throw new e(`Dashboard request host was not authorized.`,403)}if(r!==`127.0.0.1`&&r!==`::1`&&r!==`localhost`&&!r.endsWith(`.localhost`))throw new e(`Dashboard request host was not authorized.`,403)}function i(t,r){if(!n(t.method??``,t.headers.origin,r.origin))throw new e(`Dashboard mutation origin was not authorized.`,403)}export{i as assertDashboardApiRequestOrigin,r as assertLocalDashboardHost,t as getDashboardRequestId,n as isSameOriginDashboardMutation};
|
package/dist/package/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DashboardPayload, DashboardReleaseIdentity, DeployedDashboardPayload } from "./types.js";
|
|
2
1
|
import { DashboardRequestHandler, DashboardServerOptions, createDashboardRequestHandler, createDashboardServer } from "./server.js";
|
|
2
|
+
import { DashboardPayload, DashboardReleaseIdentity, DeployedDashboardPayload } from "./types.js";
|
|
3
3
|
export { type DashboardPayload, type DashboardReleaseIdentity, type DashboardRequestHandler, type DashboardServerOptions, type DeployedDashboardPayload, createDashboardRequestHandler, createDashboardServer };
|
|
@@ -1,59 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
//#region src/plugin-api.d.ts
|
|
6
|
-
interface DashboardLocalCapabilityContext {
|
|
7
|
-
/** Root of the application the local dashboard is inspecting. */
|
|
8
|
-
projectRoot: string;
|
|
9
|
-
}
|
|
10
|
-
interface DashboardWorkerCapabilityContext {
|
|
11
|
-
/** Deployment tier selected by the Coreframe Worker host. */
|
|
12
|
-
environment: "production" | "staging";
|
|
13
|
-
/** Release identity deliberately derived by the authenticated dashboard host. */
|
|
14
|
-
release: DashboardReleaseIdentity;
|
|
15
|
-
/** Configuration names and presence only; never raw binding values. */
|
|
16
|
-
configuration: readonly DeployedConfigurationEntry[];
|
|
17
|
-
/** Non-secret links deliberately derived by the dashboard host. */
|
|
18
|
-
links: readonly DashboardLink[];
|
|
19
|
-
}
|
|
20
|
-
type DashboardPluginCapabilityFactory<Context, Capability> = (context: Readonly<Context>) => Capability | Promise<Capability>;
|
|
21
|
-
type DashboardPluginApiHandlersFactory<Routes extends HttpRouteTree, Capability> = (capability: Capability) => RouteRequestHandlerMap<Routes, Router>;
|
|
22
|
-
interface DashboardPluginApiRegistration<Context = unknown> {
|
|
23
|
-
pluginId: string;
|
|
24
|
-
routes: HttpRouteTree;
|
|
25
|
-
createHandlers: (capability: never) => RouteRequestHandlerMap<HttpRouteTree, Router>;
|
|
26
|
-
createCapability: DashboardPluginCapabilityFactory<Context, unknown>;
|
|
27
|
-
}
|
|
28
|
-
interface DashboardPluginApiHandlerOptions<Context> {
|
|
29
|
-
context: Readonly<Context>;
|
|
30
|
-
onError?: (pluginId: string, error: unknown) => void;
|
|
31
|
-
}
|
|
32
|
-
/** Preserves Rouzer handler-map inference while injecting one narrow capability object. */
|
|
33
|
-
declare function defineDashboardPluginApiHandlers<const Routes extends HttpRouteTree, Capability>(createHandlers: DashboardPluginApiHandlersFactory<Routes, Capability>): DashboardPluginApiHandlersFactory<Routes, Capability>;
|
|
34
|
-
/** Defines a target-specific capability factory without widening its host context. */
|
|
35
|
-
declare function defineDashboardPluginCapability<Context, Capability>(createCapability: DashboardPluginCapabilityFactory<Context, Capability>): DashboardPluginCapabilityFactory<Context, Capability>;
|
|
36
|
-
/** Creates the normal typed Rouzer browser client for one namespaced plugin route tree. */
|
|
37
|
-
declare function createDashboardPluginApiClient<const Routes extends HttpRouteTree>(options: {
|
|
38
|
-
pluginId: string;
|
|
39
|
-
routes: Routes;
|
|
40
|
-
baseURL?: string;
|
|
41
|
-
fetch?: typeof fetch;
|
|
42
|
-
}): import("rouzer").ClientTree<Routes, ""> & {
|
|
43
|
-
clientConfig: {
|
|
44
|
-
baseURL: string;
|
|
45
|
-
headers?: Record<string, string>;
|
|
46
|
-
routes: Routes;
|
|
47
|
-
plugins?: readonly import("rouzer").ClientResponsePlugin[];
|
|
48
|
-
onJsonError?: (response: Response) => unknown;
|
|
49
|
-
fetch?: typeof globalThis.fetch;
|
|
50
|
-
clientHook?: import("rouzer").RouzerClientHook;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Composes target-loaded plugin registrations behind one read-only Fetch boundary. Authentication
|
|
55
|
-
* remains the responsibility of the local or Worker host that invokes this handler.
|
|
56
|
-
*/
|
|
57
|
-
declare function createDashboardPluginApiFetchHandler<Context>(registrations: readonly DashboardPluginApiRegistration<Context>[], options: DashboardPluginApiHandlerOptions<Context>): (request: Request) => Promise<Response>;
|
|
58
|
-
//#endregion
|
|
59
|
-
export { DashboardLocalCapabilityContext, DashboardPluginApiHandlerOptions, DashboardPluginApiHandlersFactory, DashboardPluginApiRegistration, DashboardPluginCapabilityFactory, DashboardWorkerCapabilityContext, createDashboardPluginApiClient, createDashboardPluginApiFetchHandler, defineDashboardPluginApiHandlers, defineDashboardPluginCapability };
|
|
1
|
+
import { DashboardCommand, DashboardCommandMap, DashboardInitializationContext, DashboardOperationDefinitionOptions, DashboardOperationInput, DashboardOperationKind, DashboardOperationOutput, DashboardPluginApi, DashboardPluginImplementation, DashboardPluginImplementationFactory, DashboardPluginRegistration, DashboardQuery, DashboardQueryMap, DashboardRequestContext, DashboardSuperuser, defineDashboardApi, defineDashboardCommand, defineDashboardPluginImplementation, defineDashboardQuery } from "./api/contract.js";
|
|
2
|
+
import { DashboardClientRequestOptions, DashboardPluginClient, createDashboardPluginClient } from "./api/client.js";
|
|
3
|
+
import { DashboardOperationError, DashboardOperationErrorBody, DashboardOperationErrorCode, dashboardOperationError } from "./api/errors.js";
|
|
4
|
+
export { DashboardClientRequestOptions, DashboardCommand, DashboardCommandMap, DashboardInitializationContext, DashboardOperationDefinitionOptions, DashboardOperationError, type DashboardOperationErrorBody, type DashboardOperationErrorCode, DashboardOperationInput, DashboardOperationKind, DashboardOperationOutput, DashboardPluginApi, DashboardPluginClient, DashboardPluginImplementation, DashboardPluginImplementationFactory, DashboardPluginRegistration, DashboardQuery, DashboardQueryMap, DashboardRequestContext, DashboardSuperuser, createDashboardPluginClient, dashboardOperationError, defineDashboardApi, defineDashboardCommand, defineDashboardPluginImplementation, defineDashboardQuery };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{DashboardOperationError as e,dashboardOperationError as t}from"./api/errors.js";import{defineDashboardApi as n,defineDashboardCommand as r,defineDashboardPluginImplementation as i,defineDashboardQuery as a}from"./api/contract.js";import{createDashboardPluginClient as o}from"./api/client.js";export{e as DashboardOperationError,o as createDashboardPluginClient,t as dashboardOperationError,n as defineDashboardApi,r as defineDashboardCommand,i as defineDashboardPluginImplementation,a as defineDashboardQuery};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DashboardPluginApi, DashboardQuery } from "../../../api/contract.js";
|
|
2
|
+
import { DashboardPayload } from "../../../types.js";
|
|
3
|
+
//#region src/plugins/diagnostics/api/contract.d.ts
|
|
4
|
+
/** The typed operation contract shared by the diagnostics page and runtime targets. */
|
|
5
|
+
declare const diagnosticsApi: DashboardPluginApi<"diagnostics", {
|
|
6
|
+
readonly overview: DashboardQuery<undefined, DashboardPayload>;
|
|
7
|
+
}, {}>;
|
|
8
|
+
declare const api: DashboardPluginApi<"diagnostics", {
|
|
9
|
+
readonly overview: DashboardQuery<undefined, DashboardPayload>;
|
|
10
|
+
}, {}>;
|
|
11
|
+
type DiagnosticsApi = typeof diagnosticsApi;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { DiagnosticsApi, api, diagnosticsApi };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineDashboardApi as e,defineDashboardQuery as t}from"../../../api/contract.js";import{z as n}from"zod";const r=e({id:`diagnostics`,queries:{overview:t({output:n.custom()})},commands:{}}),i=r;export{i as api,r as diagnosticsApi};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DashboardInitializationContext, DashboardPluginImplementation } from "../../../api/contract.js";
|
|
2
|
+
import { DashboardLocalHostData } from "../../../server.js";
|
|
3
|
+
import { DiagnosticsApi } from "./contract.js";
|
|
3
4
|
|
|
4
5
|
//#region src/plugins/diagnostics/api/local.d.ts
|
|
5
|
-
declare function
|
|
6
|
+
declare function createImplementation({
|
|
7
|
+
host
|
|
8
|
+
}: DashboardInitializationContext<DashboardLocalHostData>): DashboardPluginImplementation<DiagnosticsApi, DashboardLocalHostData>;
|
|
6
9
|
//#endregion
|
|
7
|
-
export {
|
|
10
|
+
export { createImplementation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{defineDashboardPluginImplementation as e}from"../../../api/contract.js";import{diagnosticsApi as t}from"./contract.js";import{inspectWorkerEnvironment as n}from"@coreframe/deploy";import{runDiagnostics as r}from"@coreframe/diagnostics";function i({host:i}){return e(t,{queries:{async overview(){let[e,t]=await Promise.all([r({projectRoot:i.projectRoot,environment:`development`,env:process.env}),n({cwd:i.projectRoot})]);return{mode:`local`,diagnostics:e,workerEnvironment:t}}},commands:{}})}export{i as createImplementation};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DashboardInitializationContext, DashboardPluginImplementation } from "../../../api/contract.js";
|
|
2
|
+
import { DiagnosticsApi } from "./contract.js";
|
|
3
|
+
import { DashboardWorkerHostData } from "../../../worker.js";
|
|
3
4
|
|
|
4
5
|
//#region src/plugins/diagnostics/api/worker.d.ts
|
|
5
|
-
declare function
|
|
6
|
+
declare function createImplementation(_context: DashboardInitializationContext<DashboardWorkerHostData>): DashboardPluginImplementation<DiagnosticsApi, DashboardWorkerHostData>;
|
|
6
7
|
//#endregion
|
|
7
|
-
export {
|
|
8
|
+
export { createImplementation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{defineDashboardPluginImplementation as e}from"../../../api/contract.js";import{diagnosticsApi as t}from"./contract.js";function n(n){return e(t,{queries:{overview({host:e}){return{mode:`deployed`,environment:e.environment,release:e.release,configuration:[...e.configuration],links:[...e.links]}}},commands:{}})}export{n as createImplementation};
|
|
@@ -1,36 +1,30 @@
|
|
|
1
|
+
import { DashboardPluginApi, DashboardQuery } from "../../api/contract.js";
|
|
2
|
+
import { DashboardPayload } from "../../types.js";
|
|
1
3
|
//#region src/plugins/diagnostics/index.d.ts
|
|
2
4
|
declare const diagnosticsPlugin: {
|
|
3
5
|
readonly id: "diagnostics";
|
|
4
|
-
readonly
|
|
5
|
-
readonly id: "diagnostics";
|
|
6
|
+
readonly navigation: {
|
|
6
7
|
readonly path: "diagnostics";
|
|
7
8
|
readonly title: "Production readiness";
|
|
8
9
|
readonly description: "Review launch readiness, deployment configuration, and project health.";
|
|
9
|
-
readonly routeModule: "@coreframe/dashboard/plugins/diagnostics/web";
|
|
10
|
-
}];
|
|
11
|
-
readonly api: {
|
|
12
|
-
readonly routesModule: "@coreframe/dashboard/plugins/diagnostics/api/routes";
|
|
13
|
-
readonly handlersModule: "@coreframe/dashboard/plugins/diagnostics/api/handlers";
|
|
14
|
-
readonly localCapabilityModule: "@coreframe/dashboard/plugins/diagnostics/api/local";
|
|
15
|
-
readonly workerCapabilityModule: "@coreframe/dashboard/plugins/diagnostics/api/worker";
|
|
16
10
|
};
|
|
11
|
+
readonly pageModule: "@coreframe/dashboard/plugins/diagnostics/web";
|
|
12
|
+
readonly api: DashboardPluginApi<"diagnostics", {
|
|
13
|
+
readonly overview: DashboardQuery<undefined, DashboardPayload>;
|
|
14
|
+
}, {}>;
|
|
17
15
|
};
|
|
18
16
|
/** Registers Coreframe's built-in production-readiness dashboard. */
|
|
19
17
|
declare function diagnostics(): {
|
|
20
18
|
readonly id: "diagnostics";
|
|
21
|
-
readonly
|
|
22
|
-
readonly id: "diagnostics";
|
|
19
|
+
readonly navigation: {
|
|
23
20
|
readonly path: "diagnostics";
|
|
24
21
|
readonly title: "Production readiness";
|
|
25
22
|
readonly description: "Review launch readiness, deployment configuration, and project health.";
|
|
26
|
-
readonly routeModule: "@coreframe/dashboard/plugins/diagnostics/web";
|
|
27
|
-
}];
|
|
28
|
-
readonly api: {
|
|
29
|
-
readonly routesModule: "@coreframe/dashboard/plugins/diagnostics/api/routes";
|
|
30
|
-
readonly handlersModule: "@coreframe/dashboard/plugins/diagnostics/api/handlers";
|
|
31
|
-
readonly localCapabilityModule: "@coreframe/dashboard/plugins/diagnostics/api/local";
|
|
32
|
-
readonly workerCapabilityModule: "@coreframe/dashboard/plugins/diagnostics/api/worker";
|
|
33
23
|
};
|
|
24
|
+
readonly pageModule: "@coreframe/dashboard/plugins/diagnostics/web";
|
|
25
|
+
readonly api: DashboardPluginApi<"diagnostics", {
|
|
26
|
+
readonly overview: DashboardQuery<undefined, DashboardPayload>;
|
|
27
|
+
}, {}>;
|
|
34
28
|
};
|
|
35
29
|
//#endregion
|
|
36
30
|
export { diagnostics, diagnosticsPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineDashboardPlugin as e}from"../../config.js";const
|
|
1
|
+
import{defineDashboardPlugin as e}from"../../config.js";import{diagnosticsApi as t}from"./api/contract.js";const n=e({id:`diagnostics`,navigation:{path:`diagnostics`,title:`Production readiness`,description:`Review launch readiness, deployment configuration, and project health.`},pageModule:`@coreframe/dashboard/plugins/diagnostics/web`,api:t},{apiModule:`@coreframe/dashboard/plugins/diagnostics/api/contract`,localImplementationModule:`@coreframe/dashboard/plugins/diagnostics/api/local`,deployedImplementationModule:`@coreframe/dashboard/plugins/diagnostics/api/worker`});function r(){return n}export{r as diagnostics,n as diagnosticsPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createDashboardPluginClient as e}from"../../../api/client.js";import{diagnosticsApi as t}from"../api/contract.js";import{queryOptions as n}from"@tanstack/react-query";const r={overview:()=>n({queryKey:[`dashboard`,`plugins`,`diagnostics`,`overview`],queryFn:()=>e(t).queries.overview()})};export{r as diagnosticsQueries};
|
package/dist/package/server.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DashboardPluginRegistration } from "./api/contract.js";
|
|
2
2
|
import { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
3
3
|
|
|
4
4
|
//#region src/server.d.ts
|
|
5
5
|
type DashboardServerOptions = {
|
|
6
6
|
/** Built dashboard client directory. Omit when the host only dispatches API requests. */clientDist?: string;
|
|
7
|
-
|
|
7
|
+
plugins: readonly DashboardPluginRegistration<DashboardLocalHostData>[];
|
|
8
8
|
projectRoot: string;
|
|
9
9
|
};
|
|
10
|
+
type DashboardLocalHostData = {
|
|
11
|
+
/** Root of the application the local dashboard is inspecting. */projectRoot: string;
|
|
12
|
+
};
|
|
10
13
|
type DashboardRequestHandler = {
|
|
11
14
|
dispose(): Promise<void>;
|
|
12
15
|
handle(request: IncomingMessage, response: ServerResponse): Promise<void>;
|
|
13
16
|
};
|
|
14
17
|
declare function createDashboardServer(options: DashboardServerOptions): Server;
|
|
15
|
-
/** Creates the localhost-only Node host for the built client and composed plugin
|
|
18
|
+
/** Creates the localhost-only Node host for the built client and composed plugin operations. */
|
|
16
19
|
declare function createDashboardRequestHandler(options: DashboardServerOptions): DashboardRequestHandler;
|
|
17
20
|
//#endregion
|
|
18
|
-
export { DashboardRequestHandler, DashboardServerOptions, createDashboardRequestHandler, createDashboardServer };
|
|
21
|
+
export { DashboardLocalHostData, DashboardRequestHandler, DashboardServerOptions, createDashboardRequestHandler, createDashboardServer };
|
package/dist/package/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DashboardRequestError as e}from"./request-error.js";import{
|
|
1
|
+
import{DashboardRequestError as e}from"./request-error.js";import{assertDashboardApiRequestOrigin as t,assertLocalDashboardHost as n,getDashboardRequestId as r}from"./host-policy.js";import{handleFetchRequest as i}from"./node-fetch-adapter.js";import{createDashboardPluginDispatcher as a}from"./api/dispatcher.js";import{readFile as o,stat as s}from"node:fs/promises";import{extname as c,isAbsolute as l,join as u,relative as d,resolve as f,sep as p}from"node:path";import{createServer as m}from"node:http";function h(e){let t=g(e),n=m(async(e,n)=>{await t.handle(e,n)});return n.on(`close`,()=>{t.dispose()}),n}function g(o){let s=a(o.plugins,{host:Object.freeze({projectRoot:o.projectRoot}),getRequestId:r});return{dispose:async()=>void 0,async handle(r,a){try{n(r);let e=r.headers[`x-forwarded-proto`]===`https`?`https`:`http`,c=new URL(r.url??`/`,`${e}://${r.headers.host??`127.0.0.1`}`);if(c.pathname.startsWith(`/__dashboard/api/plugins/`)){t(r,c),await i(r,a,s);return}if(c.pathname===`/__dashboard/api`||c.pathname.startsWith(`/__dashboard/api/`)){v(a,404,{error:`Not found`});return}if(!o.clientDist){v(a,404,{error:`Not found`});return}if(c.pathname===`/__dashboard`){a.writeHead(302,{location:`/__dashboard/`}),a.end();return}if(c.pathname.startsWith(`/__dashboard/`)){if(r.method!==`GET`&&r.method!==`HEAD`){v(a,405,{error:`Method not allowed`});return}await _(r,a,c.pathname.slice(12)||`/`,o.clientDist);return}v(a,404,{error:`Not found`})}catch(t){v(a,t instanceof e?t.status:500,{error:t instanceof Error?t.message:String(t)})}}}}async function _(e,t,n,r){let i=y(r,n);if(!i){v(t,404,{error:`Client asset not found`});return}let a=await b(i),o=!a&&c(n)===``,s=u(r,`index.html`),l=o?await b(s):void 0,d=a?i:s,f=a??l;if(!f){v(t,404,{error:`Client asset not found`});return}t.writeHead(200,{"content-type":x(d),"cache-control":d.endsWith(`index.html`)?`no-store`:`public, max-age=31536000, immutable`}),t.end(e.method===`HEAD`?void 0:f)}function v(e,t,n){e.writeHead(t,{"content-type":`application/json; charset=utf-8`,"cache-control":`no-store`}),e.end(JSON.stringify(n))}function y(t,n){let r;try{r=decodeURIComponent(n)}catch{throw new e(`Dashboard request path is invalid.`,400)}if(r.includes(`\0`))throw new e(`Dashboard request path is invalid.`,400);let i=f(t,r===`/`?`index.html`:r.slice(1)),a=d(t,i);if(!(a===``||a===`..`||a.startsWith(`..${p}`)||l(a)))return i}async function b(e){try{return(await s(e)).isFile()?await o(e):void 0}catch(e){if(S(e)&&(e.code===`ENOENT`||e.code===`ENOTDIR`))return;throw e}}function x(e){switch(c(e)){case`.css`:return`text/css; charset=utf-8`;case`.html`:return`text/html; charset=utf-8`;case`.ico`:return`image/x-icon`;case`.jpeg`:case`.jpg`:return`image/jpeg`;case`.js`:case`.mjs`:return`text/javascript; charset=utf-8`;case`.json`:case`.map`:return`application/json; charset=utf-8`;case`.png`:return`image/png`;case`.svg`:return`image/svg+xml`;case`.ttf`:return`font/ttf`;case`.wasm`:return`application/wasm`;case`.webp`:return`image/webp`;case`.woff`:return`font/woff`;case`.woff2`:return`font/woff2`;default:return`application/octet-stream`}}function S(e){return e instanceof Error&&`code`in e}export{g as createDashboardRequestHandler,h as createDashboardServer};
|
package/dist/package/worker.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DashboardPluginRegistration } from "./api/contract.js";
|
|
2
|
+
import { DashboardLink, DashboardReleaseIdentity, DeployedConfigurationEntry } from "./types.js";
|
|
2
3
|
|
|
3
4
|
//#region src/worker.d.ts
|
|
4
5
|
type DashboardWorkerEnv = {
|
|
@@ -28,8 +29,16 @@ type DashboardBuildMetadata = {
|
|
|
28
29
|
deployUrls: Partial<Record<"production" | "staging", string>>;
|
|
29
30
|
};
|
|
30
31
|
type DashboardWorkerOptions = {
|
|
31
|
-
|
|
32
|
+
plugins: readonly DashboardPluginRegistration<DashboardWorkerHostData>[];
|
|
32
33
|
};
|
|
34
|
+
type DashboardWorkerHandler = (request: Request, env: DashboardWorkerEnv) => Promise<Response> | null;
|
|
35
|
+
type DashboardWorkerHostData = {
|
|
36
|
+
environment: "production" | "staging";
|
|
37
|
+
release: DashboardReleaseIdentity;
|
|
38
|
+
configuration: readonly DeployedConfigurationEntry[];
|
|
39
|
+
links: readonly DashboardLink[];
|
|
40
|
+
};
|
|
41
|
+
declare function createDashboardWorkerHandler(options: DashboardWorkerOptions): DashboardWorkerHandler;
|
|
33
42
|
declare function handleDashboardRequest<Env extends DashboardWorkerEnv>(request: Request, env: Env, options: DashboardWorkerOptions): Promise<Response> | null;
|
|
34
43
|
//#endregion
|
|
35
|
-
export { DashboardBuildMetadata, DashboardWorkerEnv, DashboardWorkerOptions, handleDashboardRequest };
|
|
44
|
+
export { DashboardBuildMetadata, DashboardWorkerEnv, DashboardWorkerHandler, DashboardWorkerHostData, DashboardWorkerOptions, createDashboardWorkerHandler, handleDashboardRequest };
|
package/dist/package/worker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getDashboardRequestId as e,isSameOriginDashboardMutation as t}from"./host-policy.js";import{createDashboardPluginDispatcher as n}from"./api/dispatcher.js";const r=`/__dashboard`,i=`${r}/api`,a=new WeakMap;function o(t){let r=n(t.plugins,{getRequestId:e});return(e,t)=>{let n=new URL(e.url);return!d(n.pathname)||!t.DEPLOY_ENV?null:c(e,t,n,t.DEPLOY_ENV,r)}}function s(e,t,n){if(!d(new URL(e.url).pathname)||!t.DEPLOY_ENV)return null;let r=n.plugins,i=a.get(r);return i||(i=o(n),a.set(r,i)),i(e,t)}async function c(e,n,a,o,s){if(!n.DASHBOARD_PASSWORD)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});let c=m(e.headers.get(`authorization`));if(!c||!await h(c,n.DASHBOARD_PASSWORD))return new Response(`Authentication required`,{headers:{"cache-control":`no-store`,"www-authenticate":`Basic realm="Coreframe dashboard", charset="UTF-8"`},status:401});if(a.pathname.startsWith(`${i}/plugins/`))return t(e.method,e.headers.get(`origin`),a.origin)?s(e,l(e,n,o)):p({error:{code:`invalid_input`}},403);if(a.pathname===i||a.pathname.startsWith(`${i}/`))return p({error:`Not found`},404);if(a.pathname===r)return a.pathname=`${r}/`,Response.redirect(a,302);if(e.method!==`GET`&&e.method!==`HEAD`)return new Response(`Method not allowed`,{headers:{"cache-control":`no-store`},status:405});if(!n.ASSETS)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});(a.pathname===`${r}/`||!a.pathname.slice(13).includes(`.`))&&(a.pathname=`${r}/index.html`);let u=await n.ASSETS.fetch(new Request(a,e)),d=new Headers(u.headers);return d.set(`cache-control`,a.pathname.endsWith(`/index.html`)?`no-store`:`public, max-age=31536000, immutable`),new Response(e.method===`HEAD`?null:u.body,{headers:d,status:u.status,statusText:u.statusText})}function l(e,t,n){let r=u(),i=t,a=r.configuration.filter(e=>e.requiredIn.includes(n)).map(e=>({description:e.description,kind:e.kind,name:e.name,status:f(i[e.name])?`configured`:`missing`})),o=[],s=r.deployUrls[n];return s?o.push({href:s,id:`application`,label:`Application`}):o.push({href:new URL(`/`,e.url).href,id:`application`,label:`Application`}),{environment:n,release:{applicationName:r.applicationName,applicationVersion:r.applicationVersion,cloudflareVersionId:t.CF_VERSION_METADATA?.id,cloudflareVersionTag:t.CF_VERSION_METADATA?.tag,cloudflareVersionTimestamp:t.CF_VERSION_METADATA?.timestamp,commit:r.commit,coreframeVersion:r.coreframeVersion,releaseName:t.POSTHOG_RELEASE},configuration:a,links:o}}function u(){return typeof __COREFRAME_DASHBOARD_BUILD__<`u`?__COREFRAME_DASHBOARD_BUILD__:{applicationName:`Coreframe application`,configuration:[],deployUrls:{}}}function d(e){return e===r||e.startsWith(`${r}/`)}function f(e){return typeof e==`string`?e.trim().length>0:e!=null}function p(e,t=200){return Response.json(e,{headers:{"cache-control":`no-store`},status:t})}function m(e){if(e?.startsWith(`Basic `))try{let t=Uint8Array.from(atob(e.slice(6)),e=>e.charCodeAt(0)),n=new TextDecoder().decode(t),r=n.indexOf(`:`);return r===-1||n.slice(0,r)!==`coreframe`?void 0:n.slice(r+1)}catch{return}}async function h(e,t){let n=new TextEncoder,[r,i]=await Promise.all([crypto.subtle.digest(`SHA-256`,n.encode(e)),crypto.subtle.digest(`SHA-256`,n.encode(t))]),a=new Uint8Array(r),o=new Uint8Array(i),s=0;for(let e=0;e<a.length;e+=1)s|=a[e]^o[e];return s===0}export{o as createDashboardWorkerHandler,s as handleDashboardRequest};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreframe/dashboard",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "Reusable dashboard composition, shell, plugin, and authenticated runtime for Coreframe apps",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,13 +52,9 @@
|
|
|
52
52
|
"types": "./dist/package/plugins/diagnostics/web.d.ts",
|
|
53
53
|
"default": "./dist/package/plugins/diagnostics/web.js"
|
|
54
54
|
},
|
|
55
|
-
"./plugins/diagnostics/api/
|
|
56
|
-
"types": "./dist/package/plugins/diagnostics/api/
|
|
57
|
-
"default": "./dist/package/plugins/diagnostics/api/
|
|
58
|
-
},
|
|
59
|
-
"./plugins/diagnostics/api/handlers": {
|
|
60
|
-
"types": "./dist/package/plugins/diagnostics/api/handlers.d.ts",
|
|
61
|
-
"default": "./dist/package/plugins/diagnostics/api/handlers.js"
|
|
55
|
+
"./plugins/diagnostics/api/contract": {
|
|
56
|
+
"types": "./dist/package/plugins/diagnostics/api/contract.d.ts",
|
|
57
|
+
"default": "./dist/package/plugins/diagnostics/api/contract.js"
|
|
62
58
|
},
|
|
63
59
|
"./plugins/diagnostics/api/local": {
|
|
64
60
|
"types": "./dist/package/plugins/diagnostics/api/local.d.ts",
|
|
@@ -68,10 +64,6 @@
|
|
|
68
64
|
"types": "./dist/package/plugins/diagnostics/api/worker.d.ts",
|
|
69
65
|
"default": "./dist/package/plugins/diagnostics/api/worker.js"
|
|
70
66
|
},
|
|
71
|
-
"./plugins/diagnostics/api/client": {
|
|
72
|
-
"types": "./dist/package/plugins/diagnostics/api/client.d.ts",
|
|
73
|
-
"default": "./dist/package/plugins/diagnostics/api/client.js"
|
|
74
|
-
},
|
|
75
67
|
"./shell.css": "./dist/package/shell.css"
|
|
76
68
|
},
|
|
77
69
|
"dependencies": {
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { DashboardPayload } from "../../../types.js";
|
|
2
|
-
|
|
3
|
-
//#region src/plugins/diagnostics/api/client.d.ts
|
|
4
|
-
declare function createDiagnosticsApiClient(options?: {
|
|
5
|
-
baseURL?: string;
|
|
6
|
-
fetch?: typeof fetch;
|
|
7
|
-
}): import("rouzer").ClientTree<{
|
|
8
|
-
dashboard: import("rouzer/http").HttpAction<"dashboard", {
|
|
9
|
-
readonly response: import("rouzer").Unchecked<DashboardPayload>;
|
|
10
|
-
}, "GET">;
|
|
11
|
-
}, ""> & {
|
|
12
|
-
clientConfig: {
|
|
13
|
-
baseURL: string;
|
|
14
|
-
headers?: Record<string, string>;
|
|
15
|
-
routes: {
|
|
16
|
-
dashboard: import("rouzer/http").HttpAction<"dashboard", {
|
|
17
|
-
readonly response: import("rouzer").Unchecked<DashboardPayload>;
|
|
18
|
-
}, "GET">;
|
|
19
|
-
};
|
|
20
|
-
plugins?: readonly import("rouzer").ClientResponsePlugin[];
|
|
21
|
-
onJsonError?: (response: Response) => unknown;
|
|
22
|
-
fetch?: typeof globalThis.fetch;
|
|
23
|
-
clientHook?: import("rouzer").RouzerClientHook;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
//#endregion
|
|
27
|
-
export { createDiagnosticsApiClient };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createDashboardPluginApiClient as e}from"../../../plugin-api.js";import{routes as t}from"./routes.js";function n(n={}){return e({pluginId:`diagnostics`,routes:t,...n})}export{n as createDiagnosticsApiClient};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DashboardPayload } from "../../../types.js";
|
|
2
|
-
import { DashboardPluginApiHandlersFactory } from "../../../plugin-api.js";
|
|
3
|
-
|
|
4
|
-
//#region src/plugins/diagnostics/api/handlers.d.ts
|
|
5
|
-
interface DiagnosticsCapability {
|
|
6
|
-
collect(): DashboardPayload | Promise<DashboardPayload>;
|
|
7
|
-
}
|
|
8
|
-
declare const createHandlers: DashboardPluginApiHandlersFactory<{
|
|
9
|
-
dashboard: import("rouzer/http").HttpAction<"dashboard", {
|
|
10
|
-
readonly response: import("rouzer").Unchecked<DashboardPayload>;
|
|
11
|
-
}, "GET">;
|
|
12
|
-
}, DiagnosticsCapability>;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { DiagnosticsCapability, createHandlers };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{defineDashboardPluginApiHandlers as e}from"../../../plugin-api.js";const t=e(e=>({dashboard(){return e.collect()}}));export{t as createHandlers};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DashboardPayload } from "../../../types.js";
|
|
2
|
-
import * as http from "rouzer/http";
|
|
3
|
-
|
|
4
|
-
//#region src/plugins/diagnostics/api/routes.d.ts
|
|
5
|
-
declare const routes: {
|
|
6
|
-
dashboard: http.HttpAction<"dashboard", {
|
|
7
|
-
readonly response: import("rouzer").Unchecked<DashboardPayload>;
|
|
8
|
-
}, "GET">;
|
|
9
|
-
};
|
|
10
|
-
type DiagnosticsRoutes = typeof routes;
|
|
11
|
-
//#endregion
|
|
12
|
-
export { DiagnosticsRoutes, routes };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$type as e}from"rouzer";import*as t from"rouzer/http";const n={dashboard:t.get(`dashboard`,{response:e()})};export{n as routes};
|