@ai-matrx/records 0.84.2 → 0.84.4

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,17 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
+ ## 0.84.4
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/records/v0.84.3..npm/records/v0.84.4 -- apps/shared/records`).
7
+ No source changes intended and no consumer action required.
8
+
9
+ ## 0.84.3
10
+
11
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
12
+ `git diff npm/records/v0.84.2..npm/records/v0.84.3 -- apps/shared/records`).
13
+ No source changes intended and no consumer action required.
14
+
3
15
  ## 0.84.2
4
16
 
5
17
  Automatic changed-only republish (docs/metadata drift since the last tag — see
@@ -447,9 +447,20 @@ function takePrimedDoorAnswer(key) {
447
447
  registry2.delete(key);
448
448
  return null;
449
449
  }
450
- function dropPrimedDoorAnswers() {
451
- doorRegistry().clear();
450
+ function dropPrimedDoorAnswers(doors) {
451
+ const registry2 = doorRegistry();
452
+ if (!doors) {
453
+ registry2.clear();
454
+ return;
455
+ }
456
+ for (const key of [...registry2.keys()]) if (doors.some((door) => key.startsWith(`${door}|`))) registry2.delete(key);
452
457
  }
458
+ var LOOK_WRITES = {
459
+ view_declare: ["views", "view_look_read", "grid_layout", "table_page_bundle"],
460
+ view_designate: ["views", "view_look_read", "grid_layout", "table_page_bundle"],
461
+ view_look_set: ["views", "view_look_read", "grid_layout", "table_page_bundle"],
462
+ view_record_order_set: ["views", "view_look_read", "grid_layout", "table_page_bundle"]
463
+ };
453
464
  function isWritingDoor(door) {
454
465
  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
466
  }
@@ -2926,12 +2937,18 @@ function createRecordsClient(given) {
2926
2937
  for (const key of [...bundleParts.keys()]) if (key.includes(tableId)) bundleParts.delete(key);
2927
2938
  }
2928
2939
  function primedFor(door, args) {
2940
+ const look = LOOK_WRITES[door];
2941
+ if (look) {
2942
+ dropPrimedDoorAnswers(look);
2943
+ return null;
2944
+ }
2929
2945
  if (isWritingDoor(door)) {
2930
2946
  dropPrimedDoorAnswers();
2931
2947
  return null;
2932
2948
  }
2933
2949
  return takePrimedDoorAnswer(`${door}|${canonicalArgs(args)}`);
2934
2950
  }
2951
+ const readsInFlight = /* @__PURE__ */ new Map();
2935
2952
  async function callDoor(door, args, where) {
2936
2953
  const primed = primedFor(door, args);
2937
2954
  if (primed) return ok(primed.data);
@@ -2942,7 +2959,19 @@ function createRecordsClient(given) {
2942
2959
  scream({ code: refusal2.code, message: refusal2.message, ...refusal2.hint ? { hint: refusal2.hint } : {}, where });
2943
2960
  return err(refusal2);
2944
2961
  }
2945
- const response = await config.dataSource.rpc(`${door}`, args, { schema });
2962
+ const flightKey = isWritingDoor(door) ? null : `${door}|${canonicalArgs(args)}`;
2963
+ const flying = flightKey ? readsInFlight.get(flightKey) : void 0;
2964
+ const response = await (flying ?? (() => {
2965
+ const call = Promise.resolve(config.dataSource.rpc(`${door}`, args, { schema }));
2966
+ if (flightKey) {
2967
+ readsInFlight.set(flightKey, call);
2968
+ const forget = () => {
2969
+ if (readsInFlight.get(flightKey) === call) readsInFlight.delete(flightKey);
2970
+ };
2971
+ call.then(forget, forget);
2972
+ }
2973
+ return call;
2974
+ })());
2946
2975
  if (response.error) {
2947
2976
  const refusal2 = mapPgError(response.error, where);
2948
2977
  scream({ code: refusal2.code, message: refusal2.message, ...refusal2.hint ? { hint: refusal2.hint } : {}, where });