@omni-graph/omni-model 0.6.106 → 0.6.107-6-g8768e5d
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/functions/billing/index.d.ts +2 -0
- package/dist/functions/billing/index.d.ts.map +1 -0
- package/dist/functions/billing/index.js +2 -0
- package/dist/functions/billing/index.js.map +1 -0
- package/dist/functions/filtering/baseHandler.d.ts +9 -0
- package/dist/functions/filtering/baseHandler.d.ts.map +1 -0
- package/dist/functions/filtering/baseHandler.js +12 -0
- package/dist/functions/filtering/baseHandler.js.map +1 -0
- package/dist/functions/filtering/booleanHandler.d.ts +8 -0
- package/dist/functions/filtering/booleanHandler.d.ts.map +1 -0
- package/dist/functions/filtering/booleanHandler.js +41 -0
- package/dist/functions/filtering/booleanHandler.js.map +1 -0
- package/dist/functions/filtering/dateHandler.d.ts +8 -0
- package/dist/functions/filtering/dateHandler.d.ts.map +1 -0
- package/dist/functions/filtering/dateHandler.js +71 -0
- package/dist/functions/filtering/dateHandler.js.map +1 -0
- package/dist/functions/filtering/dateRangeHandler.d.ts +8 -0
- package/dist/functions/filtering/dateRangeHandler.d.ts.map +1 -0
- package/dist/functions/filtering/dateRangeHandler.js +46 -0
- package/dist/functions/filtering/dateRangeHandler.js.map +1 -0
- package/dist/functions/filtering/filterPredicate.d.ts +2 -0
- package/dist/functions/filtering/filterPredicate.d.ts.map +1 -0
- package/dist/functions/filtering/filterPredicate.js +2 -0
- package/dist/functions/filtering/filterPredicate.js.map +1 -0
- package/dist/functions/filtering/generalFilterArgs.d.ts +6 -0
- package/dist/functions/filtering/generalFilterArgs.d.ts.map +1 -0
- package/dist/functions/filtering/generalFilterArgs.js +2 -0
- package/dist/functions/filtering/generalFilterArgs.js.map +1 -0
- package/dist/functions/filtering/handler.d.ts +8 -0
- package/dist/functions/filtering/handler.d.ts.map +1 -0
- package/dist/functions/filtering/handler.js +2 -0
- package/dist/functions/filtering/handler.js.map +1 -0
- package/dist/functions/filtering/index.d.ts +2 -0
- package/dist/functions/filtering/index.d.ts.map +1 -0
- package/dist/functions/filtering/index.js +2 -0
- package/dist/functions/filtering/index.js.map +1 -0
- package/dist/functions/filtering/multiSelectHandler.d.ts +8 -0
- package/dist/functions/filtering/multiSelectHandler.d.ts.map +1 -0
- package/dist/functions/filtering/multiSelectHandler.js +48 -0
- package/dist/functions/filtering/multiSelectHandler.js.map +1 -0
- package/dist/functions/filtering/numberHandler.d.ts +8 -0
- package/dist/functions/filtering/numberHandler.d.ts.map +1 -0
- package/dist/functions/filtering/numberHandler.js +50 -0
- package/dist/functions/filtering/numberHandler.js.map +1 -0
- package/dist/functions/filtering/numberRangeHandler.d.ts +8 -0
- package/dist/functions/filtering/numberRangeHandler.d.ts.map +1 -0
- package/dist/functions/filtering/numberRangeHandler.js +27 -0
- package/dist/functions/filtering/numberRangeHandler.js.map +1 -0
- package/dist/functions/filtering/queryFilters.d.ts +85 -0
- package/dist/functions/filtering/queryFilters.d.ts.map +1 -0
- package/dist/functions/filtering/queryFilters.js +171 -0
- package/dist/functions/filtering/queryFilters.js.map +1 -0
- package/dist/functions/filtering/textHandler.d.ts +8 -0
- package/dist/functions/filtering/textHandler.d.ts.map +1 -0
- package/dist/functions/filtering/textHandler.js +44 -0
- package/dist/functions/filtering/textHandler.js.map +1 -0
- package/dist/functions/filtering/utils.d.ts +26 -0
- package/dist/functions/filtering/utils.d.ts.map +1 -0
- package/dist/functions/filtering/utils.js +96 -0
- package/dist/functions/filtering/utils.js.map +1 -0
- package/dist/functions/index.d.ts +2 -1
- package/dist/functions/index.d.ts.map +1 -1
- package/dist/functions/index.js +2 -1
- package/dist/functions/index.js.map +1 -1
- package/dist/zod/account-settings/accountSettings.d.ts +98 -0
- package/dist/zod/account-settings/accountSettings.d.ts.map +1 -1
- package/dist/zod/account-settings/accountSettings.js +11 -1
- package/dist/zod/account-settings/accountSettings.js.map +1 -1
- package/dist/zod/filtering/columnFilterItem.d.ts +13 -0
- package/dist/zod/filtering/columnFilterItem.d.ts.map +1 -0
- package/dist/zod/filtering/columnFilterItem.js +8 -0
- package/dist/zod/filtering/columnFilterItem.js.map +1 -0
- package/dist/zod/filtering/index.d.ts +2 -0
- package/dist/zod/filtering/index.d.ts.map +1 -0
- package/dist/zod/filtering/index.js +2 -0
- package/dist/zod/filtering/index.js.map +1 -0
- package/dist/zod/index.d.ts +1 -0
- package/dist/zod/index.d.ts.map +1 -1
- package/dist/zod/index.js +1 -0
- package/dist/zod/index.js.map +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/functions/billing/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/billing/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Handler } from "./handler";
|
|
2
|
+
import { GeneralFilterArgs } from "./generalFilterArgs";
|
|
3
|
+
import { FilterPredicate } from "./filterPredicate";
|
|
4
|
+
export declare abstract class BaseHandler implements Handler {
|
|
5
|
+
private next?;
|
|
6
|
+
setNext(next: Handler): Handler;
|
|
7
|
+
handle(args: GeneralFilterArgs): FilterPredicate | null;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=baseHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseHandler.d.ts","sourceRoot":"","sources":["../../../src/functions/filtering/baseHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,8BAAsB,WAAY,YAAW,OAAO;IAClD,OAAO,CAAC,IAAI,CAAC,CAAU;IAEvB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO;IAK/B,MAAM,CAAC,IAAI,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI;CAIxD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class BaseHandler {
|
|
2
|
+
setNext(next) {
|
|
3
|
+
this.next = next;
|
|
4
|
+
return this;
|
|
5
|
+
}
|
|
6
|
+
handle(args) {
|
|
7
|
+
if (this.next)
|
|
8
|
+
return this.next.handle(args);
|
|
9
|
+
throw new Error(`No handler found for variant "${args.variant}"`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=baseHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseHandler.js","sourceRoot":"","sources":["../../../src/functions/filtering/baseHandler.ts"],"names":[],"mappings":"AAIA,MAAM,OAAgB,WAAW;IAG/B,OAAO,CAAC,IAAa;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,IAAuB;QAC5B,IAAI,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACpE,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseHandler } from "./baseHandler";
|
|
2
|
+
import { GeneralFilterArgs } from "./generalFilterArgs";
|
|
3
|
+
import { FilterPredicate } from "./filterPredicate";
|
|
4
|
+
export declare class BooleanHandler extends BaseHandler {
|
|
5
|
+
private readonly allowed;
|
|
6
|
+
handle({ variant, operator, valueJson }: GeneralFilterArgs): FilterPredicate | null;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=booleanHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booleanHandler.d.ts","sourceRoot":"","sources":["../../../src/functions/filtering/booleanHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,qBAAa,cAAe,SAAQ,WAAW;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoE;IAEnF,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI;CA6B3F"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BaseHandler } from "./baseHandler";
|
|
2
|
+
import { ensureAllowed, parseJSONValue } from "./utils";
|
|
3
|
+
export class BooleanHandler extends BaseHandler {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.allowed = ['=', '!=', 'isEmpty', 'isNotEmpty'];
|
|
7
|
+
}
|
|
8
|
+
handle({ variant, operator, valueJson }) {
|
|
9
|
+
if (variant !== 'boolean')
|
|
10
|
+
return super.handle({ variant, operator, valueJson });
|
|
11
|
+
ensureAllowed(operator, this.allowed);
|
|
12
|
+
const parseBooleanValue = (value) => {
|
|
13
|
+
if (typeof value === 'boolean')
|
|
14
|
+
return value;
|
|
15
|
+
if (value === 'true')
|
|
16
|
+
return true;
|
|
17
|
+
if (value === 'false')
|
|
18
|
+
return false;
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
const raw = parseJSONValue(valueJson);
|
|
22
|
+
const v = Array.isArray(raw) ? raw[0] : raw;
|
|
23
|
+
const val = parseBooleanValue(v);
|
|
24
|
+
switch (operator) {
|
|
25
|
+
case '=':
|
|
26
|
+
if (val == null)
|
|
27
|
+
throw new Error('Boolean "eq" needs value "true" or "false"');
|
|
28
|
+
return (cell) => Boolean(cell) === val;
|
|
29
|
+
case '!=':
|
|
30
|
+
if (val == null)
|
|
31
|
+
throw new Error('Boolean "ne" needs value "true" or "false"');
|
|
32
|
+
return (cell) => Boolean(cell) !== val;
|
|
33
|
+
case 'isEmpty':
|
|
34
|
+
return (cell) => cell == null || cell === '';
|
|
35
|
+
case 'isNotEmpty':
|
|
36
|
+
return (cell) => !(cell == null || cell === '');
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Unsupported boolean operator "${operator}"`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=booleanHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"booleanHandler.js","sourceRoot":"","sources":["../../../src/functions/filtering/booleanHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAEtD,MAAM,OAAO,cAAe,SAAQ,WAAW;IAA/C;;QACmB,YAAO,GAAsB,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,CAAU,CAAC;IA+B9F,CAAC;IA7BU,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAoB;QAC/D,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,CAAC,CAAC;QAC/E,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEtC,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAAkB,EAAE;YAC3D,IAAI,OAAO,KAAK,KAAK,SAAS;gBAAE,OAAO,KAAK,CAAC;YAC7C,IAAI,KAAK,KAAK,MAAM;gBAAE,OAAO,IAAI,CAAC;YAClC,IAAI,KAAK,KAAK,OAAO;gBAAE,OAAO,KAAK,CAAC;YACpC,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QAEF,MAAM,GAAG,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAC5C,MAAM,GAAG,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAEjC,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,GAAG;gBACN,IAAI,GAAG,IAAI,IAAI;oBAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;gBAC/E,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC;YACzC,KAAK,IAAI;gBACP,IAAI,GAAG,IAAI,IAAI;oBAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;gBAC/E,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC;YACzC,KAAK,SAAS;gBACZ,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;YAC/C,KAAK,YAAY;gBACf,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,iCAAiC,QAAQ,GAAG,CAAC,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseHandler } from "./baseHandler";
|
|
2
|
+
import { GeneralFilterArgs } from "./generalFilterArgs";
|
|
3
|
+
import { FilterPredicate } from "./filterPredicate";
|
|
4
|
+
export declare class DateHandler extends BaseHandler {
|
|
5
|
+
private readonly allowed;
|
|
6
|
+
handle({ variant, operator, valueJson }: GeneralFilterArgs): FilterPredicate | null;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=dateHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateHandler.d.ts","sourceRoot":"","sources":["../../../src/functions/filtering/dateHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,qBAAa,WAAY,SAAQ,WAAW;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAUb;IAEF,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI;CAsD3F"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BaseHandler } from "./baseHandler";
|
|
2
|
+
import { addDays, compareDateOnly, ensureAllowed, parseJSONValue, parseRelative, startOfDay, toDate } from "./utils";
|
|
3
|
+
export class DateHandler extends BaseHandler {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.allowed = [
|
|
7
|
+
'=',
|
|
8
|
+
'!=',
|
|
9
|
+
'<',
|
|
10
|
+
'<=',
|
|
11
|
+
'>',
|
|
12
|
+
'>=',
|
|
13
|
+
'isEmpty',
|
|
14
|
+
'isNotEmpty',
|
|
15
|
+
'isRelativeToToday',
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
handle({ variant, operator, valueJson }) {
|
|
19
|
+
if (variant !== 'date')
|
|
20
|
+
return super.handle({ variant, operator, valueJson });
|
|
21
|
+
ensureAllowed(operator, this.allowed);
|
|
22
|
+
if (operator === 'isRelativeToToday') {
|
|
23
|
+
const rel = parseRelative(valueJson);
|
|
24
|
+
if (!('offsetDays' in rel))
|
|
25
|
+
throw new Error('date:isRelativeToToday expects {offsetDays, compare}');
|
|
26
|
+
const pivot = addDays(startOfDay(new Date()), rel.offsetDays);
|
|
27
|
+
switch (rel.compare) {
|
|
28
|
+
case '<':
|
|
29
|
+
return (cell) => compareDateOnly(toDate(cell), pivot) < 0;
|
|
30
|
+
case '<=':
|
|
31
|
+
return (cell) => compareDateOnly(toDate(cell), pivot) <= 0;
|
|
32
|
+
case '>':
|
|
33
|
+
return (cell) => compareDateOnly(toDate(cell), pivot) > 0;
|
|
34
|
+
case '>=':
|
|
35
|
+
return (cell) => compareDateOnly(toDate(cell), pivot) >= 0;
|
|
36
|
+
case '=':
|
|
37
|
+
return (cell) => compareDateOnly(toDate(cell), pivot) === 0;
|
|
38
|
+
case '!=':
|
|
39
|
+
return (cell) => compareDateOnly(toDate(cell), pivot) !== 0;
|
|
40
|
+
default:
|
|
41
|
+
throw new Error(`Unsupported compare "${rel.compare}" for isRelativeToToday`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const raw = parseJSONValue(valueJson);
|
|
45
|
+
const v = Array.isArray(raw) ? raw[0] : raw;
|
|
46
|
+
const target = toDate(v);
|
|
47
|
+
if (!target && !['isEmpty', 'isNotEmpty'].includes(operator)) {
|
|
48
|
+
throw new Error('Date filter requires a valid date value');
|
|
49
|
+
}
|
|
50
|
+
switch (operator) {
|
|
51
|
+
case '=':
|
|
52
|
+
return (cell) => compareDateOnly(toDate(cell), target) === 0;
|
|
53
|
+
case '!=':
|
|
54
|
+
return (cell) => compareDateOnly(toDate(cell), target) !== 0;
|
|
55
|
+
case '<':
|
|
56
|
+
return (cell) => compareDateOnly(toDate(cell), target) < 0;
|
|
57
|
+
case '<=':
|
|
58
|
+
return (cell) => compareDateOnly(toDate(cell), target) <= 0;
|
|
59
|
+
case '>':
|
|
60
|
+
return (cell) => compareDateOnly(toDate(cell), target) > 0;
|
|
61
|
+
case '>=':
|
|
62
|
+
return (cell) => compareDateOnly(toDate(cell), target) >= 0;
|
|
63
|
+
case 'isEmpty':
|
|
64
|
+
return (cell) => !toDate(cell);
|
|
65
|
+
case 'isNotEmpty':
|
|
66
|
+
return (cell) => !!toDate(cell);
|
|
67
|
+
}
|
|
68
|
+
throw new Error(`Unsupported date operator "${operator}"`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=dateHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateHandler.js","sourceRoot":"","sources":["../../../src/functions/filtering/dateHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAC,MAAM,SAAS,CAAC;AAEnH,MAAM,OAAO,WAAY,SAAQ,WAAW;IAA5C;;QACmB,YAAO,GAAsB;YAC5C,GAAG;YACH,IAAI;YACJ,GAAG;YACH,IAAI;YACJ,GAAG;YACH,IAAI;YACJ,SAAS;YACT,YAAY;YACZ,mBAAmB;SACX,CAAC;IAwDb,CAAC;IAtDU,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAoB;QAC/D,IAAI,OAAO,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,CAAC,CAAC;QAC5E,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEtC,IAAI,QAAQ,KAAK,mBAAmB,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;YACrC,IAAI,CAAC,CAAC,YAAY,IAAI,GAAG,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;YACpG,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,GAAG,CAA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CAAC,8BAA8B,QAAQ,GAAG,CAAC,CAAC;IAC7D,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseHandler } from "./baseHandler";
|
|
2
|
+
import { GeneralFilterArgs } from "./generalFilterArgs";
|
|
3
|
+
import { FilterPredicate } from "./filterPredicate";
|
|
4
|
+
export declare class DateRangeHandler extends BaseHandler {
|
|
5
|
+
private readonly allowed;
|
|
6
|
+
handle({ variant, operator, valueJson }: GeneralFilterArgs): FilterPredicate | null;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=dateRangeHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateRangeHandler.d.ts","sourceRoot":"","sources":["../../../src/functions/filtering/dateRangeHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,qBAAa,gBAAiB,SAAQ,WAAW;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkE;IAEjF,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI;CAsC3F"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BaseHandler } from "./baseHandler";
|
|
2
|
+
import { addDays, endOfDay, ensureAllowed, parseJSONValue, parseRelative, startOfDay, toDate } from "./utils";
|
|
3
|
+
export class DateRangeHandler extends BaseHandler {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.allowed = ['isBetween', 'isRelativeToToday'];
|
|
7
|
+
}
|
|
8
|
+
handle({ variant, operator, valueJson }) {
|
|
9
|
+
if (variant !== 'dateRange')
|
|
10
|
+
return super.handle({ variant, operator, valueJson });
|
|
11
|
+
ensureAllowed(operator, this.allowed);
|
|
12
|
+
if (operator === 'isRelativeToToday') {
|
|
13
|
+
const rel = parseRelative(valueJson);
|
|
14
|
+
if (!('startOffsetDays' in rel)) {
|
|
15
|
+
throw new Error('dateRange:isRelativeToToday expects {startOffsetDays,endOffsetDays}');
|
|
16
|
+
}
|
|
17
|
+
const today = startOfDay(new Date());
|
|
18
|
+
const start = addDays(today, rel.startOffsetDays);
|
|
19
|
+
const end = addDays(today, rel.endOffsetDays);
|
|
20
|
+
const [lo, hi] = start <= end ? [start, end] : [end, start];
|
|
21
|
+
return (cell) => {
|
|
22
|
+
const d = toDate(cell);
|
|
23
|
+
if (!d)
|
|
24
|
+
return false;
|
|
25
|
+
const sd = startOfDay(d);
|
|
26
|
+
return sd >= lo && sd <= hi;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// isBetween with absolute dates: valueJson is string | [string, string]
|
|
30
|
+
const raw = parseJSONValue(valueJson);
|
|
31
|
+
const arr = Array.isArray(raw) ? raw : [raw];
|
|
32
|
+
const [startRaw, endRaw] = arr;
|
|
33
|
+
const start = startRaw ? startOfDay(toDate(startRaw)) : null;
|
|
34
|
+
const end = endRaw ? endOfDay(toDate(endRaw)) : null;
|
|
35
|
+
return (cell) => {
|
|
36
|
+
const d = toDate(cell);
|
|
37
|
+
if (!d)
|
|
38
|
+
return false;
|
|
39
|
+
const sd = d;
|
|
40
|
+
const geStart = !start || sd >= start;
|
|
41
|
+
const leEnd = !end || sd <= end;
|
|
42
|
+
return geStart && leEnd;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=dateRangeHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateRangeHandler.js","sourceRoot":"","sources":["../../../src/functions/filtering/dateRangeHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAC,OAAO,EAAE,QA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@
|
|
|
1
|
+
{"version":3,"file":"filterPredicate.js","sourceRoot":"","sources":["../../../src/functions/filtering/filterPredicate.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generalFilterArgs.d.ts","sourceRoot":"","sources":["../../../src/functions/filtering/generalFilterArgs.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC,CAAG,uEAAuE;CAC7F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generalFilterArgs.js","sourceRoot":"","sources":["../../../src/functions/filtering/generalFilterArgs.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GeneralFilterArgs } from "./generalFilterArgs";
|
|
2
|
+
import { FilterPredicate } from "./filterPredicate";
|
|
3
|
+
/** ---------- Chain of Responsibility Handler Pattern ---------- */
|
|
4
|
+
export interface Handler {
|
|
5
|
+
setNext(next: Handler): Handler;
|
|
6
|
+
handle(args: GeneralFilterArgs): FilterPredicate | null;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/functions/filtering/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD,oEAAoE;AACpE,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAEhC,MAAM,CAAC,IAAI,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI,CAAC;CACzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/functions/filtering/handler.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/functions/filtering/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/filtering/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseHandler } from "./baseHandler";
|
|
2
|
+
import { GeneralFilterArgs } from "./generalFilterArgs";
|
|
3
|
+
import { FilterPredicate } from "./filterPredicate";
|
|
4
|
+
export declare class MultiSelectHandler extends BaseHandler {
|
|
5
|
+
private readonly allowed;
|
|
6
|
+
handle({ variant, operator, valueJson }: GeneralFilterArgs): FilterPredicate | null;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=multiSelectHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiSelectHandler.d.ts","sourceRoot":"","sources":["../../../src/functions/filtering/multiSelectHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+C;IAE9D,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI;CAuC3F"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BaseHandler } from "./baseHandler";
|
|
2
|
+
import { ensureAllowed, parseJSONValue } from "./utils";
|
|
3
|
+
export class MultiSelectHandler extends BaseHandler {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.allowed = ['in', 'notIn'];
|
|
7
|
+
}
|
|
8
|
+
handle({ variant, operator, valueJson }) {
|
|
9
|
+
if (variant !== 'multiSelect')
|
|
10
|
+
return super.handle({ variant, operator, valueJson });
|
|
11
|
+
ensureAllowed(operator, this.allowed);
|
|
12
|
+
const raw = parseJSONValue(valueJson);
|
|
13
|
+
const needles = Array.isArray(raw) ? raw : [raw];
|
|
14
|
+
const asArray = (x) => {
|
|
15
|
+
if (Array.isArray(x))
|
|
16
|
+
return x.map(String);
|
|
17
|
+
// allow comma-separated strings as a convenience
|
|
18
|
+
if (typeof x === 'string')
|
|
19
|
+
return x
|
|
20
|
+
.split(',')
|
|
21
|
+
.map((s) => s.trim())
|
|
22
|
+
.filter(Boolean);
|
|
23
|
+
if (x == null)
|
|
24
|
+
return [];
|
|
25
|
+
return [JSON.stringify(x)];
|
|
26
|
+
};
|
|
27
|
+
switch (operator) {
|
|
28
|
+
case 'in':
|
|
29
|
+
// cell has ANY of the selected
|
|
30
|
+
return (cell) => {
|
|
31
|
+
const arr = asArray(cell);
|
|
32
|
+
return arr.some((v) => needles.includes(String(v)));
|
|
33
|
+
};
|
|
34
|
+
case 'notIn':
|
|
35
|
+
// cell has NONE of the selected
|
|
36
|
+
return (cell) => {
|
|
37
|
+
const arr = asArray(cell);
|
|
38
|
+
return arr.every((v) => !needles.includes(String(v)));
|
|
39
|
+
};
|
|
40
|
+
case 'isEmpty':
|
|
41
|
+
return (cell) => asArray(cell).length === 0;
|
|
42
|
+
case 'isNotEmpty':
|
|
43
|
+
return (cell) => asArray(cell).length > 0;
|
|
44
|
+
}
|
|
45
|
+
throw new Error(`Unsupported multi-select operator "${operator}"`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=multiSelectHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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B,CAAC,CAAC;QAEF,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,IAAI;gBACP,+BAA+B;gBAC/B,OAAO,CAAC,IAAI,EAAE,EAAE;oBACd,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;oBAC1B,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtD,CAAC,CAAC;YACJ,KAAK,OAAO;gBACV,gCAAgC;gBAChC,OAAO,CAAC,IAAI,EAAE,EAAE;oBACd,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;oBAC1B,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxD,CAAC,CAAC;YACJ,KAAK,SAAS;gBACZ,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;YAC9C,KAAK,YAAY;gBACf,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,GAAG,CAAC,CAAC;IACrE,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GeneralFilterArgs } from "./generalFilterArgs";
|
|
2
|
+
import { FilterPredicate } from "./filterPredicate";
|
|
3
|
+
import { BaseHandler } from "./baseHandler";
|
|
4
|
+
export declare class NumberHandler extends BaseHandler {
|
|
5
|
+
private readonly allowed;
|
|
6
|
+
handle({ variant, operator, valueJson }: GeneralFilterArgs): FilterPredicate | null;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=numberHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberHandler.d.ts","sourceRoot":"","sources":["../../../src/functions/filtering/numberHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,qBAAa,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0F;IAEzG,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI;CA0C3F"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ensureAllowed, parseJSONValue, toNumber } from "./utils";
|
|
2
|
+
import { BaseHandler } from "./baseHandler";
|
|
3
|
+
export class NumberHandler extends BaseHandler {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.allowed = ['=', '!=', '>', '>=', '<', '<=', 'isEmpty', 'isNotEmpty'];
|
|
7
|
+
}
|
|
8
|
+
handle({ variant, operator, valueJson }) {
|
|
9
|
+
if (variant !== 'number')
|
|
10
|
+
return super.handle({ variant, operator, valueJson });
|
|
11
|
+
ensureAllowed(operator, this.allowed);
|
|
12
|
+
const raw = parseJSONValue(valueJson);
|
|
13
|
+
const value = Array.isArray(raw) ? toNumber(raw[0]) : toNumber(raw);
|
|
14
|
+
if (value == null && !['isEmpty', 'isNotEmpty'].includes(operator)) {
|
|
15
|
+
throw new Error('Number filter requires a numeric value');
|
|
16
|
+
}
|
|
17
|
+
switch (operator) {
|
|
18
|
+
case '=':
|
|
19
|
+
return (cell) => toNumber(cell) === value;
|
|
20
|
+
case '!=':
|
|
21
|
+
return (cell) => toNumber(cell) !== value;
|
|
22
|
+
case '<':
|
|
23
|
+
return (cell) => {
|
|
24
|
+
const n = toNumber(cell);
|
|
25
|
+
return n == null ? false : n < value;
|
|
26
|
+
};
|
|
27
|
+
case '<=':
|
|
28
|
+
return (cell) => {
|
|
29
|
+
const n = toNumber(cell);
|
|
30
|
+
return n == null ? false : n <= value;
|
|
31
|
+
};
|
|
32
|
+
case '>':
|
|
33
|
+
return (cell) => {
|
|
34
|
+
const n = toNumber(cell);
|
|
35
|
+
return n == null ? false : n > value;
|
|
36
|
+
};
|
|
37
|
+
case '>=':
|
|
38
|
+
return (cell) => {
|
|
39
|
+
const n = toNumber(cell);
|
|
40
|
+
return n == null ? false : n >= value;
|
|
41
|
+
};
|
|
42
|
+
case 'isEmpty':
|
|
43
|
+
return (cell) => cell == null || cell === '';
|
|
44
|
+
case 'isNotEmpty':
|
|
45
|
+
return (cell) => !(cell == null || cell === '');
|
|
46
|
+
}
|
|
47
|
+
throw new Error(`Unsupported number operator "${operator}"`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=numberHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberHandler.js","sourceRoot":"","sources":["../../../src/functions/filtering/numberHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAE,cAAc,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEhE,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,MAAM,OAAO,aAAc,SAAQ,WAAW;IAA9C;;QACmB,YAAO,GAAsB,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,CAAU,CAAC;IA4CpH,CAAC;IA1CU,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAoB;QAC/D,IAAI,OAAO,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SA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E,EAAE;oBACd,MAAM,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACzB,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAI,KAAgB,CAAC;gBACnD,CAAC,CAAC;YACJ,KAAK,IAAI;gBACP,OAAO,CAAC,IAAI,EAAE,EAAE;oBACd,MAAM,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACzB,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAK,KAAgB,CAAC;gBACpD,CAAC,CAAC;YACJ,KAAK,SAAS;gBACZ,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;YAC/C,KAAK,YAAY;gBACf,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,gCAAgC,QAAQ,GAAG,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GeneralFilterArgs } from "./generalFilterArgs";
|
|
2
|
+
import { FilterPredicate } from "./filterPredicate";
|
|
3
|
+
import { BaseHandler } from "./baseHandler";
|
|
4
|
+
export declare class NumberRangeHandler extends BaseHandler {
|
|
5
|
+
private readonly allowed;
|
|
6
|
+
handle({ variant, operator, valueJson }: GeneralFilterArgs): FilterPredicate | null;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=numberRangeHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberRangeHandler.d.ts","sourceRoot":"","sources":["../../../src/functions/filtering/numberRangeHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6C;IAE5D,MAAM,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAC,EAAE,iBAAiB,GAAG,eAAe,GAAG,IAAI;CAkB3F"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ensureAllowed, parseJSONValue, toNumber } from "./utils";
|
|
2
|
+
import { BaseHandler } from "./baseHandler";
|
|
3
|
+
export class NumberRangeHandler extends BaseHandler {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.allowed = ['isBetween'];
|
|
7
|
+
}
|
|
8
|
+
handle({ variant, operator, valueJson }) {
|
|
9
|
+
if (variant !== 'range')
|
|
10
|
+
return super.handle({ variant, operator, valueJson });
|
|
11
|
+
ensureAllowed(operator, this.allowed);
|
|
12
|
+
const raw = parseJSONValue(valueJson);
|
|
13
|
+
const arr = Array.isArray(raw) ? raw : [raw];
|
|
14
|
+
const [minStr, maxStr] = arr;
|
|
15
|
+
const min = toNumber(minStr);
|
|
16
|
+
const max = toNumber(maxStr);
|
|
17
|
+
return (cell) => {
|
|
18
|
+
const n = toNumber(cell);
|
|
19
|
+
if (n == null)
|
|
20
|
+
return false;
|
|
21
|
+
const geMin = min == null || n >= min;
|
|
22
|
+
const leMax = max == null || n <= max;
|
|
23
|
+
return geMin && leMax;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=numberRangeHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numberRangeHandler.js","sourceRoot":"","sources":["../../../src/functions/filtering/numberRangeHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAE,cAAc,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
|
+
import { RuleGroupType, RuleType } from 'react-querybuilder';
|
|
3
|
+
import { GeneralFilterArgs } from "./generalFilterArgs";
|
|
4
|
+
import { FilterPredicate } from "./filterPredicate";
|
|
5
|
+
/** ---------- Public factories ---------- */
|
|
6
|
+
/**
|
|
7
|
+
* Builds a predicate for a single cell given a filter config.
|
|
8
|
+
* Throws for unknown variant or irrelevant operators.
|
|
9
|
+
*/
|
|
10
|
+
export declare const createFilterPredicate: (args: GeneralFilterArgs) => FilterPredicate;
|
|
11
|
+
/**
|
|
12
|
+
* A type for defining a function that determines whether a specific row of data
|
|
13
|
+
* meets the conditions defined by a filter.
|
|
14
|
+
*
|
|
15
|
+
* @template TData - The type of data represented in the row.
|
|
16
|
+
* @param {Row<TData>} row - The row of data being evaluated.
|
|
17
|
+
* @param {string} columnId - The identifier for the column being filtered.
|
|
18
|
+
* @param {string} filterJson - The value to filter against serialized as JSON.
|
|
19
|
+
* @returns {boolean} - Returns true if the row matches the filter condition, otherwise false.
|
|
20
|
+
*/
|
|
21
|
+
export type GenericColumnFilterFunction<TData> = (row: Row<TData>, columnId: string, filterJson: string) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Factory function that creates a filter function to be applied to data rows.
|
|
24
|
+
* The generated filter function evaluates a row against a given filter condition
|
|
25
|
+
* and returns a boolean indicating whether the row satisfies the filter criteria
|
|
26
|
+
* for the specified column.
|
|
27
|
+
*
|
|
28
|
+
* The filter function is constructed dynamically based on the provided filter
|
|
29
|
+
* definition, which includes an operator, variant, and filter value. The filter
|
|
30
|
+
* value is serialized and deserialized as JSON to ensure proper handling of
|
|
31
|
+
* complex data structures.
|
|
32
|
+
*
|
|
33
|
+
* @template TData - The type of the data row objects.
|
|
34
|
+
* @returns {GenericColumnFilterFunction<TData>} A filter function that takes a row, column ID, and filter value, and returns a boolean.
|
|
35
|
+
*/
|
|
36
|
+
export declare const genericColumnFilter: <TData>() => GenericColumnFilterFunction<TData>;
|
|
37
|
+
/**
|
|
38
|
+
* A generic filter function type used to evaluate whether a given row of data satisfies
|
|
39
|
+
* a specified filter condition. This function is commonly used in tables or data grids
|
|
40
|
+
* to implement filtering logic.
|
|
41
|
+
*
|
|
42
|
+
* @template TData - The type of the row data being filtered.
|
|
43
|
+
* @param {TData} row - The data object or row being evaluated against the filter condition.
|
|
44
|
+
* @param {string} columnId - The identifier for the column being filtered.
|
|
45
|
+
* @param {string} filterValue - The value to compare against the specified column of the row data.
|
|
46
|
+
* @returns {boolean} Returns true if the row satisfies the filter condition, otherwise false.
|
|
47
|
+
*/
|
|
48
|
+
type genericFilterFunction<TData> = (row: TData, filterValue: RuleType) => boolean;
|
|
49
|
+
/**
|
|
50
|
+
* A higher-order function that creates a generic filter function.
|
|
51
|
+
*
|
|
52
|
+
* @template TData
|
|
53
|
+
* @returns {genericFilterFunction<TData>} A function that takes a data row and a filter schema,
|
|
54
|
+
* and evaluates whether the row matches the filter criteria.
|
|
55
|
+
*
|
|
56
|
+
* The returned function takes two arguments:
|
|
57
|
+
* - `row` (TData): The data row to be evaluated.
|
|
58
|
+
* - `filter` (FilterItemSchema): Defines the filtering criteria, including the operator and value to filter by.
|
|
59
|
+
*
|
|
60
|
+
* Internally, the function determines the variant based on the row and operator, creates a filter
|
|
61
|
+
* predicate using the specified operator and value, and applies the predicate on the row to determine
|
|
62
|
+
* whether it satisfies the filter.
|
|
63
|
+
*/
|
|
64
|
+
export declare const genericFilter: <TData>() => genericFilterFunction<TData>;
|
|
65
|
+
/**
|
|
66
|
+
* A type definition for a generic function that processes a row of data and determines
|
|
67
|
+
* whether it satisfies the conditions specified in a filter group.
|
|
68
|
+
*
|
|
69
|
+
* @callback genericFilterGroupFunction
|
|
70
|
+
* @template TData - The type of the data row being evaluated.
|
|
71
|
+
* @param {TData} row - The data row to evaluate against the filter group.
|
|
72
|
+
* @param {RuleGroupType} filter - The object representing the group of filtering rules. (React Query Builder format)
|
|
73
|
+
* @returns {boolean} A boolean indicating whether the data row satisfies the filter group.
|
|
74
|
+
*/
|
|
75
|
+
type genericFilterGroupFunction<TData> = (row: TData, filter: RuleGroupType) => boolean;
|
|
76
|
+
/**
|
|
77
|
+
* A generic filter group function that applies a set of filtering rules to a given data row.
|
|
78
|
+
* This function evaluates the rules based on the combinator provided ('and' or 'or') and applies the corresponding logical operation.
|
|
79
|
+
*
|
|
80
|
+
* @template TData The type of the data to which filtering rules will be applied.
|
|
81
|
+
* @returns {genericFilterGroupFunction<TData>} A function that evaluates a row against the given filter rules.
|
|
82
|
+
*/
|
|
83
|
+
export declare const genericFilterGroup: <TData>() => genericFilterGroupFunction<TData>;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=queryFilters.d.ts.map
|