nucleus-core-ts 0.10.241 → 0.10.242

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/dist/.build-ok CHANGED
@@ -1 +1 @@
1
- 0.10.241
1
+ 0.10.242
@@ -29,5 +29,14 @@ function seen(entry, clock) {
29
29
  const past = queue.entries.filter((entry)=>seen(entry, clock));
30
30
  return [
31
31
  ...past
32
- ].reverse().find((entry)=>entry.payload === payload) ?? queue.last ?? past.at(-1) ?? queue.entries.find((entry)=>entry.at === undefined);
32
+ ].reverse().find((entry)=>entry.payload === payload) ?? queue.last ?? past.at(-1) ?? queue.entries.find((entry)=>entry.at === undefined) ?? earliestAhead(queue.entries, payload, clock);
33
+ }
34
+ /**
35
+ * A call made before the first recorded answer of its key: the recorded call was made before its answer arrived too
36
+ * (`at` is when the answer came), so a page that asks at load gets the first answer ahead, the one for the same payload
37
+ * when there is one. Without it the page's first `ME` at 0 ms found its answer recorded at 388 ms "not due" and
38
+ * the replayed app took itself for signed out. A write recorded after other writes still waits for them.
39
+ */ function earliestAhead(entries, payload, clock) {
40
+ const ahead = entries.filter((entry)=>entry.at !== undefined && entry.at > clock.playhead && !(entry.write && entry.served)).sort((a, b)=>(a.at ?? 0) - (b.at ?? 0));
41
+ return ahead.find((entry)=>entry.payload === payload) ?? ahead[0];
33
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-core-ts",
3
- "version": "0.10.241",
3
+ "version": "0.10.242",
4
4
  "description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
5
5
  "author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",