@atscript/ui 0.1.163 → 0.1.165

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 (164) hide show
  1. package/dist/client-factory.cjs +27 -0
  2. package/dist/client-factory.d.cts +58 -0
  3. package/dist/client-factory.d.mts +58 -0
  4. package/dist/client-factory.mjs +25 -0
  5. package/dist/form/apply.cjs +38 -0
  6. package/dist/form/apply.d.cts +36 -0
  7. package/dist/form/apply.d.mts +36 -0
  8. package/dist/form/apply.mjs +38 -0
  9. package/dist/form/clone.cjs +30 -0
  10. package/dist/form/clone.d.cts +23 -0
  11. package/dist/form/clone.d.mts +23 -0
  12. package/dist/form/clone.mjs +30 -0
  13. package/dist/form/create-form-def.cjs +462 -0
  14. package/dist/form/create-form-def.d.cts +67 -0
  15. package/dist/form/create-form-def.d.mts +67 -0
  16. package/dist/form/create-form-def.mjs +460 -0
  17. package/dist/form/decimal-format.cjs +324 -0
  18. package/dist/form/decimal-format.d.cts +86 -0
  19. package/dist/form/decimal-format.d.mts +86 -0
  20. package/dist/form/decimal-format.mjs +315 -0
  21. package/dist/form/diff.cjs +458 -0
  22. package/dist/form/diff.d.cts +80 -0
  23. package/dist/form/diff.d.mts +80 -0
  24. package/dist/form/diff.mjs +457 -0
  25. package/dist/form/dirty.cjs +65 -0
  26. package/dist/form/dirty.d.cts +47 -0
  27. package/dist/form/dirty.d.mts +47 -0
  28. package/dist/form/dirty.mjs +64 -0
  29. package/dist/form/error-utils.cjs +97 -0
  30. package/dist/form/error-utils.d.cts +58 -0
  31. package/dist/form/error-utils.d.mts +58 -0
  32. package/dist/form/error-utils.mjs +92 -0
  33. package/dist/form/form-actions.cjs +30 -0
  34. package/dist/form/form-actions.d.cts +17 -0
  35. package/dist/form/form-actions.d.mts +17 -0
  36. package/dist/form/form-actions.mjs +30 -0
  37. package/dist/form/grid.cjs +69 -0
  38. package/dist/form/grid.d.cts +49 -0
  39. package/dist/form/grid.d.mts +49 -0
  40. package/dist/form/grid.mjs +64 -0
  41. package/dist/form/labels.cjs +13 -0
  42. package/dist/form/labels.d.cts +11 -0
  43. package/dist/form/labels.d.mts +11 -0
  44. package/dist/form/labels.mjs +13 -0
  45. package/dist/form/measurement.cjs +20 -0
  46. package/dist/form/measurement.d.cts +29 -0
  47. package/dist/form/measurement.d.mts +29 -0
  48. package/dist/form/measurement.mjs +20 -0
  49. package/dist/form/path-utils.cjs +182 -0
  50. package/dist/form/path-utils.d.cts +47 -0
  51. package/dist/form/path-utils.d.mts +47 -0
  52. package/dist/form/path-utils.mjs +175 -0
  53. package/dist/form/rebase.cjs +89 -0
  54. package/dist/form/rebase.d.cts +61 -0
  55. package/dist/form/rebase.d.mts +61 -0
  56. package/dist/form/rebase.mjs +89 -0
  57. package/dist/form/skipped-nav.cjs +100 -0
  58. package/dist/form/skipped-nav.d.cts +13 -0
  59. package/dist/form/skipped-nav.d.mts +13 -0
  60. package/dist/form/skipped-nav.mjs +98 -0
  61. package/dist/form/types.cjs +40 -0
  62. package/dist/form/types.d.cts +147 -0
  63. package/dist/form/types.d.mts +147 -0
  64. package/dist/form/types.mjs +36 -0
  65. package/dist/form/union-detect.cjs +46 -0
  66. package/dist/form/union-detect.d.cts +22 -0
  67. package/dist/form/union-detect.d.mts +22 -0
  68. package/dist/form/union-detect.mjs +46 -0
  69. package/dist/form/validate.cjs +186 -0
  70. package/dist/form/validate.d.cts +81 -0
  71. package/dist/form/validate.d.mts +81 -0
  72. package/dist/form/validate.mjs +182 -0
  73. package/dist/i18n/ui-texts.cjs +135 -0
  74. package/dist/i18n/ui-texts.d.cts +81 -0
  75. package/dist/i18n/ui-texts.d.mts +81 -0
  76. package/dist/i18n/ui-texts.mjs +132 -0
  77. package/dist/index.cjs +223 -3360
  78. package/dist/index.d.cts +39 -1693
  79. package/dist/index.d.mts +39 -1693
  80. package/dist/index.mjs +36 -3179
  81. package/dist/messages.cjs +301 -0
  82. package/dist/messages.d.cts +302 -0
  83. package/dist/messages.d.mts +302 -0
  84. package/dist/messages.mjs +300 -0
  85. package/dist/nav/model-routes.cjs +59 -0
  86. package/dist/nav/model-routes.d.cts +33 -0
  87. package/dist/nav/model-routes.d.mts +33 -0
  88. package/dist/nav/model-routes.mjs +59 -0
  89. package/dist/plugin/annotations.cjs +592 -0
  90. package/dist/plugin/annotations.mjs +592 -0
  91. package/dist/plugin/primitives.cjs +30 -0
  92. package/dist/plugin/primitives.mjs +30 -0
  93. package/dist/plugin/value-help-validation.cjs +429 -0
  94. package/dist/plugin/value-help-validation.mjs +423 -0
  95. package/dist/plugin.cjs +4 -1001
  96. package/dist/plugin.mjs +2 -999
  97. package/dist/shared/annotation-keys.cjs +189 -0
  98. package/dist/shared/annotation-keys.d.cts +82 -0
  99. package/dist/shared/annotation-keys.d.mts +82 -0
  100. package/dist/shared/annotation-keys.mjs +97 -0
  101. package/dist/shared/field-resolver.cjs +123 -0
  102. package/dist/shared/field-resolver.d.cts +77 -0
  103. package/dist/shared/field-resolver.d.mts +77 -0
  104. package/dist/shared/field-resolver.mjs +110 -0
  105. package/dist/shared/meta-cache.cjs +282 -0
  106. package/dist/shared/meta-cache.d.cts +130 -0
  107. package/dist/shared/meta-cache.d.mts +130 -0
  108. package/dist/shared/meta-cache.mjs +275 -0
  109. package/dist/shared/str.cjs +19 -0
  110. package/dist/shared/str.d.cts +7 -0
  111. package/dist/shared/str.d.mts +7 -0
  112. package/dist/shared/str.mjs +17 -0
  113. package/dist/table/column-resolver.cjs +17 -0
  114. package/dist/table/column-resolver.d.cts +11 -0
  115. package/dist/table/column-resolver.d.mts +11 -0
  116. package/dist/table/column-resolver.mjs +15 -0
  117. package/dist/table/create-table-def.cjs +242 -0
  118. package/dist/table/create-table-def.d.cts +19 -0
  119. package/dist/table/create-table-def.d.mts +19 -0
  120. package/dist/table/create-table-def.mjs +242 -0
  121. package/dist/table/navigate-href.cjs +45 -0
  122. package/dist/table/navigate-href.d.cts +31 -0
  123. package/dist/table/navigate-href.d.mts +31 -0
  124. package/dist/table/navigate-href.mjs +45 -0
  125. package/dist/table/types.d.cts +290 -0
  126. package/dist/table/types.d.mts +290 -0
  127. package/dist/table/value-kind.cjs +20 -0
  128. package/dist/table/value-kind.d.cts +16 -0
  129. package/dist/table/value-kind.d.mts +16 -0
  130. package/dist/table/value-kind.mjs +19 -0
  131. package/dist/value-help/dict-paths.cjs +17 -0
  132. package/dist/value-help/dict-paths.d.cts +11 -0
  133. package/dist/value-help/dict-paths.d.mts +11 -0
  134. package/dist/value-help/dict-paths.mjs +17 -0
  135. package/dist/value-help/distinct-client.cjs +51 -0
  136. package/dist/value-help/distinct-client.d.cts +40 -0
  137. package/dist/value-help/distinct-client.d.mts +40 -0
  138. package/dist/value-help/distinct-client.mjs +50 -0
  139. package/dist/value-help/extract-literals.cjs +115 -0
  140. package/dist/value-help/extract-literals.d.cts +44 -0
  141. package/dist/value-help/extract-literals.d.mts +44 -0
  142. package/dist/value-help/extract-literals.mjs +111 -0
  143. package/dist/value-help/extract-ref.cjs +100 -0
  144. package/dist/value-help/extract-ref.d.cts +37 -0
  145. package/dist/value-help/extract-ref.d.mts +37 -0
  146. package/dist/value-help/extract-ref.mjs +100 -0
  147. package/dist/value-help/filter-tree.cjs +45 -0
  148. package/dist/value-help/filter-tree.mjs +45 -0
  149. package/dist/value-help/index.d.mts +8 -0
  150. package/dist/value-help/resolve-options.cjs +68 -0
  151. package/dist/value-help/resolve-options.d.cts +40 -0
  152. package/dist/value-help/resolve-options.d.mts +40 -0
  153. package/dist/value-help/resolve-options.mjs +64 -0
  154. package/dist/value-help/resolve.cjs +66 -0
  155. package/dist/value-help/resolve.d.cts +36 -0
  156. package/dist/value-help/resolve.d.mts +36 -0
  157. package/dist/value-help/resolve.mjs +65 -0
  158. package/dist/value-help/types.d.cts +41 -0
  159. package/dist/value-help/types.d.mts +41 -0
  160. package/dist/value-help/value-help-client.cjs +136 -0
  161. package/dist/value-help/value-help-client.d.cts +67 -0
  162. package/dist/value-help/value-help-client.d.mts +67 -0
  163. package/dist/value-help/value-help-client.mjs +134 -0
  164. package/package.json +15 -10
