@atscript/ui 0.1.189 → 0.1.191
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.d.cts +9 -7
- package/dist/client-factory.d.mts +9 -7
- package/dist/form/create-form-def.cjs +40 -1
- package/dist/form/create-form-def.d.cts +1 -1
- package/dist/form/create-form-def.d.mts +1 -1
- package/dist/form/create-form-def.mjs +40 -1
- package/dist/form/diff.cjs +8 -1
- package/dist/form/diff.d.cts +5 -2
- package/dist/form/diff.d.mts +5 -2
- package/dist/form/diff.mjs +9 -2
- package/dist/form/skipped-nav.cjs +1 -1
- package/dist/form/skipped-nav.mjs +1 -1
- package/dist/index.cjs +11 -0
- package/dist/index.d.cts +7 -4
- package/dist/index.d.mts +7 -4
- package/dist/index.mjs +6 -3
- package/dist/messages.cjs +3 -0
- package/dist/messages.d.cts +3 -0
- package/dist/messages.d.mts +3 -0
- package/dist/messages.mjs +3 -0
- package/dist/plugin/annotations.cjs +57 -2
- package/dist/plugin/annotations.mjs +58 -3
- package/dist/plugin/value-help-validation.cjs +357 -24
- package/dist/plugin/value-help-validation.mjs +355 -26
- package/dist/shared/annotation-keys.cjs +11 -0
- package/dist/shared/annotation-keys.d.cts +3 -1
- package/dist/shared/annotation-keys.d.mts +3 -1
- package/dist/shared/annotation-keys.mjs +8 -1
- package/dist/shared/meta-cache.d.cts +3 -3
- package/dist/shared/meta-cache.d.mts +3 -3
- package/dist/shared/value-label.cjs +28 -0
- package/dist/shared/value-label.d.cts +25 -0
- package/dist/shared/value-label.d.mts +25 -0
- package/dist/shared/value-label.mjs +27 -0
- package/dist/table/create-table-def.cjs +15 -1
- package/dist/table/create-table-def.mjs +15 -1
- package/dist/table/types.d.cts +31 -9
- package/dist/table/types.d.mts +31 -9
- package/dist/value-help/distinct-client.cjs +2 -1
- package/dist/value-help/distinct-client.d.cts +2 -2
- package/dist/value-help/distinct-client.d.mts +2 -2
- package/dist/value-help/distinct-client.mjs +2 -1
- package/dist/value-help/extract-ref.cjs +22 -5
- package/dist/value-help/extract-ref.mjs +23 -6
- package/dist/value-help/filter-tree.cjs +39 -14
- package/dist/value-help/filter-tree.mjs +39 -14
- package/dist/value-help/index.d.mts +3 -1
- package/dist/value-help/options.cjs +30 -0
- package/dist/value-help/options.d.cts +19 -0
- package/dist/value-help/options.d.mts +19 -0
- package/dist/value-help/options.mjs +29 -0
- package/dist/value-help/scope.cjs +50 -0
- package/dist/value-help/scope.d.cts +32 -0
- package/dist/value-help/scope.d.mts +32 -0
- package/dist/value-help/scope.mjs +49 -0
- package/dist/value-help/types.d.cts +29 -1
- package/dist/value-help/types.d.mts +29 -1
- package/dist/value-help/value-help-client.cjs +23 -4
- package/dist/value-help/value-help-client.d.cts +27 -8
- package/dist/value-help/value-help-client.d.mts +27 -8
- package/dist/value-help/value-help-client.mjs +23 -5
- package/package.json +9 -9
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { getFieldsForType, getSiblingAnnotation, isInterface, isProp, isQueryComparison, isQueryLogical, isRef, isStructure } from "@atscript/core";
|
|
2
|
-
import { NOT_DIMENSION_REASON,
|
|
2
|
+
import { NOT_DIMENSION_REASON, annotationTarget, effectiveAnnotationNames, fkChainRef, getAnnotationAlias, getTypeFields, isAliasDecl, isDbSourceDecl, isNavProp, isStrictAggregateStruct, primitiveBaseType, siblingStringFields, validateExclusiveWith, validateQueryScope, validateRefArgument, validateSiblingStringField } from "@atscript/db/shared";
|
|
3
3
|
//#region src/plugin/value-help-validation.ts
|
|
4
4
|
/**
|
|
5
5
|
* Editor scopes + validators of `@ui.valueHelp`, `@ui.valueHelp.distinct` and
|
|
6
|
-
* `@ui.literalLabel` (since 0.1.148)
|
|
6
|
+
* `@ui.literalLabel` (since 0.1.148), and of `@ui.valueHelp.fill`,
|
|
7
|
+
* `@ui.valueHelp.column`, host references in a binding filter and
|
|
8
|
+
* `@ui.valueLabel` (since 0.1.190). Scopes and validators share one source,
|
|
7
9
|
* so a diagnostic and what the editor completes never diverge.
|
|
8
10
|
*/
|
|
9
11
|
const WARNING = 2;
|
|
@@ -21,11 +23,27 @@ const valueHelpScopes = {
|
|
|
21
23
|
unqualifiedTarget: target
|
|
22
24
|
} : void 0;
|
|
23
25
|
},
|
|
24
|
-
filter: (arg) => {
|
|
26
|
+
filter: (arg, doc) => {
|
|
25
27
|
const target = targetOf(arg);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
if (!target) return void 0;
|
|
29
|
+
const host = hostOf(arg, doc);
|
|
30
|
+
return {
|
|
31
|
+
allowedTypes: typeof host === "object" && host.name !== target ? [target, host.name] : [target],
|
|
28
32
|
unqualifiedTarget: target
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
hostField: (arg, doc) => {
|
|
36
|
+
const host = hostOf(arg, doc);
|
|
37
|
+
return typeof host === "object" ? {
|
|
38
|
+
allowedTypes: [],
|
|
39
|
+
unqualifiedTarget: host.name
|
|
40
|
+
} : void 0;
|
|
41
|
+
},
|
|
42
|
+
bindingField: (arg, doc) => {
|
|
43
|
+
const binding = bindingOf(annotationTarget(arg, doc), doc);
|
|
44
|
+
return binding ? {
|
|
45
|
+
allowedTypes: [],
|
|
46
|
+
unqualifiedTarget: binding.name
|
|
29
47
|
} : void 0;
|
|
30
48
|
}
|
|
31
49
|
};
|
|
@@ -196,32 +214,139 @@ function annotatedField(node, doc) {
|
|
|
196
214
|
owner
|
|
197
215
|
};
|
|
198
216
|
}
|
|
199
|
-
function isNavigation(node) {
|
|
200
|
-
return !!node && (node.countAnnotations("db.rel.to") > 0 || node.countAnnotations("db.rel.from") > 0 || node.countAnnotations("db.rel.via") > 0);
|
|
201
|
-
}
|
|
202
217
|
/** Top-level conjuncts of a predicate (an `and` chain flattened). */
|
|
203
218
|
function conjuncts(expr) {
|
|
204
219
|
if (isQueryLogical(expr) && expr.operator === "and") return expr.operands.flatMap(conjuncts);
|
|
205
220
|
return [expr];
|
|
206
221
|
}
|
|
222
|
+
/** The right-hand field reference of a comparison, if it compares two fields. */
|
|
223
|
+
function rightRef(cmp) {
|
|
224
|
+
return cmp.right && "fieldRef" in cmp.right ? cmp.right : void 0;
|
|
225
|
+
}
|
|
207
226
|
/**
|
|
208
227
|
* Fields the filter pins with a top-level `=` against a literal value. The
|
|
209
|
-
* compile-time twin of `pinnedOf` in `value-help/filter-tree.ts` (which reads
|
|
210
|
-
* emitted tree at runtime) — keep the two rules in step.
|
|
228
|
+
* compile-time twin of `pinnedOf` in `value-help/filter-tree.ts` (which reads
|
|
229
|
+
* the emitted tree at runtime) — keep the two rules in step.
|
|
211
230
|
*/
|
|
212
231
|
function pinnedFields(filter) {
|
|
213
232
|
const pinned = /* @__PURE__ */ new Set();
|
|
214
233
|
const expr = filter?.queryNode?.expression;
|
|
215
234
|
if (!expr) return pinned;
|
|
216
|
-
for (const c of conjuncts(expr))
|
|
235
|
+
for (const c of conjuncts(expr)) {
|
|
236
|
+
if (!isQueryComparison(c) || c.operator !== "=" || !c.right) continue;
|
|
237
|
+
if (!rightRef(c)) pinned.add(c.left.fieldRef.text);
|
|
238
|
+
}
|
|
217
239
|
return pinned;
|
|
218
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* The target fields the filter's host references pin (`targetField =
|
|
243
|
+
* Host.field`), each with its host field — pinned only while that host field
|
|
244
|
+
* has a value.
|
|
245
|
+
*/
|
|
246
|
+
function hostPins(filter, hostName) {
|
|
247
|
+
const pins = /* @__PURE__ */ new Map();
|
|
248
|
+
const expr = filter?.queryNode?.expression;
|
|
249
|
+
if (!expr) return pins;
|
|
250
|
+
for (const c of conjuncts(expr)) {
|
|
251
|
+
if (!isQueryComparison(c) || c.operator !== "=") continue;
|
|
252
|
+
const ref = rightRef(c);
|
|
253
|
+
if (ref?.typeRef?.text === hostName) pins.set(c.left.fieldRef.text, ref.fieldRef.text);
|
|
254
|
+
}
|
|
255
|
+
return pins;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The {@link THost} of the field the annotation (or argument) `token` sits
|
|
259
|
+
* on; `undefined` when it sits on no field (a type-level binding, an entry
|
|
260
|
+
* that lands nowhere).
|
|
261
|
+
*/
|
|
262
|
+
function hostOf(token, doc) {
|
|
263
|
+
const node = token.parentNode;
|
|
264
|
+
if (!node) return void 0;
|
|
265
|
+
if (isRef(node)) {
|
|
266
|
+
const at = node.token("identifier")?.range.start;
|
|
267
|
+
const block = at ? doc.annotateBlockAt(at.line, at.character) : void 0;
|
|
268
|
+
if (!block) return void 0;
|
|
269
|
+
if (!block.isMutating) return "copy";
|
|
270
|
+
if (node.hasChain) return "inline";
|
|
271
|
+
const field = annotationTarget(token, doc);
|
|
272
|
+
const fields = getTypeFields(field?.ownerNode, doc);
|
|
273
|
+
return field && fields ? {
|
|
274
|
+
name: block.targetName,
|
|
275
|
+
fields,
|
|
276
|
+
field
|
|
277
|
+
} : void 0;
|
|
278
|
+
}
|
|
279
|
+
if (!isProp(node)) return void 0;
|
|
280
|
+
const iface = node.ownerNode?.ownerNode;
|
|
281
|
+
if (!isStructure(node.ownerNode) || !iface || !isInterface(iface)) return "inline";
|
|
282
|
+
const fields = getTypeFields(iface, doc);
|
|
283
|
+
return fields && iface.id ? {
|
|
284
|
+
name: iface.id,
|
|
285
|
+
fields,
|
|
286
|
+
field: node
|
|
287
|
+
} : void 0;
|
|
288
|
+
}
|
|
289
|
+
const REFUSED = {
|
|
290
|
+
inline: "a top-level field of an interface, not a field of an inline structure, a type or a nested annotate entry",
|
|
291
|
+
copy: "a field of an interface or of a mutating annotate block, not of an `annotate … as` copy"
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* The binding a field's fills and columns belong to: its own `@ui.valueHelp`
|
|
295
|
+
* (for an `annotate` entry's field, the landed one — the entry's wins), else its
|
|
296
|
+
* own `@db.rel.FK` help. A binding the field only gets through its type or a
|
|
297
|
+
* chain reference takes no fills or columns.
|
|
298
|
+
*/
|
|
299
|
+
function bindingOf(field, doc) {
|
|
300
|
+
if (!field) return void 0;
|
|
301
|
+
const own = field.annotations?.find((a) => a.name === "ui.valueHelp");
|
|
302
|
+
if (own) {
|
|
303
|
+
const name = own.args[0]?.text;
|
|
304
|
+
return name ? {
|
|
305
|
+
name,
|
|
306
|
+
target: resolveTarget(name, doc)
|
|
307
|
+
} : void 0;
|
|
308
|
+
}
|
|
309
|
+
if (field.countAnnotations("db.rel.FK") > 0) {
|
|
310
|
+
const ref = fkChainRef(field.getDefinition());
|
|
311
|
+
if (ref?.id) return {
|
|
312
|
+
name: ref.id,
|
|
313
|
+
target: resolveTarget(ref.id, doc.refOrigin(ref))
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const SCALAR = "a scalar (not an object, an array, a navigation or @db.json)";
|
|
318
|
+
/** Whether a field holds no scalar: an object, an array, `@db.json` or a navigation. */
|
|
319
|
+
function isNotScalar(prop, doc) {
|
|
320
|
+
if (prop.countAnnotations("db.json") > 0 || isNavProp(prop)) return true;
|
|
321
|
+
const design = designOf(prop.getDefinition(), doc.declaringDoc(prop, doc));
|
|
322
|
+
return design === "object" || design === "array";
|
|
323
|
+
}
|
|
324
|
+
/** FL3 / CL2: why `name` is no top-level scalar field of the binding's target. */
|
|
325
|
+
function targetFieldProblem(binding, name) {
|
|
326
|
+
if (name.includes(".")) return `'${name}' must be a top-level field of '${binding.name}', not a dotted path`;
|
|
327
|
+
const target = binding.target;
|
|
328
|
+
if (!target) return void 0;
|
|
329
|
+
const prop = target.props.get(name);
|
|
330
|
+
if (!prop) return `Field '${name}' does not exist on '${binding.name}'`;
|
|
331
|
+
if (isNotScalar(prop, target.doc)) return `'${binding.name}.${name}' must be ${SCALAR}`;
|
|
332
|
+
}
|
|
333
|
+
/** FL4 / VH9: why the host field `local` cannot take the target field `name`'s values. */
|
|
334
|
+
function designMismatch(host, local, binding, name, doc) {
|
|
335
|
+
const localProp = host.fields.get(local);
|
|
336
|
+
const targetProp = binding.target?.props.get(name);
|
|
337
|
+
if (!localProp || !targetProp || !binding.target) return void 0;
|
|
338
|
+
const a = designOf(targetProp.getDefinition(), binding.target.doc);
|
|
339
|
+
const b = designOf(localProp.getDefinition(), doc.declaringDoc(localProp, doc));
|
|
340
|
+
if (!a || !b || a === "other" || b === "other" || a === b) return void 0;
|
|
341
|
+
return `'${binding.name}.${name}' is ${a}, '${host.name}.${local}' is ${b}`;
|
|
342
|
+
}
|
|
219
343
|
function validateValueHelp(token, args, doc) {
|
|
220
344
|
const errors = [];
|
|
221
345
|
const [targetArg, fieldArg, filterArg] = args;
|
|
222
346
|
const host = token.parentNode;
|
|
223
347
|
const field = annotatedField(host, doc);
|
|
224
|
-
|
|
348
|
+
const navNode = field?.prop ?? host;
|
|
349
|
+
if (navNode && isNavProp(navNode)) errors.push({
|
|
225
350
|
message: "@ui.valueHelp is not valid on a navigation field — bind the foreign-key field",
|
|
226
351
|
severity: ERROR,
|
|
227
352
|
range: token.range
|
|
@@ -273,36 +398,52 @@ function validateValueHelp(token, args, doc) {
|
|
|
273
398
|
});
|
|
274
399
|
}
|
|
275
400
|
const filterQuery = filterArg?.queryNode;
|
|
401
|
+
const formHost = hostOf(token, doc);
|
|
402
|
+
const validHost = typeof formHost === "object" ? formHost : void 0;
|
|
276
403
|
if (filterArg && filterQuery) {
|
|
277
404
|
errors.push(...validateQueryScope(filterArg, {
|
|
278
|
-
allowedTypes: [targetName],
|
|
405
|
+
allowedTypes: validHost && validHost.name !== targetName ? [targetName, validHost.name] : [targetName],
|
|
279
406
|
unqualifiedTarget: targetName
|
|
280
407
|
}, doc));
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
408
|
+
errors.push(...validateHostRefs(filterQuery.expression, {
|
|
409
|
+
host: formHost,
|
|
410
|
+
binding: {
|
|
411
|
+
name: targetName,
|
|
412
|
+
target
|
|
413
|
+
},
|
|
414
|
+
doc
|
|
415
|
+
}));
|
|
286
416
|
}
|
|
287
417
|
if (fieldProp && fieldName !== void 0) {
|
|
288
418
|
const idFields = [...target.props.entries()].filter(([, p]) => p.countAnnotations("meta.id") > 0);
|
|
289
419
|
let ok = fieldProp.countAnnotations("db.index.unique") > 0 || fieldProp.countAnnotations("meta.id") > 0 && idFields.length === 1;
|
|
290
420
|
if (!ok && fieldProp.countAnnotations("meta.id") > 0) {
|
|
291
|
-
const
|
|
292
|
-
|
|
421
|
+
const literal = pinnedFields(filterArg);
|
|
422
|
+
const byHost = validHost ? hostPins(filterArg, validHost.name) : void 0;
|
|
423
|
+
const fieldAnnotations = annotationTarget(token, doc)?.annotations ?? [];
|
|
424
|
+
const argOf = (name) => fieldAnnotations.find((a) => a.name === name)?.args[0]?.text;
|
|
425
|
+
const formType = argOf("ui.form.type") ?? argOf("ui.type");
|
|
426
|
+
const dropdown = formType === "select" || formType === "radio";
|
|
427
|
+
const fills = fieldAnnotations.filter((a) => a.name === "ui.valueHelp.fill");
|
|
428
|
+
const columns = new Set(fieldAnnotations.filter((a) => a.name === "ui.valueHelp.column").map((a) => a.args[0]?.text));
|
|
429
|
+
const writtenBack = (member) => {
|
|
430
|
+
const local = byHost?.get(member);
|
|
431
|
+
return local !== void 0 && fills.some((a) => a.args[0]?.text === local && a.args[1]?.text === member);
|
|
432
|
+
};
|
|
433
|
+
ok = idFields.every(([name]) => name === fieldName || literal.has(name) || !dropdown && (writtenBack(name) || columns.has(name)));
|
|
293
434
|
}
|
|
294
435
|
if (!ok) errors.push({
|
|
295
|
-
message: `values may repeat in the picker — '${targetName}.${fieldName}' is not unique (a sole @meta.id, @db.index.unique, or a composite key member with the other members pinned by '=' in the filter)`,
|
|
436
|
+
message: `values may repeat in the picker — '${targetName}.${fieldName}' is not unique (a sole @meta.id, @db.index.unique, or a composite key member with the other members pinned by '=' to a literal in the filter, or to a host field a fill writes back from the picked row, or shown as a @ui.valueHelp.column of this field)`,
|
|
296
437
|
severity: WARNING,
|
|
297
438
|
range: token.range
|
|
298
439
|
});
|
|
299
440
|
}
|
|
300
441
|
if (filterQuery && getAnnotationAlias(target.decl, "db.table.filterable") === "manual") {
|
|
301
442
|
const seen = /* @__PURE__ */ new Set();
|
|
302
|
-
|
|
303
|
-
if (ref.typeRef && ref.typeRef.text !== targetName)
|
|
443
|
+
for (const { left: ref } of comparisons(filterQuery.expression)) {
|
|
444
|
+
if (ref.typeRef && ref.typeRef.text !== targetName) continue;
|
|
304
445
|
const name = ref.fieldRef.text;
|
|
305
|
-
if (seen.has(name))
|
|
446
|
+
if (seen.has(name)) continue;
|
|
306
447
|
seen.add(name);
|
|
307
448
|
const prop = target.props.get(name.split(".")[0]);
|
|
308
449
|
if (prop && prop.countAnnotations("db.column.filterable") === 0) errors.push({
|
|
@@ -310,7 +451,27 @@ function validateValueHelp(token, args, doc) {
|
|
|
310
451
|
severity: WARNING,
|
|
311
452
|
range: ref.fieldRef.range
|
|
312
453
|
});
|
|
313
|
-
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (validHost && isRef(host)) {
|
|
457
|
+
const binding = {
|
|
458
|
+
name: targetName,
|
|
459
|
+
target
|
|
460
|
+
};
|
|
461
|
+
for (const a of validHost.field.annotations ?? []) {
|
|
462
|
+
if (a.token.parentNode === host) continue;
|
|
463
|
+
const isFill = a.name === "ui.valueHelp.fill";
|
|
464
|
+
if (!isFill && a.name !== "ui.valueHelp.column") continue;
|
|
465
|
+
const local = isFill ? a.args[0]?.text : void 0;
|
|
466
|
+
const name = a.args[isFill ? 1 : 0]?.text;
|
|
467
|
+
if (name === void 0) continue;
|
|
468
|
+
const problem = targetFieldProblem(binding, name) ?? (local === void 0 ? void 0 : designMismatch(validHost, local, binding, name, doc));
|
|
469
|
+
if (problem) errors.push({
|
|
470
|
+
message: `@${a.name} '${a.args.map((t) => t.text).join("', '")}' of this field: ${problem}`,
|
|
471
|
+
severity: ERROR,
|
|
472
|
+
range: token.range
|
|
473
|
+
});
|
|
474
|
+
}
|
|
314
475
|
}
|
|
315
476
|
return errors;
|
|
316
477
|
}
|
|
@@ -319,6 +480,136 @@ function comparisons(expr) {
|
|
|
319
480
|
if (isQueryLogical(expr)) return expr.operands.flatMap(comparisons);
|
|
320
481
|
return isQueryComparison(expr) ? [expr] : [];
|
|
321
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* VH5 / VH9 (since 0.1.190): a field-to-field comparison is a host reference —
|
|
485
|
+
* a top-level `and` conjunct `targetField = Host.field` naming an existing
|
|
486
|
+
* scalar field of the host of the same design type that is not the bound
|
|
487
|
+
* field. Anything else that compares two fields or names the host is an error.
|
|
488
|
+
*/
|
|
489
|
+
function validateHostRefs(expr, ctx) {
|
|
490
|
+
const errors = [];
|
|
491
|
+
const { host, binding, doc } = ctx;
|
|
492
|
+
const targetName = binding.name;
|
|
493
|
+
const error = (message, range) => errors.push({
|
|
494
|
+
message,
|
|
495
|
+
severity: ERROR,
|
|
496
|
+
range
|
|
497
|
+
});
|
|
498
|
+
const visit = (node, topLevel) => {
|
|
499
|
+
if (isQueryLogical(node)) {
|
|
500
|
+
const chain = topLevel && node.operator === "and";
|
|
501
|
+
for (const operand of node.operands) visit(operand, chain);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
if (!isQueryComparison(node)) return;
|
|
505
|
+
const hostName = typeof host === "object" ? host.name : void 0;
|
|
506
|
+
if (hostName && hostName !== targetName && node.left.typeRef?.text === hostName) error(`the left side names a field of '${targetName}'; a host field belongs on the right ('field = ${hostName}.${node.left.fieldRef.text}')`, node.left.typeRef.range);
|
|
507
|
+
const ref = rightRef(node);
|
|
508
|
+
if (!ref) return;
|
|
509
|
+
if (typeof host !== "object") {
|
|
510
|
+
error(host === void 0 ? "a value-help filter compares target fields with literal values" : `a host reference (a right-hand field reference) needs ${REFUSED[host]}`, ref.fieldRef.range);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const typeName = ref.typeRef?.text;
|
|
514
|
+
if (typeName !== host.name) {
|
|
515
|
+
if (typeName === void 0 || typeName === targetName) error(`a value-help filter compares target fields with literal values, or with a field of the host: '${host.name}.${ref.fieldRef.text}'`, ref.fieldRef.range);
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
if (!topLevel) error("a host reference must be a top-level 'and' conjunct of the filter (not under 'or' / 'not')", ref.fieldRef.range);
|
|
519
|
+
if (node.operator !== "=") error(`a host reference compares with '=' (got '${node.operator}')`, ref.fieldRef.range);
|
|
520
|
+
const name = ref.fieldRef.text;
|
|
521
|
+
const prop = name.includes(".") ? void 0 : host.fields.get(name);
|
|
522
|
+
if (!prop) {
|
|
523
|
+
error(name.includes(".") ? `a host reference names a top-level field of '${host.name}', not a dotted path` : `Field '${name}' does not exist on '${host.name}'`, ref.fieldRef.range);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (name === host.field.id) error("a host reference cannot name the bound field itself", ref.fieldRef.range);
|
|
527
|
+
else if (isNotScalar(prop, doc)) error(`host field '${host.name}.${name}' must be ${SCALAR}`, ref.fieldRef.range);
|
|
528
|
+
else {
|
|
529
|
+
const mismatch = designMismatch(host, name, binding, node.left.fieldRef.text, doc);
|
|
530
|
+
if (mismatch) error(mismatch, ref.fieldRef.range);
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
visit(expr, true);
|
|
534
|
+
return errors;
|
|
535
|
+
}
|
|
536
|
+
function validateFill(token, args, doc) {
|
|
537
|
+
const errors = [];
|
|
538
|
+
const [localArg, targetArg] = args;
|
|
539
|
+
const host = hostOf(token, doc);
|
|
540
|
+
if (typeof host !== "object") {
|
|
541
|
+
if (host) errors.push({
|
|
542
|
+
message: `@ui.valueHelp.fill needs ${REFUSED[host]}`,
|
|
543
|
+
severity: ERROR,
|
|
544
|
+
range: token.range
|
|
545
|
+
});
|
|
546
|
+
return errors;
|
|
547
|
+
}
|
|
548
|
+
const binding = bindingOf(host.field, doc);
|
|
549
|
+
if (!binding) {
|
|
550
|
+
errors.push({
|
|
551
|
+
message: "@ui.valueHelp.fill needs a binding of this field's own (@ui.valueHelp or @db.rel.FK)",
|
|
552
|
+
severity: ERROR,
|
|
553
|
+
range: token.range
|
|
554
|
+
});
|
|
555
|
+
return errors;
|
|
556
|
+
}
|
|
557
|
+
const local = localArg?.text;
|
|
558
|
+
let localOk = false;
|
|
559
|
+
if (localArg && local !== void 0) {
|
|
560
|
+
const prop = local.includes(".") ? void 0 : host.fields.get(local);
|
|
561
|
+
if (!prop || local === host.field.id) errors.push({
|
|
562
|
+
message: local.includes(".") ? `'${local}' must be a top-level field of '${host.name}', not a dotted path` : prop ? "@ui.valueHelp.fill cannot fill the bound field itself" : `Field '${local}' does not exist on '${host.name}'`,
|
|
563
|
+
severity: ERROR,
|
|
564
|
+
range: localArg.range
|
|
565
|
+
});
|
|
566
|
+
else if (isNavProp(prop)) errors.push({
|
|
567
|
+
message: `'${local}' is a navigation field — a pick never writes it`,
|
|
568
|
+
severity: WARNING,
|
|
569
|
+
range: localArg.range
|
|
570
|
+
});
|
|
571
|
+
else if (isNotScalar(prop, doc)) errors.push({
|
|
572
|
+
message: `'${host.name}.${local}' must be ${SCALAR}`,
|
|
573
|
+
severity: ERROR,
|
|
574
|
+
range: localArg.range
|
|
575
|
+
});
|
|
576
|
+
else {
|
|
577
|
+
localOk = true;
|
|
578
|
+
if (effectiveAnnotationNames(prop, doc).has("db.column.derived")) errors.push({
|
|
579
|
+
message: `'${local}' is @db.column.derived — a pick never writes it`,
|
|
580
|
+
severity: WARNING,
|
|
581
|
+
range: localArg.range
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
const name = targetArg?.text;
|
|
586
|
+
if (targetArg && name !== void 0) {
|
|
587
|
+
const problem = targetFieldProblem(binding, name) ?? (localOk && local !== void 0 ? designMismatch(host, local, binding, name, doc) : void 0);
|
|
588
|
+
if (problem) errors.push({
|
|
589
|
+
message: problem,
|
|
590
|
+
severity: ERROR,
|
|
591
|
+
range: targetArg.range
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
return errors;
|
|
595
|
+
}
|
|
596
|
+
function validateColumn(token, args, doc) {
|
|
597
|
+
const field = annotationTarget(token, doc);
|
|
598
|
+
if (!field) return [];
|
|
599
|
+
const binding = bindingOf(field, doc);
|
|
600
|
+
if (!binding) return [{
|
|
601
|
+
message: "@ui.valueHelp.column needs a binding of this field's own (@ui.valueHelp or @db.rel.FK)",
|
|
602
|
+
severity: ERROR,
|
|
603
|
+
range: token.range
|
|
604
|
+
}];
|
|
605
|
+
const name = args[0]?.text;
|
|
606
|
+
const problem = name === void 0 ? void 0 : targetFieldProblem(binding, name);
|
|
607
|
+
return problem ? [{
|
|
608
|
+
message: problem,
|
|
609
|
+
severity: ERROR,
|
|
610
|
+
range: args[0].range
|
|
611
|
+
}] : [];
|
|
612
|
+
}
|
|
322
613
|
function validateDistinct(token, _args, doc) {
|
|
323
614
|
const errors = [];
|
|
324
615
|
const host = token.parentNode;
|
|
@@ -406,6 +697,44 @@ function validateLiteralLabel(token, args, doc) {
|
|
|
406
697
|
return errors;
|
|
407
698
|
}
|
|
408
699
|
/**
|
|
700
|
+
* `valueScope` of `@ui.valueLabel`'s `field`: the string-valued fields of the
|
|
701
|
+
* type the annotated field belongs to, declared or inherited
|
|
702
|
+
* (`siblingStringFields`: never the field itself, an object, a number or a
|
|
703
|
+
* dotted path) — for an `annotate` entry, of the annotated interface.
|
|
704
|
+
* Go-to-definition jumps to the field in the file that declares it.
|
|
705
|
+
*/
|
|
706
|
+
function valueLabelFields(annotationToken, doc) {
|
|
707
|
+
return siblingStringFields(annotationToken, doc).map((prop) => {
|
|
708
|
+
const token = prop.token("identifier");
|
|
709
|
+
return Object.assign({ value: prop.id ?? `` }, token && { definition: {
|
|
710
|
+
doc: doc.declaringDoc(prop, doc),
|
|
711
|
+
token
|
|
712
|
+
} });
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
function validateValueLabel(token, args, doc) {
|
|
716
|
+
const errors = [];
|
|
717
|
+
const field = annotationTarget(token, doc);
|
|
718
|
+
const name = args[0]?.text;
|
|
719
|
+
if (name !== void 0) if (field?.id !== void 0 && name === field.id) errors.push({
|
|
720
|
+
message: "@ui.valueLabel names the field holding this value's text, not this field",
|
|
721
|
+
severity: ERROR,
|
|
722
|
+
range: args[0].range
|
|
723
|
+
});
|
|
724
|
+
else errors.push(...validateSiblingStringField(token, args, doc, "@ui.valueLabel"));
|
|
725
|
+
errors.push(...validateExclusiveWith(token, "@ui.valueLabel", [{ key: "ui.literalLabel" }], doc));
|
|
726
|
+
if (field && name !== void 0 && name !== field.id) {
|
|
727
|
+
const binding = bindingOf(field, doc);
|
|
728
|
+
const filled = (field.annotations ?? []).some((a) => a.name === "ui.valueHelp.fill" && a.args[0]?.text === name);
|
|
729
|
+
if (binding && !filled) errors.push({
|
|
730
|
+
message: `a pick of this field's value help does not fill '${name}' — the text goes stale after a pick (add @ui.valueHelp.fill '${name}', '<a field of ${binding.name}>')`,
|
|
731
|
+
severity: WARNING,
|
|
732
|
+
range: token.range
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
return errors;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
409
738
|
* `@ui.form.type` / `@ui.type`: the free-entry `tags` renderer edits an array —
|
|
410
739
|
* on any other field it would mount with a scalar value.
|
|
411
740
|
*/
|
|
@@ -420,4 +749,4 @@ function validateFormType(token, args, doc) {
|
|
|
420
749
|
}];
|
|
421
750
|
}
|
|
422
751
|
//#endregion
|
|
423
|
-
export { isValueHelpTarget, literalLabelValues, validateDistinct, validateFormType, validateLiteralLabel, validateValueHelp, valueHelpScopes };
|
|
752
|
+
export { isValueHelpTarget, literalLabelValues, validateColumn, validateDistinct, validateFill, validateFormType, validateLiteralLabel, validateValueHelp, validateValueLabel, valueHelpScopes, valueLabelFields };
|
|
@@ -43,7 +43,13 @@ const UI_DICT_SORTABLE = "ui.dict.sortable";
|
|
|
43
43
|
const UI_DICT_SEARCHABLE = "ui.dict.searchable";
|
|
44
44
|
const UI_VALUE_HELP = "ui.valueHelp";
|
|
45
45
|
const UI_VALUE_HELP_DISTINCT = "ui.valueHelp.distinct";
|
|
46
|
+
/** `@ui.valueHelp.fill 'local', 'targetField'` — since 0.1.190. */
|
|
47
|
+
const UI_VALUE_HELP_FILL = "ui.valueHelp.fill";
|
|
48
|
+
/** `@ui.valueHelp.column 'field'` — since 0.1.190. */
|
|
49
|
+
const UI_VALUE_HELP_COLUMN = "ui.valueHelp.column";
|
|
46
50
|
const UI_LITERAL_LABEL = "ui.literalLabel";
|
|
51
|
+
/** `@ui.valueLabel 'field', 'arrangement'?` — a code shown with its text; since 0.1.190. */
|
|
52
|
+
const UI_VALUE_LABEL = "ui.valueLabel";
|
|
47
53
|
const UI_NAV_GROUP = "ui.nav.group";
|
|
48
54
|
const UI_NAV_ORDER = "ui.nav.order";
|
|
49
55
|
const UI_NAV_HIDDEN = "ui.nav.hidden";
|
|
@@ -60,6 +66,7 @@ const DB_UNIT = "db.unit";
|
|
|
60
66
|
const DB_UNIT_REF = "db.unit.ref";
|
|
61
67
|
const DB_COLUMN_PRECISION = "db.column.precision";
|
|
62
68
|
const DB_COLUMN_VERSION = "db.column.version";
|
|
69
|
+
const DB_COLUMN_VERSION_TOKEN = "db.column.version.token";
|
|
63
70
|
const DB_COLUMN_DERIVED = "db.column.derived";
|
|
64
71
|
const WF_ACTION_WITH_DATA = "wf.action.withData";
|
|
65
72
|
const META_LABEL = "meta.label";
|
|
@@ -99,6 +106,7 @@ exports.DB_AMOUNT_CURRENCY_REF = DB_AMOUNT_CURRENCY_REF;
|
|
|
99
106
|
exports.DB_COLUMN_DERIVED = DB_COLUMN_DERIVED;
|
|
100
107
|
exports.DB_COLUMN_PRECISION = DB_COLUMN_PRECISION;
|
|
101
108
|
exports.DB_COLUMN_VERSION = DB_COLUMN_VERSION;
|
|
109
|
+
exports.DB_COLUMN_VERSION_TOKEN = DB_COLUMN_VERSION_TOKEN;
|
|
102
110
|
exports.DB_ENCRYPTED = DB_ENCRYPTED;
|
|
103
111
|
exports.DB_HTTP_PATH = DB_HTTP_PATH;
|
|
104
112
|
exports.DB_JSON = DB_JSON;
|
|
@@ -185,5 +193,8 @@ exports.UI_TABLE_TYPE = UI_TABLE_TYPE;
|
|
|
185
193
|
exports.UI_TABLE_WIDTH = UI_TABLE_WIDTH;
|
|
186
194
|
exports.UI_TYPE = UI_TYPE;
|
|
187
195
|
exports.UI_VALUE_HELP = UI_VALUE_HELP;
|
|
196
|
+
exports.UI_VALUE_HELP_COLUMN = UI_VALUE_HELP_COLUMN;
|
|
188
197
|
exports.UI_VALUE_HELP_DISTINCT = UI_VALUE_HELP_DISTINCT;
|
|
198
|
+
exports.UI_VALUE_HELP_FILL = UI_VALUE_HELP_FILL;
|
|
199
|
+
exports.UI_VALUE_LABEL = UI_VALUE_LABEL;
|
|
189
200
|
exports.WF_ACTION_WITH_DATA = WF_ACTION_WITH_DATA;
|
|
@@ -38,6 +38,8 @@ declare const UI_DICT_ATTR: "ui.dict.attr";
|
|
|
38
38
|
declare const UI_DICT_FILTERABLE: "ui.dict.filterable";
|
|
39
39
|
declare const UI_DICT_SORTABLE: "ui.dict.sortable";
|
|
40
40
|
declare const UI_DICT_SEARCHABLE: "ui.dict.searchable";
|
|
41
|
+
/** `@ui.valueLabel 'field', 'arrangement'?` — a code shown with its text; since 0.1.190. */
|
|
42
|
+
declare const UI_VALUE_LABEL: "ui.valueLabel";
|
|
41
43
|
declare const UI_NAV_GROUP: "ui.nav.group";
|
|
42
44
|
declare const UI_NAV_ORDER: "ui.nav.order";
|
|
43
45
|
declare const UI_NAV_HIDDEN: "ui.nav.hidden";
|
|
@@ -79,4 +81,4 @@ declare const UI_TABLE_FN_CLASSES: "ui.table.fn.classes";
|
|
|
79
81
|
declare const UI_TABLE_FN_STYLES: "ui.table.fn.styles";
|
|
80
82
|
declare const UI_FORM_VALIDATE: "ui.form.validate";
|
|
81
83
|
//#endregion
|
|
82
|
-
export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, WF_ACTION_WITH_DATA };
|
|
84
|
+
export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, UI_VALUE_LABEL, WF_ACTION_WITH_DATA };
|
|
@@ -38,6 +38,8 @@ declare const UI_DICT_ATTR: "ui.dict.attr";
|
|
|
38
38
|
declare const UI_DICT_FILTERABLE: "ui.dict.filterable";
|
|
39
39
|
declare const UI_DICT_SORTABLE: "ui.dict.sortable";
|
|
40
40
|
declare const UI_DICT_SEARCHABLE: "ui.dict.searchable";
|
|
41
|
+
/** `@ui.valueLabel 'field', 'arrangement'?` — a code shown with its text; since 0.1.190. */
|
|
42
|
+
declare const UI_VALUE_LABEL: "ui.valueLabel";
|
|
41
43
|
declare const UI_NAV_GROUP: "ui.nav.group";
|
|
42
44
|
declare const UI_NAV_ORDER: "ui.nav.order";
|
|
43
45
|
declare const UI_NAV_HIDDEN: "ui.nav.hidden";
|
|
@@ -79,4 +81,4 @@ declare const UI_TABLE_FN_CLASSES: "ui.table.fn.classes";
|
|
|
79
81
|
declare const UI_TABLE_FN_STYLES: "ui.table.fn.styles";
|
|
80
82
|
declare const UI_FORM_VALIDATE: "ui.form.validate";
|
|
81
83
|
//#endregion
|
|
82
|
-
export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, WF_ACTION_WITH_DATA };
|
|
84
|
+
export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, UI_VALUE_LABEL, WF_ACTION_WITH_DATA };
|
|
@@ -43,7 +43,13 @@ const UI_DICT_SORTABLE = "ui.dict.sortable";
|
|
|
43
43
|
const UI_DICT_SEARCHABLE = "ui.dict.searchable";
|
|
44
44
|
const UI_VALUE_HELP = "ui.valueHelp";
|
|
45
45
|
const UI_VALUE_HELP_DISTINCT = "ui.valueHelp.distinct";
|
|
46
|
+
/** `@ui.valueHelp.fill 'local', 'targetField'` — since 0.1.190. */
|
|
47
|
+
const UI_VALUE_HELP_FILL = "ui.valueHelp.fill";
|
|
48
|
+
/** `@ui.valueHelp.column 'field'` — since 0.1.190. */
|
|
49
|
+
const UI_VALUE_HELP_COLUMN = "ui.valueHelp.column";
|
|
46
50
|
const UI_LITERAL_LABEL = "ui.literalLabel";
|
|
51
|
+
/** `@ui.valueLabel 'field', 'arrangement'?` — a code shown with its text; since 0.1.190. */
|
|
52
|
+
const UI_VALUE_LABEL = "ui.valueLabel";
|
|
47
53
|
const UI_NAV_GROUP = "ui.nav.group";
|
|
48
54
|
const UI_NAV_ORDER = "ui.nav.order";
|
|
49
55
|
const UI_NAV_HIDDEN = "ui.nav.hidden";
|
|
@@ -60,6 +66,7 @@ const DB_UNIT = "db.unit";
|
|
|
60
66
|
const DB_UNIT_REF = "db.unit.ref";
|
|
61
67
|
const DB_COLUMN_PRECISION = "db.column.precision";
|
|
62
68
|
const DB_COLUMN_VERSION = "db.column.version";
|
|
69
|
+
const DB_COLUMN_VERSION_TOKEN = "db.column.version.token";
|
|
63
70
|
const DB_COLUMN_DERIVED = "db.column.derived";
|
|
64
71
|
const WF_ACTION_WITH_DATA = "wf.action.withData";
|
|
65
72
|
const META_LABEL = "meta.label";
|
|
@@ -94,4 +101,4 @@ const UI_TABLE_FN_CLASSES = "ui.table.fn.classes";
|
|
|
94
101
|
const UI_TABLE_FN_STYLES = "ui.table.fn.styles";
|
|
95
102
|
const UI_FORM_VALIDATE = "ui.form.validate";
|
|
96
103
|
//#endregion
|
|
97
|
-
export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_DERIVED, DB_COLUMN_PRECISION, DB_COLUMN_VERSION, DB_ENCRYPTED, DB_HTTP_PATH, DB_JSON, DB_REL_FK, DB_TABLE, DB_UNIT, DB_UNIT_REF, DB_VIEW, DB_VIEW_FOR, EXPECT_ARRAY_KEY, EXPECT_ARRAY_UNIQUE_ITEMS, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_NS, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_PUSH_DOWN, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_LITERAL_LABEL, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, UI_VALUE_HELP, UI_VALUE_HELP_DISTINCT, WF_ACTION_WITH_DATA };
|
|
104
|
+
export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_DERIVED, DB_COLUMN_PRECISION, DB_COLUMN_VERSION, DB_COLUMN_VERSION_TOKEN, DB_ENCRYPTED, DB_HTTP_PATH, DB_JSON, DB_REL_FK, DB_TABLE, DB_UNIT, DB_UNIT_REF, DB_VIEW, DB_VIEW_FOR, EXPECT_ARRAY_KEY, EXPECT_ARRAY_UNIQUE_ITEMS, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_NS, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_PUSH_DOWN, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_LITERAL_LABEL, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, UI_VALUE_HELP, UI_VALUE_HELP_COLUMN, UI_VALUE_HELP_DISTINCT, UI_VALUE_HELP_FILL, UI_VALUE_LABEL, WF_ACTION_WITH_DATA };
|
|
@@ -3,7 +3,7 @@ import { MetaResponse, TableDef } from "../table/types.cjs";
|
|
|
3
3
|
import { UiTexts } from "../i18n/ui-texts.cjs";
|
|
4
4
|
import { ResolvedValueHelp } from "../value-help/resolve.cjs";
|
|
5
5
|
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
6
|
-
import {
|
|
6
|
+
import { ClientLike } from "@atscript/db-client";
|
|
7
7
|
|
|
8
8
|
//#region src/shared/meta-cache.d.ts
|
|
9
9
|
/**
|
|
@@ -34,7 +34,7 @@ import { Client } from "@atscript/db-client";
|
|
|
34
34
|
* uncached entry whose client keeps no `/meta` store.
|
|
35
35
|
*/
|
|
36
36
|
interface MetaCacheEntry {
|
|
37
|
-
client:
|
|
37
|
+
client: ClientLike;
|
|
38
38
|
meta: Promise<MetaResponse>;
|
|
39
39
|
type: Promise<TAtscriptAnnotatedType>;
|
|
40
40
|
resolved?: Promise<ResolvedValueHelp>;
|
|
@@ -66,7 +66,7 @@ interface MetaEntryOptions {
|
|
|
66
66
|
*
|
|
67
67
|
* @internal Shared with `@atscript/vue-table`.
|
|
68
68
|
*/
|
|
69
|
-
declare function createMetaClient(url: string, factory: ClientFactory | undefined, locale: string | undefined, metaKey?: string):
|
|
69
|
+
declare function createMetaClient(url: string, factory: ClientFactory | undefined, locale: string | undefined, metaKey?: string): ClientLike;
|
|
70
70
|
/**
|
|
71
71
|
* Get or create the cache entry for `url` in the UI locale of
|
|
72
72
|
* `options.texts`. First caller's `factory` (and `options.metaKey`) seeds the
|
|
@@ -3,7 +3,7 @@ import { MetaResponse, TableDef } from "../table/types.mjs";
|
|
|
3
3
|
import { UiTexts } from "../i18n/ui-texts.mjs";
|
|
4
4
|
import { ResolvedValueHelp } from "../value-help/resolve.mjs";
|
|
5
5
|
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
6
|
-
import {
|
|
6
|
+
import { ClientLike } from "@atscript/db-client";
|
|
7
7
|
|
|
8
8
|
//#region src/shared/meta-cache.d.ts
|
|
9
9
|
/**
|
|
@@ -34,7 +34,7 @@ import { Client } from "@atscript/db-client";
|
|
|
34
34
|
* uncached entry whose client keeps no `/meta` store.
|
|
35
35
|
*/
|
|
36
36
|
interface MetaCacheEntry {
|
|
37
|
-
client:
|
|
37
|
+
client: ClientLike;
|
|
38
38
|
meta: Promise<MetaResponse>;
|
|
39
39
|
type: Promise<TAtscriptAnnotatedType>;
|
|
40
40
|
resolved?: Promise<ResolvedValueHelp>;
|
|
@@ -66,7 +66,7 @@ interface MetaEntryOptions {
|
|
|
66
66
|
*
|
|
67
67
|
* @internal Shared with `@atscript/vue-table`.
|
|
68
68
|
*/
|
|
69
|
-
declare function createMetaClient(url: string, factory: ClientFactory | undefined, locale: string | undefined, metaKey?: string):
|
|
69
|
+
declare function createMetaClient(url: string, factory: ClientFactory | undefined, locale: string | undefined, metaKey?: string): ClientLike;
|
|
70
70
|
/**
|
|
71
71
|
* Get or create the cache entry for `url` in the UI locale of
|
|
72
72
|
* `options.texts`. First caller's `factory` (and `options.metaKey`) seeds the
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const require_annotation_keys = require("./annotation-keys.cjs");
|
|
2
|
+
const require_field_resolver = require("./field-resolver.cjs");
|
|
3
|
+
//#region src/shared/value-label.ts
|
|
4
|
+
/** The field's `@ui.valueLabel`, the arrangement defaulted to `textKey`; `undefined` without one. */
|
|
5
|
+
function valueLabelOf(prop) {
|
|
6
|
+
const meta = require_field_resolver.getFieldMeta(prop, require_annotation_keys.UI_VALUE_LABEL);
|
|
7
|
+
if (!meta?.field) return void 0;
|
|
8
|
+
return {
|
|
9
|
+
field: meta.field,
|
|
10
|
+
arrangement: meta.arrangement ?? "textKey"
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The one rendering of a code with its text (`@ui.valueLabel`, since 0.1.190):
|
|
15
|
+
* `textKey` (default) `text (key)`, `keyText` `key (text)`, `text` the text
|
|
16
|
+
* alone. An empty text (`undefined`, `null`, `""`, or no scalar) yields the
|
|
17
|
+
* key; an empty key yields `""` — a text without a code labels nothing.
|
|
18
|
+
*/
|
|
19
|
+
function arrangeText(key, text, arrangement = "textKey") {
|
|
20
|
+
if (key === "") return "";
|
|
21
|
+
const label = typeof text === "string" ? text : typeof text === "number" ? String(text) : void 0;
|
|
22
|
+
if (!label) return key;
|
|
23
|
+
if (arrangement === "text") return label;
|
|
24
|
+
return arrangement === "keyText" ? `${key} (${label})` : `${label} (${key})`;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.arrangeText = arrangeText;
|
|
28
|
+
exports.valueLabelOf = valueLabelOf;
|