@atscript/ui 0.1.158 → 0.1.160

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) {
@@ -1885,8 +1885,9 @@ const INSERT_CONTEXT = { mode: "insert" };
1885
1885
  * blocked on them:
1886
1886
  * - `@db.column.derived` — read-only and server-computed: never validated
1887
1887
  * (not even a loaded value, which the user could not fix).
1888
- * - an absent `@db.default*` / `@db.column.version` value — delegated to
1889
- * `@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.
1890
1891
  * `db.rel.FK` is kept out: a form fills the FK itself (no nested nav
1891
1892
  * object), so an empty required FK must still fail.
1892
1893
  *
@@ -1901,10 +1902,11 @@ const serverManagedPlugin = (ctx, def, value) => {
1901
1902
  };
1902
1903
  /**
1903
1904
  * The props of the fields `createFormDef` marked `derived`, at any depth — a
1904
- * computed view column (`metaFields`) or an edit form's `@db.onUpdate.now`
1905
- * field carries no annotation the plugin above could read. The validator
1906
- * matches by prop, so a prop that is also used where it is not derived (an
1907
- * 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.
1908
1910
  */
1909
1911
  function collectDerivedProps(def) {
1910
1912
  const derived = /* @__PURE__ */ new Set();
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
  /**
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
  /**
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) {
@@ -1884,8 +1884,9 @@ const INSERT_CONTEXT = { mode: "insert" };
1884
1884
  * blocked on them:
1885
1885
  * - `@db.column.derived` — read-only and server-computed: never validated
1886
1886
  * (not even a loaded value, which the user could not fix).
1887
- * - an absent `@db.default*` / `@db.column.version` value — delegated to
1888
- * `@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.
1889
1890
  * `db.rel.FK` is kept out: a form fills the FK itself (no nested nav
1890
1891
  * object), so an empty required FK must still fail.
1891
1892
  *
@@ -1900,10 +1901,11 @@ const serverManagedPlugin = (ctx, def, value) => {
1900
1901
  };
1901
1902
  /**
1902
1903
  * The props of the fields `createFormDef` marked `derived`, at any depth — a
1903
- * computed view column (`metaFields`) or an edit form's `@db.onUpdate.now`
1904
- * field carries no annotation the plugin above could read. The validator
1905
- * matches by prop, so a prop that is also used where it is not derived (an
1906
- * 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.
1907
1909
  */
1908
1910
  function collectDerivedProps(def) {
1909
1911
  const derived = /* @__PURE__ */ new Set();
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.158",
3
+ "version": "0.1.160",
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.161"
50
+ "@atscript/db-client": "^0.1.164"
51
51
  },
52
52
  "devDependencies": {
53
- "@atscript/core": "^0.1.108",
54
- "@atscript/db": "^0.1.161",
55
- "@atscript/typescript": "^0.1.108",
53
+ "@atscript/core": "^0.1.109",
54
+ "@atscript/db": "^0.1.164",
55
+ "@atscript/typescript": "^0.1.109",
56
56
  "@uniqu/core": "^0.1.15",
57
- "unplugin-atscript": "^0.1.108",
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.108",
62
- "@atscript/db": "^0.1.161",
63
- "@atscript/typescript": "^0.1.108"
61
+ "@atscript/core": "^0.1.109",
62
+ "@atscript/db": "^0.1.164",
63
+ "@atscript/typescript": "^0.1.109"
64
64
  },
65
65
  "scripts": {
66
66
  "build": "vp pack",