@brickkit/core 0.13.3 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
- import { Dn as SecretSource, E as Logger, J as ValidationErrorItem, Kn as EventsOptions, R as Service, cn as ServicePort, dr as HttpMethod, ht as EventsHub, mt as EventsDefinition, ot as SocketBroker, qt as InstalledPlugin, rt as BrickSocketSchema, t as Action, wt as DatabaseHandle, yn as PluginInstance } from "./types.js";
1
+ import { E as Logger, J as ValidationErrorItem, Nn as PluginInstance, Nt as DatabaseHandle, R as Service, Vn as SecretSource, _n as ServicePort, ht as EventsHub, jr as HttpMethod, mt as EventsDefinition, nn as InstalledPlugin, or as EventsOptions, ot as SocketBroker, rt as BrickSocketSchema, t as Action, wt as DashboardUser } from "./types.js";
2
2
  import { Elysia } from "elysia";
3
3
  type RouteMethod = HttpMethod;
4
+ /** How a string from a query or form field becomes the schema's type; objects travel as JSON. */
5
+ type Coercion = "number" | "boolean" | "array" | "json";
4
6
  interface RouteIR {
5
7
  readonly method: RouteMethod;
6
8
  readonly path: string;
@@ -19,8 +21,12 @@ interface RouteIR {
19
21
  readonly inputSource: "query" | "body";
20
22
  readonly coercions: readonly {
21
23
  readonly key: string;
22
- readonly type: "number" | "boolean" | "array";
24
+ readonly type: Coercion;
25
+ /** How each item of an `array` field is coerced. */
26
+ readonly items?: Exclude<Coercion, "array">;
23
27
  }[];
28
+ /** The most bytes a multipart body may declare (`Content-Length`) for an input with `t.File` fields. */
29
+ readonly bodyLimit?: number;
24
30
  /** JSON projection for inspection and stale-artifact detection, not runtime validation. */
25
31
  readonly inputSchema?: unknown;
26
32
  readonly outputSchema?: unknown;
@@ -107,11 +113,20 @@ interface DashboardAuth {
107
113
  * `Response` to send instead, such as a redirect to your login page. If it
108
114
  * throws or takes longer than five seconds, the request is refused with 503.
109
115
  *
116
+ * Return `{ user: { id, name } }` to let it in and say who it is: requests
117
+ * the dashboard's pages send to the app through `/app/*` carry that user,
118
+ * signed, which the app reads with `ctx.dashboard?.user` in an action or
119
+ * `dashboardUser(request)` in an endpoint.
120
+ *
110
121
  * A request is let in when it carries a valid `token`, or when this
111
122
  * returns `true`; give both to let monitors in by token and people in by
112
123
  * sign-in.
113
124
  */
114
- authorize?: (request: Request) => boolean | Response | Promise<boolean | Response>;
125
+ authorize?: (request: Request) => boolean | Response | {
126
+ user: DashboardUser;
127
+ } | Promise<boolean | Response | {
128
+ user: DashboardUser;
129
+ }>;
115
130
  }
116
131
  /**
117
132
  * The monitoring dashboard `brick start` serves beside the app, on a port of