package/dist/index.d.mts CHANGED
@@ -1,1693 +1,39 @@
1
- import { TAtscriptAnnotatedType, TAtscriptDataType, TSerializedAnnotatedType, TValidatorOptions, TValidatorPlugin } from "@atscript/typescript/utils";
2
- import { Client, ClientOptions, FilterExpr, 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_SELECT_WITH: "ui.table.selectWith";
32
- declare const UI_TABLE_EXCLUDE: "ui.table.exclude";
33
- declare const UI_TABLE_ATTR: "ui.table.attr";
34
- declare const UI_TABLE_CLASSES: "ui.table.classes";
35
- declare const UI_TABLE_STYLES: "ui.table.styles";
36
- declare const UI_TABLE_TYPE: "ui.table.type";
37
- declare const UI_TABLE_ORDER: "ui.table.order";
38
- declare const UI_DICT_LABEL: "ui.dict.label";
39
- declare const UI_DICT_DESCR: "ui.dict.descr";
40
- declare const UI_DICT_ATTR: "ui.dict.attr";
41
- declare const UI_DICT_FILTERABLE: "ui.dict.filterable";
42
- declare const UI_DICT_SORTABLE: "ui.dict.sortable";
43
- declare const UI_DICT_SEARCHABLE: "ui.dict.searchable";
44
- declare const UI_NAV_GROUP: "ui.nav.group";
45
- declare const UI_NAV_ORDER: "ui.nav.order";
46
- declare const UI_NAV_HIDDEN: "ui.nav.hidden";
47
- declare const DB_REL_FK: "db.rel.FK";
48
- declare const DB_HTTP_PATH: "db.http.path";
49
- declare const DB_AMOUNT_CURRENCY: "db.amount.currency";
50
- declare const DB_AMOUNT_CURRENCY_REF: "db.amount.currency.ref";
51
- declare const DB_UNIT: "db.unit";
52
- declare const DB_UNIT_REF: "db.unit.ref";
53
- declare const DB_COLUMN_PRECISION: "db.column.precision";
54
- declare const WF_ACTION_WITH_DATA: "wf.action.withData";
55
- declare const META_LABEL: "meta.label";
56
- declare const META_ID: "meta.id";
57
- declare const META_DESCRIPTION: "meta.description";
58
- declare const META_READONLY: "meta.readonly";
59
- declare const META_REQUIRED: "meta.required";
60
- declare const META_DEFAULT: "meta.default";
61
- declare const META_SENSITIVE: "meta.sensitive";
62
- declare const EXPECT_MAX_LENGTH: "expect.maxLength";
63
- declare const UI_FORM_FN_PREFIX: "ui.form.fn.";
64
- declare const UI_FORM_FN_LABEL: "ui.form.fn.label";
65
- declare const UI_FORM_FN_PLACEHOLDER: "ui.form.fn.placeholder";
66
- declare const UI_FORM_FN_DESCRIPTION: "ui.form.fn.description";
67
- declare const UI_FORM_FN_HINT: "ui.form.fn.hint";
68
- declare const UI_FORM_FN_HIDDEN: "ui.form.fn.hidden";
69
- declare const UI_FORM_FN_DISABLED: "ui.form.fn.disabled";
70
- declare const UI_FORM_FN_READONLY: "ui.form.fn.readonly";
71
- declare const UI_FORM_FN_OPTIONS: "ui.form.fn.options";
72
- declare const UI_FORM_FN_ATTR: "ui.form.fn.attr";
73
- declare const UI_FORM_FN_VALUE: "ui.form.fn.value";
74
- declare const UI_FORM_FN_CLASSES: "ui.form.fn.classes";
75
- declare const UI_FORM_FN_STYLES: "ui.form.fn.styles";
76
- declare const UI_FORM_FN_TITLE: "ui.form.fn.title";
77
- declare const UI_FORM_FN_SUBMIT_TEXT: "ui.form.fn.submit.text";
78
- declare const UI_FORM_FN_SUBMIT_DISABLED: "ui.form.fn.submit.disabled";
79
- declare const UI_TABLE_FN_PREFIX: "ui.table.fn.";
80
- declare const UI_TABLE_FN_ATTR: "ui.table.fn.attr";
81
- declare const UI_TABLE_FN_CLASSES: "ui.table.fn.classes";
82
- declare const UI_TABLE_FN_STYLES: "ui.table.fn.styles";
83
- declare const UI_FORM_VALIDATE: "ui.form.validate";
84
- //#endregion
85
- //#region src/value-help/types.d.ts
86
- /** An option for select/radio fields — either a plain string or a `{ key, label }` pair. */
87
- type TFormEntryOptions = {
88
- key: string;
89
- label: string;
90
- } | string;
91
- /**
92
- * Minimal sync probe output for a value-help–eligible prop.
93
- *
94
- * Emitted by `extractValueHelp(prop)` at def-construction time. Consumers use
95
- * `url` to key the lazy resolver (`resolveValueHelp(url)`) that fetches the
96
- * target's own `/meta` endpoint and returns the field-role details.
97
- */
98
- interface ValueHelpInfo {
99
- /** HTTP path to the value-help target (from the target's `@db.http.path`). */
100
- url: string;
101
- /**
102
- * Field on the target that this FK references (from `prop.ref.field`, e.g. "id").
103
- * This is the value committed to the FK field when the user picks a row.
104
- */
105
- targetField: string;
106
- /**
107
- * Static dictionary scope from `@ui.valueHelp`'s filter — AND'd into every
108
- * picker query. Since 0.1.148.
109
- */
110
- filter?: FilterExpr;
111
- /**
112
- * Target fields the filter pins with `=` — constant in the picker, hidden
113
- * from its columns. Since 0.1.148.
114
- */
115
- pinned?: string[];
116
- }
117
- //#endregion
118
- //#region src/form/types.d.ts
119
- /** Form action metadata — the action id and display label. */
120
- interface TFormAction {
121
- id: string;
122
- label: string;
123
- }
124
- /**
125
- * A single form field definition — thin pointer to the ATScript prop.
126
- *
127
- * All metadata (label, disabled, options, etc.) lives in `prop.metadata`
128
- * and is resolved on demand via resolve utilities.
129
- */
130
- interface FormFieldDef {
131
- /** Dot-separated path relative to the parent data context. `''` = root. */
132
- path: string;
133
- prop: TAtscriptAnnotatedType;
134
- /**
135
- * Render-key the renderer dispatches on. For structured kinds (array,
136
- * object, tuple, multi-variant union) this stays the kind name so that
137
- * `isArrayField`/`isObjectField`/`isUnionField`/`isTupleField` keep
138
- * working downstream (validator resetValue, child path provide, AsArray
139
- * recursion). Primitives may store an `@ui.form.type`/`@ui.type`
140
- * override here directly — for those there is no structural behaviour
141
- * to preserve.
142
- */
143
- type: string;
144
- /**
145
- * Optional `@ui.form.type` (or `@ui.type`) override for structured
146
- * kinds. When set, the renderer looks this up in the `types` map FIRST
147
- * and falls back to `type` only when the map has no entry. Letting the
148
- * override live in a separate field keeps the structural type guards
149
- * (`isArrayField` et al.) on `type` honest while still allowing a
150
- * consumer to attach a flat custom widget to e.g. a `string[]`.
151
- */
152
- customType?: string;
153
- phantom: boolean;
154
- name: string;
155
- /** True when no `ui.fn.*` metadata keys exist. Vue perf flag. */
156
- allStatic: boolean;
157
- /**
158
- * `@ui.form.pushDown` — render this field below the submit button in its
159
- * own grid, instead of in the main field grid above submit. Set on
160
- * top-level form fields (typically secondary `ui.action` links). The field
161
- * stays in `fields[]` for validation/data; only its render slot moves.
162
- */
163
- pushDown: boolean;
164
- /**
165
- * Value-help target for an FK field — `{ url, targetField }` resolved once by
166
- * `extractValueHelp` while the def is built (since 0.1.134; mirrors
167
- * `ColumnDef.valueHelpInfo` on the table side). `undefined` for every field
168
- * that is not an FK. Renderers read this instead of re-walking the
169
- * annotations per field, which also keeps the annotation dependency out of
170
- * the component layer.
171
- */
172
- valueHelpInfo?: ValueHelpInfo;
173
- /**
174
- * Server-owned field: a `@db.column.derived` one (read from the type
175
- * metadata), a computed view column (`CreateFormDefOptions.metaFields`) or,
176
- * in an edit form, an update-stamped one (see `CreateFormDefOptions.mode`).
177
- * Rendered read-only, exempt from form validation and never sent by
178
- * `buildFormDiff` (the server drops or overwrites a written value anyway).
179
- * Since 0.1.144.
180
- */
181
- derived?: true;
182
- }
183
- /**
184
- * Complete form definition — produced by createFormDef().
185
- * Form-level metadata (title, submit) resolved on demand via resolveFormProp.
186
- */
187
- interface FormDef {
188
- type: TAtscriptAnnotatedType;
189
- /** Root field representing the entire form. For interface types this is `type='object'`; for single-type forms it is a leaf field. */
190
- rootField: FormFieldDef;
191
- fields: FormFieldDef[];
192
- /**
193
- * Render partition of `fields` by `@ui.form.pushDown`, precomputed once so
194
- * the renderer never re-scans per frame. `mainFields` (above submit) plus
195
- * `pushDownFields` (below submit) cover `fields` exactly once. In the common
196
- * case nothing is pushed down: `mainFields === fields` (same ref) and
197
- * `pushDownFields` is empty.
198
- */
199
- mainFields: FormFieldDef[];
200
- pushDownFields: FormFieldDef[];
201
- flatMap: Map<string, TAtscriptAnnotatedType>;
202
- }
203
- /** One branch of a union type — used by union fields and union array items. */
204
- interface FormUnionVariant {
205
- /** Display label — from @meta.label or auto-generated (e.g. "1. String") */
206
- label: string;
207
- /** The annotated type for this variant */
208
- type: TAtscriptAnnotatedType;
209
- /** Pre-built FormDef for object variants (undefined for primitives) */
210
- def?: FormDef;
211
- /** Pre-built field def for primitive variants (undefined for objects) */
212
- itemField?: FormFieldDef;
213
- /** Design type for primitive variants ('string', 'number', 'boolean') */
214
- designType?: string;
215
- }
216
- /** Extended field def for array-typed fields. */
217
- interface FormArrayFieldDef extends FormFieldDef {
218
- /** ATScript annotated type of array items (from TAtscriptTypeArray.of) */
219
- itemType: TAtscriptAnnotatedType;
220
- /** Pre-built template field def for items (path=''). */
221
- itemField: FormFieldDef;
222
- }
223
- /** Extended field def for object (interface/type) nested fields. */
224
- interface FormObjectFieldDef extends FormFieldDef {
225
- /** Pre-built FormDef for the nested object's fields */
226
- objectDef: FormDef;
227
- }
228
- /** Extended field def for union fields — standalone union props and union array items. */
229
- interface FormUnionFieldDef extends FormFieldDef {
230
- /** Available union branches. */
231
- unionVariants: FormUnionVariant[];
232
- }
233
- /** Extended field def for tuple fields — fixed-length with typed positions. */
234
- interface FormTupleFieldDef extends FormFieldDef {
235
- /** Pre-built field defs, one per tuple position. */
236
- itemFields: FormFieldDef[];
237
- }
238
- /** Type guard: checks if a field def is an array field. */
239
- declare function isArrayField(field: FormFieldDef): field is FormArrayFieldDef;
240
- /** Type guard: checks if a field def is an object field. */
241
- declare function isObjectField(field: FormFieldDef): field is FormObjectFieldDef;
242
- /** Type guard: checks if a field def is a union field. */
243
- declare function isUnionField(field: FormFieldDef): field is FormUnionFieldDef;
244
- /** Type guard: checks if a field def is a tuple field. */
245
- declare function isTupleField(field: FormFieldDef): field is FormTupleFieldDef;
246
- //#endregion
247
- //#region src/form/create-form-def.d.ts
248
- /** Options for {@link createFormDef}. */
249
- interface CreateFormDefOptions {
250
- /**
251
- * `meta.versionColumn` — the server-managed OCC version field (its LOGICAL
252
- * name; a `@db.column` rename changes only the storage column). Excluded
253
- * from `fields[]`; it stays in `flatMap` so the wire payload is unchanged.
254
- * Root-table concept; not propagated into nested recursive calls.
255
- */
256
- versionColumn?: string;
257
- /**
258
- * `meta.fields` of the `/meta` the type came from. A field it marks
259
- * `computed` (a computed view column, whose `@db.compute` annotation the
260
- * server does not send) is marked `derived` like a `@db.column.derived`
261
- * one: read-only, never validated, never sent. Root-table concept; not
262
- * propagated into nested recursive calls. Since 0.1.147.
263
- */
264
- metaFields?: Record<string, {
265
- computed?: boolean;
266
- }>;
267
- /**
268
- * What the form is for. `"edit"` — the form edits a stored row and is sent
269
- * as an update: an `@db.onUpdate.now` field (`number.timestamp.updated`) or
270
- * an `@db.onUpdate.inc` change counter, which the server sets on every
271
- * update and whose sent value it ignores, is then marked `derived` —
272
- * read-only, never validated, never sent. Applies at every depth (embedded
273
- * objects, objects in arrays), except for a reference to another field, an
274
- * element of an array of numbers, and below a tuple or a union of several
275
- * types, where the server does not set the field (`@db.onUpdate.inc` is
276
- * top-level only). `"create"` (default) — the field stays editable: the
277
- * server only fills it when the value is left out and it has
278
- * `@db.default.now`, or is an `@db.onUpdate.inc` counter (`0`). Since
279
- * 0.1.154; `@db.onUpdate.inc` since 0.1.159.
280
- */
281
- mode?: "create" | "edit";
282
- }
283
- /**
284
- * Converts an ATScript annotated type into a FormDef.
285
- *
286
- * - **Object types** (`kind === 'object'`): produces an object root with nested fields.
287
- * - **Non-object types** (primitive, array, union, etc.): produces a single leaf root field
288
- * with `path: ''`.
289
- *
290
- * A `@db.column.derived` field is marked `derived` straight from its metadata;
291
- * a computed view column, from `opts.metaFields`; an update-stamped field
292
- * (see `CreateFormDefOptions.mode`), when `opts.mode` is `"edit"`.
293
- */
294
- declare function createFormDef(type: TAtscriptAnnotatedType, opts?: CreateFormDefOptions): FormDef;
295
- /**
296
- * Builds union variant definitions from a union annotated type.
297
- * Iterates top-level items directly — one variant per item.
298
- */
299
- declare function buildUnionVariants(typeDef: TAtscriptAnnotatedType): FormUnionVariant[];
300
- //#endregion
301
- //#region src/form/form-actions.d.ts
302
- /** One declared form action: its id and whether it carries form data. */
303
- interface FormActionInfo {
304
- id: string;
305
- withData: boolean;
306
- }
307
- /**
308
- * Declared actions of a form — the union of `@ui.form.action` ids and
309
- * `@wf.action.withData` ids across all fields. `withData` distinguishes a
310
- * data-carrying workflow action (sends the current form payload) from a plain
311
- * stateless action. Single source of truth for "what actions can a host fire".
312
- */
313
- declare function getDeclaredFormActions(def: FormDef): FormActionInfo[];
314
- //#endregion
315
- //#region src/shared/field-resolver.d.ts
316
- /** Options for field and form property resolution. */
317
- interface TResolveOptions<T> {
318
- /** When true, any non-undefined static value is returned as `true` (for boolean flags like ui.disabled). */
319
- staticAsBoolean?: boolean;
320
- /** Transform the raw static value before returning. */
321
- transform?: (raw: unknown) => T;
322
- }
323
- /**
324
- * Pluggable resolver interface for field/form metadata.
325
- * @atscript/ui provides a static implementation (reads only static annotation values).
326
- * ui-fns extends it with dynamic `new Function` compilation for `ui.fn.*` keys.
327
- */
328
- interface FieldResolver {
329
- /** Resolve a field-level metadata property. */
330
- resolveFieldProp<T>(prop: TAtscriptAnnotatedType, fnKey: string, staticKey: string | undefined, scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
331
- /** Resolve a form-level metadata property. */
332
- resolveFormProp<T>(type: TAtscriptAnnotatedType, fnKey: string, staticKey: string | undefined, scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
333
- /** Check if a prop has dynamic annotations (ui.fn.*). */
334
- hasComputedAnnotations(prop: TAtscriptAnnotatedType): boolean;
335
- }
336
- /** Static resolver — ignores fn keys, reads only static metadata. */
337
- declare class StaticFieldResolver implements FieldResolver {
338
- resolveFieldProp<T>(prop: TAtscriptAnnotatedType, _fnKey: string, staticKey: string | undefined, _scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
339
- resolveFormProp<T>(type: TAtscriptAnnotatedType, _fnKey: string, staticKey: string | undefined, _scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
340
- hasComputedAnnotations(_prop: TAtscriptAnnotatedType): boolean;
341
- }
342
- /** Resolves a static metadata value. Exported for reuse by dynamic resolvers. */
343
- declare function resolveStatic<T>(metadata: TAtscriptAnnotatedType["metadata"], staticKey: string | undefined, opts?: TResolveOptions<T>): T | undefined;
344
- /** Default static resolver instance. */
345
- declare const defaultResolver: StaticFieldResolver;
346
- /** Replace the active resolver (called by ui-fns to install dynamic resolution). */
347
- declare function setResolver(resolver: FieldResolver): void;
348
- /** Get the current active resolver. */
349
- declare function getResolver(): FieldResolver;
350
- /** Resolve a field-level metadata property via the active resolver. */
351
- declare function resolveFieldProp<T>(prop: TAtscriptAnnotatedType, fnKey: string, staticKey: string | undefined, scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
352
- /** Resolve a form-level metadata property via the active resolver. */
353
- declare function resolveFormProp<T>(type: TAtscriptAnnotatedType, fnKey: string, staticKey: string | undefined, scope: Record<string, unknown>, opts?: TResolveOptions<T>): T | undefined;
354
- /** Check if a prop has dynamic annotations via the active resolver. */
355
- declare function hasComputedAnnotations(prop: TAtscriptAnnotatedType): boolean;
356
- /**
357
- * SSOT for field hidden resolution — resolves `@ui.form.fn.hidden`
358
- * (dynamic, via the active resolver) with static `@ui.form.hidden`
359
- * presence as the fallback. Absent both → `false` (visible).
360
- */
361
- declare function isFieldHidden(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>): boolean;
362
- /**
363
- * Reads a static metadata value from an ATScript prop.
364
- * Typed overload for known AtscriptMetadata keys; falls back to `unknown` for other keys.
365
- */
366
- declare function getFieldMeta<K extends keyof AtscriptMetadata>(prop: TAtscriptAnnotatedType, key: K): AtscriptMetadata[K] | undefined;
367
- declare function getFieldMeta(prop: TAtscriptAnnotatedType, key: string): unknown;
368
- /** Checks whether a metadata key is present on an ATScript prop. */
369
- declare function hasFieldMeta(prop: TAtscriptAnnotatedType, key: string): boolean;
370
- /** Ensures a value is an array — returns as-is if already one, wraps in `[x]` otherwise. */
371
- declare function asArray<T>(x: T | T[]): T[];
372
- /**
373
- * Parses static `ui.attr` metadata into a key-value record.
374
- * Exported so ui-fns can reuse this without duplicating the parsing logic.
375
- */
376
- declare function parseStaticAttrs(staticAttrs: unknown): Record<string, unknown> | undefined;
377
- /** Per-surface attr key pair — defaults to the form-side keys. */
378
- interface TResolveAttrsKeys {
379
- staticKey?: string;
380
- fnKey?: string;
381
- }
382
- /**
383
- * Resolves `<staticKey>` + `<fnKey>` attr metadata on demand.
384
- * Defaults read `ui.form.attr` + `ui.form.fn.attr`; pass `{ staticKey, fnKey }` to read
385
- * the table-side pair (`ui.table.attr` + `ui.table.fn.attr`) or any other surface.
386
- */
387
- declare function resolveAttrs(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>, keys?: TResolveAttrsKeys): Record<string, unknown> | undefined;
388
- //#endregion
389
- //#region src/value-help/resolve.d.ts
390
- /**
391
- * Field-role + capability metadata for a value-help target, lazily resolved
392
- * from the target's own `/meta` endpoint.
393
- */
394
- interface ResolvedValueHelp {
395
- url: string;
396
- primaryKeys: string[];
397
- labelField: string;
398
- descrField: string | undefined;
399
- attrFields: string[];
400
- filterableFields: string[];
401
- sortableFields: string[];
402
- searchable: boolean;
403
- targetType: TAtscriptAnnotatedType;
404
- }
405
- /**
406
- * Lazily fetch and extract value-help metadata for the given URL.
407
- *
408
- * - Issues exactly one `GET {url}/meta` per URL across the session (shared via meta-cache).
409
- * - Concurrent callers with the same URL share the in-flight promise.
410
- * - If the underlying fetch rejects, the cache entry is evicted so a later
411
- * retry performs a fresh fetch.
412
- */
413
- declare function resolveValueHelp(url: string): Promise<ResolvedValueHelp>;
414
- /** Thin alias over `resetMetaCache` — retained so existing test code keeps working. */
415
- declare function resetValueHelpCache(): void;
416
- //#endregion
417
- //#region src/value-help/value-help-client.d.ts
418
- interface ValueHelpSearchOptions {
419
- /** Search term. Empty or undefined returns all records. */
420
- text?: string;
421
- /** "form" = PK + label + descr; "filter" = all dict fields including attrs. Default: "form". */
422
- mode?: "form" | "filter";
423
- /** Max results. Default: 20. */
424
- limit?: number;
425
- /** Override the computed select fields. */
426
- select?: string[];
427
- /**
428
- * Static dictionary scope (`ValueHelpInfo.filter`) — AND'd with the search
429
- * filter and with `$search`. Since 0.1.148.
430
- */
431
- filter?: FilterExpr;
432
- /**
433
- * The target field the picker commits (`ValueHelpInfo.targetField`). It is
434
- * selected, and it is the exact-match key of a non-searchable search — a
435
- * composite-key dictionary's `primaryKeys[0]` is not the value. Default:
436
- * `primaryKeys[0]`. Since 0.1.148.
437
- */
438
- valueField?: string;
439
- }
440
- interface ValueHelpResult {
441
- items: Record<string, unknown>[];
442
- }
443
- /**
444
- * How long (ms) a settled value-help search is reused for an identical
445
- * search on the same client. Default 5000. `0` shares only searches still in
446
- * flight; a negative value turns sharing off. Server-side rendering never
447
- * shares (one process serves many viewers).
448
- */
449
- declare function setValueHelpCacheTtl(ms: number): void;
450
- /**
451
- * Drop shared value-help search results — for one `client`, or for every
452
- * client when omitted. Call after writing to a dictionary outside the
453
- * built-in table actions to make pickers refetch at once.
454
- */
455
- declare function invalidateValueHelpCache(client?: Client): void;
456
- /**
457
- * Value-help query client. Wraps a `Client` from `@atscript/db-client`
458
- * with FK-specific search logic (regex fallback for non-searchable tables,
459
- * $select scoping).
460
- *
461
- * Consumers resolve the target's metadata once via `resolveValueHelp(url)`
462
- * and pass the resulting `ResolvedValueHelp` to `search()`. Label resolution
463
- * for cells is deliberately unsupported — cells always display raw ids.
464
- *
465
- * Identical searches on the same `Client` are shared (see
466
- * {@link setValueHelpCacheTtl}).
467
- */
468
- declare class ValueHelpClient {
469
- private readonly _client;
470
- constructor(client: Client);
471
- /**
472
- * Search the target with value-help semantics.
473
- *
474
- * - If target is searchable → sends `$search` (server full-text)
475
- * - If not searchable → sends `$or` regex across select fields + exact PK match
476
- */
477
- search(resolved: ResolvedValueHelp, opts?: ValueHelpSearchOptions): Promise<ValueHelpResult>;
478
- }
479
- //#endregion
480
- //#region src/value-help/dict-paths.d.ts
481
- /**
482
- * Paths that make up the "dict view" of a value-help target:
483
- * PKs + label + descr + attr fields. Used by filter dialogs to clamp
484
- * visible columns to the dictionary subset.
485
- */
486
- declare function valueHelpDictPaths(resolved: ResolvedValueHelp): Set<string>;
487
- //#endregion
488
- //#region src/value-help/extract-literals.d.ts
489
- /**
490
- * One literal of a union: `key` / `label` are the string forms the UI keys
491
- * on; `value` is the typed literal (`true`, `3`, `'a'`) — what a filter or a
492
- * form must send to the server. `value` since 0.1.148.
493
- */
494
- interface LiteralOption {
495
- key: string;
496
- label: string;
497
- value: string | number | boolean;
498
- }
499
- /**
500
- * Extracts options from a union of literal types (e.g. 'a' | 'b' | 'c').
501
- * Returns undefined if the type is not a pure union of literals.
502
- *
503
- * Handles nested unions created by flattenAnnotatedType, which recurses
504
- * into union items and produces synthetic unions containing both individual
505
- * literals and the original union type as nested items.
506
- */
507
- declare function extractLiteralOptions(prop: TAtscriptAnnotatedType, outer?: TAtscriptAnnotatedType): LiteralOption[] | undefined;
508
- /**
509
- * The literal options of a field: a literal union's, or those of an array of one
510
- * (`tags: Tag[]`), where the array prop's own `@ui.literalLabel` labels win over the
511
- * element type's. `undefined` when the field is neither. Since 0.1.148.
512
- */
513
- declare function extractFieldLiteralOptions(prop: TAtscriptAnnotatedType): LiteralOption[] | undefined;
514
- /** Returns true when the annotated type is a union composed entirely of literal values. */
515
- declare function isPureLiteralUnion(prop: TAtscriptAnnotatedType): boolean;
516
- //#endregion
517
- //#region src/value-help/extract-ref.d.ts
518
- /**
519
- * Synchronous probe. Returns `{ url, targetField }` for the first link of the
520
- * reference chain starting at `prop` that carries a `@ui.valueHelp` binding
521
- * (since 0.1.148 — an explicit binding beats `@db.rel.FK`, and also supplies
522
- * the static `filter` / `pinned` fields), or that satisfies all three conditions:
523
- *
524
- * 1. the link carries `@db.rel.FK`,
525
- * 2. the link has a `.ref`,
526
- * 3. the ref's target metadata carries `@db.http.path`.
527
- *
528
- * Since 0.1.134 the probe follows **reference chains**: when a link does not
529
- * qualify, it hops onto the referenced field (`ref.type()` → that object's
530
- * `props[ref.field]`) and re-tests. A view field declared as
531
- * `errorCode: Issue.errorCode`, where `Issue.errorCode: ErrorCode.code` is the
532
- * link carrying `@db.rel.FK`, therefore keeps its value help instead of losing
533
- * the dictionary.
534
- *
535
- * This mirrors what the server already does on the `/meta` path: since
536
- * `@atscript/db` 0.1.128 the serialized meta collapses such chains onto the
537
- * terminal field (`ref` → terminal, `db.rel.FK: true`), so a form def built
538
- * from `/meta` and one built from the compiled `.as` type land on the same
539
- * dictionary.
540
- *
541
- * The walk is bounded ({@link MAX_REF_CHAIN_DEPTH}), which is also what makes a
542
- * cyclic chain terminate (it runs out of hops and gives up instead of looping).
543
- * It stops as soon as a link has no `.ref`, or the referenced
544
- * field cannot be found — e.g. behind a shallow `{ id, metadata }` ref target
545
- * from `/meta`, which carries no props (and needs none: the server already
546
- * resolved the chain).
547
- */
548
- declare function extractValueHelp(prop: TAtscriptAnnotatedType): ValueHelpInfo | undefined;
549
- //#endregion
550
- //#region src/value-help/resolve-options.d.ts
551
- /** Extracts the key from an option entry. */
552
- declare function optKey(opt: TFormEntryOptions): string;
553
- /** Extracts the display label from an option entry. */
554
- declare function optLabel(opt: TFormEntryOptions): string;
555
- /**
556
- * The display label of a literal-union column's option (`@ui.literalLabel`) for
557
- * `value` — `undefined` when the column has no options or none matches. Map-backed
558
- * per options array, so rendering a table does not scan the options per cell.
559
- * The one lookup behind the table cell, the filter chips, export and a custom cell.
560
- * Since 0.1.148.
561
- */
562
- declare function optionLabel(column: {
563
- options?: {
564
- key: string;
565
- label: string;
566
- }[];
567
- }, value: unknown): string | undefined;
568
- /**
569
- * Converts raw option annotation value to a normalized array.
570
- */
571
- declare function parseStaticOptions(raw: unknown): TFormEntryOptions[];
572
- /**
573
- * Resolves options from metadata with a fallback chain:
574
- * 1. `@ui.form.fn.options` (dynamic, compiled by ui-fns)
575
- * 2. `@ui.form.options` (static annotation)
576
- * 3. Literal union type extraction (auto-derived from type)
577
- * 4. Future: dictionary / value-help lookup
578
- */
579
- declare function resolveOptions(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>): TFormEntryOptions[] | undefined;
580
- //#endregion
581
- //#region src/value-help/distinct-client.d.ts
582
- interface DistinctValuesOptions {
583
- /** Search text: a case-insensitive prefix match for strings, an exact match for numbers. */
584
- text?: string;
585
- /** Page size. Default: 50. */
586
- limit?: number;
587
- /**
588
- * Rows to skip (the next page of a scrolled picker). Distinct values are only
589
- * stable across pages when ordered, so a caller pages only with `sortable`.
590
- */
591
- skip?: number;
592
- /** Send `$sort` on the grouped field — only when the server lists it as sortable. */
593
- sortable?: boolean;
594
- /** The field stores numbers: search is an exact match and non-numeric text finds nothing. */
595
- numeric?: boolean;
596
- /** Extra scope AND'd into the query (e.g. the table's `forceFilters`). */
597
- filter?: FilterExpr;
598
- }
599
- /**
600
- * `true` for a 4xx answer — the server declined this picker (gate, ARBAC, unknown field).
601
- * @internal Shared with `@atscript/vue-table`.
602
- */
603
- declare function isPickerDeclined(err: unknown): boolean;
604
- /**
605
- * Distinct values of one column of the table behind `client`, via
606
- * `/query?$groupBy=<field>`. All server gates (hidden field, ARBAC `$groupBy`
607
- * control, row scope, write-only, encrypted) apply as for any grouped read; a
608
- * 4xx rejects with a `ClientError` — see {@link isPickerDeclined}.
609
- * `hasMore` tells whether another page follows.
610
- *
611
- * @internal Backs the distinct-values picker of `@atscript/vue-table`.
612
- */
613
- declare function fetchDistinctValues(client: Pick<Client, "aggregate">, field: string, opts?: DistinctValuesOptions): Promise<{
614
- items: unknown[];
615
- hasMore: boolean;
616
- }>;
617
- //#endregion
618
- //#region src/form/path-utils.d.ts
619
- /**
620
- * Joins a dot-separated path prefix with a segment. Empty-safe on both
621
- * sides: an empty segment returns the prefix as-is, an empty prefix
622
- * returns the segment as-is (no leading/trailing dots).
623
- */
624
- declare function joinPath(prefix: string, segment: string): string;
625
- /**
626
- * Gets a nested value by dot-separated path.
627
- * Always dereferences `obj.value` first (form data is wrapped in `{ value: domainData }`).
628
- * When `path` is empty, returns the root domain data (`obj.value`).
629
- */
630
- declare function getByPath(obj: Record<string, unknown>, path: string): unknown;
631
- /**
632
- * Sets a nested value by dot-separated path.
633
- * Always dereferences `obj.value` first (form data is wrapped in `{ value: domainData }`).
634
- * When `path` is empty, sets the root domain data (`obj.value = value`).
635
- * Creates intermediate objects if they do not exist.
636
- */
637
- declare function setByPath(obj: Record<string, unknown>, path: string, value: unknown): void;
638
- /**
639
- * Deletes the own key at a dot-separated path (form-data wrapper aware — derefs
640
- * `obj.value` first). Walks to the parent WITHOUT vivifying intermediate nodes:
641
- * if any ancestor is missing, the call is a no-op (nothing to delete).
642
- *
643
- * Unlike `setByPath(obj, path, undefined)`, this leaves NO own key behind — the
644
- * leaf reads as absent (`'k' in parent === false`), which keeps `deepEqual`
645
- * structural comparisons in sync (a present `undefined` own-key and an absent
646
- * key are NOT structurally equal under the own-key walk). Used by
647
- * {@link applyFormChanges} to apply a clear-to-`undefined` change as a delete.
648
- *
649
- * Empty path clears the root domain value (`obj.value = undefined`).
650
- */
651
- declare function deleteByPath(obj: Record<string, unknown>, path: string): void;
652
- /** Value resolver function type — created once per form, reused across calls. */
653
- type TFormValueResolver = (prop: TAtscriptAnnotatedType, path: string) => unknown;
654
- declare function createFormValueResolver(data?: Record<string, unknown>, context?: Record<string, unknown>): TFormValueResolver;
655
- declare function createFormData<T extends TAtscriptAnnotatedType>(type: T, resolver?: TFormValueResolver): {
656
- value: TAtscriptDataType<T>;
657
- };
658
- declare function detectUnionVariant(value: unknown, variants: FormUnionVariant[]): number;
659
- //#endregion
660
- //#region src/form/clone.d.ts
661
- /**
662
- * Optional per-value unwrap hook. Lets a framework caller strip a reactive
663
- * proxy off every visited value before it is copied (e.g. Vue's `toRaw`). The
664
- * core never needs it — it is `undefined` here and the value passes through.
665
- */
666
- type CloneUnwrap = (value: unknown) => unknown;
667
- /**
668
- * Structural deep clone of plain JSON-ish data (objects / arrays / primitives /
669
- * `Date`). Walks OWN-ENUMERABLE keys only (matches the own-key discipline in
670
- * `diff.ts` — never copies an accidental prototype) and copies leaves by value.
671
- *
672
- * `structuredClone` is deliberately NOT used: it throws on functions and on Vue
673
- * reactive proxies. The optional `unwrap` hook lets a framework caller
674
- * de-proxy each value first (vue-form passes `toRaw`); the core omits it.
675
- *
676
- * The SINGLE deep-clone primitive for the form engine — used by
677
- * `applyFormChanges`, `buildFormRebase`, and vue-form's baseline snapshot. Do
678
- * not reimplement structural cloning elsewhere.
679
- */
680
- declare function deepClone<T>(value: T, unwrap?: CloneUnwrap): T;
681
- //#endregion
682
- //#region src/form/validate.d.ts
683
- /** Per-call options for the form validator function. */
684
- interface TFormValidatorCallOptions {
685
- data: Record<string, unknown>;
686
- context?: Record<string, unknown>;
687
- }
688
- /** Replace the default validator plugins applied to every form/field validator. */
689
- declare function setDefaultValidatorPlugins(plugins: TValidatorPlugin[]): void;
690
- /** Get the currently registered default validator plugins. */
691
- declare function getDefaultValidatorPlugins(): TValidatorPlugin[];
692
- /**
693
- * Returns a reusable validator function for a whole FormDef.
694
- *
695
- * Validator is created once and reused on every call.
696
- * ATScript's @expect.* validation runs automatically; server-managed db
697
- * fields (every `derived` field, absent `@db.default*` / version) pass.
698
- * For custom `ui.fn.*` validators, install ui-fns and pass its plugin via `opts.plugins`.
699
- *
700
- * Errors are keyed by dotted path. A root-level error (a failing
701
- * `@ui.form.validate` on the form's interface) is keyed `__form`.
702
- */
703
- declare function getFormValidator(def: FormDef, opts?: Partial<TValidatorOptions>): (callOpts: TFormValidatorCallOptions) => Record<string, string>;
704
- /** Options for createFieldValidator. */
705
- interface TFieldValidatorOptions {
706
- /** Only report errors at the root path (for structure/array container validation). */
707
- rootOnly?: boolean;
708
- }
709
- /**
710
- * Whether a type kind is a container that carries its own children:
711
- * `object`, `array` or `tuple`. Union / intersection kinds are not
712
- * containers — they evaluate their branches at their own path.
713
- */
714
- declare function isContainerKind(kind: string): boolean;
715
- /**
716
- * Creates a cached validator function for a single ATScript prop.
717
- *
718
- * The `Validator` instance is created lazily on first call and reused.
719
- * Returns `true` when valid, or the first error message string when invalid.
720
- * With `rootOnly`, an object / array / tuple prop is validated at its root
721
- * only (descendants are not walked — their errors would be discarded anyway).
722
- */
723
- declare function createFieldValidator(prop: TAtscriptAnnotatedType, opts?: TFieldValidatorOptions): (value: unknown, externalCtx?: {
724
- data: unknown;
725
- context: unknown;
726
- }) => true | string;
727
- //#endregion
728
- //#region src/form/diff.d.ts
729
- /**
730
- * One field that differs between baseline and current.
731
- *
732
- * - `kind: 'set'` — scalar / object / union / tuple field whose value changed
733
- * (including a clear-to-`null`). `before` / `after` are the whole values at
734
- * `path`.
735
- * - `kind: 'array'` — array field whose membership or item content changed.
736
- * `before` / `after` are the whole arrays.
737
- *
738
- * NOTE: `before` / `after` hold live references into the supplied `baseline` /
739
- * `current` containers — see {@link buildFormDiff} for the snapshot contract.
740
- */
741
- interface FormFieldChange {
742
- /** Dot-separated path relative to the form root (matches FormFieldDef.path). */
743
- path: string;
744
- kind: "set" | "array";
745
- before: unknown;
746
- after: unknown;
747
- }
748
- /** Options for {@link buildFormDiff}. */
749
- interface FormDiffOptions {
750
- /**
751
- * Optimistic-concurrency control. When `true` (default), a top-level
752
- * `$cas: { [versionColumn]: baselineVersion }` sibling is auto-included in
753
- * the patch whenever the form has a `@db.column.version` column AND the
754
- * patch is non-empty AND a baseline version value exists. `false` suppresses
755
- * it entirely.
756
- *
757
- * Independent of `$cas`, the `@db.column.version` column is ALWAYS excluded
758
- * from the SET diff: it is server-managed, and a direct write to it is
759
- * rejected by `@atscript/db` (`DbError('VERSION_COLUMN_WRITE')`). It is only
760
- * ever round-tripped through `$cas`.
761
- */
762
- cas?: boolean;
763
- }
764
- /** Result of {@link buildFormDiff}. */
765
- interface FormDiffResult {
766
- /** True when at least one field changed (revert-aware). */
767
- isDirty: boolean;
768
- /** Per-field changes (revert-aware — reverted fields are absent). */
769
- changes: FormFieldChange[];
770
- /**
771
- * `@atscript/db` patch object — flat, keyed by field name. Empty `{}` when
772
- * nothing changed. Carries a top-level `$cas` sibling when `opts.cas` is on
773
- * and a version column exists.
774
- */
775
- patch: Record<string, unknown>;
776
- }
777
- /**
778
- * Diffs a form's `current` data against its `baseline` snapshot, producing both
779
- * a changed-fields list and an `@atscript/db` patch object.
780
- *
781
- * Both `baseline` and `current` are the WRAPPED form-data container
782
- * (`{ value: domainData }`) so this reuses {@link getByPath}.
783
- *
784
- * Revert-aware: a value edited back to its baseline produces no change and no
785
- * patch entry.
786
- *
787
- * Snapshot contract: the result is NOT a deep copy. `$insert` items, `$replace`
788
- * arrays, scalar leaf values, and `changes[].before/after` all hold live
789
- * references into `baseline` / `current`. Callers that keep editing the form
790
- * after building the patch must snapshot first (e.g. build the patch at submit
791
- * time on a frozen clone). This is the common Vue v-model flow.
792
- */
793
- declare function buildFormDiff(def: FormDef, baseline: Record<string, unknown>, current: Record<string, unknown>, opts?: FormDiffOptions): FormDiffResult;
794
- /**
795
- * Structural deep equality (order-sensitive for arrays). `NaN` equals `NaN`
796
- * (revert-aware for NaN scalars) while `0` / `-0` stay equal (matches DB
797
- * intent — `===` treats them equal, only NaN is special-cased).
798
- *
799
- * The single comparator shared across the form engine: diff, conflict
800
- * detection ({@link buildFormRebase}), and apply all route through this — never
801
- * reimplement equality elsewhere.
802
- */
803
- declare function deepEqual(a: unknown, b: unknown): boolean;
804
- //#endregion
805
- //#region src/form/dirty.d.ts
806
- /**
807
- * True when the field at dot-path `path` is dirty given a {@link FormFieldChange}
808
- * list (as produced by {@link buildFormDiff}).
809
- *
810
- * The change list is leaf-grained for scalars/objects but WHOLE-ARRAY for arrays,
811
- * so a field at `path` is dirty iff some change path equals `path` OR starts with
812
- * `path + "."`:
813
- *
814
- * - scalar / leaf field (incl. nested `address.city`) → exact match.
815
- * - object / section container → no entry at its own path, only its leaves →
816
- * matched by the PREFIX branch.
817
- * - whole-array field → one entry at the array root → exact match.
818
- * - a field rendered for an array-ITEM leaf (e.g. `items.0.qty`) → NOT detectable:
819
- * the array diff emits a single whole-array change at the array root, never
820
- * per-item leaf paths, so this correctly returns false (the array container
821
- * lights up instead). This is a known, documented limitation.
822
- *
823
- * The prefix uses `path + "."` so field `item` never matches a change at `items`
824
- * (no false positives).
825
- *
826
- * Empty `path` `''` is the wrapped form root — every change is nested under it,
827
- * so it is considered dirty iff there are ANY changes.
828
- */
829
- declare function isPathDirty(changes: FormFieldChange[], path: string): boolean;
830
- /**
831
- * Precomputes the set of ALL dirty paths from a {@link FormFieldChange} list so
832
- * that membership is an O(1) `Set.has(path)` instead of {@link isPathDirty}'s
833
- * per-call O(changes) prefix scan. Callers that probe many fields against the
834
- * same change list (e.g. a form rendering one field per leaf) build this once
835
- * and query it per field.
836
- *
837
- * For each change path `C` it adds `C` AND every dot-prefix ancestor of `C`
838
- * (so `'address.city'` adds both `'address.city'` and `'address'`), matching
839
- * `isPathDirty`'s "exact OR `path + '.'` prefix" predicate — an ancestor
840
- * container is dirty exactly when some change is nested under it. The wrapped
841
- * root `''` is added iff there are ANY changes, mirroring `isPathDirty('')`.
842
- *
843
- * INVARIANT (locked, tested): for EVERY path `P`,
844
- * `collectDirtyPaths(changes).has(P) === isPathDirty(changes, P)`. This is a
845
- * precompute of the SAME predicate, not a second one — keep them in lockstep.
846
- */
847
- declare function collectDirtyPaths(changes: FormFieldChange[]): Set<string>;
848
- //#endregion
849
- //#region src/form/apply.d.ts
850
- /**
851
- * Applies a {@link FormFieldChange} list onto a WRAPPED form-data container
852
- * (`{ value: domainData }`), mutating it in place and returning the same
853
- * reference. The inverse direction of {@link buildFormDiff}: where the diff
854
- * READS `(baseline, current)` into changes, this WRITES changes onto data.
855
- *
856
- * IMPORTANT: pass a CLONE, never the live fetched row — every write mutates
857
- * `data` directly. Callers that need the original intact should
858
- * `deepClone(data)` first (see {@link deepClone}).
859
- *
860
- * Per-change semantics (the single place the apply rules live, so
861
- * {@link buildFormRebase} stays consistent):
862
- *
863
- * - `kind: 'set'`:
864
- * - `change.after === undefined` → DELETE the own key at `change.path` (walk
865
- * to parent, `delete`). A cleared field must read as ABSENT, not as a
866
- * present `undefined` own-key — otherwise a re-diff sees a structural
867
- * mismatch where the form intends "no value". `setByPath(…, undefined)`
868
- * leaves an own key behind, so we use {@link deleteByPath} instead.
869
- * - otherwise → `setByPath(data, change.path, change.after)`.
870
- * - `kind: 'array'`: whole-array set via `setByPath(data, change.path,
871
- * change.after)` (LOCKED Option A — no per-element merge; the diff already
872
- * carried the full after-array).
873
- *
874
- * The `def` is currently unused by the apply walk (paths fully describe the
875
- * write target) but is part of the signature for parity with
876
- * `buildFormDiff`/`buildFormRebase`, so the rebase engine threads one `def`
877
- * uniformly through diff + apply.
878
- */
879
- declare function applyFormChanges(_def: FormDef, data: Record<string, unknown>, changes: FormFieldChange[]): Record<string, unknown>;
880
- //#endregion
881
- //#region src/form/rebase.d.ts
882
- /** Options for {@link buildFormRebase}. */
883
- interface FormRebaseOptions {
884
- /**
885
- * How to resolve a field changed on BOTH sides (local edit vs. upstream
886
- * edit) to a different value:
887
- * - `'ours'` (default) — keep the local edit, discard upstream's value.
888
- * - `'theirs'` — take upstream's value, discard the local edit.
889
- *
890
- * A field changed on both sides to the SAME value is never a conflict.
891
- */
892
- conflict?: "ours" | "theirs";
893
- }
894
- /** Result of {@link buildFormRebase}. */
895
- interface FormRebaseResult {
896
- /**
897
- * The rebased WRAPPED form-data container (`{ value }`). Always a fresh deep
898
- * clone of `upstream` with the local diff reapplied — never aliases any
899
- * input container.
900
- */
901
- next: Record<string, unknown>;
902
- /**
903
- * Paths that were changed on both sides to different values (same-path
904
- * conflicts), plus ancestor paths whose subtree upstream cleared while local
905
- * still edited a leaf under it (ancestor-clear conflicts). De-duplicated.
906
- */
907
- conflicts: string[];
908
- /**
909
- * The diff of `next` against the NEW baseline (`upstream`) — i.e. exactly the
910
- * changes that survive on top of upstream. Empty `[]` when the rebased form
911
- * equals upstream (a fully clean / fully reverted rebase).
912
- *
913
- * The returned `reapplied` does NOT alias the returned `next`, so installing
914
- * `next` as live form data never retroactively mutates the returned change set.
915
- */
916
- reapplied: FormFieldChange[];
917
- }
918
- /**
919
- * Pure 3-way rebase for a change-tracked form. Given the current baseline `B0`,
920
- * the live form `C`, and a fresh upstream `U`, produces the form rewritten as
921
- * `U` + the local diff (`C` vs `B0`) reapplied on top:
922
- *
923
- * - Fields the user never touched adopt upstream's value.
924
- * - Local edits survive (reapplied onto the upstream clone).
925
- * - Fields changed on BOTH sides to different values are conflicts, resolved by
926
- * `opts.conflict` (`'ours'` keeps local, `'theirs'` takes upstream).
927
- *
928
- * All inputs are WRAPPED form-data containers (`{ value: domainData }`). The
929
- * result `next` is a fresh container; no input is mutated.
930
- *
931
- * `diffOptions` are forwarded to BOTH internal `buildFormDiff` passes so the
932
- * same field exclusions apply (notably the `@db.column.version` column and the
933
- * `$cas` policy) on the local and upstream sides — keep them identical to the
934
- * options the caller uses for its own change tracking.
935
- */
936
- declare function buildFormRebase(def: FormDef, baseline: Record<string, unknown>, current: Record<string, unknown>, upstream: Record<string, unknown>, opts?: FormRebaseOptions, diffOptions?: FormDiffOptions): FormRebaseResult;
937
- //#endregion
938
- //#region src/form/union-detect.d.ts
939
- /**
940
- * True when ANY union field in the form resolves to a DIFFERENT discriminated
941
- * variant between two wrapped data containers. A variant picker typically
942
- * detects its variant index once at setup and keys the variant subtree on it,
943
- * so a rebase that lands a different variant (via conflict OR an upstream-only
944
- * switch) needs a remount to re-detect. This walks union + nested-object fields
945
- * and compares `detectUnionVariant` at each union path.
946
- *
947
- * Scope note (pragmatic): walks standalone + nested-OBJECT union fields. Unions
948
- * nested INSIDE array items are not walked — an array renderer that keeps a
949
- * stable per-item key across in-place value mutations would not remount an
950
- * existing row's picker on an upstream-driven variant flip, but that collision
951
- * (a 3-way rebase landing a different union variant inside an unchanged array
952
- * row) is a rare edge. TODO: extend to array-item unions if a real consumer
953
- * hits a stuck picker inside an array row.
954
- */
955
- declare function unionVariantChanged(def: FormDef, before: Record<string, unknown>, after: Record<string, unknown>): boolean;
956
- //#endregion
957
- //#region src/form/error-utils.d.ts
958
- /**
959
- * Framework-agnostic helpers for working with form-error maps keyed by
960
- * dotted path. Used by AsForm to drive error badges and auto-open
961
- * collapsed sections; safe to share with React (or any other) bindings.
962
- *
963
- * Convention:
964
- * - Keys are dotted paths (`a.b.c`); empty string and `__form` denote
965
- * the form-level error.
966
- * - Values may be `string | undefined`; falsy entries are dropped on
967
- * merge.
968
- */
969
- /** Error-map key of the form-level error. */
970
- declare const FORM_ERROR_KEY = "__form";
971
- /**
972
- * Turn a validator's error list into an error map keyed by path. A
973
- * root-level error (empty path) becomes the form-level error
974
- * ({@link FORM_ERROR_KEY}). The first error per path wins: a failing
975
- * container rule is reported before the container's own shape / length
976
- * checks at the same path.
977
- */
978
- declare function validatorErrorsToMap(errors: ReadonlyArray<{
979
- path: string;
980
- message: string;
981
- }>): Record<string, string>;
982
- /**
983
- * Merge any number of partial error maps into a single dense
984
- * `Record<path, message>`. Falsy values are skipped — later sources do
985
- * NOT overwrite earlier ones with an empty value.
986
- */
987
- declare function mergeErrorMaps(...maps: Array<Record<string, string | undefined> | undefined>): Record<string, string>;
988
- /**
989
- * Return `errors` without the entries whose key is in `paths`.
990
- *
991
- * Identity-preserving: when no key matches, the ORIGINAL `errors` object
992
- * is returned unchanged — callers compare `result !== errors` to detect
993
- * that something was pruned and skip spurious reactive writes.
994
- */
995
- declare function omitPaths(errors: Record<string, string>, paths: ReadonlySet<string>): Record<string, string>;
996
- /**
997
- * Yield every ancestor prefix of a dotted path, longest-first
998
- * (`a.b.c` → `a.b.c`, `a.b`, `a`). Returns the path itself first so
999
- * callers can include it in the iteration without a special case.
1000
- *
1001
- * Empty paths and the form-level key (`__form`) yield nothing.
1002
- */
1003
- declare function iteratePathAncestors(path: string): Generator<string>;
1004
- /**
1005
- * Build an indexed `Map<absolutePath, descendantErrorCount>` so each
1006
- * struct in the tree can render an error-count badge in O(1).
1007
- *
1008
- * For every error path, the count is incremented on the path itself
1009
- * AND every dotted-path ancestor — so a struct at `a.b` reports the
1010
- * total of all errors at `a.b` or below.
1011
- */
1012
- declare function buildDescendantErrorCounts(errors: Record<string, string | undefined>): Map<string, number>;
1013
- //#endregion
1014
- //#region src/form/grid.d.ts
1015
- /** Grid layout parsing for `@ui.form.grid.colSpan` / `@ui.form.grid.rowSpan`. */
1016
- declare const DEFAULT_COL_SPAN = 12;
1017
- declare const DEFAULT_ROW_SPAN = 1;
1018
- /** Accepts "1"-"12" and the aliases "full" (12), "half" (6), "third" (4). */
1019
- declare function parseColSpan(raw: string | undefined): number | undefined;
1020
- /** Accepts numeric strings "1"+; rejects "0", negatives, decimals, aliases. */
1021
- declare function parseRowSpan(raw: string | undefined): number | undefined;
1022
- interface GridSpec {
1023
- col: {
1024
- desktop: number;
1025
- narrow: number;
1026
- };
1027
- row: {
1028
- desktop: number;
1029
- narrow: number;
1030
- };
1031
- }
1032
- /**
1033
- * Shape returned by `getFieldMeta(prop, UI_FORM_GRID_COL_SPAN | …ROW_SPAN)` —
1034
- * atscript codegen produces a struct from named multi-arg annotation specs.
1035
- */
1036
- interface GridSpanArgs {
1037
- desktop: string;
1038
- narrow?: string;
1039
- }
1040
- /**
1041
- * Resolve a field's grid footprint. Narrow defaults to full-width / single-row
1042
- * regardless of the desktop value, so authors can opt into a narrow override
1043
- * via the second annotation arg without it inheriting an unintended desktop span.
1044
- */
1045
- declare function resolveGridSpec(colSpan: GridSpanArgs | undefined, rowSpan: GridSpanArgs | undefined): GridSpec;
1046
- /**
1047
- * Build the UnoCSS class string for a field's grid footprint.
1048
- *
1049
- * - Skips desktop classes that match the default (`as-grid-item` already
1050
- * covers `col-span-full row-span-1`).
1051
- * - Skips narrow overrides that match the desktop value (no override needed).
1052
- * - The narrow variant uses the custom `as-narrow:` prefix, which the
1053
- * atscript-ui UnoCSS preset rewrites to `@container as-grid (max-width:
1054
- * 480px) { ... }`. The parent grid is registered as
1055
- * `container-name: as-grid` via the `as-form-grid` shortcut, so the
1056
- * rule resolves against the actual grid's inline size — not the viewport.
1057
- *
1058
- * Returned string is space-separated, ready to drop into a Vue class binding.
1059
- */
1060
- declare function buildGridClasses(spec: GridSpec): string;
1061
- //#endregion
1062
- //#region src/form/labels.d.ts
1063
- /** Singular label for an array field (used by AsArray for "Add <singular>"). */
1064
- declare function resolveSingularLabel(meta: TAtscriptAnnotatedType | undefined): string;
1065
- //#endregion
1066
- //#region src/form/measurement.d.ts
1067
- /**
1068
- * Resolved measurement annotations — currency / unit-of-measure / numeric
1069
- * precision. Read once at form/table-def construction time and surfaced as
1070
- * already-resolved values so downstream renderers (cells, default form
1071
- * components, custom inputs) never re-read annotation metadata.
1072
- */
1073
- interface MeasurementInfo {
1074
- /** Literal currency code from `@db.amount.currency 'EUR'`. */
1075
- currencyCode?: string;
1076
- /** Sibling-field path from `@db.amount.currency.ref 'fieldName'`. */
1077
- currencyRefField?: string;
1078
- /** Literal unit-of-measure from `@db.unit 'kg'`. */
1079
- unitCode?: string;
1080
- /** Sibling-field path from `@db.unit.ref 'fieldName'`. */
1081
- unitRefField?: string;
1082
- /** Decimal scale (fraction digits) — second arg of `@db.column.precision precision, scale`. */
1083
- precisionScale?: number;
1084
- }
1085
- /**
1086
- * Read measurement annotations off a single field prop. Returns `undefined`
1087
- * for any annotation that's absent — callers can spread the result into a
1088
- * larger record.
1089
- */
1090
- declare function extractMeasurement(prop: TAtscriptAnnotatedType): MeasurementInfo;
1091
- //#endregion
1092
- //#region src/form/decimal-format.d.ts
1093
- /**
1094
- * Framework-agnostic decimal formatting + parsing helpers shared by
1095
- * `@atscript/vue-table` (read-only cell display) and `@atscript/vue-form`
1096
- * (editable amount/measure inputs). Symmetric output is the contract —
1097
- * a value rendered in a cell must read identically when displayed in
1098
- * the form composables, modulo currency / unit adornment.
1099
- *
1100
- * The functions here are intentionally pure (no `Number()` round-trips
1101
- * in the storage value path) — decimal-as-string correctness depends on
1102
- * not bouncing through floats.
1103
- */
1104
- interface CurrencyDisplay {
1105
- /** Narrow symbol: "$" / "€" / "US$" depending on locale. Falls back to code on Intl failure. */
1106
- symbol: string;
1107
- /** Whether the symbol typically sits left or right of the amount. */
1108
- position: "prefix" | "suffix";
1109
- }
1110
- interface DecimalParts {
1111
- sign: "" | "-";
1112
- /** Integer part, no thousands separator, no leading zeros beyond "0". */
1113
- integer: string;
1114
- /** Decimal part as captured, no separator. Empty string if absent. */
1115
- decimal: string;
1116
- }
1117
- interface FormatDecimalOptions {
1118
- value: string | number | null | undefined;
1119
- /** Scale used for display (typically the effective scale, not DB scale). Trailing zeros pad. */
1120
- scale?: number;
1121
- locale?: string;
1122
- /** When set → Intl.NumberFormat with style:currency. Symbol/grouping handled by Intl. */
1123
- currency?: string;
1124
- /** When set (and no currency) → "<formatted> <unit>". */
1125
- unit?: string;
1126
- /**
1127
- * Whether to group thousands. Grouping is reserved for measured values, so
1128
- * the default is derived: true when `currency`, `unit`, or `scale` is set,
1129
- * false for plain numbers. Pass explicitly to override.
1130
- */
1131
- useGrouping?: boolean;
1132
- }
1133
- /** "." in en-US, "," in fr-FR. Returns "." when locale is undefined. */
1134
- declare function getDecimalSeparator(locale?: string): string;
1135
- /**
1136
- * "," in en-US, NNBSP (U+202F) in fr-FR. Returns "" when no grouping is
1137
- * applied (or when Intl rejects the locale).
1138
- */
1139
- declare function getThousandsSeparator(locale?: string): string;
1140
- declare function getCurrencyDisplayParts(code: string, locale?: string): CurrencyDisplay;
1141
- /**
1142
- * Currency's natural decimal count via Intl. JPY=0, USD/EUR=2, BHD/KWD=3.
1143
- * Returns `undefined` for codes Intl doesn't know — caller falls back to
1144
- * `dbPrecisionScale`.
1145
- */
1146
- declare function getCurrencyDecimals(code: string, locale?: string): number | undefined;
1147
- /**
1148
- * Parse a user-typed decimal string. Returns the canonical decimal
1149
- * (no thousands separator, "." as decimal separator) or `null` if invalid.
1150
- * Accepts both "." and "," as the decimal separator (locale-aware).
1151
- * Strips the locale thousands separator. Preserves sign. Does NOT
1152
- * enforce scale.
1153
- */
1154
- declare function parseDecimalInput(raw: string, locale?: string): string | null;
1155
- /**
1156
- * Enforce a fractional-digit count by truncating or padding. String-only —
1157
- * no float arithmetic. Default behaviour truncates (no rounding) so digits
1158
- * the user typed can't silently shift. Pass `roundHalfUp: true` to round.
1159
- *
1160
- * enforceScale("12.345", 2) → "12.34" (truncate)
1161
- * enforceScale("12.3", 4) → "12.3000" (pad)
1162
- * enforceScale("12", 0) → "12"
1163
- * enforceScale("12.99", 0) → "12" (no rounding)
1164
- */
1165
- declare function enforceScale(s: string, scale: number | undefined, opts?: {
1166
- roundHalfUp?: boolean;
1167
- }): string;
1168
- declare function splitDecimalString(s: string): DecimalParts;
1169
- declare function joinDecimalString(parts: DecimalParts): string;
1170
- declare function formatDecimalForDisplay(opts: FormatDecimalOptions): string;
1171
- /**
1172
- * Insert the locale's thousands separator into a plain integer string.
1173
- * Pure string-based — no float math, handles arbitrary length.
1174
- */
1175
- declare function groupInteger(integer: string, locale?: string): string;
1176
- //#endregion
1177
- //#region src/table/types.d.ts
1178
- /** Search index metadata from the server. */
1179
- interface SearchIndexInfo {
1180
- name: string;
1181
- description?: string;
1182
- type?: "text" | "vector";
1183
- }
1184
- /** Relation summary in meta response. */
1185
- interface RelationInfo {
1186
- name: string;
1187
- direction: "to" | "from" | "via";
1188
- isArray: boolean;
1189
- /**
1190
- * `true` when the relation is `@db.rel.filterable`: the server accepts
1191
- * filters by related rows on it (`ticket: { $some: {…} }` /
1192
- * `{ $none: {…} }`, URL `ticket=$some(status=open)`). Absent otherwise.
1193
- * Tables display such predicates (residual filters) but offer no UI to
1194
- * author them. Needs `@atscript/moost-db` 0.1.147+. Since 0.1.147.
1195
- */
1196
- filterable?: boolean;
1197
- }
1198
- /** Per-field capability flags. */
1199
- interface FieldMeta {
1200
- sortable: boolean;
1201
- /** Whether the field accepts value comparisons (`=`, `>`, `$regex`, …). */
1202
- filterable: boolean;
1203
- /**
1204
- * Present only when `filterable` is `false` but narrower predicates still
1205
- * pass the server's gate — e.g. `["$exists"]` on a JSON-stored column.
1206
- * Needs `@atscript/moost-db` 0.1.132+. Since 0.1.139.
1207
- */
1208
- filterOps?: string[];
1209
- /**
1210
- * The caller may write this field but not read it (an access-control
1211
- * projection kept it in `/meta` for forms). The server rejects it in
1212
- * `$select`, filters and `$sort`, so it is never a table column and never
1213
- * fetchable. Since 0.1.141.
1214
- */
1215
- writeOnly?: boolean;
1216
- /**
1217
- * Server-computed (`@db.column.derived`, `@atscript/db` 0.1.141+): filterable
1218
- * and sortable like any column, but a value written to it is dropped. Forms
1219
- * read the annotation from the type itself (`FormFieldDef.derived`).
1220
- * Since 0.1.144.
1221
- */
1222
- derived?: boolean;
1223
- /**
1224
- * A computed view column (`@db.compute`, `@atscript/db` 0.1.147+): the
1225
- * database evaluates it from other fields of the view. It is a column like
1226
- * any other — sorting and filtering follow `sortable` / `filterable` —
1227
- * but never writable: `createFormDef` marks it `derived` when given these
1228
- * fields (`CreateFormDefOptions.metaFields`). Since 0.1.147.
1229
- */
1230
- computed?: boolean;
1231
- /**
1232
- * Display-only value the controller computes (`@DbDecorations`,
1233
- * `@atscript/moost-db` 0.1.148+): selectable, never filterable, sortable or
1234
- * groupable. `createTableDef` turns it into a column from
1235
- * `MetaResponse.decorations`. Since 0.1.148.
1236
- */
1237
- decoration?: boolean;
1238
- /**
1239
- * `$groupBy` on this field passes the server's gate (`@atscript/moost-db`
1240
- * 0.1.148+). Together with `filterable` and `@ui.valueHelp.distinct` it
1241
- * enables the distinct-values picker. Since 0.1.148.
1242
- */
1243
- groupable?: boolean;
1244
- }
1245
- /** Meta response from moost-db `/meta` endpoint. */
1246
- interface MetaResponse {
1247
- searchable: boolean;
1248
- vectorSearchable: boolean;
1249
- searchIndexes: SearchIndexInfo[];
1250
- primaryKeys: string[];
1251
- /**
1252
- * Preferred row identifier (UI/wire addressing). From
1253
- * `@db.table.preferredId.uniqueIndex` — defaults to `primaryKeys` when the
1254
- * server omits it (older servers / stub fixtures). Drives identifier object
1255
- * construction for action POSTs and `'navigate'` URL `$1` substitution.
1256
- */
1257
- preferredId: string[];
1258
- /**
1259
- * Server-managed OCC column name (from `@db.column.version`). When present,
1260
- * names a normal `int` field that ships with rows like any other column.
1261
- * Consumers MUST keep the field's value in update payloads — the server
1262
- * auto-lifts it to `$cas` to detect concurrent writes — but MUST NOT render
1263
- * it as a user-facing column, filter, or sorter. `createTableDef` skips it
1264
- * from the generated `columns[]` array on this basis.
1265
- */
1266
- versionColumn?: string;
1267
- crud: TCrudPermissions$1;
1268
- actions: TDbActionInfo$1[];
1269
- relations: RelationInfo[];
1270
- fields: Record<string, FieldMeta>;
1271
- type: TSerializedAnnotatedType;
1272
- /**
1273
- * The controller's declared display-only fields (`@DbDecorations`) as a
1274
- * serialized plain interface. Absent on older servers. Since 0.1.148.
1275
- */
1276
- decorations?: TSerializedAnnotatedType;
1277
- }
1278
- /**
1279
- * Server-declared actions grouped by `level`. Built by `createTableDef` from
1280
- * `meta.actions[]` — sorted within each group by `(order ?? 0)` then
1281
- * declaration order. `default.{table,row,rows}` is the first `default: true`
1282
- * entry per level (or `undefined`). The synthesised `__remove` UI action is
1283
- * never selected as a default.
1284
- */
1285
- interface TableActionsModel {
1286
- table: TDbActionInfo$1[];
1287
- row: TDbActionInfo$1[];
1288
- rows: TDbActionInfo$1[];
1289
- default: {
1290
- table?: TDbActionInfo$1;
1291
- row?: TDbActionInfo$1;
1292
- rows?: TDbActionInfo$1;
1293
- };
1294
- }
1295
- /** Complete table definition — produced by createTableDef(). */
1296
- interface TableDef {
1297
- type: TAtscriptAnnotatedType;
1298
- columns: ColumnDef[];
1299
- /**
1300
- * Flattened type tree (path → annotated prop). Empty Map for non-object roots.
1301
- * Excludes phantom types. Consumers (e.g. cell-resolver) read this instead
1302
- * of re-walking the type.
1303
- */
1304
- flatMap: Map<string, TAtscriptAnnotatedType>;
1305
- /**
1306
- * Server-returnable field paths (from meta.fields) — the gate for
1307
- * @ui.table.selectWith targets, includes @ui.table.exclude fields.
1308
- * `writeOnly` fields are not readable, so they are left out (since 0.1.141).
1309
- */
1310
- fetchableFields: Set<string>;
1311
- primaryKeys: string[];
1312
- /** Preferred row identifier — see `MetaResponse.preferredId`. */
1313
- preferredId: string[];
1314
- /**
1315
- * The row fields an action identifier is built from: `preferredId` plus
1316
- * every path a delegated action's `idMap` reads (an action another
1317
- * controller owns, e.g. a view listing its source table's actions). The
1318
- * table keeps these values on every identifier it hands to an action, so
1319
- * the client can map them to the owner's identification. Equals
1320
- * `preferredId` when no action carries an `idMap`. Always set by
1321
- * `createTableDef`; a hand-built `TableDef` may omit it (consumers fall back
1322
- * to `preferredId`). Since 0.1.147.
1323
- */
1324
- identifierFields?: string[];
1325
- /** Server-managed OCC column name — see `MetaResponse.versionColumn`. */
1326
- versionColumn?: string;
1327
- /** Per-op CRUD permissions advertised in `/meta`. Key absent → denied. */
1328
- crud: TCrudPermissions$1;
1329
- canRemove: boolean;
1330
- /** Server-declared actions, grouped by level with defaults pre-resolved. */
1331
- actions: TableActionsModel;
1332
- searchable: boolean;
1333
- vectorSearchable: boolean;
1334
- searchIndexes: SearchIndexInfo[];
1335
- relations: RelationInfo[];
1336
- }
1337
- /**
1338
- * Scalar storage kind of a column's value — what the server's filter guard
1339
- * checks. `string` / `date` / `isoDate` are `string`, `string.date` and
1340
- * `string.isoDate`; `timestamp` is `number.timestamp` (epoch ms).
1341
- * Since 0.1.148.
1342
- */
1343
- type ColumnValueKind = "string" | "date" | "isoDate" | "number" | "integer" | "decimal" | "timestamp" | "boolean";
1344
- /** A single column definition — built from field metadata + annotations. */
1345
- interface ColumnDef {
1346
- /** Field path in dot-notation (e.g. 'address.city'). */
1347
- path: string;
1348
- /** Display label — from @meta.label or humanized path. */
1349
- label: string;
1350
- /** Display type — from @ui.table.type, then @ui.type, then inferred from designType. */
1351
- type: string;
1352
- /**
1353
- * Scalar storage kind of the column's value, derived from the atscript type
1354
- * (a union of one kind counts; arrays, objects, JSON and mixed unions have
1355
- * none). Filter UIs and the query builder read it to pick the filter kind
1356
- * and to encode values the way the server's filter guard expects.
1357
- * Since 0.1.148.
1358
- */
1359
- valueKind?: ColumnValueKind;
1360
- /** Named component override from @ui.table.component — looked up in the table components map. */
1361
- component?: string;
1362
- /**
1363
- * Extra leaf field paths to include in `$select` whenever this column is displayed.
1364
- * Never rendered as columns; declared via @ui.table.selectWith.
1365
- */
1366
- selectWith?: string[];
1367
- /** Whether this column supports sorting. */
1368
- sortable: boolean;
1369
- /** Whether this column supports value filtering (the server's `filterable`). */
1370
- filterable: boolean;
1371
- /**
1372
- * Narrower filter operators the server accepts on a column that is not
1373
- * value-filterable — `["$exists"]` on a JSON-stored column, whose value
1374
- * cannot be compared but whose presence can. Copied from
1375
- * `meta.fields[path].filterOps`; omitted when absent. Filter UIs read it
1376
- * through `columnFilterConditions()` from `@atscript/ui-table`. Since 0.1.139.
1377
- */
1378
- filterOps?: string[];
1379
- /**
1380
- * Whether the column accepts `null` values (atscript prop is `optional`).
1381
- * Drives operator-picker availability — `null` / `notNull` are dropped
1382
- * for non-nullable columns since they can never match.
1383
- */
1384
- nullable: boolean;
1385
- /** Default column width from @ui.table.width. */
1386
- width?: string;
1387
- /** Maximum length constraint from @expect.maxLen — used to derive default column width. */
1388
- maxLen?: number;
1389
- /** Initial column ordering from @ui.table.order (lower = first). */
1390
- order: number;
1391
- /**
1392
- * Enumerated options for union literal types (e.g. 'a' | 'b' | 'c'). `value` is
1393
- * the typed literal (`true`, `3`) — what a filter sends to the server; the
1394
- * `key` is its string form. `createTableDef` always sets it (since 0.1.148);
1395
- * a hand-built column may omit it, and the string `key` is used.
1396
- */
1397
- options?: {
1398
- key: string;
1399
- label: string;
1400
- value?: string | number | boolean;
1401
- }[];
1402
- /** Value-help info for FK columns (from extractValueHelp). */
1403
- valueHelpInfo?: ValueHelpInfo;
1404
- /**
1405
- * Distinct-values picker (`@ui.valueHelp.distinct`): the table's own controller
1406
- * (`url`) answers the values of `field` via `$groupBy`. Set only when the server
1407
- * lists the field `filterable` and `groupable` and no dictionary help or literal
1408
- * options apply — independent of `valueHelpInfo`. Since 0.1.148.
1409
- */
1410
- distinct?: {
1411
- url: string;
1412
- field: string;
1413
- };
1414
- /** Literal currency code from `@db.amount.currency 'EUR'`. */
1415
- currencyCode?: string;
1416
- /** Sibling field path from `@db.amount.currency.ref 'fieldName'`. */
1417
- currencyRefField?: string;
1418
- /** Literal unit-of-measure from `@db.unit 'kg'`. */
1419
- unitCode?: string;
1420
- /** Sibling field path from `@db.unit.ref 'fieldName'`. */
1421
- unitRefField?: string;
1422
- /** Decimal scale (fraction digits) — second arg of `@db.column.precision precision, scale`. */
1423
- precisionScale?: number;
1424
- /**
1425
- * Synthesised, locked-chrome column. When `true`: header-cell column-menu
1426
- * skipped, resize handle skipped, drag-reorder excluded, NOT in the
1427
- * `columnNames` v-model. Used for the row-actions pseudo-column
1428
- * (`path: '__actions'`).
1429
- */
1430
- fixed?: boolean;
1431
- /**
1432
- * Client-owned (display-only) column: nothing on the server backs it, so it
1433
- * never enters `$select`, server sorting or filters. It still takes part in
1434
- * column visibility, reordering and presets like any other column. Produced
1435
- * from `<AsTableRoot :display-columns>`. A `local` column with
1436
- * `sortable: true` is sorted in memory over the loaded page, never by the
1437
- * server. Since 0.1.134.
1438
- */
1439
- local?: boolean;
1440
- }
1441
- /** A single sort directive. */
1442
- interface SortControl {
1443
- field: string;
1444
- direction: "asc" | "desc";
1445
- }
1446
- /** Pagination state. */
1447
- interface PaginationControl {
1448
- page: number;
1449
- itemsPerPage: number;
1450
- }
1451
- /** Reactive query state for a table — mirrors @uniqu/core controls. */
1452
- interface TableQueryState {
1453
- sort?: SortControl[];
1454
- pagination?: PaginationControl;
1455
- search?: string;
1456
- filters?: Record<string, unknown>;
1457
- }
1458
- //#endregion
1459
- //#region src/table/create-table-def.d.ts
1460
- /**
1461
- * Builds a TableDef from a moost-db MetaResponse.
1462
- *
1463
- * 1. Deserializes `meta.type` into a live TAtscriptAnnotatedType
1464
- * 2. Flattens to discover all field paths
1465
- * 3. Builds ColumnDef per field using annotations + meta.fields capabilities
1466
- * 4. Sorts by @ui.table.order
1467
- */
1468
- declare function createTableDef(meta: MetaResponse, preDeserializedType?: TAtscriptAnnotatedType): TableDef;
1469
- //#endregion
1470
- //#region src/table/value-kind.d.ts
1471
- /** Storage kinds that hold plain numbers (a `timestamp` is epoch ms, but filters treat it as a date). */
1472
- declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
1473
- /**
1474
- * The typed value of one of a column's `options` — the literal itself
1475
- * (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
1476
- * column that has no `value`.
1477
- *
1478
- * @internal Shared with `@atscript/vue-table`.
1479
- */
1480
- declare function optionValue(option: NonNullable<ColumnDef["options"]>[number]): string | number | boolean;
1481
- //#endregion
1482
- //#region src/client-factory.d.ts
1483
- /**
1484
- * Client options the library itself may ask a {@link ClientFactory} for —
1485
- * spread them into the `Client` options your factory builds:
1486
- *
1487
- * ```ts
1488
- * setDefaultClientFactory((url, opts) => new Client(url, { ...opts, fetch: myFetch }))
1489
- * ```
1490
- *
1491
- * - `metaKey` — the store key for `/meta` revalidation, set when a table is
1492
- * given `metaKey` (e.g. the route template of a parametric mount). Since 0.1.153.
1493
- * - `metaStore` — `false` during server rendering, so `/meta` bodies are never
1494
- * kept in a process-wide store shared by every viewer. Since 0.1.153.
1495
- */
1496
- type ClientFactoryOptions = Pick<ClientOptions, "metaKey" | "metaStore">;
1497
- /**
1498
- * Factory that creates a `Client` for a given URL.
1499
- *
1500
- * Single contract shared by every atscript-ui primitive that needs to talk
1501
- * to an atscript-db-compatible endpoint: table composables, FK value-help,
1502
- * and any future consumer. Produces a `Client` configured with whatever
1503
- * transport / auth wiring the host application wants. Forward the optional
1504
- * second argument ({@link ClientFactoryOptions}) into the `Client` options.
1505
- */
1506
- type ClientFactory = (url: string, options?: ClientFactoryOptions) => Client;
1507
- /**
1508
- * Override the app-wide default factory. Call once at startup (e.g. in
1509
- * `entry-client.ts`) to wire shared fetch, credentials, error handling, etc.
1510
- * Every table, value-help picker, and other client consumer will pick it up.
1511
- */
1512
- declare function setDefaultClientFactory(factory: ClientFactory): void;
1513
- /** Current app-wide default factory. Falls back to `new Client(url, options)`. */
1514
- declare function getDefaultClientFactory(): ClientFactory;
1515
- /** Reset the default factory to the built-in one (primarily for tests). */
1516
- declare function resetDefaultClientFactory(): void;
1517
- //#endregion
1518
- //#region src/shared/meta-cache.d.ts
1519
- /**
1520
- * Shared per-URL cache. A single entry holds the `Client` instance, the raw
1521
- * `/meta` promise, the deserialized type, and lazily-populated derived shapes
1522
- * (`ResolvedValueHelp` for value-help, `TableDef` for tables). Both
1523
- * `resolveValueHelp` and `useTable` route through it so a given URL triggers
1524
- * at most one network round-trip and one `deserializeAnnotatedType`.
1525
- *
1526
- * Byte-identical `/meta` bodies (same `ETag`, e.g. one parametric controller
1527
- * under different route params) also share the deserialized type and the
1528
- * `TableDef` across URLs.
1529
- *
1530
- * The cache keeps the {@link setMetaCacheMaxEntries} most recently used
1531
- * URLs; an entry held with {@link retainMetaEntry} is never evicted.
1532
- *
1533
- * `/meta` is projected per viewer, so the cache belongs to one identity
1534
- * (`setMetaCacheIdentity`) and exists only in the browser: during server
1535
- * rendering one process serves many viewers, so every call builds a fresh,
1536
- * uncached entry whose client keeps no `/meta` store.
1537
- */
1538
- interface MetaCacheEntry {
1539
- client: Client;
1540
- meta: Promise<MetaResponse>;
1541
- type: Promise<TAtscriptAnnotatedType>;
1542
- resolved?: Promise<ResolvedValueHelp>;
1543
- tableDef?: Promise<TableDef>;
1544
- }
1545
- /** Options for {@link getMetaEntry}. */
1546
- interface MetaEntryOptions {
1547
- /**
1548
- * Key under which the `/meta` revalidation store keeps this URL's `ETag`s
1549
- * (default: the `/meta` URL). Give every URL of one parametric mount the
1550
- * route template (e.g. `"/api/db/ticket-issue/:key"`): a new route param
1551
- * then revalidates against the body already loaded for another one and
1552
- * costs a `304` instead of the full `/meta`. Forwarded to the
1553
- * {@link ClientFactory} as `metaKey`; honoured only by the first call per
1554
- * URL, like the factory. Since 0.1.153.
1555
- */
1556
- metaKey?: string;
1557
- }
1558
- /**
1559
- * Get or create the cache entry for `url`. First caller's `factory` (and
1560
- * `options.metaKey`) seeds the `Client`; subsequent callers reuse it. On
1561
- * `meta` rejection, the entry is evicted so the next call retries. A hit
1562
- * marks the URL most recently used; hold an entry you keep using with
1563
- * {@link retainMetaEntry}. Without a browser `window` nothing is cached and
1564
- * the client is asked for `metaStore: false`.
1565
- */
1566
- declare function getMetaEntry(url: string, factory?: ClientFactory, options?: MetaEntryOptions): MetaCacheEntry;
1567
- /**
1568
- * Keep `entry` in the cache while it is in use: a held entry is never
1569
- * evicted by the size limit ({@link setMetaCacheMaxEntries}), so later
1570
- * `getMetaEntry` / `resolveValueHelp` calls for its URL keep returning it.
1571
- * Call the returned function (idempotent) once done — `useTable` and the
1572
- * form value-help do this for their component's lifetime. A reset still
1573
- * drops held entries. Since 0.1.154.
1574
- */
1575
- declare function retainMetaEntry(entry: MetaCacheEntry): () => void;
1576
- /**
1577
- * How many URLs the meta cache keeps (default `100`). Least recently used
1578
- * entries beyond it are dropped — entries held with {@link retainMetaEntry}
1579
- * (every mounted table and form value-help) never are, and may exceed it.
1580
- * At least `1`; `Infinity` turns the limit off; no argument restores the
1581
- * default. Since 0.1.154.
1582
- */
1583
- declare function setMetaCacheMaxEntries(max?: number): void;
1584
- /**
1585
- * The `TableDef` for a cache entry, built once per entry — and once per
1586
- * `/meta` `ETag` across entries. Since 0.1.153.
1587
- */
1588
- declare function getMetaTableDef(entry: MetaCacheEntry): Promise<TableDef>;
1589
- /**
1590
- * Drop every cached `/meta` — including the copy each cached `Client`
1591
- * memoizes and the `@atscript/db-client` meta stores used to revalidate it
1592
- * (the shared default one and any custom one a factory supplied) — the
1593
- * value-help searches shared under them, and everything registered through
1594
- * {@link onMetaCacheReset} (e.g. the table-presets cache). Entries already
1595
- * handed out keep working; the next `getMetaEntry` refetches.
1596
- */
1597
- declare function resetMetaCache(): void;
1598
- /**
1599
- * Bind the meta cache to the current viewer. Call it whenever the signed-in
1600
- * user or their role may have changed — after login, after logout and on
1601
- * every reload of the current user. A key that differs from the previous
1602
- * one resets the cache (`resetMetaCache`); the same key keeps it. `null` /
1603
- * `undefined` = anonymous.
1604
- *
1605
- * Binding an identity also turns on caches that are only safe when the app
1606
- * reports sign-in changes, such as the table-presets cache.
1607
- */
1608
- declare function setMetaCacheIdentity(key: string | null | undefined): void;
1609
- /**
1610
- * The identity last passed to {@link setMetaCacheIdentity}: `undefined` when
1611
- * the app never bound one, `null` for anonymous. Since 0.1.153.
1612
- */
1613
- declare function getMetaCacheIdentity(): string | null | undefined;
1614
- /**
1615
- * Run `listener` on every {@link resetMetaCache} (and so on every identity
1616
- * change). For caches that belong to the signed-in viewer. Returns an
1617
- * unsubscribe function. Since 0.1.153.
1618
- */
1619
- declare function onMetaCacheReset(listener: () => void): () => void;
1620
- //#endregion
1621
- //#region src/shared/str.d.ts
1622
- /** Escape special regex characters in user input for safe embedding in a `$regex` filter. */
1623
- declare function escapeRegex(input: string): string;
1624
- /** Safely convert an unknown value to a string without triggering no-base-to-string lint errors. */
1625
- declare function str(value: unknown): string;
1626
- //#endregion
1627
- //#region src/table/column-resolver.d.ts
1628
- /** Get sortable columns. */
1629
- declare function getSortableColumns(def: TableDef): ColumnDef[];
1630
- /** Get filterable columns. */
1631
- declare function getFilterableColumns(def: TableDef): ColumnDef[];
1632
- /** Find a column by path. */
1633
- declare function getColumn(def: TableDef, path: string): ColumnDef | undefined;
1634
- //#endregion
1635
- //#region src/table/navigate-href.d.ts
1636
- /**
1637
- * Compute the href a `processor: 'navigate'` action would open — synchronously,
1638
- * at render time. Mirrors the interpolation `Client` performs when the action
1639
- * is invoked (`action.value` with every `$1` replaced by the URL-encoded,
1640
- * `/`-joined `preferredId` fields — see `encodeNavigateId`), so tables can
1641
- * render navigate actions as real `<a href>` anchors and native link behaviour
1642
- * (middle-click → new tab, copy link, hover preview) just works.
1643
- *
1644
- * Returns `undefined` when no link is possible — the caller should fall back to
1645
- * a button and let `Client` handle the invoke:
1646
- *
1647
- * - `action.processor !== 'navigate'` — backend/custom actions stay buttons;
1648
- * - row-level action with `id === undefined` — the row is not identifiable
1649
- * (note this deliberately differs from `Client`, which navigates to the raw
1650
- * template in that case; a raw-template href would be a broken link);
1651
- * - row-level action with an empty `preferredId` — `$1` has nothing to encode.
1652
- *
1653
- * Table/rows-level navigate actions carry no `$1` placeholder and return
1654
- * `action.value` verbatim.
1655
- *
1656
- * A delegated action (`action.idMap`, since 0.1.147) reads `id` as one of THIS
1657
- * table's rows (or identifiers) and encodes the owner's identification it maps
1658
- * to, in `Object.keys(idMap)` order — the same as `Client`. A row the map
1659
- * cannot address (a missing path) has no link.
1660
- */
1661
- declare function navigateHrefFor(action: TDbActionInfo$1, id: Record<string, unknown> | undefined, preferredId: readonly string[]): string | undefined;
1662
- //#endregion
1663
- //#region src/nav/model-routes.d.ts
1664
- /** A navigable route derived from a DB-backed model's metadata. */
1665
- interface TModelRoute {
1666
- model: TAtscriptAnnotatedType;
1667
- /** Route path without leading/trailing slashes — mountable anywhere. */
1668
- path: string;
1669
- /** Display label — from @meta.label or humanized last path segment. */
1670
- label: string;
1671
- kind: "table" | "view";
1672
- /** Nav section from @ui.nav.group — grouping is the consumer's job. */
1673
- group?: string;
1674
- /** Position from @ui.nav.order — lower first, undefined last. */
1675
- order?: number;
1676
- /** From @ui.nav.hidden — hidden routes are still returned; consumers filter. */
1677
- hidden?: boolean;
1678
- }
1679
- /**
1680
- * Derives navigable routes from DB-backed models' metadata.
1681
- *
1682
- * A model is included only when it is a DB entity (`@db.table`, `@db.view`,
1683
- * or `@db.view.for`) AND a path can be derived: `@db.http.path` first, then
1684
- * the string value of `@db.table` / `@db.view`, then the type's own id
1685
- * as-is. Models where none of these yield a non-empty path are omitted.
1686
- *
1687
- * Routes are sorted by `order` ascending (undefined last, ties keep input
1688
- * order). Hidden models are returned with `hidden: true` — filtering and
1689
- * grouping are left to the consumer.
1690
- */
1691
- declare function buildModelRoutes(models: readonly TAtscriptAnnotatedType[]): TModelRoute[];
1692
- //#endregion
1693
- export { type ClientFactory, type ClientFactoryOptions, type CloneUnwrap, type ColumnDef, type ColumnValueKind, type CreateFormDefOptions, 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, FORM_ERROR_KEY, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, 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 MetaEntryOptions, type MetaResponse, NUMERIC_VALUE_KINDS, 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 TModelRoute, 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_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isContainerKind, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, onMetaCacheReset, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, retainMetaEntry, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setMetaCacheMaxEntries, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, validatorErrorsToMap, valueHelpDictPaths };
1
+ import { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, 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_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, WF_ACTION_WITH_DATA } from "./shared/annotation-keys.mjs";
2
+ import { TFormEntryOptions, ValueHelpInfo } from "./value-help/types.mjs";
3
+ import { FormArrayFieldDef, FormDef, FormFieldDef, FormObjectFieldDef, FormTupleFieldDef, FormUnionFieldDef, FormUnionVariant, TFormAction, isArrayField, isObjectField, isTupleField, isUnionField } from "./form/types.mjs";
4
+ import { CreateFormDefOptions, buildUnionVariants, createFormDef } from "./form/create-form-def.mjs";
5
+ import { FormActionInfo, getDeclaredFormActions } from "./form/form-actions.mjs";
6
+ import { FieldResolver, StaticFieldResolver, TResolveOptions, asArray, defaultResolver, getFieldMeta, getResolver, hasComputedAnnotations, hasFieldMeta, isFieldHidden, parseStaticAttrs, resolveAttrs, resolveFieldProp, resolveFormProp, resolveStatic, setResolver } from "./shared/field-resolver.mjs";
7
+ import { ClientFactory, ClientFactoryOptions, TypedClientFactory, getDefaultClientFactory, resetDefaultClientFactory, setDefaultClientFactory } from "./client-factory.mjs";
8
+ import { ColumnDef, ColumnValueKind, FieldMeta, MetaResponse, PaginationControl, RelationInfo, SearchIndexInfo, SortControl, TableActionsModel, TableDef, TableQueryState } from "./table/types.mjs";
9
+ import { UiT, UiTextParams, UiTexts, UiTranslate, activateUiTexts, createUiTexts, getUiTexts, setUiLocale } from "./i18n/ui-texts.mjs";
10
+ import { MetaCacheEntry, MetaEntryOptions, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, onMetaCacheReset, resetMetaCache, retainMetaEntry, setMetaCacheIdentity, setMetaCacheMaxEntries } from "./shared/meta-cache.mjs";
11
+ import { ResolvedValueHelp, resetValueHelpCache, resolveValueHelp } from "./value-help/resolve.mjs";
12
+ import { ValueHelpClient, ValueHelpResult, ValueHelpSearchOptions, invalidateValueHelpCache, setValueHelpCacheTtl } from "./value-help/value-help-client.mjs";
13
+ import { valueHelpDictPaths } from "./value-help/dict-paths.mjs";
14
+ import { DEFAULT_BOOLEAN_LABELS, extractFieldLiteralOptions, extractLiteralOptions, isPureLiteralUnion } from "./value-help/extract-literals.mjs";
15
+ import { extractValueHelp } from "./value-help/extract-ref.mjs";
16
+ import { optKey, optLabel, optionLabel, parseStaticOptions, resolveOptions } from "./value-help/resolve-options.mjs";
17
+ import { fetchDistinctValues, isPickerDeclined } from "./value-help/distinct-client.mjs";
18
+ import { TFormValueResolver, createFormData, createFormValueResolver, deleteByPath, detectUnionVariant, getByPath, joinPath, setByPath } from "./form/path-utils.mjs";
19
+ import { CloneUnwrap, deepClone } from "./form/clone.mjs";
20
+ import { FormValidator, TFieldValidatorOptions, TFormValidatorCallOptions, createFieldValidator, getDefaultValidatorPlugins, getFormValidator, isContainerKind, setDefaultValidatorPlugins } from "./form/validate.mjs";
21
+ import { FormDiffOptions, FormDiffResult, FormFieldChange, buildFormDiff, deepEqual } from "./form/diff.mjs";
22
+ import { omitSkippedNavFields } from "./form/skipped-nav.mjs";
23
+ import { collectDirtyPaths, isPathDirty } from "./form/dirty.mjs";
24
+ import { applyFormChanges } from "./form/apply.mjs";
25
+ import { FormRebaseOptions, FormRebaseResult, buildFormRebase } from "./form/rebase.mjs";
26
+ import { unionVariantChanged } from "./form/union-detect.mjs";
27
+ import { FORM_ERROR_KEY, buildDescendantErrorCounts, iteratePathAncestors, mergeErrorMaps, omitPaths, validatorErrorsToMap } from "./form/error-utils.mjs";
28
+ import { DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, GridSpanArgs, GridSpec, buildGridClasses, parseColSpan, parseRowSpan, resolveGridSpec } from "./form/grid.mjs";
29
+ import { resolveSingularLabel } from "./form/labels.mjs";
30
+ import { MeasurementInfo, extractMeasurement } from "./form/measurement.mjs";
31
+ import { CurrencyDisplay, DecimalParts, FormatDecimalOptions, enforceScale, formatDecimalForDisplay, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getThousandsSeparator, groupInteger, joinDecimalString, parseDecimalInput, splitDecimalString } from "./form/decimal-format.mjs";
32
+ import { createTableDef } from "./table/create-table-def.mjs";
33
+ import { NUMERIC_VALUE_KINDS, optionValue } from "./table/value-kind.mjs";
34
+ import { escapeRegex, str } from "./shared/str.mjs";
35
+ import { getColumn, getFilterableColumns, getSortableColumns } from "./table/column-resolver.mjs";
36
+ import { navigateHrefFor } from "./table/navigate-href.mjs";
37
+ import { TModelRoute, buildModelRoutes } from "./nav/model-routes.mjs";
38
+ import { TCrudOp, TCrudPermissions, TDbActionInfo, TDbActionIntent, TDbActionLevel, TDbActionProcessor } from "@atscript/db-client";
39
+ export { type ClientFactory, type ClientFactoryOptions, type CloneUnwrap, type ColumnDef, type ColumnValueKind, type CreateFormDefOptions, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_BOOLEAN_LABELS, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, FORM_ERROR_KEY, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormValidator, 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 MetaEntryOptions, type MetaResponse, NUMERIC_VALUE_KINDS, 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 TModelRoute, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, type TypedClientFactory, 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_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, type UiT, type UiTextParams, type UiTexts, type UiTranslate, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, activateUiTexts, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, createUiTexts, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, getResolver, getSortableColumns, getThousandsSeparator, getUiTexts, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isContainerKind, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, omitSkippedNavFields, onMetaCacheReset, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, retainMetaEntry, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setMetaCacheMaxEntries, setResolver, setUiLocale, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, validatorErrorsToMap, valueHelpDictPaths };