@rotorsoft/act-tck 1.27.3 → 1.27.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/dist/index.js CHANGED
@@ -3931,6 +3931,97 @@ var runStoreTck = (options) => {
3931
3931
  );
3932
3932
  expect8(calls).toEqual([1, 2]);
3933
3933
  });
3934
+ it7("query created bounds are filters, not id-ordered breaks", async () => {
3935
+ const s = `restore-created-order-${uid()}`;
3936
+ const newest = /* @__PURE__ */ new Date("2020-06-01T00:00:00.000Z");
3937
+ const oldest = /* @__PURE__ */ new Date("2020-01-01T00:00:00.000Z");
3938
+ await restore(
3939
+ as_source([
3940
+ event(1, s, 0, "Incremented", newest, { amount: 10 }),
3941
+ event(2, s, 1, "Incremented", oldest, { amount: 20 })
3942
+ ])
3943
+ );
3944
+ const cutoff = /* @__PURE__ */ new Date("2020-03-01T00:00:00.000Z");
3945
+ const fwd = [];
3946
+ await store.query(
3947
+ (e) => {
3948
+ fwd.push(e.data.amount);
3949
+ },
3950
+ { stream: s, stream_exact: true, created_before: cutoff }
3951
+ );
3952
+ expect8(fwd).toEqual([20]);
3953
+ const bwd = [];
3954
+ await store.query(
3955
+ (e) => {
3956
+ bwd.push(e.data.amount);
3957
+ },
3958
+ {
3959
+ stream: s,
3960
+ stream_exact: true,
3961
+ created_after: cutoff,
3962
+ backward: true
3963
+ }
3964
+ );
3965
+ expect8(bwd).toEqual([10]);
3966
+ });
3967
+ it7.skipIf(!caps.pii_isolation)(
3968
+ "isolates restored pii so forget_pii erases it",
3969
+ async () => {
3970
+ const s = `restore-pii-${uid()}`;
3971
+ const t = /* @__PURE__ */ new Date("2020-05-01T00:00:00.000Z");
3972
+ const result = await restore(
3973
+ as_source([
3974
+ {
3975
+ id: 1,
3976
+ stream: s,
3977
+ version: 0,
3978
+ name: "Incremented",
3979
+ data: { amount: 1 },
3980
+ pii: { email: "first@example.com" },
3981
+ created: t,
3982
+ meta: { correlation: "restore-tck", causation: {} }
3983
+ },
3984
+ {
3985
+ id: 2,
3986
+ stream: s,
3987
+ version: 1,
3988
+ name: "Incremented",
3989
+ data: { amount: 2 },
3990
+ pii: { email: "second@example.com" },
3991
+ created: t,
3992
+ meta: { correlation: "restore-tck", causation: {} }
3993
+ }
3994
+ ])
3995
+ );
3996
+ expect8(result.kept).toBe(2);
3997
+ const before = [];
3998
+ await store.query(
3999
+ (e) => {
4000
+ before.push(e);
4001
+ },
4002
+ { stream: s, stream_exact: true }
4003
+ );
4004
+ expect8(before.map((e) => e.pii)).toEqual([
4005
+ { email: "first@example.com" },
4006
+ { email: "second@example.com" }
4007
+ ]);
4008
+ const wiped = await store.forget_pii.call(store, s);
4009
+ expect8(wiped).toBe(2);
4010
+ const after = [];
4011
+ await store.query(
4012
+ (e) => {
4013
+ after.push(e);
4014
+ },
4015
+ { stream: s, stream_exact: true }
4016
+ );
4017
+ expect8(after).toHaveLength(2);
4018
+ for (const e of after) expect8(e.pii == null).toBe(true);
4019
+ expect8(after.map((e) => e.data)).toEqual([
4020
+ { amount: 1 },
4021
+ { amount: 2 }
4022
+ ]);
4023
+ }
4024
+ );
3934
4025
  });
3935
4026
  describe8.skipIf(!caps.pii_isolation)("pii_isolation (capability)", () => {
3936
4027
  it7("commits and loads pii alongside data", async () => {