@rotorsoft/act-tck 1.30.0 → 1.30.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.
@@ -1 +1 @@
1
- {"version":3,"file":"store-tck.d.ts","sourceRoot":"","sources":["../../src/store-tck.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAQV,KAAK,EAGN,MAAM,sBAAsB,CAAC;AAc9B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC;;;;;;;;;OASG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC;;;;;;;;OAQG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IACxC;;;;;;;;OAQG;IACH,QAAQ,CAAC,gCAAgC,CAAC,EAAE,OAAO,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/C;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACxD;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;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;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,WAAW,YAAa,eAAe,KAAG,IA48ItD,CAAC"}
package/dist/index.cjs CHANGED
@@ -1738,6 +1738,74 @@ var runStoreTck = (options) => {
1738
1738
  await store.subscribe([{ stream: s }]);
1739
1739
  (0, import_vitest9.expect)(await read()).toBe(10);
1740
1740
  });
1741
+ (0, import_vitest9.it)("does not claim a fresh subscription with no matching events", async () => {
1742
+ const s = `fresh-empty-${uid()}`;
1743
+ const src = `fresh-src-${uid()}`;
1744
+ await store.subscribe([{ stream: s, source: src }]);
1745
+ const leases = await store.claim(5, 5, `w-${uid()}`, 5e3);
1746
+ (0, import_vitest9.expect)(leases.filter((l) => l.stream === s)).toHaveLength(0);
1747
+ });
1748
+ (0, import_vitest9.it)("claims a fresh subscription as soon as its first event lands", async () => {
1749
+ const s = `fresh-first-${uid()}`;
1750
+ const src = `fresh-first-src-${uid()}`;
1751
+ await store.subscribe([{ stream: s, source: src }]);
1752
+ await store.commit(
1753
+ src,
1754
+ [inc(1)],
1755
+ make_meta({ stream: src })
1756
+ );
1757
+ const leases = await store.claim(5, 5, `w-${uid()}`, 5e3);
1758
+ const mine = leases.filter((l) => l.stream === s);
1759
+ (0, import_vitest9.expect)(mine).toHaveLength(1);
1760
+ (0, import_vitest9.expect)(mine[0].at).toBe(-1);
1761
+ const in_window = [];
1762
+ await store.query((e) => in_window.push(e), {
1763
+ stream: src,
1764
+ stream_exact: true,
1765
+ after: mine[0].at
1766
+ });
1767
+ (0, import_vitest9.expect)(in_window).toHaveLength(1);
1768
+ });
1769
+ (0, import_vitest9.it)("keeps the maximum for negative and zero priorities too", async () => {
1770
+ const s = `sub-pri-neg-${uid()}`;
1771
+ const read = async () => {
1772
+ const got = {};
1773
+ await store.query_streams(
1774
+ (p) => {
1775
+ got.priority = p.priority;
1776
+ },
1777
+ { stream: s, stream_exact: true }
1778
+ );
1779
+ return got.priority;
1780
+ };
1781
+ await store.subscribe([{ stream: s, priority: -5 }]);
1782
+ (0, import_vitest9.expect)(await read()).toBe(-5);
1783
+ await store.subscribe([{ stream: s, priority: -1 }]);
1784
+ (0, import_vitest9.expect)(await read()).toBe(-1);
1785
+ await store.subscribe([{ stream: s, priority: -9 }]);
1786
+ (0, import_vitest9.expect)(await read()).toBe(-1);
1787
+ await store.subscribe([{ stream: s }]);
1788
+ (0, import_vitest9.expect)(await read()).toBe(0);
1789
+ });
1790
+ (0, import_vitest9.it)("restores the declared priority on the next subscribe after a prioritize() downgrade", async () => {
1791
+ const s = `sub-pri-restore-${uid()}`;
1792
+ const read = async () => {
1793
+ const got = {};
1794
+ await store.query_streams(
1795
+ (p) => {
1796
+ got.priority = p.priority;
1797
+ },
1798
+ { stream: s, stream_exact: true }
1799
+ );
1800
+ return got.priority;
1801
+ };
1802
+ await store.subscribe([{ stream: s }]);
1803
+ (0, import_vitest9.expect)(await read()).toBe(0);
1804
+ await store.prioritize({ stream: s, stream_exact: true }, -5);
1805
+ (0, import_vitest9.expect)(await read()).toBe(-5);
1806
+ await store.subscribe([{ stream: s }]);
1807
+ (0, import_vitest9.expect)(await read()).toBe(0);
1808
+ });
1741
1809
  (0, import_vitest9.it)("claims a subscribed stream and ack releases the lease", async () => {
1742
1810
  const s = `claim-${uid()}`;
1743
1811
  await store.subscribe([{ stream: s }]);
@@ -2136,12 +2204,8 @@ var runStoreTck = (options) => {
2136
2204
  const first = await fresh.claim(100, 0, `w-${uid()}`, 3e4);
2137
2205
  const l1 = first.find((s) => s.stream === target);
2138
2206
  (0, import_vitest9.expect)(l1).toBeDefined();
2139
- const c1 = first.find((s) => s.stream === control);
2140
- (0, import_vitest9.expect)(c1).toBeDefined();
2141
- await fresh.ack([
2142
- { ...l1, at: ea.id },
2143
- { ...c1, at: -1 }
2144
- ]);
2207
+ (0, import_vitest9.expect)(first.map((s) => s.stream)).not.toContain(control);
2208
+ await fresh.ack([{ ...l1, at: ea.id }]);
2145
2209
  await seed_stream(fresh, other, 1);
2146
2210
  const claimed = await fresh.claim(100, 0, `w-${uid()}`, 3e4);
2147
2211
  const streams = claimed.map((s) => s.stream);