@ai-matrx/records 0.60.6 → 0.60.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
+ <!-- matrx-auto-git-docs-resolution-needed-delete-this-when-resolved — two versions follow: LOCAL first, then GITHUB. (LOCAL latest 2026-10-02 14:57; GITHUB latest 2026-10-02 14:58; LOCAL lacks 1 of GITHUB's 3 new lines; GITHUB lacks 17 of LOCAL's 17 new lines; recover: git show e40bf4695b:'apps/shared/records/CHANGELOG.md' / 5b7bf04c07:'apps/shared/records/CHANGELOG.md') Delete these three marker lines when resolved. -->
4
+
5
+ ## 0.60.9
6
+
7
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
8
+ `git diff npm/records/v0.60.7..npm/records/v0.60.9 -- apps/shared/records`).
9
+ No source changes intended and no consumer action required.
10
+
11
+ ## 0.61.0
12
+
13
+ Lane PLATFORM-APP-DATA (asked by lane KINDS-GLUE, board items L12-1 … L12-7) — `ensureTable` makes the
14
+ tables an app keeps.
15
+
16
+ - **Placement, kind and drafts facts are stored.** `NewTableSpec` takes `keptByTheApp`, `keptFor`, `kind`,
17
+ `draftsFor`, `draftsStamp`; they are written on the table `ensureTable` (and `declareTable`) makes.
18
+ - **`keptFor` is part of the address.** `ensureTable` finds a table by slug AND `keptFor`: a person's table and
19
+ an app's table of the same slug are different tables (`custom.table_ensure`, lane12_f).
20
+ - **`homeId`.** A new table can be put in an existing Home the caller may change; no second Home is made. A Home
21
+ that is not in this organization (or archived, or not hers to change) is refused and nothing is made.
22
+ - **Full column declarations.** `NewFieldSpec.optionsTableId` reuses an existing choice list (sent as
23
+ `config.options_table_id`); `NewFieldSpec.declaration` passes any other `custom.field_declare` key through
24
+ verbatim, applied last.
25
+ - Proven on the clone as admin@admin.com and test@test.com: a 48-character slug, and a server path declaring the
26
+ code tier (`app.actor_tier = system`) acting as the person, both work. `drift` is unchanged.
27
+ - `custom.table_find` now asks the record-store switch first (lane12_one_table_is_found_by_its_slug).
28
+
29
+ Consumer action: none required. Needs `lane12_f_an_ensured_table_finds_its_kept_for_and_takes_a_home.sql` on
30
+ production for `keptFor` matching and `homeId`; before it, `homeId` is ignored (a Home is made) and matching
31
+ is by slug alone.
32
+ <!-- matrx-auto-git-docs-resolution-needed-delete-this-when-resolved — GITHUB version below -->
33
+ ## 0.60.8
34
+
35
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
36
+ `git diff npm/records/v0.60.7..npm/records/v0.60.8 -- apps/shared/records`).
37
+ No source changes intended and no consumer action required.
38
+ <!-- matrx-auto-git-docs-resolution-needed-delete-this-when-resolved — end of both versions -->
39
+
40
+ ## 0.60.7
41
+
42
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
43
+ `git diff npm/records/v0.60.6..npm/records/v0.60.7 -- apps/shared/records`).
44
+ No source changes intended and no consumer action required.
45
+
3
46
  ## 0.60.6
4
47
 
5
48
  Automatic changed-only republish (docs/metadata drift since the last tag — see
package/README.md CHANGED
@@ -73,6 +73,32 @@ not be read; `declared` is the store's sentence). It is `[]` on a birth and when
73
73
  it, so `long_text` is never a false `type` drift. This shape is the contract a release-time drift
74
74
  check reads (`parseFieldDrift` types a raw answer).
75
75
 
76
+ ### A table the app keeps
77
+
78
+ ```ts
79
+ const outputs = await ensureTable(records, {
80
+ name: "Exercise flashcard outputs", slug: "agent_output_exercise_flashcard",
81
+ keptByTheApp: true, keptFor: "agent_output", kind: "exercise_flashcard",
82
+ homeId: sharedOutputsHome, // a NEW table goes in this Home; none is made
83
+ fields: [{ key: "body_region", label: "Body region", type: "select", optionsTableId }],
84
+ });
85
+ ```
86
+
87
+ `keptFor` is part of the address: a spec carrying it finds only a table kept for that word, and a spec
88
+ without it never finds an app's table — a person's table and an app's table of one slug are different
89
+ tables. `keptByTheApp`, `keptFor`, `kind`, `draftsFor` and `draftsStamp` are stored on the table it
90
+ makes. `homeId` must be a live Home of this organization the caller may change, or nothing is made.
91
+ `optionsTableId` reuses an existing choice list; `declaration` passes any other `custom.field_declare`
92
+ key through as written.
93
+
94
+ ### When two tables share a slug, `tableFind` and `ensureTable` may differ
95
+
96
+ A slug is not unique (older organizations hold a few duplicates). `tableFind` answers the oldest
97
+ table of that slug **the caller may see**. `ensureTable` takes the oldest table of that slug
98
+ **overall** and, if the caller may not know that one, refuses with the read door's own words rather
99
+ than making a second table. So for a hidden oldest duplicate, `tableFind` returns a newer table while
100
+ `ensureTable` refuses; both always agree when the caller can see the oldest one.
101
+
76
102
  Nothing here throws, and nothing here invents an answer. A door the store does
77
103
  not have yet is answered `door_absent`, naming the door AND the lane that owes
78
104
  it — `fieldPropose`, `tablePropose` and `mergeFieldResolve`
@@ -44351,17 +44351,18 @@ function createRecordsClient(given) {
44351
44351
  "tableFromExample"
44352
44352
  );
44353
44353
  },
