dyo-tools 0.1.0-rc2 → 0.2.0
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/.c8rc.json +4 -0
- package/.eslintignore +2 -0
- package/.eslintrc.json +47 -0
- package/LICENSE +21 -0
- package/Makefile +34 -0
- package/README.md +0 -7
- package/babel.config.js +1 -0
- package/cucumber-report.html +48 -0
- package/cucumber.js +9 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.js +63 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/DTBunch.d.ts +11 -15
- package/dist/core/DTBunch.js +27 -106
- package/dist/core/DTBunch.js.map +1 -1
- package/dist/core/DTComponent.d.ts +13 -5
- package/dist/core/DTComponent.js +39 -1
- package/dist/core/DTComponent.js.map +1 -1
- package/dist/core/DTComponentPhysical.d.ts +10 -0
- package/dist/core/DTComponentPhysical.js +16 -0
- package/dist/core/DTComponentPhysical.js.map +1 -0
- package/dist/core/DTComponentWithMeta.d.ts +2 -2
- package/dist/core/DTComponentWithMeta.js.map +1 -1
- package/dist/core/DTElement.d.ts +2 -7
- package/dist/core/DTElement.js +3 -12
- package/dist/core/DTElement.js.map +1 -1
- package/dist/core/DTManager.d.ts +31 -0
- package/dist/core/DTManager.js +180 -0
- package/dist/core/DTManager.js.map +1 -0
- package/dist/core/DTPlayer.js +1 -1
- package/dist/core/DTPlayer.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/libs/DYOFinder.d.ts +10 -0
- package/dist/libs/DYOFinder.js +96 -0
- package/dist/libs/DYOFinder.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1321
- package/dist/types/index.d.ts +64 -24
- package/dist/types/index.js.map +1 -1
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +29 -0
- package/docs/assets/main.js +58 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1367 -0
- package/docs/index.html +46 -0
- package/e2e/0.2.0/epic1.feature +29 -0
- package/e2e/0.2.0/epic2.feature +22 -0
- package/e2e/0.2.0/epic3.feature +25 -0
- package/e2e/0.2.0/resources/dominion.js +195 -0
- package/e2e/0.2.0/resources/utils.js +27 -0
- package/e2e/0.2.0/support/steps.js +108 -0
- package/e2e/future/epic4.feature +39 -0
- package/e2e/future/resources/dominion.js +238 -0
- package/e2e/future/resources/utils.js +27 -0
- package/jest.config.js +6 -0
- package/package.json +33 -23
- package/src/constants.ts +85 -0
- package/src/core/DTBunch.ts +461 -0
- package/src/core/DTComponent.ts +225 -0
- package/src/core/DTComponentPhysical.ts +39 -0
- package/src/core/DTComponentWithMeta.ts +65 -0
- package/src/core/DTElement.ts +69 -0
- package/src/core/DTError.ts +78 -0
- package/src/core/DTManager.ts +446 -0
- package/src/core/DTPlayer.ts +57 -0
- package/src/index.ts +9 -0
- package/src/libs/DYOFinder.ts +175 -0
- package/src/types/index.ts +162 -0
- package/test/core/DTBunch.double.ts +253 -0
- package/test/core/DTBunch.spec.ts +895 -0
- package/test/core/DTComponent.double.ts +164 -0
- package/test/core/DTComponent.spec.ts +295 -0
- package/test/core/DTComponentPhysical.double.ts +76 -0
- package/test/core/DTComponentPhysical.spec.ts +64 -0
- package/test/core/DTComponentWithMeta.double.ts +115 -0
- package/test/core/DTComponentWithMeta.spec.ts +124 -0
- package/test/core/DTElement.double.ts +147 -0
- package/test/core/DTElement.spec.ts +102 -0
- package/test/core/DTError.double.ts +92 -0
- package/test/core/DTError.spec.ts +89 -0
- package/test/core/DTManager.double.ts +192 -0
- package/test/core/DTManager.spec.ts +902 -0
- package/test/core/DTPlayer.double.ts +64 -0
- package/test/core/DTPlayer.spec.ts +80 -0
- package/test/core/copy.spec.ts +227 -0
- package/test/libs/DYOFinder.double.ts +152 -0
- package/test/libs/DYOFinder.spec.ts +194 -0
- package/tsconfig.dev.json +22 -0
- package/tsconfig.json +21 -0
- package/dist/utils/filters.d.ts +0 -6
- package/dist/utils/filters.js +0 -39
- package/dist/utils/filters.js.map +0 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import {
|
|
2
|
+
afterEach, beforeEach, describe, expect, jest, test,
|
|
3
|
+
} from '@jest/globals';
|
|
4
|
+
import { DTBunchStub, IDTest } from '../core/DTBunch.double';
|
|
5
|
+
import DYOFinderTest, { DefaultConfiguration, generateComponent } from './DYOFinder.double';
|
|
6
|
+
import { FilterOperatorType } from '../../src/types';
|
|
7
|
+
|
|
8
|
+
/** *********************** TESTS SUITES ****************************** */
|
|
9
|
+
describe('class DYOFinder', () => {
|
|
10
|
+
let bunchStubToFind: DTBunchStub;
|
|
11
|
+
let finder: DYOFinderTest;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
bunchStubToFind = generateComponent();
|
|
15
|
+
finder = new DYOFinderTest(bunchStubToFind, DefaultConfiguration);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
jest.resetAllMocks();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('constructor()', () => {
|
|
23
|
+
test('simple initialisation', () => {
|
|
24
|
+
const newFinder = new DYOFinderTest(bunchStubToFind, DefaultConfiguration);
|
|
25
|
+
|
|
26
|
+
expect(newFinder.th_get_component().getId()).toBe(IDTest);
|
|
27
|
+
expect(newFinder.th_get_configuration()).toStrictEqual(DefaultConfiguration);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('execute()', () => {
|
|
32
|
+
const finderExecutionTestValue = (results: any): [number, []] => [
|
|
33
|
+
results.length,
|
|
34
|
+
results.map((result) => result.parentIndex),
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
test('find items - $eq operator case', () => {
|
|
38
|
+
// String prop
|
|
39
|
+
expect(finderExecutionTestValue(finder.execute({ propString: { $eq: 'item_prime' } }))).toStrictEqual([2, [0, 1]]);
|
|
40
|
+
expect(finderExecutionTestValue(finder.execute({ propString: { $eq: 'invalid' } }))).toStrictEqual([0, []]);
|
|
41
|
+
// Number prop
|
|
42
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $eq: 17 } }))).toStrictEqual([2, [0, 3]]);
|
|
43
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $eq: 24 } }))).toStrictEqual([0, []]);
|
|
44
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $eq: '17' } }))).toStrictEqual([0, []]);
|
|
45
|
+
// Array prop
|
|
46
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $eq: 'tag1' } }))).toStrictEqual([0, []]);
|
|
47
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $eq: undefined } }))).toStrictEqual([1, [3]]);
|
|
48
|
+
// Boolean prop
|
|
49
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $eq: true } }))).toStrictEqual([3, [0, 2, 4]]);
|
|
50
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $eq: false } }))).toStrictEqual([2, [1, 3]]);
|
|
51
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $eq: 'false' } }))).toStrictEqual([0, []]);
|
|
52
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $eq: null } }))).toStrictEqual([0, []]);
|
|
53
|
+
// Object prop
|
|
54
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $eq: 'value' } }))).toStrictEqual([0, []]);
|
|
55
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $eq: "{ data: 'value' }" } }))).toStrictEqual([0, []]);
|
|
56
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $eq: null } }))).toStrictEqual([2, [3, 4]]);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('find items - $ne operator case', () => {
|
|
60
|
+
// String prop
|
|
61
|
+
expect(finderExecutionTestValue(finder.execute({ propString: { $ne: 'item_prime' } }))).toStrictEqual([3, [2, 3, 4]]);
|
|
62
|
+
expect(finderExecutionTestValue(finder.execute({ propString: { $ne: 'invalid' } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
63
|
+
// Number prop
|
|
64
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $ne: 17 } }))).toStrictEqual([3, [1, 2, 4]]);
|
|
65
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $ne: 24 } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
66
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $ne: '17' } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
67
|
+
// Array prop
|
|
68
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $ne: 'tag1' } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
69
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $ne: undefined } }))).toStrictEqual([4, [0, 1, 2, 4]]);
|
|
70
|
+
// Boolean prop
|
|
71
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $ne: true } }))).toStrictEqual([2, [1, 3]]);
|
|
72
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $ne: false } }))).toStrictEqual([3, [0, 2, 4]]);
|
|
73
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $ne: 'false' } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
74
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $ne: null } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
75
|
+
// Object prop
|
|
76
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $ne: 'value' } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
77
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $ne: "{ data: 'value' }" } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
78
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $ne: null } }))).toStrictEqual([3, [0, 1, 2]]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('find items - $in operator case', () => {
|
|
82
|
+
// String prop
|
|
83
|
+
expect(finderExecutionTestValue(finder.execute({ propString: { $in: ['item_prime', 'item_second'] } }))).toStrictEqual([4, [0, 1, 2, 4]]);
|
|
84
|
+
expect(finderExecutionTestValue(finder.execute({ propString: { $in: ['item_third', 'invalid', false] } }))).toStrictEqual([1, [3]]);
|
|
85
|
+
// Number prop
|
|
86
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $in: [17, 19] } }))).toStrictEqual([3, [0, 1, 3]]);
|
|
87
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $in: ['17', 24, false] } }))).toStrictEqual([0, []]);
|
|
88
|
+
// Array prop
|
|
89
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $in: ['tag1'] } }))).toStrictEqual([0, []]);
|
|
90
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $in: ['tag1', 'tag2', undefined] } }))).toStrictEqual([1, [3]]);
|
|
91
|
+
// Boolean prop
|
|
92
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $in: [true, false] } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
93
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $in: ['true', 'false', null] } }))).toStrictEqual([0, []]);
|
|
94
|
+
// Object prop
|
|
95
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $in: ['value'] } }))).toStrictEqual([0, []]);
|
|
96
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $in: null } }))).toStrictEqual([0, []]);
|
|
97
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $in: [null] } }))).toStrictEqual([2, [3, 4]]);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('find items - $nin operator case', () => {
|
|
101
|
+
// String prop
|
|
102
|
+
expect(finderExecutionTestValue(finder.execute({ propString: { $nin: ['item_prime', 'item_second'] } }))).toStrictEqual([1, [3]]);
|
|
103
|
+
expect(finderExecutionTestValue(finder.execute({ propString: { $nin: ['item_third', 'invalid', false] } }))).toStrictEqual([4, [0, 1, 2, 4]]);
|
|
104
|
+
// Number prop
|
|
105
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $nin: [17, 19] } }))).toStrictEqual([2, [2, 4]]);
|
|
106
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $nin: ['17', 24, false] } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
107
|
+
// Array prop
|
|
108
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $nin: ['tag1'] } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
109
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $nin: ['tag1', 'tag2', undefined] } }))).toStrictEqual([4, [0, 1, 2, 4]]);
|
|
110
|
+
// Boolean prop
|
|
111
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $nin: [true, false] } }))).toStrictEqual([0, []]);
|
|
112
|
+
expect(finderExecutionTestValue(finder.execute({ propBoolean: { $nin: ['true', 'false', null] } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
113
|
+
// Object prop
|
|
114
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $nin: ['value'] } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
115
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $nin: null } }))).toStrictEqual([0, []]);
|
|
116
|
+
expect(finderExecutionTestValue(finder.execute({ propObject: { $nin: [null] } }))).toStrictEqual([3, [0, 1, 2]]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('find items - $lte operator case', () => {
|
|
120
|
+
// Number prop
|
|
121
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $lte: 23 } }))).toStrictEqual([4, [0, 1, 2, 3]]);
|
|
122
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $lte: 1000 } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
123
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $lte: null } }))).toStrictEqual([0, []]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('find items - $gte operator case', () => {
|
|
127
|
+
// Number prop
|
|
128
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $gte: 23 } }))).toStrictEqual([2, [2, 4]]);
|
|
129
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $gte: -1000 } }))).toStrictEqual([5, [0, 1, 2, 3, 4]]);
|
|
130
|
+
expect(finderExecutionTestValue(finder.execute({ propNumber: { $gte: null } }))).toStrictEqual([0, []]);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('find items - $contains operator case', () => {
|
|
134
|
+
// Array prop
|
|
135
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $contains: 'tag1' } }))).toStrictEqual([3, [0, 1, 2]]);
|
|
136
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $contains: undefined } }))).toStrictEqual([0, []]);
|
|
137
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $contains: 'invalid_tag' } }))).toStrictEqual([0, []]);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('find items - $ncontains operator case', () => {
|
|
141
|
+
// Array prop
|
|
142
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $ncontains: 'tag1' } }))).toStrictEqual([1, [4]]);
|
|
143
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $ncontains: undefined } }))).toStrictEqual([4, [0, 1, 2, 4]]);
|
|
144
|
+
expect(finderExecutionTestValue(finder.execute({ propArray: { $ncontains: 'invalid_tag' } }))).toStrictEqual([4, [0, 1, 2, 4]]);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('disable filters by configuration', () => {
|
|
148
|
+
finder.th_set_configuration({
|
|
149
|
+
propString: {
|
|
150
|
+
operators: [FilterOperatorType.NE],
|
|
151
|
+
getValue: (item: any) => item.getPropString(),
|
|
152
|
+
objectSearch: false,
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
expect(finderExecutionTestValue(finder.execute({ propString: { $eq: 'item_prime' } }))).toStrictEqual([0, []]);
|
|
157
|
+
expect(finderExecutionTestValue(finder.execute({ propString: { $in: ['item_prime', 'item_second'] } }))).toStrictEqual([0, []]);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('returns no items when no filter passed', () => {
|
|
161
|
+
expect(finderExecutionTestValue(finder.execute({}))).toStrictEqual([0, []]);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('find items with object search property', () => {
|
|
165
|
+
expect(finderExecutionTestValue(finder.execute(
|
|
166
|
+
{ propMeta: { meta1: { $eq: 'value1' } } },
|
|
167
|
+
))).toStrictEqual([2, [0, 1]]);
|
|
168
|
+
expect(finderExecutionTestValue(finder.execute(
|
|
169
|
+
{ propMeta: { meta2: { $in: ['value2', 'value1'] } } },
|
|
170
|
+
))).toStrictEqual([2, [1, 2]]);
|
|
171
|
+
expect(finderExecutionTestValue(finder.execute(
|
|
172
|
+
{ propMeta: { meta1: { $ne: 'value1' } } },
|
|
173
|
+
))).toStrictEqual([2, [2, 4]]);
|
|
174
|
+
expect(finderExecutionTestValue(finder.execute(
|
|
175
|
+
{ propMeta: { meta1: { } } },
|
|
176
|
+
))).toStrictEqual([0, []]);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test('find items with complex and multiple filters', () => {
|
|
180
|
+
// Multiple filters
|
|
181
|
+
expect(finderExecutionTestValue(finder.execute(
|
|
182
|
+
{ propString: { $eq: 'item_prime' }, propNumber: { $lte: 18 } },
|
|
183
|
+
))).toStrictEqual([1, [0]]);
|
|
184
|
+
// Multiple operators
|
|
185
|
+
expect(finderExecutionTestValue(finder.execute(
|
|
186
|
+
{ propNumber: { $lte: 25, $gte: 15, $ne: 19 } },
|
|
187
|
+
))).toStrictEqual([3, [0, 2, 3]]);
|
|
188
|
+
// Multiple filters and Object search
|
|
189
|
+
expect(finderExecutionTestValue(finder.execute(
|
|
190
|
+
{ propString: { $in: ['item_prime', 'item_third'] }, propArray: { $ne: undefined }, propMeta: { meta2: { $ne: undefined } } },
|
|
191
|
+
))).toStrictEqual([1, [1]]);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"target": "es2015",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"baseUrl": "./",
|
|
13
|
+
"incremental": true
|
|
14
|
+
},
|
|
15
|
+
"include": [
|
|
16
|
+
"src/**/*.ts",
|
|
17
|
+
"test/**/*.ts"
|
|
18
|
+
],
|
|
19
|
+
"exclude": [
|
|
20
|
+
"node_modules"
|
|
21
|
+
]
|
|
22
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"allowSyntheticDefaultImports": true,
|
|
9
|
+
"target": "es2015",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"baseUrl": "./",
|
|
13
|
+
"incremental": true
|
|
14
|
+
},
|
|
15
|
+
"include": [
|
|
16
|
+
"src/**/*.ts"
|
|
17
|
+
],
|
|
18
|
+
"exclude": [
|
|
19
|
+
"node_modules"
|
|
20
|
+
]
|
|
21
|
+
}
|
package/dist/utils/filters.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FilterOperatorType, StandardPrimitiveType } from '../types';
|
|
2
|
-
export declare function validFiltersForItem(itemProp: StandardPrimitiveType, filter: StandardPrimitiveType, operator: FilterOperatorType.EQ): boolean;
|
|
3
|
-
export declare function validFiltersForItem(itemProp: StandardPrimitiveType, filter: StandardPrimitiveType[], operator: FilterOperatorType.IN | FilterOperatorType.NIN): boolean;
|
|
4
|
-
export declare function validFiltersForItem(itemProp: StandardPrimitiveType, filter: StandardPrimitiveType, operator: FilterOperatorType.NE): boolean;
|
|
5
|
-
export declare function validFiltersForItem(itemProp: number, filter: number, operator: FilterOperatorType.LTE | FilterOperatorType.GTE): boolean;
|
|
6
|
-
export declare function validFiltersForItem(itemProp: StandardPrimitiveType[], filter: StandardPrimitiveType, operator: FilterOperatorType.CONTAINS | FilterOperatorType.NCONTAINS): boolean;
|
package/dist/utils/filters.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validFiltersForItem = void 0;
|
|
4
|
-
const types_1 = require("../types");
|
|
5
|
-
function validFiltersForItem(itemProp, filter, operator = types_1.FilterOperatorType.EQ) {
|
|
6
|
-
if (operator === types_1.FilterOperatorType.EQ) {
|
|
7
|
-
return itemProp === filter;
|
|
8
|
-
}
|
|
9
|
-
if (operator === types_1.FilterOperatorType.IN) {
|
|
10
|
-
return filter ? filter.includes(itemProp) : false;
|
|
11
|
-
}
|
|
12
|
-
if (operator === types_1.FilterOperatorType.NIN) {
|
|
13
|
-
return filter ? !filter.includes(itemProp) : false;
|
|
14
|
-
}
|
|
15
|
-
if (operator === types_1.FilterOperatorType.NE) {
|
|
16
|
-
return itemProp !== filter;
|
|
17
|
-
}
|
|
18
|
-
if (operator === types_1.FilterOperatorType.LTE) {
|
|
19
|
-
if (typeof itemProp === 'number' && typeof filter === 'number') {
|
|
20
|
-
return itemProp <= filter;
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
if (operator === types_1.FilterOperatorType.GTE) {
|
|
25
|
-
if (typeof itemProp === 'number' && typeof filter === 'number') {
|
|
26
|
-
return itemProp >= filter;
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if (operator === types_1.FilterOperatorType.CONTAINS) {
|
|
31
|
-
return itemProp ? itemProp.includes(filter) : false;
|
|
32
|
-
}
|
|
33
|
-
if (operator === types_1.FilterOperatorType.NCONTAINS) {
|
|
34
|
-
return itemProp ? !itemProp.includes(filter) : false;
|
|
35
|
-
}
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
exports.validFiltersForItem = validFiltersForItem;
|
|
39
|
-
//# sourceMappingURL=filters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/utils/filters.ts"],"names":[],"mappings":";;;AAAA,oCAAqE;AAiBrE,SAAgB,mBAAmB,CACjC,QAAyD,EACzD,MAAuD,EACvD,WAA+B,0BAAkB,CAAC,EAAE;IAGpD,IAAI,QAAQ,KAAK,0BAAkB,CAAC,EAAE,EAAE;QACtC,OAAO,QAAQ,KAAK,MAAM,CAAC;KAC5B;IAED,IAAI,QAAQ,KAAK,0BAAkB,CAAC,EAAE,EAAE;QACtC,OAAO,MAAM,CAAC,CAAC,CAAE,MAAkC,CAAC,QAAQ,CAAC,QAAiC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;KACzG;IAED,IAAI,QAAQ,KAAK,0BAAkB,CAAC,GAAG,EAAE;QACvC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAE,MAAkC,CAAC,QAAQ,CAAC,QAAiC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;KAC1G;IAGD,IAAI,QAAQ,KAAK,0BAAkB,CAAC,EAAE,EAAE;QACtC,OAAO,QAAQ,KAAK,MAAM,CAAC;KAC5B;IAED,IAAI,QAAQ,KAAK,0BAAkB,CAAC,GAAG,EAAE;QACvC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9D,OAAO,QAAQ,IAAI,MAAM,CAAC;SAC3B;QACD,OAAO,KAAK,CAAC;KACd;IAED,IAAI,QAAQ,KAAK,0BAAkB,CAAC,GAAG,EAAE;QACvC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9D,OAAO,QAAQ,IAAI,MAAM,CAAC;SAC3B;QACD,OAAO,KAAK,CAAC;KACd;IAED,IAAI,QAAQ,KAAK,0BAAkB,CAAC,QAAQ,EAAE;QAC5C,OAAO,QAAQ,CAAC,CAAC,CAAE,QAAoC,CAAC,QAAQ,CAAC,MAA+B,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;KAC3G;IAED,IAAI,QAAQ,KAAK,0BAAkB,CAAC,SAAS,EAAE;QAC7C,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAE,QAAoC,CAAC,QAAQ,CAAC,MAA+B,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;KAC5G;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AA9CD,kDA8CC"}
|