@atscript/ui 0.1.157 → 0.1.159

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/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let _atscript_typescript_utils = require("@atscript/typescript/utils");
3
- let _atscript_db_client = require("@atscript/db-client");
4
3
  let _atscript_db_validator = require("@atscript/db/validator");
4
+ let _atscript_db_client = require("@atscript/db-client");
5
5
  //#region src/shared/annotation-keys.ts
6
6
  const UI_TYPE = "ui.type";
7
7
  const UI_FORM_PLACEHOLDER = "ui.form.placeholder";
@@ -444,8 +444,8 @@ const EDIT = { mode: "edit" };
444
444
  * with `path: ''`.
445
445
  *
446
446
  * A `@db.column.derived` field is marked `derived` straight from its metadata;
447
- * a computed view column, from `opts.metaFields`; an `@db.onUpdate.now` field,
448
- * when `opts.mode` is `"edit"`.
447
+ * a computed view column, from `opts.metaFields`; an update-stamped field
448
+ * (see `CreateFormDefOptions.mode`), when `opts.mode` is `"edit"`.
449
449
  */
450
450
  function createFormDef(type, opts) {
451
451
  const edit = opts?.mode === "edit";
@@ -726,14 +726,14 @@ function createVariant(def, edit) {
726
726
  };
727
727
  }
728
728
  /**
729
- * `@db.onUpdate.now` (`number.timestamp.updated`): the server sets the field
730
- * on every update. Read off the prop, or — as `@atscript/db` does — off the one
731
- * value member of `T | null`, unless the prop references another field.
729
+ * An update-stamped field (see `CreateFormDefOptions.mode`). Read off the prop,
730
+ * or — as `@atscript/db` does — off the one value member of `T | null`, unless
731
+ * the prop references another field.
732
732
  */
733
733
  function isUpdateStamped(prop) {
734
- if (hasFieldMeta(prop, "db.onUpdate.now")) return true;
734
+ if ((0, _atscript_db_validator.isServerStampedOnUpdate)(prop.metadata)) return true;
735
735
  const member = prop.ref?.field ? void 0 : soleValueMember(prop);
736
- return member !== void 0 && hasFieldMeta(member, "db.onUpdate.now");
736
+ return member !== void 0 && (0, _atscript_db_validator.isServerStampedOnUpdate)(member.metadata);
737
737
  }
738
738
  /** The one non-`null` / `undefined` member of a (nested) union, if there is exactly one. */
