@aikotools/datafilter 1.0.0 → 1.0.1

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.
@@ -1,11 +1,11 @@
1
- import { DateTime as E } from "luxon";
2
- function R(i) {
1
+ import { DateTime as $ } from "luxon";
2
+ function x(i) {
3
3
  return "matchAny" in i;
4
4
  }
5
- function S(i) {
5
+ function b(i) {
6
6
  return "match" in i && "expected" in i;
7
7
  }
8
- function k(i, s) {
8
+ function g(i, s) {
9
9
  const t = [];
10
10
  if (s.length === 0)
11
11
  return {
@@ -67,15 +67,15 @@ function k(i, s) {
67
67
  validPath: t
68
68
  };
69
69
  }
70
- function N(i, s) {
71
- const t = k(i, s);
70
+ function V(i, s) {
71
+ const t = g(i, s);
72
72
  return t.found && t.value !== void 0;
73
73
  }
74
- function z(i, s, t) {
75
- const e = k(i, s);
74
+ function I(i, s, t) {
75
+ const e = g(i, s);
76
76
  return e.found && e.value !== void 0 ? e.value : t;
77
77
  }
78
- class M {
78
+ class w {
79
79
  constructor(s) {
80
80
  this.context = s;
81
81
  }
@@ -104,7 +104,7 @@ class M {
104
104
  * @returns FilterCheckResult
105
105
  */
106
106
  checkValue(s, t, e) {
107
- const n = k(s, t);
107
+ const n = g(s, t);
108
108
  if (!n.found)
109
109
  return {
110
110
  status: !1,
@@ -138,7 +138,7 @@ class M {
138
138
  * @returns FilterCheckResult
139
139
  */
140
140
  checkExists(s, t, e) {
141
- const n = k(s, t), r = n.found && n.value !== void 0;
141
+ const n = g(s, t), r = n.found && n.value !== void 0;
142
142
  return e.exists === r ? {
143
143
  status: !0,
144
144
  checkType: "checkExists"
@@ -160,7 +160,7 @@ class M {
160
160
  * @returns FilterCheckResult
161
161
  */
162
162
  checkArrayElement(s, t, e) {
163
- const n = k(s, t);
163
+ const n = g(s, t);
164
164
  if (!n.found)
165
165
  return {
166
166
  status: !1,
@@ -204,7 +204,7 @@ class M {
204
204
  * @returns FilterCheckResult
205
205
  */
206
206
  checkArraySize(s, t, e) {
207
- const n = k(s, t);
207
+ const n = g(s, t);
208
208
  if (!n.found)
209
209
  return {
210
210
  status: !1,
@@ -261,7 +261,7 @@ class M {
261
261
  * @returns FilterCheckResult
262
262
  */
263
263
  checkTimeRange(s, t, e) {
264
- const n = k(s, t);
264
+ const n = g(s, t);
265
265
  if (!n.found)
266
266
  return {
267
267
  status: !1,
@@ -298,7 +298,7 @@ class M {
298
298
  };
299
299
  }
300
300
  if (typeof r == "string") {
301
- const a = E.fromISO(r), u = E.fromISO(e.min), c = E.fromISO(e.max);
301
+ const a = $.fromISO(r), u = $.fromISO(e.min), c = $.fromISO(e.max);
302
302
  return a.isValid ? !u.isValid || !c.isValid ? {
303
303
  status: !1,
304
304
  checkType: "checkTimeRange",
@@ -347,7 +347,7 @@ class M {
347
347
  * @returns FilterCheckResult
348
348
  */
349
349
  checkNumericRange(s, t, e) {
350
- const n = k(s, t);
350
+ const n = g(s, t);
351
351
  if (!n.found)
352
352
  return {
353
353
  status: !1,
@@ -401,9 +401,9 @@ class M {
401
401
  return s === t;
402
402
  }
403
403
  }
404
- class P {
404
+ class S {
405
405
  constructor(s) {
406
- this.engine = new M(s);
406
+ this.engine = new w(s);
407
407
  }
408
408
  /**
409
409
  * Matches a single file against a rule.
@@ -413,7 +413,7 @@ class P {
413
413
  * @returns MatchResult indicating if all criteria matched
414
414
  */
415
415
  matchFile(s, t) {
416
- const n = (R(t) ? t.matchAny : t.match).map((a) => this.engine.evaluateCriterion(s.data, a));
416
+ const n = (x(t) ? t.matchAny : t.match).map((a) => this.engine.evaluateCriterion(s.data, a));
417
417
  return {
418
418
  matched: n.every((a) => a.status),
419
419
  checks: n,
@@ -440,54 +440,53 @@ class P {
440
440
  * @returns FilterResult with mapped, wildcardMatched, and unmapped files
441
441
  */
442
442
  filterFiles(s, t, e, n) {
443
- var T, y;
444
- const r = n ? this.applyPreFilter(s, n) : s, a = e ? [...r].sort(e) : [...r], u = [], c = [], f = [], p = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Map();
443
+ const r = n ? this.applyPreFilter(s, n) : s, a = e ? [...r].sort(e) : [...r], u = [], c = [], f = [], y = /* @__PURE__ */ new Set(), k = /* @__PURE__ */ new Map();
445
444
  let o = 0, l = 0;
446
445
  for (; o < a.length; ) {
447
- const g = a[o];
446
+ const h = a[o];
448
447
  if (l >= t.length) {
449
- p.has(o) || f.push({
450
- file: g,
448
+ y.has(o) || f.push({
449
+ file: h,
451
450
  attemptedRules: []
452
451
  }), o++;
453
452
  continue;
454
453
  }
455
- const d = t[l], F = [];
456
- let b = !1;
457
- if (Array.isArray(d)) {
458
- for (let m = 0; m < d.length; m++) {
459
- if ((T = x.get(l)) == null ? void 0 : T.has(m))
454
+ const m = t[l], v = [];
455
+ let R = !1;
456
+ if (Array.isArray(m)) {
457
+ for (let p = 0; p < m.length; p++) {
458
+ if (k.get(l)?.has(p))
460
459
  continue;
461
- const v = d[m], $ = this.matchFile(g, v);
462
- if (F.push($), $.matched && S(v)) {
463
- x.has(l) || x.set(l, /* @__PURE__ */ new Set());
464
- const w = x.get(l);
465
- w && w.add(m), u.push({
466
- expected: v.expected,
467
- file: g,
468
- matchResult: $,
469
- optional: v.optional || !1,
470
- info: v.info
471
- }), p.add(o), b = !0;
460
+ const T = m[p], F = this.matchFile(h, T);
461
+ if (v.push(F), F.matched && b(T)) {
462
+ k.has(l) || k.set(l, /* @__PURE__ */ new Set());
463
+ const E = k.get(l);
464
+ E && E.add(p), u.push({
465
+ expected: T.expected,
466
+ file: h,
467
+ matchResult: F,
468
+ optional: T.optional || !1,
469
+ info: T.info
470
+ }), y.add(o), R = !0;
472
471
  break;
473
472
  }
474
473
  }
475
- ((y = x.get(l)) == null ? void 0 : y.size) === d.length && l++, o++;
474
+ k.get(l)?.size === m.length && l++, o++;
476
475
  } else {
477
- const h = d, m = this.matchFile(g, h);
478
- F.push(m), m.matched ? S(h) ? (u.push({
479
- expected: h.expected,
480
- file: g,
481
- matchResult: m,
482
- optional: h.optional || !1,
483
- info: h.info
484
- }), p.add(o), l++, o++) : R(h) && (c.push({
485
- file: g,
486
- matchResult: m,
487
- info: h.info
488
- }), p.add(o), h.greedy || l++, o++) : h.optional || R(h) ? l++ : (f.push({
489
- file: g,
490
- attemptedRules: F
476
+ const d = m, p = this.matchFile(h, d);
477
+ v.push(p), p.matched ? b(d) ? (u.push({
478
+ expected: d.expected,
479
+ file: h,
480
+ matchResult: p,
481
+ optional: d.optional || !1,
482
+ info: d.info
483
+ }), y.add(o), l++, o++) : x(d) && (c.push({
484
+ file: h,
485
+ matchResult: p,
486
+ info: d.info
487
+ }), y.add(o), d.greedy || l++, o++) : d.optional || x(d) ? l++ : (f.push({
488
+ file: h,
489
+ attemptedRules: v
491
490
  }), o++);
492
491
  }
493
492
  }
@@ -517,13 +516,13 @@ class P {
517
516
  * Counts mandatory rules
518
517
  */
519
518
  countMandatoryRules(s) {
520
- return s.reduce((t, e) => Array.isArray(e) ? t + e.filter((n) => !n.optional && !R(n)).length : t + (e.optional || R(e) ? 0 : 1), 0);
519
+ return s.reduce((t, e) => Array.isArray(e) ? t + e.filter((n) => !n.optional && !x(n)).length : t + (e.optional || x(e) ? 0 : 1), 0);
521
520
  }
522
521
  /**
523
522
  * Counts optional rules
524
523
  */
525
524
  countOptionalRules(s) {
526
- return s.reduce((t, e) => Array.isArray(e) ? t + e.filter((n) => n.optional || R(n)).length : t + (e.optional || R(e) ? 1 : 0), 0);
525
+ return s.reduce((t, e) => Array.isArray(e) ? t + e.filter((n) => n.optional || x(n)).length : t + (e.optional || x(e) ? 1 : 0), 0);
527
526
  }
528
527
  /**
529
528
  * Filtering function for grouped rules with common filter criteria.
@@ -539,31 +538,31 @@ class P {
539
538
  filterFilesWithGroups(s, t, e, n) {
540
539
  const r = n ? this.applyPreFilter(s, n) : s, a = e ? [...r].sort(e) : [...r], u = [], c = [], f = [];
541
540
  for (const o of t) {
542
- const l = a.filter((y) => o.groupFilter.map((d) => this.engine.evaluateCriterion(y.data, d)).every((d) => d.status));
541
+ const l = a.filter((m) => o.groupFilter.map((R) => this.engine.evaluateCriterion(m.data, R)).every((R) => R.status));
543
542
  if (l.length === 0)
544
543
  continue;
545
- const A = o.rules.map((y) => (Array.isArray(y), y)), T = this.filterFiles(l, A);
546
- u.push(...T.mapped), c.push(...T.wildcardMatched), f.push(...T.unmapped);
544
+ const A = o.rules.map((m) => (Array.isArray(m), m)), h = this.filterFiles(l, A);
545
+ u.push(...h.mapped), c.push(...h.wildcardMatched), f.push(...h.unmapped);
547
546
  }
548
- const p = t.flatMap((o) => o.rules), x = {
547
+ const y = t.flatMap((o) => o.rules), k = {
549
548
  totalFiles: s.length,
550
549
  mappedFiles: u.length,
551
550
  wildcardMatchedFiles: c.length,
552
551
  unmappedFiles: f.length,
553
- totalRules: this.countRules(p),
554
- mandatoryRules: this.countMandatoryRules(p),
555
- optionalRules: this.countOptionalRules(p)
552
+ totalRules: this.countRules(y),
553
+ mandatoryRules: this.countMandatoryRules(y),
554
+ optionalRules: this.countOptionalRules(y)
556
555
  };
557
556
  return {
558
557
  mapped: u,
559
558
  wildcardMatched: c,
560
559
  unmapped: f,
561
- stats: x
560
+ stats: k
562
561
  };
563
562
  }
564
563
  }
565
- function O(i) {
566
- const s = new P(i.context);
564
+ function N(i) {
565
+ const s = new S(i.context);
567
566
  if (i.rules && i.groups)
568
567
  throw new Error('FilterRequest: Provide either "rules" or "groups", not both');
569
568
  if (!i.rules && !i.groups)
@@ -580,12 +579,12 @@ function O(i) {
580
579
  return s.filterFiles(i.files, i.rules, i.sortFn, i.preFilter);
581
580
  }
582
581
  export {
583
- M as FilterEngine,
584
- P as Matcher,
585
- O as filterFiles,
586
- k as getValueFromPath,
587
- z as getValueOr,
588
- S as isSingleMatchRule,
589
- R as isWildcardRule,
590
- N as pathExists
582
+ w as FilterEngine,
583
+ S as Matcher,
584
+ N as filterFiles,
585
+ g as getValueFromPath,
586
+ I as getValueOr,
587
+ b as isSingleMatchRule,
588
+ x as isWildcardRule,
589
+ V as pathExists
591
590
  };
@@ -1,5 +1,4 @@
1
1
  import { FilterCriterion, FilterCheckResult } from '../core/types';
2
-
3
2
  /**
4
3
  * Filter engine that evaluates filter criteria against data objects.
5
4
  * Provides various check methods for different types of comparisons.
@@ -1 +1 @@
1
- {"version":3,"file":"FilterEngine.d.ts","sourceRoot":"","sources":["../../../src/engine/FilterEngine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAOlB,MAAM,eAAe,CAAA;AAGtB;;;GAGG;AACH,qBAAa,YAAY;IACvB;;OAEG;IAEH,OAAO,CAAC,OAAO,CAAC,CAGf;gBAEW,OAAO,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;IAI1E;;;;;;OAMG;IAEH,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,eAAe,GAAG,iBAAiB;IAoC3E;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;IAyClB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;IA4BnB;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;IAwDzB;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAyEtB;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAqHtB;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;IAqDzB;;;OAGG;IAEH,OAAO,CAAC,SAAS;CAmClB"}
1
+ {"version":3,"file":"FilterEngine.d.ts","sourceRoot":"","sources":["../../../src/engine/FilterEngine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAOlB,MAAM,eAAe,CAAA;AAGtB;;;GAGG;AACH,qBAAa,YAAY;IACvB;;OAEG;IACH,OAAO,CAAC,OAAO,CAAC,CAGf;gBAEW,OAAO,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;IAI1E;;;;;;OAMG;IAEH,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,eAAe,GAAG,iBAAiB;IAoC3E;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;IAyClB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;IA4BnB;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;IAwDzB;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAyEtB;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAqHtB;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;IAqDzB;;;OAGG;IAEH,OAAO,CAAC,SAAS;CAmClB"}
@@ -1,5 +1,4 @@
1
1
  import { JsonFile, MatchRule, FilterResult, MatchResult, FilterCriterion, FilterGroup } from '../core/types';
2
-
3
2
  /**
4
3
  * Matcher system that matches files against rules.
5
4
  * Supports single matches, flexible ordering, and wildcard matches.
@@ -1,5 +1,4 @@
1
1
  import { PathElement } from '../core/types';
2
-
3
2
  /**
4
3
  * Result of accessing a value from an object
5
4
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikotools/datafilter",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Advanced data filtering engine for JSON file matching in E2E testing",
5
5
  "main": "dist/aikotools-datafilter.js",
6
6
  "module": "dist/aikotools-datafilter.js",
@@ -38,15 +38,15 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/luxon": "^3.7.1",
41
- "@types/node": "^20.0.0",
42
- "@typescript-eslint/eslint-plugin": "^7.0.0",
43
- "@typescript-eslint/parser": "^7.0.0",
44
- "@vitest/coverage-v8": "^1.6.0",
45
- "eslint": "^8.57.0",
46
- "prettier": "^3.0.0",
47
- "typescript": "^5.4.0",
48
- "vite": "^5.0.0",
49
- "vite-plugin-dts": "^3.0.0",
50
- "vitest": "^1.0.0"
41
+ "@types/node": "^24.9.1",
42
+ "@typescript-eslint/eslint-plugin": "^8.46.2",
43
+ "@typescript-eslint/parser": "^8.46.2",
44
+ "@vitest/coverage-v8": "^3.2.4",
45
+ "eslint": "^9.38.0",
46
+ "prettier": "^3.6.2",
47
+ "typescript": "^5.9.3",
48
+ "vite": "^7.1.11",
49
+ "vite-plugin-dts": "^4.5.4",
50
+ "vitest": "^3.2.4"
51
51
  }
52
52
  }