@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,233 @@
|
|
|
1
|
+
import { DB_HTTP_PATH, EXPECT_MAX_LENGTH, UI_TABLE_COMPONENT, UI_TABLE_SELECT_WITH, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE } from "../shared/annotation-keys.mjs";
|
|
2
|
+
import { getFieldMeta } from "../shared/field-resolver.mjs";
|
|
3
|
+
import { extractFieldLiteralOptions } from "../value-help/extract-literals.mjs";
|
|
4
|
+
import { extractValueHelp } from "../value-help/extract-ref.mjs";
|
|
5
|
+
import { humanizePath } from "../shared/str.mjs";
|
|
6
|
+
import { extractMeasurement } from "../form/measurement.mjs";
|
|
7
|
+
import { deserializeAnnotatedType, flattenAnnotatedType } from "@atscript/typescript/utils";
|
|
8
|
+
//#region src/table/create-table-def.ts
|
|
9
|
+
/**
|
|
10
|
+
* Builds a TableDef from a moost-db MetaResponse.
|
|
11
|
+
*
|
|
12
|
+
* 1. Deserializes `meta.type` into a live TAtscriptAnnotatedType
|
|
13
|
+
* 2. Flattens to discover all field paths
|
|
14
|
+
* 3. Builds ColumnDef per field using annotations + meta.fields capabilities
|
|
15
|
+
* 4. Sorts by @ui.table.order
|
|
16
|
+
*/
|
|
17
|
+
function createTableDef(meta, preDeserializedType) {
|
|
18
|
+
const type = preDeserializedType ?? deserializeAnnotatedType(meta.type);
|
|
19
|
+
const flatMap = type.type.kind === "object" ? flattenAnnotatedType(type, { excludePhantomTypes: true }) : /* @__PURE__ */ new Map();
|
|
20
|
+
const columns = [];
|
|
21
|
+
for (const [path, prop] of flatMap.entries()) {
|
|
22
|
+
if (path === "") continue;
|
|
23
|
+
if (path === meta.versionColumn) continue;
|
|
24
|
+
const fieldMeta = meta.fields[path];
|
|
25
|
+
if (!isReadable(fieldMeta)) continue;
|
|
26
|
+
if (getFieldMeta(prop, "ui.table.exclude") !== void 0) continue;
|
|
27
|
+
const options = extractFieldLiteralOptions(prop);
|
|
28
|
+
const valueHelpInfo = extractValueHelp(prop);
|
|
29
|
+
let distinct;
|
|
30
|
+
if (!valueHelpInfo && !options && fieldMeta.groupable && fieldMeta.filterable) {
|
|
31
|
+
const url = type.metadata.get(DB_HTTP_PATH);
|
|
32
|
+
if (url && getFieldMeta(prop, "ui.valueHelp.distinct") !== void 0) distinct = {
|
|
33
|
+
url,
|
|
34
|
+
field: path
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
columns.push(buildColumn(path, prop, fieldMeta, {
|
|
38
|
+
options,
|
|
39
|
+
valueHelpInfo,
|
|
40
|
+
distinct
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
if (meta.decorations) {
|
|
44
|
+
const decoType = deserializeAnnotatedType(meta.decorations);
|
|
45
|
+
if (decoType.type.kind === "object") for (const [path, prop] of decoType.type.props) {
|
|
46
|
+
const fieldMeta = meta.fields[path];
|
|
47
|
+
if (!fieldMeta?.decoration || flatMap.has(path)) continue;
|
|
48
|
+
if (getFieldMeta(prop, "ui.table.exclude") !== void 0) continue;
|
|
49
|
+
flatMap.set(path, prop);
|
|
50
|
+
columns.push(buildColumn(path, prop, fieldMeta, { options: extractFieldLiteralOptions(prop) }));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
columns.sort((a, b) => a.order - b.order);
|
|
54
|
+
const actions = groupActions(meta.actions ?? []);
|
|
55
|
+
const crud = meta.crud ?? {};
|
|
56
|
+
const preferredId = meta.preferredId ?? meta.primaryKeys;
|
|
57
|
+
return {
|
|
58
|
+
type,
|
|
59
|
+
columns,
|
|
60
|
+
flatMap,
|
|
61
|
+
fetchableFields: new Set(Object.keys(meta.fields).filter((p) => isReadable(meta.fields[p]))),
|
|
62
|
+
primaryKeys: meta.primaryKeys,
|
|
63
|
+
preferredId,
|
|
64
|
+
identifierFields: identifierFieldsOf(preferredId, meta.actions ?? []),
|
|
65
|
+
versionColumn: meta.versionColumn,
|
|
66
|
+
crud,
|
|
67
|
+
canRemove: "remove" in crud,
|
|
68
|
+
actions,
|
|
69
|
+
searchable: meta.searchable,
|
|
70
|
+
vectorSearchable: meta.vectorSearchable,
|
|
71
|
+
searchIndexes: meta.searchIndexes,
|
|
72
|
+
relations: meta.relations
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* One column. A server-declared display-only column (`fieldMeta.decoration`)
|
|
77
|
+
* is never sortable, filterable or groupable and always nullable (a decoration
|
|
78
|
+
* can be absent); an ordinary one takes its capabilities from `/meta`.
|
|
79
|
+
*/
|
|
80
|
+
function buildColumn(path, prop, fieldMeta, resolved) {
|
|
81
|
+
const { options, valueHelpInfo, distinct } = resolved;
|
|
82
|
+
const maxLengthMeta = getFieldMeta(prop, EXPECT_MAX_LENGTH);
|
|
83
|
+
const tableType = getFieldMeta(prop, UI_TABLE_TYPE);
|
|
84
|
+
const sharedType = getFieldMeta(prop, UI_TYPE);
|
|
85
|
+
const tableComponent = getFieldMeta(prop, UI_TABLE_COMPONENT);
|
|
86
|
+
const decoration = fieldMeta.decoration === true;
|
|
87
|
+
const filterOps = decoration ? void 0 : fieldMeta.filterOps;
|
|
88
|
+
return {
|
|
89
|
+
path,
|
|
90
|
+
label: getFieldMeta(prop, "meta.label") ?? humanizePath(path),
|
|
91
|
+
type: tableType ?? sharedType ?? (valueHelpInfo ? "ref" : inferDisplayType(prop, options)),
|
|
92
|
+
valueKind: inferValueKind(prop),
|
|
93
|
+
component: tableComponent,
|
|
94
|
+
selectWith: getFieldMeta(prop, UI_TABLE_SELECT_WITH),
|
|
95
|
+
sortable: !decoration && (fieldMeta.sortable ?? false),
|
|
96
|
+
filterable: !decoration && (fieldMeta.filterable ?? false),
|
|
97
|
+
...filterOps && { filterOps: [...filterOps] },
|
|
98
|
+
nullable: decoration || prop.optional === true,
|
|
99
|
+
width: getFieldMeta(prop, UI_TABLE_WIDTH),
|
|
100
|
+
maxLen: maxLengthMeta?.length,
|
|
101
|
+
order: getFieldMeta(prop, "ui.table.order") ?? Infinity,
|
|
102
|
+
options,
|
|
103
|
+
valueHelpInfo,
|
|
104
|
+
...distinct && { distinct },
|
|
105
|
+
...extractMeasurement(prop)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* `preferredId` ∪ every delegated action's `idMap` paths, in that order —
|
|
110
|
+
* the same array when no action carries an `idMap`.
|
|
111
|
+
*/
|
|
112
|
+
function identifierFieldsOf(preferredId, actions) {
|
|
113
|
+
let out;
|
|
114
|
+
for (const a of actions) {
|
|
115
|
+
if (!a.idMap) continue;
|
|
116
|
+
for (const path of Object.values(a.idMap)) {
|
|
117
|
+
if (preferredId.includes(path) || out?.includes(path)) continue;
|
|
118
|
+
(out ??= [...preferredId]).push(path);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return out ?? preferredId;
|
|
122
|
+
}
|
|
123
|
+
/** A field the caller may read: listed in `meta.fields` and not write-only. */
|
|
124
|
+
function isReadable(field) {
|
|
125
|
+
return field !== void 0 && field.writeOnly !== true;
|
|
126
|
+
}
|
|
127
|
+
/** Sort by (order ?? 0). `toSorted` is stable per spec, so ties preserve declaration order. */
|
|
128
|
+
function byOrder(xs) {
|
|
129
|
+
return xs.toSorted((x, y) => (x.order ?? 0) - (y.order ?? 0));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Partition actions by `level`, sort each group by `(order ?? 0)` then
|
|
133
|
+
* declaration order, and pick the first `default: true` entry per level.
|
|
134
|
+
* The synthesised `__remove` UI action lives outside this set and is never
|
|
135
|
+
* a candidate for `default.row`.
|
|
136
|
+
*/
|
|
137
|
+
function groupActions(actions) {
|
|
138
|
+
const table = [];
|
|
139
|
+
const row = [];
|
|
140
|
+
const rows = [];
|
|
141
|
+
for (const a of actions) if (a.level === "table") table.push(a);
|
|
142
|
+
else if (a.level === "row") row.push(a);
|
|
143
|
+
else if (a.level === "rows") rows.push(a);
|
|
144
|
+
const tableSorted = byOrder(table);
|
|
145
|
+
const rowSorted = byOrder(row);
|
|
146
|
+
const rowsSorted = byOrder(rows);
|
|
147
|
+
return {
|
|
148
|
+
table: tableSorted,
|
|
149
|
+
row: rowSorted,
|
|
150
|
+
rows: rowsSorted,
|
|
151
|
+
default: {
|
|
152
|
+
table: tableSorted.find((a) => a.default === true),
|
|
153
|
+
row: rowSorted.find((a) => a.default === true),
|
|
154
|
+
rows: rowsSorted.find((a) => a.default === true)
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** Infers a display type string from the annotated type's kind and designType. */
|
|
159
|
+
function inferDisplayType(prop, literalOpts) {
|
|
160
|
+
const kind = prop.type.kind;
|
|
161
|
+
if (kind === "array") return "array";
|
|
162
|
+
if (kind === "object") return "object";
|
|
163
|
+
if (kind === "union") return literalOpts !== void 0 ? "enum" : "union";
|
|
164
|
+
if (kind === "") {
|
|
165
|
+
const final = prop.type;
|
|
166
|
+
const dt = final.designType;
|
|
167
|
+
if (dt === "number") return final.tags?.has("timestamp") ? "datetime" : "number";
|
|
168
|
+
if (dt === "decimal") return "number";
|
|
169
|
+
if (dt === "boolean") return "boolean";
|
|
170
|
+
return "text";
|
|
171
|
+
}
|
|
172
|
+
return "text";
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Number metadata that makes the server treat a plain `number` column as an
|
|
176
|
+
* integer (mirrors the db layer's `valueTypeOf`), beside the `int` / `expect.int` tags.
|
|
177
|
+
*/
|
|
178
|
+
const INTEGER_NUMBER_META = [
|
|
179
|
+
"expect.int",
|
|
180
|
+
"db.default.increment",
|
|
181
|
+
"db.default.now",
|
|
182
|
+
"db.agg.count",
|
|
183
|
+
"db.agg.countDistinct"
|
|
184
|
+
];
|
|
185
|
+
/** The kind of one scalar leaf, or `undefined` for a non-scalar / unknown design type. */
|
|
186
|
+
function scalarValueKind(prop) {
|
|
187
|
+
const final = prop.type;
|
|
188
|
+
const tags = final.tags;
|
|
189
|
+
switch (final.designType) {
|
|
190
|
+
case "string": return tags?.has("isoDate") ? "isoDate" : tags?.has("date") ? "date" : "string";
|
|
191
|
+
case "number":
|
|
192
|
+
if (tags?.has("timestamp")) return "timestamp";
|
|
193
|
+
if (tags?.has("int") || INTEGER_NUMBER_META.some((k) => prop.metadata.has(k))) return "integer";
|
|
194
|
+
return "number";
|
|
195
|
+
case "decimal": return "decimal";
|
|
196
|
+
case "boolean": return "boolean";
|
|
197
|
+
default: return;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** Kinds of every non-null leaf of a (possibly nested) union; `null` when one is not a scalar. */
|
|
201
|
+
function collectUnionKinds(items, out) {
|
|
202
|
+
for (const item of items) {
|
|
203
|
+
if (item.type.kind === "union") {
|
|
204
|
+
collectUnionKinds(item.type.items, out);
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (item.type.kind === "") {
|
|
208
|
+
const dt = item.type.designType;
|
|
209
|
+
if (dt === "null" || dt === "undefined") continue;
|
|
210
|
+
out.add(scalarValueKind(item));
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
out.add(void 0);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Scalar storage kind of the column's value — what the server's filter guard
|
|
218
|
+
* checks. A scalar maps to its kind; a union that agrees on one kind across
|
|
219
|
+
* its non-null members (`'a' | 'b'`, `1 | 2`, `number.timestamp | null`)
|
|
220
|
+
* takes it; arrays, objects, JSON and mixed unions have none (`undefined`),
|
|
221
|
+
* which means no value coercion.
|
|
222
|
+
*/
|
|
223
|
+
function inferValueKind(prop) {
|
|
224
|
+
const kind = prop.type.kind;
|
|
225
|
+
if (kind === "") return scalarValueKind(prop);
|
|
226
|
+
if (kind !== "union") return void 0;
|
|
227
|
+
const kinds = /* @__PURE__ */ new Set();
|
|
228
|
+
collectUnionKinds(prop.type.items, kinds);
|
|
229
|
+
if (kinds.size !== 1) return void 0;
|
|
230
|
+
return [...kinds][0];
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
export { createTableDef };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
let _atscript_db_client = require("@atscript/db-client");
|
|
2
|
+
//#region src/table/navigate-href.ts
|
|
3
|
+
/**
|
|
4
|
+
* Compute the href a `processor: 'navigate'` action would open — synchronously,
|
|
5
|
+
* at render time. Mirrors the interpolation `Client` performs when the action
|
|
6
|
+
* is invoked (`action.value` with every `$1` replaced by the URL-encoded,
|
|
7
|
+
* `/`-joined `preferredId` fields — see `encodeNavigateId`), so tables can
|
|
8
|
+
* render navigate actions as real `<a href>` anchors and native link behaviour
|
|
9
|
+
* (middle-click → new tab, copy link, hover preview) just works.
|
|
10
|
+
*
|
|
11
|
+
* Returns `undefined` when no link is possible — the caller should fall back to
|
|
12
|
+
* a button and let `Client` handle the invoke:
|
|
13
|
+
*
|
|
14
|
+
* - `action.processor !== 'navigate'` — backend/custom actions stay buttons;
|
|
15
|
+
* - row-level action with `id === undefined` — the row is not identifiable
|
|
16
|
+
* (note this deliberately differs from `Client`, which navigates to the raw
|
|
17
|
+
* template in that case; a raw-template href would be a broken link);
|
|
18
|
+
* - row-level action with an empty `preferredId` — `$1` has nothing to encode.
|
|
19
|
+
*
|
|
20
|
+
* Table/rows-level navigate actions carry no `$1` placeholder and return
|
|
21
|
+
* `action.value` verbatim.
|
|
22
|
+
*
|
|
23
|
+
* A delegated action (`action.idMap`, since 0.1.147) reads `id` as one of THIS
|
|
24
|
+
* table's rows (or identifiers) and encodes the owner's identification it maps
|
|
25
|
+
* to, in `Object.keys(idMap)` order — the same as `Client`. A row the map
|
|
26
|
+
* cannot address (a missing path) has no link.
|
|
27
|
+
*/
|
|
28
|
+
function navigateHrefFor(action, id, preferredId) {
|
|
29
|
+
if (action.processor !== "navigate") return void 0;
|
|
30
|
+
if (action.level !== "row") return action.value;
|
|
31
|
+
if (id === void 0) return void 0;
|
|
32
|
+
if (action.idMap) {
|
|
33
|
+
let mapped;
|
|
34
|
+
try {
|
|
35
|
+
mapped = (0, _atscript_db_client.actionIdentifier)(action, id, []);
|
|
36
|
+
} catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
return action.value.replace(/\$1/g, (0, _atscript_db_client.encodeNavigateId)(mapped, Object.keys(action.idMap)));
|
|
40
|
+
}
|
|
41
|
+
if (preferredId.length === 0) return void 0;
|
|
42
|
+
return action.value.replace(/\$1/g, (0, _atscript_db_client.encodeNavigateId)(id, preferredId));
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.navigateHrefFor = navigateHrefFor;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TDbActionInfo } from "@atscript/db-client";
|
|
2
|
+
|
|
3
|
+
//#region src/table/navigate-href.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Compute the href a `processor: 'navigate'` action would open — synchronously,
|
|
6
|
+
* at render time. Mirrors the interpolation `Client` performs when the action
|
|
7
|
+
* is invoked (`action.value` with every `$1` replaced by the URL-encoded,
|
|
8
|
+
* `/`-joined `preferredId` fields — see `encodeNavigateId`), so tables can
|
|
9
|
+
* render navigate actions as real `<a href>` anchors and native link behaviour
|
|
10
|
+
* (middle-click → new tab, copy link, hover preview) just works.
|
|
11
|
+
*
|
|
12
|
+
* Returns `undefined` when no link is possible — the caller should fall back to
|
|
13
|
+
* a button and let `Client` handle the invoke:
|
|
14
|
+
*
|
|
15
|
+
* - `action.processor !== 'navigate'` — backend/custom actions stay buttons;
|
|
16
|
+
* - row-level action with `id === undefined` — the row is not identifiable
|
|
17
|
+
* (note this deliberately differs from `Client`, which navigates to the raw
|
|
18
|
+
* template in that case; a raw-template href would be a broken link);
|
|
19
|
+
* - row-level action with an empty `preferredId` — `$1` has nothing to encode.
|
|
20
|
+
*
|
|
21
|
+
* Table/rows-level navigate actions carry no `$1` placeholder and return
|
|
22
|
+
* `action.value` verbatim.
|
|
23
|
+
*
|
|
24
|
+
* A delegated action (`action.idMap`, since 0.1.147) reads `id` as one of THIS
|
|
25
|
+
* table's rows (or identifiers) and encodes the owner's identification it maps
|
|
26
|
+
* to, in `Object.keys(idMap)` order — the same as `Client`. A row the map
|
|
27
|
+
* cannot address (a missing path) has no link.
|
|
28
|
+
*/
|
|
29
|
+
declare function navigateHrefFor(action: TDbActionInfo, id: Record<string, unknown> | undefined, preferredId: readonly string[]): string | undefined;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { navigateHrefFor };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TDbActionInfo } from "@atscript/db-client";
|
|
2
|
+
|
|
3
|
+
//#region src/table/navigate-href.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Compute the href a `processor: 'navigate'` action would open — synchronously,
|
|
6
|
+
* at render time. Mirrors the interpolation `Client` performs when the action
|
|
7
|
+
* is invoked (`action.value` with every `$1` replaced by the URL-encoded,
|
|
8
|
+
* `/`-joined `preferredId` fields — see `encodeNavigateId`), so tables can
|
|
9
|
+
* render navigate actions as real `<a href>` anchors and native link behaviour
|
|
10
|
+
* (middle-click → new tab, copy link, hover preview) just works.
|
|
11
|
+
*
|
|
12
|
+
* Returns `undefined` when no link is possible — the caller should fall back to
|
|
13
|
+
* a button and let `Client` handle the invoke:
|
|
14
|
+
*
|
|
15
|
+
* - `action.processor !== 'navigate'` — backend/custom actions stay buttons;
|
|
16
|
+
* - row-level action with `id === undefined` — the row is not identifiable
|
|
17
|
+
* (note this deliberately differs from `Client`, which navigates to the raw
|
|
18
|
+
* template in that case; a raw-template href would be a broken link);
|
|
19
|
+
* - row-level action with an empty `preferredId` — `$1` has nothing to encode.
|
|
20
|
+
*
|
|
21
|
+
* Table/rows-level navigate actions carry no `$1` placeholder and return
|
|
22
|
+
* `action.value` verbatim.
|
|
23
|
+
*
|
|
24
|
+
* A delegated action (`action.idMap`, since 0.1.147) reads `id` as one of THIS
|
|
25
|
+
* table's rows (or identifiers) and encodes the owner's identification it maps
|
|
26
|
+
* to, in `Object.keys(idMap)` order — the same as `Client`. A row the map
|
|
27
|
+
* cannot address (a missing path) has no link.
|
|
28
|
+
*/
|
|
29
|
+
declare function navigateHrefFor(action: TDbActionInfo, id: Record<string, unknown> | undefined, preferredId: readonly string[]): string | undefined;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { navigateHrefFor };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { actionIdentifier, encodeNavigateId } from "@atscript/db-client";
|
|
2
|
+
//#region src/table/navigate-href.ts
|
|
3
|
+
/**
|
|
4
|
+
* Compute the href a `processor: 'navigate'` action would open — synchronously,
|
|
5
|
+
* at render time. Mirrors the interpolation `Client` performs when the action
|
|
6
|
+
* is invoked (`action.value` with every `$1` replaced by the URL-encoded,
|
|
7
|
+
* `/`-joined `preferredId` fields — see `encodeNavigateId`), so tables can
|
|
8
|
+
* render navigate actions as real `<a href>` anchors and native link behaviour
|
|
9
|
+
* (middle-click → new tab, copy link, hover preview) just works.
|
|
10
|
+
*
|
|
11
|
+
* Returns `undefined` when no link is possible — the caller should fall back to
|
|
12
|
+
* a button and let `Client` handle the invoke:
|
|
13
|
+
*
|
|
14
|
+
* - `action.processor !== 'navigate'` — backend/custom actions stay buttons;
|
|
15
|
+
* - row-level action with `id === undefined` — the row is not identifiable
|
|
16
|
+
* (note this deliberately differs from `Client`, which navigates to the raw
|
|
17
|
+
* template in that case; a raw-template href would be a broken link);
|
|
18
|
+
* - row-level action with an empty `preferredId` — `$1` has nothing to encode.
|
|
19
|
+
*
|
|
20
|
+
* Table/rows-level navigate actions carry no `$1` placeholder and return
|
|
21
|
+
* `action.value` verbatim.
|
|
22
|
+
*
|
|
23
|
+
* A delegated action (`action.idMap`, since 0.1.147) reads `id` as one of THIS
|
|
24
|
+
* table's rows (or identifiers) and encodes the owner's identification it maps
|
|
25
|
+
* to, in `Object.keys(idMap)` order — the same as `Client`. A row the map
|
|
26
|
+
* cannot address (a missing path) has no link.
|
|
27
|
+
*/
|
|
28
|
+
function navigateHrefFor(action, id, preferredId) {
|
|
29
|
+
if (action.processor !== "navigate") return void 0;
|
|
30
|
+
if (action.level !== "row") return action.value;
|
|
31
|
+
if (id === void 0) return void 0;
|
|
32
|
+
if (action.idMap) {
|
|
33
|
+
let mapped;
|
|
34
|
+
try {
|
|
35
|
+
mapped = actionIdentifier(action, id, []);
|
|
36
|
+
} catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
return action.value.replace(/\$1/g, encodeNavigateId(mapped, Object.keys(action.idMap)));
|
|
40
|
+
}
|
|
41
|
+
if (preferredId.length === 0) return void 0;
|
|
42
|
+
return action.value.replace(/\$1/g, encodeNavigateId(id, preferredId));
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { navigateHrefFor };
|
|
@@ -0,0 +1,287 @@
|
|
|
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`).
|
|
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 };
|