@atscript/ui 0.1.58
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/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/index.cjs +1643 -0
- package/dist/index.d.cts +862 -0
- package/dist/index.d.mts +862 -0
- package/dist/index.mjs +1498 -0
- package/dist/plugin.cjs +515 -0
- package/dist/plugin.d.cts +18 -0
- package/dist/plugin.d.mts +19 -0
- package/dist/plugin.mjs +515 -0
- package/package.json +68 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,862 @@
|
|
|
1
|
+
import { TAtscriptAnnotatedType, TAtscriptDataType, TSerializedAnnotatedType, TValidatorOptions, TValidatorPlugin } from "@atscript/typescript/utils";
|
|
2
|
+
import { Client, TCrudOp, TCrudPermissions, TCrudPermissions as TCrudPermissions$1, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionLevel, TDbActionProcessor } from "@atscript/db-client";
|
|
3
|
+
|
|
4
|
+
//#region src/shared/annotation-keys.d.ts
|
|
5
|
+
declare const UI_TYPE: "ui.type";
|
|
6
|
+
declare const UI_FORM_PLACEHOLDER: "ui.form.placeholder";
|
|
7
|
+
declare const UI_FORM_HINT: "ui.form.hint";
|
|
8
|
+
declare const UI_FORM_CLASSES: "ui.form.classes";
|
|
9
|
+
declare const UI_FORM_STYLES: "ui.form.styles";
|
|
10
|
+
declare const UI_FORM_AUTOCOMPLETE: "ui.form.autocomplete";
|
|
11
|
+
declare const UI_FORM_DISABLED: "ui.form.disabled";
|
|
12
|
+
declare const UI_FORM_OPTIONS: "ui.form.options";
|
|
13
|
+
declare const UI_FORM_ORDER: "ui.form.order";
|
|
14
|
+
declare const UI_FORM_TYPE: "ui.form.type";
|
|
15
|
+
declare const UI_FORM_COMPONENT: "ui.form.component";
|
|
16
|
+
declare const UI_FORM_HIDDEN: "ui.form.hidden";
|
|
17
|
+
declare const UI_FORM_ATTR: "ui.form.attr";
|
|
18
|
+
declare const UI_FORM_GRID_COL_SPAN: "ui.form.grid.colSpan";
|
|
19
|
+
declare const UI_FORM_GRID_ROW_SPAN: "ui.form.grid.rowSpan";
|
|
20
|
+
declare const UI_FORM_SUBMIT_TEXT: "ui.form.submit.text";
|
|
21
|
+
declare const UI_FORM_LABEL_SINGULAR: "ui.form.label.singular";
|
|
22
|
+
declare const UI_FORM_ACTION: "ui.form.action";
|
|
23
|
+
declare const UI_FORM_PREFIX: "ui.form.prefix";
|
|
24
|
+
declare const UI_FORM_PREFIX_REF: "ui.form.prefix.ref";
|
|
25
|
+
declare const UI_FORM_PREFIX_ICON: "ui.form.prefix.icon";
|
|
26
|
+
declare const UI_FORM_SUFFIX: "ui.form.suffix";
|
|
27
|
+
declare const UI_FORM_SUFFIX_REF: "ui.form.suffix.ref";
|
|
28
|
+
declare const UI_FORM_SUFFIX_ICON: "ui.form.suffix.icon";
|
|
29
|
+
declare const UI_TABLE_WIDTH: "ui.table.width";
|
|
30
|
+
declare const UI_TABLE_COMPONENT: "ui.table.component";
|
|
31
|
+
declare const UI_TABLE_HIDDEN: "ui.table.hidden";
|
|
32
|
+
declare const UI_TABLE_ATTR: "ui.table.attr";
|
|
33
|
+
declare const UI_TABLE_CLASSES: "ui.table.classes";
|
|
34
|
+
declare const UI_TABLE_STYLES: "ui.table.styles";
|
|
35
|
+
declare const UI_TABLE_TYPE: "ui.table.type";
|
|
36
|
+
declare const UI_TABLE_ORDER: "ui.table.order";
|
|
37
|
+
declare const UI_DICT_LABEL: "ui.dict.label";
|
|
38
|
+
declare const UI_DICT_DESCR: "ui.dict.descr";
|
|
39
|
+
declare const UI_DICT_ATTR: "ui.dict.attr";
|
|
40
|
+
declare const UI_DICT_FILTERABLE: "ui.dict.filterable";
|
|
41
|
+
declare const UI_DICT_SORTABLE: "ui.dict.sortable";
|
|
42
|
+
declare const UI_DICT_SEARCHABLE: "ui.dict.searchable";
|
|
43
|
+
declare const DB_REL_FK: "db.rel.FK";
|
|
44
|
+
declare const DB_HTTP_PATH: "db.http.path";
|
|
45
|
+
declare const DB_AMOUNT_CURRENCY: "db.amount.currency";
|
|
46
|
+
declare const DB_AMOUNT_CURRENCY_REF: "db.amount.currency.ref";
|
|
47
|
+
declare const DB_UNIT: "db.unit";
|
|
48
|
+
declare const DB_UNIT_REF: "db.unit.ref";
|
|
49
|
+
declare const DB_COLUMN_PRECISION: "db.column.precision";
|
|
50
|
+
declare const WF_ACTION_WITH_DATA: "wf.action.withData";
|
|
51
|
+
declare const META_LABEL: "meta.label";
|
|
52
|
+
declare const META_ID: "meta.id";
|
|
53
|
+
declare const META_DESCRIPTION: "meta.description";
|
|
54
|
+
declare const META_READONLY: "meta.readonly";
|
|
55
|
+
declare const META_REQUIRED: "meta.required";
|
|
56
|
+
declare const META_DEFAULT: "meta.default";
|
|
57
|
+
declare const META_SENSITIVE: "meta.sensitive";
|
|
58
|
+
declare const EXPECT_MAX_LENGTH: "expect.maxLength";
|
|
59
|
+
declare const UI_FORM_FN_PREFIX: "ui.form.fn.";
|
|
60
|
+
declare const UI_FORM_FN_LABEL: "ui.form.fn.label";
|
|
61
|
+
declare const UI_FORM_FN_PLACEHOLDER: "ui.form.fn.placeholder";
|
|
62
|
+
declare const UI_FORM_FN_DESCRIPTION: "ui.form.fn.description";
|
|
63
|
+
declare const UI_FORM_FN_HINT: "ui.form.fn.hint";
|
|
64
|
+
declare const UI_FORM_FN_HIDDEN: "ui.form.fn.hidden";
|
|
65
|
+
declare const UI_FORM_FN_DISABLED: "ui.form.fn.disabled";
|
|
66
|
+
declare const UI_FORM_FN_READONLY: "ui.form.fn.readonly";
|
|
67
|
+
declare const UI_FORM_FN_OPTIONS: "ui.form.fn.options";
|
|
68
|
+
declare const UI_FORM_FN_ATTR: "ui.form.fn.attr";
|
|
69
|
+
declare const UI_FORM_FN_VALUE: "ui.form.fn.value";
|
|
70
|
+
declare const UI_FORM_FN_CLASSES: "ui.form.fn.classes";
|
|
71
|
+
declare const UI_FORM_FN_STYLES: "ui.form.fn.styles";
|
|
72
|
+
declare const UI_FORM_FN_TITLE: "ui.form.fn.title";
|
|
73
|
+
declare const UI_FORM_FN_SUBMIT_TEXT: "ui.form.fn.submit.text";
|
|
74
|
+
declare const UI_FORM_FN_SUBMIT_DISABLED: "ui.form.fn.submit.disabled";
|
|
75
|
+
declare const UI_TABLE_FN_PREFIX: "ui.table.fn.";
|
|
76
|
+
declare const UI_TABLE_FN_ATTR: "ui.table.fn.attr";
|
|
77
|
+
declare const UI_TABLE_FN_CLASSES: "ui.table.fn.classes";
|
|
78
|
+
declare const UI_TABLE_FN_STYLES: "ui.table.fn.styles";
|
|
79
|
+
declare const UI_FORM_VALIDATE: "ui.form.validate";
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/value-help/types.d.ts
|
|
82
|
+
/** An option for select/radio fields — either a plain string or a `{ key, label }` pair. */
|
|
83
|
+
type TFormEntryOptions = {
|
|
84
|
+
key: string;
|
|
85
|
+
label: string;
|
|
86
|
+
} | string;
|
|
87
|
+
/**
|
|
88
|
+
* Minimal sync probe output for a value-help–eligible prop.
|
|
89
|
+
*
|
|
90
|
+
* Emitted by `extractValueHelp(prop)` at def-construction time. Consumers use
|
|
91
|
+
* `url` to key the lazy resolver (`resolveValueHelp(url)`) that fetches the
|
|
92
|
+
* target's own `/meta` endpoint and returns the field-role details.
|
|
93
|
+
*/
|
|
94
|
+
interface ValueHelpInfo {
|
|
95
|
+
/** HTTP path to the value-help target (from the target's `@db.http.path`). */
|
|
96
|
+
url: string;
|
|
97
|
+
/**
|
|
98
|
+
* Field on the target that this FK references (from `prop.ref.field`, e.g. "id").
|
|
99
|
+
* This is the value committed to the FK field when the user picks a row.
|
|
100
|
+
*/
|
|
101
|
+
targetField: string;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/form/types.d.ts
|
|
105
|
+
/** Form action metadata — the action id and display label. */
|
|
106
|
+
interface TFormAction {
|
|
107
|
+
id: string;
|
|
108
|
+
label: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A single form field definition — thin pointer to the ATScript prop.
|
|
112
|
+
*
|
|
113
|
+
* All metadata (label, disabled, options, etc.) lives in `prop.metadata`
|
|
114
|
+
* and is resolved on demand via resolve utilities.
|
|
115
|
+
*/
|
|
116
|
+
interface FormFieldDef {
|
|
117
|
+
/** Dot-separated path relative to the parent data context. `''` = root. */
|
|
118
|
+
path: string;
|
|
119
|
+
prop: TAtscriptAnnotatedType;
|
|
120
|
+
/**
|
|
121
|
+
* Render-key the renderer dispatches on. For structured kinds (array,
|
|
122
|
+
* object, tuple, multi-variant union) this stays the kind name so that
|
|
123
|
+
* `isArrayField`/`isObjectField`/`isUnionField`/`isTupleField` keep
|
|
124
|
+
* working downstream (validator resetValue, child path provide, AsArray
|
|
125
|
+
* recursion). Primitives may store an `@ui.form.type`/`@ui.type`
|
|
126
|
+
* override here directly — for those there is no structural behaviour
|
|
127
|
+
* to preserve.
|
|
128
|
+
*/
|
|
129
|
+
type: string;
|
|
130
|
+
/**
|
|
131
|
+
* Optional `@ui.form.type` (or `@ui.type`) override for structured
|
|
132
|
+
* kinds. When set, the renderer looks this up in the `types` map FIRST
|
|
133
|
+
* and falls back to `type` only when the map has no entry. Letting the
|
|
134
|
+
* override live in a separate field keeps the structural type guards
|
|
135
|
+
* (`isArrayField` et al.) on `type` honest while still allowing a
|
|
136
|
+
* consumer to attach a flat custom widget to e.g. a `string[]`.
|
|
137
|
+
*/
|
|
138
|
+
customType?: string;
|
|
139
|
+
phantom: boolean;
|
|
140
|
+
name: string;
|
|
141
|
+
/** True when no `ui.fn.*` metadata keys exist. Vue perf flag. */
|
|
142
|
+
allStatic: boolean;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Complete form definition — produced by createFormDef().
|
|
146
|
+
* Form-level metadata (title, submit) resolved on demand via resolveFormProp.
|
|
147
|
+
*/
|
|
148
|
+
interface FormDef {
|
|
149
|
+
type: TAtscriptAnnotatedType;
|
|
150
|
+
/** Root field representing the entire form. For interface types this is `type='object'`; for single-type forms it is a leaf field. */
|
|
151
|
+
rootField: FormFieldDef;
|
|
152
|
+
fields: FormFieldDef[];
|
|
153
|
+
flatMap: Map<string, TAtscriptAnnotatedType>;
|
|
154
|
+
}
|
|
155
|
+
/** One branch of a union type — used by union fields and union array items. */
|
|
156
|
+
interface FormUnionVariant {
|
|
157
|
+
/** Display label — from @meta.label or auto-generated (e.g. "1. String") */
|
|
158
|
+
label: string;
|
|
159
|
+
/** The annotated type for this variant */
|
|
160
|
+
type: TAtscriptAnnotatedType;
|
|
161
|
+
/** Pre-built FormDef for object variants (undefined for primitives) */
|
|
162
|
+
def?: FormDef;
|
|
163
|
+
/** Pre-built field def for primitive variants (undefined for objects) */
|
|
164
|
+
itemField?: FormFieldDef;
|
|
165
|
+
/** Design type for primitive variants ('string', 'number', 'boolean') */
|
|
166
|
+
designType?: string;
|
|
167
|
+
}
|
|
168
|
+
/** Extended field def for array-typed fields. */
|
|
169
|
+
interface FormArrayFieldDef extends FormFieldDef {
|
|
170
|
+
/** ATScript annotated type of array items (from TAtscriptTypeArray.of) */
|
|
171
|
+
itemType: TAtscriptAnnotatedType;
|
|
172
|
+
/** Pre-built template field def for items (path=''). */
|
|
173
|
+
itemField: FormFieldDef;
|
|
174
|
+
}
|
|
175
|
+
/** Extended field def for object (interface/type) nested fields. */
|
|
176
|
+
interface FormObjectFieldDef extends FormFieldDef {
|
|
177
|
+
/** Pre-built FormDef for the nested object's fields */
|
|
178
|
+
objectDef: FormDef;
|
|
179
|
+
}
|
|
180
|
+
/** Extended field def for union fields — standalone union props and union array items. */
|
|
181
|
+
interface FormUnionFieldDef extends FormFieldDef {
|
|
182
|
+
/** Available union branches. */
|
|
183
|
+
unionVariants: FormUnionVariant[];
|
|
184
|
+
}
|
|
185
|
+
/** Extended field def for tuple fields — fixed-length with typed positions. */
|
|
186
|
+
interface FormTupleFieldDef extends FormFieldDef {
|
|
187
|
+
/** Pre-built field defs, one per tuple position. */
|
|
188
|
+
itemFields: FormFieldDef[];
|
|
189
|
+
}
|
|
190
|
+
/** Type guard: checks if a field def is an array field. */
|
|
191
|
+
declare function isArrayField(field: FormFieldDef): field is FormArrayFieldDef;
|
|
192
|
+
/** Type guard: checks if a field def is an object field. */
|
|
193
|
+
declare function isObjectField(field: FormFieldDef): field is FormObjectFieldDef;
|
|
194
|
+
/** Type guard: checks if a field def is a union field. */
|
|
195
|
+
declare function isUnionField(field: FormFieldDef): field is FormUnionFieldDef;
|
|
196
|
+
/** Type guard: checks if a field def is a tuple field. */
|
|
197
|
+
declare function isTupleField(field: FormFieldDef): field is FormTupleFieldDef;
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/form/create-form-def.d.ts
|
|
200
|
+
/**
|
|
201
|
+
* Converts an ATScript annotated type into a FormDef.
|
|
202
|
+
*
|
|
203
|
+
* - **Object types** (`kind === 'object'`): produces an object root with nested fields.
|
|
204
|
+
* - **Non-object types** (primitive, array, union, etc.): produces a single leaf root field
|
|
205
|
+
* with `path: ''`.
|
|
206
|
+
*/
|
|
207
|
+
declare function createFormDef(type: TAtscriptAnnotatedType): FormDef;
|
|
208
|
+
/**
|
|
209
|
+
* Builds union variant definitions from a union annotated type.
|
|
210
|
+
* Iterates top-level items directly — one variant per item.
|
|
211
|
+
*/
|
|
212
|
+
declare function buildUnionVariants(typeDef: TAtscriptAnnotatedType): FormUnionVariant[];
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/shared/field-resolver.d.ts
|
|
215
|
+
/** Options for field and form property resolution. */
|
|
216
|
+
interface TResolveOptions<T> {
|
|
217
|
+
/** When true, any non-undefined static value is returned as `true` (for boolean flags like ui.disabled). */
|
|
218
|
+
staticAsBoolean?: boolean;
|
|
219
|
+
/** Transform the raw static value before returning. */
|
|
220
|
+
transform?: (raw: unknown) => T;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Pluggable resolver interface for field/form metadata.
|
|
224
|
+
* @atscript/ui provides a static implementation (reads only static annotation values).
|
|
225
|
+
* ui-fns extends it with dynamic `new Function` compilation for `ui.fn.*` keys.
|
|
226
|
+
*/
|
|
227
|
+
interface FieldResolver {
|
|
228
|
+
/** Resolve a field-level metadata property. */
|
|
229
|
+
resolveFieldProp<T>(prop: TAtscriptAnnotatedType, fnKey: string, staticKey: string | undefined, scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
|
|
230
|
+
/** Resolve a form-level metadata property. */
|
|
231
|
+
resolveFormProp<T>(type: TAtscriptAnnotatedType, fnKey: string, staticKey: string | undefined, scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
|
|
232
|
+
/** Check if a prop has dynamic annotations (ui.fn.*). */
|
|
233
|
+
hasComputedAnnotations(prop: TAtscriptAnnotatedType): boolean;
|
|
234
|
+
}
|
|
235
|
+
/** Static resolver — ignores fn keys, reads only static metadata. */
|
|
236
|
+
declare class StaticFieldResolver implements FieldResolver {
|
|
237
|
+
resolveFieldProp<T>(prop: TAtscriptAnnotatedType, _fnKey: string, staticKey: string | undefined, _scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
|
|
238
|
+
resolveFormProp<T>(type: TAtscriptAnnotatedType, _fnKey: string, staticKey: string | undefined, _scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
|
|
239
|
+
hasComputedAnnotations(_prop: TAtscriptAnnotatedType): boolean;
|
|
240
|
+
}
|
|
241
|
+
/** Resolves a static metadata value. Exported for reuse by dynamic resolvers. */
|
|
242
|
+
declare function resolveStatic<T>(metadata: TAtscriptAnnotatedType["metadata"], staticKey: string | undefined, opts?: TResolveOptions<T>): T | undefined;
|
|
243
|
+
/** Default static resolver instance. */
|
|
244
|
+
declare const defaultResolver: StaticFieldResolver;
|
|
245
|
+
/** Replace the active resolver (called by ui-fns to install dynamic resolution). */
|
|
246
|
+
declare function setResolver(resolver: FieldResolver): void;
|
|
247
|
+
/** Get the current active resolver. */
|
|
248
|
+
declare function getResolver(): FieldResolver;
|
|
249
|
+
/** Resolve a field-level metadata property via the active resolver. */
|
|
250
|
+
declare function resolveFieldProp<T>(prop: TAtscriptAnnotatedType, fnKey: string, staticKey: string | undefined, scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
|
|
251
|
+
/** Resolve a form-level metadata property via the active resolver. */
|
|
252
|
+
declare function resolveFormProp<T>(type: TAtscriptAnnotatedType, fnKey: string, staticKey: string | undefined, scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
|
|
253
|
+
/** Check if a prop has dynamic annotations via the active resolver. */
|
|
254
|
+
declare function hasComputedAnnotations(prop: TAtscriptAnnotatedType): boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Reads a static metadata value from an ATScript prop.
|
|
257
|
+
* Typed overload for known AtscriptMetadata keys; falls back to `unknown` for other keys.
|
|
258
|
+
*/
|
|
259
|
+
declare function getFieldMeta<K extends keyof AtscriptMetadata>(prop: TAtscriptAnnotatedType, key: K): AtscriptMetadata[K] | undefined;
|
|
260
|
+
declare function getFieldMeta(prop: TAtscriptAnnotatedType, key: string): unknown;
|
|
261
|
+
/** Ensures a value is an array — returns as-is if already one, wraps in `[x]` otherwise. */
|
|
262
|
+
declare function asArray<T>(x: T | T[]): T[];
|
|
263
|
+
/**
|
|
264
|
+
* Parses static `ui.attr` metadata into a key-value record.
|
|
265
|
+
* Exported so ui-fns can reuse this without duplicating the parsing logic.
|
|
266
|
+
*/
|
|
267
|
+
declare function parseStaticAttrs(staticAttrs: unknown): Record<string, unknown> | undefined;
|
|
268
|
+
/** Per-surface attr key pair — defaults to the form-side keys. */
|
|
269
|
+
interface TResolveAttrsKeys {
|
|
270
|
+
staticKey?: string;
|
|
271
|
+
fnKey?: string;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Resolves `<staticKey>` + `<fnKey>` attr metadata on demand.
|
|
275
|
+
* Defaults read `ui.form.attr` + `ui.form.fn.attr`; pass `{ staticKey, fnKey }` to read
|
|
276
|
+
* the table-side pair (`ui.table.attr` + `ui.table.fn.attr`) or any other surface.
|
|
277
|
+
*/
|
|
278
|
+
declare function resolveAttrs(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>, keys?: TResolveAttrsKeys): Record<string, unknown> | undefined;
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/value-help/resolve.d.ts
|
|
281
|
+
/**
|
|
282
|
+
* Field-role + capability metadata for a value-help target, lazily resolved
|
|
283
|
+
* from the target's own `/meta` endpoint.
|
|
284
|
+
*/
|
|
285
|
+
interface ResolvedValueHelp {
|
|
286
|
+
url: string;
|
|
287
|
+
primaryKeys: string[];
|
|
288
|
+
labelField: string;
|
|
289
|
+
descrField: string | undefined;
|
|
290
|
+
attrFields: string[];
|
|
291
|
+
filterableFields: string[];
|
|
292
|
+
sortableFields: string[];
|
|
293
|
+
searchable: boolean;
|
|
294
|
+
targetType: TAtscriptAnnotatedType;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Lazily fetch and extract value-help metadata for the given URL.
|
|
298
|
+
*
|
|
299
|
+
* - Issues exactly one `GET {url}/meta` per URL across the session (shared via meta-cache).
|
|
300
|
+
* - Concurrent callers with the same URL share the in-flight promise.
|
|
301
|
+
* - If the underlying fetch rejects, the cache entry is evicted so a later
|
|
302
|
+
* retry performs a fresh fetch.
|
|
303
|
+
*/
|
|
304
|
+
declare function resolveValueHelp(url: string): Promise<ResolvedValueHelp>;
|
|
305
|
+
/** Thin alias over `resetMetaCache` — retained so existing test code keeps working. */
|
|
306
|
+
declare function resetValueHelpCache(): void;
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/value-help/value-help-client.d.ts
|
|
309
|
+
interface ValueHelpSearchOptions {
|
|
310
|
+
/** Search term. Empty or undefined returns all records. */
|
|
311
|
+
text?: string;
|
|
312
|
+
/** "form" = PK + label + descr; "filter" = all dict fields including attrs. Default: "form". */
|
|
313
|
+
mode?: "form" | "filter";
|
|
314
|
+
/** Max results. Default: 20. */
|
|
315
|
+
limit?: number;
|
|
316
|
+
/** Override the computed select fields. */
|
|
317
|
+
select?: string[];
|
|
318
|
+
}
|
|
319
|
+
interface ValueHelpResult {
|
|
320
|
+
items: Record<string, unknown>[];
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Value-help query client. Wraps a `Client` from `@atscript/db-client`
|
|
324
|
+
* with FK-specific search logic (regex fallback for non-searchable tables,
|
|
325
|
+
* $select scoping).
|
|
326
|
+
*
|
|
327
|
+
* Consumers resolve the target's metadata once via `resolveValueHelp(url)`
|
|
328
|
+
* and pass the resulting `ResolvedValueHelp` to `search()`. Label resolution
|
|
329
|
+
* for cells is deliberately unsupported — cells always display raw ids.
|
|
330
|
+
*/
|
|
331
|
+
declare class ValueHelpClient {
|
|
332
|
+
private readonly _client;
|
|
333
|
+
constructor(client: Client);
|
|
334
|
+
/**
|
|
335
|
+
* Search the target with value-help semantics.
|
|
336
|
+
*
|
|
337
|
+
* - If target is searchable → sends `$search` (server full-text)
|
|
338
|
+
* - If not searchable → sends `$or` regex across select fields + exact PK match
|
|
339
|
+
*/
|
|
340
|
+
search(resolved: ResolvedValueHelp, opts?: ValueHelpSearchOptions): Promise<ValueHelpResult>;
|
|
341
|
+
}
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/value-help/dict-paths.d.ts
|
|
344
|
+
/**
|
|
345
|
+
* Paths that make up the "dict view" of a value-help target:
|
|
346
|
+
* PKs + label + descr + attr fields. Used by filter dialogs to clamp
|
|
347
|
+
* visible columns to the dictionary subset.
|
|
348
|
+
*/
|
|
349
|
+
declare function valueHelpDictPaths(resolved: ResolvedValueHelp): Set<string>;
|
|
350
|
+
//#endregion
|
|
351
|
+
//#region src/value-help/extract-literals.d.ts
|
|
352
|
+
/**
|
|
353
|
+
* Extracts options from a union of literal types (e.g. 'a' | 'b' | 'c').
|
|
354
|
+
* Returns undefined if the type is not a pure union of literals.
|
|
355
|
+
*
|
|
356
|
+
* Handles nested unions created by flattenAnnotatedType, which recurses
|
|
357
|
+
* into union items and produces synthetic unions containing both individual
|
|
358
|
+
* literals and the original union type as nested items.
|
|
359
|
+
*/
|
|
360
|
+
declare function extractLiteralOptions(prop: TAtscriptAnnotatedType): {
|
|
361
|
+
key: string;
|
|
362
|
+
label: string;
|
|
363
|
+
}[] | undefined;
|
|
364
|
+
/** Returns true when the annotated type is a union composed entirely of literal values. */
|
|
365
|
+
declare function isPureLiteralUnion(prop: TAtscriptAnnotatedType): boolean;
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/value-help/extract-ref.d.ts
|
|
368
|
+
/**
|
|
369
|
+
* Synchronous probe. Returns `{ url, targetField }` iff:
|
|
370
|
+
* 1. the prop carries `@db.rel.FK`,
|
|
371
|
+
* 2. the prop has a `.ref`,
|
|
372
|
+
* 3. the ref's target metadata carries `@db.http.path`.
|
|
373
|
+
*/
|
|
374
|
+
declare function extractValueHelp(prop: TAtscriptAnnotatedType): ValueHelpInfo | undefined;
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/value-help/resolve-options.d.ts
|
|
377
|
+
/** Extracts the key from an option entry. */
|
|
378
|
+
declare function optKey(opt: TFormEntryOptions): string;
|
|
379
|
+
/** Extracts the display label from an option entry. */
|
|
380
|
+
declare function optLabel(opt: TFormEntryOptions): string;
|
|
381
|
+
/**
|
|
382
|
+
* Converts raw option annotation value to a normalized array.
|
|
383
|
+
*/
|
|
384
|
+
declare function parseStaticOptions(raw: unknown): TFormEntryOptions[];
|
|
385
|
+
/**
|
|
386
|
+
* Resolves options from metadata with a fallback chain:
|
|
387
|
+
* 1. `@ui.form.fn.options` (dynamic, compiled by ui-fns)
|
|
388
|
+
* 2. `@ui.form.options` (static annotation)
|
|
389
|
+
* 3. Literal union type extraction (auto-derived from type)
|
|
390
|
+
* 4. Future: dictionary / value-help lookup
|
|
391
|
+
*/
|
|
392
|
+
declare function resolveOptions(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>): TFormEntryOptions[] | undefined;
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/form/path-utils.d.ts
|
|
395
|
+
/**
|
|
396
|
+
* Gets a nested value by dot-separated path.
|
|
397
|
+
* Always dereferences `obj.value` first (form data is wrapped in `{ value: domainData }`).
|
|
398
|
+
* When `path` is empty, returns the root domain data (`obj.value`).
|
|
399
|
+
*/
|
|
400
|
+
declare function getByPath(obj: Record<string, unknown>, path: string): unknown;
|
|
401
|
+
/**
|
|
402
|
+
* Sets a nested value by dot-separated path.
|
|
403
|
+
* Always dereferences `obj.value` first (form data is wrapped in `{ value: domainData }`).
|
|
404
|
+
* When `path` is empty, sets the root domain data (`obj.value = value`).
|
|
405
|
+
* Creates intermediate objects if they do not exist.
|
|
406
|
+
*/
|
|
407
|
+
declare function setByPath(obj: Record<string, unknown>, path: string, value: unknown): void;
|
|
408
|
+
/** Value resolver function type — created once per form, reused across calls. */
|
|
409
|
+
type TFormValueResolver = (prop: TAtscriptAnnotatedType, path: string) => unknown;
|
|
410
|
+
declare function createFormValueResolver(data?: Record<string, unknown>, context?: Record<string, unknown>): TFormValueResolver;
|
|
411
|
+
declare function createFormData<T extends TAtscriptAnnotatedType>(type: T, resolver?: TFormValueResolver): {
|
|
412
|
+
value: TAtscriptDataType<T>;
|
|
413
|
+
};
|
|
414
|
+
declare function detectUnionVariant(value: unknown, variants: FormUnionVariant[]): number;
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/form/validate.d.ts
|
|
417
|
+
/** Per-call options for the form validator function. */
|
|
418
|
+
interface TFormValidatorCallOptions {
|
|
419
|
+
data: Record<string, unknown>;
|
|
420
|
+
context?: Record<string, unknown>;
|
|
421
|
+
}
|
|
422
|
+
/** Replace the default validator plugins applied to every form/field validator. */
|
|
423
|
+
declare function setDefaultValidatorPlugins(plugins: TValidatorPlugin[]): void;
|
|
424
|
+
/** Get the currently registered default validator plugins. */
|
|
425
|
+
declare function getDefaultValidatorPlugins(): TValidatorPlugin[];
|
|
426
|
+
/**
|
|
427
|
+
* Returns a reusable validator function for a whole FormDef.
|
|
428
|
+
*
|
|
429
|
+
* Validator is created once and reused on every call.
|
|
430
|
+
* ATScript's @expect.* validation runs automatically.
|
|
431
|
+
* For custom `ui.fn.*` validators, install ui-fns and pass its plugin via `opts.plugins`.
|
|
432
|
+
*/
|
|
433
|
+
declare function getFormValidator(def: FormDef, opts?: Partial<TValidatorOptions>): (callOpts: TFormValidatorCallOptions) => Record<string, string>;
|
|
434
|
+
/** Options for createFieldValidator. */
|
|
435
|
+
interface TFieldValidatorOptions {
|
|
436
|
+
/** Only report errors at the root path (for structure/array container validation). */
|
|
437
|
+
rootOnly?: boolean;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Creates a cached validator function for a single ATScript prop.
|
|
441
|
+
*
|
|
442
|
+
* The `Validator` instance is created lazily on first call and reused.
|
|
443
|
+
* Returns `true` when valid, or the first error message string when invalid.
|
|
444
|
+
*/
|
|
445
|
+
declare function createFieldValidator(prop: TAtscriptAnnotatedType, opts?: TFieldValidatorOptions): (value: unknown, externalCtx?: {
|
|
446
|
+
data: unknown;
|
|
447
|
+
context: unknown;
|
|
448
|
+
}) => true | string;
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/form/error-utils.d.ts
|
|
451
|
+
/**
|
|
452
|
+
* Framework-agnostic helpers for working with form-error maps keyed by
|
|
453
|
+
* dotted path. Used by AsForm to drive error badges and auto-open
|
|
454
|
+
* collapsed sections; safe to share with React (or any other) bindings.
|
|
455
|
+
*
|
|
456
|
+
* Convention:
|
|
457
|
+
* - Keys are dotted paths (`a.b.c`); empty string and `__form` denote
|
|
458
|
+
* the form-level error.
|
|
459
|
+
* - Values may be `string | undefined`; falsy entries are dropped on
|
|
460
|
+
* merge.
|
|
461
|
+
*/
|
|
462
|
+
/**
|
|
463
|
+
* Merge any number of partial error maps into a single dense
|
|
464
|
+
* `Record<path, message>`. Falsy values are skipped — later sources do
|
|
465
|
+
* NOT overwrite earlier ones with an empty value.
|
|
466
|
+
*/
|
|
467
|
+
declare function mergeErrorMaps(...maps: Array<Record<string, string | undefined> | undefined>): Record<string, string>;
|
|
468
|
+
/**
|
|
469
|
+
* Yield every ancestor prefix of a dotted path, longest-first
|
|
470
|
+
* (`a.b.c` → `a.b.c`, `a.b`, `a`). Returns the path itself first so
|
|
471
|
+
* callers can include it in the iteration without a special case.
|
|
472
|
+
*
|
|
473
|
+
* Empty paths and the form-level key (`__form`) yield nothing.
|
|
474
|
+
*/
|
|
475
|
+
declare function iteratePathAncestors(path: string): Generator<string>;
|
|
476
|
+
/**
|
|
477
|
+
* Build an indexed `Map<absolutePath, descendantErrorCount>` so each
|
|
478
|
+
* struct in the tree can render an error-count badge in O(1).
|
|
479
|
+
*
|
|
480
|
+
* For every error path, the count is incremented on the path itself
|
|
481
|
+
* AND every dotted-path ancestor — so a struct at `a.b` reports the
|
|
482
|
+
* total of all errors at `a.b` or below.
|
|
483
|
+
*/
|
|
484
|
+
declare function buildDescendantErrorCounts(errors: Record<string, string | undefined>): Map<string, number>;
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/form/grid.d.ts
|
|
487
|
+
/** Grid layout parsing for `@ui.form.grid.colSpan` / `@ui.form.grid.rowSpan`. */
|
|
488
|
+
declare const DEFAULT_COL_SPAN = 12;
|
|
489
|
+
declare const DEFAULT_ROW_SPAN = 1;
|
|
490
|
+
/** Accepts "1"-"12" and the aliases "full" (12), "half" (6), "third" (4). */
|
|
491
|
+
declare function parseColSpan(raw: string | undefined): number | undefined;
|
|
492
|
+
/** Accepts numeric strings "1"+; rejects "0", negatives, decimals, aliases. */
|
|
493
|
+
declare function parseRowSpan(raw: string | undefined): number | undefined;
|
|
494
|
+
interface GridSpec {
|
|
495
|
+
col: {
|
|
496
|
+
desktop: number;
|
|
497
|
+
narrow: number;
|
|
498
|
+
};
|
|
499
|
+
row: {
|
|
500
|
+
desktop: number;
|
|
501
|
+
narrow: number;
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Shape returned by `getFieldMeta(prop, UI_FORM_GRID_COL_SPAN | …ROW_SPAN)` —
|
|
506
|
+
* atscript codegen produces a struct from named multi-arg annotation specs.
|
|
507
|
+
*/
|
|
508
|
+
interface GridSpanArgs {
|
|
509
|
+
desktop: string;
|
|
510
|
+
narrow?: string;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Resolve a field's grid footprint. Narrow defaults to full-width / single-row
|
|
514
|
+
* regardless of the desktop value, so authors can opt into a narrow override
|
|
515
|
+
* via the second annotation arg without it inheriting an unintended desktop span.
|
|
516
|
+
*/
|
|
517
|
+
declare function resolveGridSpec(colSpan: GridSpanArgs | undefined, rowSpan: GridSpanArgs | undefined): GridSpec;
|
|
518
|
+
/**
|
|
519
|
+
* Build the UnoCSS class string for a field's grid footprint.
|
|
520
|
+
*
|
|
521
|
+
* - Skips desktop classes that match the default (`as-grid-item` already
|
|
522
|
+
* covers `col-span-full row-span-1`).
|
|
523
|
+
* - Skips narrow overrides that match the desktop value (no override needed).
|
|
524
|
+
* - The narrow variant uses the custom `as-narrow:` prefix, which the
|
|
525
|
+
* atscript-ui UnoCSS preset rewrites to `@container as-grid (max-width:
|
|
526
|
+
* 480px) { ... }`. The parent grid is registered as
|
|
527
|
+
* `container-name: as-grid` via the `as-form-grid` shortcut, so the
|
|
528
|
+
* rule resolves against the actual grid's inline size — not the viewport.
|
|
529
|
+
*
|
|
530
|
+
* Returned string is space-separated, ready to drop into a Vue class binding.
|
|
531
|
+
*/
|
|
532
|
+
declare function buildGridClasses(spec: GridSpec): string;
|
|
533
|
+
//#endregion
|
|
534
|
+
//#region src/form/labels.d.ts
|
|
535
|
+
/** Singular label for an array field (used by AsArray for "Add <singular>"). */
|
|
536
|
+
declare function resolveSingularLabel(meta: TAtscriptAnnotatedType | undefined): string;
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region src/form/measurement.d.ts
|
|
539
|
+
/**
|
|
540
|
+
* Resolved measurement annotations — currency / unit-of-measure / numeric
|
|
541
|
+
* precision. Read once at form/table-def construction time and surfaced as
|
|
542
|
+
* already-resolved values so downstream renderers (cells, default form
|
|
543
|
+
* components, custom inputs) never re-read annotation metadata.
|
|
544
|
+
*/
|
|
545
|
+
interface MeasurementInfo {
|
|
546
|
+
/** Literal currency code from `@db.amount.currency 'EUR'`. */
|
|
547
|
+
currencyCode?: string;
|
|
548
|
+
/** Sibling-field path from `@db.amount.currency.ref 'fieldName'`. */
|
|
549
|
+
currencyRefField?: string;
|
|
550
|
+
/** Literal unit-of-measure from `@db.unit 'kg'`. */
|
|
551
|
+
unitCode?: string;
|
|
552
|
+
/** Sibling-field path from `@db.unit.ref 'fieldName'`. */
|
|
553
|
+
unitRefField?: string;
|
|
554
|
+
/** Decimal scale (fraction digits) — second arg of `@db.column.precision precision, scale`. */
|
|
555
|
+
precisionScale?: number;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Read measurement annotations off a single field prop. Returns `undefined`
|
|
559
|
+
* for any annotation that's absent — callers can spread the result into a
|
|
560
|
+
* larger record.
|
|
561
|
+
*/
|
|
562
|
+
declare function extractMeasurement(prop: TAtscriptAnnotatedType): MeasurementInfo;
|
|
563
|
+
//#endregion
|
|
564
|
+
//#region src/form/decimal-format.d.ts
|
|
565
|
+
/**
|
|
566
|
+
* Framework-agnostic decimal formatting + parsing helpers shared by
|
|
567
|
+
* `@atscript/vue-table` (read-only cell display) and `@atscript/vue-form`
|
|
568
|
+
* (editable amount/measure inputs). Symmetric output is the contract —
|
|
569
|
+
* a value rendered in a cell must read identically when displayed in
|
|
570
|
+
* the form composables, modulo currency / unit adornment.
|
|
571
|
+
*
|
|
572
|
+
* The functions here are intentionally pure (no `Number()` round-trips
|
|
573
|
+
* in the storage value path) — decimal-as-string correctness depends on
|
|
574
|
+
* not bouncing through floats.
|
|
575
|
+
*/
|
|
576
|
+
interface CurrencyDisplay {
|
|
577
|
+
/** Narrow symbol: "$" / "€" / "US$" depending on locale. Falls back to code on Intl failure. */
|
|
578
|
+
symbol: string;
|
|
579
|
+
/** Whether the symbol typically sits left or right of the amount. */
|
|
580
|
+
position: "prefix" | "suffix";
|
|
581
|
+
}
|
|
582
|
+
interface DecimalParts {
|
|
583
|
+
sign: "" | "-";
|
|
584
|
+
/** Integer part, no thousands separator, no leading zeros beyond "0". */
|
|
585
|
+
integer: string;
|
|
586
|
+
/** Decimal part as captured, no separator. Empty string if absent. */
|
|
587
|
+
decimal: string;
|
|
588
|
+
}
|
|
589
|
+
interface FormatDecimalOptions {
|
|
590
|
+
value: string | number | null | undefined;
|
|
591
|
+
/** Scale used for display (typically the effective scale, not DB scale). Trailing zeros pad. */
|
|
592
|
+
scale?: number;
|
|
593
|
+
locale?: string;
|
|
594
|
+
/** When set → Intl.NumberFormat with style:currency. Symbol/grouping handled by Intl. */
|
|
595
|
+
currency?: string;
|
|
596
|
+
/** When set (and no currency) → "<formatted> <unit>". */
|
|
597
|
+
unit?: string;
|
|
598
|
+
/** Whether to group thousands. Defaults to true. */
|
|
599
|
+
useGrouping?: boolean;
|
|
600
|
+
}
|
|
601
|
+
/** "." in en-US, "," in fr-FR. Returns "." when locale is undefined. */
|
|
602
|
+
declare function getDecimalSeparator(locale?: string): string;
|
|
603
|
+
/**
|
|
604
|
+
* "," in en-US, NNBSP (U+202F) in fr-FR. Returns "" when no grouping is
|
|
605
|
+
* applied (or when Intl rejects the locale).
|
|
606
|
+
*/
|
|
607
|
+
declare function getThousandsSeparator(locale?: string): string;
|
|
608
|
+
declare function getCurrencyDisplayParts(code: string, locale?: string): CurrencyDisplay;
|
|
609
|
+
/**
|
|
610
|
+
* Currency's natural decimal count via Intl. JPY=0, USD/EUR=2, BHD/KWD=3.
|
|
611
|
+
* Returns `undefined` for codes Intl doesn't know — caller falls back to
|
|
612
|
+
* `dbPrecisionScale`.
|
|
613
|
+
*/
|
|
614
|
+
declare function getCurrencyDecimals(code: string, locale?: string): number | undefined;
|
|
615
|
+
/**
|
|
616
|
+
* Parse a user-typed decimal string. Returns the canonical decimal
|
|
617
|
+
* (no thousands separator, "." as decimal separator) or `null` if invalid.
|
|
618
|
+
* Accepts both "." and "," as the decimal separator (locale-aware).
|
|
619
|
+
* Strips the locale thousands separator. Preserves sign. Does NOT
|
|
620
|
+
* enforce scale.
|
|
621
|
+
*/
|
|
622
|
+
declare function parseDecimalInput(raw: string, locale?: string): string | null;
|
|
623
|
+
/**
|
|
624
|
+
* Enforce a fractional-digit count by truncating or padding. String-only —
|
|
625
|
+
* no float arithmetic. Default behaviour truncates (no rounding) so digits
|
|
626
|
+
* the user typed can't silently shift. Pass `roundHalfUp: true` to round.
|
|
627
|
+
*
|
|
628
|
+
* enforceScale("12.345", 2) → "12.34" (truncate)
|
|
629
|
+
* enforceScale("12.3", 4) → "12.3000" (pad)
|
|
630
|
+
* enforceScale("12", 0) → "12"
|
|
631
|
+
* enforceScale("12.99", 0) → "12" (no rounding)
|
|
632
|
+
*/
|
|
633
|
+
declare function enforceScale(s: string, scale: number | undefined, opts?: {
|
|
634
|
+
roundHalfUp?: boolean;
|
|
635
|
+
}): string;
|
|
636
|
+
declare function splitDecimalString(s: string): DecimalParts;
|
|
637
|
+
declare function joinDecimalString(parts: DecimalParts): string;
|
|
638
|
+
declare function formatDecimalForDisplay(opts: FormatDecimalOptions): string;
|
|
639
|
+
/**
|
|
640
|
+
* Insert the locale's thousands separator into a plain integer string.
|
|
641
|
+
* Pure string-based — no float math, handles arbitrary length.
|
|
642
|
+
*/
|
|
643
|
+
declare function groupInteger(integer: string, locale?: string): string;
|
|
644
|
+
//#endregion
|
|
645
|
+
//#region src/table/types.d.ts
|
|
646
|
+
/** Search index metadata from the server. */
|
|
647
|
+
interface SearchIndexInfo {
|
|
648
|
+
name: string;
|
|
649
|
+
description?: string;
|
|
650
|
+
type?: "text" | "vector";
|
|
651
|
+
}
|
|
652
|
+
/** Relation summary in meta response. */
|
|
653
|
+
interface RelationInfo {
|
|
654
|
+
name: string;
|
|
655
|
+
direction: "to" | "from" | "via";
|
|
656
|
+
isArray: boolean;
|
|
657
|
+
}
|
|
658
|
+
/** Per-field capability flags. */
|
|
659
|
+
interface FieldMeta {
|
|
660
|
+
sortable: boolean;
|
|
661
|
+
filterable: boolean;
|
|
662
|
+
}
|
|
663
|
+
/** Meta response from moost-db `/meta` endpoint. */
|
|
664
|
+
interface MetaResponse {
|
|
665
|
+
searchable: boolean;
|
|
666
|
+
vectorSearchable: boolean;
|
|
667
|
+
searchIndexes: SearchIndexInfo[];
|
|
668
|
+
primaryKeys: string[];
|
|
669
|
+
/**
|
|
670
|
+
* Preferred row identifier (UI/wire addressing). From
|
|
671
|
+
* `@db.table.preferredId.uniqueIndex` — defaults to `primaryKeys` when the
|
|
672
|
+
* server omits it (older servers / stub fixtures). Drives identifier object
|
|
673
|
+
* construction for action POSTs and `'navigate'` URL `$1` substitution.
|
|
674
|
+
*/
|
|
675
|
+
preferredId: string[];
|
|
676
|
+
crud: TCrudPermissions$1;
|
|
677
|
+
actions: TDbActionInfo$1[];
|
|
678
|
+
relations: RelationInfo[];
|
|
679
|
+
fields: Record<string, FieldMeta>;
|
|
680
|
+
type: TSerializedAnnotatedType;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Server-declared actions grouped by `level`. Built by `createTableDef` from
|
|
684
|
+
* `meta.actions[]` — sorted within each group by `(order ?? 0)` then
|
|
685
|
+
* declaration order. `default.{table,row,rows}` is the first `default: true`
|
|
686
|
+
* entry per level (or `undefined`). The synthesised `__remove` UI action is
|
|
687
|
+
* never selected as a default.
|
|
688
|
+
*/
|
|
689
|
+
interface TableActionsModel {
|
|
690
|
+
table: TDbActionInfo$1[];
|
|
691
|
+
row: TDbActionInfo$1[];
|
|
692
|
+
rows: TDbActionInfo$1[];
|
|
693
|
+
default: {
|
|
694
|
+
table?: TDbActionInfo$1;
|
|
695
|
+
row?: TDbActionInfo$1;
|
|
696
|
+
rows?: TDbActionInfo$1;
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
/** Complete table definition — produced by createTableDef(). */
|
|
700
|
+
interface TableDef {
|
|
701
|
+
type: TAtscriptAnnotatedType;
|
|
702
|
+
columns: ColumnDef[];
|
|
703
|
+
/**
|
|
704
|
+
* Flattened type tree (path → annotated prop). Empty Map for non-object roots.
|
|
705
|
+
* Excludes phantom types. Consumers (e.g. cell-resolver) read this instead
|
|
706
|
+
* of re-walking the type.
|
|
707
|
+
*/
|
|
708
|
+
flatMap: Map<string, TAtscriptAnnotatedType>;
|
|
709
|
+
primaryKeys: string[];
|
|
710
|
+
/** Preferred row identifier — see `MetaResponse.preferredId`. */
|
|
711
|
+
preferredId: string[];
|
|
712
|
+
/** Per-op CRUD permissions advertised in `/meta`. Key absent → denied. */
|
|
713
|
+
crud: TCrudPermissions$1;
|
|
714
|
+
canRemove: boolean;
|
|
715
|
+
/** Server-declared actions, grouped by level with defaults pre-resolved. */
|
|
716
|
+
actions: TableActionsModel;
|
|
717
|
+
searchable: boolean;
|
|
718
|
+
vectorSearchable: boolean;
|
|
719
|
+
searchIndexes: SearchIndexInfo[];
|
|
720
|
+
relations: RelationInfo[];
|
|
721
|
+
}
|
|
722
|
+
/** A single column definition — built from field metadata + annotations. */
|
|
723
|
+
interface ColumnDef {
|
|
724
|
+
/** Field path in dot-notation (e.g. 'address.city'). */
|
|
725
|
+
path: string;
|
|
726
|
+
/** Display label — from @meta.label or humanized path. */
|
|
727
|
+
label: string;
|
|
728
|
+
/** Display type — from @ui.table.type, then @ui.type, then inferred from designType. */
|
|
729
|
+
type: string;
|
|
730
|
+
/** Named component override from @ui.table.component — looked up in the table components map. */
|
|
731
|
+
component?: string;
|
|
732
|
+
/** Whether this column supports sorting. */
|
|
733
|
+
sortable: boolean;
|
|
734
|
+
/** Whether this column supports filtering. */
|
|
735
|
+
filterable: boolean;
|
|
736
|
+
/**
|
|
737
|
+
* Whether the column accepts `null` values (atscript prop is `optional`).
|
|
738
|
+
* Drives operator-picker availability — `null` / `notNull` are dropped
|
|
739
|
+
* for non-nullable columns since they can never match.
|
|
740
|
+
*/
|
|
741
|
+
nullable: boolean;
|
|
742
|
+
/** Whether this column is visible by default. */
|
|
743
|
+
visible: boolean;
|
|
744
|
+
/** Default column width from @ui.table.width. */
|
|
745
|
+
width?: string;
|
|
746
|
+
/** Maximum length constraint from @expect.maxLen — used to derive default column width. */
|
|
747
|
+
maxLen?: number;
|
|
748
|
+
/** Initial column ordering from @ui.table.order (lower = first). */
|
|
749
|
+
order: number;
|
|
750
|
+
/** Enumerated options for union literal types (e.g. 'a' | 'b' | 'c'). */
|
|
751
|
+
options?: {
|
|
752
|
+
key: string;
|
|
753
|
+
label: string;
|
|
754
|
+
}[];
|
|
755
|
+
/** Value-help info for FK columns (from extractValueHelp). */
|
|
756
|
+
valueHelpInfo?: ValueHelpInfo;
|
|
757
|
+
/** Literal currency code from `@db.amount.currency 'EUR'`. */
|
|
758
|
+
currencyCode?: string;
|
|
759
|
+
/** Sibling field path from `@db.amount.currency.ref 'fieldName'`. */
|
|
760
|
+
currencyRefField?: string;
|
|
761
|
+
/** Literal unit-of-measure from `@db.unit 'kg'`. */
|
|
762
|
+
unitCode?: string;
|
|
763
|
+
/** Sibling field path from `@db.unit.ref 'fieldName'`. */
|
|
764
|
+
unitRefField?: string;
|
|
765
|
+
/** Decimal scale (fraction digits) — second arg of `@db.column.precision precision, scale`. */
|
|
766
|
+
precisionScale?: number;
|
|
767
|
+
/**
|
|
768
|
+
* Synthesised, locked-chrome column. When `true`: header-cell column-menu
|
|
769
|
+
* skipped, resize handle skipped, drag-reorder excluded, NOT in the
|
|
770
|
+
* `columnNames` v-model. Used for the row-actions pseudo-column
|
|
771
|
+
* (`path: '__actions'`).
|
|
772
|
+
*/
|
|
773
|
+
fixed?: boolean;
|
|
774
|
+
}
|
|
775
|
+
/** A single sort directive. */
|
|
776
|
+
interface SortControl {
|
|
777
|
+
field: string;
|
|
778
|
+
direction: "asc" | "desc";
|
|
779
|
+
}
|
|
780
|
+
/** Pagination state. */
|
|
781
|
+
interface PaginationControl {
|
|
782
|
+
page: number;
|
|
783
|
+
itemsPerPage: number;
|
|
784
|
+
}
|
|
785
|
+
/** Reactive query state for a table — mirrors @uniqu/core controls. */
|
|
786
|
+
interface TableQueryState {
|
|
787
|
+
sort?: SortControl[];
|
|
788
|
+
pagination?: PaginationControl;
|
|
789
|
+
search?: string;
|
|
790
|
+
filters?: Record<string, unknown>;
|
|
791
|
+
}
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region src/table/create-table-def.d.ts
|
|
794
|
+
/**
|
|
795
|
+
* Builds a TableDef from a moost-db MetaResponse.
|
|
796
|
+
*
|
|
797
|
+
* 1. Deserializes `meta.type` into a live TAtscriptAnnotatedType
|
|
798
|
+
* 2. Flattens to discover all field paths
|
|
799
|
+
* 3. Builds ColumnDef per field using annotations + meta.fields capabilities
|
|
800
|
+
* 4. Sorts by @ui.table.order
|
|
801
|
+
*/
|
|
802
|
+
declare function createTableDef(meta: MetaResponse, preDeserializedType?: TAtscriptAnnotatedType): TableDef;
|
|
803
|
+
//#endregion
|
|
804
|
+
//#region src/client-factory.d.ts
|
|
805
|
+
/**
|
|
806
|
+
* Factory that creates a `Client` for a given URL.
|
|
807
|
+
*
|
|
808
|
+
* Single contract shared by every atscript-ui primitive that needs to talk
|
|
809
|
+
* to an atscript-db-compatible endpoint: table composables, FK value-help,
|
|
810
|
+
* and any future consumer. Produces a `Client` configured with whatever
|
|
811
|
+
* transport / auth wiring the host application wants.
|
|
812
|
+
*/
|
|
813
|
+
type ClientFactory = (url: string) => Client;
|
|
814
|
+
/**
|
|
815
|
+
* Override the app-wide default factory. Call once at startup (e.g. in
|
|
816
|
+
* `entry-client.ts`) to wire shared fetch, credentials, error handling, etc.
|
|
817
|
+
* Every table, value-help picker, and other client consumer will pick it up.
|
|
818
|
+
*/
|
|
819
|
+
declare function setDefaultClientFactory(factory: ClientFactory): void;
|
|
820
|
+
/** Current app-wide default factory. Falls back to `new Client(url)`. */
|
|
821
|
+
declare function getDefaultClientFactory(): ClientFactory;
|
|
822
|
+
/** Reset the default factory to the built-in one (primarily for tests). */
|
|
823
|
+
declare function resetDefaultClientFactory(): void;
|
|
824
|
+
//#endregion
|
|
825
|
+
//#region src/shared/meta-cache.d.ts
|
|
826
|
+
/**
|
|
827
|
+
* Shared per-URL cache. A single entry holds the `Client` instance, the raw
|
|
828
|
+
* `/meta` promise, the deserialized type, and lazily-populated derived shapes
|
|
829
|
+
* (`ResolvedValueHelp` for value-help, `TableDef` for tables). Both
|
|
830
|
+
* `resolveValueHelp` and `useTable` route through it so a given URL triggers
|
|
831
|
+
* at most one network round-trip and one `deserializeAnnotatedType`.
|
|
832
|
+
*/
|
|
833
|
+
interface MetaCacheEntry {
|
|
834
|
+
client: Client;
|
|
835
|
+
meta: Promise<MetaResponse>;
|
|
836
|
+
type: Promise<TAtscriptAnnotatedType>;
|
|
837
|
+
resolved?: Promise<ResolvedValueHelp>;
|
|
838
|
+
tableDef?: Promise<TableDef>;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Get or create the cache entry for `url`. First caller's `factory` seeds the
|
|
842
|
+
* `Client`; subsequent callers reuse it. On `meta` rejection, the entry is
|
|
843
|
+
* evicted so the next call retries.
|
|
844
|
+
*/
|
|
845
|
+
declare function getMetaEntry(url: string, factory?: ClientFactory): MetaCacheEntry;
|
|
846
|
+
declare function resetMetaCache(): void;
|
|
847
|
+
//#endregion
|
|
848
|
+
//#region src/shared/str.d.ts
|
|
849
|
+
/** Safely convert an unknown value to a string without triggering no-base-to-string lint errors. */
|
|
850
|
+
declare function str(value: unknown): string;
|
|
851
|
+
//#endregion
|
|
852
|
+
//#region src/table/column-resolver.d.ts
|
|
853
|
+
/** Get visible columns only, already sorted by order. */
|
|
854
|
+
declare function getVisibleColumns(def: TableDef): ColumnDef[];
|
|
855
|
+
/** Get sortable columns. */
|
|
856
|
+
declare function getSortableColumns(def: TableDef): ColumnDef[];
|
|
857
|
+
/** Get filterable columns. */
|
|
858
|
+
declare function getFilterableColumns(def: TableDef): ColumnDef[];
|
|
859
|
+
/** Find a column by path. */
|
|
860
|
+
declare function getColumn(def: TableDef, path: string): ColumnDef | undefined;
|
|
861
|
+
//#endregion
|
|
862
|
+
export { type ClientFactory, type ColumnDef, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormArrayFieldDef, type FormDef, type FormFieldDef, type FormObjectFieldDef, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaResponse, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_HIDDEN, UI_TABLE_ORDER, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, asArray, buildDescendantErrorCounts, buildGridClasses, buildUnionVariants, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, defaultResolver, detectUnionVariant, enforceScale, extractLiteralOptions, extractMeasurement, extractValueHelp, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, getVisibleColumns, groupInteger, hasComputedAnnotations, isArrayField, isObjectField, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, mergeErrorMaps, optKey, optLabel, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setResolver, splitDecimalString, str, valueHelpDictPaths };
|