@aikotools/datafilter 1.0.2 → 1.0.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/README.md +154 -3
- package/dist/aikotools-datafilter.cjs +1 -1
- package/dist/aikotools-datafilter.mjs +120 -96
- package/dist/src/core/types.d.ts +18 -0
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/matcher/Matcher.d.ts +2 -2
- package/dist/src/matcher/Matcher.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,8 @@ Advanced data filtering engine for JSON file matching in E2E testing.
|
|
|
15
15
|
- **Order Handling**: Support for both strict and flexible ordering of expected files
|
|
16
16
|
- **🆕 Wildcard Optionals**: Match arbitrary number of optional files without explicit specification
|
|
17
17
|
- **Greedy vs. Non-Greedy**: Control whether wildcards match once or multiple times
|
|
18
|
+
- **PreFilter Support**: Global file filtering before rule matching
|
|
19
|
+
- **Group Filtering**: Organize files into groups with shared filter criteria
|
|
18
20
|
- **Deep Object Access**: Path-based navigation through nested JSON structures
|
|
19
21
|
- **Sort Integration**: Custom sort functions for file ordering before matching
|
|
20
22
|
|
|
@@ -176,6 +178,131 @@ Validate timestamps (ISO strings or numeric):
|
|
|
176
178
|
}
|
|
177
179
|
```
|
|
178
180
|
|
|
181
|
+
## Advanced Features
|
|
182
|
+
|
|
183
|
+
### PreFilter - Global File Exclusion
|
|
184
|
+
|
|
185
|
+
PreFilter allows you to exclude files globally **before** any rule matching occurs. Files not matching the preFilter criteria are collected in the `preFiltered` property of the result, separate from `unmapped` files.
|
|
186
|
+
|
|
187
|
+
**Use Case:** Filter out irrelevant files (e.g., debug files, temporary files) before processing, while keeping track of what was excluded.
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
const result = filterFiles({
|
|
191
|
+
files: [
|
|
192
|
+
{ fileName: 'event1.json', data: { type: 'event', status: 'active', value: 42 } },
|
|
193
|
+
{ fileName: 'event2.json', data: { type: 'event', status: 'active', value: 100 } },
|
|
194
|
+
{ fileName: 'debug.json', data: { type: 'debug', status: 'inactive', value: 0 } },
|
|
195
|
+
{ fileName: 'temp.json', data: { type: 'temp', status: 'inactive', value: -1 } },
|
|
196
|
+
],
|
|
197
|
+
preFilter: [
|
|
198
|
+
// Only process files with status 'active'
|
|
199
|
+
{ path: ['status'], check: { value: 'active' } }
|
|
200
|
+
],
|
|
201
|
+
rules: [
|
|
202
|
+
{ match: [{ path: ['type'], check: { value: 'event' } }], expected: 'event1' },
|
|
203
|
+
{ match: [{ path: ['type'], check: { value: 'event' } }], expected: 'event2' },
|
|
204
|
+
],
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// Result:
|
|
208
|
+
// - mapped: event1.json, event2.json
|
|
209
|
+
// - preFiltered: debug.json, temp.json (with failed check details)
|
|
210
|
+
// - unmapped: []
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Group Filtering - Organize by Categories
|
|
214
|
+
|
|
215
|
+
Group filtering allows you to organize files into categories with shared filter criteria, then apply category-specific rules.
|
|
216
|
+
|
|
217
|
+
**Use Case:** Different file types (e.g., orders, invoices, reports) need different validation rules.
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
import { filterFilesWithGroups } from '@aikotools/datafilter';
|
|
221
|
+
|
|
222
|
+
const result = filterFilesWithGroups({
|
|
223
|
+
files: [
|
|
224
|
+
{ fileName: 'order1.json', data: { category: 'order', orderId: 'A123', amount: 100 } },
|
|
225
|
+
{ fileName: 'order2.json', data: { category: 'order', orderId: 'A124', amount: 200 } },
|
|
226
|
+
{ fileName: 'invoice1.json', data: { category: 'invoice', invoiceId: 'INV-001', total: 100 } },
|
|
227
|
+
{ fileName: 'invoice2.json', data: { category: 'invoice', invoiceId: 'INV-002', total: 200 } },
|
|
228
|
+
{ fileName: 'report.json', data: { category: 'report', month: 'January' } },
|
|
229
|
+
],
|
|
230
|
+
groups: [
|
|
231
|
+
{
|
|
232
|
+
// Group 1: Orders
|
|
233
|
+
groupFilter: [
|
|
234
|
+
{ path: ['category'], check: { value: 'order' } }
|
|
235
|
+
],
|
|
236
|
+
rules: [
|
|
237
|
+
{ match: [{ path: ['orderId'], check: { value: 'A123' } }], expected: 'order_A123' },
|
|
238
|
+
{ match: [{ path: ['orderId'], check: { value: 'A124' } }], expected: 'order_A124' },
|
|
239
|
+
]
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
// Group 2: Invoices
|
|
243
|
+
groupFilter: [
|
|
244
|
+
{ path: ['category'], check: { value: 'invoice' } }
|
|
245
|
+
],
|
|
246
|
+
rules: [
|
|
247
|
+
{ match: [{ path: ['invoiceId'], check: { value: 'INV-001' } }], expected: 'invoice_001' },
|
|
248
|
+
{ match: [{ path: ['invoiceId'], check: { value: 'INV-002' } }], expected: 'invoice_002' },
|
|
249
|
+
]
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
// Group 3: Reports (with wildcard)
|
|
253
|
+
groupFilter: [
|
|
254
|
+
{ path: ['category'], check: { value: 'report' } }
|
|
255
|
+
],
|
|
256
|
+
rules: [
|
|
257
|
+
{ matchAny: [{ path: ['category'], check: { value: 'report' } }], optional: true, greedy: true }
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
preFilter: [
|
|
262
|
+
// Optional: Only process files with specific structure
|
|
263
|
+
{ path: ['category'], check: { exists: true } }
|
|
264
|
+
]
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Result:
|
|
268
|
+
// - mapped: order_A123, order_A124, invoice_001, invoice_002
|
|
269
|
+
// - wildcardMatched: report.json
|
|
270
|
+
// - unmapped: []
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Combining PreFilter, Groups, and Wildcards
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
const result = filterFilesWithGroups({
|
|
277
|
+
files: allFiles,
|
|
278
|
+
|
|
279
|
+
// Step 1: Global exclusion
|
|
280
|
+
preFilter: [
|
|
281
|
+
{ path: ['status'], check: { value: 'active' } },
|
|
282
|
+
{ path: ['deleted'], check: { exists: false } }
|
|
283
|
+
],
|
|
284
|
+
|
|
285
|
+
// Step 2: Group by type and apply rules
|
|
286
|
+
groups: [
|
|
287
|
+
{
|
|
288
|
+
groupFilter: [{ path: ['type'], check: { value: 'critical' } }],
|
|
289
|
+
rules: [
|
|
290
|
+
{ match: [{ path: ['priority'], check: { value: 1 } }], expected: 'critical_1' },
|
|
291
|
+
{ match: [{ path: ['priority'], check: { value: 2 } }], expected: 'critical_2' },
|
|
292
|
+
]
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
groupFilter: [{ path: ['type'], check: { value: 'normal' } }],
|
|
296
|
+
rules: [
|
|
297
|
+
{ matchAny: [{ path: ['type'], check: { value: 'normal' } }], optional: true, greedy: true }
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
],
|
|
301
|
+
|
|
302
|
+
sortFn: (a, b) => a.data.timestamp - b.data.timestamp
|
|
303
|
+
});
|
|
304
|
+
```
|
|
305
|
+
|
|
179
306
|
## Complete Example
|
|
180
307
|
|
|
181
308
|
### Scenario from Requirements
|
|
@@ -250,13 +377,32 @@ Main filtering function.
|
|
|
250
377
|
- `files: JsonFile[]` - Files to filter
|
|
251
378
|
- `rules: (MatchRule | MatchRule[])[]` - Matching rules
|
|
252
379
|
- `sortFn?: (a, b) => number` - Optional sort function
|
|
380
|
+
- `preFilter?: FilterCriterion[]` - Optional pre-filter criteria (files not matching are collected in `preFiltered`)
|
|
253
381
|
- `context?: { startTimeScript?, startTimeTest?, pathTime? }` - Optional context
|
|
254
382
|
|
|
255
383
|
**FilterResult:**
|
|
256
384
|
- `mapped: MappedFile[]` - Successfully mapped files
|
|
257
385
|
- `wildcardMatched: WildcardMappedFile[]` - Files matched by wildcards
|
|
258
|
-
- `unmapped: UnmappedFile[]` - Files that couldn't be matched
|
|
259
|
-
- `
|
|
386
|
+
- `unmapped: UnmappedFile[]` - Files that passed preFilter but couldn't be matched to any rule
|
|
387
|
+
- `preFiltered: PreFilteredFile[]` - Files excluded by preFilter criteria (with failed check details)
|
|
388
|
+
- `stats: { totalFiles, mappedFiles, wildcardMatchedFiles, unmappedFiles, preFilteredFiles, ... }`
|
|
389
|
+
|
|
390
|
+
### filterFilesWithGroups(request: FilterGroupRequest): FilterResult
|
|
391
|
+
|
|
392
|
+
Filtering with grouped rules for categorized file processing.
|
|
393
|
+
|
|
394
|
+
**FilterGroupRequest:**
|
|
395
|
+
- `files: JsonFile[]` - Files to filter
|
|
396
|
+
- `groups: FilterGroup[]` - Filter groups with common criteria and rules
|
|
397
|
+
- `sortFn?: (a, b) => number` - Optional sort function
|
|
398
|
+
- `preFilter?: FilterCriterion[]` - Optional pre-filter criteria (applied before group filtering)
|
|
399
|
+
- `context?: { startTimeScript?, startTimeTest?, pathTime? }` - Optional context
|
|
400
|
+
|
|
401
|
+
**FilterGroup:**
|
|
402
|
+
- `groupFilter: FilterCriterion[]` - Criteria to identify files belonging to this group
|
|
403
|
+
- `rules: (MatchRule | MatchRule[])[]` - Rules to apply to files in this group
|
|
404
|
+
|
|
405
|
+
**FilterResult:** Same as `filterFiles()`
|
|
260
406
|
|
|
261
407
|
### Matcher Class
|
|
262
408
|
|
|
@@ -266,7 +412,12 @@ For advanced usage with multiple filter operations:
|
|
|
266
412
|
import { Matcher } from '@aikotools/datafilter';
|
|
267
413
|
|
|
268
414
|
const matcher = new Matcher({ startTimeScript, startTimeTest });
|
|
269
|
-
|
|
415
|
+
|
|
416
|
+
// With preFilter
|
|
417
|
+
const result = matcher.filterFiles(files, rules, sortFn, preFilter);
|
|
418
|
+
|
|
419
|
+
// With groups
|
|
420
|
+
const groupResult = matcher.filterFilesWithGroups(files, groups, sortFn, preFilter);
|
|
270
421
|
```
|
|
271
422
|
|
|
272
423
|
### FilterEngine Class
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("luxon");function x(i){return"matchAny"in i}function b(i){return"match"in i&&"expected"in i}function y(i,s){const t=[];if(s.length===0)return{value:i,found:!0,validPath:[]};let e=i;for(let n=0;n<s.length;n++){const r=s[n];if(e==null)return{value:void 0,found:!1,error:`Cannot read property '${r}' of ${e}`,validPath:t};if(Array.isArray(e)){const a=typeof r=="number"?r:parseInt(String(r),10);if(isNaN(a))return{value:void 0,found:!1,error:`Array index must be a number, got '${r}'`,validPath:t};if(a<0||a>=e.length)return{value:void 0,found:!1,error:`Array index ${a} out of bounds (length: ${e.length})`,validPath:t};t.push(a),e=e[a];continue}if(typeof e=="object"){const a=String(r);if(!(a in e))return{value:void 0,found:!1,error:`Property '${a}' does not exist`,validPath:t};t.push(a),e=e[a];continue}return{value:void 0,found:!1,error:`Cannot access property '${r}' of primitive type ${typeof e}`,validPath:t}}return{value:e,found:!0,validPath:t}}function P(i,s){const t=y(i,s);return t.found&&t.value!==void 0}function V(i,s,t){const e=y(i,s);return e.found&&e.value!==void 0?e.value:t}class w{constructor(s){this.context=s}evaluateCriterion(s,t){const e=t.check;return"value"in e?this.checkValue(s,t.path,e):"exists"in e?this.checkExists(s,t.path,e):"itemExists"in e&&"item"in e?this.checkArrayElement(s,t.path,e):"type"in e&&"size"in e?this.checkArraySize(s,t.path,e):"min"in e&&"max"in e?typeof e.min=="number"&&typeof e.max=="number"?this.checkNumericRange(s,t.path,e):this.checkTimeRange(s,t.path,e):{status:!1,checkType:"unknown",reason:`Unknown check type: ${JSON.stringify(e)}`}}checkValue(s,t,e){const n=y(s,t);if(!n.found)return{status:!1,checkType:"checkValue",reason:{message:n.error||"Path not found",path:t}};const r=n.value,a=e.value;return this.deepEqual(r,a)?{status:!0,checkType:"checkValue"}:{status:!1,checkType:"checkValue",reason:{message:"Value mismatch",path:t,expected:a,actual:r}}}checkExists(s,t,e){const n=y(s,t),r=n.found&&n.value!==void 0;return e.exists===r?{status:!0,checkType:"checkExists"}:{status:!1,checkType:"checkExists",reason:{message:e.exists?`Path should exist but doesn't: ${n.error}`:"Path should not exist but does",path:t}}}checkArrayElement(s,t,e){const n=y(s,t);if(!n.found)return{status:!1,checkType:"checkArrayElement",reason:{message:n.error||"Path not found",path:t}};const r=n.value;if(!Array.isArray(r))return{status:!1,checkType:"checkArrayElement",reason:{message:"Value is not an array",path:t,actualType:typeof r}};const a=r.some(u=>this.deepEqual(u,e.item));return e.itemExists===a?{status:!0,checkType:"checkArrayElement"}:{status:!1,checkType:"checkArrayElement",reason:{message:e.itemExists?"Item should exist in array but doesn't":"Item should not exist in array but does",path:t,item:e.item}}}checkArraySize(s,t,e){const n=y(s,t);if(!n.found)return{status:!1,checkType:"checkArraySize",reason:{message:n.error||"Path not found",path:t}};const r=n.value;if(!Array.isArray(r))return{status:!1,checkType:"checkArraySize",reason:{message:"Value is not an array",path:t,actualType:typeof r}};const a=r.length,u=e.size;let o=!1,h="";switch(e.type){case"equal":o=a===u,h=`Array length should be ${u} but is ${a}`;break;case"lessThan":o=a<u,h=`Array length should be less than ${u} but is ${a}`;break;case"greaterThan":o=a>u,h=`Array length should be greater than ${u} but is ${a}`;break}return o?{status:!0,checkType:"checkArraySize"}:{status:!1,checkType:"checkArraySize",reason:{message:h,path:t,expected:u,actual:a}}}checkTimeRange(s,t,e){const n=y(s,t);if(!n.found)return{status:!1,checkType:"checkTimeRange",reason:{message:n.error||"Path not found",path:t}};const r=n.value;if(typeof r=="number"){const a=parseInt(e.min),u=parseInt(e.max);return isNaN(a)||isNaN(u)?{status:!1,checkType:"checkTimeRange",reason:{message:"Min or max is not a valid number",min:e.min,max:e.max}}:r>=a&&r<=u?{status:!0,checkType:"checkTimeRange"}:{status:!1,checkType:"checkTimeRange",reason:{message:`Timestamp ${r} is outside range [${a}, ${u}]`,path:t,actual:r,min:a,max:u}}}if(typeof r=="string"){const a=E.DateTime.fromISO(r),u=E.DateTime.fromISO(e.min),o=E.DateTime.fromISO(e.max);return a.isValid?!u.isValid||!o.isValid?{status:!1,checkType:"checkTimeRange",reason:{message:"Invalid min or max time",min:e.min,max:e.max}}:a>=u&&a<=o?{status:!0,checkType:"checkTimeRange"}:{status:!1,checkType:"checkTimeRange",reason:{message:`Timestamp ${r} is outside range [${e.min}, ${e.max}]`,path:t,actual:r,min:e.min,max:e.max}}:{status:!1,checkType:"checkTimeRange",reason:{message:`Invalid timestamp: ${r}`,path:t}}}return{status:!1,checkType:"checkTimeRange",reason:{message:`Timestamp must be a string or number, got ${typeof r}`,path:t}}}checkNumericRange(s,t,e){const n=y(s,t);if(!n.found)return{status:!1,checkType:"checkNumericRange",reason:{message:n.error||"Path not found",path:t}};const r=n.value;return typeof r!="number"?{status:!1,checkType:"checkNumericRange",reason:{message:`Value must be a number, got ${typeof r}`,path:t,actual:r}}:r>=e.min&&r<=e.max?{status:!0,checkType:"checkNumericRange"}:{status:!1,checkType:"checkNumericRange",reason:{message:`Value ${r} is outside range [${e.min}, ${e.max}]`,path:t,actual:r,min:e.min,max:e.max}}}deepEqual(s,t){if(s===t)return!0;if(s===null||t===null||s===void 0||t===void 0)return s===t;if(typeof s!=typeof t)return!1;if(s instanceof Date&&t instanceof Date)return s.getTime()===t.getTime();if(Array.isArray(s)&&Array.isArray(t))return s.length!==t.length?!1:s.every((e,n)=>this.deepEqual(e,t[n]));if(typeof s=="object"&&typeof t=="object"){const e=Object.keys(s),n=Object.keys(t);return e.length!==n.length?!1:e.every(r=>this.deepEqual(s[r],t[r]))}return s===t}}class M{constructor(s){this.engine=new w(s)}matchFile(s,t){const n=(x(t)?t.matchAny:t.match).map(a=>this.engine.evaluateCriterion(s.data,a));return{matched:n.every(a=>a.status),checks:n,rule:t}}applyPreFilter(s,t){const e=[],n=[];for(const r of s){const a=t.map(u=>this.engine.evaluateCriterion(r.data,u));a.every(u=>u.status)?e.push(r):n.push({file:r,failedChecks:a.filter(u=>!u.status)})}return{matched:e,excluded:n}}filterFiles(s,t,e,n){let r,a=[];if(n){const f=this.applyPreFilter(s,n);r=f.matched,a=f.excluded}else r=s;const u=e?[...r].sort(e):[...r],o=[],h=[],g=[],k=new Set,R=new Map;let l=0,c=0;for(;l<u.length;){const f=u[l];if(c>=t.length){k.has(l)||g.push({file:f,attemptedRules:[]}),l++;continue}const m=t[c],F=[];let T=!1;if(Array.isArray(m)){for(let p=0;p<m.length;p++){if(R.get(c)?.has(p))continue;const v=m[p],$=this.matchFile(f,v);if(F.push($),$.matched&&b(v)){R.has(c)||R.set(c,new Set);const S=R.get(c);S&&S.add(p),o.push({expected:v.expected,file:f,matchResult:$,optional:v.optional||!1,info:v.info}),k.add(l),T=!0;break}}R.get(c)?.size===m.length&&c++,l++}else{const d=m,p=this.matchFile(f,d);F.push(p),p.matched?b(d)?(o.push({expected:d.expected,file:f,matchResult:p,optional:d.optional||!1,info:d.info}),k.add(l),c++,l++):x(d)&&(h.push({file:f,matchResult:p,info:d.info}),k.add(l),d.greedy||c++,l++):d.optional||x(d)?c++:(g.push({file:f,attemptedRules:F}),l++)}}const A={totalFiles:s.length,mappedFiles:o.length,wildcardMatchedFiles:h.length,unmappedFiles:g.length,preFilteredFiles:a.length,totalRules:this.countRules(t),mandatoryRules:this.countMandatoryRules(t),optionalRules:this.countOptionalRules(t)};return{mapped:o,wildcardMatched:h,unmapped:g,preFiltered:a,stats:A}}countRules(s){return s.reduce((t,e)=>Array.isArray(e)?t+e.length:t+1,0)}countMandatoryRules(s){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)}countOptionalRules(s){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)}filterFilesWithGroups(s,t,e,n){let r,a=[];if(n){const l=this.applyPreFilter(s,n);r=l.matched,a=l.excluded}else r=s;const u=e?[...r].sort(e):[...r],o=[],h=[],g=[];for(const l of t){const c=u.filter(m=>l.groupFilter.map(T=>this.engine.evaluateCriterion(m.data,T)).every(T=>T.status));if(c.length===0)continue;const A=l.rules.map(m=>(Array.isArray(m),m)),f=this.filterFiles(c,A);o.push(...f.mapped),h.push(...f.wildcardMatched),g.push(...f.unmapped)}const k=t.flatMap(l=>l.rules),R={totalFiles:s.length,mappedFiles:o.length,wildcardMatchedFiles:h.length,unmappedFiles:g.length,preFilteredFiles:a.length,totalRules:this.countRules(k),mandatoryRules:this.countMandatoryRules(k),optionalRules:this.countOptionalRules(k)};return{mapped:o,wildcardMatched:h,unmapped:g,preFiltered:a,stats:R}}}function I(i){const s=new M(i.context);if(i.rules&&i.groups)throw new Error('FilterRequest: Provide either "rules" or "groups", not both');if(!i.rules&&!i.groups)throw new Error('FilterRequest: Must provide either "rules" or "groups"');if(i.groups)return s.filterFilesWithGroups(i.files,i.groups,i.sortFn,i.preFilter);if(!i.rules)throw new Error("FilterRequest: Rules are required");return s.filterFiles(i.files,i.rules,i.sortFn,i.preFilter)}exports.FilterEngine=w;exports.Matcher=M;exports.filterFiles=I;exports.getValueFromPath=y;exports.getValueOr=V;exports.isSingleMatchRule=b;exports.isWildcardRule=x;exports.pathExists=P;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DateTime as
|
|
2
|
-
function
|
|
1
|
+
import { DateTime as E } from "luxon";
|
|
2
|
+
function R(i) {
|
|
3
3
|
return "matchAny" in i;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function w(i) {
|
|
6
6
|
return "match" in i && "expected" in i;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function k(i, s) {
|
|
9
9
|
const t = [];
|
|
10
10
|
if (s.length === 0)
|
|
11
11
|
return {
|
|
@@ -67,15 +67,15 @@ function g(i, s) {
|
|
|
67
67
|
validPath: t
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
const t =
|
|
70
|
+
function I(i, s) {
|
|
71
|
+
const t = k(i, s);
|
|
72
72
|
return t.found && t.value !== void 0;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
const e =
|
|
74
|
+
function N(i, s, t) {
|
|
75
|
+
const e = k(i, s);
|
|
76
76
|
return e.found && e.value !== void 0 ? e.value : t;
|
|
77
77
|
}
|
|
78
|
-
class
|
|
78
|
+
class S {
|
|
79
79
|
constructor(s) {
|
|
80
80
|
this.context = s;
|
|
81
81
|
}
|
|
@@ -104,7 +104,7 @@ class w {
|
|
|
104
104
|
* @returns FilterCheckResult
|
|
105
105
|
*/
|
|
106
106
|
checkValue(s, t, e) {
|
|
107
|
-
const n =
|
|
107
|
+
const n = k(s, t);
|
|
108
108
|
if (!n.found)
|
|
109
109
|
return {
|
|
110
110
|
status: !1,
|
|
@@ -138,7 +138,7 @@ class w {
|
|
|
138
138
|
* @returns FilterCheckResult
|
|
139
139
|
*/
|
|
140
140
|
checkExists(s, t, e) {
|
|
141
|
-
const n =
|
|
141
|
+
const n = k(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 w {
|
|
|
160
160
|
* @returns FilterCheckResult
|
|
161
161
|
*/
|
|
162
162
|
checkArrayElement(s, t, e) {
|
|
163
|
-
const n =
|
|
163
|
+
const n = k(s, t);
|
|
164
164
|
if (!n.found)
|
|
165
165
|
return {
|
|
166
166
|
status: !1,
|
|
@@ -204,7 +204,7 @@ class w {
|
|
|
204
204
|
* @returns FilterCheckResult
|
|
205
205
|
*/
|
|
206
206
|
checkArraySize(s, t, e) {
|
|
207
|
-
const n =
|
|
207
|
+
const n = k(s, t);
|
|
208
208
|
if (!n.found)
|
|
209
209
|
return {
|
|
210
210
|
status: !1,
|
|
@@ -226,26 +226,26 @@ class w {
|
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
const a = r.length, u = e.size;
|
|
229
|
-
let
|
|
229
|
+
let l = !1, h = "";
|
|
230
230
|
switch (e.type) {
|
|
231
231
|
case "equal":
|
|
232
|
-
|
|
232
|
+
l = a === u, h = `Array length should be ${u} but is ${a}`;
|
|
233
233
|
break;
|
|
234
234
|
case "lessThan":
|
|
235
|
-
|
|
235
|
+
l = a < u, h = `Array length should be less than ${u} but is ${a}`;
|
|
236
236
|
break;
|
|
237
237
|
case "greaterThan":
|
|
238
|
-
|
|
238
|
+
l = a > u, h = `Array length should be greater than ${u} but is ${a}`;
|
|
239
239
|
break;
|
|
240
240
|
}
|
|
241
|
-
return
|
|
241
|
+
return l ? {
|
|
242
242
|
status: !0,
|
|
243
243
|
checkType: "checkArraySize"
|
|
244
244
|
} : {
|
|
245
245
|
status: !1,
|
|
246
246
|
checkType: "checkArraySize",
|
|
247
247
|
reason: {
|
|
248
|
-
message:
|
|
248
|
+
message: h,
|
|
249
249
|
path: t,
|
|
250
250
|
expected: u,
|
|
251
251
|
actual: a
|
|
@@ -261,7 +261,7 @@ class w {
|
|
|
261
261
|
* @returns FilterCheckResult
|
|
262
262
|
*/
|
|
263
263
|
checkTimeRange(s, t, e) {
|
|
264
|
-
const n =
|
|
264
|
+
const n = k(s, t);
|
|
265
265
|
if (!n.found)
|
|
266
266
|
return {
|
|
267
267
|
status: !1,
|
|
@@ -298,8 +298,8 @@ class w {
|
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
if (typeof r == "string") {
|
|
301
|
-
const a =
|
|
302
|
-
return a.isValid ? !u.isValid || !
|
|
301
|
+
const a = E.fromISO(r), u = E.fromISO(e.min), l = E.fromISO(e.max);
|
|
302
|
+
return a.isValid ? !u.isValid || !l.isValid ? {
|
|
303
303
|
status: !1,
|
|
304
304
|
checkType: "checkTimeRange",
|
|
305
305
|
reason: {
|
|
@@ -307,7 +307,7 @@ class w {
|
|
|
307
307
|
min: e.min,
|
|
308
308
|
max: e.max
|
|
309
309
|
}
|
|
310
|
-
} : a >= u && a <=
|
|
310
|
+
} : a >= u && a <= l ? {
|
|
311
311
|
status: !0,
|
|
312
312
|
checkType: "checkTimeRange"
|
|
313
313
|
} : {
|
|
@@ -347,7 +347,7 @@ class w {
|
|
|
347
347
|
* @returns FilterCheckResult
|
|
348
348
|
*/
|
|
349
349
|
checkNumericRange(s, t, e) {
|
|
350
|
-
const n =
|
|
350
|
+
const n = k(s, t);
|
|
351
351
|
if (!n.found)
|
|
352
352
|
return {
|
|
353
353
|
status: !1,
|
|
@@ -401,9 +401,9 @@ class w {
|
|
|
401
401
|
return s === t;
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
-
class
|
|
404
|
+
class M {
|
|
405
405
|
constructor(s) {
|
|
406
|
-
this.engine = new
|
|
406
|
+
this.engine = new S(s);
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
409
409
|
* Matches a single file against a rule.
|
|
@@ -413,7 +413,7 @@ class S {
|
|
|
413
413
|
* @returns MatchResult indicating if all criteria matched
|
|
414
414
|
*/
|
|
415
415
|
matchFile(s, t) {
|
|
416
|
-
const n = (
|
|
416
|
+
const n = (R(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,
|
|
@@ -421,14 +421,22 @@ class S {
|
|
|
421
421
|
};
|
|
422
422
|
}
|
|
423
423
|
/**
|
|
424
|
-
* Applies pre-filter criteria to files,
|
|
424
|
+
* Applies pre-filter criteria to files, separating files that match from those that don't.
|
|
425
425
|
*
|
|
426
426
|
* @param files - Files to filter
|
|
427
427
|
* @param preFilter - Filter criteria that all files must match
|
|
428
|
-
* @returns
|
|
428
|
+
* @returns Object with matched files and excluded files (with failed checks)
|
|
429
429
|
*/
|
|
430
430
|
applyPreFilter(s, t) {
|
|
431
|
-
|
|
431
|
+
const e = [], n = [];
|
|
432
|
+
for (const r of s) {
|
|
433
|
+
const a = t.map((u) => this.engine.evaluateCriterion(r.data, u));
|
|
434
|
+
a.every((u) => u.status) ? e.push(r) : n.push({
|
|
435
|
+
file: r,
|
|
436
|
+
failedChecks: a.filter((u) => !u.status)
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
return { matched: e, excluded: n };
|
|
432
440
|
}
|
|
433
441
|
/**
|
|
434
442
|
* Main filtering function that processes files according to rules.
|
|
@@ -440,70 +448,78 @@ class S {
|
|
|
440
448
|
* @returns FilterResult with mapped, wildcardMatched, and unmapped files
|
|
441
449
|
*/
|
|
442
450
|
filterFiles(s, t, e, n) {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
451
|
+
let r, a = [];
|
|
452
|
+
if (n) {
|
|
453
|
+
const f = this.applyPreFilter(s, n);
|
|
454
|
+
r = f.matched, a = f.excluded;
|
|
455
|
+
} else
|
|
456
|
+
r = s;
|
|
457
|
+
const u = e ? [...r].sort(e) : [...r], l = [], h = [], y = [], g = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Map();
|
|
458
|
+
let o = 0, c = 0;
|
|
459
|
+
for (; o < u.length; ) {
|
|
460
|
+
const f = u[o];
|
|
461
|
+
if (c >= t.length) {
|
|
462
|
+
g.has(o) || y.push({
|
|
463
|
+
file: f,
|
|
450
464
|
attemptedRules: []
|
|
451
465
|
}), o++;
|
|
452
466
|
continue;
|
|
453
467
|
}
|
|
454
|
-
const m = t[
|
|
455
|
-
let
|
|
468
|
+
const m = t[c], A = [];
|
|
469
|
+
let T = !1;
|
|
456
470
|
if (Array.isArray(m)) {
|
|
457
471
|
for (let p = 0; p < m.length; p++) {
|
|
458
|
-
if (
|
|
472
|
+
if (x.get(c)?.has(p))
|
|
459
473
|
continue;
|
|
460
|
-
const
|
|
461
|
-
if (
|
|
462
|
-
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
expected:
|
|
466
|
-
file:
|
|
467
|
-
matchResult:
|
|
468
|
-
optional:
|
|
469
|
-
info:
|
|
470
|
-
}),
|
|
474
|
+
const v = m[p], $ = this.matchFile(f, v);
|
|
475
|
+
if (A.push($), $.matched && w(v)) {
|
|
476
|
+
x.has(c) || x.set(c, /* @__PURE__ */ new Set());
|
|
477
|
+
const b = x.get(c);
|
|
478
|
+
b && b.add(p), l.push({
|
|
479
|
+
expected: v.expected,
|
|
480
|
+
file: f,
|
|
481
|
+
matchResult: $,
|
|
482
|
+
optional: v.optional || !1,
|
|
483
|
+
info: v.info
|
|
484
|
+
}), g.add(o), T = !0;
|
|
471
485
|
break;
|
|
472
486
|
}
|
|
473
487
|
}
|
|
474
|
-
|
|
488
|
+
x.get(c)?.size === m.length && c++, o++;
|
|
475
489
|
} else {
|
|
476
|
-
const d = m, p = this.matchFile(
|
|
477
|
-
|
|
490
|
+
const d = m, p = this.matchFile(f, d);
|
|
491
|
+
A.push(p), p.matched ? w(d) ? (l.push({
|
|
478
492
|
expected: d.expected,
|
|
479
|
-
file:
|
|
493
|
+
file: f,
|
|
480
494
|
matchResult: p,
|
|
481
495
|
optional: d.optional || !1,
|
|
482
496
|
info: d.info
|
|
483
|
-
}),
|
|
484
|
-
file:
|
|
497
|
+
}), g.add(o), c++, o++) : R(d) && (h.push({
|
|
498
|
+
file: f,
|
|
485
499
|
matchResult: p,
|
|
486
500
|
info: d.info
|
|
487
|
-
}),
|
|
488
|
-
file:
|
|
489
|
-
attemptedRules:
|
|
501
|
+
}), g.add(o), d.greedy || c++, o++) : d.optional || R(d) ? c++ : (y.push({
|
|
502
|
+
file: f,
|
|
503
|
+
attemptedRules: A
|
|
490
504
|
}), o++);
|
|
491
505
|
}
|
|
492
506
|
}
|
|
493
|
-
const
|
|
507
|
+
const F = {
|
|
494
508
|
totalFiles: s.length,
|
|
495
|
-
mappedFiles:
|
|
496
|
-
wildcardMatchedFiles:
|
|
497
|
-
unmappedFiles:
|
|
509
|
+
mappedFiles: l.length,
|
|
510
|
+
wildcardMatchedFiles: h.length,
|
|
511
|
+
unmappedFiles: y.length,
|
|
512
|
+
preFilteredFiles: a.length,
|
|
498
513
|
totalRules: this.countRules(t),
|
|
499
514
|
mandatoryRules: this.countMandatoryRules(t),
|
|
500
515
|
optionalRules: this.countOptionalRules(t)
|
|
501
516
|
};
|
|
502
517
|
return {
|
|
503
|
-
mapped:
|
|
504
|
-
wildcardMatched:
|
|
505
|
-
unmapped:
|
|
506
|
-
|
|
518
|
+
mapped: l,
|
|
519
|
+
wildcardMatched: h,
|
|
520
|
+
unmapped: y,
|
|
521
|
+
preFiltered: a,
|
|
522
|
+
stats: F
|
|
507
523
|
};
|
|
508
524
|
}
|
|
509
525
|
/**
|
|
@@ -516,13 +532,13 @@ class S {
|
|
|
516
532
|
* Counts mandatory rules
|
|
517
533
|
*/
|
|
518
534
|
countMandatoryRules(s) {
|
|
519
|
-
return s.reduce((t, e) => Array.isArray(e) ? t + e.filter((n) => !n.optional && !
|
|
535
|
+
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);
|
|
520
536
|
}
|
|
521
537
|
/**
|
|
522
538
|
* Counts optional rules
|
|
523
539
|
*/
|
|
524
540
|
countOptionalRules(s) {
|
|
525
|
-
return s.reduce((t, e) => Array.isArray(e) ? t + e.filter((n) => n.optional ||
|
|
541
|
+
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);
|
|
526
542
|
}
|
|
527
543
|
/**
|
|
528
544
|
* Filtering function for grouped rules with common filter criteria.
|
|
@@ -536,33 +552,41 @@ class S {
|
|
|
536
552
|
* @returns FilterResult with mapped, wildcardMatched, and unmapped files
|
|
537
553
|
*/
|
|
538
554
|
filterFilesWithGroups(s, t, e, n) {
|
|
539
|
-
|
|
555
|
+
let r, a = [];
|
|
556
|
+
if (n) {
|
|
557
|
+
const o = this.applyPreFilter(s, n);
|
|
558
|
+
r = o.matched, a = o.excluded;
|
|
559
|
+
} else
|
|
560
|
+
r = s;
|
|
561
|
+
const u = e ? [...r].sort(e) : [...r], l = [], h = [], y = [];
|
|
540
562
|
for (const o of t) {
|
|
541
|
-
const
|
|
542
|
-
if (
|
|
563
|
+
const c = u.filter((m) => o.groupFilter.map((T) => this.engine.evaluateCriterion(m.data, T)).every((T) => T.status));
|
|
564
|
+
if (c.length === 0)
|
|
543
565
|
continue;
|
|
544
|
-
const
|
|
545
|
-
|
|
566
|
+
const F = o.rules.map((m) => (Array.isArray(m), m)), f = this.filterFiles(c, F);
|
|
567
|
+
l.push(...f.mapped), h.push(...f.wildcardMatched), y.push(...f.unmapped);
|
|
546
568
|
}
|
|
547
|
-
const
|
|
569
|
+
const g = t.flatMap((o) => o.rules), x = {
|
|
548
570
|
totalFiles: s.length,
|
|
549
|
-
mappedFiles:
|
|
550
|
-
wildcardMatchedFiles:
|
|
551
|
-
unmappedFiles:
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
571
|
+
mappedFiles: l.length,
|
|
572
|
+
wildcardMatchedFiles: h.length,
|
|
573
|
+
unmappedFiles: y.length,
|
|
574
|
+
preFilteredFiles: a.length,
|
|
575
|
+
totalRules: this.countRules(g),
|
|
576
|
+
mandatoryRules: this.countMandatoryRules(g),
|
|
577
|
+
optionalRules: this.countOptionalRules(g)
|
|
555
578
|
};
|
|
556
579
|
return {
|
|
557
|
-
mapped:
|
|
558
|
-
wildcardMatched:
|
|
559
|
-
unmapped:
|
|
560
|
-
|
|
580
|
+
mapped: l,
|
|
581
|
+
wildcardMatched: h,
|
|
582
|
+
unmapped: y,
|
|
583
|
+
preFiltered: a,
|
|
584
|
+
stats: x
|
|
561
585
|
};
|
|
562
586
|
}
|
|
563
587
|
}
|
|
564
|
-
function
|
|
565
|
-
const s = new
|
|
588
|
+
function z(i) {
|
|
589
|
+
const s = new M(i.context);
|
|
566
590
|
if (i.rules && i.groups)
|
|
567
591
|
throw new Error('FilterRequest: Provide either "rules" or "groups", not both');
|
|
568
592
|
if (!i.rules && !i.groups)
|
|
@@ -579,12 +603,12 @@ function N(i) {
|
|
|
579
603
|
return s.filterFiles(i.files, i.rules, i.sortFn, i.preFilter);
|
|
580
604
|
}
|
|
581
605
|
export {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
606
|
+
S as FilterEngine,
|
|
607
|
+
M as Matcher,
|
|
608
|
+
z as filterFiles,
|
|
609
|
+
k as getValueFromPath,
|
|
610
|
+
N as getValueOr,
|
|
611
|
+
w as isSingleMatchRule,
|
|
612
|
+
R as isWildcardRule,
|
|
613
|
+
I as pathExists
|
|
590
614
|
};
|
package/dist/src/core/types.d.ts
CHANGED
|
@@ -247,6 +247,19 @@ export interface UnmappedFile {
|
|
|
247
247
|
*/
|
|
248
248
|
attemptedRules: MatchResult[];
|
|
249
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* A pre-filtered file that was excluded by preFilter criteria
|
|
252
|
+
*/
|
|
253
|
+
export interface PreFilteredFile {
|
|
254
|
+
/**
|
|
255
|
+
* The file that was excluded
|
|
256
|
+
*/
|
|
257
|
+
file: JsonFile;
|
|
258
|
+
/**
|
|
259
|
+
* The preFilter checks that failed
|
|
260
|
+
*/
|
|
261
|
+
failedChecks: FilterCheckResult[];
|
|
262
|
+
}
|
|
250
263
|
/**
|
|
251
264
|
* Result of the entire filtering operation
|
|
252
265
|
*/
|
|
@@ -263,6 +276,10 @@ export interface FilterResult {
|
|
|
263
276
|
* Files that couldn't be matched to any rule
|
|
264
277
|
*/
|
|
265
278
|
unmapped: UnmappedFile[];
|
|
279
|
+
/**
|
|
280
|
+
* Files that were excluded by preFilter criteria
|
|
281
|
+
*/
|
|
282
|
+
preFiltered: PreFilteredFile[];
|
|
266
283
|
/**
|
|
267
284
|
* Statistics
|
|
268
285
|
*/
|
|
@@ -271,6 +288,7 @@ export interface FilterResult {
|
|
|
271
288
|
mappedFiles: number;
|
|
272
289
|
wildcardMatchedFiles: number;
|
|
273
290
|
unmappedFiles: number;
|
|
291
|
+
preFilteredFiles: number;
|
|
274
292
|
totalRules: number;
|
|
275
293
|
mandatoryRules: number;
|
|
276
294
|
optionalRules: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAA;AAEzC;;GAEG;AACH,MAAM,MAAM,QAAQ,GAChB,cAAc,GACd,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,GACN,OAAO,GACP,QAAQ,GACR,OAAO,CAAA;AAEX;;GAEG;AACH,MAAM,WAAW,UAAU;IAEzB,KAAK,EAAE,GAAG,CAAA;CACX;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,OAAO,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,OAAO,CAAA;IAEnB,IAAI,EAAE,GAAG,CAAA;CACV;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,aAAa,CAAA;IAC1C,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,WAAW,EAAE,CAAA;IAEnB;;OAEG;IACH,KAAK,EACD,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,cAAc,GACd,cAAc,GACd,iBAAiB,CAAA;CACtB;AAED;;GAEG;AACH,MAA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C;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IAEtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,KAAK,MAAM,CAAA;IAE7C;;;;OAIG;IACH,SAAS,CAAC,EAAE,eAAe,EAAE,CAAA;IAE7B;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAA;KACzB,CAAA;CACF"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { FilterRequest, FilterResult } from './core/types';
|
|
|
4
4
|
*
|
|
5
5
|
* Advanced data filtering engine for JSON file matching in E2E testing
|
|
6
6
|
*/
|
|
7
|
-
export type { PathElement, TimeUnit, CheckValue, CheckExists, CheckArrayElement, CheckArraySize, CheckTimeRange, CheckNumericRange, FilterCriterion, SingleMatchRule, WildcardMatchRule, MatchRule, FilterGroup, JsonFile, FilterCheckResult, MatchResult, MappedFile, WildcardMappedFile, UnmappedFile, FilterResult, FilterRequest, } from './core/types';
|
|
7
|
+
export type { PathElement, TimeUnit, CheckValue, CheckExists, CheckArrayElement, CheckArraySize, CheckTimeRange, CheckNumericRange, FilterCriterion, SingleMatchRule, WildcardMatchRule, MatchRule, FilterGroup, JsonFile, FilterCheckResult, MatchResult, MappedFile, WildcardMappedFile, UnmappedFile, PreFilteredFile, FilterResult, FilterRequest, } from './core/types';
|
|
8
8
|
export { isWildcardRule, isSingleMatchRule } from './core/types';
|
|
9
9
|
export { FilterEngine } from './engine';
|
|
10
10
|
export { Matcher } from './matcher';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,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AU,CAAA;AAGvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAClE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAI3C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,CA4BhE"}
|
|
@@ -18,11 +18,11 @@ export declare class Matcher {
|
|
|
18
18
|
*/
|
|
19
19
|
matchFile(file: JsonFile, rule: MatchRule): MatchResult;
|
|
20
20
|
/**
|
|
21
|
-
* Applies pre-filter criteria to files,
|
|
21
|
+
* Applies pre-filter criteria to files, separating files that match from those that don't.
|
|
22
22
|
*
|
|
23
23
|
* @param files - Files to filter
|
|
24
24
|
* @param preFilter - Filter criteria that all files must match
|
|
25
|
-
* @returns
|
|
25
|
+
* @returns Object with matched files and excluded files (with failed checks)
|
|
26
26
|
*/
|
|
27
27
|
private applyPreFilter;
|
|
28
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matcher.d.ts","sourceRoot":"","sources":["../../../src/matcher/Matcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,YAAY,
|
|
1
|
+
{"version":3,"file":"Matcher.d.ts","sourceRoot":"","sources":["../../../src/matcher/Matcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EAKZ,WAAW,EACX,eAAe,EACf,WAAW,EACZ,MAAM,eAAe,CAAA;AAItB;;;GAGG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAc;gBAEhB,OAAO,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE;IAI1E;;;;;;OAMG;IACH,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,GAAG,WAAW;IAgBvD;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IA4BtB;;;;;;;;OAQG;IACH,WAAW,CACT,KAAK,EAAE,QAAQ,EAAE,EACjB,KAAK,EAAE,CAAC,SAAS,GAAG,SAAS,EAAE,CAAC,EAAE,EAClC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,KAAK,MAAM,EAC7C,SAAS,CAAC,EAAE,eAAe,EAAE,GAC5B,YAAY;IAkLf;;OAEG;IACH,OAAO,CAAC,UAAU;IASlB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;;;;;;;;;OAUG;IACH,qBAAqB,CACnB,KAAK,EAAE,QAAQ,EAAE,EACjB,MAAM,EAAE,WAAW,EAAE,EACrB,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,KAAK,MAAM,EAC7C,SAAS,CAAC,EAAE,eAAe,EAAE,GAC5B,YAAY;CA0EhB"}
|