@ai-matrx/records 0.84.4 → 0.84.6

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/app-table/index.cjs +51 -2
  3. package/dist/app-table/index.cjs.map +1 -1
  4. package/dist/app-table/index.d.cts +3 -3
  5. package/dist/app-table/index.d.ts +3 -3
  6. package/dist/app-table/index.js +51 -2
  7. package/dist/app-table/index.js.map +1 -1
  8. package/dist/{client-TU-nvgcF.d.ts → client-Cx2JV38-.d.ts} +7 -1
  9. package/dist/{client-CesQciPd.d.cts → client-xErw4ZgF.d.cts} +7 -1
  10. package/dist/core/index.cjs +59 -4
  11. package/dist/core/index.cjs.map +1 -1
  12. package/dist/core/index.d.cts +12 -5
  13. package/dist/core/index.d.ts +12 -5
  14. package/dist/core/index.js +59 -4
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/data/index.cjs +51 -2
  17. package/dist/data/index.cjs.map +1 -1
  18. package/dist/data/index.d.cts +2 -2
  19. package/dist/data/index.d.ts +2 -2
  20. package/dist/data/index.js +51 -2
  21. package/dist/data/index.js.map +1 -1
  22. package/dist/{declareTable-COXYIOiT.d.ts → declareTable-CYzGWD5K.d.ts} +2 -2
  23. package/dist/{declareTable-B9sr2E0h.d.cts → declareTable-G-H3AK48.d.cts} +2 -2
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +2 -2
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.js.map +1 -1
  28. package/dist/react/index.cjs +66 -5
  29. package/dist/react/index.cjs.map +1 -1
  30. package/dist/react/index.d.cts +16 -1
  31. package/dist/react/index.d.ts +16 -1
  32. package/dist/react/index.js +66 -5
  33. package/dist/react/index.js.map +1 -1
  34. package/dist/{table-kind-C5T-DOdc.d.ts → table-kind-B_qYmQJG.d.ts} +10 -1
  35. package/dist/{table-kind-B4vIKJVM.d.cts → table-kind-KMjVs-rk.d.cts} +10 -1
  36. package/package.json +2 -2
@@ -368,6 +368,16 @@ function announceRecordChanged(recordId) {
368
368
  }
369
369
  }
370
370
  }
