@magicvr/schema-ui-renderer 0.3.2 → 0.3.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.
Files changed (37) hide show
  1. package/components/account-session-toolbar.d.ts +2 -0
  2. package/components/activity-export.d.ts +2 -0
  3. package/components/cron-preview.d.ts +2 -0
  4. package/components/data-permission-scopes.d.ts +2 -0
  5. package/components/data-table.d.ts +43 -0
  6. package/components/email-identity.d.ts +2 -0
  7. package/components/force-password-change.d.ts +1 -0
  8. package/components/import-template-download.d.ts +2 -0
  9. package/components/invite-accept.d.ts +6 -0
  10. package/components/invite-issue-card.d.ts +7 -0
  11. package/components/invite-resend-dialog.d.ts +9 -0
  12. package/components/locale-switcher.d.ts +23 -0
  13. package/components/mail-admin-tab.d.ts +2 -0
  14. package/components/mfa-manager.d.ts +2 -0
  15. package/components/monitoring-auto-refresh.d.ts +2 -0
  16. package/components/notification-center.d.ts +2 -0
  17. package/components/password-policy-tab.d.ts +6 -0
  18. package/components/qr-code.d.ts +16 -0
  19. package/components/theme-toggle.d.ts +10 -0
  20. package/components/timezone-switcher.d.ts +16 -0
  21. package/components/wallet-ensure.d.ts +2 -0
  22. package/package.json +1 -8
  23. package/renderer/confirm.d.ts +17 -0
  24. package/renderer/custom-components.d.ts +14 -0
  25. package/renderer/form-controls.d.ts +45 -0
  26. package/renderer/form-controls.types.d.ts +135 -0
  27. package/renderer/index.d.ts +13 -0
  28. package/renderer/modal.d.ts +6 -0
  29. package/renderer/permissions.d.ts +53 -0
  30. package/renderer/reaction-engine.d.ts +92 -0
  31. package/renderer/reaction-expression.d.ts +74 -0
  32. package/renderer/reactions.d.ts +64 -0
  33. package/renderer/render.d.ts +194 -0
  34. package/renderer/render.types.d.ts +289 -0
  35. package/renderer/resource.d.ts +114 -0
  36. package/renderer/row-action.d.ts +28 -0
  37. package/renderer/schema-table.d.ts +90 -0
