@ai-matrx/records 0.84.1 → 0.84.2

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,11 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
+ ## 0.84.2
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/records/v0.84.1..npm/records/v0.84.2 -- apps/shared/records`).
7
+ No source changes intended and no consumer action required.
8
+
3
9
  ## 0.84.1
4
10
 
5
11
  Automatic changed-only republish (docs/metadata drift since the last tag — see
@@ -433,6 +433,26 @@ function takePrimedTablePageBundle(organizationId, tableId, viewId) {
433
433
  primed.delete(key);
434
434
  return Date.now() - held.at < PRIMED_TTL_MS ? held.answer : null;
435
435
  }
436
+ var DOOR_REGISTRY = /* @__PURE__ */ Symbol.for("@ai-matrx/records/primed-door-answers");
437
+ function doorRegistry() {
438
+ const g = globalThis;
439
+ return g[DOOR_REGISTRY] ??= /* @__PURE__ */ new Map();
440
+ }
441
+ var PRIMED_DOOR_TTL_MS = 1e4;
442
+ function takePrimedDoorAnswer(key) {
443
+ const registry2 = doorRegistry();
444
+ const held = registry2.get(key);
445
+ if (!held) return null;
446
+ if (Date.now() - held.at < PRIMED_DOOR_TTL_MS) return { data: held.data };
447
+ registry2.delete(key);
448
+ return null;
449
+ }
450
+ function dropPrimedDoorAnswers() {
451
+ doorRegistry().clear();
452
+ }
453
+ function isWritingDoor(door) {
454
+ return /(_declare|_set(_|$)|_update|_write|_delete|_restore|_archive|_upsert|_reparent|_change|_duplicate|_move|_decide|_run$|_submit|_publish|_import_|_start$|_complete|_sign$|_add$|_retire|_propose|_promote|_land$|_pin$|_mute|_snooze|_unsnooze|_clear|_unclear|_revoke|_issue|_bind|_unbind|_apply|_backfill|_sync$|_decorate|_designate|_ensure|^migrate_|^home_add|^capture_|^claim_|^record_stage|^anon_|^io_import_|^io_comment_resolve|^enrich_(declare|land|pin)|^field_(declare|duplicate|propose|restore|retire|update)|^table_(declare|ensure|from_example|move|sync)|^value_restore|^relation_own)/.test(door);
455
+ }
436
456
 
437
457
  // src/core/recordChanges.ts
438
458
  var listeners = /* @__PURE__ */ new Set();
@@ -2905,7 +2925,16 @@ function createRecordsClient(given) {
2905
2925
  bundleAsked.delete(tableId);
2906
2926
  for (const key of [...bundleParts.keys()]) if (key.includes(tableId)) bundleParts.delete(key);
2907
2927
  }
2928
+ function primedFor(door, args) {
2929
+ if (isWritingDoor(door)) {
2930
+ dropPrimedDoorAnswers();
2931
+ return null;
2932
+ }
2933
+ return takePrimedDoorAnswer(`${door}|${canonicalArgs(args)}`);
2934
+ }
2908
2935
  async function callDoor(door, args, where) {
2936
+ const primed = primedFor(door, args);
2937
+ if (primed) return ok(primed.data);
2909
2938
  const bundled = await fromBundle(door, args);
2910
2939
  if (bundled) return ok(bundled.data);
2911
2940
  if (!doorReady(config, door)) {
@@ -2930,6 +2959,8 @@ function createRecordsClient(given) {
2930
2959
  }
2931
2960
  async function owedDoor(door, args, where) {
2932
2961
  if (doorExists(door)) return callDoor(door, args, where);
2962
+ const primed = primedFor(door, args);
2963
+ if (primed) return ok(primed.data);
2933
2964
  const response = await config.dataSource.rpc(door, args, { schema });
2934
2965
  if (response.error) {
2935
2966
  const code = response.error.code;
@@ -2995,6 +3026,8 @@ function createRecordsClient(given) {
2995
3026
  return ok(response.data);
2996
3027
  }
2997
3028
  async function drillDoor(door, args, where) {
3029
+ const primed = primedFor(door, args);
3030
+ if (primed) return ok(primed.data);
2998
3031
  const response = await config.dataSource.rpc(door, args, { schema: DRILL_SCHEMA });
2999
3032
  if (response.error) {
3000
3033
  const refusal2 = mapPgError(response.error, where);