@atscript/ui 0.1.163 → 0.1.164
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-factory.cjs +27 -0
- package/dist/client-factory.d.cts +53 -0
- package/dist/client-factory.d.mts +53 -0
- package/dist/client-factory.mjs +25 -0
- package/dist/form/apply.cjs +38 -0
- package/dist/form/apply.d.cts +36 -0
- package/dist/form/apply.d.mts +36 -0
- package/dist/form/apply.mjs +38 -0
- package/dist/form/clone.cjs +30 -0
- package/dist/form/clone.d.cts +23 -0
- package/dist/form/clone.d.mts +23 -0
- package/dist/form/clone.mjs +30 -0
- package/dist/form/create-form-def.cjs +440 -0
- package/dist/form/create-form-def.d.cts +67 -0
- package/dist/form/create-form-def.d.mts +67 -0
- package/dist/form/create-form-def.mjs +438 -0
- package/dist/form/decimal-format.cjs +324 -0
- package/dist/form/decimal-format.d.cts +86 -0
- package/dist/form/decimal-format.d.mts +86 -0
- package/dist/form/decimal-format.mjs +315 -0
- package/dist/form/diff.cjs +458 -0
- package/dist/form/diff.d.cts +80 -0
- package/dist/form/diff.d.mts +80 -0
- package/dist/form/diff.mjs +457 -0
- package/dist/form/dirty.cjs +65 -0
- package/dist/form/dirty.d.cts +47 -0
- package/dist/form/dirty.d.mts +47 -0
- package/dist/form/dirty.mjs +64 -0
- package/dist/form/error-utils.cjs +97 -0
- package/dist/form/error-utils.d.cts +58 -0
- package/dist/form/error-utils.d.mts +58 -0
- package/dist/form/error-utils.mjs +92 -0
- package/dist/form/form-actions.cjs +30 -0
- package/dist/form/form-actions.d.cts +17 -0
- package/dist/form/form-actions.d.mts +17 -0
- package/dist/form/form-actions.mjs +30 -0
- package/dist/form/grid.cjs +69 -0
- package/dist/form/grid.d.cts +49 -0
- package/dist/form/grid.d.mts +49 -0
- package/dist/form/grid.mjs +64 -0
- package/dist/form/labels.cjs +10 -0
- package/dist/form/labels.d.cts +7 -0
- package/dist/form/labels.d.mts +7 -0
- package/dist/form/labels.mjs +10 -0
- package/dist/form/measurement.cjs +20 -0
- package/dist/form/measurement.d.cts +29 -0
- package/dist/form/measurement.d.mts +29 -0
- package/dist/form/measurement.mjs +20 -0
- package/dist/form/path-utils.cjs +182 -0
- package/dist/form/path-utils.d.cts +47 -0
- package/dist/form/path-utils.d.mts +47 -0
- package/dist/form/path-utils.mjs +175 -0
- package/dist/form/rebase.cjs +89 -0
- package/dist/form/rebase.d.cts +61 -0
- package/dist/form/rebase.d.mts +61 -0
- package/dist/form/rebase.mjs +89 -0
- package/dist/form/skipped-nav.cjs +100 -0
- package/dist/form/skipped-nav.d.cts +13 -0
- package/dist/form/skipped-nav.d.mts +13 -0
- package/dist/form/skipped-nav.mjs +98 -0
- package/dist/form/types.cjs +40 -0
- package/dist/form/types.d.cts +133 -0
- package/dist/form/types.d.mts +133 -0
- package/dist/form/types.mjs +36 -0
- package/dist/form/union-detect.cjs +46 -0
- package/dist/form/union-detect.d.cts +22 -0
- package/dist/form/union-detect.d.mts +22 -0
- package/dist/form/union-detect.mjs +46 -0
- package/dist/form/validate.cjs +150 -0
- package/dist/form/validate.d.cts +50 -0
- package/dist/form/validate.d.mts +50 -0
- package/dist/form/validate.mjs +147 -0
- package/dist/index.cjs +217 -3360
- package/dist/index.d.cts +38 -1693
- package/dist/index.d.mts +38 -1693
- package/dist/index.mjs +35 -3179
- package/dist/nav/model-routes.cjs +59 -0
- package/dist/nav/model-routes.d.cts +33 -0
- package/dist/nav/model-routes.d.mts +33 -0
- package/dist/nav/model-routes.mjs +59 -0
- package/dist/plugin/annotations.cjs +577 -0
- package/dist/plugin/annotations.mjs +577 -0
- package/dist/plugin/primitives.cjs +30 -0
- package/dist/plugin/primitives.mjs +30 -0
- package/dist/plugin/value-help-validation.cjs +419 -0
- package/dist/plugin/value-help-validation.mjs +413 -0
- package/dist/plugin.cjs +4 -1001
- package/dist/plugin.mjs +2 -999
- package/dist/shared/annotation-keys.cjs +189 -0
- package/dist/shared/annotation-keys.d.cts +82 -0
- package/dist/shared/annotation-keys.d.mts +82 -0
- package/dist/shared/annotation-keys.mjs +97 -0
- package/dist/shared/field-resolver.cjs +123 -0
- package/dist/shared/field-resolver.d.cts +77 -0
- package/dist/shared/field-resolver.d.mts +77 -0
- package/dist/shared/field-resolver.mjs +110 -0
- package/dist/shared/meta-cache.cjs +244 -0
- package/dist/shared/meta-cache.d.cts +110 -0
- package/dist/shared/meta-cache.d.mts +110 -0
- package/dist/shared/meta-cache.mjs +237 -0
- package/dist/shared/str.cjs +19 -0
- package/dist/shared/str.d.cts +7 -0
- package/dist/shared/str.d.mts +7 -0
- package/dist/shared/str.mjs +17 -0
- package/dist/table/column-resolver.cjs +17 -0
- package/dist/table/column-resolver.d.cts +11 -0
- package/dist/table/column-resolver.d.mts +11 -0
- package/dist/table/column-resolver.mjs +15 -0
- package/dist/table/create-table-def.cjs +233 -0
- package/dist/table/create-table-def.d.cts +15 -0
- package/dist/table/create-table-def.d.mts +15 -0
- package/dist/table/create-table-def.mjs +233 -0
- package/dist/table/navigate-href.cjs +45 -0
- package/dist/table/navigate-href.d.cts +31 -0
- package/dist/table/navigate-href.d.mts +31 -0
- package/dist/table/navigate-href.mjs +45 -0
- package/dist/table/types.d.cts +287 -0
- package/dist/table/types.d.mts +287 -0
- package/dist/table/value-kind.cjs +20 -0
- package/dist/table/value-kind.d.cts +15 -0
- package/dist/table/value-kind.d.mts +15 -0
- package/dist/table/value-kind.mjs +19 -0
- package/dist/value-help/dict-paths.cjs +17 -0
- package/dist/value-help/dict-paths.d.cts +11 -0
- package/dist/value-help/dict-paths.d.mts +11 -0
- package/dist/value-help/dict-paths.mjs +17 -0
- package/dist/value-help/distinct-client.cjs +51 -0
- package/dist/value-help/distinct-client.d.cts +40 -0
- package/dist/value-help/distinct-client.d.mts +40 -0
- package/dist/value-help/distinct-client.mjs +50 -0
- package/dist/value-help/extract-literals.cjs +76 -0
- package/dist/value-help/extract-literals.d.cts +32 -0
- package/dist/value-help/extract-literals.d.mts +32 -0
- package/dist/value-help/extract-literals.mjs +74 -0
- package/dist/value-help/extract-ref.cjs +100 -0
- package/dist/value-help/extract-ref.d.cts +37 -0
- package/dist/value-help/extract-ref.d.mts +37 -0
- package/dist/value-help/extract-ref.mjs +100 -0
- package/dist/value-help/filter-tree.cjs +45 -0
- package/dist/value-help/filter-tree.mjs +45 -0
- package/dist/value-help/index.d.mts +8 -0
- package/dist/value-help/resolve-options.cjs +64 -0
- package/dist/value-help/resolve-options.d.cts +35 -0
- package/dist/value-help/resolve-options.d.mts +35 -0
- package/dist/value-help/resolve-options.mjs +60 -0
- package/dist/value-help/resolve.cjs +62 -0
- package/dist/value-help/resolve.d.cts +31 -0
- package/dist/value-help/resolve.d.mts +31 -0
- package/dist/value-help/resolve.mjs +61 -0
- package/dist/value-help/types.d.cts +36 -0
- package/dist/value-help/types.d.mts +36 -0
- package/dist/value-help/value-help-client.cjs +136 -0
- package/dist/value-help/value-help-client.d.cts +67 -0
- package/dist/value-help/value-help-client.d.mts +67 -0
- package/dist/value-help/value-help-client.mjs +134 -0
- package/package.json +10 -10
|
@@ -0,0 +1,287 @@
|
|
|
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`).
|
|
209
|
+
* Drives operator-picker availability — `null` / `notNull` are dropped
|
|
210
|
+
* for non-nullable columns since they can never match.
|
|
211
|
+
*/
|
|
212
|
+
nullable: boolean;
|
|
213
|
+
/** Default column width from @ui.table.width. */
|
|
214
|
+
width?: string;
|
|
215
|
+
/** Maximum length constraint from @expect.maxLen — used to derive default column width. */
|
|
216
|
+
maxLen?: number;
|
|
217
|
+
/** Initial column ordering from @ui.table.order (lower = first). */
|
|
218
|
+
order: number;
|
|
219
|
+
/**
|
|
220
|
+
* Enumerated options for union literal types (e.g. 'a' | 'b' | 'c'). `value` is
|
|
221
|
+
* the typed literal (`true`, `3`) — what a filter sends to the server; the
|
|
222
|
+
* `key` is its string form. `createTableDef` always sets it (since 0.1.148);
|
|
223
|
+
* a hand-built column may omit it, and the string `key` is used.
|
|
224
|
+
*/
|
|
225
|
+
options?: {
|
|
226
|
+
key: string;
|
|
227
|
+
label: string;
|
|
228
|
+
value?: string | number | boolean;
|
|
229
|
+
}[];
|
|
230
|
+
/** Value-help info for FK columns (from extractValueHelp). */
|
|
231
|
+
valueHelpInfo?: ValueHelpInfo;
|
|
232
|
+
/**
|
|
233
|
+
* Distinct-values picker (`@ui.valueHelp.distinct`): the table's own controller
|
|
234
|
+
* (`url`) answers the values of `field` via `$groupBy`. Set only when the server
|
|
235
|
+
* lists the field `filterable` and `groupable` and no dictionary help or literal
|
|
236
|
+
* options apply — independent of `valueHelpInfo`. Since 0.1.148.
|
|
237
|
+
*/
|
|
238
|
+
distinct?: {
|
|
239
|
+
url: string;
|
|
240
|
+
field: string;
|
|
241
|
+
};
|
|
242
|
+
/** Literal currency code from `@db.amount.currency 'EUR'`. */
|
|
243
|
+
currencyCode?: string;
|
|
244
|
+
/** Sibling field path from `@db.amount.currency.ref 'fieldName'`. */
|
|
245
|
+
currencyRefField?: string;
|
|
246
|
+
/** Literal unit-of-measure from `@db.unit 'kg'`. */
|
|
247
|
+
unitCode?: string;
|
|
248
|
+
/** Sibling field path from `@db.unit.ref 'fieldName'`. */
|
|
249
|
+
unitRefField?: string;
|
|
250
|
+
/** Decimal scale (fraction digits) — second arg of `@db.column.precision precision, scale`. */
|
|
251
|
+
precisionScale?: number;
|
|
252
|
+
/**
|
|
253
|
+
* Synthesised, locked-chrome column. When `true`: header-cell column-menu
|
|
254
|
+
* skipped, resize handle skipped, drag-reorder excluded, NOT in the
|
|
255
|
+
* `columnNames` v-model. Used for the row-actions pseudo-column
|
|
256
|
+
* (`path: '__actions'`).
|
|
257
|
+
*/
|
|
258
|
+
fixed?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Client-owned (display-only) column: nothing on the server backs it, so it
|
|
261
|
+
* never enters `$select`, server sorting or filters. It still takes part in
|
|
262
|
+
* column visibility, reordering and presets like any other column. Produced
|
|
263
|
+
* from `<AsTableRoot :display-columns>`. A `local` column with
|
|
264
|
+
* `sortable: true` is sorted in memory over the loaded page, never by the
|
|
265
|
+
* server. Since 0.1.134.
|
|
266
|
+
*/
|
|
267
|
+
local?: boolean;
|
|
268
|
+
}
|
|
269
|
+
/** A single sort directive. */
|
|
270
|
+
interface SortControl {
|
|
271
|
+
field: string;
|
|
272
|
+
direction: "asc" | "desc";
|
|
273
|
+
}
|
|
274
|
+
/** Pagination state. */
|
|
275
|
+
interface PaginationControl {
|
|
276
|
+
page: number;
|
|
277
|
+
itemsPerPage: number;
|
|
278
|
+
}
|
|
279
|
+
/** Reactive query state for a table — mirrors @uniqu/core controls. */
|
|
280
|
+
interface TableQueryState {
|
|
281
|
+
sort?: SortControl[];
|
|
282
|
+
pagination?: PaginationControl;
|
|
283
|
+
search?: string;
|
|
284
|
+
filters?: Record<string, unknown>;
|
|
285
|
+
}
|
|
286
|
+
//#endregion
|
|
287
|
+
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 one of a column's `options` — the literal itself
|
|
10
|
+
* (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
|
|
11
|
+
* column that has no `value`.
|
|
12
|
+
*
|
|
13
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
14
|
+
*/
|
|
15
|
+
function optionValue(option) {
|
|
16
|
+
return option.value ?? option.key;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.NUMERIC_VALUE_KINDS = NUMERIC_VALUE_KINDS;
|
|
20
|
+
exports.optionValue = optionValue;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ColumnDef, ColumnValueKind } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/table/value-kind.d.ts
|
|
4
|
+
/** Storage kinds that hold plain numbers (a `timestamp` is epoch ms, but filters treat it as a date). */
|
|
5
|
+
declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
|
|
6
|
+
/**
|
|
7
|
+
* The typed value of one of a column's `options` — the literal itself
|
|
8
|
+
* (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
|
|
9
|
+
* column that has no `value`.
|
|
10
|
+
*
|
|
11
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
12
|
+
*/
|
|
13
|
+
declare function optionValue(option: NonNullable<ColumnDef["options"]>[number]): string | number | boolean;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { NUMERIC_VALUE_KINDS, optionValue };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ColumnDef, ColumnValueKind } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/table/value-kind.d.ts
|
|
4
|
+
/** Storage kinds that hold plain numbers (a `timestamp` is epoch ms, but filters treat it as a date). */
|
|
5
|
+
declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
|
|
6
|
+
/**
|
|
7
|
+
* The typed value of one of a column's `options` — the literal itself
|
|
8
|
+
* (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
|
|
9
|
+
* column that has no `value`.
|
|
10
|
+
*
|
|
11
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
12
|
+
*/
|
|
13
|
+
declare function optionValue(option: NonNullable<ColumnDef["options"]>[number]): string | number | boolean;
|
|
14
|
+
//#endregion
|
|
15
|
+
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 one of a column's `options` — the literal itself
|
|
10
|
+
* (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
|
|
11
|
+
* column that has no `value`.
|
|
12
|
+
*
|
|
13
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
14
|
+
*/
|
|
15
|
+
function optionValue(option) {
|
|
16
|
+
return 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 };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ResolvedValueHelp } from "./resolve.mjs";
|
|
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 };
|
|
@@ -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
|
+
export { valueHelpDictPaths };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const require_str = require("../shared/str.cjs");
|
|
2
|
+
//#region src/value-help/distinct-client.ts
|
|
3
|
+
/**
|
|
4
|
+
* `true` for a 4xx answer — the server declined this picker (gate, ARBAC, unknown field).
|
|
5
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
6
|
+
*/
|
|
7
|
+
function isPickerDeclined(err) {
|
|
8
|
+
const status = err?.status;
|
|
9
|
+
return typeof status === "number" && status >= 400 && status < 500;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Distinct values of one column of the table behind `client`, via
|
|
13
|
+
* `/query?$groupBy=<field>`. All server gates (hidden field, ARBAC `$groupBy`
|
|
14
|
+
* control, row scope, write-only, encrypted) apply as for any grouped read; a
|
|
15
|
+
* 4xx rejects with a `ClientError` — see {@link isPickerDeclined}.
|
|
16
|
+
* `hasMore` tells whether another page follows.
|
|
17
|
+
*
|
|
18
|
+
* @internal Backs the distinct-values picker of `@atscript/vue-table`.
|
|
19
|
+
*/
|
|
20
|
+
async function fetchDistinctValues(client, field, opts = {}) {
|
|
21
|
+
const limit = opts.limit ?? 50;
|
|
22
|
+
const text = opts.text?.trim();
|
|
23
|
+
const conditions = [];
|
|
24
|
+
if (opts.filter) conditions.push(opts.filter);
|
|
25
|
+
if (text) if (opts.numeric) {
|
|
26
|
+
const n = Number(text);
|
|
27
|
+
if (!Number.isFinite(n)) return {
|
|
28
|
+
items: [],
|
|
29
|
+
hasMore: false
|
|
30
|
+
};
|
|
31
|
+
conditions.push({ [field]: n });
|
|
32
|
+
} else conditions.push({ [field]: { $regex: `/^${require_str.escapeRegex(text)}/i` } });
|
|
33
|
+
const filter = conditions.length > 1 ? { $and: conditions } : conditions[0];
|
|
34
|
+
const rows = await client.aggregate({
|
|
35
|
+
...filter && { filter },
|
|
36
|
+
controls: {
|
|
37
|
+
$groupBy: [field],
|
|
38
|
+
$select: [field],
|
|
39
|
+
...opts.sortable && { $sort: { [field]: 1 } },
|
|
40
|
+
$limit: limit + 1,
|
|
41
|
+
$skip: opts.skip ?? 0
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
items: rows.slice(0, limit).map((r) => r[field]).filter((v) => v !== null && v !== void 0),
|
|
46
|
+
hasMore: rows.length > limit
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.fetchDistinctValues = fetchDistinctValues;
|
|
51
|
+
exports.isPickerDeclined = isPickerDeclined;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Client, FilterExpr } from "@atscript/db-client";
|
|
2
|
+
|
|
3
|
+
//#region src/value-help/distinct-client.d.ts
|
|
4
|
+
interface DistinctValuesOptions {
|
|
5
|
+
/** Search text: a case-insensitive prefix match for strings, an exact match for numbers. */
|
|
6
|
+
text?: string;
|
|
7
|
+
/** Page size. Default: 50. */
|
|
8
|
+
limit?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Rows to skip (the next page of a scrolled picker). Distinct values are only
|
|
11
|
+
* stable across pages when ordered, so a caller pages only with `sortable`.
|
|
12
|
+
*/
|
|
13
|
+
skip?: number;
|
|
14
|
+
/** Send `$sort` on the grouped field — only when the server lists it as sortable. */
|
|
15
|
+
sortable?: boolean;
|
|
16
|
+
/** The field stores numbers: search is an exact match and non-numeric text finds nothing. */
|
|
17
|
+
numeric?: boolean;
|
|
18
|
+
/** Extra scope AND'd into the query (e.g. the table's `forceFilters`). */
|
|
19
|
+
filter?: FilterExpr;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `true` for a 4xx answer — the server declined this picker (gate, ARBAC, unknown field).
|
|
23
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
24
|
+
*/
|
|
25
|
+
declare function isPickerDeclined(err: unknown): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Distinct values of one column of the table behind `client`, via
|
|
28
|
+
* `/query?$groupBy=<field>`. All server gates (hidden field, ARBAC `$groupBy`
|
|
29
|
+
* control, row scope, write-only, encrypted) apply as for any grouped read; a
|
|
30
|
+
* 4xx rejects with a `ClientError` — see {@link isPickerDeclined}.
|
|
31
|
+
* `hasMore` tells whether another page follows.
|
|
32
|
+
*
|
|
33
|
+
* @internal Backs the distinct-values picker of `@atscript/vue-table`.
|
|
34
|
+
*/
|
|
35
|
+
declare function fetchDistinctValues(client: Pick<Client, "aggregate">, field: string, opts?: DistinctValuesOptions): Promise<{
|
|
36
|
+
items: unknown[];
|
|
37
|
+
hasMore: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { fetchDistinctValues, isPickerDeclined };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Client, FilterExpr } from "@atscript/db-client";
|
|
2
|
+
|
|
3
|
+
//#region src/value-help/distinct-client.d.ts
|
|
4
|
+
interface DistinctValuesOptions {
|
|
5
|
+
/** Search text: a case-insensitive prefix match for strings, an exact match for numbers. */
|
|
6
|
+
text?: string;
|
|
7
|
+
/** Page size. Default: 50. */
|
|
8
|
+
limit?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Rows to skip (the next page of a scrolled picker). Distinct values are only
|
|
11
|
+
* stable across pages when ordered, so a caller pages only with `sortable`.
|
|
12
|
+
*/
|
|
13
|
+
skip?: number;
|
|
14
|
+
/** Send `$sort` on the grouped field — only when the server lists it as sortable. */
|
|
15
|
+
sortable?: boolean;
|
|
16
|
+
/** The field stores numbers: search is an exact match and non-numeric text finds nothing. */
|
|
17
|
+
numeric?: boolean;
|
|
18
|
+
/** Extra scope AND'd into the query (e.g. the table's `forceFilters`). */
|
|
19
|
+
filter?: FilterExpr;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `true` for a 4xx answer — the server declined this picker (gate, ARBAC, unknown field).
|
|
23
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
24
|
+
*/
|
|
25
|
+
declare function isPickerDeclined(err: unknown): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Distinct values of one column of the table behind `client`, via
|
|
28
|
+
* `/query?$groupBy=<field>`. All server gates (hidden field, ARBAC `$groupBy`
|
|
29
|
+
* control, row scope, write-only, encrypted) apply as for any grouped read; a
|
|
30
|
+
* 4xx rejects with a `ClientError` — see {@link isPickerDeclined}.
|
|
31
|
+
* `hasMore` tells whether another page follows.
|
|
32
|
+
*
|
|
33
|
+
* @internal Backs the distinct-values picker of `@atscript/vue-table`.
|
|
34
|
+
*/
|
|
35
|
+
declare function fetchDistinctValues(client: Pick<Client, "aggregate">, field: string, opts?: DistinctValuesOptions): Promise<{
|
|
36
|
+
items: unknown[];
|
|
37
|
+
hasMore: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { fetchDistinctValues, isPickerDeclined };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { escapeRegex } from "../shared/str.mjs";
|
|
2
|
+
//#region src/value-help/distinct-client.ts
|
|
3
|
+
/**
|
|
4
|
+
* `true` for a 4xx answer — the server declined this picker (gate, ARBAC, unknown field).
|
|
5
|
+
* @internal Shared with `@atscript/vue-table`.
|
|
6
|
+
*/
|
|
7
|
+
function isPickerDeclined(err) {
|
|
8
|
+
const status = err?.status;
|
|
9
|
+
return typeof status === "number" && status >= 400 && status < 500;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Distinct values of one column of the table behind `client`, via
|
|
13
|
+
* `/query?$groupBy=<field>`. All server gates (hidden field, ARBAC `$groupBy`
|
|
14
|
+
* control, row scope, write-only, encrypted) apply as for any grouped read; a
|
|
15
|
+
* 4xx rejects with a `ClientError` — see {@link isPickerDeclined}.
|
|
16
|
+
* `hasMore` tells whether another page follows.
|
|
17
|
+
*
|
|
18
|
+
* @internal Backs the distinct-values picker of `@atscript/vue-table`.
|
|
19
|
+
*/
|
|
20
|
+
async function fetchDistinctValues(client, field, opts = {}) {
|
|
21
|
+
const limit = opts.limit ?? 50;
|
|
22
|
+
const text = opts.text?.trim();
|
|
23
|
+
const conditions = [];
|
|
24
|
+
if (opts.filter) conditions.push(opts.filter);
|
|
25
|
+
if (text) if (opts.numeric) {
|
|
26
|
+
const n = Number(text);
|
|
27
|
+
if (!Number.isFinite(n)) return {
|
|
28
|
+
items: [],
|
|
29
|
+
hasMore: false
|
|
30
|
+
};
|
|
31
|
+
conditions.push({ [field]: n });
|
|
32
|
+
} else conditions.push({ [field]: { $regex: `/^${escapeRegex(text)}/i` } });
|
|
33
|
+
const filter = conditions.length > 1 ? { $and: conditions } : conditions[0];
|
|
34
|
+
const rows = await client.aggregate({
|
|
35
|
+
...filter && { filter },
|
|
36
|
+
controls: {
|
|
37
|
+
$groupBy: [field],
|
|
38
|
+
$select: [field],
|
|
39
|
+
...opts.sortable && { $sort: { [field]: 1 } },
|
|
40
|
+
$limit: limit + 1,
|
|
41
|
+
$skip: opts.skip ?? 0
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
items: rows.slice(0, limit).map((r) => r[field]).filter((v) => v !== null && v !== void 0),
|
|
46
|
+
hasMore: rows.length > limit
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { fetchDistinctValues, isPickerDeclined };
|