@@ -0,0 +1,114 @@
1
+ import type { SortOrder } from "@magicvr/schema-ui-renderer/components/data-table";
2
+ export declare const DEFAULT_PAGE_SIZE = 10;
3
+ /**
4
+ * Frozen list-endpoint rule (I-010-001 v0.2.0 · A-001 F-001): `table.props.dataSource`
5
+ * must be a single-slash same-origin absolute path — starts with one `/`, no `//`
6
+ * (no protocol-relative host), no scheme, no whitespace, backslash, `?` or `#`.
7
+ * Query strings are appended by `buildResourceQuery`, never authored in dataSource;
8
+ * fragments are never allowed. Validated before any (auth) fetch is attempted.
9
+ * Mirrors `DataRef.url`'s `^/(?!/)[^\s\\]*$` but additionally rejects `?`/`#`.
10
+ */
11
+ export declare const DATASOURCE_URL_PATTERN: RegExp;
12
+ /** A schema-driven resource row: any plain JSON object (no field whitelist). */
13
+ export interface ResourceItem {
14
+ [key: string]: unknown;
15
+ }
16
+ /** Unified list envelope frozen across resources: `{items,total,page,pageSize}`. */
17
+ export interface ResourceList {
18
+ items: ResourceItem[];
19
+ total: number;
20
+ page: number;
21
+ pageSize: number;
22
+ }
23
+ /** A generic resource list query. */
24
+ export interface ResourceQuery {
25
+ q?: string;
26
+ sort?: string;
27
+ order?: SortOrder;
28
+ page?: number;
29
+ pageSize?: number;
30
+ /** Schema-driven table filters (table node props.filters): field to value. */
31
+ filters?: Record<string, string>;
32
+ }
33
+ /**
34
+ * Shared query for display components (statCard/chart) that read the first
35
+ * item + envelope of a list endpoint. The pageSize keeps the historical RPC
36
+ * shape (one generous bucket); wallet-ensure uses the exact same query so its
37
+ * existence probe coalesces with the statCards' request (per-page fetch cache).
38
+ */
39
+ export declare const DISPLAY_LIST_QUERY: ResourceQuery;
40
+ /** One field-level validation failure (GOAL-014 D-002 §2.1). */
41
+ export interface FieldError {
42
+ field: string;
43
+ reason: string;
44
+ }
45
+ /** A resource API failure carrying the frozen envelope `{error, message}`. */
46
+ export declare class ResourceApiError extends Error {
47
+ readonly code: string;
48
+ readonly status: number;
49
+ /** VP-007 S4: stable catalog key when the server cataloged this error. */
50
+ readonly messageKey?: string;
51
+ /** VP-007 S4: interpolation params for messageKey. */
52
+ readonly params?: Record<string, unknown>;
53
+ /** GOAL-014: field-level validation failures, when the server attached them. */
54
+ readonly fieldErrors: FieldError[];
55
+ /** R1 correlation identifier for support/operator lookup. */
56
+ readonly correlationId?: string;
57
+ constructor(status: number, code: string, message: string, messageKey?: string, params?: Record<string, unknown>, fieldErrors?: FieldError[], correlationId?: string);
58
+ }
59
+ /** W19: missing self-wallet is an empty surface, not a hard page error. */
60
+ export declare function isWalletNotFoundError(err: unknown): boolean;
61
+ export declare const EMPTY_RESOURCE_LIST: ResourceList;
62
+ export type ResourceCreateBody = ResourceItem;
63
+ export type ResourcePatch = Partial<ResourceItem>;
64
+ /** F-001: single executable rule for a table list endpoint (fail-closed on any violation). */
65
+ export declare function isValidDataSource(url: string): boolean;
66
+ /** Reads the frozen error envelope from a non-OK response. */
67
+ export declare function readResourceApiError(response: Response, label: string): Promise<ResourceApiError>;
68
+ /** Serializes a ResourceQuery into a URL query string (query-serialization). */
69
+ /**
70
+ * v2.9 dataSource params resolution (ADR-0039, capability data.route-binding).
71
+ * Literal scalars pass through; whole `$context.route.query.*` /
72
+ * `$context.route.params.*` bindings are resolved from the route snapshot;
73
+ * a missing key (or absent route) is a tombstone — the parameter is dropped
74
+ * (ADR-0010 semantics, same as null values). Returns the merged query string
75
+ * (empty when nothing resolves).
76
+ */
77
+ export declare function resolveDataParamsQuery(params: Record<string, unknown> | undefined, route: {
78
+ query?: Record<string, string>;
79
+ params?: Record<string, string>;
80
+ }): string;
81
+ export declare function buildResourceQuery(query: ResourceQuery): string;
82
+ /**
83
+ * Maps an unknown list payload to the unified ResourceList envelope, fail-closed
84
+ * on shape drift. Items are arbitrary JSON objects (F-002 rowKey is enforced at
85
+ * the table surface, not here).
86
+ */
87
+ export declare function parseResourceList(value: unknown): ResourceList;
88
+ /**
89
+ * Builds the query-string portion of a resource list request — the exact
90
+ * construction `fetchResourceList` sends on the wire. `extraQuery` carries
91
+ * v2.9 ADR-0039 dataSource params that already resolved to literal key=value
92
+ * pairs and is merged over the standard q/sort/order/page/pageSize query.
93
+ */
94
+ export declare function resourceListQueryString(query: ResourceQuery, extraQuery?: string): string;
95
+ /**
96
+ * The final URL for a resource list request (F-001-validated baseURL + query
97
+ * string). Shared by `fetchResourceList` and the renderer's per-page fetch
98
+ * cache so the cache key and the wire request can never drift apart.
99
+ */
100
+ export declare function resourceListURL(baseURL: string, query: ResourceQuery, extraQuery?: string): string;
101
+ /**
102
+ * Fetches a page of a schema-driven resource list (request-construction).
103
+ *
104
+ * `extraQuery` carries v2.9 ADR-0039 dataSource params that already resolved
105
+ * to literal key=value pairs (e.g. `dictKey=order_status` from a
106
+ * `$context.route.query.*` binding). It is merged with the standard
107
+ * q/sort/order/page/pageSize query; baseURL itself must stay a bare
108
+ * single-slash same-origin path (F-001).
109
+ */
110
+ export declare function fetchResourceList(fetcher: typeof fetch, baseURL: string, query: ResourceQuery, extraQuery?: string): Promise<ResourceList>;
111
+ /** Creates a resource row via POST; returns the 201 row. */
112
+ export declare function createResource(fetcher: typeof fetch, baseURL: string, body: ResourceCreateBody): Promise<ResourceItem>;
113
+ export declare function updateResource(fetcher: typeof fetch, baseURL: string, id: string, patch: ResourcePatch): Promise<ResourceItem>;
114
+ export declare function deleteResource(fetcher: typeof fetch, baseURL: string, id: string): Promise<void>;
@@ -0,0 +1,28 @@
1
+ import { type ExecutionResult } from "@magicvr/schema-ui-renderer/renderer/permissions";
2
+ import type { NavigationContext } from "@magicvr/schema-ui-protocol/app-manifest";
3
+ /**
4
+ * R5 D-ACT non-batch row action execution (frozen Q1: batch excluded).
5
+ *
6
+ * Wraps the R4 executeAction engine so UI actions gate through the same
7
+ * permission / confirm / disabled sequence as the frozen permission fixtures.
8
+ * `page` is the R5 example page document; `targetId` is a table row action key.
9
+ */
10
+ export type RowActionOutcome = ExecutionResult["outcome"];
11
+ export interface RowActionRequest {
12
+ page: Record<string, unknown>;
13
+ targetId: string;
14
+ context: NavigationContext;
15
+ /** Defaults to true; a hidden action fails closed as NOT_VISIBLE. */
16
+ visible?: boolean;
17
+ confirm?: boolean;
18
+ confirmed?: boolean;
19
+ disabled?: boolean;
20
+ requiresSelection?: boolean;
21
+ }
22
+ export interface RowActionResult {
23
+ outcome: RowActionOutcome;
24
+ reason?: ExecutionResult["reason"];
25
+ permissionDenied: boolean;
26
+ confirmed?: boolean;
27
+ }
28
+ export declare function runRowAction(request: RowActionRequest): RowActionResult;
@@ -0,0 +1,90 @@
1
+ import { type ResourceItem } from "@magicvr/schema-ui-renderer/renderer/resource";
2
+ import type { RenderTableNode } from "@magicvr/schema-ui-renderer/renderer/render.types";
3
+ /**
4
+ * Default schema-driven table surface (R1 · GOAL-004 / D-004) + S4 CRUD wiring
5
+ * + A-002 generic adapter (GOAL-010 S3).
6
+ *
7
+ * Renders a whitelisted table node's `props.columns` over its `props.dataSource`.
8
+ * Fails closed when the node declares no columns, no (valid) data source, or a
9
+ * response that violates the frozen rowKey invariant (F-001 / F-002).
10
+ *
11
+ * F-001 (I-010-001 v0.2.0 §2): `dataSource` must be a single-slash same-origin
12
+ * path; invalid/absent sources render an observable fail-closed state and never
13
+ * reach the (auth) fetcher.
14
+ *
15
+ * F-002 (I-010-001 v0.2.0 §3): `props.rowKey` (default `"id"`) is the direct
16
+ * field name of each row's unique, non-empty scalar key (string / finite
17
+ * number). A missing / empty / non-scalar / duplicate key stops rendering the
18
+ * table data and forbids row actions and selection.
19
+ *
20
+ * S4 (GOAL-007 · I-007-003 v0.2.2 §9): when rendered inside a `RenderPage`
21
+ * (which always wraps content in the SchemaCrudProvider), the table surfaces
22
+ * `props.toolbar` (create trigger) and `props.actions` (row edit/delete),
23
+ * participates in row selection for the page's recordView / edit-form prefill,
24
+ * reads its query from the shared per-table query state (so the search-form
25
+ * binding and the post-write reload both reach it), and registers its injected
26
+ * fetcher so modal form submits / row actions use the same transport. All of
27
+ * this is fixture-driven: no record-specific logic lives here.
28
+ */
29
+ export interface SchemaTableProps {
30
+ node: RenderTableNode;
31
+ /** Injectable fetch (defaults to `globalThis.fetch`). */
32
+ fetcher?: typeof fetch;
33
+ }
34
+ export interface SchemaTableColumnSpec {
35
+ field: string;
36
+ label?: string;
37
+ sortable?: boolean;
38
+ /** W4 · GOAL-005: single-line truncate + title affordance for long values. */
39
+ truncate?: boolean;
40
+ /** Column width hint (px number or CSS length). */
41
+ width?: number | string;
42
+ /** Minimum column width (px number or CSS length). */
43
+ minWidth?: number | string;
44
+ /** W16-F04: render a cent-valued number as a localized currency string. */
45
+ format?: "currency";
46
+ /** W16-F09: render this cell as a colored badge using the row field value. */
47
+ badgeStyleField?: string;
48
+ }
49
+ /** Structured row predicate used by Schema actions; malformed predicates fail closed. */
50
+ export declare function rowActionDisabled(action: unknown, row: ResourceItem): boolean;
51
+ /** Extracts the table node's column specs, fail-closed on malformed entries. */
52
+ export declare function schemaTableColumns(node: RenderTableNode): SchemaTableColumnSpec[];
53
+ /**
54
+ * Resolves the table node's list endpoint (F-001). v2.9 prefers the node-level
55
+ * DataRef (ADR-0039, source:api url); the legacy props.dataSource string stays
56
+ * supported. Returns null when absent or not a single-slash same-origin path;
57
+ * the table then fails closed and never fetches (the fixture fallback was
58
+ * removed in GOAL-010 S3).
59
+ */
60
+ export declare function schemaTableDataSource(node: RenderTableNode): string | null;
61
+ /** v2.9 node-level DataRef params (ADR-0039 route bindings), else empty. */
62
+ export declare function schemaTableDataParams(node: RenderTableNode): Record<string, unknown> | undefined;
63
+ /** F-002: the direct field name used as each row's unique key (default "id"). */
64
+ export declare function schemaTableRowKey(node: RenderTableNode): string;
65
+ /** One select option of a schema-driven table filter. */
66
+ export interface SchemaTableFilterOptionSpec {
67
+ value: string;
68
+ label?: string;
69
+ labelKey?: string;
70
+ }
71
+ /** A schema-driven table filter (table node `props.filters`; select-only). */
72
+ export interface SchemaTableFilterSpec {
73
+ field: string;
74
+ type: "select";
75
+ label?: string;
76
+ labelKey?: string;
77
+ options: SchemaTableFilterOptionSpec[];
78
+ }
79
+ /**
80
+ * Extracts the table node's filter specs (fail-closed on malformed entries).
81
+ * Only `select` filters are supported; other/unknown types are dropped so a
82
+ * schema typo never renders a broken control.
83
+ */
84
+ export declare function schemaTableFilters(node: RenderTableNode): SchemaTableFilterSpec[];
85
+ /**
86
+ * Windowed pager page list: 1 … current±1 … total, with gap markers for
87
+ * long page runs (stable shape for tests and a11y).
88
+ */
89
+ export declare function pagerPages(current: number, total: number): Array<number | "gap">;
90
+ export declare function SchemaTable({ node, fetcher }: SchemaTableProps): import("react").JSX.Element;