@rotorsoft/act-tck 1.3.0 → 1.5.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.js CHANGED
@@ -1553,8 +1553,7 @@ var runStoreTck = (options) => {
1553
1553
  expect3(result.duration_ms).toBeGreaterThanOrEqual(0);
1554
1554
  expect3(result.dropped).toEqual({
1555
1555
  closed_streams: 0,
1556
- snapshots: 0,
1557
- empty_streams: 0
1556
+ snapshots: 0
1558
1557
  });
1559
1558
  const events = await collect(store, { limit: 10 });
1560
1559
  expect3(events).toHaveLength(0);
@@ -1896,6 +1895,153 @@ var runStoreTck = (options) => {
1896
1895
  expect3(calls).toEqual([1, 2]);
1897
1896
  });
1898
1897
  });
1898
+ describe3.skipIf(!caps.pii_isolation)("pii_isolation (capability)", () => {
1899
+ it3("commits and loads pii alongside data", async () => {
1900
+ const s = `pii-roundtrip-${uid()}`;
1901
+ const committed = await store.commit(
1902
+ s,
1903
+ [
1904
+ {
1905
+ name: "Incremented",
1906
+ data: { amount: 1 },
1907
+ pii: { email: "u@example.com", name: "Ursula" }
1908
+ }
1909
+ ],
1910
+ makeMeta({ stream: s })
1911
+ );
1912
+ expect3(committed).toHaveLength(1);
1913
+ expect3(committed[0].pii).toEqual({
1914
+ email: "u@example.com",
1915
+ name: "Ursula"
1916
+ });
1917
+ const seen = [];
1918
+ await store.query(
1919
+ (e) => {
1920
+ seen.push(e);
1921
+ },
1922
+ { stream: s, stream_exact: true }
1923
+ );
1924
+ expect3(seen).toHaveLength(1);
1925
+ expect3(seen[0].pii).toEqual({ email: "u@example.com", name: "Ursula" });
1926
+ expect3(seen[0].data).toEqual({ amount: 1 });
1927
+ });
1928
+ it3("passes through events without pii (pii is null or undefined on load)", async () => {
1929
+ const s = `pii-none-${uid()}`;
1930
+ await store.commit(s, [inc(1)], makeMeta({ stream: s }));
1931
+ const seen = [];
1932
+ await store.query(
1933
+ (e) => {
1934
+ seen.push(e);
1935
+ },
1936
+ { stream: s, stream_exact: true }
1937
+ );
1938
+ expect3(seen).toHaveLength(1);
1939
+ expect3(seen[0].pii == null).toBe(true);
1940
+ });
1941
+ it3("wipes pii for every event on the stream via forget_pii", async () => {
1942
+ const s = `pii-forget-${uid()}`;
1943
+ await store.commit(
1944
+ s,
1945
+ [
1946
+ {
1947
+ name: "Incremented",
1948
+ data: { amount: 1 },
1949
+ pii: { email: "a@example.com" }
1950
+ },
1951
+ {
1952
+ name: "Incremented",
1953
+ data: { amount: 2 },
1954
+ pii: { email: "b@example.com" }
1955
+ }
1956
+ ],
1957
+ makeMeta({ stream: s })
1958
+ );
1959
+ const forget = store.forget_pii;
1960
+ expect3(forget).toBeDefined();
1961
+ const wiped = await forget.call(store, s);
1962
+ expect3(wiped).toBe(2);
1963
+ const seen = [];
1964
+ await store.query(
1965
+ (e) => {
1966
+ seen.push(e);
1967
+ },
1968
+ { stream: s, stream_exact: true }
1969
+ );
1970
+ expect3(seen).toHaveLength(2);
1971
+ for (const e of seen) {
1972
+ expect3(e.pii == null).toBe(true);
1973
+ expect3(e.data).toBeDefined();
1974
+ }
1975
+ });
1976
+ it3("is idempotent \u2014 second forget_pii returns 0, no error", async () => {
1977
+ const s = `pii-forget-idem-${uid()}`;
1978
+ await store.commit(
1979
+ s,
1980
+ [
1981
+ {
1982
+ name: "Incremented",
1983
+ data: { amount: 1 },
1984
+ pii: { email: "u@example.com" }
1985
+ }
1986
+ ],
1987
+ makeMeta({ stream: s })
1988
+ );
1989
+ const forget = store.forget_pii;
1990
+ const first = await forget.call(store, s);
1991
+ expect3(first).toBe(1);
1992
+ const second = await forget.call(store, s);
1993
+ expect3(second).toBe(0);
1994
+ });
1995
+ it3("only wipes the targeted stream \u2014 siblings untouched", async () => {
1996
+ const sA = `pii-iso-a-${uid()}`;
1997
+ const sB = `pii-iso-b-${uid()}`;
1998
+ await store.commit(
1999
+ sA,
2000
+ [
2001
+ {
2002
+ name: "Incremented",
2003
+ data: { amount: 1 },
2004
+ pii: { email: "alice@example.com" }
2005
+ }
2006
+ ],
2007
+ makeMeta({ stream: sA })
2008
+ );
2009
+ await store.commit(
2010
+ sB,
2011
+ [
2012
+ {
2013
+ name: "Incremented",
2014
+ data: { amount: 1 },
2015
+ pii: { email: "bob@example.com" }
2016
+ }
2017
+ ],
2018
+ makeMeta({ stream: sB })
2019
+ );
2020
+ await store.forget_pii.call(store, sA);
2021
+ const a = [];
2022
+ await store.query(
2023
+ (e) => {
2024
+ a.push(e);
2025
+ },
2026
+ { stream: sA, stream_exact: true }
2027
+ );
2028
+ expect3(a[0].pii == null).toBe(true);
2029
+ const b = [];
2030
+ await store.query(
2031
+ (e) => {
2032
+ b.push(e);
2033
+ },
2034
+ { stream: sB, stream_exact: true }
2035
+ );
2036
+ expect3(b[0].pii).toEqual({ email: "bob@example.com" });
2037
+ });
2038
+ it3("forget_pii on a stream with no pii events returns 0", async () => {
2039
+ const s = `pii-forget-empty-${uid()}`;
2040
+ await store.commit(s, [inc(1)], makeMeta({ stream: s }));
2041
+ const wiped = await store.forget_pii.call(store, s);
2042
+ expect3(wiped).toBe(0);
2043
+ });
2044
+ });
1899
2045
  if (caps.notify) {
1900
2046
  describe3("notify (capability)", () => {
1901
2047
  it3("delivers a notification when a different instance commits", async () => {