@ai-matrx/records 0.79.0 → 0.80.0

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 +13 -0
  2. package/dist/app-table/index.cjs +26 -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 +26 -6
  7. package/dist/app-table/index.js.map +1 -1
  8. package/dist/{client-SM21Erad.d.ts → client-BcVOYKL1.d.ts} +1 -1
  9. package/dist/{client-BKXt18rw.d.cts → client-DHoI0qvP.d.cts} +1 -1
  10. package/dist/core/index.cjs +36 -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 +36 -6
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/data/index.cjs +26 -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 +26 -6
  21. package/dist/data/index.js.map +1 -1
  22. package/dist/{declareTable-CRPC4uku.d.ts → declareTable-CDKHwyrF.d.ts} +2 -2
  23. package/dist/{declareTable-DVbm7Rck.d.cts → declareTable-DM9mPkSc.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 +26 -6
  29. package/dist/react/index.cjs.map +1 -1
  30. package/dist/react/index.d.cts +21 -1
  31. package/dist/react/index.d.ts +21 -1
  32. package/dist/react/index.js +26 -6
  33. package/dist/react/index.js.map +1 -1
  34. package/dist/{table-kind-CJ_K3E1F.d.ts → table-kind-Ct-nhoCZ.d.ts} +21 -1
  35. package/dist/{table-kind-DoSFfQDe.d.cts → table-kind-wYO_qjK1.d.cts} +21 -1
  36. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
- import { N as NewFieldSpec } from '../declareTable-DVbm7Rck.cjs';
1
+ import { N as NewFieldSpec } from '../declareTable-DM9mPkSc.cjs';
2
2
  import { U as Uuid, h as RecordsResult, n as RecordPageSort } from '../record-DCaOJbhA.cjs';
3
- import { R as RecordsClient } from '../client-BKXt18rw.cjs';
4
- import { F as FieldDrift, T as TableArchiveProgress } from '../table-kind-DoSFfQDe.cjs';
3
+ import { R as RecordsClient } from '../client-DHoI0qvP.cjs';
4
+ import { F as FieldDrift, T as TableArchiveProgress } from '../table-kind-wYO_qjK1.cjs';
5
5
  import '../field-DCXU6k9i.cjs';
6
6
  import '../subscription-C_hNjbaR.cjs';
7
7
  import '../ports-DaHUjVg7.cjs';
@@ -1,7 +1,7 @@
1
- import { N as NewFieldSpec } from '../declareTable-CRPC4uku.js';
1
+ import { N as NewFieldSpec } from '../declareTable-CDKHwyrF.js';
2
2
  import { U as Uuid, h as RecordsResult, n as RecordPageSort } from '../record-DCaOJbhA.js';
3
- import { R as RecordsClient } from '../client-SM21Erad.js';
4
- import { F as FieldDrift, T as TableArchiveProgress } from '../table-kind-CJ_K3E1F.js';
3
+ import { R as RecordsClient } from '../client-BcVOYKL1.js';
4
+ import { F as FieldDrift, T as TableArchiveProgress } from '../table-kind-Ct-nhoCZ.js';
5
5
  import '../field-DJAvDExi.js';
6
6
  import '../subscription-B9znK2dw.js';
7
7
  import '../ports-Kpc-RihV.js';
@@ -359,6 +359,19 @@ function sha256Hex(text2) {
359
359
  return Array.from(h, (x) => x.toString(16).padStart(8, "0")).join("");
360
360
  }
361
361
 
362
+ // src/core/primedBundle.ts
363
+ var PRIMED_TTL_MS = 15e3;
364
+ var primed = /* @__PURE__ */ new Map();
365
+ var primedKey = (organizationId, tableId, viewId) => `${organizationId}|${tableId}|${viewId ?? ""}`;
366
+ function takePrimedTablePageBundle(organizationId, tableId, viewId) {
367
+ if (!organizationId) return null;
368
+ const key = primedKey(organizationId, tableId, viewId);
369
+ const held = primed.get(key);
370
+ if (!held) return null;
371
+ primed.delete(key);
372
+ return Date.now() - held.at < PRIMED_TTL_MS ? held.answer : null;
373
+ }
374
+
362
375
  // src/archive.ts
363
376
  var DEFAULT_ARCHIVE_LANE = "org";
364
377
 
@@ -2700,13 +2713,20 @@ function createRecordsClient(given) {
2700
2713
  }
2701
2714
  async function fillBundle(tableId, viewId) {
2702
2715
  try {
2703
- const response = await config.dataSource.rpc(
2704
- "table_page_bundle",
2705
- { p_organization_id: org, p_table_id: tableId, p_view_id: typeof viewId === "string" ? viewId : null },
2706
- { schema }
2707
- );
2716
+ const view = typeof viewId === "string" ? viewId : null;
2717
+ const usable = (r) => r !== null && !r.error && r.data !== null && typeof r.data === "object" && Array.isArray(r.data.parts);
2718
+ const primedAnswer = takePrimedTablePageBundle(org, tableId, view);
2719
+ let response = primedAnswer ? await primedAnswer : null;
2720
+ if (!usable(response)) {
2721
+ response = await config.dataSource.rpc(
2722
+ "table_page_bundle",
2723
+ { p_organization_id: org, p_table_id: tableId, p_view_id: view },
2724
+ { schema }
2725
+ );
2726
+ }
2727
+ if (!usable(response)) return;
2708
2728
  const answer = response.data;
2709
- if (response.error || !answer || !Array.isArray(answer.parts)) return;
2729
+ if (!answer || !Array.isArray(answer.parts)) return;
2710
2730
  const now = Date.now();
2711
2731
  for (const part of answer.parts) {
2712
2732
  if (part.error !== void 0 || part.data === void 0) continue;