@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
@@ -1,6 +1,6 @@
1
- import { bK as EntityRefWithWords } from '../table-kind-wYO_qjK1.cjs';
1
+ import { bK as EntityRefWithWords } from '../table-kind-DptSVo_4.cjs';
2
2
  import { U as Uuid, h as RecordsResult, n as RecordPageSort, m as ReadRow } from '../record-DCaOJbhA.cjs';
3
- import { R as RecordsClient } from '../client-DHoI0qvP.cjs';
3
+ import { R as RecordsClient } from '../client-GhSH0bR7.cjs';
4
4
  import { b as Field } from '../field-DCXU6k9i.cjs';
5
5
  import { u as RuleExpression } from '../subscription-C_hNjbaR.cjs';
6
6
  import '../ports-DaHUjVg7.cjs';
@@ -1,6 +1,6 @@
1
- import { bK as EntityRefWithWords } from '../table-kind-Ct-nhoCZ.js';
1
+ import { bK as EntityRefWithWords } from '../table-kind-lHVdMZGy.js';
2
2
  import { U as Uuid, h as RecordsResult, n as RecordPageSort, m as ReadRow } from '../record-DCaOJbhA.js';
3
- import { R as RecordsClient } from '../client-BcVOYKL1.js';
3
+ import { R as RecordsClient } from '../client-BbLzOf08.js';
4
4
  import { b as Field } from '../field-DJAvDExi.js';
5
5
  import { u as RuleExpression } from '../subscription-B9znK2dw.js';
6
6
  import '../ports-Kpc-RihV.js';
@@ -176,6 +176,24 @@ function compileSort(sort, shape) {
176
176
  return { ok: true, data: out };
177
177
  }
178
178
 
179
+ // src/core/primedBundle.ts
180
+ var PRIMED_TTL_MS = 15e3;
181
+ var REGISTRY = /* @__PURE__ */ Symbol.for("@ai-matrx/records/primed-table-page-bundles");
182
+ function registry() {
183
+ const g = globalThis;
184
+ return g[REGISTRY] ??= /* @__PURE__ */ new Map();
185
+ }
186
+ var primedKey = (organizationId, tableId, viewId) => `${organizationId}|${tableId}|${viewId ?? ""}`;
187
+ function takePrimedTablePageBundle(organizationId, tableId, viewId) {
188
+ if (!organizationId) return null;
189
+ const key = primedKey(organizationId, tableId, viewId);
190
+ const primed = registry();
191
+ const held = primed.get(key);
192
+ if (!held) return null;
193
+ primed.delete(key);
194
+ return Date.now() - held.at < PRIMED_TTL_MS ? held.answer : null;
195
+ }
196
+
179
197
  // src/archive.ts
180
198
  var DEFAULT_ARCHIVE_LANE = "org";
181
199
 
@@ -2541,13 +2559,20 @@ function createRecordsClient(given) {
2541
2559
  }
2542
2560
  async function fillBundle(tableId, viewId) {
2543
2561
  try {
2544
- const response = await config.dataSource.rpc(
2545
- "table_page_bundle",
2546
- { p_organization_id: org, p_table_id: tableId, p_view_id: typeof viewId === "string" ? viewId : null },
2547
- { schema }
2548
- );
2562
+ const view = typeof viewId === "string" ? viewId : null;
2563
+ const usable = (r) => r !== null && !r.error && r.data !== null && typeof r.data === "object" && Array.isArray(r.data.parts);
2564
+ const primedAnswer = takePrimedTablePageBundle(org, tableId, view);
2565
+ let response = primedAnswer ? await primedAnswer : null;
2566
+ if (!usable(response)) {
2567
+ response = await config.dataSource.rpc(
2568
+ "table_page_bundle",
2569
+ { p_organization_id: org, p_table_id: tableId, p_view_id: view },
2570
+ { schema }
2571
+ );
2572
+ }
2573
+ if (!usable(response)) return;
2549
2574
  const answer = response.data;
2550
- if (response.error || !answer || !Array.isArray(answer.parts)) return;
2575
+ if (!answer || !Array.isArray(answer.parts)) return;
2551
2576
  const now = Date.now();
2552
2577
  for (const part of answer.parts) {
2553
2578
  if (part.error !== void 0 || part.data === void 0) continue;