@atscript/ui 0.1.71 → 0.1.73

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
@@ -282,8 +282,12 @@ const UI_TAGS = new Set([
282
282
  * - **Object types** (`kind === 'object'`): produces an object root with nested fields.
283
283
  * - **Non-object types** (primitive, array, union, etc.): produces a single leaf root field
284
284
  * with `path: ''`.
285
+ *
286
+ * @param opts.versionColumn - Name of a server-managed OCC version column to
287
+ * exclude from `fields[]` (it stays in `flatMap` so the wire payload is
288
+ * unchanged). Root-table concept; not propagated into nested recursive calls.
285
289
  */
286
- function createFormDef(type) {
290
+ function createFormDef(type, opts) {
287
291
  if (type.type.kind !== "object") {
288
292
  const rootField = createFieldDef("", type);
289
293
  return {
@@ -299,6 +303,7 @@ function createFormDef(type) {
299
303
  const structuredPrefixes = /* @__PURE__ */ new Set();
300
304
  for (const [path, prop] of flatMap.entries()) {
301
305
  if (path === "") continue;
306
+ if (path === opts?.versionColumn) continue;
302
307
  if (isChildOfStructured(path, structuredPrefixes)) continue;
303
308
  const originalProp = resolveOriginalProp(objectType, path) ?? prop;
304
309
  const kind = originalProp.type.kind;
@@ -687,12 +692,14 @@ function resetValueHelpCache() {
687
692
  }
688
693
  function buildResolved(url, meta, targetType) {
689
694
  const objectType = targetType.type.kind === "object" ? targetType.type : void 0;
695
+ const versionColumn = meta.versionColumn;
690
696
  const primaryKeys = [];
691
697
  let labelField;
692
698
  let descrField;
693
699
  const attrFields = [];
694
700
  let firstStringField;
695
701
  if (objectType) for (const [name, fieldProp] of objectType.props) {
702
+ if (name === versionColumn) continue;
696
703
  const isPK = fieldProp.metadata.has(META_ID);
697
704
  if (isPK) primaryKeys.push(name);
698
705
  if (fieldProp.metadata.has("ui.dict.label")) labelField = name;
@@ -705,6 +712,7 @@ function buildResolved(url, meta, targetType) {
705
712
  const filterableFields = [];
706
713
  const sortableFields = [];
707
714
  if (meta.fields) for (const [name, fm] of Object.entries(meta.fields)) {
715
+ if (name === versionColumn) continue;
708
716
  if (fm?.filterable) filterableFields.push(name);
709
717
  if (fm?.sortable) sortableFields.push(name);
710
718
  }
@@ -1375,6 +1383,7 @@ function createTableDef(meta, preDeserializedType) {
1375
1383
  const columns = [];
1376
1384
  for (const [path, prop] of flatMap.entries()) {
1377
1385
  if (path === "") continue;
1386
+ if (path === meta.versionColumn) continue;
1378
1387
  if (!(path in meta.fields)) {
1379
1388
  const kind = prop.type.kind;
1380
1389
  if (path.includes(".") || kind === "object" || kind === "array") continue;
@@ -1412,6 +1421,7 @@ function createTableDef(meta, preDeserializedType) {
1412
1421
  flatMap,
1413
1422
  primaryKeys: meta.primaryKeys,
1414
1423
  preferredId: meta.preferredId ?? meta.primaryKeys,
1424
+ versionColumn: meta.versionColumn,
1415
1425
  crud,
1416
1426
  canRemove: "remove" in crud,
1417
1427
  actions,
package/dist/index.d.cts CHANGED
@@ -203,8 +203,14 @@ declare function isTupleField(field: FormFieldDef): field is FormTupleFieldDef;
203
203
  * - **Object types** (`kind === 'object'`): produces an object root with nested fields.
204
204
  * - **Non-object types** (primitive, array, union, etc.): produces a single leaf root field
205
205
  * with `path: ''`.
206
+ *
207
+ * @param opts.versionColumn - Name of a server-managed OCC version column to
208
+ * exclude from `fields[]` (it stays in `flatMap` so the wire payload is
209
+ * unchanged). Root-table concept; not propagated into nested recursive calls.
206
210
  */
207
- declare function createFormDef(type: TAtscriptAnnotatedType): FormDef;
211
+ declare function createFormDef(type: TAtscriptAnnotatedType, opts?: {
212
+ versionColumn?: string;
213
+ }): FormDef;
208
214
  /**
209
215
  * Builds union variant definitions from a union annotated type.
210
216
  * Iterates top-level items directly — one variant per item.
@@ -673,6 +679,15 @@ interface MetaResponse {
673
679
  * construction for action POSTs and `'navigate'` URL `$1` substitution.
674
680
  */
675
681
  preferredId: string[];
682
+ /**
683
+ * Server-managed OCC column name (from `@db.column.version`). When present,
684
+ * names a normal `int` field that ships with rows like any other column.
685
+ * Consumers MUST keep the field's value in update payloads — the server
686
+ * auto-lifts it to `$cas` to detect concurrent writes — but MUST NOT render
687
+ * it as a user-facing column, filter, or sorter. `createTableDef` skips it
688
+ * from the generated `columns[]` array on this basis.
689
+ */
690
+ versionColumn?: string;
676
691
  crud: TCrudPermissions$1;
677
692
  actions: TDbActionInfo$1[];
678
693
  relations: RelationInfo[];
@@ -709,6 +724,8 @@ interface TableDef {
709
724
  primaryKeys: string[];
710
725
  /** Preferred row identifier — see `MetaResponse.preferredId`. */
711
726
  preferredId: string[];
727
+ /** Server-managed OCC column name — see `MetaResponse.versionColumn`. */
728
+ versionColumn?: string;
712
729
  /** Per-op CRUD permissions advertised in `/meta`. Key absent → denied. */
713
730
  crud: TCrudPermissions$1;
714
731
  canRemove: boolean;
package/dist/index.d.mts CHANGED
@@ -203,8 +203,14 @@ declare function isTupleField(field: FormFieldDef): field is FormTupleFieldDef;
203
203
  * - **Object types** (`kind === 'object'`): produces an object root with nested fields.
204
204
  * - **Non-object types** (primitive, array, union, etc.): produces a single leaf root field
205
205
  * with `path: ''`.
206
+ *
207
+ * @param opts.versionColumn - Name of a server-managed OCC version column to
208
+ * exclude from `fields[]` (it stays in `flatMap` so the wire payload is
209
+ * unchanged). Root-table concept; not propagated into nested recursive calls.
206
210
  */
207
- declare function createFormDef(type: TAtscriptAnnotatedType): FormDef;
211
+ declare function createFormDef(type: TAtscriptAnnotatedType, opts?: {
212
+ versionColumn?: string;
213
+ }): FormDef;
208
214
  /**
209
215
  * Builds union variant definitions from a union annotated type.
210
216
  * Iterates top-level items directly — one variant per item.
@@ -673,6 +679,15 @@ interface MetaResponse {
673
679
  * construction for action POSTs and `'navigate'` URL `$1` substitution.
674
680
  */
675
681
  preferredId: string[];
682
+ /**
683
+ * Server-managed OCC column name (from `@db.column.version`). When present,
684
+ * names a normal `int` field that ships with rows like any other column.
685
+ * Consumers MUST keep the field's value in update payloads — the server
686
+ * auto-lifts it to `$cas` to detect concurrent writes — but MUST NOT render
687
+ * it as a user-facing column, filter, or sorter. `createTableDef` skips it
688
+ * from the generated `columns[]` array on this basis.
689
+ */
690
+ versionColumn?: string;
676
691
  crud: TCrudPermissions$1;
677
692
  actions: TDbActionInfo$1[];
678
693
  relations: RelationInfo[];
@@ -709,6 +724,8 @@ interface TableDef {
709
724
  primaryKeys: string[];
710
725
  /** Preferred row identifier — see `MetaResponse.preferredId`. */
711
726
  preferredId: string[];
727
+ /** Server-managed OCC column name — see `MetaResponse.versionColumn`. */
728
+ versionColumn?: string;
712
729
  /** Per-op CRUD permissions advertised in `/meta`. Key absent → denied. */
713
730
  crud: TCrudPermissions$1;
714
731
  canRemove: boolean;
package/dist/index.mjs CHANGED
@@ -281,8 +281,12 @@ const UI_TAGS = new Set([
281
281
  * - **Object types** (`kind === 'object'`): produces an object root with nested fields.
282
282
  * - **Non-object types** (primitive, array, union, etc.): produces a single leaf root field
283
283
  * with `path: ''`.
284
+ *
285
+ * @param opts.versionColumn - Name of a server-managed OCC version column to
286
+ * exclude from `fields[]` (it stays in `flatMap` so the wire payload is
287
+ * unchanged). Root-table concept; not propagated into nested recursive calls.
284
288
  */
285
- function createFormDef(type) {
289
+ function createFormDef(type, opts) {
286
290
  if (type.type.kind !== "object") {
287
291
  const rootField = createFieldDef("", type);
288
292
  return {
@@ -298,6 +302,7 @@ function createFormDef(type) {
298
302
  const structuredPrefixes = /* @__PURE__ */ new Set();
299
303
  for (const [path, prop] of flatMap.entries()) {
300
304
  if (path === "") continue;
305
+ if (path === opts?.versionColumn) continue;
301
306
  if (isChildOfStructured(path, structuredPrefixes)) continue;
302
307
  const originalProp = resolveOriginalProp(objectType, path) ?? prop;
303
308
  const kind = originalProp.type.kind;
@@ -686,12 +691,14 @@ function resetValueHelpCache() {
686
691
  }
687
692
  function buildResolved(url, meta, targetType) {
688
693
  const objectType = targetType.type.kind === "object" ? targetType.type : void 0;
694
+ const versionColumn = meta.versionColumn;
689
695
  const primaryKeys = [];
690
696
  let labelField;
691
697
  let descrField;
692
698
  const attrFields = [];
693
699
  let firstStringField;
694
700
  if (objectType) for (const [name, fieldProp] of objectType.props) {
701
+ if (name === versionColumn) continue;
695
702
  const isPK = fieldProp.metadata.has(META_ID);
696
703
  if (isPK) primaryKeys.push(name);
697
704
  if (fieldProp.metadata.has("ui.dict.label")) labelField = name;
@@ -704,6 +711,7 @@ function buildResolved(url, meta, targetType) {
704
711
  const filterableFields = [];
705
712
  const sortableFields = [];
706
713
  if (meta.fields) for (const [name, fm] of Object.entries(meta.fields)) {
714
+ if (name === versionColumn) continue;
707
715
  if (fm?.filterable) filterableFields.push(name);
708
716
  if (fm?.sortable) sortableFields.push(name);
709
717
  }
@@ -1374,6 +1382,7 @@ function createTableDef(meta, preDeserializedType) {
1374
1382
  const columns = [];
1375
1383
  for (const [path, prop] of flatMap.entries()) {
1376
1384
  if (path === "") continue;
1385
+ if (path === meta.versionColumn) continue;
1377
1386
  if (!(path in meta.fields)) {
1378
1387
  const kind = prop.type.kind;
1379
1388
  if (path.includes(".") || kind === "object" || kind === "array") continue;
@@ -1411,6 +1420,7 @@ function createTableDef(meta, preDeserializedType) {
1411
1420
  flatMap,
1412
1421
  primaryKeys: meta.primaryKeys,
1413
1422
  preferredId: meta.preferredId ?? meta.primaryKeys,
1423
+ versionColumn: meta.versionColumn,
1414
1424
  crud,
1415
1425
  canRemove: "remove" in crud,
1416
1426
  actions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/ui",
3
- "version": "0.1.71",
3
+ "version": "0.1.73",
4
4
  "description": "Framework-agnostic runtime for form and table definitions from atscript annotated types",
5
5
  "keywords": [
6
6
  "annotations",
@@ -46,18 +46,18 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "@atscript/db-client": "^0.1.82"
49
+ "@atscript/db-client": "^0.1.85"
50
50
  },
51
51
  "devDependencies": {
52
- "@atscript/core": "^0.1.58",
53
- "@atscript/db": "^0.1.82",
54
- "@atscript/typescript": "^0.1.58",
55
- "unplugin-atscript": "^0.1.58",
52
+ "@atscript/core": "^0.1.59",
53
+ "@atscript/db": "^0.1.85",
54
+ "@atscript/typescript": "^0.1.59",
55
+ "unplugin-atscript": "^0.1.59",
56
56
  "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14"
57
57
  },
58
58
  "peerDependencies": {
59
- "@atscript/core": "^0.1.58",
60
- "@atscript/typescript": "^0.1.58"
59
+ "@atscript/core": "^0.1.59",
60
+ "@atscript/typescript": "^0.1.59"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "vp pack",