371
+ var removed = /* @__PURE__ */ new Set();
372
+ function markRecordRemoved(recordId) {
373
+ removed.add(recordId);
374
+ }
375
+ function markRecordRestored(recordId) {
376
+ removed.delete(recordId);
377
+ }
378
+ function isRecordRemoved(recordId) {
379
+ return removed.has(recordId);
380
+ }
371
381
  function onRecordChanged(listener) {
372
382
  listeners.add(listener);
373
383
  return () => listeners.delete(listener);
@@ -3578,6 +3588,10 @@ var OWED_BY = {
3578
3588
  // clone; they reach the main database when the chair applies them, after
3579
3589
  // visionreach_w4_a_the_store_asks_before_an_agent_changes_a_table.sql (its field_declare body).
3580
3590
  reverse_columns: "VIEWS-AND-FIELDS BL \u2014 matrx-frontend migrations/campaign/viewsfields_bl_a_link_shows_on_both_tables.sql (chair's production apply)",
3591
+ // SEED-ENTITY (2026-10-08): the same links through SEVERAL reverse columns in one call; applied to production
3592
+ // through the ledgered runner. Until `pnpm records:generate` lists it, `reverseLinksFields` asks it as an owed door
3593
+ // and a store without it answers `door_absent` (the caller falls back to one call per column).
3594
+ reverse_links_many_fields: "SEED-ENTITY \u2014 matrx-frontend migrations/campaign/seedentity_reverse_links_many_fields.sql (applied 2026-10-08)",
3581
3595
  reverse_links_many: "VIEWS-AND-FIELDS BL \u2014 matrx-frontend migrations/campaign/viewsfields_bl_a_link_shows_on_both_tables.sql (chair's production apply)",
3582
3596
  // Live on Matrx Main since 2026-10-06 (applied through the Supabase MCP); STORE_DOORS lists it at the
3583
3597
  // next `pnpm records:generate`, until then `listKeyset` asks it as an owed door.
@@ -3818,6 +3832,7 @@ var DOORS = {
3818
3832
  // links through one of them. Called through `owedDoor` until `pnpm records:generate` lists them.
3819
3833
  reverseColumns: "reverse_columns",
3820
3834
  reverseLinksMany: "reverse_links_many",
3835
+ reverseLinksManyFields: "reverse_links_many_fields",
3821
3836
  homeAdd: "home_add",
3822
3837
  recordReparent: "record_reparent",
3823
3838
  containmentChain: "containment_chain",
@@ -4898,7 +4913,10 @@ function createRecordsClient(given) {
4898
4913
  { p_organization_id: org, p_record_id: record_id },
4899
4914
  "recordDelete"
4900
4915
  );
4901
- if (result.ok) announceRecordChanged(record_id);
4916
+ if (result.ok) {
4917
+ markRecordRemoved(record_id);
4918
+ announceRecordChanged(record_id);
4919
+ }
4902
4920
  return result;
4903
4921
  },
4904
4922
  async recordRestore({ record_id }) {
@@ -4907,7 +4925,10 @@ function createRecordsClient(given) {
4907
4925
  { p_organization_id: org, p_record_id: record_id },
4908
4926
  "recordRestore"
4909
4927
  );
4910
- if (result.ok) announceRecordChanged(record_id);
4928
+ if (result.ok) {
4929
+ markRecordRestored(record_id);
4930
+ announceRecordChanged(record_id);
4931
+ }
4911
4932
  return result;
4912
4933
  },
4913
4934
  async tableArchive({ table_id, chunk, includeTable }) {
@@ -5708,6 +5729,37 @@ function createRecordsClient(given) {
5708
5729
  }
5709
5730
  return ok(out);
5710
5731
  },
5732
+ async reverseLinksFields(args) {
5733
+ const ids = [...new Set(args.record_ids.filter((id) => typeof id === "string" && id.length > 0))];
5734
+ const fieldIds = [...new Set(args.source_field_ids)];
5735
+ const out = Object.fromEntries(fieldIds.map((id) => [id, {}]));
5736
+ for (let f2 = 0; f2 < fieldIds.length || f2 === 0; f2 += 20) {
5737
+ for (let at = 0; at < ids.length; at += REVERSE_LINKS_RECORDS_PER_CALL) {
5738
+ const result = await owedDoor(
5739
+ DOORS.reverseLinksManyFields,
5740
+ {
5741
+ p_organization_id: org,
5742
+ p_table_id: args.table_id,
5743
+ p_field_ids: fieldIds.slice(f2, f2 + 20),
5744
+ p_record_ids: ids.slice(at, at + REVERSE_LINKS_RECORDS_PER_CALL),
5745
+ p_limit: args.limit ?? 10,
5746
+ p_offset: args.offset ?? 0
5747
+ },
5748
+ "reverseLinksFields"
5749
+ );
5750
+ if (!result.ok) return result;
5751
+ for (const row of result.data ?? []) {
5752
+ if (!row?.record_id || !row.field_id) continue;
5753
+ (out[row.field_id] ??= {})[row.record_id] = {
5754
+ total: typeof row.total === "number" ? row.total : 0,
5755
+ links: Array.isArray(row.links) ? row.links : []
5756
+ };
5757
+ }
5758
+ }
5759
+ if (fieldIds.length === 0) break;
5760
+ }
5761
+ return ok(out);
5762
+ },
5711
5763
  async relationNamesMatch(args) {
5712
5764
  const distinct = [];
5713
5765
  const seen = /* @__PURE__ */ new Set();
@@ -8462,6 +8514,16 @@ function useReverseLinks(tableId, columns, recordIds, limit = 3, offset = 0) {
8462
8514
  if (!tableId || columns.length === 0 || recordIds.length === 0 || !doorReady(client.config, DOORS.reverseLinksMany)) {
8463
8515
  return { ok: true, data: {} };
8464
8516
  }
8517
+ const out = {};
8518
+ const all = await answerOrRefusal(
8519
+ () => client.reverseLinksFields({ table_id: tableId, source_field_ids: columns.map((c) => c.source_field_id), record_ids: recordIds, limit, offset }),
8520
+ "reverseLinksFields"
8521
+ );
8522
+ if (all.ok) {
8523
+ for (const c of columns) out[c.key] = all.data[c.source_field_id] ?? {};
8524
+ return { ok: true, data: out };
8525
+ }
8526
+ if (all.error.code !== "door_absent") return all;
8465
8527
  const answers = await Promise.all(
8466
8528
  columns.map(
8467
8529
  (c) => answerOrRefusal(
@@ -8470,7 +8532,6 @@ function useReverseLinks(tableId, columns, recordIds, limit = 3, offset = 0) {
8470
8532
  )
8471
8533
  )
8472
8534
  );
8473
- const out = {};
8474
8535
  for (let i = 0; i < columns.length; i += 1) {
8475
8536
  const answer = answers[i];
8476
8537
  if (!answer.ok) return answer;
@@ -8670,7 +8731,7 @@ function liveRecordFor(recordId, tableId) {
8670
8731
  const stops = [];
8671
8732
  stops.push(
8672
8733
  onRecordChanged((changed) => {
8673
- if (changed === recordId) entry.refetch();
8734
+ if (changed === recordId && !isRecordRemoved(recordId)) entry.refetch();
8674
8735
  })
8675
8736
  );
8676
8737
  const client = entry.client;
@@ -8681,7 +8742,7 @@ function liveRecordFor(recordId, tableId) {
8681
8742
  { organization_id: client.config.organizationId, table_id: tableId },
8682
8743
  {
8683
8744
  records(ids) {
8684
- if (ids === null || ids.includes(recordId)) entry.refetch();
8745
+ if ((ids === null || ids.includes(recordId)) && !isRecordRemoved(recordId)) entry.refetch();
8685
8746
  },
8686
8747
  shape() {
8687
8748
  tableShapeChanged(tableId);