@ai-matrx/records 0.84.3 → 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,11 @@
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
+
3
9
  ## 0.84.3
4
10
 
5
11
  Automatic changed-only republish (docs/metadata drift since the last tag — see
@@ -2948,6 +2948,7 @@ function createRecordsClient(given) {
2948
2948
  }
2949
2949
  return takePrimedDoorAnswer(`${door}|${canonicalArgs(args)}`);
2950
2950
  }
2951
+ const readsInFlight = /* @__PURE__ */ new Map();
2951
2952
  async function callDoor(door, args, where) {
2952
2953
  const primed = primedFor(door, args);
2953
2954
  if (primed) return ok(primed.data);
@@ -2958,7 +2959,19 @@ function createRecordsClient(given) {
2958
2959
  scream({ code: refusal2.code, message: refusal2.message, ...refusal2.hint ? { hint: refusal2.hint } : {}, where });
2959
2960
  return err(refusal2);
2960
2961
  }
2961
- 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
+ })());
2962
2975
  if (response.error) {
2963
2976
  const refusal2 = mapPgError(response.error, where);
2964
2977
  scream({ code: refusal2.code, message: refusal2.message, ...refusal2.hint ? { hint: refusal2.hint } : {}, where });