44354
- async tableListEverywhere() {
44354
+ async tableListEverywhere(args) {
44355
44355
  return callDoor(
44356
44356
  DOORS.tableListEverywhere,
44357
- { p_organization_id: org },
44357
+ // The two-argument overload is chosen by naming both arguments (CHAIR-DOORS-2, N-C8).
44358
+ args?.include_app_tables ? { p_organization_id: org, p_include_app_tables: true } : { p_organization_id: org },
44358
44359
  "tableListEverywhere"
44359
44360
  );
44360
44361
  },
44361
- async dataHomeTables({ organization_id }) {
44362
+ async dataHomeTables({ organization_id, include_app_tables }) {
44362
44363
  return callDoor(
44363
44364
  DOORS.dataHomeTables,
44364
- { p_organization_id: organization_id },
44365
+ include_app_tables ? { p_organization_id: organization_id, p_include_app_tables: true } : { p_organization_id: organization_id },
44365
44366
  "dataHomeTables"
44366
44367
  );
44367
44368
  },
@@ -44505,7 +44506,9 @@ function fieldDeclarationFor(field) {
44505
44506
  ...field.unit ? { unit: field.unit } : {},
44506
44507
  ...field.kind ? { kind: field.kind } : {},
44507
44508
  ...field.allowedTypes ? { allowed_types: field.allowedTypes } : {},
44508
- ...field.unique ? { rules: [{ kind: "unique" }] } : {}
44509
+ ...field.unique ? { rules: [{ kind: "unique" }] } : {},
44510
+ ...field.optionsTableId ? { config: { ...field.config ?? {}, options_table_id: field.optionsTableId } } : {},
44511
+ ...field.declaration ?? {}
44509
44512
  };
44510
44513
  }
44511
44514
  function tableSpecFor(spec, fields, slug) {
@@ -44525,14 +44528,23 @@ function tableSpecFor(spec, fields, slug) {
44525
44528
  // AGT-1: a table a person made is agent-writable by declaration; the
44526
44529
  // organization turns it off, never this package.
44527
44530
  agent_writable: true,
44528
- default_sort: [{ field: titleField, direction: "asc" }]
44531
+ default_sort: [{ field: titleField, direction: "asc" }],
44532
+ ...spec.keptByTheApp !== void 0 ? { kept_by_the_app: spec.keptByTheApp } : {},
44533
+ ...spec.keptFor ? { kept_for: spec.keptFor } : {},
44534
+ ...spec.kind ? { kind: spec.kind } : {},
44535
+ ...spec.draftsFor ? { drafts_for: spec.draftsFor } : {},
44536
+ ...spec.draftsStamp ? { drafts_stamp: spec.draftsStamp } : {}
44529
44537
  };
44530
44538
  }
44531
44539
  async function ensureTable(client, spec) {
44532
44540
  const fields = spec.fields && spec.fields.length > 0 ? spec.fields : DEFAULT_FIELDS;
44533
44541
  const slug = spec.slug ?? tokenFor(spec.name);
44534
44542
  const ensured = await client.tableEnsure({
44535
- spec: { ...tableSpecFor(spec, fields, slug), fields: fields.map(fieldDeclarationFor) }
44543
+ spec: {
44544
+ ...tableSpecFor(spec, fields, slug),
44545
+ ...spec.homeId ? { home_id: spec.homeId } : {},
44546
+ fields: fields.map(fieldDeclarationFor)
44547
+ }
44536
44548
  });
44537
44549
  if (!ensured.ok) return ensured;
44538
44550
  return {