@rotorsoft/act-tck 1.19.2 → 1.19.3

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
@@ -1203,6 +1203,94 @@ var runStoreTck = (options) => {
1203
1203
  (0, import_vitest9.expect)(got.map((e) => e.stream).sort()).toEqual([a, b].sort());
1204
1204
  });
1205
1205
  });
1206
+ (0, import_vitest9.describe)("stream filter grammar", () => {
1207
+ const seed_streams = async (streams) => {
1208
+ for (const s of streams)
1209
+ await store.commit(
1210
+ s,
1211
+ [inc(1)],
1212
+ make_meta({ stream: s })
1213
+ );
1214
+ };
1215
+ const streams_matching = async (pattern) => (await collect(store, { stream: pattern })).map((e) => e.stream).sort();
1216
+ const match_exactly_or_throw = async (pattern, expected) => {
1217
+ let matched;
1218
+ let error;
1219
+ try {
1220
+ matched = await streams_matching(pattern);
1221
+ } catch (e) {
1222
+ error = e;
1223
+ }
1224
+ if (error !== void 0) (0, import_vitest9.expect)(error).toBeInstanceOf(import_act2.ValidationError);
1225
+ else (0, import_vitest9.expect)(matched).toEqual(expected.sort());
1226
+ };
1227
+ (0, import_vitest9.it)("portable subset: anchors, `.`, and `.*` match identically", async () => {
1228
+ const tag = uid();
1229
+ const plain = `g-${tag}-plain`;
1230
+ const dotted = `g-${tag}.dot`;
1231
+ const scored = `g-${tag}_us`;
1232
+ const pct = `g-${tag}%pc`;
1233
+ await seed_streams([plain, dotted, scored, pct]);
1234
+ (0, import_vitest9.expect)(await streams_matching(`^g-${tag}`)).toEqual(
1235
+ [plain, dotted, scored, pct].sort()
1236
+ );
1237
+ (0, import_vitest9.expect)(await streams_matching(`${tag}-plain$`)).toEqual([plain]);
1238
+ (0, import_vitest9.expect)(await streams_matching(`^g-${tag}-plain$`)).toEqual([plain]);
1239
+ (0, import_vitest9.expect)(await streams_matching(`^g-${tag}.dot$`)).toEqual([dotted]);
1240
+ (0, import_vitest9.expect)(await streams_matching(`^g-${tag}.plain$`)).toEqual([plain]);
1241
+ (0, import_vitest9.expect)(await streams_matching(`^g-${tag}.*dot$`)).toEqual([dotted]);
1242
+ });
1243
+ (0, import_vitest9.it)("literal `_` and `%` in patterns are not wildcards", async () => {
1244
+ const tag = uid();
1245
+ const scored = `u-${tag}_x`;
1246
+ const scored_decoy = `u-${tag}Zx`;
1247
+ const pct = `p-${tag}%y`;
1248
+ const pct_decoy = `p-${tag}ZZy`;
1249
+ await seed_streams([scored, scored_decoy, pct, pct_decoy]);
1250
+ (0, import_vitest9.expect)(await streams_matching(`^u-${tag}_x$`)).toEqual([scored]);
1251
+ (0, import_vitest9.expect)(await streams_matching(`^p-${tag}%y$`)).toEqual([pct]);
1252
+ });
1253
+ (0, import_vitest9.it)("portable subset applies to stream-position filters", async () => {
1254
+ const tag = uid();
1255
+ const scored = `sf-${tag}_a`;
1256
+ const decoy = `sf-${tag}Za`;
1257
+ await store.subscribe([{ stream: scored }, { stream: decoy }]);
1258
+ const got = [];
1259
+ await store.query_streams((p) => got.push(p.stream), {
1260
+ stream: `^sf-${tag}_a$`
1261
+ });
1262
+ (0, import_vitest9.expect)(got).toEqual([scored]);
1263
+ });
1264
+ (0, import_vitest9.it)("non-portable patterns match with full regex semantics or throw", async () => {
1265
+ const tag = uid();
1266
+ const a = `np-${tag}-a`;
1267
+ const b = `np-${tag}-b`;
1268
+ const c = `np-${tag}-c`;
1269
+ const one = `np-${tag}-1`;
1270
+ const aaa = `np-${tag}-aaa`;
1271
+ const dot = `e-${tag}.d`;
1272
+ const dot_decoy = `e-${tag}xd`;
1273
+ await seed_streams([a, b, c, one, aaa, dot, dot_decoy]);
1274
+ await match_exactly_or_throw(`^np-${tag}-(a|b)$`, [a, b]);
1275
+ await match_exactly_or_throw(`^np-${tag}-[0-9]$`, [one]);
1276
+ await match_exactly_or_throw(`^np-${tag}-a+$`, [a, aaa]);
1277
+ await match_exactly_or_throw(`^e-${tag}\\.d$`, [dot]);
1278
+ });
1279
+ (0, import_vitest9.it)("bulk stream ops reject non-portable filters instead of mis-matching", async () => {
1280
+ const tag = uid();
1281
+ const s = `bo-${tag}-a`;
1282
+ await store.subscribe([{ stream: s }]);
1283
+ let count;
1284
+ let error;
1285
+ try {
1286
+ count = await store.reset({ stream: `^bo-${tag}-(a|b)$` });
1287
+ } catch (e) {
1288
+ error = e;
1289
+ }
1290
+ if (error !== void 0) (0, import_vitest9.expect)(error).toBeInstanceOf(import_act2.ValidationError);
1291
+ else (0, import_vitest9.expect)(count).toBe(1);
1292
+ });
1293
+ });
1206
1294
  (0, import_vitest9.describe)("subscribe + claim + ack", () => {
1207
1295
  (0, import_vitest9.it)("subscribes new streams and is idempotent on repeat", async () => {
1208
1296
  const s = `sub-${uid()}`;