@rotorsoft/act-tck 1.27.4 → 1.27.6
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/.tsbuildinfo +1 -1
- package/dist/@types/store-tck.d.ts.map +1 -1
- package/dist/index.cjs +154 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2147,6 +2147,27 @@ var runStoreTck = (options) => {
|
|
|
2147
2147
|
]);
|
|
2148
2148
|
expect8(blocked).toHaveLength(0);
|
|
2149
2149
|
});
|
|
2150
|
+
it7("re-blocking an already-blocked stream is a no-op (#1263)", async () => {
|
|
2151
|
+
const s = `block-twice-${uid()}`;
|
|
2152
|
+
await store.subscribe([{ stream: s }]);
|
|
2153
|
+
await store.commit(
|
|
2154
|
+
s,
|
|
2155
|
+
[inc(1)],
|
|
2156
|
+
make_meta({ stream: s })
|
|
2157
|
+
);
|
|
2158
|
+
const leased = await store.claim(100, 0, `w-${uid()}`, 1e5);
|
|
2159
|
+
const mine = leased.find((l) => l.stream === s);
|
|
2160
|
+
expect8(mine).toBeDefined();
|
|
2161
|
+
await store.ack(leased.filter((l) => l.stream !== s));
|
|
2162
|
+
const first = await store.block([
|
|
2163
|
+
{ ...mine, error: "boom" }
|
|
2164
|
+
]);
|
|
2165
|
+
expect8(first).toHaveLength(1);
|
|
2166
|
+
const second = await store.block([
|
|
2167
|
+
{ ...mine, error: "boom" }
|
|
2168
|
+
]);
|
|
2169
|
+
expect8(second).toHaveLength(0);
|
|
2170
|
+
});
|
|
2150
2171
|
});
|
|
2151
2172
|
describe8("defer", () => {
|
|
2152
2173
|
it7("hides a stream from claim until its deferred_at passes", async () => {
|
|
@@ -3931,6 +3952,139 @@ var runStoreTck = (options) => {
|
|
|
3931
3952
|
);
|
|
3932
3953
|
expect8(calls).toEqual([1, 2]);
|
|
3933
3954
|
});
|
|
3955
|
+
it7("query created bounds are filters, not id-ordered breaks", async () => {
|
|
3956
|
+
const s = `restore-created-order-${uid()}`;
|
|
3957
|
+
const newest = /* @__PURE__ */ new Date("2020-06-01T00:00:00.000Z");
|
|
3958
|
+
const oldest = /* @__PURE__ */ new Date("2020-01-01T00:00:00.000Z");
|
|
3959
|
+
await restore(
|
|
3960
|
+
as_source([
|
|
3961
|
+
event(1, s, 0, "Incremented", newest, { amount: 10 }),
|
|
3962
|
+
event(2, s, 1, "Incremented", oldest, { amount: 20 })
|
|
3963
|
+
])
|
|
3964
|
+
);
|
|
3965
|
+
const cutoff = /* @__PURE__ */ new Date("2020-03-01T00:00:00.000Z");
|
|
3966
|
+
const fwd = [];
|
|
3967
|
+
await store.query(
|
|
3968
|
+
(e) => {
|
|
3969
|
+
fwd.push(e.data.amount);
|
|
3970
|
+
},
|
|
3971
|
+
{ stream: s, stream_exact: true, created_before: cutoff }
|
|
3972
|
+
);
|
|
3973
|
+
expect8(fwd).toEqual([20]);
|
|
3974
|
+
const bwd = [];
|
|
3975
|
+
await store.query(
|
|
3976
|
+
(e) => {
|
|
3977
|
+
bwd.push(e.data.amount);
|
|
3978
|
+
},
|
|
3979
|
+
{
|
|
3980
|
+
stream: s,
|
|
3981
|
+
stream_exact: true,
|
|
3982
|
+
created_after: cutoff,
|
|
3983
|
+
backward: true
|
|
3984
|
+
}
|
|
3985
|
+
);
|
|
3986
|
+
expect8(bwd).toEqual([10]);
|
|
3987
|
+
});
|
|
3988
|
+
it7("time-travel query ignores a snapshot newer than the created cutoff", async () => {
|
|
3989
|
+
const s = `restore-tt-snap-${uid()}`;
|
|
3990
|
+
const t0 = /* @__PURE__ */ new Date("2020-01-01T00:00:00.000Z");
|
|
3991
|
+
const t1 = /* @__PURE__ */ new Date("2020-02-01T00:00:00.000Z");
|
|
3992
|
+
const tSnap = /* @__PURE__ */ new Date("2020-03-01T00:00:00.000Z");
|
|
3993
|
+
await restore(
|
|
3994
|
+
as_source([
|
|
3995
|
+
event(1, s, 0, "Incremented", t0, { amount: 1 }),
|
|
3996
|
+
event(2, s, 1, "Incremented", t1, { amount: 2 }),
|
|
3997
|
+
// Snapshot committed last → highest id and latest `created`.
|
|
3998
|
+
event(3, s, 2, SNAP_EVENT2, tSnap, { count: 3 })
|
|
3999
|
+
])
|
|
4000
|
+
);
|
|
4001
|
+
const cutoff = /* @__PURE__ */ new Date("2020-01-15T00:00:00.000Z");
|
|
4002
|
+
const before = [];
|
|
4003
|
+
await store.query(
|
|
4004
|
+
(e) => {
|
|
4005
|
+
before.push(e.data.amount);
|
|
4006
|
+
},
|
|
4007
|
+
{
|
|
4008
|
+
stream: s,
|
|
4009
|
+
stream_exact: true,
|
|
4010
|
+
with_snaps: true,
|
|
4011
|
+
created_before: cutoff
|
|
4012
|
+
}
|
|
4013
|
+
);
|
|
4014
|
+
expect8(before).toEqual([1]);
|
|
4015
|
+
const after = [];
|
|
4016
|
+
await store.query(
|
|
4017
|
+
(e) => {
|
|
4018
|
+
if (e.name !== SNAP_EVENT2)
|
|
4019
|
+
after.push(e.data.amount);
|
|
4020
|
+
},
|
|
4021
|
+
{
|
|
4022
|
+
stream: s,
|
|
4023
|
+
stream_exact: true,
|
|
4024
|
+
with_snaps: true,
|
|
4025
|
+
created_after: cutoff
|
|
4026
|
+
}
|
|
4027
|
+
);
|
|
4028
|
+
expect8(after).toEqual([2]);
|
|
4029
|
+
});
|
|
4030
|
+
it7.skipIf(!caps.pii_isolation)(
|
|
4031
|
+
"isolates restored pii so forget_pii erases it",
|
|
4032
|
+
async () => {
|
|
4033
|
+
const s = `restore-pii-${uid()}`;
|
|
4034
|
+
const t = /* @__PURE__ */ new Date("2020-05-01T00:00:00.000Z");
|
|
4035
|
+
const result = await restore(
|
|
4036
|
+
as_source([
|
|
4037
|
+
{
|
|
4038
|
+
id: 1,
|
|
4039
|
+
stream: s,
|
|
4040
|
+
version: 0,
|
|
4041
|
+
name: "Incremented",
|
|
4042
|
+
data: { amount: 1 },
|
|
4043
|
+
pii: { email: "first@example.com" },
|
|
4044
|
+
created: t,
|
|
4045
|
+
meta: { correlation: "restore-tck", causation: {} }
|
|
4046
|
+
},
|
|
4047
|
+
{
|
|
4048
|
+
id: 2,
|
|
4049
|
+
stream: s,
|
|
4050
|
+
version: 1,
|
|
4051
|
+
name: "Incremented",
|
|
4052
|
+
data: { amount: 2 },
|
|
4053
|
+
pii: { email: "second@example.com" },
|
|
4054
|
+
created: t,
|
|
4055
|
+
meta: { correlation: "restore-tck", causation: {} }
|
|
4056
|
+
}
|
|
4057
|
+
])
|
|
4058
|
+
);
|
|
4059
|
+
expect8(result.kept).toBe(2);
|
|
4060
|
+
const before = [];
|
|
4061
|
+
await store.query(
|
|
4062
|
+
(e) => {
|
|
4063
|
+
before.push(e);
|
|
4064
|
+
},
|
|
4065
|
+
{ stream: s, stream_exact: true }
|
|
4066
|
+
);
|
|
4067
|
+
expect8(before.map((e) => e.pii)).toEqual([
|
|
4068
|
+
{ email: "first@example.com" },
|
|
4069
|
+
{ email: "second@example.com" }
|
|
4070
|
+
]);
|
|
4071
|
+
const wiped = await store.forget_pii.call(store, s);
|
|
4072
|
+
expect8(wiped).toBe(2);
|
|
4073
|
+
const after = [];
|
|
4074
|
+
await store.query(
|
|
4075
|
+
(e) => {
|
|
4076
|
+
after.push(e);
|
|
4077
|
+
},
|
|
4078
|
+
{ stream: s, stream_exact: true }
|
|
4079
|
+
);
|
|
4080
|
+
expect8(after).toHaveLength(2);
|
|
4081
|
+
for (const e of after) expect8(e.pii == null).toBe(true);
|
|
4082
|
+
expect8(after.map((e) => e.data)).toEqual([
|
|
4083
|
+
{ amount: 1 },
|
|
4084
|
+
{ amount: 2 }
|
|
4085
|
+
]);
|
|
4086
|
+
}
|
|
4087
|
+
);
|
|
3934
4088
|
});
|
|
3935
4089
|
describe8.skipIf(!caps.pii_isolation)("pii_isolation (capability)", () => {
|
|
3936
4090
|
it7("commits and loads pii alongside data", async () => {
|