@ai-matrx/records 0.84.3 → 0.84.5

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,19 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
+ ## 0.84.5
4
+ ### Unreleased
5
+ ### lane spaces-fixes-r39
6
+
7
+ - An archived record is no longer read again: `recordDelete` marks it removed (`markRecordRemoved`, lifted by `recordRestore`), and the live `useRecord` entry of a screen that closed (a peek) skips its re-read on the archive's change announcement and on realtime's echo of it — `custom.read_record` answered both with a 400.
8
+
9
+ **Consumer action:** none.
10
+
11
+ ## 0.84.4
12
+
13
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
14
+ `git diff npm/records/v0.84.3..npm/records/v0.84.4 -- apps/shared/records`).
15
+ No source changes intended and no consumer action required.
16
+
3
17
  ## 0.84.3
4
18
 
5
19
  Automatic changed-only republish (docs/metadata drift since the last tag — see
@@ -476,6 +476,13 @@ function announceRecordChanged(recordId) {
476
476
  }
477
477
  }
478
478
  }
479
+ var removed = /* @__PURE__ */ new Set();
480
+ function markRecordRemoved(recordId) {
481
+ removed.add(recordId);
482
+ }
483
+ function markRecordRestored(recordId) {
484
+ removed.delete(recordId);
485
+ }
479
486
  function onRecordChanged(listener) {
480
487
  listeners.add(listener);
481
488
  return () => listeners.delete(listener);
@@ -2948,6 +2955,7 @@ function createRecordsClient(given) {
2948
2955
  }
2949
2956
  return takePrimedDoorAnswer(`${door}|${canonicalArgs(args)}`);
2950
2957
  }
2958
+ const readsInFlight = /* @__PURE__ */ new Map();
2951
2959
  async function callDoor(door, args, where) {
2952
2960
  const primed = primedFor(door, args);
2953
2961
  if (primed) return ok(primed.data);
@@ -2958,7 +2966,19 @@ function createRecordsClient(given) {
2958
2966
  scream({ code: refusal2.code, message: refusal2.message, ...refusal2.hint ? { hint: refusal2.hint } : {}, where });
2959
2967
  return err(refusal2);
2960
2968
  }
2961
- const response = await config.dataSource.rpc(`${door}`, args, { schema });
2969
+ const flightKey = isWritingDoor(door) ? null : `${door}|${canonicalArgs(args)}`;
2970
+ const flying = flightKey ? readsInFlight.get(flightKey) : void 0;
2971
+ const response = await (flying ?? (() => {
2972
+ const call = Promise.resolve(config.dataSource.rpc(`${door}`, args, { schema }));
2973
+ if (flightKey) {
2974
+ readsInFlight.set(flightKey, call);
2975
+ const forget = () => {
2976
+ if (readsInFlight.get(flightKey) === call) readsInFlight.delete(flightKey);
2977
+ };
2978
+ call.then(forget, forget);
2979
+ }
2980
+ return call;
2981
+ })());
2962
2982
  if (response.error) {
2963
2983
  const refusal2 = mapPgError(response.error, where);
2964
2984
  scream({ code: refusal2.code, message: refusal2.message, ...refusal2.hint ? { hint: refusal2.hint } : {}, where });
@@ -3268,7 +3288,10 @@ function createRecordsClient(given) {
3268
3288
  { p_organization_id: org, p_record_id: record_id },
3269
3289
  "recordDelete"
3270
3290
  );
3271
- if (result.ok) announceRecordChanged(record_id);
3291
+ if (result.ok) {
3292
+ markRecordRemoved(record_id);
3293
+ announceRecordChanged(record_id);
3294
+ }
3272
3295
  return result;
3273
3296
  },
3274
3297
  async recordRestore({ record_id }) {
@@ -3277,7 +3300,10 @@ function createRecordsClient(given) {
3277
3300
  { p_organization_id: org, p_record_id: record_id },
3278
3301
  "recordRestore"
3279
3302
  );
3280
- if (result.ok) announceRecordChanged(record_id);
3303
+ if (result.ok) {
3304
+ markRecordRestored(record_id);
3305
+ announceRecordChanged(record_id);
3306
+ }
3281
3307
  return result;
3282
3308
  },
3283
3309
  async tableArchive({ table_id, chunk, includeTable }) {