@ai-matrx/records 0.79.1 → 0.80.1

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 +31 -6
  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 +31 -6
  7. package/dist/app-table/index.js.map +1 -1
  8. package/dist/{client-BcVOYKL1.d.ts → client-BbLzOf08.d.ts} +1 -1
  9. package/dist/{client-DHoI0qvP.d.cts → client-GhSH0bR7.d.cts} +1 -1
  10. package/dist/core/index.cjs +41 -6
  11. package/dist/core/index.cjs.map +1 -1
  12. package/dist/core/index.d.cts +26 -5
  13. package/dist/core/index.d.ts +26 -5
  14. package/dist/core/index.js +41 -6
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/data/index.cjs +31 -6
  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 +31 -6
  21. package/dist/data/index.js.map +1 -1
  22. package/dist/{declareTable-DM9mPkSc.d.cts → declareTable-Bb0eUtPF.d.cts} +2 -2
  23. package/dist/{declareTable-CDKHwyrF.d.ts → declareTable-D6mB7Va8.d.ts} +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 +31 -6
  29. package/dist/react/index.cjs.map +1 -1
  30. package/dist/react/index.d.cts +6 -2
  31. package/dist/react/index.d.ts +6 -2
  32. package/dist/react/index.js +31 -6
  33. package/dist/react/index.js.map +1 -1
  34. package/dist/{table-kind-wYO_qjK1.d.cts → table-kind-DptSVo_4.d.cts} +6 -2
  35. package/dist/{table-kind-Ct-nhoCZ.d.ts → table-kind-lHVdMZGy.d.ts} +6 -2
  36. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
+ ## 0.80.1
4
+ ### PAGE-BUNDLE-2 fix
5
+
6
+ THE PRIMED BUNDLE IS SEEN BY EVERY ENTRY: the package's entries (`/core`, `/react`, `/data`, `/app-table`) each bundle their own copy of the client, so 0.80.0's module-level registry was four registries — a host priming through `/core` was never seen by the `RecordsProvider` (`/react`), and the bundle was asked again. The registry now lives on `globalThis` under `Symbol.for("@ai-matrx/records/primed-table-page-bundles")`.
7
+
8
+ **Consumer action:** none.
9
+
10
+ ## 0.80.0
11
+ ### PAGE-BUNDLE-2
12
+
13
+ A TABLE PAGE'S BUNDLE CAN BE ASKED BEFORE THE PAGE BOOTS: `primeTablePageBundle({ organizationId, tableId, viewId?, answer })` (from `@ai-matrx/records/core`) hands the records client a `custom.table_page_bundle` answer asked elsewhere — the server render, as the same person. The next client opening that Table in that organization uses it instead of asking, once, within 15 s. A primed failure or non-bundle answer is ignored and the bundle is asked as before; part-by-part matching is unchanged.
14
+
15
+ **Consumer action:** none (additive).
16
+
3
17
  ## 0.79.1
4
18
 
5
19
  Automatic changed-only republish (docs/metadata drift since the last tag — see
@@ -416,6 +416,24 @@ function sha256Hex(text2) {
416
416
  return Array.from(h, (x) => x.toString(16).padStart(8, "0")).join("");
417
417
  }
418
418
 
419
+ // src/core/primedBundle.ts
420
+ var PRIMED_TTL_MS = 15e3;
421
+ var REGISTRY = /* @__PURE__ */ Symbol.for("@ai-matrx/records/primed-table-page-bundles");
422
+ function registry() {
423
+ const g = globalThis;
424
+ return g[REGISTRY] ??= /* @__PURE__ */ new Map();
425
+ }
426
+ var primedKey = (organizationId, tableId, viewId) => `${organizationId}|${tableId}|${viewId ?? ""}`;
427
+ function takePrimedTablePageBundle(organizationId, tableId, viewId) {
428
+ if (!organizationId) return null;
429
+ const key = primedKey(organizationId, tableId, viewId);
430
+ const primed = registry();
431
+ const held = primed.get(key);
432
+ if (!held) return null;
433
+ primed.delete(key);
434
+ return Date.now() - held.at < PRIMED_TTL_MS ? held.answer : null;
435
+ }
436
+
419
437
  // src/archive.ts
420
438
  var DEFAULT_ARCHIVE_LANE = "org";
421
439
 
@@ -2757,13 +2775,20 @@ function createRecordsClient(given) {
2757
2775
  }
2758
2776
  async function fillBundle(tableId, viewId) {
2759
2777
  try {
2760
- const response = await config.dataSource.rpc(
2761
- "table_page_bundle",
2762
- { p_organization_id: org, p_table_id: tableId, p_view_id: typeof viewId === "string" ? viewId : null },
2763
- { schema }
2764
- );
2778
+ const view = typeof viewId === "string" ? viewId : null;
2779
+ const usable = (r) => r !== null && !r.error && r.data !== null && typeof r.data === "object" && Array.isArray(r.data.parts);
2780
+ const primedAnswer = takePrimedTablePageBundle(org, tableId, view);
2781
+ let response = primedAnswer ? await primedAnswer : null;
2782
+ if (!usable(response)) {
2783
+ response = await config.dataSource.rpc(
2784
+ "table_page_bundle",
2785
+ { p_organization_id: org, p_table_id: tableId, p_view_id: view },
2786
+ { schema }
2787
+ );
2788
+ }
2789
+ if (!usable(response)) return;
2765
2790
  const answer = response.data;
2766
- if (response.error || !answer || !Array.isArray(answer.parts)) return;
2791
+ if (!answer || !Array.isArray(answer.parts)) return;
2767
2792
  const now = Date.now();
2768
2793
  for (const part of answer.parts) {
2769
2794
  if (part.error !== void 0 || part.data === void 0) continue;