elysia-rack 0.3.0 → 0.5.1

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.
@@ -0,0 +1,39 @@
1
+ import type { FieldDescriptor, FieldKind } from "../../../rack/adapters/index";
2
+ import type { CrudFieldConfig, CrudFieldFormat, CrudFieldOption } from "../../../rack/types/fields";
3
+ /**
4
+ * Serializable per-field descriptor shared by the server renderer,
5
+ * the browser bundle, and tests. Relation options are resolved before
6
+ * serialization so the client never needs a data loader.
7
+ */
8
+ export interface PanelField {
9
+ name: string;
10
+ label: string;
11
+ kind: FieldKind;
12
+ format: CrudFieldFormat;
13
+ currency?: string;
14
+ nullable: boolean;
15
+ primary: boolean;
16
+ autoIncrement: boolean;
17
+ readOnly: boolean;
18
+ hideInTable: boolean;
19
+ hideInForm: boolean;
20
+ enumValues?: readonly string[];
21
+ relation?: readonly CrudFieldOption[];
22
+ order: number;
23
+ }
24
+ export declare function buildPanelFields(input: {
25
+ fields?: FieldDescriptor[];
26
+ columns: string[];
27
+ config?: Record<string, CrudFieldConfig>;
28
+ hiddenFields?: readonly string[];
29
+ primaryKey: string;
30
+ deletedAtField: string;
31
+ }): Promise<PanelField[]>;
32
+ export declare function isNumericField(field: PanelField): boolean;
33
+ /** Human-readable cell text for a field value. */
34
+ export declare function displayValue(field: PanelField | undefined, value: unknown): string;
35
+ /** Coerce a raw form/bulk string to the field's kind. */
36
+ export declare function coerceFieldValue(field: PanelField | undefined, raw: string): {
37
+ value?: unknown;
38
+ error?: string;
39
+ };
@@ -1,2 +1,2 @@
1
- import type { ReactRack } from "./types";
1
+ import { ReactRack } from "./types";
2
2
  export declare function createRenderer(pages: ReactRack.PageRegistry): (path: string, props: unknown) => Promise<Response>;
@@ -7,9 +7,23 @@ export declare namespace ReactRack {
7
7
  props?: Props;
8
8
  }
9
9
  type PageComponent<Props = any> = ComponentType<Props>;
10
- type PageRegistry = Record<string, () => Promise<{
10
+ type PageLoader = () => Promise<{
11
11
  default: PageComponent;
12
- }>>;
12
+ }>;
13
+ /** A page is either a component or a loader wrapped with `lazyPage()`. */
14
+ type PageEntry = PageComponent | PageLoader;
15
+ type PageRegistry = Record<string, PageEntry>;
16
+ /** Mark a `() => import(...)` loader so it is not mistaken for a component. */
17
+ function lazyPage(loader: PageLoader): PageLoader;
18
+ /** @internal */
19
+ function isLazyPage(entry: PageEntry): entry is PageLoader;
20
+ /** A page registered directly with its URL — no `page()` call needed. */
21
+ interface ReactView<Props = any> {
22
+ /** URL path the route is mounted at. */
23
+ path: string;
24
+ component: PageEntry;
25
+ props?: Props;
26
+ }
13
27
  /** Override source for panel.css */
14
28
  type PanelCssOverride = string | {
15
29
  path?: string;
@@ -17,6 +31,8 @@ export declare namespace ReactRack {
17
31
  };
18
32
  interface ReactPluginOptions {
19
33
  pages?: PageRegistry | PageRegistry[];
34
+ /** Pages auto-mounted at their `path`; `page()` is not needed for these. */
35
+ views?: ReactView[];
20
36
  /**
21
37
  * Override `panel.css` served at `/__rack/panel.css`.
22
38
  * - `string`: file path if the file exists, otherwise raw CSS string.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elysia-rack",
3
- "version": "0.3.0",
3
+ "version": "0.5.1",
4
4
  "description": "Model-driven CRUD rack for Elysia: REST + QUERY routes, validation, authorization, OpenAPI metadata, and React panel rendering.",
5
5
  "type": "module",
6
6
  "license": "MIT",