@atscript/ui 0.1.203 → 0.1.205
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/form/create-form-def.cjs +52 -21
- package/dist/form/create-form-def.d.cts +23 -18
- package/dist/form/create-form-def.d.mts +23 -18
- package/dist/form/create-form-def.mjs +52 -21
- package/dist/form/decimal-format.cjs +9 -11
- package/dist/form/decimal-format.mjs +9 -11
- package/dist/form/diff.cjs +32 -14
- package/dist/form/diff.d.cts +7 -4
- package/dist/form/diff.d.mts +7 -4
- package/dist/form/diff.mjs +32 -14
- package/dist/form/loaded-empty.cjs +56 -0
- package/dist/form/loaded-empty.d.cts +25 -0
- package/dist/form/loaded-empty.d.mts +25 -0
- package/dist/form/loaded-empty.mjs +56 -0
- package/dist/form/omit-derived.cjs +38 -0
- package/dist/form/omit-derived.d.cts +17 -0
- package/dist/form/omit-derived.d.mts +17 -0
- package/dist/form/omit-derived.mjs +38 -0
- package/dist/form/optional-mode.cjs +85 -0
- package/dist/form/optional-mode.d.cts +58 -0
- package/dist/form/optional-mode.d.mts +58 -0
- package/dist/form/optional-mode.mjs +82 -0
- package/dist/form/path-utils.cjs +4 -5
- package/dist/form/path-utils.mjs +4 -5
- package/dist/form/types.d.cts +15 -14
- package/dist/form/types.d.mts +15 -14
- package/dist/form/validate.cjs +2 -2
- package/dist/form/validate.mjs +2 -2
- package/dist/index.cjs +23 -4
- package/dist/index.d.cts +7 -3
- package/dist/index.d.mts +7 -3
- package/dist/index.mjs +10 -6
- package/dist/plugin/annotations.cjs +12 -0
- package/dist/plugin/annotations.mjs +13 -1
- package/dist/plugin/value-help-validation.cjs +25 -1
- package/dist/plugin/value-help-validation.mjs +25 -2
- package/dist/shared/annotation-keys.cjs +3 -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 +3 -1
- package/dist/shared/exact-number.cjs +12 -0
- package/dist/shared/exact-number.mjs +12 -0
- package/dist/shared/meta-cache.cjs +1 -1
- package/dist/shared/meta-cache.mjs +1 -1
- package/dist/table/create-table-def.cjs +4 -1
- package/dist/table/create-table-def.mjs +4 -2
- package/dist/table/types.d.cts +23 -16
- package/dist/table/types.d.mts +23 -16
- package/dist/table/value-kind.cjs +37 -2
- package/dist/table/value-kind.d.cts +22 -2
- package/dist/table/value-kind.d.mts +22 -2
- package/dist/table/value-kind.mjs +36 -3
- package/dist/value-help/distinct-client.cjs +5 -4
- package/dist/value-help/distinct-client.d.cts +8 -2
- package/dist/value-help/distinct-client.d.mts +8 -2
- package/dist/value-help/distinct-client.mjs +5 -4
- package/dist/value-help/value-help-client.cjs +45 -9
- package/dist/value-help/value-help-client.mjs +45 -9
- package/package.json +11 -12
|
@@ -91,7 +91,7 @@ function leafDesign(def) {
|
|
|
91
91
|
switch (def.entity) {
|
|
92
92
|
case "primitive": {
|
|
93
93
|
const base = (0, _atscript_db_shared.primitiveBaseType)(def);
|
|
94
|
-
if (base === "string" || base === "number" || base === "decimal" || base === "boolean") return base;
|
|
94
|
+
if (base === "string" || base === "number" || base === "decimal" || base === "long" || base === "boolean") return base;
|
|
95
95
|
if (base === "object") return "object";
|
|
96
96
|
if (base === "array" || base === "tuple") return "array";
|
|
97
97
|
return base ? "other" : void 0;
|
|
@@ -743,6 +743,29 @@ function validateValueLabel(token, args, doc) {
|
|
|
743
743
|
return errors;
|
|
744
744
|
}
|
|
745
745
|
/**
|
|
746
|
+
* `@ui.form.optionalMode`: a mode of an optional scalar field. An optional
|
|
747
|
+
* object, array, tuple or union (`T | null` included) always keeps its Add /
|
|
748
|
+
* remove controls, so the annotation would do nothing there. Since 0.1.205.
|
|
749
|
+
*/
|
|
750
|
+
function validateOptionalMode(token, args, doc) {
|
|
751
|
+
const field = (0, _atscript_db_shared.annotationTarget)(token, doc);
|
|
752
|
+
if (field && (0, _atscript_core.isProp)(field) && !field.has("optional")) return [{
|
|
753
|
+
message: "@ui.form.optionalMode applies to an optional field (name?: T)",
|
|
754
|
+
severity: ERROR,
|
|
755
|
+
range: token.range
|
|
756
|
+
}];
|
|
757
|
+
const leaves = hostLeaves(token.parentNode, doc);
|
|
758
|
+
if (leaves.includes(null)) return [];
|
|
759
|
+
const design = hostDesign(token, doc);
|
|
760
|
+
const union = leaves.length > 1 && !leaves.every((leaf) => leaf.def.entity === "const");
|
|
761
|
+
if (design !== "object" && design !== "array" && !union) return [];
|
|
762
|
+
return [{
|
|
763
|
+
message: "@ui.form.optionalMode applies to a scalar field — optional objects, arrays, tuples and unions keep their Add / remove controls",
|
|
764
|
+
severity: ERROR,
|
|
765
|
+
range: args[0]?.range ?? token.range
|
|
766
|
+
}];
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
746
769
|
* `@ui.form.type` / `@ui.type`: the free-entry `tags` renderer edits an array —
|
|
747
770
|
* on any other field it would mount with a scalar value.
|
|
748
771
|
*/
|
|
@@ -764,6 +787,7 @@ exports.validateDistinct = validateDistinct;
|
|
|
764
787
|
exports.validateFill = validateFill;
|
|
765
788
|
exports.validateFormType = validateFormType;
|
|
766
789
|
exports.validateLiteralLabel = validateLiteralLabel;
|
|
790
|
+
exports.validateOptionalMode = validateOptionalMode;
|
|
767
791
|
exports.validateValueHelp = validateValueHelp;
|
|
768
792
|
exports.validateValueLabel = validateValueLabel;
|
|
769
793
|
exports.valueHelpScopes = valueHelpScopes;
|
|
@@ -91,7 +91,7 @@ function leafDesign(def) {
|
|
|
91
91
|
switch (def.entity) {
|
|
92
92
|
case "primitive": {
|
|
93
93
|
const base = primitiveBaseType(def);
|
|
94
|
-
if (base === "string" || base === "number" || base === "decimal" || base === "boolean") return base;
|
|
94
|
+
if (base === "string" || base === "number" || base === "decimal" || base === "long" || base === "boolean") return base;
|
|
95
95
|
if (base === "object") return "object";
|
|
96
96
|
if (base === "array" || base === "tuple") return "array";
|
|
97
97
|
return base ? "other" : void 0;
|
|
@@ -743,6 +743,29 @@ function validateValueLabel(token, args, doc) {
|
|
|
743
743
|
return errors;
|
|
744
744
|
}
|
|
745
745
|
/**
|
|
746
|
+
* `@ui.form.optionalMode`: a mode of an optional scalar field. An optional
|
|
747
|
+
* object, array, tuple or union (`T | null` included) always keeps its Add /
|
|
748
|
+
* remove controls, so the annotation would do nothing there. Since 0.1.205.
|
|
749
|
+
*/
|
|
750
|
+
function validateOptionalMode(token, args, doc) {
|
|
751
|
+
const field = annotationTarget(token, doc);
|
|
752
|
+
if (field && isProp(field) && !field.has("optional")) return [{
|
|
753
|
+
message: "@ui.form.optionalMode applies to an optional field (name?: T)",
|
|
754
|
+
severity: ERROR,
|
|
755
|
+
range: token.range
|
|
756
|
+
}];
|
|
757
|
+
const leaves = hostLeaves(token.parentNode, doc);
|
|
758
|
+
if (leaves.includes(null)) return [];
|
|
759
|
+
const design = hostDesign(token, doc);
|
|
760
|
+
const union = leaves.length > 1 && !leaves.every((leaf) => leaf.def.entity === "const");
|
|
761
|
+
if (design !== "object" && design !== "array" && !union) return [];
|
|
762
|
+
return [{
|
|
763
|
+
message: "@ui.form.optionalMode applies to a scalar field — optional objects, arrays, tuples and unions keep their Add / remove controls",
|
|
764
|
+
severity: ERROR,
|
|
765
|
+
range: args[0]?.range ?? token.range
|
|
766
|
+
}];
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
746
769
|
* `@ui.form.type` / `@ui.type`: the free-entry `tags` renderer edits an array —
|
|
747
770
|
* on any other field it would mount with a scalar value.
|
|
748
771
|
*/
|
|
@@ -757,4 +780,4 @@ function validateFormType(token, args, doc) {
|
|
|
757
780
|
}];
|
|
758
781
|
}
|
|
759
782
|
//#endregion
|
|
760
|
-
export { isValueHelpTarget, literalLabelValues, validateColumn, validateDistinct, validateFill, validateFormType, validateLiteralLabel, validateValueHelp, validateValueLabel, valueHelpScopes, valueLabelFields };
|
|
783
|
+
export { isValueHelpTarget, literalLabelValues, validateColumn, validateDistinct, validateFill, validateFormType, validateLiteralLabel, validateOptionalMode, validateValueHelp, validateValueLabel, valueHelpScopes, valueLabelFields };
|
|
@@ -26,6 +26,8 @@ const UI_FORM_PREFIX_ICON = "ui.form.prefix.icon";
|
|
|
26
26
|
const UI_FORM_SUFFIX = "ui.form.suffix";
|
|
27
27
|
const UI_FORM_SUFFIX_REF = "ui.form.suffix.ref";
|
|
28
28
|
const UI_FORM_SUFFIX_ICON = "ui.form.suffix.icon";
|
|
29
|
+
/** `@ui.form.optionalMode 'business' | 'technical'` — since 0.1.205. */
|
|
30
|
+
const UI_FORM_OPTIONAL_MODE = "ui.form.optionalMode";
|
|
29
31
|
const UI_TABLE_WIDTH = "ui.table.width";
|
|
30
32
|
/** `@ui.table.fill` — the column takes a wide table's spare width; since 0.1.201. */
|
|
31
33
|
const UI_TABLE_FILL = "ui.table.fill";
|
|
@@ -168,6 +170,7 @@ exports.UI_FORM_HIDDEN = UI_FORM_HIDDEN;
|
|
|
168
170
|
exports.UI_FORM_HINT = UI_FORM_HINT;
|
|
169
171
|
exports.UI_FORM_LABEL_SINGULAR = UI_FORM_LABEL_SINGULAR;
|
|
170
172
|
exports.UI_FORM_NS = UI_FORM_NS;
|
|
173
|
+
exports.UI_FORM_OPTIONAL_MODE = UI_FORM_OPTIONAL_MODE;
|
|
171
174
|
exports.UI_FORM_OPTIONS = UI_FORM_OPTIONS;
|
|
172
175
|
exports.UI_FORM_ORDER = UI_FORM_ORDER;
|
|
173
176
|
exports.UI_FORM_PLACEHOLDER = UI_FORM_PLACEHOLDER;
|
|
@@ -23,6 +23,8 @@ declare const UI_FORM_PREFIX_ICON: "ui.form.prefix.icon";
|
|
|
23
23
|
declare const UI_FORM_SUFFIX: "ui.form.suffix";
|
|
24
24
|
declare const UI_FORM_SUFFIX_REF: "ui.form.suffix.ref";
|
|
25
25
|
declare const UI_FORM_SUFFIX_ICON: "ui.form.suffix.icon";
|
|
26
|
+
/** `@ui.form.optionalMode 'business' | 'technical'` — since 0.1.205. */
|
|
27
|
+
declare const UI_FORM_OPTIONAL_MODE: "ui.form.optionalMode";
|
|
26
28
|
declare const UI_TABLE_WIDTH: "ui.table.width";
|
|
27
29
|
/** `@ui.table.fill` — the column takes a wide table's spare width; since 0.1.201. */
|
|
28
30
|
declare const UI_TABLE_FILL: "ui.table.fill";
|
|
@@ -83,4 +85,4 @@ declare const UI_TABLE_FN_CLASSES: "ui.table.fn.classes";
|
|
|
83
85
|
declare const UI_TABLE_FN_STYLES: "ui.table.fn.styles";
|
|
84
86
|
declare const UI_FORM_VALIDATE: "ui.form.validate";
|
|
85
87
|
//#endregion
|
|
86
|
-
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_FILL, 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 };
|
|
88
|
+
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_OPTIONAL_MODE, 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_FILL, 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 };
|
|
@@ -23,6 +23,8 @@ declare const UI_FORM_PREFIX_ICON: "ui.form.prefix.icon";
|
|
|
23
23
|
declare const UI_FORM_SUFFIX: "ui.form.suffix";
|
|
24
24
|
declare const UI_FORM_SUFFIX_REF: "ui.form.suffix.ref";
|
|
25
25
|
declare const UI_FORM_SUFFIX_ICON: "ui.form.suffix.icon";
|
|
26
|
+
/** `@ui.form.optionalMode 'business' | 'technical'` — since 0.1.205. */
|
|
27
|
+
declare const UI_FORM_OPTIONAL_MODE: "ui.form.optionalMode";
|
|
26
28
|
declare const UI_TABLE_WIDTH: "ui.table.width";
|
|
27
29
|
/** `@ui.table.fill` — the column takes a wide table's spare width; since 0.1.201. */
|
|
28
30
|
declare const UI_TABLE_FILL: "ui.table.fill";
|
|
@@ -83,4 +85,4 @@ declare const UI_TABLE_FN_CLASSES: "ui.table.fn.classes";
|
|
|
83
85
|
declare const UI_TABLE_FN_STYLES: "ui.table.fn.styles";
|
|
84
86
|
declare const UI_FORM_VALIDATE: "ui.form.validate";
|
|
85
87
|
//#endregion
|
|
86
|
-
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_FILL, 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 };
|
|
88
|
+
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_OPTIONAL_MODE, 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_FILL, 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 };
|
|
@@ -26,6 +26,8 @@ const UI_FORM_PREFIX_ICON = "ui.form.prefix.icon";
|
|
|
26
26
|
const UI_FORM_SUFFIX = "ui.form.suffix";
|
|
27
27
|
const UI_FORM_SUFFIX_REF = "ui.form.suffix.ref";
|
|
28
28
|
const UI_FORM_SUFFIX_ICON = "ui.form.suffix.icon";
|
|
29
|
+
/** `@ui.form.optionalMode 'business' | 'technical'` — since 0.1.205. */
|
|
30
|
+
const UI_FORM_OPTIONAL_MODE = "ui.form.optionalMode";
|
|
29
31
|
const UI_TABLE_WIDTH = "ui.table.width";
|
|
30
32
|
/** `@ui.table.fill` — the column takes a wide table's spare width; since 0.1.201. */
|
|
31
33
|
const UI_TABLE_FILL = "ui.table.fill";
|
|
@@ -106,4 +108,4 @@ const UI_TABLE_FN_CLASSES = "ui.table.fn.classes";
|
|
|
106
108
|
const UI_TABLE_FN_STYLES = "ui.table.fn.styles";
|
|
107
109
|
const UI_FORM_VALIDATE = "ui.form.validate";
|
|
108
110
|
//#endregion
|
|
109
|
-
export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_DERIVED, DB_COLUMN_PRECISION, DB_COLUMN_VERSION, DB_COLUMN_VERSION_TOKEN, DB_COMPUTE, DB_COMPUTE_HOST, 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, EXPECT_MESSAGE, 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_FILL, 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 };
|
|
111
|
+
export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_DERIVED, DB_COLUMN_PRECISION, DB_COLUMN_VERSION, DB_COLUMN_VERSION_TOKEN, DB_COMPUTE, DB_COMPUTE_HOST, 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, EXPECT_MESSAGE, 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_OPTIONAL_MODE, 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_FILL, 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 };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/shared/exact-number.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether `prop` holds an exact number as text — a `decimal`, or a `long`
|
|
4
|
+
* (64-bit integer; since 0.1.205): its value is a numeric string end to end,
|
|
5
|
+
* never a JS number, which would round it.
|
|
6
|
+
*/
|
|
7
|
+
function isExactNumberText(prop) {
|
|
8
|
+
const t = prop?.type;
|
|
9
|
+
return t?.kind === "" && (t.designType === "decimal" || t.designType === "long");
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.isExactNumberText = isExactNumberText;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/shared/exact-number.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether `prop` holds an exact number as text — a `decimal`, or a `long`
|
|
4
|
+
* (64-bit integer; since 0.1.205): its value is a numeric string end to end,
|
|
5
|
+
* never a JS number, which would round it.
|
|
6
|
+
*/
|
|
7
|
+
function isExactNumberText(prop) {
|
|
8
|
+
const t = prop?.type;
|
|
9
|
+
return t?.kind === "" && (t.designType === "decimal" || t.designType === "long");
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isExactNumberText };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_model_texts = require("../i18n/model-texts.cjs");
|
|
2
2
|
const require_ui_texts = require("../i18n/ui-texts.cjs");
|
|
3
|
+
const require_create_table_def = require("../table/create-table-def.cjs");
|
|
3
4
|
const require_value_help_client = require("../value-help/value-help-client.cjs");
|
|
4
5
|
const require_client_factory = require("../client-factory.cjs");
|
|
5
|
-
const require_create_table_def = require("../table/create-table-def.cjs");
|
|
6
6
|
let _atscript_db_client = require("@atscript/db-client");
|
|
7
7
|
//#region src/shared/meta-cache.ts
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { deserializeServedType } from "../i18n/model-texts.mjs";
|
|
2
2
|
import { getUiTexts } from "../i18n/ui-texts.mjs";
|
|
3
|
+
import { createTableDef } from "../table/create-table-def.mjs";
|
|
3
4
|
import { invalidateValueHelpCache } from "../value-help/value-help-client.mjs";
|
|
4
5
|
import { getDefaultClientFactory } from "../client-factory.mjs";
|
|
5
|
-
import { createTableDef } from "../table/create-table-def.mjs";
|
|
6
6
|
import { clearMetaStore, defaultMetaStore } from "@atscript/db-client";
|
|
7
7
|
//#region src/shared/meta-cache.ts
|
|
8
8
|
/**
|
|
@@ -3,6 +3,7 @@ const require_model_texts = require("../i18n/model-texts.cjs");
|
|
|
3
3
|
const require_field_resolver = require("../shared/field-resolver.cjs");
|
|
4
4
|
const require_extract_literals = require("../value-help/extract-literals.cjs");
|
|
5
5
|
const require_extract_ref = require("../value-help/extract-ref.cjs");
|
|
6
|
+
const require_exact_number = require("../shared/exact-number.cjs");
|
|
6
7
|
const require_str = require("../shared/str.cjs");
|
|
7
8
|
const require_measurement = require("../form/measurement.cjs");
|
|
8
9
|
const require_value_label = require("../shared/value-label.cjs");
|
|
@@ -176,7 +177,7 @@ function inferDisplayType(prop, literalOpts) {
|
|
|
176
177
|
const final = prop.type;
|
|
177
178
|
const dt = final.designType;
|
|
178
179
|
if (dt === "number") return final.tags?.has("timestamp") ? "datetime" : "number";
|
|
179
|
-
if (
|
|
180
|
+
if (require_exact_number.isExactNumberText(prop)) return "number";
|
|
180
181
|
if (dt === "boolean") return "boolean";
|
|
181
182
|
return "text";
|
|
182
183
|
}
|
|
@@ -204,6 +205,7 @@ function scalarValueKind(prop) {
|
|
|
204
205
|
if (tags?.has("int") || INTEGER_NUMBER_META.some((k) => prop.metadata.has(k))) return "integer";
|
|
205
206
|
return "number";
|
|
206
207
|
case "decimal": return "decimal";
|
|
208
|
+
case "long": return "long";
|
|
207
209
|
case "boolean": return "boolean";
|
|
208
210
|
default: return;
|
|
209
211
|
}
|
|
@@ -245,3 +247,4 @@ function inferValueKind(prop) {
|
|
|
245
247
|
}
|
|
246
248
|
//#endregion
|
|
247
249
|
exports.createTableDef = createTableDef;
|
|
250
|
+
exports.inferValueKind = inferValueKind;
|
|
@@ -3,6 +3,7 @@ import { deserializeServedType } from "../i18n/model-texts.mjs";
|
|
|
3
3
|
import { getFieldMeta } from "../shared/field-resolver.mjs";
|
|
4
4
|
import { extractFieldLiteralOptions, isEmptyMember } from "../value-help/extract-literals.mjs";
|
|
5
5
|
import { extractValueHelp } from "../value-help/extract-ref.mjs";
|
|
6
|
+
import { isExactNumberText } from "../shared/exact-number.mjs";
|
|
6
7
|
import { humanizePath } from "../shared/str.mjs";
|
|
7
8
|
import { extractMeasurement } from "../form/measurement.mjs";
|
|
8
9
|
import { valueLabelOf } from "../shared/value-label.mjs";
|
|
@@ -176,7 +177,7 @@ function inferDisplayType(prop, literalOpts) {
|
|
|
176
177
|
const final = prop.type;
|
|
177
178
|
const dt = final.designType;
|
|
178
179
|
if (dt === "number") return final.tags?.has("timestamp") ? "datetime" : "number";
|
|
179
|
-
if (
|
|
180
|
+
if (isExactNumberText(prop)) return "number";
|
|
180
181
|
if (dt === "boolean") return "boolean";
|
|
181
182
|
return "text";
|
|
182
183
|
}
|
|
@@ -204,6 +205,7 @@ function scalarValueKind(prop) {
|
|
|
204
205
|
if (tags?.has("int") || INTEGER_NUMBER_META.some((k) => prop.metadata.has(k))) return "integer";
|
|
205
206
|
return "number";
|
|
206
207
|
case "decimal": return "decimal";
|
|
208
|
+
case "long": return "long";
|
|
207
209
|
case "boolean": return "boolean";
|
|
208
210
|
default: return;
|
|
209
211
|
}
|
|
@@ -244,4 +246,4 @@ function inferValueKind(prop) {
|
|
|
244
246
|
return [...kinds][0];
|
|
245
247
|
}
|
|
246
248
|
//#endregion
|
|
247
|
-
export { createTableDef };
|
|
249
|
+
export { createTableDef, inferValueKind };
|
package/dist/table/types.d.cts
CHANGED
|
@@ -52,27 +52,33 @@ interface FieldMeta {
|
|
|
52
52
|
*/
|
|
53
53
|
writeOnly?: boolean;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
55
|
+
* Read, never written, through this endpoint (`@atscript/db` 0.1.209+): the
|
|
56
|
+
* field is not in the model's write model — `derived`, `computed`,
|
|
57
|
+
* `hostComputed`, a `@db.view.writable` view's own field — or a permission
|
|
58
|
+
* overlay marks it. A write carrying it drops the key. `createFormDef`
|
|
59
|
+
* (`CreateFormDefOptions.metaFields`) marks such a field `derived`: rendered
|
|
60
|
+
* read-only, never sent. Since 0.1.205.
|
|
61
|
+
*/
|
|
62
|
+
readOnly?: true;
|
|
63
|
+
/**
|
|
64
|
+
* Server-computed (`@db.column.derived`, `@atscript/db` 0.1.141+) — why the
|
|
65
|
+
* field is `readOnly`: filterable and sortable like any column, but a value
|
|
66
|
+
* written to it is dropped. Since 0.1.144.
|
|
59
67
|
*/
|
|
60
68
|
derived?: boolean;
|
|
61
69
|
/**
|
|
62
|
-
* A computed view column (`@db.compute`, `@atscript/db` 0.1.147+)
|
|
63
|
-
* database evaluates it from other fields of
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* `db.compute` marker since 0.1.205, else from these fields —
|
|
67
|
-
* `CreateFormDefOptions.metaFields`). Since 0.1.147.
|
|
70
|
+
* A computed view column (`@db.compute`, `@atscript/db` 0.1.147+) — why
|
|
71
|
+
* the field is `readOnly`: the database evaluates it from other fields of
|
|
72
|
+
* the view. Sorting and filtering follow `sortable` / `filterable`.
|
|
73
|
+
* Since 0.1.147.
|
|
68
74
|
*/
|
|
69
75
|
computed?: boolean;
|
|
70
76
|
/**
|
|
71
77
|
* A view's host-computed field (`@db.compute.host`, `@atscript/db`
|
|
72
|
-
* 0.1.205+)
|
|
73
|
-
* read.
|
|
74
|
-
* is a
|
|
75
|
-
*
|
|
78
|
+
* 0.1.205+) — why the field is `readOnly`: no column, the server's
|
|
79
|
+
* `computeHost` fills it after each read. Served `sortable: false,
|
|
80
|
+
* filterable: false`, so it is a column with no sort or filter. Since
|
|
81
|
+
* 0.1.203 (replaces `decoration`).
|
|
76
82
|
*/
|
|
77
83
|
hostComputed?: boolean;
|
|
78
84
|
/**
|
|
@@ -172,10 +178,11 @@ interface TableDef {
|
|
|
172
178
|
/**
|
|
173
179
|
* Scalar storage kind of a column's value — what the server's filter guard
|
|
174
180
|
* checks. `string` / `date` / `isoDate` are `string`, `string.date` and
|
|
175
|
-
* `string.isoDate`; `timestamp` is `number.timestamp` (epoch ms)
|
|
181
|
+
* `string.isoDate`; `timestamp` is `number.timestamp` (epoch ms); `decimal`
|
|
182
|
+
* and `long` hold exact numbers as text (`long` since 0.1.205).
|
|
176
183
|
* Since 0.1.148.
|
|
177
184
|
*/
|
|
178
|
-
type ColumnValueKind = "string" | "date" | "isoDate" | "number" | "integer" | "decimal" | "timestamp" | "boolean";
|
|
185
|
+
type ColumnValueKind = "string" | "date" | "isoDate" | "number" | "integer" | "decimal" | "long" | "timestamp" | "boolean";
|
|
179
186
|
/** A single column definition — built from field metadata + annotations. */
|
|
180
187
|
interface ColumnDef {
|
|
181
188
|
/** Field path in dot-notation (e.g. 'address.city'). */
|
package/dist/table/types.d.mts
CHANGED
|
@@ -52,27 +52,33 @@ interface FieldMeta {
|
|
|
52
52
|
*/
|
|
53
53
|
writeOnly?: boolean;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
55
|
+
* Read, never written, through this endpoint (`@atscript/db` 0.1.209+): the
|
|
56
|
+
* field is not in the model's write model — `derived`, `computed`,
|
|
57
|
+
* `hostComputed`, a `@db.view.writable` view's own field — or a permission
|
|
58
|
+
* overlay marks it. A write carrying it drops the key. `createFormDef`
|
|
59
|
+
* (`CreateFormDefOptions.metaFields`) marks such a field `derived`: rendered
|
|
60
|
+
* read-only, never sent. Since 0.1.205.
|
|
61
|
+
*/
|
|
62
|
+
readOnly?: true;
|
|
63
|
+
/**
|
|
64
|
+
* Server-computed (`@db.column.derived`, `@atscript/db` 0.1.141+) — why the
|
|
65
|
+
* field is `readOnly`: filterable and sortable like any column, but a value
|
|
66
|
+
* written to it is dropped. Since 0.1.144.
|
|
59
67
|
*/
|
|
60
68
|
derived?: boolean;
|
|
61
69
|
/**
|
|
62
|
-
* A computed view column (`@db.compute`, `@atscript/db` 0.1.147+)
|
|
63
|
-
* database evaluates it from other fields of
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* `db.compute` marker since 0.1.205, else from these fields —
|
|
67
|
-
* `CreateFormDefOptions.metaFields`). Since 0.1.147.
|
|
70
|
+
* A computed view column (`@db.compute`, `@atscript/db` 0.1.147+) — why
|
|
71
|
+
* the field is `readOnly`: the database evaluates it from other fields of
|
|
72
|
+
* the view. Sorting and filtering follow `sortable` / `filterable`.
|
|
73
|
+
* Since 0.1.147.
|
|
68
74
|
*/
|
|
69
75
|
computed?: boolean;
|
|
70
76
|
/**
|
|
71
77
|
* A view's host-computed field (`@db.compute.host`, `@atscript/db`
|
|
72
|
-
* 0.1.205+)
|
|
73
|
-
* read.
|
|
74
|
-
* is a
|
|
75
|
-
*
|
|
78
|
+
* 0.1.205+) — why the field is `readOnly`: no column, the server's
|
|
79
|
+
* `computeHost` fills it after each read. Served `sortable: false,
|
|
80
|
+
* filterable: false`, so it is a column with no sort or filter. Since
|
|
81
|
+
* 0.1.203 (replaces `decoration`).
|
|
76
82
|
*/
|
|
77
83
|
hostComputed?: boolean;
|
|
78
84
|
/**
|
|
@@ -172,10 +178,11 @@ interface TableDef {
|
|
|
172
178
|
/**
|
|
173
179
|
* Scalar storage kind of a column's value — what the server's filter guard
|
|
174
180
|
* checks. `string` / `date` / `isoDate` are `string`, `string.date` and
|
|
175
|
-
* `string.isoDate`; `timestamp` is `number.timestamp` (epoch ms)
|
|
181
|
+
* `string.isoDate`; `timestamp` is `number.timestamp` (epoch ms); `decimal`
|
|
182
|
+
* and `long` hold exact numbers as text (`long` since 0.1.205).
|
|
176
183
|
* Since 0.1.148.
|
|
177
184
|
*/
|
|
178
|
-
type ColumnValueKind = "string" | "date" | "isoDate" | "number" | "integer" | "decimal" | "timestamp" | "boolean";
|
|
185
|
+
type ColumnValueKind = "string" | "date" | "isoDate" | "number" | "integer" | "decimal" | "long" | "timestamp" | "boolean";
|
|
179
186
|
/** A single column definition — built from field metadata + annotations. */
|
|
180
187
|
interface ColumnDef {
|
|
181
188
|
/** Field path in dot-notation (e.g. 'address.city'). */
|
|
@@ -1,10 +1,43 @@
|
|
|
1
|
+
let _atscript_db_meta = require("@atscript/db/meta");
|
|
1
2
|
//#region src/table/value-kind.ts
|
|
2
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Storage kinds that hold numbers (a `timestamp` is epoch ms, but filters treat
|
|
5
|
+
* it as a date). A `decimal` or `long` value is exact numeric text, not a JS
|
|
6
|
+
* number.
|
|
7
|
+
*/
|
|
3
8
|
const NUMERIC_VALUE_KINDS = new Set([
|
|
4
9
|
"number",
|
|
5
10
|
"integer",
|
|
6
|
-
"decimal"
|
|
11
|
+
"decimal",
|
|
12
|
+
"long"
|
|
7
13
|
]);
|
|
14
|
+
const NUMERIC_TEXT = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
|
|
15
|
+
/** Whether `raw` is plain decimal-number text (`12`, `-0.5`, `1e3`) — not `Infinity`, `0x1`, or `1_000`. Since 0.1.205. */
|
|
16
|
+
function isNumericText(raw) {
|
|
17
|
+
return NUMERIC_TEXT.test(raw.trim());
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The typed value of numeric text — what a filter or a search sends for a
|
|
21
|
+
* field of storage kind `valueKind` — or `undefined` when the text is no such
|
|
22
|
+
* value:
|
|
23
|
+
*
|
|
24
|
+
* - an `integer` takes whole numbers only;
|
|
25
|
+
* - a `decimal` keeps the text as a **string** (a JS number would round it);
|
|
26
|
+
* - a `long` takes integer text within the 64-bit range, as canonical text
|
|
27
|
+
* (`" +007 "` → `"7"`);
|
|
28
|
+
* - any other kind gets a finite number.
|
|
29
|
+
*
|
|
30
|
+
* Since 0.1.205 (`@atscript/ui-table`'s filter coercion before).
|
|
31
|
+
*/
|
|
32
|
+
function coerceNumericText(raw, valueKind) {
|
|
33
|
+
if (!isNumericText(raw)) return void 0;
|
|
34
|
+
const text = raw.trim();
|
|
35
|
+
if (valueKind === "decimal") return text;
|
|
36
|
+
if (valueKind === "long") return (0, _atscript_db_meta.canonicalLong)(text);
|
|
37
|
+
const n = Number(text);
|
|
38
|
+
if (!Number.isFinite(n)) return void 0;
|
|
39
|
+
return valueKind === "integer" && !Number.isInteger(n) ? void 0 : n;
|
|
40
|
+
}
|
|
8
41
|
/**
|
|
9
42
|
* The typed value of an option — a column's or a form field's — the literal
|
|
10
43
|
* itself (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
|
|
@@ -17,4 +50,6 @@ function optionValue(option) {
|
|
|
17
50
|
}
|
|
18
51
|
//#endregion
|
|
19
52
|
exports.NUMERIC_VALUE_KINDS = NUMERIC_VALUE_KINDS;
|
|
53
|
+
exports.coerceNumericText = coerceNumericText;
|
|
54
|
+
exports.isNumericText = isNumericText;
|
|
20
55
|
exports.optionValue = optionValue;
|
|
@@ -2,8 +2,28 @@ import { TFormEntryOptions } from "../value-help/types.cjs";
|
|
|
2
2
|
import { ColumnValueKind } from "./types.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/table/value-kind.d.ts
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Storage kinds that hold numbers (a `timestamp` is epoch ms, but filters treat
|
|
7
|
+
* it as a date). A `decimal` or `long` value is exact numeric text, not a JS
|
|
8
|
+
* number.
|
|
9
|
+
*/
|
|
6
10
|
declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
|
|
11
|
+
/** Whether `raw` is plain decimal-number text (`12`, `-0.5`, `1e3`) — not `Infinity`, `0x1`, or `1_000`. Since 0.1.205. */
|
|
12
|
+
declare function isNumericText(raw: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The typed value of numeric text — what a filter or a search sends for a
|
|
15
|
+
* field of storage kind `valueKind` — or `undefined` when the text is no such
|
|
16
|
+
* value:
|
|
17
|
+
*
|
|
18
|
+
* - an `integer` takes whole numbers only;
|
|
19
|
+
* - a `decimal` keeps the text as a **string** (a JS number would round it);
|
|
20
|
+
* - a `long` takes integer text within the 64-bit range, as canonical text
|
|
21
|
+
* (`" +007 "` → `"7"`);
|
|
22
|
+
* - any other kind gets a finite number.
|
|
23
|
+
*
|
|
24
|
+
* Since 0.1.205 (`@atscript/ui-table`'s filter coercion before).
|
|
25
|
+
*/
|
|
26
|
+
declare function coerceNumericText(raw: string, valueKind?: ColumnValueKind): string | number | undefined;
|
|
7
27
|
/**
|
|
8
28
|
* The typed value of an option — a column's or a form field's — the literal
|
|
9
29
|
* itself (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
|
|
@@ -13,4 +33,4 @@ declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
|
|
|
13
33
|
*/
|
|
14
34
|
declare function optionValue(option: TFormEntryOptions): string | number | boolean;
|
|
15
35
|
//#endregion
|
|
16
|
-
export { NUMERIC_VALUE_KINDS, optionValue };
|
|
36
|
+
export { NUMERIC_VALUE_KINDS, coerceNumericText, isNumericText, optionValue };
|
|
@@ -2,8 +2,28 @@ import { TFormEntryOptions } from "../value-help/types.mjs";
|
|
|
2
2
|
import { ColumnValueKind } from "./types.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/table/value-kind.d.ts
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Storage kinds that hold numbers (a `timestamp` is epoch ms, but filters treat
|
|
7
|
+
* it as a date). A `decimal` or `long` value is exact numeric text, not a JS
|
|
8
|
+
* number.
|
|
9
|
+
*/
|
|
6
10
|
declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
|
|
11
|
+
/** Whether `raw` is plain decimal-number text (`12`, `-0.5`, `1e3`) — not `Infinity`, `0x1`, or `1_000`. Since 0.1.205. */
|
|
12
|
+
declare function isNumericText(raw: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The typed value of numeric text — what a filter or a search sends for a
|
|
15
|
+
* field of storage kind `valueKind` — or `undefined` when the text is no such
|
|
16
|
+
* value:
|
|
17
|
+
*
|
|
18
|
+
* - an `integer` takes whole numbers only;
|
|
19
|
+
* - a `decimal` keeps the text as a **string** (a JS number would round it);
|
|
20
|
+
* - a `long` takes integer text within the 64-bit range, as canonical text
|
|
21
|
+
* (`" +007 "` → `"7"`);
|
|
22
|
+
* - any other kind gets a finite number.
|
|
23
|
+
*
|
|
24
|
+
* Since 0.1.205 (`@atscript/ui-table`'s filter coercion before).
|
|
25
|
+
*/
|
|
26
|
+
declare function coerceNumericText(raw: string, valueKind?: ColumnValueKind): string | number | undefined;
|
|
7
27
|
/**
|
|
8
28
|
* The typed value of an option — a column's or a form field's — the literal
|
|
9
29
|
* itself (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
|
|
@@ -13,4 +33,4 @@ declare const NUMERIC_VALUE_KINDS: ReadonlySet<ColumnValueKind>;
|
|
|
13
33
|
*/
|
|
14
34
|
declare function optionValue(option: TFormEntryOptions): string | number | boolean;
|
|
15
35
|
//#endregion
|
|
16
|
-
export { NUMERIC_VALUE_KINDS, optionValue };
|
|
36
|
+
export { NUMERIC_VALUE_KINDS, coerceNumericText, isNumericText, optionValue };
|
|
@@ -1,10 +1,43 @@
|
|
|
1
|
+
import { canonicalLong } from "@atscript/db/meta";
|
|
1
2
|
//#region src/table/value-kind.ts
|
|
2
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Storage kinds that hold numbers (a `timestamp` is epoch ms, but filters treat
|
|
5
|
+
* it as a date). A `decimal` or `long` value is exact numeric text, not a JS
|
|
6
|
+
* number.
|
|
7
|
+
*/
|
|
3
8
|
const NUMERIC_VALUE_KINDS = new Set([
|
|
4
9
|
"number",
|
|
5
10
|
"integer",
|
|
6
|
-
"decimal"
|
|
11
|
+
"decimal",
|
|
12
|
+
"long"
|
|
7
13
|
]);
|
|
14
|
+
const NUMERIC_TEXT = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
|
|
15
|
+
/** Whether `raw` is plain decimal-number text (`12`, `-0.5`, `1e3`) — not `Infinity`, `0x1`, or `1_000`. Since 0.1.205. */
|
|
16
|
+
function isNumericText(raw) {
|
|
17
|
+
return NUMERIC_TEXT.test(raw.trim());
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The typed value of numeric text — what a filter or a search sends for a
|
|
21
|
+
* field of storage kind `valueKind` — or `undefined` when the text is no such
|
|
22
|
+
* value:
|
|
23
|
+
*
|
|
24
|
+
* - an `integer` takes whole numbers only;
|
|
25
|
+
* - a `decimal` keeps the text as a **string** (a JS number would round it);
|
|
26
|
+
* - a `long` takes integer text within the 64-bit range, as canonical text
|
|
27
|
+
* (`" +007 "` → `"7"`);
|
|
28
|
+
* - any other kind gets a finite number.
|
|
29
|
+
*
|
|
30
|
+
* Since 0.1.205 (`@atscript/ui-table`'s filter coercion before).
|
|
31
|
+
*/
|
|
32
|
+
function coerceNumericText(raw, valueKind) {
|
|
33
|
+
if (!isNumericText(raw)) return void 0;
|
|
34
|
+
const text = raw.trim();
|
|
35
|
+
if (valueKind === "decimal") return text;
|
|
36
|
+
if (valueKind === "long") return canonicalLong(text);
|
|
37
|
+
const n = Number(text);
|
|
38
|
+
if (!Number.isFinite(n)) return void 0;
|
|
39
|
+
return valueKind === "integer" && !Number.isInteger(n) ? void 0 : n;
|
|
40
|
+
}
|
|
8
41
|
/**
|
|
9
42
|
* The typed value of an option — a column's or a form field's — the literal
|
|
10
43
|
* itself (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
|
|
@@ -16,4 +49,4 @@ function optionValue(option) {
|
|
|
16
49
|
return typeof option === "string" ? option : option.value ?? option.key;
|
|
17
50
|
}
|
|
18
51
|
//#endregion
|
|
19
|
-
export { NUMERIC_VALUE_KINDS, optionValue };
|
|
52
|
+
export { NUMERIC_VALUE_KINDS, coerceNumericText, isNumericText, optionValue };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_path_utils = require("../form/path-utils.cjs");
|
|
2
2
|
const require_str = require("../shared/str.cjs");
|
|
3
|
+
const require_value_kind = require("../table/value-kind.cjs");
|
|
3
4
|
//#region src/value-help/distinct-client.ts
|
|
4
5
|
/**
|
|
5
6
|
* `true` for a 4xx answer — the server declined this picker (gate, ARBAC, unknown field).
|
|
@@ -23,13 +24,13 @@ async function fetchDistinctValues(client, field, opts = {}) {
|
|
|
23
24
|
const text = opts.text?.trim();
|
|
24
25
|
const conditions = [];
|
|
25
26
|
if (opts.filter) conditions.push(opts.filter);
|
|
26
|
-
if (text) if (opts.
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
27
|
+
if (text) if (opts.valueKind && require_value_kind.NUMERIC_VALUE_KINDS.has(opts.valueKind)) {
|
|
28
|
+
const value = require_value_kind.coerceNumericText(text, opts.valueKind);
|
|
29
|
+
if (value === void 0) return {
|
|
29
30
|
items: [],
|
|
30
31
|
hasMore: false
|
|
31
32
|
};
|
|
32
|
-
conditions.push({ [field]:
|
|
33
|
+
conditions.push({ [field]: value });
|
|
33
34
|
} else conditions.push({ [field]: { $regex: `/^${require_str.escapeRegex(text)}/i` } });
|
|
34
35
|
const filter = conditions.length > 1 ? { $and: conditions } : conditions[0];
|
|
35
36
|
const rows = await client.aggregate({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ColumnValueKind } from "../table/types.cjs";
|
|
1
2
|
import { ClientLike, FilterExpr } from "@atscript/db-client";
|
|
2
3
|
|
|
3
4
|
//#region src/value-help/distinct-client.d.ts
|
|
@@ -13,8 +14,13 @@ interface DistinctValuesOptions {
|
|
|
13
14
|
skip?: number;
|
|
14
15
|
/** Send `$sort` on the grouped field — only when the server lists it as sortable. */
|
|
15
16
|
sortable?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The field's storage kind. A numeric one ({@link NUMERIC_VALUE_KINDS}) is
|
|
19
|
+
* searched by exact value — text that is no value of it finds nothing; a
|
|
20
|
+
* `decimal` / `long` value is sent as text (since 0.1.205; before, a
|
|
21
|
+
* `numeric` flag and a JS number).
|
|
22
|
+
*/
|
|
23
|
+
valueKind?: ColumnValueKind;
|
|
18
24
|
/** Extra scope AND'd into the query (e.g. the table's `forceFilters`). */
|
|
19
25
|
filter?: FilterExpr;
|
|
20
26
|
}
|