@rotorsoft/act-tck 1.15.0 → 1.16.0

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/index.cjs CHANGED
@@ -643,13 +643,14 @@ var runStoreTck = (options) => {
643
643
  });
644
644
  (0, import_vitest6.it)("created_after/created_before filter by timestamp", async () => {
645
645
  const s = `q-ts-${uid()}`;
646
- const before = new Date(Date.now() - 6e4);
647
- const future = new Date(Date.now() + 6e4);
648
- await store.commit(
646
+ const committed = await store.commit(
649
647
  s,
650
648
  [inc(1)],
651
649
  make_meta({ stream: s })
652
650
  );
651
+ const ts = committed[0].created.getTime();
652
+ const before = new Date(ts - 6e4);
653
+ const future = new Date(ts + 6e4);
653
654
  const in_window = await collect(store, {
654
655
  stream: s,
655
656
  stream_exact: true,
@@ -700,8 +701,12 @@ var runStoreTck = (options) => {
700
701
  });
701
702
  (0, import_vitest6.it)("backward traversal honors created_before by skipping newer events", async () => {
702
703
  const s = `q-back-ts-${uid()}`;
703
- await store.commit(s, [inc(1)], make_meta());
704
- const past = new Date(Date.now() - 6e4);
704
+ const committed = await store.commit(
705
+ s,
706
+ [inc(1)],
707
+ make_meta()
708
+ );
709
+ const past = new Date(committed[0].created.getTime() - 6e4);
705
710
  const got = await collect(store, {
706
711
  stream: s,
707
712
  stream_exact: true,
@@ -1902,7 +1907,88 @@ var runStoreTck = (options) => {
1902
1907
  (0, import_vitest6.expect)(t.get(s)?.count).toBeUndefined();
1903
1908
  (0, import_vitest6.expect)(t.get(s)?.names).toBeUndefined();
1904
1909
  });
1910
+ (0, import_vitest6.it)("paginates with limit + after (keyset), ordered by stream name", async () => {
1911
+ const tag = uid();
1912
+ const streams = [
1913
+ `qsp-${tag}-a`,
1914
+ `qsp-${tag}-b`,
1915
+ `qsp-${tag}-c`,
1916
+ `qsp-${tag}-d`
1917
+ ];
1918
+ for (const s of streams) {
1919
+ await store.commit(
1920
+ s,
1921
+ [inc(1)],
1922
+ make_meta({ stream: s })
1923
+ );
1924
+ }
1925
+ const page1 = await store.query_stats(
1926
+ { stream: `qsp-${tag}-.*` },
1927
+ { limit: 2 }
1928
+ );
1929
+ const k1 = [...page1.keys()];
1930
+ (0, import_vitest6.expect)(k1).toEqual([`qsp-${tag}-a`, `qsp-${tag}-b`]);
1931
+ const page2 = await store.query_stats(
1932
+ { stream: `qsp-${tag}-.*` },
1933
+ { limit: 2, after: k1.at(-1) }
1934
+ );
1935
+ const k2 = [...page2.keys()];
1936
+ (0, import_vitest6.expect)(k2).toEqual([`qsp-${tag}-c`, `qsp-${tag}-d`]);
1937
+ const page3 = await store.query_stats(
1938
+ { stream: `qsp-${tag}-.*` },
1939
+ { limit: 2, after: k2.at(-1) }
1940
+ );
1941
+ (0, import_vitest6.expect)(page3.size).toBe(0);
1942
+ const all = await store.query_stats({
1943
+ stream: `qsp-${tag}-.*`
1944
+ });
1945
+ (0, import_vitest6.expect)([...all.keys()].sort()).toEqual([...streams].sort());
1946
+ });
1905
1947
  });
1948
+ import_vitest6.describe.skipIf(!caps.source_matches)(
1949
+ "query_streams source_matches (capability)",
1950
+ () => {
1951
+ (0, import_vitest6.it)("returns only subscriptions whose source pattern matches a name", async () => {
1952
+ const tag = uid();
1953
+ const subConcreteA = `sm-${tag}-sub-a`;
1954
+ const subConcreteB = `sm-${tag}-sub-b`;
1955
+ const subRegex = `sm-${tag}-sub-regex`;
1956
+ const subNoSource = `sm-${tag}-sub-nosource`;
1957
+ const srcA = `sm-${tag}-order-1`;
1958
+ const srcB = `sm-${tag}-order-2`;
1959
+ const srcRegex = `^sm-${tag}-order-`;
1960
+ await store.subscribe([
1961
+ { stream: subConcreteA, source: srcA },
1962
+ { stream: subConcreteB, source: srcB },
1963
+ { stream: subRegex, source: srcRegex },
1964
+ // No source = no source constraint = matches every name.
1965
+ { stream: subNoSource }
1966
+ ]);
1967
+ const matched = [];
1968
+ await store.query_streams((p) => matched.push(p.stream), {
1969
+ stream: `sm-${tag}-sub-.*`,
1970
+ source_matches: [srcA]
1971
+ });
1972
+ (0, import_vitest6.expect)(matched.sort()).toEqual(
1973
+ [subConcreteA, subRegex, subNoSource].sort()
1974
+ );
1975
+ const none = [];
1976
+ await store.query_streams((p) => none.push(p.stream), {
1977
+ stream: `sm-${tag}-sub-.*`,
1978
+ source_matches: [`sm-${tag}-unrelated`]
1979
+ });
1980
+ (0, import_vitest6.expect)(none).toEqual([subNoSource]);
1981
+ const both = [];
1982
+ await store.query_streams((p) => both.push(p.stream), {
1983
+ stream: `sm-${tag}-sub-.*`,
1984
+ source_matches: [srcA, srcB]
1985
+ });
1986
+ (0, import_vitest6.expect)(both.sort()).toEqual(
1987
+ [subConcreteA, subConcreteB, subRegex, subNoSource].sort()
1988
+ );
1989
+ });
1990
+ }
1991
+ );
1906
1992
  (0, import_vitest6.describe)("query_streams anchor contract", () => {
1907
1993
  (0, import_vitest6.it)("plain regex without anchors is a substring match", async () => {
1908
1994
  const tag = uid();