@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
@@ -0,0 +1,290 @@
1
+ import { ValueHelpInfo } from "../value-help/types.cjs";
2
+ import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
3
+ import { TCrudPermissions, TDbActionInfo } from "@atscript/db-client";
4
+
5
+ //#region src/table/types.d.ts
6
+ /** Search index metadata from the server. */
7
+ interface SearchIndexInfo {
8
+ name: string;
9
+ description?: string;
10
+ type?: "text" | "vector";
11
+ }
12
+ /** Relation summary in meta response. */
13
+ interface RelationInfo {
14
+ name: string;
15
+ direction: "to" | "from" | "via";
16
+ isArray: boolean;
17
+ /**
18
+ * `true` when the relation is `@db.rel.filterable`: the server accepts
19
+ * filters by related rows on it (`ticket: { $some: {…} }` /
20
+ * `{ $none: {…} }`, URL `ticket=$some(status=open)`). Absent otherwise.
21
+ * Tables display such predicates (residual filters) but offer no UI to
22
+ * author them. Needs `@atscript/moost-db` 0.1.147+. Since 0.1.147.
23
+ */
24
+ filterable?: boolean;
25
+ }
26
+ /** Per-field capability flags. */
27
+ interface FieldMeta {
28
+ sortable: boolean;
29
+ /** Whether the field accepts value comparisons (`=`, `>`, `$regex`, …). */
30
+ filterable: boolean;
31
+ /**
32
+ * Present only when `filterable` is `false` but narrower predicates still
33
+ * pass the server's gate — e.g. `["$exists"]` on a JSON-stored column.
34
+ * Needs `@atscript/moost-db` 0.1.132+. Since 0.1.139.
35
+ */
36
+ filterOps?: string[];
37
+ /**
38
+ * The caller may write this field but not read it (an access-control
39
+ * projection kept it in `/meta` for forms). The server rejects it in
40
+ * `$select`, filters and `$sort`, so it is never a table column and never
41
+ * fetchable. Since 0.1.141.
42
+ */
43
+ writeOnly?: boolean;
44
+ /**
45
+ * Server-computed (`@db.column.derived`, `@atscript/db` 0.1.141+): filterable
46
+ * and sortable like any column, but a value written to it is dropped. Forms
47
+ * read the annotation from the type itself (`FormFieldDef.derived`).
48
+ * Since 0.1.144.
49
+ */
50
+ derived?: boolean;
51
+ /**
52
+ * A computed view column (`@db.compute`, `@atscript/db` 0.1.147+): the
53
+ * database evaluates it from other fields of the view. It is a column like
54
+ * any other — sorting and filtering follow `sortable` / `filterable` —
55
+ * but never writable: `createFormDef` marks it `derived` when given these
56
+ * fields (`CreateFormDefOptions.metaFields`). Since 0.1.147.
57
+ */
58
+ computed?: boolean;
59
+ /**
60
+ * Display-only value the controller computes (`@DbDecorations`,
61
+ * `@atscript/moost-db` 0.1.148+): selectable, never filterable, sortable or
62
+ * groupable. `createTableDef` turns it into a column from
63
+ * `MetaResponse.decorations`. Since 0.1.148.
64
+ */
65
+ decoration?: boolean;
66
+ /**
67
+ * `$groupBy` on this field passes the server's gate (`@atscript/moost-db`
68
+ * 0.1.148+). Together with `filterable` and `@ui.valueHelp.distinct` it
69
+ * enables the distinct-values picker. Since 0.1.148.
70
+ */
71
+ groupable?: boolean;
72
+ }
73
+ /** Meta response from moost-db `/meta` endpoint. */
74
+ interface MetaResponse {
75
+ searchable: boolean;
76
+ vectorSearchable: boolean;
77
+ searchIndexes: SearchIndexInfo[];
78
+ primaryKeys: string[];
79
+ /**
80
+ * Preferred row identifier (UI/wire addressing). From
81
+ * `@db.table.preferredId.uniqueIndex` — defaults to `primaryKeys` when the
82
+ * server omits it (older servers / stub fixtures). Drives identifier object
83
+ * construction for action POSTs and `'navigate'` URL `$1` substitution.
84
+ */
85
+ preferredId: string[];
86
+ /**
87
+ * Server-managed OCC column name (from `@db.column.version`). When present,
88
+ * names a normal `int` field that ships with rows like any other column.
89
+ * Consumers MUST keep the field's value in update payloads — the server
90
+ * auto-lifts it to `$cas` to detect concurrent writes — but MUST NOT render
91
+ * it as a user-facing column, filter, or sorter. `createTableDef` skips it
92
+ * from the generated `columns[]` array on this basis.
93
+ */
94
+ versionColumn?: string;
95
+ crud: TCrudPermissions;
96
+ actions: TDbActionInfo[];
97
+ relations: RelationInfo[];
98
+ fields: Record<string, FieldMeta>;
99
+ type: TSerializedAnnotatedType;
100
+ /**
101
+ * The controller's declared display-only fields (`@DbDecorations`) as a
102
+ * serialized plain interface. Absent on older servers. Since 0.1.148.
103
+ */
104
+ decorations?: TSerializedAnnotatedType;
105
+ }
106
+ /**
107
+ * Server-declared actions grouped by `level`. Built by `createTableDef` from
108
+ * `meta.actions[]` — sorted within each group by `(order ?? 0)` then
109
+ * declaration order. `default.{table,row,rows}` is the first `default: true`
110
+ * entry per level (or `undefined`). The synthesised `__remove` UI action is
111
+ * never selected as a default.
112
+ */
113
+ interface TableActionsModel {
114
+ table: TDbActionInfo[];
115
+ row: TDbActionInfo[];
116
+ rows: TDbActionInfo[];
117
+ default: {
118
+ table?: TDbActionInfo;
119
+ row?: TDbActionInfo;
120
+ rows?: TDbActionInfo;
121
+ };
122
+ }
123
+ /** Complete table definition — produced by createTableDef(). */
124
+ interface TableDef {
125
+ type: TAtscriptAnnotatedType;
126
+ columns: ColumnDef[];
127
+ /**
128
+ * Flattened type tree (path → annotated prop). Empty Map for non-object roots.
129
+ * Excludes phantom types. Consumers (e.g. cell-resolver) read this instead
130
+ * of re-walking the type.
131
+ */
132
+ flatMap: Map<string, TAtscriptAnnotatedType>;
133
+ /**
134
+ * Server-returnable field paths (from meta.fields) — the gate for
135
+ * @ui.table.selectWith targets, includes @ui.table.exclude fields.
136
+ * `writeOnly` fields are not readable, so they are left out (since 0.1.141).
137
+ */
138
+ fetchableFields: Set<string>;
139
+ primaryKeys: string[];
140
+ /** Preferred row identifier — see `MetaResponse.preferredId`. */
141
+ preferredId: string[];
142
+ /**
143
+ * The row fields an action identifier is built from: `preferredId` plus
144
+ * every path a delegated action's `idMap` reads (an action another
145
+ * controller owns, e.g. a view listing its source table's actions). The
146
+ * table keeps these values on every identifier it hands to an action, so
147
+ * the client can map them to the owner's identification. Equals
148
+ * `preferredId` when no action carries an `idMap`. Always set by
149
+ * `createTableDef`; a hand-built `TableDef` may omit it (consumers fall back
150
+ * to `preferredId`). Since 0.1.147.
151
+ */
152
+ identifierFields?: string[];
153
+ /** Server-managed OCC column name — see `MetaResponse.versionColumn`. */
154
+ versionColumn?: string;
155
+ /** Per-op CRUD permissions advertised in `/meta`. Key absent → denied. */
156
+ crud: TCrudPermissions;
157
+ canRemove: boolean;
158
+ /** Server-declared actions, grouped by level with defaults pre-resolved. */
159
+ actions: TableActionsModel;
160
+ searchable: boolean;
161
+ vectorSearchable: boolean;
162
+ searchIndexes: SearchIndexInfo[];
163
+ relations: RelationInfo[];
164
+ }
165
+ /**
166
+ * Scalar storage kind of a column's value — what the server's filter guard
167
+ * checks. `string` / `date` / `isoDate` are `string`, `string.date` and
168
+ * `string.isoDate`; `timestamp` is `number.timestamp` (epoch ms).
169
+ * Since 0.1.148.
170
+ */
171
+ type ColumnValueKind = "string" | "date" | "isoDate" | "number" | "integer" | "decimal" | "timestamp" | "boolean";
172
+ /** A single column definition — built from field metadata + annotations. */
173
+ interface ColumnDef {
174
+ /** Field path in dot-notation (e.g. 'address.city'). */
175
+ path: string;
176
+ /** Display label — from @meta.label or humanized path. */
177
+ label: string;
178
+ /** Display type — from @ui.table.type, then @ui.type, then inferred from designType. */
179
+ type: string;
180
+ /**
181
+ * Scalar storage kind of the column's value, derived from the atscript type
182
+ * (a union of one kind counts; arrays, objects, JSON and mixed unions have
183
+ * none). Filter UIs and the query builder read it to pick the filter kind
184
+ * and to encode values the way the server's filter guard expects.
185
+ * Since 0.1.148.
186
+ */
187
+ valueKind?: ColumnValueKind;
188
+ /** Named component override from @ui.table.component — looked up in the table components map. */
189
+ component?: string;
190
+ /**
191
+ * Extra leaf field paths to include in `$select` whenever this column is displayed.
192
+ * Never rendered as columns; declared via @ui.table.selectWith.
193
+ */
194
+ selectWith?: string[];
195
+ /** Whether this column supports sorting. */
196
+ sortable: boolean;
197
+ /** Whether this column supports value filtering (the server's `filterable`). */
198
+ filterable: boolean;
199
+ /**
200
+ * Narrower filter operators the server accepts on a column that is not
201
+ * value-filterable — `["$exists"]` on a JSON-stored column, whose value
202
+ * cannot be compared but whose presence can. Copied from
203
+ * `meta.fields[path].filterOps`; omitted when absent. Filter UIs read it
204
+ * through `columnFilterConditions()` from `@atscript/ui-table`. Since 0.1.139.
205
+ */
206
+ filterOps?: string[];
207
+ /**
208
+ * Whether the column accepts `null` values (atscript prop is `optional`, or —
209
+ * since 0.1.165 — its type has a `null` member: `T | null`).
210
+ * Drives operator-picker availability — `null` / `notNull` are dropped
211
+ * for non-nullable columns since they can never match.
212
+ */
213
+ nullable: boolean;
214
+ /** Default column width from @ui.table.width. */
215
+ width?: string;
216
+ /** Maximum length constraint from @expect.maxLen — used to derive default column width. */
217
+ maxLen?: number;
218
+ /** Initial column ordering from @ui.table.order (lower = first). */
219
+ order: number;
220
+ /**
221
+ * Enumerated options for union literal types (e.g. 'a' | 'b' | 'c') and — since
222
+ * 0.1.165 — booleans (`true` / `false`, labelled Yes / No unless
223
+ * `@ui.literalLabel` says otherwise). `value` is
224
+ * the typed literal (`true`, `3`) — what a filter sends to the server; the
225
+ * `key` is its string form. `createTableDef` always sets it (since 0.1.148);
226
+ * a hand-built column may omit it, and the string `key` is used.
227
+ */
228
+ options?: {
229
+ key: string;
230
+ label: string;
231
+ value?: string | number | boolean;
232
+ }[];
233
+ /** Value-help info for FK columns (from extractValueHelp). */
234
+ valueHelpInfo?: ValueHelpInfo;
235
+ /**
236
+ * Distinct-values picker (`@ui.valueHelp.distinct`): the table's own controller
237
+ * (`url`) answers the values of `field` via `$groupBy`. Set only when the server
238
+ * lists the field `filterable` and `groupable` and no dictionary help or literal
239
+ * options apply — independent of `valueHelpInfo`. Since 0.1.148.
240
+ */
241
+ distinct?: {
242
+ url: string;
243
+ field: string;
244
+ };
245
+ /** Literal currency code from `@db.amount.currency 'EUR'`. */
246
+ currencyCode?: string;
247
+ /** Sibling field path from `@db.amount.currency.ref 'fieldName'`. */
248
+ currencyRefField?: string;
249
+ /** Literal unit-of-measure from `@db.unit 'kg'`. */
250
+ unitCode?: string;
251
+ /** Sibling field path from `@db.unit.ref 'fieldName'`. */
252
+ unitRefField?: string;
253
+ /** Decimal scale (fraction digits) — second arg of `@db.column.precision precision, scale`. */
254
+ precisionScale?: number;
255
+ /**
256
+ * Synthesised, locked-chrome column. When `true`: header-cell column-menu
257
+ * skipped, resize handle skipped, drag-reorder excluded, NOT in the
258
+ * `columnNames` v-model. Used for the row-actions pseudo-column
259
+ * (`path: '__actions'`).
260
+ */
261
+ fixed?: boolean;
262
+ /**
263
+ * Client-owned (display-only) column: nothing on the server backs it, so it
264
+ * never enters `$select`, server sorting or filters. It still takes part in
265
+ * column visibility, reordering and presets like any other column. Produced
266
+ * from `<AsTableRoot :display-columns>`. A `local` column with
267
+ * `sortable: true` is sorted in memory over the loaded page, never by the
268
+ * server. Since 0.1.134.
269
+ */
270
+ local?: boolean;
271
+ }
272
+ /** A single sort directive. */
273
+ interface SortControl {
274
+ field: string;
275
+ direction: "asc" | "desc";
276
+ }
277
+ /** Pagination state. */
278
+ interface PaginationControl {
279
+ page: number;
280
+ itemsPerPage: number;
281
+ }
282
+ /** Reactive query state for a table — mirrors @uniqu/core controls. */
283
+ interface TableQueryState {
284
+ sort?: SortControl[];
285
+ pagination?: PaginationControl;
286
+ search?: string;
287
+ filters?: Record<string, unknown>;
288
+ }
289
+ //#endregion
290
+ export { ColumnDef, ColumnValueKind, FieldMeta, MetaResponse, PaginationControl, RelationInfo, SearchIndexInfo, SortControl, TableActionsModel, TableDef, TableQueryState };
@@ -0,0 +1,290 @@
1
+ import { ValueHelpInfo } from "../value-help/types.mjs";
2
+ import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
3
+ import { TCrudPermissions, TDbActionInfo } from "@atscript/db-client";
4
+
5
+ //#region src/table/types.d.ts
6
+ /** Search index metadata from the server. */
7
+ interface SearchIndexInfo {
8
+ name: string;
9
+ description?: string;
10
+ type?: "text" | "vector";
11
+ }
12
+ /** Relation summary in meta response. */
13
+ interface RelationInfo {
14
+ name: string;
15
+ direction: "to" | "from" | "via";
16
+ isArray: boolean;
17
+ /**
18
+ * `true` when the relation is `@db.rel.filterable`: the server accepts
19
+ * filters by related rows on it (`ticket: { $some: {…} }` /
20
+ * `{ $none: {…} }`, URL `ticket=$some(status=open)`). Absent otherwise.
21
+ * Tables display such predicates (residual filters) but offer no UI to
22
+ * author them. Needs `@atscript/moost-db` 0.1.147+. Since 0.1.147.
23
+ */
24
+ filterable?: boolean;
25
+ }
26
+ /** Per-field capability flags. */
27
+ interface FieldMeta {
28
+ sortable: boolean;
29
+ /** Whether the field accepts value comparisons (`=`, `>`, `$regex`, …). */
30
+ filterable: boolean;
31
+ /**
32
+ * Present only when `filterable` is `false` but narrower predicates still
33
+ * pass the server's gate — e.g. `["$exists"]` on a JSON-stored column.
34
+ * Needs `@atscript/moost-db` 0.1.132+. Since 0.1.139.
35
+ */
36
+ filterOps?: string[];
37
+ /**
38
+ * The caller may write this field but not read it (an access-control
39
+ * projection kept it in `/meta` for forms). The server rejects it in
40
+ * `$select`, filters and `$sort`, so it is never a table column and never
41
+ * fetchable. Since 0.1.141.
42
+ */
43
+ writeOnly?: boolean;
44
+ /**
45
+ * Server-computed (`@db.column.derived`, `@atscript/db` 0.1.141+): filterable
46
+ * and sortable like any column, but a value written to it is dropped. Forms
47
+ * read the annotation from the type itself (`FormFieldDef.derived`).
48
+ * Since 0.1.144.
49
+ */
50
+ derived?: boolean;
51
+ /**
52
+ * A computed view column (`@db.compute`, `@atscript/db` 0.1.147+): the
53
+ * database evaluates it from other fields of the view. It is a column like
54
+ * any other — sorting and filtering follow `sortable` / `filterable` —
55
+ * but never writable: `createFormDef` marks it `derived` when given these
56
+ * fields (`CreateFormDefOptions.metaFields`). Since 0.1.147.
57
+ */
58
+ computed?: boolean;
59
+ /**
60
+ * Display-only value the controller computes (`@DbDecorations`,
61
+ * `@atscript/moost-db` 0.1.148+): selectable, never filterable, sortable or
62
+ * groupable. `createTableDef` turns it into a column from
63
+ * `MetaResponse.decorations`. Since 0.1.148.
64
+ */
65
+ decoration?: boolean;
66
+ /**
67
+ * `$groupBy` on this field passes the server's gate (`@atscript/moost-db`
68
+ * 0.1.148+). Together with `filterable` and `@ui.valueHelp.distinct` it
69
+ * enables the distinct-values picker. Since 0.1.148.
70
+ */
71
+ groupable?: boolean;
72
+ }
73
+ /** Meta response from moost-db `/meta` endpoint. */
74
+ interface MetaResponse {
75
+ searchable: boolean;
76
+ vectorSearchable: boolean;
77
+ searchIndexes: SearchIndexInfo[];
78
+ primaryKeys: string[];
79
+ /**
80
+ * Preferred row identifier (UI/wire addressing). From
81
+ * `@db.table.preferredId.uniqueIndex` — defaults to `primaryKeys` when the
82
+ * server omits it (older servers / stub fixtures). Drives identifier object
83
+ * construction for action POSTs and `'navigate'` URL `$1` substitution.
84
+ */
85
+ preferredId: string[];
86
+ /**
87
+ * Server-managed OCC column name (from `@db.column.version`). When present,
88
+ * names a normal `int` field that ships with rows like any other column.
89
+ * Consumers MUST keep the field's value in update payloads — the server
90
+ * auto-lifts it to `$cas` to detect concurrent writes — but MUST NOT render
91
+ * it as a user-facing column, filter, or sorter. `createTableDef` skips it
92
+ * from the generated `columns[]` array on this basis.
93
+ */
94
+ versionColumn?: string;
95
+ crud: TCrudPermissions;
96
+ actions: TDbActionInfo[];
97
+ relations: RelationInfo[];
98
+ fields: Record<string, FieldMeta>;
99
+ type: TSerializedAnnotatedType;
100
+ /**
101
+ * The controller's declared display-only fields (`@DbDecorations`) as a
102
+ * serialized plain interface. Absent on older servers. Since 0.1.148.
103
+ */
104
+ decorations?: TSerializedAnnotatedType;
105
+ }
106
+ /**
107
+ * Server-declared actions grouped by `level`. Built by `createTableDef` from
108
+ * `meta.actions[]` — sorted within each group by `(order ?? 0)` then
109
+ * declaration order. `default.{table,row,rows}` is the first `default: true`
110
+ * entry per level (or `undefined`). The synthesised `__remove` UI action is
111
+ * never selected as a default.
112
+ */
113
+ interface TableActionsModel {
114
+ table: TDbActionInfo[];
115
+ row: TDbActionInfo[];
116
+ rows: TDbActionInfo[];
117
+ default: {
118
+ table?: TDbActionInfo;
119
+ row?: TDbActionInfo;
120
+ rows?: TDbActionInfo;
121
+ };
122
+ }
123
+ /** Complete table definition — produced by createTableDef(). */
124
+ interface TableDef {
125
+ type: TAtscriptAnnotatedType;
126
+ columns: ColumnDef[];
127
+ /**
128
+ * Flattened type tree (path → annotated prop). Empty Map for non-object roots.
129
+ * Excludes phantom types. Consumers (e.g. cell-resolver) read this instead
130
+ * of re-walking the type.
131
+ */
132
+ flatMap: Map<string, TAtscriptAnnotatedType>;
133
+ /**
134
+ * Server-returnable field paths (from meta.fields) — the gate for
135
+ * @ui.table.selectWith targets, includes @ui.table.exclude fields.
136
+ * `writeOnly` fields are not readable, so they are left out (since 0.1.141).
137
+ */
138
+ fetchableFields: Set<string>;
139
+ primaryKeys: string[];
140
+ /** Preferred row identifier — see `MetaResponse.preferredId`. */
141
+ preferredId: string[];
142
+ /**
143
+ * The row fields an action identifier is built from: `preferredId` plus
144
+ * every path a delegated action's `idMap` reads (an action another
145
+ * controller owns, e.g. a view listing its source table's actions). The
146
+ * table keeps these values on every identifier it hands to an action, so
147
+ * the client can map them to the owner's identification. Equals
148
+ * `preferredId` when no action carries an `idMap`. Always set by
149
+ * `createTableDef`; a hand-built `TableDef` may omit it (consumers fall back
150
+ * to `preferredId`). Since 0.1.147.
151
+ */
152
+ identifierFields?: string[];
153
+ /** Server-managed OCC column name — see `MetaResponse.versionColumn`. */
154
+ versionColumn?: string;
155
+ /** Per-op CRUD permissions advertised in `/meta`. Key absent → denied. */
156
+ crud: TCrudPermissions;
157
+ canRemove: boolean;
158
+ /** Server-declared actions, grouped by level with defaults pre-resolved. */
159
+ actions: TableActionsModel;
160
+ searchable: boolean;
161
+ vectorSearchable: boolean;
162
+ searchIndexes: SearchIndexInfo[];
163
+ relations: RelationInfo[];
164
+ }
165
+ /**
166
+ * Scalar storage kind of a column's value — what the server's filter guard
167
+ * checks. `string` / `date` / `isoDate` are `string`, `string.date` and
168
+ * `string.isoDate`; `timestamp` is `number.timestamp` (epoch ms).
169
+ * Since 0.1.148.
170
+ */
171
+ type ColumnValueKind = "string" | "date" | "isoDate" | "number" | "integer" | "decimal" | "timestamp" | "boolean";
172
+ /** A single column definition — built from field metadata + annotations. */
173
+ interface ColumnDef {
174
+ /** Field path in dot-notation (e.g. 'address.city'). */
175
+ path: string;
176
+ /** Display label — from @meta.label or humanized path. */
177
+ label: string;
178
+ /** Display type — from @ui.table.type, then @ui.type, then inferred from designType. */
179
+ type: string;
180
+ /**
181
+ * Scalar storage kind of the column's value, derived from the atscript type
182
+ * (a union of one kind counts; arrays, objects, JSON and mixed unions have
183
+ * none). Filter UIs and the query builder read it to pick the filter kind
184
+ * and to encode values the way the server's filter guard expects.
185
+ * Since 0.1.148.
186
+ */
187
+ valueKind?: ColumnValueKind;
188
+ /** Named component override from @ui.table.component — looked up in the table components map. */
189
+ component?: string;
190
+ /**
191
+ * Extra leaf field paths to include in `$select` whenever this column is displayed.
192
+ * Never rendered as columns; declared via @ui.table.selectWith.
193
+ */
194
+ selectWith?: string[];
195
+ /** Whether this column supports sorting. */
196
+ sortable: boolean;
197
+ /** Whether this column supports value filtering (the server's `filterable`). */
198
+ filterable: boolean;
199
+ /**
200
+ * Narrower filter operators the server accepts on a column that is not
201
+ * value-filterable — `["$exists"]` on a JSON-stored column, whose value
202
+ * cannot be compared but whose presence can. Copied from
203
+ * `meta.fields[path].filterOps`; omitted when absent. Filter UIs read it
204
+ * through `columnFilterConditions()` from `@atscript/ui-table`. Since 0.1.139.
205
+ */
206
+ filterOps?: string[];
207
+ /**
208
+ * Whether the column accepts `null` values (atscript prop is `optional`, or —
209
+ * since 0.1.165 — its type has a `null` member: `T | null`).
210
+ * Drives operator-picker availability — `null` / `notNull` are dropped
211
+ * for non-nullable columns since they can never match.
212
+ */
213
+ nullable: boolean;
214
+ /** Default column width from @ui.table.width. */
215
+ width?: string;
216
+ /** Maximum length constraint from @expect.maxLen — used to derive default column width. */
217
+ maxLen?: number;
218
+ /** Initial column ordering from @ui.table.order (lower = first). */
219
+ order: number;
220
+ /**
221
+ * Enumerated options for union literal types (e.g. 'a' | 'b' | 'c') and — since
222
+ * 0.1.165 — booleans (`true` / `false`, labelled Yes / No unless
223
+ * `@ui.literalLabel` says otherwise). `value` is
224
+ * the typed literal (`true`, `3`) — what a filter sends to the server; the
225
+ * `key` is its string form. `createTableDef` always sets it (since 0.1.148);
226
+ * a hand-built column may omit it, and the string `key` is used.
227
+ */
228
+ options?: {
229
+ key: string;
230
+ label: string;
231
+ value?: string | number | boolean;
232
+ }[];
233
+ /** Value-help info for FK columns (from extractValueHelp). */
234
+ valueHelpInfo?: ValueHelpInfo;
235
+ /**
236
+ * Distinct-values picker (`@ui.valueHelp.distinct`): the table's own controller
237
+ * (`url`) answers the values of `field` via `$groupBy`. Set only when the server
238
+ * lists the field `filterable` and `groupable` and no dictionary help or literal
239
+ * options apply — independent of `valueHelpInfo`. Since 0.1.148.
240
+ */
241
+ distinct?: {
242
+ url: string;
243
+ field: string;
244
+ };
245
+ /** Literal currency code from `@db.amount.currency 'EUR'`. */
246
+ currencyCode?: string;
247
+ /** Sibling field path from `@db.amount.currency.ref 'fieldName'`. */
248
+ currencyRefField?: string;
249
+ /** Literal unit-of-measure from `@db.unit 'kg'`. */
250
+ unitCode?: string;
251
+ /** Sibling field path from `@db.unit.ref 'fieldName'`. */
252
+ unitRefField?: string;
253
+ /** Decimal scale (fraction digits) — second arg of `@db.column.precision precision, scale`. */
254
+ precisionScale?: number;
255
+ /**
256
+ * Synthesised, locked-chrome column. When `true`: header-cell column-menu
257
+ * skipped, resize handle skipped, drag-reorder excluded, NOT in the
258
+ * `columnNames` v-model. Used for the row-actions pseudo-column
259
+ * (`path: '__actions'`).
260
+ */
261
+ fixed?: boolean;
262
+ /**
263
+ * Client-owned (display-only) column: nothing on the server backs it, so it
264
+ * never enters `$select`, server sorting or filters. It still takes part in
265
+ * column visibility, reordering and presets like any other column. Produced
266
+ * from `<AsTableRoot :display-columns>`. A `local` column with
267
+ * `sortable: true` is sorted in memory over the loaded page, never by the
268
+ * server. Since 0.1.134.
269
+ */
270
+ local?: boolean;
271
+ }
272
+ /** A single sort directive. */
273
+ interface SortControl {
274
+ field: string;
275
+ direction: "asc" | "desc";
276
+ }
277
+ /** Pagination state. */
278
+ interface PaginationControl {
279
+ page: number;
280
+ itemsPerPage: number;
281
+ }
282
+ /** Reactive query state for a table — mirrors @uniqu/core controls. */
283
+ interface TableQueryState {
284
+ sort?: SortControl[];
285
+ pagination?: PaginationControl;
286
+ search?: string;
287
+ filters?: Record<string, unknown>;
288
+ }
289
+ //#endregion
290
+ export { ColumnDef, ColumnValueKind, FieldMeta, MetaResponse, PaginationControl, RelationInfo, SearchIndexInfo, SortControl, TableActionsModel, TableDef, TableQueryState };
@@ -0,0 +1,20 @@
1
+ //#region src/table/value-kind.ts
2
+ /** Storage kinds that hold plain numbers (a `timestamp` is epoch ms, but filters treat it as a date). */
3
+ const NUMERIC_VALUE_KINDS = new Set([
4
+ "number",
5
+ "integer",
6
+ "decimal"
7
+ ]);
8
+ /**
9
+ * The typed value of an option — a column's or a form field's — the literal
10
+ * itself (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
11
+ * option that has no `value`; a plain string option is itself. What a filter
12
+ * sends and what a select / radio / multiselect writes into the model.
13
+ * Since 0.1.148; form options (`TFormEntryOptions`) since 0.1.165.
14
+ */
15
+ function optionValue(option) {
16
+ return typeof option === "string" ? option : option.value ?? option.key;
17
+ }
18
+ //#endregion
19
+ exports.NUMERIC_VALUE_KINDS = NUMERIC_VALUE_KINDS;
20
+ exports.optionValue = optionValue;
@@ -0,0 +1,16 @@
1
+ import { TFormEntryOptions } from "../value-help/types.cjs";
2
+ import { ColumnValueKind } from "./types.cjs";
3
+
4
+ //#region src/table/value-kind.d.ts
5
+ /** Storage kinds that hold plain numbers (a `timestamp` is epoch ms, but filters treat it as a date). */
6
+ declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
7
+ /**
8
+ * The typed value of an option — a column's or a form field's — the literal
9
+ * itself (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
10
+ * option that has no `value`; a plain string option is itself. What a filter
11
+ * sends and what a select / radio / multiselect writes into the model.
12
+ * Since 0.1.148; form options (`TFormEntryOptions`) since 0.1.165.
13
+ */
14
+ declare function optionValue(option: TFormEntryOptions): string | number | boolean;
15
+ //#endregion
16
+ export { NUMERIC_VALUE_KINDS, optionValue };
@@ -0,0 +1,16 @@
1
+ import { TFormEntryOptions } from "../value-help/types.mjs";
2
+ import { ColumnValueKind } from "./types.mjs";
3
+
4
+ //#region src/table/value-kind.d.ts
5
+ /** Storage kinds that hold plain numbers (a `timestamp` is epoch ms, but filters treat it as a date). */
6
+ declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
7
+ /**
8
+ * The typed value of an option — a column's or a form field's — the literal
9
+ * itself (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
10
+ * option that has no `value`; a plain string option is itself. What a filter
11
+ * sends and what a select / radio / multiselect writes into the model.
12
+ * Since 0.1.148; form options (`TFormEntryOptions`) since 0.1.165.
13
+ */
14
+ declare function optionValue(option: TFormEntryOptions): string | number | boolean;
15
+ //#endregion
16
+ export { NUMERIC_VALUE_KINDS, optionValue };
@@ -0,0 +1,19 @@
1
+ //#region src/table/value-kind.ts
2
+ /** Storage kinds that hold plain numbers (a `timestamp` is epoch ms, but filters treat it as a date). */
3
+ const NUMERIC_VALUE_KINDS = new Set([
4
+ "number",
5
+ "integer",
6
+ "decimal"
7
+ ]);
8
+ /**
9
+ * The typed value of an option — a column's or a form field's — the literal
10
+ * itself (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
11
+ * option that has no `value`; a plain string option is itself. What a filter
12
+ * sends and what a select / radio / multiselect writes into the model.
13
+ * Since 0.1.148; form options (`TFormEntryOptions`) since 0.1.165.
14
+ */
15
+ function optionValue(option) {
16
+ return typeof option === "string" ? option : option.value ?? option.key;
17
+ }
18
+ //#endregion
19
+ export { NUMERIC_VALUE_KINDS, optionValue };
@@ -0,0 +1,17 @@
1
+ //#region src/value-help/dict-paths.ts
2
+ /**
3
+ * Paths that make up the "dict view" of a value-help target:
4
+ * PKs + label + descr + attr fields. Used by filter dialogs to clamp
5
+ * visible columns to the dictionary subset.
6
+ */
7
+ function valueHelpDictPaths(resolved) {
8
+ const paths = [
9
+ ...resolved.primaryKeys,
10
+ resolved.labelField,
11
+ ...resolved.attrFields
12
+ ];
13
+ if (resolved.descrField) paths.push(resolved.descrField);
14
+ return new Set(paths);
15
+ }
16
+ //#endregion
17
+ exports.valueHelpDictPaths = valueHelpDictPaths;
@@ -0,0 +1,11 @@
1
+ import { ResolvedValueHelp } from "./resolve.cjs";
2
+
3
+ //#region src/value-help/dict-paths.d.ts
4
+ /**
5
+ * Paths that make up the "dict view" of a value-help target:
6
+ * PKs + label + descr + attr fields. Used by filter dialogs to clamp
7
+ * visible columns to the dictionary subset.
8
+ */
9
+ declare function valueHelpDictPaths(resolved: ResolvedValueHelp): Set<string>;
10
+ //#endregion
11
+ export { valueHelpDictPaths };