739
739
  function soleValueMember(prop) {
@@ -1786,6 +1786,97 @@ function deepClone(value, unwrap) {
1786
1786
  return out;
1787
1787
  }
1788
1788
  //#endregion
1789
+ //#region src/form/error-utils.ts
1790
+ /**
1791
+ * Framework-agnostic helpers for working with form-error maps keyed by
1792
+ * dotted path. Used by AsForm to drive error badges and auto-open
1793
+ * collapsed sections; safe to share with React (or any other) bindings.
1794
+ *
1795
+ * Convention:
1796
+ * - Keys are dotted paths (`a.b.c`); empty string and `__form` denote
1797
+ * the form-level error.
1798
+ * - Values may be `string | undefined`; falsy entries are dropped on
1799
+ * merge.
1800
+ */
1801
+ /** Error-map key of the form-level error. */
1802
+ const FORM_ERROR_KEY = "__form";
1803
+ /**
1804
+ * Turn a validator's error list into an error map keyed by path. A
1805
+ * root-level error (empty path) becomes the form-level error
1806
+ * ({@link FORM_ERROR_KEY}). The first error per path wins: a failing
1807
+ * container rule is reported before the container's own shape / length
1808
+ * checks at the same path.
1809
+ */
1810
+ function validatorErrorsToMap(errors) {
1811
+ const out = {};
1812
+ for (const err of errors) out[err.path || "__form"] ??= err.message;
1813
+ return out;
1814
+ }
1815
+ /**
1816
+ * Merge any number of partial error maps into a single dense
1817
+ * `Record<path, message>`. Falsy values are skipped — later sources do
1818
+ * NOT overwrite earlier ones with an empty value.
1819
+ */
1820
+ function mergeErrorMaps(...maps) {
1821
+ const merged = {};
1822
+ for (const m of maps) {
1823
+ if (!m) continue;
1824
+ for (const k of Object.keys(m)) {
1825
+ const v = m[k];
1826
+ if (v) merged[k] = v;
1827
+ }
1828
+ }
1829
+ return merged;
1830
+ }
1831
+ /**
1832
+ * Return `errors` without the entries whose key is in `paths`.
1833
+ *
1834
+ * Identity-preserving: when no key matches, the ORIGINAL `errors` object
1835
+ * is returned unchanged — callers compare `result !== errors` to detect
1836
+ * that something was pruned and skip spurious reactive writes.
1837
+ */
1838
+ function omitPaths(errors, paths) {
1839
+ let pruned = null;
1840
+ for (const key in errors) if (paths.has(key)) {
1841
+ pruned ??= { ...errors };
1842
+ delete pruned[key];
1843
+ }
1844
+ return pruned ?? errors;
1845
+ }
1846
+ /**
1847
+ * Yield every ancestor prefix of a dotted path, longest-first
1848
+ * (`a.b.c` → `a.b.c`, `a.b`, `a`). Returns the path itself first so
1849
+ * callers can include it in the iteration without a special case.
1850
+ *
1851
+ * Empty paths and the form-level key (`__form`) yield nothing.
1852
+ */
1853
+ function* iteratePathAncestors(path) {
1854
+ if (!path || path === "__form") return;
1855
+ let pos = path.length;
1856
+ while (pos > 0) {
1857
+ yield path.slice(0, pos);
1858
+ const dot = path.lastIndexOf(".", pos - 1);
1859
+ if (dot < 0) return;
1860
+ pos = dot;
1861
+ }
1862
+ }
1863
+ /**
1864
+ * Build an indexed `Map<absolutePath, descendantErrorCount>` so each
1865
+ * struct in the tree can render an error-count badge in O(1).
1866
+ *
1867
+ * For every error path, the count is incremented on the path itself
1868
+ * AND every dotted-path ancestor — so a struct at `a.b` reports the
1869
+ * total of all errors at `a.b` or below.
1870
+ */
1871
+ function buildDescendantErrorCounts(errors) {
1872
+ const map = /* @__PURE__ */ new Map();
1873
+ for (const errPath of Object.keys(errors)) {
1874
+ if (!errors[errPath]) continue;
1875
+ for (const prefix of iteratePathAncestors(errPath)) map.set(prefix, (map.get(prefix) ?? 0) + 1);
1876
+ }
1877
+ return map;
1878
+ }
1879
+ //#endregion
1789
1880
  //#region src/form/validate.ts
1790
1881
  const dbPlugin = (0, _atscript_db_validator.createDbValidatorPlugin)();
1791
1882
  const INSERT_CONTEXT = { mode: "insert" };
@@ -1794,8 +1885,9 @@ const INSERT_CONTEXT = { mode: "insert" };
1794
1885
  * blocked on them:
1795
1886
  * - `@db.column.derived` — read-only and server-computed: never validated
1796
1887
  * (not even a loaded value, which the user could not fix).
1797
- * - an absent `@db.default*` / `@db.column.version` value — delegated to
1798
- * `@atscript/db`'s own insert-mode rule, so the key list has one owner.
1888
+ * - an absent `@db.default*` / `@db.column.version` / `@db.onUpdate.inc` value
1889
+ * — delegated to `@atscript/db`'s own insert-mode rule, so the key list has
1890
+ * one owner.
1799
1891
  * `db.rel.FK` is kept out: a form fills the FK itself (no nested nav
1800
1892
  * object), so an empty required FK must still fail.
1801
1893
  *
@@ -1810,10 +1902,11 @@ const serverManagedPlugin = (ctx, def, value) => {
1810
1902
  };
1811
1903
  /**
1812
1904
  * The props of the fields `createFormDef` marked `derived`, at any depth — a
1813
- * computed view column (`metaFields`) or an edit form's `@db.onUpdate.now`
1814
- * field carries no annotation the plugin above could read. The validator
1815
- * matches by prop, so a prop that is also used where it is not derived (an
1816
- * interface's stamp below a union of several types, too) stays validated.
1905
+ * computed view column (`metaFields`) or an edit form's update-stamped field
1906
+ * (see `CreateFormDefOptions.mode`) carries no annotation the plugin above
1907
+ * could read. The validator matches by prop, so a prop that is also used where
1908
+ * it is not derived (an interface's stamp below a union of several types, too)
1909
+ * stays validated.
1817
1910
  */
1818
1911
  function collectDerivedProps(def) {
1819
1912
  const derived = /* @__PURE__ */ new Set();
@@ -1854,6 +1947,9 @@ function getDefaultValidatorPlugins() {
1854
1947
  * ATScript's @expect.* validation runs automatically; server-managed db
1855
1948
  * fields (every `derived` field, absent `@db.default*` / version) pass.
1856
1949
  * For custom `ui.fn.*` validators, install ui-fns and pass its plugin via `opts.plugins`.
1950
+ *
1951
+ * Errors are keyed by dotted path. A root-level error (a failing
1952
+ * `@ui.form.validate` on the form's interface) is keyed `__form`.
1857
1953
  */
1858
1954
  function getFormValidator(def, opts) {
1859
1955
  const derived = collectDerivedProps(def);
@@ -1873,9 +1969,7 @@ function getFormValidator(def, opts) {
1873
1969
  data: callOpts.data,
1874
1970
  context: callOpts.context ?? {}
1875
1971
  })) return {};
1876
- const errors = {};
1877
- for (const err of validator.errors) errors[err.path] = err.message;
1878
- return errors;
1972
+ return validatorErrorsToMap(validator.errors);
1879
1973
  };
1880
1974
  }
1881
1975
  /**
@@ -1887,8 +1981,12 @@ function getFormValidator(def, opts) {
1887
1981
  * a branch's verdict depends on its children — those keep the full walk.
1888
1982
  */
1889
1983
  const skipDescendantsPlugin = (ctx) => ctx.path === "" ? void 0 : true;
1890
- function skipsDescendants(prop) {
1891
- const kind = prop.type.kind;
1984
+ /**
1985
+ * Whether a type kind is a container that carries its own children:
1986
+ * `object`, `array` or `tuple`. Union / intersection kinds are not
1987
+ * containers — they evaluate their branches at their own path.
1988
+ */
1989
+ function isContainerKind(kind) {
1892
1990
  return kind === "object" || kind === "array" || kind === "tuple";
1893
1991
  }
1894
1992
  /**
@@ -1902,7 +2000,7 @@ function skipsDescendants(prop) {
1902
2000
  function createFieldValidator(prop, opts) {
1903
2001
  let cached;
1904
2002
  return (value, externalCtx) => {
1905
- cached ??= new _atscript_typescript_utils.Validator(prop, { plugins: opts?.rootOnly && skipsDescendants(prop) ? [
2003
+ cached ??= new _atscript_typescript_utils.Validator(prop, { plugins: opts?.rootOnly && isContainerKind(prop.type.kind) ? [
1906
2004
  skipDescendantsPlugin,
1907
2005
  serverManagedPlugin,
1908
2006
  ...defaultValidatorPlugins
@@ -2565,84 +2663,6 @@ function walkUnionFields(fields, prefix, before, after) {
2565
2663
  return false;
2566
2664
  }
2567
2665
  //#endregion
2568
- //#region src/form/error-utils.ts
2569
- /**
2570
- * Framework-agnostic helpers for working with form-error maps keyed by
2571
- * dotted path. Used by AsForm to drive error badges and auto-open
2572
- * collapsed sections; safe to share with React (or any other) bindings.
2573
- *
2574
- * Convention:
2575
- * - Keys are dotted paths (`a.b.c`); empty string and `__form` denote
2576
- * the form-level error.
2577
- * - Values may be `string | undefined`; falsy entries are dropped on
2578
- * merge.
2579
- */
2580
- const FORM_ERROR_KEY = "__form";
2581
- /**
2582
- * Merge any number of partial error maps into a single dense
2583
- * `Record<path, message>`. Falsy values are skipped — later sources do
2584
- * NOT overwrite earlier ones with an empty value.
2585
- */
2586
- function mergeErrorMaps(...maps) {
2587
- const merged = {};
2588
- for (const m of maps) {
2589
- if (!m) continue;
2590
- for (const k of Object.keys(m)) {
2591
- const v = m[k];
2592
- if (v) merged[k] = v;
2593
- }
2594
- }
2595
- return merged;
2596
- }
2597
- /**
2598
- * Return `errors` without the entries whose key is in `paths`.
2599
- *
2600
- * Identity-preserving: when no key matches, the ORIGINAL `errors` object
2601
- * is returned unchanged — callers compare `result !== errors` to detect
2602
- * that something was pruned and skip spurious reactive writes.
2603
- */
2604
- function omitPaths(errors, paths) {
2605
- let pruned = null;
2606
- for (const key in errors) if (paths.has(key)) {
2607
- pruned ??= { ...errors };
2608
- delete pruned[key];
2609
- }
2610
- return pruned ?? errors;
2611
- }
2612
- /**
2613
- * Yield every ancestor prefix of a dotted path, longest-first
2614
- * (`a.b.c` → `a.b.c`, `a.b`, `a`). Returns the path itself first so
2615
- * callers can include it in the iteration without a special case.
2616
- *
2617
- * Empty paths and the form-level key (`__form`) yield nothing.
2618
- */
2619
- function* iteratePathAncestors(path) {
2620
- if (!path || path === FORM_ERROR_KEY) return;
2621
- let pos = path.length;
2622
- while (pos > 0) {
2623
- yield path.slice(0, pos);
2624
- const dot = path.lastIndexOf(".", pos - 1);
2625
- if (dot < 0) return;
2626
- pos = dot;
2627
- }
2628
- }
2629
- /**
2630
- * Build an indexed `Map<absolutePath, descendantErrorCount>` so each
2631
- * struct in the tree can render an error-count badge in O(1).
2632
- *
2633
- * For every error path, the count is incremented on the path itself
2634
- * AND every dotted-path ancestor — so a struct at `a.b` reports the
2635
- * total of all errors at `a.b` or below.
2636
- */
2637
- function buildDescendantErrorCounts(errors) {
2638
- const map = /* @__PURE__ */ new Map();
2639
- for (const errPath of Object.keys(errors)) {
2640
- if (!errors[errPath]) continue;
2641
- for (const prefix of iteratePathAncestors(errPath)) map.set(prefix, (map.get(prefix) ?? 0) + 1);
2642
- }
2643
- return map;
2644
- }
2645
- //#endregion
2646
2666
  //#region src/form/grid.ts
2647
2667
  /** Grid layout parsing for `@ui.form.grid.colSpan` / `@ui.form.grid.rowSpan`. */
2648
2668
  const DEFAULT_COL_SPAN = 12;
@@ -3167,6 +3187,7 @@ exports.DB_UNIT_REF = DB_UNIT_REF;
3167
3187
  exports.DEFAULT_COL_SPAN = DEFAULT_COL_SPAN;
3168
3188
  exports.DEFAULT_ROW_SPAN = DEFAULT_ROW_SPAN;
3169
3189
  exports.EXPECT_MAX_LENGTH = EXPECT_MAX_LENGTH;
3190
+ exports.FORM_ERROR_KEY = FORM_ERROR_KEY;
3170
3191
  exports.META_DEFAULT = META_DEFAULT;
3171
3192
  exports.META_DESCRIPTION = META_DESCRIPTION;
3172
3193
  exports.META_ID = META_ID;
@@ -3290,6 +3311,7 @@ exports.hasComputedAnnotations = hasComputedAnnotations;
3290
3311
  exports.hasFieldMeta = hasFieldMeta;
3291
3312
  exports.invalidateValueHelpCache = invalidateValueHelpCache;
3292
3313
  exports.isArrayField = isArrayField;
3314
+ exports.isContainerKind = isContainerKind;
3293
3315
  exports.isFieldHidden = isFieldHidden;
3294
3316
  exports.isObjectField = isObjectField;
3295
3317
  exports.isPathDirty = isPathDirty;
@@ -3335,4 +3357,5 @@ exports.setValueHelpCacheTtl = setValueHelpCacheTtl;
3335
3357
  exports.splitDecimalString = splitDecimalString;
3336
3358
  exports.str = str;
3337
3359
  exports.unionVariantChanged = unionVariantChanged;
3360
+ exports.validatorErrorsToMap = validatorErrorsToMap;
3338
3361
  exports.valueHelpDictPaths = valueHelpDictPaths;
package/dist/index.d.cts CHANGED
@@ -173,7 +173,7 @@ interface FormFieldDef {
173
173
  /**
174
174
  * Server-owned field: a `@db.column.derived` one (read from the type
175
175
  * metadata), a computed view column (`CreateFormDefOptions.metaFields`) or,
176
- * in an edit form (`CreateFormDefOptions.mode`), an `@db.onUpdate.now` one.
176
+ * in an edit form, an update-stamped one (see `CreateFormDefOptions.mode`).
177
177
  * Rendered read-only, exempt from form validation and never sent by
178
178
  * `buildFormDiff` (the server drops or overwrites a written value anyway).
179
179
  * Since 0.1.144.
@@ -266,14 +266,17 @@ interface CreateFormDefOptions {
266
266
  }>;
267
267
  /**
268
268
  * What the form is for. `"edit"` — the form edits a stored row and is sent
269
- * as an update: an `@db.onUpdate.now` field (`number.timestamp.updated`),
270
- * which the server sets on every update and whose sent value it ignores, is
271
- * then marked `derived` — read-only, never validated, never sent. Applies at
272
- * every depth (embedded objects, objects in arrays), except for a reference
273
- * to another field, an element of an array of numbers, and below a tuple or
274
- * a union of several types, where the server does not set the field.
275
- * `"create"` (default) — the field stays editable: the server only fills it
276
- * when it has `@db.default.now` and the value is left out. Since 0.1.154.
269
+ * as an update: an `@db.onUpdate.now` field (`number.timestamp.updated`) or
270
+ * an `@db.onUpdate.inc` change counter, which the server sets on every
271
+ * update and whose sent value it ignores, is then marked `derived` —
272
+ * read-only, never validated, never sent. Applies at every depth (embedded
273
+ * objects, objects in arrays), except for a reference to another field, an
274
+ * element of an array of numbers, and below a tuple or a union of several
275
+ * types, where the server does not set the field (`@db.onUpdate.inc` is
276
+ * top-level only). `"create"` (default) — the field stays editable: the
277
+ * server only fills it when the value is left out and it has
278
+ * `@db.default.now`, or is an `@db.onUpdate.inc` counter (`0`). Since
279
+ * 0.1.154; `@db.onUpdate.inc` since 0.1.159.
277
280
  */
278
281
  mode?: "create" | "edit";
279
282
  }
@@ -285,8 +288,8 @@ interface CreateFormDefOptions {
285
288
  * with `path: ''`.
286
289
  *
287
290
  * A `@db.column.derived` field is marked `derived` straight from its metadata;
288
- * a computed view column, from `opts.metaFields`; an `@db.onUpdate.now` field,
289
- * when `opts.mode` is `"edit"`.
291
+ * a computed view column, from `opts.metaFields`; an update-stamped field
292
+ * (see `CreateFormDefOptions.mode`), when `opts.mode` is `"edit"`.
290
293
  */
291
294
  declare function createFormDef(type: TAtscriptAnnotatedType, opts?: CreateFormDefOptions): FormDef;
292
295
  /**
@@ -693,6 +696,9 @@ declare function getDefaultValidatorPlugins(): TValidatorPlugin[];
693
696
  * ATScript's @expect.* validation runs automatically; server-managed db
694
697
  * fields (every `derived` field, absent `@db.default*` / version) pass.
695
698
  * For custom `ui.fn.*` validators, install ui-fns and pass its plugin via `opts.plugins`.
699
+ *
700
+ * Errors are keyed by dotted path. A root-level error (a failing
701
+ * `@ui.form.validate` on the form's interface) is keyed `__form`.
696
702
  */
697
703
  declare function getFormValidator(def: FormDef, opts?: Partial<TValidatorOptions>): (callOpts: TFormValidatorCallOptions) => Record<string, string>;
698
704
  /** Options for createFieldValidator. */
@@ -700,6 +706,12 @@ interface TFieldValidatorOptions {
700
706
  /** Only report errors at the root path (for structure/array container validation). */
701
707
  rootOnly?: boolean;
702
708
  }
709
+ /**
710
+ * Whether a type kind is a container that carries its own children:
711
+ * `object`, `array` or `tuple`. Union / intersection kinds are not
712
+ * containers — they evaluate their branches at their own path.
713
+ */
714
+ declare function isContainerKind(kind: string): boolean;
703
715
  /**
704
716
  * Creates a cached validator function for a single ATScript prop.
705
717
  *
@@ -954,6 +966,19 @@ declare function unionVariantChanged(def: FormDef, before: Record<string, unknow
954
966
  * - Values may be `string | undefined`; falsy entries are dropped on
955
967
  * merge.
956
968
  */
969
+ /** Error-map key of the form-level error. */
970
+ declare const FORM_ERROR_KEY = "__form";
971
+ /**
972
+ * Turn a validator's error list into an error map keyed by path. A
973
+ * root-level error (empty path) becomes the form-level error
974
+ * ({@link FORM_ERROR_KEY}). The first error per path wins: a failing
975
+ * container rule is reported before the container's own shape / length
976
+ * checks at the same path.
977
+ */
978
+ declare function validatorErrorsToMap(errors: ReadonlyArray<{
979
+ path: string;
980
+ message: string;
981
+ }>): Record<string, string>;
957
982
  /**
958
983
  * Merge any number of partial error maps into a single dense
959
984
  * `Record<path, message>`. Falsy values are skipped — later sources do
@@ -1665,4 +1690,4 @@ interface TModelRoute {
1665
1690
  */
1666
1691
  declare function buildModelRoutes(models: readonly TAtscriptAnnotatedType[]): TModelRoute[];
1667
1692
  //#endregion
1668
- export { type ClientFactory, type ClientFactoryOptions, type CloneUnwrap, type ColumnDef, type ColumnValueKind, type CreateFormDefOptions, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaEntryOptions, type MetaResponse, NUMERIC_VALUE_KINDS, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TModelRoute, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, 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, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, onMetaCacheReset, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, retainMetaEntry, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setMetaCacheMaxEntries, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
1693
+ export { type ClientFactory, type ClientFactoryOptions, type CloneUnwrap, type ColumnDef, type ColumnValueKind, type CreateFormDefOptions, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, FORM_ERROR_KEY, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaEntryOptions, type MetaResponse, NUMERIC_VALUE_KINDS, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TModelRoute, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, 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, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isContainerKind, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, onMetaCacheReset, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, retainMetaEntry, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setMetaCacheMaxEntries, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, validatorErrorsToMap, valueHelpDictPaths };
package/dist/index.d.mts CHANGED
@@ -173,7 +173,7 @@ interface FormFieldDef {
173
173
  /**
174
174
  * Server-owned field: a `@db.column.derived` one (read from the type
175
175
  * metadata), a computed view column (`CreateFormDefOptions.metaFields`) or,
176
- * in an edit form (`CreateFormDefOptions.mode`), an `@db.onUpdate.now` one.
176
+ * in an edit form, an update-stamped one (see `CreateFormDefOptions.mode`).
177
177
  * Rendered read-only, exempt from form validation and never sent by
178
178
  * `buildFormDiff` (the server drops or overwrites a written value anyway).
179
179
  * Since 0.1.144.
@@ -266,14 +266,17 @@ interface CreateFormDefOptions {
266
266
  }>;
267
267
  /**
268
268
  * What the form is for. `"edit"` — the form edits a stored row and is sent
269
- * as an update: an `@db.onUpdate.now` field (`number.timestamp.updated`),
270
- * which the server sets on every update and whose sent value it ignores, is
271
- * then marked `derived` — read-only, never validated, never sent. Applies at
272
- * every depth (embedded objects, objects in arrays), except for a reference
273
- * to another field, an element of an array of numbers, and below a tuple or
274
- * a union of several types, where the server does not set the field.
275
- * `"create"` (default) — the field stays editable: the server only fills it
276
- * when it has `@db.default.now` and the value is left out. Since 0.1.154.
269
+ * as an update: an `@db.onUpdate.now` field (`number.timestamp.updated`) or
270
+ * an `@db.onUpdate.inc` change counter, which the server sets on every
271
+ * update and whose sent value it ignores, is then marked `derived` —
272
+ * read-only, never validated, never sent. Applies at every depth (embedded
273
+ * objects, objects in arrays), except for a reference to another field, an
274
+ * element of an array of numbers, and below a tuple or a union of several
275
+ * types, where the server does not set the field (`@db.onUpdate.inc` is
276
+ * top-level only). `"create"` (default) — the field stays editable: the
277
+ * server only fills it when the value is left out and it has
278
+ * `@db.default.now`, or is an `@db.onUpdate.inc` counter (`0`). Since
279
+ * 0.1.154; `@db.onUpdate.inc` since 0.1.159.
277
280
  */
278
281
  mode?: "create" | "edit";
279
282
  }
@@ -285,8 +288,8 @@ interface CreateFormDefOptions {
285
288
  * with `path: ''`.
286
289
  *
287
290
  * A `@db.column.derived` field is marked `derived` straight from its metadata;
288
- * a computed view column, from `opts.metaFields`; an `@db.onUpdate.now` field,
289
- * when `opts.mode` is `"edit"`.
291
+ * a computed view column, from `opts.metaFields`; an update-stamped field
292
+ * (see `CreateFormDefOptions.mode`), when `opts.mode` is `"edit"`.
290
293
  */
291
294
  declare function createFormDef(type: TAtscriptAnnotatedType, opts?: CreateFormDefOptions): FormDef;
292
295
  /**
@@ -693,6 +696,9 @@ declare function getDefaultValidatorPlugins(): TValidatorPlugin[];
693
696
  * ATScript's @expect.* validation runs automatically; server-managed db
694
697
  * fields (every `derived` field, absent `@db.default*` / version) pass.
695
698
  * For custom `ui.fn.*` validators, install ui-fns and pass its plugin via `opts.plugins`.
699
+ *
700
+ * Errors are keyed by dotted path. A root-level error (a failing
701
+ * `@ui.form.validate` on the form's interface) is keyed `__form`.
696
702
  */
697
703
  declare function getFormValidator(def: FormDef, opts?: Partial<TValidatorOptions>): (callOpts: TFormValidatorCallOptions) => Record<string, string>;
698
704
  /** Options for createFieldValidator. */
@@ -700,6 +706,12 @@ interface TFieldValidatorOptions {
700
706
  /** Only report errors at the root path (for structure/array container validation). */
701
707
  rootOnly?: boolean;
702
708
  }
709
+ /**
710
+ * Whether a type kind is a container that carries its own children:
711
+ * `object`, `array` or `tuple`. Union / intersection kinds are not
712
+ * containers — they evaluate their branches at their own path.
713
+ */
714
+ declare function isContainerKind(kind: string): boolean;
703
715
  /**
704
716
  * Creates a cached validator function for a single ATScript prop.
705
717
  *
@@ -954,6 +966,19 @@ declare function unionVariantChanged(def: FormDef, before: Record<string, unknow
954
966
  * - Values may be `string | undefined`; falsy entries are dropped on
955
967
  * merge.
956
968
  */
969
+ /** Error-map key of the form-level error. */
970
+ declare const FORM_ERROR_KEY = "__form";
971
+ /**
972
+ * Turn a validator's error list into an error map keyed by path. A
973
+ * root-level error (empty path) becomes the form-level error
974
+ * ({@link FORM_ERROR_KEY}). The first error per path wins: a failing
975
+ * container rule is reported before the container's own shape / length
976
+ * checks at the same path.
977
+ */
978
+ declare function validatorErrorsToMap(errors: ReadonlyArray<{
979
+ path: string;
980
+ message: string;
981
+ }>): Record<string, string>;
957
982
  /**
958
983
  * Merge any number of partial error maps into a single dense
959
984
  * `Record<path, message>`. Falsy values are skipped — later sources do
@@ -1665,4 +1690,4 @@ interface TModelRoute {
1665
1690
  */
1666
1691
  declare function buildModelRoutes(models: readonly TAtscriptAnnotatedType[]): TModelRoute[];
1667
1692
  //#endregion
1668
- export { type ClientFactory, type ClientFactoryOptions, type CloneUnwrap, type ColumnDef, type ColumnValueKind, type CreateFormDefOptions, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaEntryOptions, type MetaResponse, NUMERIC_VALUE_KINDS, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TModelRoute, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, 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, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, onMetaCacheReset, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, retainMetaEntry, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setMetaCacheMaxEntries, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
1693
+ export { type ClientFactory, type ClientFactoryOptions, type CloneUnwrap, type ColumnDef, type ColumnValueKind, type CreateFormDefOptions, type CurrencyDisplay, DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, type DecimalParts, EXPECT_MAX_LENGTH, FORM_ERROR_KEY, type FieldMeta, type FieldResolver, type FormActionInfo, type FormArrayFieldDef, type FormDef, type FormDiffOptions, type FormDiffResult, type FormFieldChange, type FormFieldDef, type FormObjectFieldDef, type FormRebaseOptions, type FormRebaseResult, type FormTupleFieldDef, type FormUnionFieldDef, type FormUnionVariant, type FormatDecimalOptions, type GridSpanArgs, type GridSpec, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, type MeasurementInfo, type MetaCacheEntry, type MetaEntryOptions, type MetaResponse, NUMERIC_VALUE_KINDS, type PaginationControl, type RelationInfo, type ResolvedValueHelp, type SearchIndexInfo, type SortControl, StaticFieldResolver, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TFieldValidatorOptions, type TFormAction, type TFormEntryOptions, type TFormValidatorCallOptions, type TFormValueResolver, type TModelRoute, type TResolveOptions, type TableActionsModel, type TableDef, type TableQueryState, 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, ValueHelpClient, type ValueHelpInfo, type ValueHelpResult, type ValueHelpSearchOptions, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isContainerKind, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, onMetaCacheReset, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, retainMetaEntry, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setMetaCacheMaxEntries, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, validatorErrorsToMap, valueHelpDictPaths };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Validator, createDataFromAnnotatedType, deserializeAnnotatedType, detectDiscriminator, flattenAnnotatedType } from "@atscript/typescript/utils";
2
+ import { createDbValidatorPlugin, isServerStampedOnUpdate } from "@atscript/db/validator";
2
3
  import { Client, actionIdentifier, clearMetaStore, defaultMetaStore, encodeNavigateId } from "@atscript/db-client";
3
- import { createDbValidatorPlugin } from "@atscript/db/validator";
4
4
  //#region src/shared/annotation-keys.ts
5
5
  const UI_TYPE = "ui.type";
6
6
  const UI_FORM_PLACEHOLDER = "ui.form.placeholder";
@@ -443,8 +443,8 @@ const EDIT = { mode: "edit" };
443
443
  * with `path: ''`.
444
444
  *
445
445
  * A `@db.column.derived` field is marked `derived` straight from its metadata;
446
- * a computed view column, from `opts.metaFields`; an `@db.onUpdate.now` field,
447
- * when `opts.mode` is `"edit"`.
446
+ * a computed view column, from `opts.metaFields`; an update-stamped field
447
+ * (see `CreateFormDefOptions.mode`), when `opts.mode` is `"edit"`.
448
448
  */
449
449
  function createFormDef(type, opts) {
450
450
  const edit = opts?.mode === "edit";
@@ -725,14 +725,14 @@ function createVariant(def, edit) {
725
725
  };
726
726
  }
727
727
  /**
728
- * `@db.onUpdate.now` (`number.timestamp.updated`): the server sets the field
729
- * on every update. Read off the prop, or — as `@atscript/db` does — off the one
730
- * value member of `T | null`, unless the prop references another field.
728
+ * An update-stamped field (see `CreateFormDefOptions.mode`). Read off the prop,
729
+ * or — as `@atscript/db` does — off the one value member of `T | null`, unless
730
+ * the prop references another field.
731
731
  */
732
732
  function isUpdateStamped(prop) {
733
- if (hasFieldMeta(prop, "db.onUpdate.now")) return true;
733
+ if (isServerStampedOnUpdate(prop.metadata)) return true;
734
734
  const member = prop.ref?.field ? void 0 : soleValueMember(prop);
735
- return member !== void 0 && hasFieldMeta(member, "db.onUpdate.now");
735
+ return member !== void 0 && isServerStampedOnUpdate(member.metadata);
736
736
  }
737
737
  /** The one non-`null` / `undefined` member of a (nested) union, if there is exactly one. */
738
738
  function soleValueMember(prop) {
@@ -1785,6 +1785,97 @@ function deepClone(value, unwrap) {
1785
1785
  return out;
1786
1786
  }
1787
1787
  //#endregion
1788
+ //#region src/form/error-utils.ts
1789
+ /**
1790
+ * Framework-agnostic helpers for working with form-error maps keyed by
1791
+ * dotted path. Used by AsForm to drive error badges and auto-open
1792
+ * collapsed sections; safe to share with React (or any other) bindings.
1793
+ *
1794
+ * Convention:
1795
+ * - Keys are dotted paths (`a.b.c`); empty string and `__form` denote
1796
+ * the form-level error.
1797
+ * - Values may be `string | undefined`; falsy entries are dropped on
1798
+ * merge.
1799
+ */
1800
+ /** Error-map key of the form-level error. */
1801
+ const FORM_ERROR_KEY = "__form";
1802
+ /**
1803
+ * Turn a validator's error list into an error map keyed by path. A
1804
+ * root-level error (empty path) becomes the form-level error
1805
+ * ({@link FORM_ERROR_KEY}). The first error per path wins: a failing
1806
+ * container rule is reported before the container's own shape / length
1807
+ * checks at the same path.
1808
+ */
1809
+ function validatorErrorsToMap(errors) {
1810
+ const out = {};
1811
+ for (const err of errors) out[err.path || "__form"] ??= err.message;
1812
+ return out;
1813
+ }
1814
+ /**
1815
+ * Merge any number of partial error maps into a single dense
1816
+ * `Record<path, message>`. Falsy values are skipped — later sources do
1817
+ * NOT overwrite earlier ones with an empty value.
1818
+ */
1819
+ function mergeErrorMaps(...maps) {
1820
+ const merged = {};
1821
+ for (const m of maps) {
1822
+ if (!m) continue;
1823
+ for (const k of Object.keys(m)) {
1824
+ const v = m[k];
1825
+ if (v) merged[k] = v;
1826
+ }
1827
+ }
1828
+ return merged;
1829
+ }
1830
+ /**
1831
+ * Return `errors` without the entries whose key is in `paths`.
1832
+ *
1833
+ * Identity-preserving: when no key matches, the ORIGINAL `errors` object
1834
+ * is returned unchanged — callers compare `result !== errors` to detect
1835
+ * that something was pruned and skip spurious reactive writes.
1836
+ */
1837
+ function omitPaths(errors, paths) {
1838
+ let pruned = null;
1839
+ for (const key in errors) if (paths.has(key)) {
1840
+ pruned ??= { ...errors };
1841
+ delete pruned[key];
1842
+ }
1843
+ return pruned ?? errors;
1844
+ }
1845
+ /**
1846
+ * Yield every ancestor prefix of a dotted path, longest-first
1847
+ * (`a.b.c` → `a.b.c`, `a.b`, `a`). Returns the path itself first so
1848
+ * callers can include it in the iteration without a special case.
1849
+ *
1850
+ * Empty paths and the form-level key (`__form`) yield nothing.
1851
+ */
1852
+ function* iteratePathAncestors(path) {
1853
+ if (!path || path === "__form") return;
1854
+ let pos = path.length;
1855
+ while (pos > 0) {
1856
+ yield path.slice(0, pos);
1857
+ const dot = path.lastIndexOf(".", pos - 1);
1858
+ if (dot < 0) return;
1859
+ pos = dot;
1860
+ }
1861
+ }
1862
+ /**
1863
+ * Build an indexed `Map<absolutePath, descendantErrorCount>` so each
1864
+ * struct in the tree can render an error-count badge in O(1).
1865
+ *
1866
+ * For every error path, the count is incremented on the path itself
1867
+ * AND every dotted-path ancestor — so a struct at `a.b` reports the
1868
+ * total of all errors at `a.b` or below.
1869
+ */
1870
+ function buildDescendantErrorCounts(errors) {
1871
+ const map = /* @__PURE__ */ new Map();
1872
+ for (const errPath of Object.keys(errors)) {
1873
+ if (!errors[errPath]) continue;
1874
+ for (const prefix of iteratePathAncestors(errPath)) map.set(prefix, (map.get(prefix) ?? 0) + 1);
1875
+ }
1876
+ return map;
1877
+ }
1878
+ //#endregion
1788
1879
  //#region src/form/validate.ts
1789
1880
  const dbPlugin = createDbValidatorPlugin();
1790
1881
  const INSERT_CONTEXT = { mode: "insert" };
@@ -1793,8 +1884,9 @@ const INSERT_CONTEXT = { mode: "insert" };
1793
1884
  * blocked on them:
1794
1885
  * - `@db.column.derived` — read-only and server-computed: never validated
1795
1886
  * (not even a loaded value, which the user could not fix).
1796
- * - an absent `@db.default*` / `@db.column.version` value — delegated to
1797
- * `@atscript/db`'s own insert-mode rule, so the key list has one owner.
1887
+ * - an absent `@db.default*` / `@db.column.version` / `@db.onUpdate.inc` value
1888
+ * — delegated to `@atscript/db`'s own insert-mode rule, so the key list has
1889
+ * one owner.
1798
1890
  * `db.rel.FK` is kept out: a form fills the FK itself (no nested nav
1799
1891
  * object), so an empty required FK must still fail.
1800
1892
  *
@@ -1809,10 +1901,11 @@ const serverManagedPlugin = (ctx, def, value) => {
1809
1901
  };
1810
1902
  /**
1811
1903
  * The props of the fields `createFormDef` marked `derived`, at any depth — a
1812
- * computed view column (`metaFields`) or an edit form's `@db.onUpdate.now`
1813
- * field carries no annotation the plugin above could read. The validator
1814
- * matches by prop, so a prop that is also used where it is not derived (an
1815
- * interface's stamp below a union of several types, too) stays validated.
1904
+ * computed view column (`metaFields`) or an edit form's update-stamped field
1905
+ * (see `CreateFormDefOptions.mode`) carries no annotation the plugin above
1906
+ * could read. The validator matches by prop, so a prop that is also used where
1907
+ * it is not derived (an interface's stamp below a union of several types, too)
1908
+ * stays validated.
1816
1909
  */
1817
1910
  function collectDerivedProps(def) {
1818
1911
  const derived = /* @__PURE__ */ new Set();
@@ -1853,6 +1946,9 @@ function getDefaultValidatorPlugins() {
1853
1946
  * ATScript's @expect.* validation runs automatically; server-managed db
1854
1947
  * fields (every `derived` field, absent `@db.default*` / version) pass.
1855
1948
  * For custom `ui.fn.*` validators, install ui-fns and pass its plugin via `opts.plugins`.
1949
+ *
1950
+ * Errors are keyed by dotted path. A root-level error (a failing
1951
+ * `@ui.form.validate` on the form's interface) is keyed `__form`.
1856
1952
  */
1857
1953
  function getFormValidator(def, opts) {
1858
1954
  const derived = collectDerivedProps(def);
@@ -1872,9 +1968,7 @@ function getFormValidator(def, opts) {
1872
1968
  data: callOpts.data,
1873
1969
  context: callOpts.context ?? {}
1874
1970
  })) return {};
1875
- const errors = {};
1876
- for (const err of validator.errors) errors[err.path] = err.message;
1877
- return errors;
1971
+ return validatorErrorsToMap(validator.errors);
1878
1972
  };
1879
1973
  }
1880
1974
  /**
@@ -1886,8 +1980,12 @@ function getFormValidator(def, opts) {
1886
1980
  * a branch's verdict depends on its children — those keep the full walk.
1887
1981
  */
1888
1982
  const skipDescendantsPlugin = (ctx) => ctx.path === "" ? void 0 : true;
1889
- function skipsDescendants(prop) {
1890
- const kind = prop.type.kind;
1983
+ /**
1984
+ * Whether a type kind is a container that carries its own children:
1985
+ * `object`, `array` or `tuple`. Union / intersection kinds are not
1986
+ * containers — they evaluate their branches at their own path.
1987
+ */
1988
+ function isContainerKind(kind) {
1891
1989
  return kind === "object" || kind === "array" || kind === "tuple";
1892
1990
  }
1893
1991
  /**
@@ -1901,7 +1999,7 @@ function skipsDescendants(prop) {
1901
1999
  function createFieldValidator(prop, opts) {
1902
2000
  let cached;
1903
2001
  return (value, externalCtx) => {
1904
- cached ??= new Validator(prop, { plugins: opts?.rootOnly && skipsDescendants(prop) ? [
2002
+ cached ??= new Validator(prop, { plugins: opts?.rootOnly && isContainerKind(prop.type.kind) ? [
1905
2003
  skipDescendantsPlugin,
1906
2004
  serverManagedPlugin,
1907
2005
  ...defaultValidatorPlugins
@@ -2564,84 +2662,6 @@ function walkUnionFields(fields, prefix, before, after) {
2564
2662
  return false;
2565
2663
  }
2566
2664
  //#endregion
2567
- //#region src/form/error-utils.ts
2568
- /**
2569
- * Framework-agnostic helpers for working with form-error maps keyed by
2570
- * dotted path. Used by AsForm to drive error badges and auto-open
2571
- * collapsed sections; safe to share with React (or any other) bindings.
2572
- *
2573
- * Convention:
2574
- * - Keys are dotted paths (`a.b.c`); empty string and `__form` denote
2575
- * the form-level error.
2576
- * - Values may be `string | undefined`; falsy entries are dropped on
2577
- * merge.
2578
- */
2579
- const FORM_ERROR_KEY = "__form";
2580
- /**
2581
- * Merge any number of partial error maps into a single dense
2582
- * `Record<path, message>`. Falsy values are skipped — later sources do
2583
- * NOT overwrite earlier ones with an empty value.
2584
- */
2585
- function mergeErrorMaps(...maps) {
2586
- const merged = {};
2587
- for (const m of maps) {
2588
- if (!m) continue;
2589
- for (const k of Object.keys(m)) {
2590
- const v = m[k];
2591
- if (v) merged[k] = v;
2592
- }
2593
- }
2594
- return merged;
2595
- }
2596
- /**
2597
- * Return `errors` without the entries whose key is in `paths`.
2598
- *
2599
- * Identity-preserving: when no key matches, the ORIGINAL `errors` object
2600
- * is returned unchanged — callers compare `result !== errors` to detect
2601
- * that something was pruned and skip spurious reactive writes.
2602
- */
2603
- function omitPaths(errors, paths) {
2604
- let pruned = null;
2605
- for (const key in errors) if (paths.has(key)) {
2606
- pruned ??= { ...errors };
2607
- delete pruned[key];
2608
- }
2609
- return pruned ?? errors;
2610
- }
2611
- /**
2612
- * Yield every ancestor prefix of a dotted path, longest-first
2613
- * (`a.b.c` → `a.b.c`, `a.b`, `a`). Returns the path itself first so
2614
- * callers can include it in the iteration without a special case.
2615
- *
2616
- * Empty paths and the form-level key (`__form`) yield nothing.
2617
- */
2618
- function* iteratePathAncestors(path) {
2619
- if (!path || path === FORM_ERROR_KEY) return;
2620
- let pos = path.length;
2621
- while (pos > 0) {
2622
- yield path.slice(0, pos);
2623
- const dot = path.lastIndexOf(".", pos - 1);
2624
- if (dot < 0) return;
2625
- pos = dot;
2626
- }
2627
- }
2628
- /**
2629
- * Build an indexed `Map<absolutePath, descendantErrorCount>` so each
2630
- * struct in the tree can render an error-count badge in O(1).
2631
- *
2632
- * For every error path, the count is incremented on the path itself
2633
- * AND every dotted-path ancestor — so a struct at `a.b` reports the
2634
- * total of all errors at `a.b` or below.
2635
- */
2636
- function buildDescendantErrorCounts(errors) {
2637
- const map = /* @__PURE__ */ new Map();
2638
- for (const errPath of Object.keys(errors)) {
2639
- if (!errors[errPath]) continue;
2640
- for (const prefix of iteratePathAncestors(errPath)) map.set(prefix, (map.get(prefix) ?? 0) + 1);
2641
- }
2642
- return map;
2643
- }
2644
- //#endregion
2645
2665
  //#region src/form/grid.ts
2646
2666
  /** Grid layout parsing for `@ui.form.grid.colSpan` / `@ui.form.grid.rowSpan`. */
2647
2667
  const DEFAULT_COL_SPAN = 12;
@@ -3156,4 +3176,4 @@ function resolvePath(model, table, view) {
3156
3176
  return path.length > 0 ? path : void 0;
3157
3177
  }
3158
3178
  //#endregion
3159
- export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, NUMERIC_VALUE_KINDS, StaticFieldResolver, 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, ValueHelpClient, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, onMetaCacheReset, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, retainMetaEntry, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setMetaCacheMaxEntries, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
3179
+ export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, EXPECT_MAX_LENGTH, FORM_ERROR_KEY, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, NUMERIC_VALUE_KINDS, StaticFieldResolver, 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, ValueHelpClient, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaCacheIdentity, getMetaEntry, getMetaTableDef, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, invalidateValueHelpCache, isArrayField, isContainerKind, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, onMetaCacheReset, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, retainMetaEntry, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setMetaCacheIdentity, setMetaCacheMaxEntries, setResolver, setValueHelpCacheTtl, splitDecimalString, str, unionVariantChanged, validatorErrorsToMap, valueHelpDictPaths };
package/dist/plugin.cjs CHANGED
@@ -217,7 +217,7 @@ function validateValueHelp(token, args, doc) {
217
217
  severity: ERROR,
218
218
  range: token.range
219
219
  });
220
- errors.push(...(0, _atscript_db_shared.validateExclusiveWith)(token, "@ui.valueHelp", [{ key: "ui.valueHelp.distinct" }]));
220
+ errors.push(...(0, _atscript_db_shared.validateExclusiveWith)(token, "@ui.valueHelp", [{ key: "ui.valueHelp.distinct" }], doc));
221
221
  if (!targetArg) return errors;
222
222
  const targetErrors = (0, _atscript_db_shared.validateRefArgument)(targetArg, doc, {
223
223
  accept: isValueHelpTarget,
package/dist/plugin.mjs CHANGED
@@ -217,7 +217,7 @@ function validateValueHelp(token, args, doc) {
217
217
  severity: ERROR,
218
218
  range: token.range
219
219
  });
220
- errors.push(...validateExclusiveWith(token, "@ui.valueHelp", [{ key: "ui.valueHelp.distinct" }]));
220
+ errors.push(...validateExclusiveWith(token, "@ui.valueHelp", [{ key: "ui.valueHelp.distinct" }], doc));
221
221
  if (!targetArg) return errors;
222
222
  const targetErrors = validateRefArgument(targetArg, doc, {
223
223
  accept: isValueHelpTarget,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/ui",
3
- "version": "0.1.157",
3
+ "version": "0.1.159",
4
4
  "description": "Framework-agnostic runtime for form and table definitions from atscript annotated types",
5
5
  "keywords": [
6
6
  "annotations",
@@ -47,20 +47,20 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@atscript/db-client": "^0.1.159"
50
+ "@atscript/db-client": "^0.1.163"
51
51
  },
52
52
  "devDependencies": {
53
- "@atscript/core": "^0.1.107",
54
- "@atscript/db": "^0.1.159",
55
- "@atscript/typescript": "^0.1.107",
53
+ "@atscript/core": "^0.1.109",
54
+ "@atscript/db": "^0.1.163",
55
+ "@atscript/typescript": "^0.1.109",
56
56
  "@uniqu/core": "^0.1.15",
57
- "unplugin-atscript": "^0.1.107",
57
+ "unplugin-atscript": "^0.1.109",
58
58
  "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14"
59
59
  },
60
60
  "peerDependencies": {
61
- "@atscript/core": "^0.1.107",
62
- "@atscript/db": "^0.1.159",
63
- "@atscript/typescript": "^0.1.107"
61
+ "@atscript/core": "^0.1.109",
62
+ "@atscript/db": "^0.1.163",
63
+ "@atscript/typescript": "^0.1.109"
64
64
  },
65
65
  "scripts": {
66
66
  "build": "vp pack",