@stonecrop/schema 0.31.0 → 0.32.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.
- package/README.md +10 -10
- package/dist/cli.js +194 -121
- package/dist/cli.js.map +1 -1
- package/dist/converter-CLwduvT_.js +2102 -0
- package/dist/converter-CLwduvT_.js.map +1 -0
- package/dist/flatten-Bx2cfvw3.js +37 -0
- package/dist/flatten-Bx2cfvw3.js.map +1 -0
- package/dist/index.js +123 -117
- package/dist/index.js.map +1 -1
- package/dist/record-BQOOi83C.js +134 -0
- package/dist/record-BQOOi83C.js.map +1 -0
- package/dist/record.js +2 -6
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +34 -18
- package/dist/flatten-C1MjkzFh.js +0 -10
- package/dist/flatten-C1MjkzFh.js.map +0 -1
- package/dist/record-Bc0lI9Rq.js +0 -61
- package/dist/record-Bc0lI9Rq.js.map +0 -1
- package/dist/record.js.map +0 -1
- package/dist/schema.tsbuildinfo +0 -1
- package/dist/src/badge.d.ts +0 -74
- package/dist/src/badge.d.ts.map +0 -1
- package/dist/src/badge.js +0 -158
- package/dist/src/cli.d.ts +0 -3
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -292
- package/dist/src/column-schema.d.ts +0 -163
- package/dist/src/column-schema.d.ts.map +0 -1
- package/dist/src/column-schema.js +0 -0
- package/dist/src/component-meta.d.ts +0 -96
- package/dist/src/component-meta.d.ts.map +0 -1
- package/dist/src/component-meta.js +0 -88
- package/dist/src/converter/aggregate.d.ts +0 -127
- package/dist/src/converter/aggregate.d.ts.map +0 -1
- package/dist/src/converter/aggregate.js +0 -235
- package/dist/src/converter/authored.d.ts +0 -43
- package/dist/src/converter/authored.d.ts.map +0 -1
- package/dist/src/converter/authored.js +0 -52
- package/dist/src/converter/heuristics.d.ts +0 -60
- package/dist/src/converter/heuristics.d.ts.map +0 -1
- package/dist/src/converter/heuristics.js +0 -304
- package/dist/src/converter/index.d.ts +0 -51
- package/dist/src/converter/index.d.ts.map +0 -1
- package/dist/src/converter/index.js +0 -195
- package/dist/src/converter/merge.d.ts +0 -102
- package/dist/src/converter/merge.d.ts.map +0 -1
- package/dist/src/converter/merge.js +0 -136
- package/dist/src/converter/scalars.d.ts +0 -46
- package/dist/src/converter/scalars.d.ts.map +0 -1
- package/dist/src/converter/scalars.js +0 -83
- package/dist/src/converter/types.d.ts +0 -157
- package/dist/src/converter/types.d.ts.map +0 -1
- package/dist/src/converter/types.js +0 -5
- package/dist/src/doctype.d.ts +0 -516
- package/dist/src/doctype.d.ts.map +0 -1
- package/dist/src/doctype.js +0 -343
- package/dist/src/field.d.ts +0 -423
- package/dist/src/field.d.ts.map +0 -1
- package/dist/src/field.js +0 -378
- package/dist/src/flatten.d.ts +0 -29
- package/dist/src/flatten.d.ts.map +0 -1
- package/dist/src/flatten.js +0 -38
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -20
- package/dist/src/mode.d.ts +0 -15
- package/dist/src/mode.d.ts.map +0 -1
- package/dist/src/mode.js +0 -0
- package/dist/src/naming.d.ts +0 -80
- package/dist/src/naming.d.ts.map +0 -1
- package/dist/src/naming.js +0 -106
- package/dist/src/record.d.ts +0 -29
- package/dist/src/record.d.ts.map +0 -1
- package/dist/src/record.js +0 -55
- package/dist/src/table.d.ts +0 -33
- package/dist/src/table.d.ts.map +0 -1
- package/dist/src/table.js +0 -25
- package/dist/src/validation.d.ts +0 -54
- package/dist/src/validation.d.ts.map +0 -1
- package/dist/src/validation.js +0 -60
- package/dist/validation-C9P__pRF.js +0 -994
- package/dist/validation-C9P__pRF.js.map +0 -1
package/dist/src/field.d.ts
DELETED
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { ColumnSchema } from './column-schema';
|
|
3
|
-
import { flattenFields } from './flatten';
|
|
4
|
-
import type { InteractionMode } from './mode';
|
|
5
|
-
import { TableViewConfig } from './table';
|
|
6
|
-
export { flattenFields };
|
|
7
|
-
/**
|
|
8
|
-
* Field options - flexible bag for type-specific configuration.
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
* - Select: array of choices (["Draft", "Submitted", "Cancelled"])
|
|
12
|
-
* - Select with badges: \{ choices: [...], badges: \{ Open: "warning", ... \} \} or bare map
|
|
13
|
-
* - Decimal: config object (\{ precision: 10, scale: 2 \})
|
|
14
|
-
* - Code: config object (\{ language: "python" \})
|
|
15
|
-
*
|
|
16
|
-
* Deliberately *not* a bare string: a string once meant "link target", which made the value's
|
|
17
|
-
* shape encode its meaning. That job belongs to `ValueField.doctype`, leaving this a plain
|
|
18
|
-
* choices-or-config bag.
|
|
19
|
-
*
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export declare const FieldOptions: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
|
|
23
|
-
/**
|
|
24
|
-
* Field options type inferred from Zod schema
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
export type FieldOptions = z.infer<typeof FieldOptions>;
|
|
28
|
-
/**
|
|
29
|
-
* Validation configuration for form fields
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export declare const FieldValidation: z.ZodObject<{
|
|
33
|
-
errorMessage: z.ZodString;
|
|
34
|
-
}, z.core.$loose>;
|
|
35
|
-
/**
|
|
36
|
-
* Field validation type inferred from Zod schema
|
|
37
|
-
* @public
|
|
38
|
-
*/
|
|
39
|
-
export type FieldValidation = z.infer<typeof FieldValidation>;
|
|
40
|
-
/**
|
|
41
|
-
* A field that holds a scalar value, a link to another record, or a select choice.
|
|
42
|
-
* The most common kind of field. `component` determines how it renders; the attributes below
|
|
43
|
-
* carry everything else that is not a rendering concern.
|
|
44
|
-
* @public
|
|
45
|
-
*/
|
|
46
|
-
export interface ValueField {
|
|
47
|
-
/** Discriminator — identifies this as a value-holding field */
|
|
48
|
-
kind: 'field';
|
|
49
|
-
/** Unique identifier for this field within its doctype */
|
|
50
|
-
fieldname: string;
|
|
51
|
-
/**
|
|
52
|
-
* Vue component that renders this field — the primary (and only) rendering axis. Required:
|
|
53
|
-
* there is nothing left to derive it from, and a field without one has nothing to render it.
|
|
54
|
-
* Any string is valid; naming a custom component is how an app renders a field Stonecrop
|
|
55
|
-
* ships no widget for. See `CANONICAL_COMPONENTS` for the set Stonecrop provides.
|
|
56
|
-
*/
|
|
57
|
-
component: string;
|
|
58
|
-
/** True for the field that identifies the record's primary-key column. */
|
|
59
|
-
primaryKey?: boolean;
|
|
60
|
-
/** True for a computed/display field with no backing DB column — excluded from SQL SELECT. */
|
|
61
|
-
computed?: boolean;
|
|
62
|
-
/** Editor language for code fields (e.g. `'json'`, `'typescript'`) — the only thing distinguishing
|
|
63
|
-
* a JSON editor from a code editor, since both render with `ACodeEditor`. */
|
|
64
|
-
language?: string;
|
|
65
|
-
/**
|
|
66
|
-
* Target doctype slug. Presence is what makes a field a link.
|
|
67
|
-
*
|
|
68
|
-
* How it renders is decided by `component`, not by this: `AFormLink` renders an
|
|
69
|
-
* inline id-picker, while `AForm`/`ATable` expand the target (see `linkRenderMode`). Expansion
|
|
70
|
-
* metadata — backlink, fetch strategy, authoritative cardinality — lives in the doctype's
|
|
71
|
-
* `links` map, which is additive and never required for a plain foreign key.
|
|
72
|
-
*/
|
|
73
|
-
doctype?: string;
|
|
74
|
-
/** Human-readable label */
|
|
75
|
-
label?: string;
|
|
76
|
-
/** CSS width (e.g. `"40ch"`, `"200px"`) */
|
|
77
|
-
width?: string;
|
|
78
|
-
/** CSS height (e.g. `"100%"`, `"40vh"`) — used by full-viewport fields such as Planner */
|
|
79
|
-
height?: string;
|
|
80
|
-
/** Text alignment */
|
|
81
|
-
align?: 'left' | 'center' | 'right' | 'start' | 'end';
|
|
82
|
-
/** Whether the field is editable in table cell context */
|
|
83
|
-
edit?: boolean;
|
|
84
|
-
/** Input mask pattern or serialized function */
|
|
85
|
-
mask?: string;
|
|
86
|
-
/** Serialized display formatter — distinct from `mask` (input). Spreads through
|
|
87
|
-
* `schemaToColumns` to `ColumnSchema.format`; deserialized at render time by ATable's
|
|
88
|
-
* `getFormattedValue`. Returns a plain string, HTML, or a {@link BadgeDescriptor} for badge
|
|
89
|
-
* cells. When a descriptor is returned it wins over any badge map on `options`. */
|
|
90
|
-
format?: string;
|
|
91
|
-
/** Per-field interaction mode override */
|
|
92
|
-
mode?: InteractionMode;
|
|
93
|
-
/** Type-specific options: Select choices, Decimal precision config, etc. A link's target is not
|
|
94
|
-
* here — it is `doctype`. */
|
|
95
|
-
options?: FieldOptions;
|
|
96
|
-
/** Whether the field is required */
|
|
97
|
-
required?: boolean;
|
|
98
|
-
/** Whether the field is read-only */
|
|
99
|
-
readOnly?: boolean;
|
|
100
|
-
/** Whether the field is hidden from the UI */
|
|
101
|
-
hidden?: boolean;
|
|
102
|
-
/** Default value for new records */
|
|
103
|
-
default?: unknown;
|
|
104
|
-
/** Validation configuration */
|
|
105
|
-
validation?: FieldValidation;
|
|
106
|
-
/** Cardinality for Link fields — authoritative value on LinkDeclaration takes precedence */
|
|
107
|
-
cardinality?: 'atMostOne' | 'one' | 'noneOrMany' | 'atLeastOne';
|
|
108
|
-
/**
|
|
109
|
-
* Provenance marker — stamped only by the GraphQL converter; absence means hand-authored.
|
|
110
|
-
* When present, the docbuilder freezes the field's identity set (`fieldname`, `primaryKey`,
|
|
111
|
-
* `required`, `options`, `cardinality`, `doctype`), since `fieldname` is the GraphQL/column
|
|
112
|
-
* binding and `doctype` is the FK's target. `component` is deliberately **not** frozen: it
|
|
113
|
-
* chooses the widget, which is an authoring decision the database has no opinion about.
|
|
114
|
-
*/
|
|
115
|
-
source?: 'introspected';
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* A layout container that groups other fields. Resolves to a nested AForm.
|
|
119
|
-
* @public
|
|
120
|
-
*/
|
|
121
|
-
export interface FieldsetField {
|
|
122
|
-
/** Discriminator — identifies this as a fieldset container */
|
|
123
|
-
kind: 'fieldset';
|
|
124
|
-
/** Unique identifier for this fieldset within its doctype */
|
|
125
|
-
fieldname: string;
|
|
126
|
-
/** Vue component to render this fieldset. Defaults to `'AFieldset'` in resolveSchema. */
|
|
127
|
-
component?: string;
|
|
128
|
-
/** Human-readable label for the fieldset legend */
|
|
129
|
-
label?: string;
|
|
130
|
-
/** Whether the fieldset can be collapsed */
|
|
131
|
-
collapsible?: boolean;
|
|
132
|
-
/** Interaction mode for all children inside this fieldset */
|
|
133
|
-
mode?: InteractionMode;
|
|
134
|
-
/** Nested field definitions — resolved recursively by resolveSchema */
|
|
135
|
-
schema: DoctypeField[];
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* An inline table whose columns are defined directly in the schema (no linked doctype).
|
|
139
|
-
* Use when the table data does not warrant a separate doctype.
|
|
140
|
-
* @public
|
|
141
|
-
*/
|
|
142
|
-
export interface TableField {
|
|
143
|
-
/** Discriminator — identifies this as an inline table */
|
|
144
|
-
kind: 'table';
|
|
145
|
-
/** Unique identifier for this table within its doctype */
|
|
146
|
-
fieldname: string;
|
|
147
|
-
/** Vue component to render this table. Defaults to `'ATable'` in resolveSchema. */
|
|
148
|
-
component?: string;
|
|
149
|
-
/** Human-readable label */
|
|
150
|
-
label?: string;
|
|
151
|
-
/** Column definitions — use ColumnSchema (fieldname key) from \@stonecrop/schema */
|
|
152
|
-
columns: ColumnSchema[];
|
|
153
|
-
/** View configuration — defaults to `{ view: 'list' }` in resolveSchema when absent */
|
|
154
|
-
config?: TableViewConfig;
|
|
155
|
-
/** Interaction mode for all cells inside this table */
|
|
156
|
-
mode?: InteractionMode;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Union of all authoring-time field variants.
|
|
160
|
-
* Use `kind` to discriminate: `'field'` | `'fieldset'` | `'table'`.
|
|
161
|
-
* @public
|
|
162
|
-
*/
|
|
163
|
-
export type DoctypeField = ValueField | FieldsetField | TableField;
|
|
164
|
-
/**
|
|
165
|
-
* Which of the three field shapes an entry has, read from the entry's own structure.
|
|
166
|
-
*
|
|
167
|
-
* The single definition of that question. It had three copies before this — the parser's
|
|
168
|
-
* `injectKind`, {@link stripFieldKind}'s agreement check, and the docbuilder's own
|
|
169
|
-
* `isValueField` in another package — each free to drift, and drift here re-types a field rather
|
|
170
|
-
* than throwing: a value field read as a fieldset loses its column, a fieldset read as a value
|
|
171
|
-
* field loses every child.
|
|
172
|
-
*
|
|
173
|
-
* Deliberately **shape-only**: a declared `kind` is ignored. Two callers depend on that. The
|
|
174
|
-
* stripper compares this against the declaration to decide whether removing it is lossless, which
|
|
175
|
-
* it cannot do if this honours it. The docbuilder reads raw JSON off disk and classifies entries to
|
|
176
|
-
* decide which to render as editable rows — and `kind` is Stonecrop's own discriminant, not
|
|
177
|
-
* something a doctype author writes, so a tool reading a file has no business consulting it.
|
|
178
|
-
*
|
|
179
|
-
* `injectKind` is the one place a declaration still wins, and only to leave an already-parsed
|
|
180
|
-
* object untouched on its way back through.
|
|
181
|
-
*
|
|
182
|
-
* @param field - a field entry, authored or parsed
|
|
183
|
-
* @returns the kind its shape implies
|
|
184
|
-
* @public
|
|
185
|
-
*/
|
|
186
|
-
export declare function inferFieldKind(field: unknown): DoctypeField['kind'];
|
|
187
|
-
/**
|
|
188
|
-
* Recursively injects the `kind` discriminant into a raw field object and, for fieldsets,
|
|
189
|
-
* into each of its nested `schema` children — mirroring exactly what Zod's `preprocess`
|
|
190
|
-
* does at every level of the discriminated union.
|
|
191
|
-
*
|
|
192
|
-
* Table `columns` are {@link ColumnSchema} entries, not `DoctypeField`s, so they are left
|
|
193
|
-
* untouched — the Zod table schema validates them with a plain passthrough and never injects
|
|
194
|
-
* `kind` there either.
|
|
195
|
-
*
|
|
196
|
-
* Needed because `Doctype.fromObject` constructs a Doctype without running Zod, yet the
|
|
197
|
-
* registry's `resolveFields` gates link and fieldset handling on `field.kind`. Without this,
|
|
198
|
-
* a JSON-authored link resolves to a flat scalar and a fieldset's children are dropped.
|
|
199
|
-
*
|
|
200
|
-
* @public
|
|
201
|
-
*/
|
|
202
|
-
export declare function normalizeFieldKind(field: unknown): unknown;
|
|
203
|
-
/**
|
|
204
|
-
* Remove the `kind` discriminant from a field, recursing into a fieldset's children.
|
|
205
|
-
*
|
|
206
|
-
* The outbound half of the boundary {@link normalizeFieldKind} owns inbound. `kind` is a
|
|
207
|
-
* discriminated-union tag the parser synthesizes, not something an author writes, so nothing that
|
|
208
|
-
* *writes* a doctype should put it on disk — the generator and the docbuilder's save both call
|
|
209
|
-
* this. Without it the two round-trip asymmetrically: every save adds a key the file never had.
|
|
210
|
-
*
|
|
211
|
-
* Strips only when `injectKind` would restore exactly what was removed. A fieldset carrying no
|
|
212
|
-
* `schema` re-infers as a plain field, so its `kind` is kept rather than silently re-typing the
|
|
213
|
-
* document; `DoctypeMeta` requires `schema` on a fieldset, so that shape is already invalid and
|
|
214
|
-
* belongs to the load gate, not here.
|
|
215
|
-
*
|
|
216
|
-
* Table `columns` are {@link ColumnSchema} entries rather than `DoctypeField`s and never carry an
|
|
217
|
-
* injected `kind`, so they are passed through untouched — the same asymmetry `injectKind` has.
|
|
218
|
-
*
|
|
219
|
-
* @param field - a field object, as held in memory after parsing
|
|
220
|
-
* @returns the field without `kind`, safe to serialize
|
|
221
|
-
* @public
|
|
222
|
-
*/
|
|
223
|
-
export declare function stripFieldKind(field: unknown): unknown;
|
|
224
|
-
/**
|
|
225
|
-
* The field properties a `source: 'introspected'` marker freezes — the ones the database owns.
|
|
226
|
-
*
|
|
227
|
-
* This is the single definition of the identity set. The docbuilder greys these inputs on an
|
|
228
|
-
* introspected field, and the converter's merge refuses to rewrite them. Stating it twice is how
|
|
229
|
-
* the two drift, so both read this constant.
|
|
230
|
-
*
|
|
231
|
-
* Everything absent from this list is author-owned, `component` most importantly: it chooses the
|
|
232
|
-
* widget, which is an authoring decision the database has no opinion about.
|
|
233
|
-
*
|
|
234
|
-
* @public
|
|
235
|
-
*/
|
|
236
|
-
export declare const INTROSPECTED_IDENTITY_PROPS: readonly ["fieldname", "primaryKey", "required", "options", "cardinality", "doctype"];
|
|
237
|
-
/**
|
|
238
|
-
* Find the field a doctype marks as its primary key, or `undefined` when none is marked.
|
|
239
|
-
*
|
|
240
|
-
* This is the single definition of "which field identifies a record". Both sides depend on it:
|
|
241
|
-
* the middleware builds the SQL identity predicate from it, and the client resolves a record's
|
|
242
|
-
* route/store key from it. Call this; never re-derive the rule at the call site, or the two will
|
|
243
|
-
* drift and the client will key records by a column the server never queried.
|
|
244
|
-
*
|
|
245
|
-
* Two deliberate rules, both matching the shape `primaryKey` actually has:
|
|
246
|
-
* - Fieldset children are **included**, via {@link flattenFields}. A fieldset is layout, not
|
|
247
|
-
* scope: its children are fields of the doctype with columns of their own, which is why the
|
|
248
|
-
* adapter's SELECT already descends and why `getDisplayField` does too. Scanning top level only
|
|
249
|
-
* did not *refuse* a nested declaration — it ignored one, so an author marked identity and
|
|
250
|
-
* nothing honoured it and nothing said so.
|
|
251
|
-
* - The **first** match in document order wins. Identity is single-valued by design — a doctype
|
|
252
|
-
* describes the API surface, and mapping a composite database key onto one identity there is the
|
|
253
|
-
* adapter's job — so a doctype declaring several is malformed rather than composite.
|
|
254
|
-
* `DoctypeMeta` rejects that at the load gate; this stays total for callers holding fields that
|
|
255
|
-
* never went through it.
|
|
256
|
-
*
|
|
257
|
-
* @param fields - the doctype's fields; fieldset children are descended into
|
|
258
|
-
* @returns the primary-key field, or `undefined` for a PK-less doctype
|
|
259
|
-
* @public
|
|
260
|
-
*/
|
|
261
|
-
export declare function getPrimaryKeyField(fields: readonly DoctypeField[]): ValueField | undefined;
|
|
262
|
-
/**
|
|
263
|
-
* Resolve the field a doctype nominates as its display text, or `undefined` when the nomination
|
|
264
|
-
* does not name a readable column.
|
|
265
|
-
*
|
|
266
|
-
* This is the single definition of "is this a usable `displayField`". Both sides depend on it:
|
|
267
|
-
* `DoctypeMeta` refuses a bad nomination at the load gate, and the adapter builds a SELECT from
|
|
268
|
-
* the field it returns. Call this; never re-derive the rule, or the gate and the query will
|
|
269
|
-
* disagree about which nominations are legal — which they did, in both directions at once.
|
|
270
|
-
*
|
|
271
|
-
* Two things disqualify a nomination, and both are the doctype saying so itself:
|
|
272
|
-
* - it names no field at all, fieldset children included
|
|
273
|
-
* - it names a `computed` field, which is declared precisely to state it has no column, so a
|
|
274
|
-
* SELECT built from it would reference a column the database does not have
|
|
275
|
-
*
|
|
276
|
-
* @param fields - the doctype's top-level fields
|
|
277
|
-
* @param displayField - the nominated fieldname
|
|
278
|
-
* @returns the nominated field, or `undefined` when it is not a readable column
|
|
279
|
-
* @public
|
|
280
|
-
*/
|
|
281
|
-
export declare function getDisplayField(fields: readonly DoctypeField[], displayField: string | undefined): ValueField | undefined;
|
|
282
|
-
/**
|
|
283
|
-
* The name of the field a record is identified by: the declared `primaryKey`, or `id` when the
|
|
284
|
-
* doctype declares none.
|
|
285
|
-
*
|
|
286
|
-
* The `id` fallback is load-bearing, not defensive — a surrogate-key doctype carries an `id`
|
|
287
|
-
* column and marks no primary key, so "nothing declared" means `id`, not "no identity".
|
|
288
|
-
*
|
|
289
|
-
* This exists because that one-line rule had been restated at four sites — the client's
|
|
290
|
-
* `Doctype.recordIdField`, both nuxt hosts' `recordLookupField`, and the Postgres adapter — and
|
|
291
|
-
* the fourth had omitted the fallback, so a doctype the client keyed by `id` was one the adapter
|
|
292
|
-
* could not look up at all. Call this; a fifth restatement is how they diverge again.
|
|
293
|
-
*
|
|
294
|
-
* The returned name is not guaranteed to be a declared field: a doctype that declares no
|
|
295
|
-
* `primaryKey` and no `id` yields `'id'` regardless. An adapter that must build a SQL predicate
|
|
296
|
-
* from it has to confirm the field exists and say so when it does not, because selecting a column
|
|
297
|
-
* the doctype never declared returns nothing rather than failing.
|
|
298
|
-
*
|
|
299
|
-
* @param fields - the doctype's top-level fields
|
|
300
|
-
* @returns the identifying fieldname
|
|
301
|
-
* @public
|
|
302
|
-
*/
|
|
303
|
-
export declare function getRecordIdField(fields: readonly DoctypeField[]): string;
|
|
304
|
-
/**
|
|
305
|
-
* Resolve a record's identity value using the doctype's declared primary key.
|
|
306
|
-
*
|
|
307
|
-
* Falls back to `record.id` when the doctype declares no `primaryKey`. That fallback is
|
|
308
|
-
* load-bearing, not defensive: surrogate-key doctypes carry an `id` column and never mark a
|
|
309
|
-
* primary key, and PostGraphile renames a single-column `id` PK to `rowId` — so the declared
|
|
310
|
-
* field and `id` are both real sources, in that order.
|
|
311
|
-
*
|
|
312
|
-
* @param fields - the doctype's top-level fields
|
|
313
|
-
* @param record - the record to read the identity from
|
|
314
|
-
* @returns the identity as a string, or `undefined` when neither source yields a usable value
|
|
315
|
-
* @public
|
|
316
|
-
*/
|
|
317
|
-
export declare function getRecordIdentity(fields: readonly DoctypeField[], record: Record<string, unknown>): string | undefined;
|
|
318
|
-
/**
|
|
319
|
-
* Zod runtime validation schema for ValueField.
|
|
320
|
-
* @public
|
|
321
|
-
*/
|
|
322
|
-
export declare const ValueFieldSchema: z.ZodObject<{
|
|
323
|
-
kind: z.ZodLiteral<"field">;
|
|
324
|
-
fieldname: z.ZodString;
|
|
325
|
-
component: z.ZodString;
|
|
326
|
-
primaryKey: z.ZodOptional<z.ZodBoolean>;
|
|
327
|
-
computed: z.ZodOptional<z.ZodBoolean>;
|
|
328
|
-
language: z.ZodOptional<z.ZodString>;
|
|
329
|
-
doctype: z.ZodOptional<z.ZodString>;
|
|
330
|
-
label: z.ZodOptional<z.ZodString>;
|
|
331
|
-
width: z.ZodOptional<z.ZodString>;
|
|
332
|
-
height: z.ZodOptional<z.ZodString>;
|
|
333
|
-
align: z.ZodOptional<z.ZodEnum<{
|
|
334
|
-
left: "left";
|
|
335
|
-
right: "right";
|
|
336
|
-
center: "center";
|
|
337
|
-
start: "start";
|
|
338
|
-
end: "end";
|
|
339
|
-
}>>;
|
|
340
|
-
edit: z.ZodOptional<z.ZodBoolean>;
|
|
341
|
-
mask: z.ZodOptional<z.ZodString>;
|
|
342
|
-
format: z.ZodOptional<z.ZodString>;
|
|
343
|
-
mode: z.ZodOptional<z.ZodEnum<{
|
|
344
|
-
edit: "edit";
|
|
345
|
-
read: "read";
|
|
346
|
-
display: "display";
|
|
347
|
-
}>>;
|
|
348
|
-
options: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
349
|
-
required: z.ZodOptional<z.ZodBoolean>;
|
|
350
|
-
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
351
|
-
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
352
|
-
default: z.ZodOptional<z.ZodUnknown>;
|
|
353
|
-
validation: z.ZodOptional<z.ZodObject<{
|
|
354
|
-
errorMessage: z.ZodString;
|
|
355
|
-
}, z.core.$loose>>;
|
|
356
|
-
cardinality: z.ZodOptional<z.ZodEnum<{
|
|
357
|
-
atMostOne: "atMostOne";
|
|
358
|
-
one: "one";
|
|
359
|
-
noneOrMany: "noneOrMany";
|
|
360
|
-
atLeastOne: "atLeastOne";
|
|
361
|
-
}>>;
|
|
362
|
-
source: z.ZodOptional<z.ZodLiteral<"introspected">>;
|
|
363
|
-
}, z.core.$strip>;
|
|
364
|
-
/**
|
|
365
|
-
* Zod runtime validation schema for FieldsetField.
|
|
366
|
-
* Recursive — FieldsetField.schema is validated against DoctypeFieldSchema.
|
|
367
|
-
* @public
|
|
368
|
-
*/
|
|
369
|
-
export declare const FieldsetFieldSchema: z.ZodObject<{
|
|
370
|
-
kind: z.ZodLiteral<"fieldset">;
|
|
371
|
-
fieldname: z.ZodString;
|
|
372
|
-
component: z.ZodOptional<z.ZodString>;
|
|
373
|
-
label: z.ZodOptional<z.ZodString>;
|
|
374
|
-
collapsible: z.ZodOptional<z.ZodBoolean>;
|
|
375
|
-
mode: z.ZodOptional<z.ZodEnum<{
|
|
376
|
-
edit: "edit";
|
|
377
|
-
read: "read";
|
|
378
|
-
display: "display";
|
|
379
|
-
}>>;
|
|
380
|
-
schema: z.ZodLazy<z.ZodArray<z.ZodType<DoctypeField, unknown, z.core.$ZodTypeInternals<DoctypeField, unknown>>>>;
|
|
381
|
-
}, z.core.$strip>;
|
|
382
|
-
/**
|
|
383
|
-
* Zod runtime validation schema for TableField.
|
|
384
|
-
* @public
|
|
385
|
-
*/
|
|
386
|
-
export declare const TableFieldSchema: z.ZodObject<{
|
|
387
|
-
kind: z.ZodLiteral<"table">;
|
|
388
|
-
fieldname: z.ZodString;
|
|
389
|
-
component: z.ZodOptional<z.ZodString>;
|
|
390
|
-
label: z.ZodOptional<z.ZodString>;
|
|
391
|
-
columns: z.ZodArray<z.ZodObject<{
|
|
392
|
-
fieldname: z.ZodString;
|
|
393
|
-
}, z.core.$loose>>;
|
|
394
|
-
config: z.ZodOptional<z.ZodObject<{
|
|
395
|
-
view: z.ZodOptional<z.ZodEnum<{
|
|
396
|
-
list: "list";
|
|
397
|
-
uncounted: "uncounted";
|
|
398
|
-
"list-expansion": "list-expansion";
|
|
399
|
-
tree: "tree";
|
|
400
|
-
gantt: "gantt";
|
|
401
|
-
"tree-gantt": "tree-gantt";
|
|
402
|
-
}>>;
|
|
403
|
-
fullWidth: z.ZodOptional<z.ZodBoolean>;
|
|
404
|
-
defaultTreeExpansion: z.ZodOptional<z.ZodEnum<{
|
|
405
|
-
root: "root";
|
|
406
|
-
branch: "branch";
|
|
407
|
-
leaf: "leaf";
|
|
408
|
-
}>>;
|
|
409
|
-
dependencyGraph: z.ZodOptional<z.ZodBoolean>;
|
|
410
|
-
}, z.core.$strip>>;
|
|
411
|
-
mode: z.ZodOptional<z.ZodEnum<{
|
|
412
|
-
edit: "edit";
|
|
413
|
-
read: "read";
|
|
414
|
-
display: "display";
|
|
415
|
-
}>>;
|
|
416
|
-
}, z.core.$strip>;
|
|
417
|
-
/**
|
|
418
|
-
* Zod runtime validation schema for the DoctypeField discriminated union.
|
|
419
|
-
* Validates all three field variants: `'field'`, `'fieldset'`, `'table'`.
|
|
420
|
-
* @public
|
|
421
|
-
*/
|
|
422
|
-
export declare const DoctypeFieldSchema: z.ZodType<DoctypeField, unknown, z.core.$ZodTypeInternals<DoctypeField, unknown>>;
|
|
423
|
-
//# sourceMappingURL=field.d.ts.map
|
package/dist/src/field.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../src/field.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAIzC,OAAO,EAAE,aAAa,EAAE,CAAA;AAExB;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,wFAQtB,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AAEvD;;;GAGG;AACH,eAAO,MAAM,eAAe;;iBAQzB,CAAA;AAEH;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAM7D;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B,+DAA+D;IAC/D,IAAI,EAAE,OAAO,CAAA;IACb,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB,0EAA0E;IAC1E,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;kFAC8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;;;OAOG;IACH,OAAO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