nestjs-prisma-querybuilder-interface 1.0.4 → 1.1.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.
Files changed (61) hide show
  1. package/README.md +135 -43
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/Querybuilder.js +7 -6
  6. package/dist/lib/Querybuilder.js.map +1 -1
  7. package/dist/lib/functions/FilterParse.d.ts +2 -1
  8. package/dist/lib/functions/FilterParse.js +70 -11
  9. package/dist/lib/functions/FilterParse.js.map +1 -1
  10. package/dist/lib/functions/FilterResolver.d.ts +1 -0
  11. package/dist/lib/functions/FilterResolver.js +19 -0
  12. package/dist/lib/functions/FilterResolver.js.map +1 -0
  13. package/dist/lib/functions/GetType.js +1 -1
  14. package/dist/lib/functions/GetType.js.map +1 -1
  15. package/dist/lib/functions/PopulateParse.d.ts +2 -0
  16. package/dist/lib/functions/PopulateParse.js +51 -0
  17. package/dist/lib/functions/PopulateParse.js.map +1 -0
  18. package/dist/lib/interfaces/Filter.d.ts +18 -2
  19. package/dist/lib/interfaces/Operator.d.ts +1 -1
  20. package/dist/lib/interfaces/Populate.d.ts +14 -4
  21. package/dist/lib/interfaces/Query.d.ts +4 -4
  22. package/dist/teste.js +15 -31
  23. package/dist/teste.js.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +3 -2
  26. package/dist/lib/FilterParse.d.ts +0 -2
  27. package/dist/lib/FilterParse.js +0 -18
  28. package/dist/lib/FilterParse.js.map +0 -1
  29. package/dist/lib/FiltersFields.d.ts +0 -13
  30. package/dist/lib/FiltersFields.js +0 -3
  31. package/dist/lib/FiltersFields.js.map +0 -1
  32. package/dist/lib/Populate.d.ts +0 -6
  33. package/dist/lib/Populate.js +0 -3
  34. package/dist/lib/Populate.js.map +0 -1
  35. package/dist/lib/Query.d.ts +0 -13
  36. package/dist/lib/Query.js +0 -3
  37. package/dist/lib/Query.js.map +0 -1
  38. package/dist/lib/SortFields.d.ts +0 -4
  39. package/dist/lib/SortFields.js +0 -3
  40. package/dist/lib/SortFields.js.map +0 -1
  41. package/dist/lib/functions/FilterObjectParse.d.ts +0 -3
  42. package/dist/lib/functions/FilterObjectParse.js +0 -37
  43. package/dist/lib/functions/FilterObjectParse.js.map +0 -1
  44. package/dist/lib/functions/ObjectParse.d.ts +0 -3
  45. package/dist/lib/functions/ObjectParse.js +0 -34
  46. package/dist/lib/functions/ObjectParse.js.map +0 -1
  47. package/dist/lib/functions/QueryParse.d.ts +0 -1
  48. package/dist/lib/functions/QueryParse.js +0 -20
  49. package/dist/lib/functions/QueryParse.js.map +0 -1
  50. package/dist/lib/interfaces/And.d.ts +0 -4
  51. package/dist/lib/interfaces/And.js +0 -3
  52. package/dist/lib/interfaces/And.js.map +0 -1
  53. package/dist/lib/interfaces/FiltersFields.d.ts +0 -4
  54. package/dist/lib/interfaces/FiltersFields.js +0 -3
  55. package/dist/lib/interfaces/FiltersFields.js.map +0 -1
  56. package/dist/lib/interfaces/Or.d.ts +0 -4
  57. package/dist/lib/interfaces/Or.js +0 -3
  58. package/dist/lib/interfaces/Or.js.map +0 -1
  59. package/dist/lib/interfaces/ParsedFilter.d.ts +0 -7
  60. package/dist/lib/interfaces/ParsedFilter.js +0 -3
  61. package/dist/lib/interfaces/ParsedFilter.js.map +0 -1
package/README.md CHANGED
@@ -10,7 +10,23 @@
10
10
 
11
11
  <br/>
12
12
 
13
- ### Documentação / Documentation
13
+ ### What's new
14
+
15
+ - **Filter in Populate**
16
+
17
+ You can filter inside populate
18
+
19
+ - **Insensitive Case**
20
+
21
+ now in the filter you can search with insensitive case
22
+
23
+ - **Verbose**
24
+
25
+ You can filter and populate with verbose method or non verbose
26
+
27
+ <hr>
28
+
29
+ ### Documentation
14
30
 
15
31
  - **How to install it?**
16
32
 
@@ -83,58 +99,36 @@
83
99
 
84
100
  - Usage
85
101
 
86
- | Name | Type | exemple |
87
- | -------- | ----------------- | ------------------------------------------------ |
88
- | select | string | select: 'name email', |
89
- | page | number | page: 2, |
90
- | limit | number | limit: 20, |
91
- | sort | SortFields | sort: {field: string, criteria: 'asc'}, |
92
- | populate | Populate [ ] | populate: [{path: 'car', select: 'model plate'}] |
93
- | filter | FiltersFields [ ] | filter: [{name: 'jonas'}, {value: { gte: 4 }}] |
102
+ | Name | Type | exemple |
103
+ | -------- | ---------- | ------------------------------------------------ |
104
+ | select | string | select: 'name email', |
105
+ | page | number | page: 2, |
106
+ | limit | number | limit: 20, |
107
+ | sort | SortFields | sort: {field: string, criteria: 'asc'}, |
108
+ | populate | Populate | populate: [{path: 'car', select: 'model plate'}] |
109
+ | filter | Filter | filter: [{name: 'jonas'}, {value: { gte: 4 }}] |
94
110
 
95
111
  <br/>
96
112
 
97
113
  - **Exported Interfaces**
98
114
 
115
+ ```tsx
116
+ import {
117
+ Query,
118
+ Populate,
119
+ Filter
120
+ } from 'nestjs-prisma-querybuilder-interface';
121
+ ```
122
+
99
123
  - **Query**
100
124
 
101
- is a full types
125
+ all types
102
126
 
103
127
  - **Populate**
128
+ - **Filter**
129
+ - **Operators**
104
130
 
105
- | Name | Type | exemple |
106
- | -------- | ------------ | ------------------------------------------- |
107
- | path | string | path: 'picture' |
108
- | select | string | select: 'url extension', |
109
- | populate | Populate [ ] | populate: [{path: 'post', select: 'title'}] |
110
-
111
- <br/>
112
-
113
- - **FilterFields**
114
-
115
- | Name | Type | exemple |
116
- | ---- | ---------- | ------------------------------------------------------------------- |
117
- | x | Filter | {name: { contains: 'Jonas' } } |
118
- | and | Filter [ ] | {and: [{name: { contains: 'Jonas' }, {active: true }}]} |
119
- | or | Filter [ ] | {or: [{post: { contains: 'hello' }, {post: { contains: 'world' }}]} |
120
-
121
- - **Filter**
122
-
123
- { key: value } with Operator 'equals'
124
-
125
- exemple: { postId: 147 }
126
-
127
- or
128
-
129
- { key: { operator: value } }
130
-
131
- exemple: { postId: { startsWith : 147 } }
132
-
133
- <br/>
134
-
135
- - **Operators**
136
-
137
- contains, endsWith, startsWith, equals, gt, gte, in, lt, lte ,not, notIn
131
+ contains, endsWith, startsWith, equals, gt, gte, in, lt, lte ,not, notIn
138
132
 
139
133
  <br/>
140
134
 
@@ -183,6 +177,104 @@
183
177
  });
184
178
  ```
185
179
 
180
+ - **Populate**
181
+
182
+ ```tsx
183
+ const populate: Populate = [
184
+ {
185
+ path: 'car',
186
+ select: 'model plate',
187
+ filter: [{path: 'name', value: 'ford', operator: 'contains'}],
188
+ populate: [
189
+ {
190
+ path: 'brand',
191
+ select: 'name',
192
+ }
193
+ ],
194
+ primaryKey: 'yourTablePrimaryKey' // default 'id'
195
+ },
196
+
197
+ // Or
198
+
199
+ {
200
+ car: 'model plate',
201
+ filter: [{name: {contains: 'ford'}],
202
+ populate: [{brand: 'name'}],
203
+ primaryKey: 'yourTablePrimaryKey' // default 'id'
204
+ },
205
+ ],
206
+ ```
207
+
208
+ - **Filter**
209
+
210
+ ```tsx
211
+ const filter: Filter = [
212
+ {
213
+ path: 'createdAt',
214
+ value: new Date(),
215
+ operator: 'lte'
216
+ },
217
+ {
218
+ or: [
219
+ {
220
+ path: 'role',
221
+ value: 'admin',
222
+ operator: 'equals'
223
+ },
224
+ {
225
+ path: 'role',
226
+ value: 'system',
227
+ operator: 'equals'
228
+ }
229
+ ]
230
+ },
231
+ {
232
+ and: [
233
+ {
234
+ path: 'name',
235
+ value: 'Ricky',
236
+ operator: 'equals',
237
+ insensitive: true
238
+ },
239
+ {
240
+ path: 'lastName',
241
+ value: 'Morty',
242
+ operator: 'contains',
243
+ insensitive: true
244
+ }
245
+ ]
246
+ }
247
+ ];
248
+
249
+ // Or
250
+
251
+ const filter: Filter = [
252
+ {
253
+ createdAt: { lte: new Date() }
254
+ },
255
+ {
256
+ or: [
257
+ {
258
+ role: 'admin'
259
+ },
260
+ {
261
+ role: 'system'
262
+ }
263
+ ]
264
+ },
265
+ {
266
+ and: [
267
+ {
268
+ name: { equals: 'Ricky', insensitive: true }
269
+ },
270
+ {
271
+ lastName: { contains: 'Morty', insensitive: true }
272
+ }
273
+ ]
274
+ }
275
+ ];
276
+ ```
277
+
186
278
  ### END
187
279
 
188
280
  - Nestjs/Prisma Querybuilder Interface is ISC licensed.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './lib/interfaces/FiltersFields';
1
+ export * from './lib/interfaces/Filter';
2
2
  export * from './lib/interfaces/Query';
3
3
  export * from './lib/interfaces/Populate';
4
4
  export * from './lib/Querybuilder';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./lib/interfaces/FiltersFields"), exports);
17
+ __exportStar(require("./lib/interfaces/Filter"), exports);
18
18
  __exportStar(require("./lib/interfaces/Query"), exports);
19
19
  __exportStar(require("./lib/interfaces/Populate"), exports);
20
20
  __exportStar(require("./lib/Querybuilder"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C;AAC/C,yDAAuC;AACvC,4DAA0C;AAC1C,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,yDAAuC;AACvC,4DAA0C;AAC1C,qDAAmC"}
@@ -2,15 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.QueryString = void 0;
4
4
  const qs_1 = require("qs");
5
- const QueryParse_1 = require("./functions/QueryParse");
5
+ const FilterResolver_1 = require("./functions/FilterResolver");
6
+ const PopulateParse_1 = require("./functions/PopulateParse");
6
7
  function QueryString(query) {
7
- if (query === null || query === void 0 ? void 0 : query.filter) {
8
- query.filter = (0, QueryParse_1.QueryParse)(query.filter);
9
- return (0, qs_1.stringify)(query);
8
+ if (query?.filter) {
9
+ query.filter = (0, FilterResolver_1.FilterResolver)(query.filter);
10
10
  }
11
- else {
12
- return (0, qs_1.stringify)(query);
11
+ if (query?.populate) {
12
+ query.populate = (0, PopulateParse_1.PopulateParse)(query.populate);
13
13
  }
14
+ return (0, qs_1.stringify)(query);
14
15
  }
15
16
  exports.QueryString = QueryString;
16
17
  //# sourceMappingURL=Querybuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Querybuilder.js","sourceRoot":"","sources":["../../lib/Querybuilder.ts"],"names":[],"mappings":";;;AAAA,2BAA+B;AAC/B,uDAAoD;AAGpD,SAAgB,WAAW,CAAC,KAAY;IACtC,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,EAAE;QACjB,KAAK,CAAC,MAAM,GAAG,IAAA,uBAAU,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO,IAAA,cAAS,EAAC,KAAK,CAAC,CAAC;KACzB;SAAM;QACL,OAAO,IAAA,cAAS,EAAC,KAAK,CAAC,CAAC;KACzB;AACH,CAAC;AAPD,kCAOC"}
1
+ {"version":3,"file":"Querybuilder.js","sourceRoot":"","sources":["../../lib/Querybuilder.ts"],"names":[],"mappings":";;;AAAA,2BAA+B;AAC/B,+DAA4D;AAC5D,6DAA0D;AAG1D,SAAgB,WAAW,CAAC,KAAY;IACtC,IAAI,KAAK,EAAE,MAAM,EAAE;QACjB,KAAK,CAAC,MAAM,GAAG,IAAA,+BAAc,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC7C;IACD,IAAI,KAAK,EAAE,QAAQ,EAAE;QACnB,KAAK,CAAC,QAAQ,GAAG,IAAA,6BAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;KAChD;IACD,OAAO,IAAA,cAAS,EAAC,KAAK,CAAC,CAAC;AAC1B,CAAC;AARD,kCAQC"}
@@ -1 +1,2 @@
1
- export declare const FilterParse: (filter: any, filterGroup: 'and' | 'or') => any;
1
+ import { Filter } from '../interfaces/Filter';
2
+ export declare const FilterParse: (filters: any, filterGroup?: string) => Filter;
@@ -1,20 +1,79 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FilterParse = void 0;
4
- const ObjectParse_1 = require("./ObjectParse");
5
- const FilterParse = (filter, filterGroup) => {
6
- if (filter === null || filter === void 0 ? void 0 : filter.length) {
7
- return filter.map(filter => {
8
- if (filter === null || filter === void 0 ? void 0 : filter.and) {
9
- return (0, exports.FilterParse)(filter.and, 'and');
4
+ const GetType_1 = require("./GetType");
5
+ const FilterParse = (filters, filterGroup) => {
6
+ return filters.map(filter => {
7
+ let parsedFilter = {};
8
+ Object.keys(filter)?.forEach(key => {
9
+ if (key === 'path') {
10
+ parsedFilter = {
11
+ ...parsedFilter,
12
+ path: filter?.path
13
+ };
10
14
  }
11
- if (filter === null || filter === void 0 ? void 0 : filter.or) {
12
- return (0, exports.FilterParse)(filter.or, 'or');
15
+ else if (key === 'value') {
16
+ parsedFilter = {
17
+ ...parsedFilter,
18
+ value: filter?.value
19
+ };
20
+ }
21
+ else if (key === 'insensitive') {
22
+ parsedFilter = {
23
+ ...parsedFilter,
24
+ insensitive: filter?.insensitive
25
+ };
26
+ }
27
+ else if (key === 'operator') {
28
+ parsedFilter = {
29
+ ...parsedFilter,
30
+ operator: filter?.operator
31
+ };
32
+ }
33
+ else {
34
+ if ((0, GetType_1.getType)(filter[key]) === 'object') {
35
+ if (filter[key]?.insensitive) {
36
+ parsedFilter = {
37
+ ...parsedFilter,
38
+ insensitive: filter[key]?.insensitive
39
+ };
40
+ delete filter[key].insensitive;
41
+ }
42
+ parsedFilter = {
43
+ ...parsedFilter,
44
+ operator: Object.keys(filter[key])[0],
45
+ value: Object.values(filter[key])[0],
46
+ path: key
47
+ };
48
+ }
49
+ else {
50
+ parsedFilter = {
51
+ ...parsedFilter,
52
+ operator: 'equals',
53
+ path: key,
54
+ value: filter[key]
55
+ };
56
+ }
57
+ }
58
+ parsedFilter = {
59
+ ...parsedFilter,
60
+ type: (0, GetType_1.getType)(parsedFilter['value'])
61
+ };
62
+ if (parsedFilter['type'] === 'date') {
63
+ parsedFilter = {
64
+ ...parsedFilter,
65
+ value: new Date(parsedFilter['value']).toISOString()
66
+ };
67
+ }
68
+ if (filterGroup) {
69
+ parsedFilter = {
70
+ ...parsedFilter,
71
+ filterGroup
72
+ };
13
73
  }
14
- const parsedObject = (0, ObjectParse_1.ObjectParse)(filter)[0];
15
- return Object.assign(Object.assign({}, parsedObject), { filterGroup });
16
74
  });
17
- }
75
+ return parsedFilter;
76
+ });
18
77
  };
19
78
  exports.FilterParse = FilterParse;
20
79
  //# sourceMappingURL=FilterParse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterParse.js","sourceRoot":"","sources":["../../../lib/functions/FilterParse.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAErC,MAAM,WAAW,GAAG,CAAC,MAAW,EAAE,WAAyB,EAAE,EAAE;IACpE,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE;QAClB,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACzB,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,EAAE;gBACf,OAAO,IAAA,mBAAW,EAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACvC;YACD,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE,EAAE;gBACd,OAAO,IAAA,mBAAW,EAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;aACrC;YACD,MAAM,YAAY,GAAG,IAAA,yBAAW,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5C,uCAAY,YAAY,KAAE,WAAW,IAAG;QAC1C,CAAC,CAAC,CAAC;KACJ;AACH,CAAC,CAAC;AAbW,QAAA,WAAW,eAatB"}
1
+ {"version":3,"file":"FilterParse.js","sourceRoot":"","sources":["../../../lib/functions/FilterParse.ts"],"names":[],"mappings":";;;AACA,uCAAoC;AAE7B,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,WAAoB,EAAU,EAAE;IACnE,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC1B,IAAI,YAAY,GAAiB,EAAE,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;YACjC,IAAI,GAAG,KAAK,MAAM,EAAE;gBAClB,YAAY,GAAG;oBACb,GAAG,YAAY;oBACf,IAAI,EAAE,MAAM,EAAE,IAAI;iBACnB,CAAC;aACH;iBAAM,IAAI,GAAG,KAAK,OAAO,EAAE;gBAC1B,YAAY,GAAG;oBACb,GAAG,YAAY;oBACf,KAAK,EAAE,MAAM,EAAE,KAAK;iBACrB,CAAC;aACH;iBAAM,IAAI,GAAG,KAAK,aAAa,EAAE;gBAChC,YAAY,GAAG;oBACb,GAAG,YAAY;oBACf,WAAW,EAAE,MAAM,EAAE,WAAW;iBACjC,CAAC;aACH;iBAAM,IAAI,GAAG,KAAK,UAAU,EAAE;gBAC7B,YAAY,GAAG;oBACb,GAAG,YAAY;oBACf,QAAQ,EAAE,MAAM,EAAE,QAAQ;iBAC3B,CAAC;aACH;iBAAM;gBACL,IAAI,IAAA,iBAAO,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,QAAQ,EAAE;oBACrC,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE;wBAC5B,YAAY,GAAG;4BACb,GAAG,YAAY;4BACf,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,WAAW;yBACtC,CAAC;wBACF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC;qBAChC;oBACD,YAAY,GAAG;wBACb,GAAG,YAAY;wBACf,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;wBACrC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;wBACpC,IAAI,EAAE,GAAG;qBACV,CAAC;iBACH;qBAAM;oBACL,YAAY,GAAG;wBACb,GAAG,YAAY;wBACf,QAAQ,EAAE,QAAQ;wBAClB,IAAI,EAAE,GAAG;wBACT,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC;qBACnB,CAAC;iBACH;aACF;YAED,YAAY,GAAG;gBACb,GAAG,YAAY;gBACf,IAAI,EAAE,IAAA,iBAAO,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC;aACrC,CAAC;YAEF,IAAI,YAAY,CAAC,MAAM,CAAC,KAAK,MAAM,EAAE;gBACnC,YAAY,GAAG;oBACb,GAAG,YAAY;oBACf,KAAK,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE;iBACrD,CAAC;aACH;YAED,IAAI,WAAW,EAAE;gBACf,YAAY,GAAG;oBACb,GAAG,YAAY;oBACf,WAAW;iBACZ,CAAC;aACH;QACH,CAAC,CAAC,CAAC;QACH,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAtEW,QAAA,WAAW,eAsEtB"}
@@ -0,0 +1 @@
1
+ export declare const FilterResolver: (filters: any) => any[];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilterResolver = void 0;
4
+ const FilterParse_1 = require("./FilterParse");
5
+ const FilterResolver = filters => {
6
+ const FilterResolved = [];
7
+ filters.forEach(filter => {
8
+ if (filter?.and) {
9
+ return FilterResolved.push(...(0, FilterParse_1.FilterParse)(filter.and, 'and'));
10
+ }
11
+ if (filter?.or) {
12
+ return FilterResolved.push(...(0, FilterParse_1.FilterParse)(filter.or, 'or'));
13
+ }
14
+ return FilterResolved.push(...(0, FilterParse_1.FilterParse)([filter]));
15
+ });
16
+ return FilterResolved;
17
+ };
18
+ exports.FilterResolver = FilterResolver;
19
+ //# sourceMappingURL=FilterResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterResolver.js","sourceRoot":"","sources":["../../../lib/functions/FilterResolver.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAErC,MAAM,cAAc,GAAG,OAAO,CAAC,EAAE;IACtC,MAAM,cAAc,GAAG,EAAE,CAAC;IAC1B,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACvB,IAAI,MAAM,EAAE,GAAG,EAAE;YACf,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAW,EAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;SAC/D;QACD,IAAI,MAAM,EAAE,EAAE,EAAE;YACd,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAW,EAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;SAC7D;QAED,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAW,EAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AAbW,QAAA,cAAc,kBAazB"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getType = void 0;
4
- const getType = (value) => {
4
+ const getType = value => {
5
5
  switch (typeof value) {
6
6
  case 'string':
7
7
  return 'string';
@@ -1 +1 @@
1
- {"version":3,"file":"GetType.js","sourceRoot":"","sources":["../../../lib/functions/GetType.ts"],"names":[],"mappings":";;;AAAO,MAAM,OAAO,GAAG,CAAC,KAAU,EAAE,EAAE;IACpC,QAAQ,OAAO,KAAK,EAAE;QACpB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,OAAO,CAAC,CAAC;YACP,IAAI,KAAK,YAAY,IAAI,EAAE;gBACzB,OAAO,MAAM,CAAC;aACf;YACD,OAAO,QAAQ,CAAC;SACjB;KACF;AACH,CAAC,CAAC;AAfW,QAAA,OAAO,WAelB"}
1
+ {"version":3,"file":"GetType.js","sourceRoot":"","sources":["../../../lib/functions/GetType.ts"],"names":[],"mappings":";;;AAAO,MAAM,OAAO,GAAG,KAAK,CAAC,EAAE;IAC7B,QAAQ,OAAO,KAAK,EAAE;QACpB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QACnB,OAAO,CAAC,CAAC;YACP,IAAI,KAAK,YAAY,IAAI,EAAE;gBACzB,OAAO,MAAM,CAAC;aACf;YACD,OAAO,QAAQ,CAAC;SACjB;KACF;AACH,CAAC,CAAC;AAfW,QAAA,OAAO,WAelB"}
@@ -0,0 +1,2 @@
1
+ import { Populate } from '../interfaces/Populate';
2
+ export declare const PopulateParse: (populates: any) => Populate;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PopulateParse = void 0;
4
+ const FilterResolver_1 = require("./FilterResolver");
5
+ const PopulateParse = (populates) => {
6
+ return populates.map(populate => {
7
+ let parsedPopulate = {};
8
+ Object.keys(populate)?.forEach(key => {
9
+ if (key === 'filter') {
10
+ parsedPopulate = {
11
+ ...parsedPopulate,
12
+ filter: (0, FilterResolver_1.FilterResolver)(populate?.filter)
13
+ };
14
+ }
15
+ else if (key === 'populate') {
16
+ parsedPopulate = {
17
+ ...parsedPopulate,
18
+ populate: (0, exports.PopulateParse)(populate?.populate)
19
+ };
20
+ }
21
+ else if (key === 'primaryKey') {
22
+ parsedPopulate = {
23
+ ...parsedPopulate,
24
+ primaryKey: populate?.primaryKey
25
+ };
26
+ }
27
+ else if (key === 'path') {
28
+ parsedPopulate = {
29
+ ...parsedPopulate,
30
+ path: populate?.path
31
+ };
32
+ }
33
+ else if (key === 'select') {
34
+ parsedPopulate = {
35
+ ...parsedPopulate,
36
+ select: populate?.select
37
+ };
38
+ }
39
+ else {
40
+ parsedPopulate = {
41
+ ...parsedPopulate,
42
+ path: key,
43
+ select: populate[key]
44
+ };
45
+ }
46
+ });
47
+ return parsedPopulate;
48
+ });
49
+ };
50
+ exports.PopulateParse = PopulateParse;
51
+ //# sourceMappingURL=PopulateParse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PopulateParse.js","sourceRoot":"","sources":["../../../lib/functions/PopulateParse.ts"],"names":[],"mappings":";;;AAEA,qDAAkD;AAE3C,MAAM,aAAa,GAAG,CAAC,SAAS,EAAY,EAAE;IACnD,OAAO,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;QAC9B,IAAI,cAAc,GAAG,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;YACnC,IAAI,GAAG,KAAK,QAAQ,EAAE;gBACpB,cAAc,GAAG;oBACf,GAAG,cAAc;oBACjB,MAAM,EAAE,IAAA,+BAAc,EAAC,QAAQ,EAAE,MAAM,CAAC;iBACzC,CAAC;aACH;iBAAM,IAAI,GAAG,KAAK,UAAU,EAAE;gBAC7B,cAAc,GAAG;oBACf,GAAG,cAAc;oBACjB,QAAQ,EAAE,IAAA,qBAAa,EAAC,QAAQ,EAAE,QAAQ,CAAC;iBAC5C,CAAC;aACH;iBAAM,IAAI,GAAG,KAAK,YAAY,EAAE;gBAC/B,cAAc,GAAG;oBACf,GAAG,cAAc;oBACjB,UAAU,EAAE,QAAQ,EAAE,UAAU;iBACjC,CAAC;aACH;iBAAM,IAAI,GAAG,KAAK,MAAM,EAAE;gBACzB,cAAc,GAAG;oBACf,GAAG,cAAc;oBACjB,IAAI,EAAE,QAAQ,EAAE,IAAI;iBACrB,CAAC;aACH;iBAAM,IAAI,GAAG,KAAK,QAAQ,EAAE;gBAC3B,cAAc,GAAG;oBACf,GAAG,cAAc;oBACjB,MAAM,EAAE,QAAQ,EAAE,MAAM;iBACzB,CAAC;aACH;iBAAM;gBACL,cAAc,GAAG;oBACf,GAAG,cAAc;oBACjB,IAAI,EAAE,GAAG;oBACT,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC;iBACtB,CAAC;aACH;QACH,CAAC,CAAC,CAAC;QACH,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAvCW,QAAA,aAAa,iBAuCxB"}
@@ -1,8 +1,24 @@
1
1
  import { Operator } from './Operator';
2
2
  declare type FilterObject = {
3
+ [x in string]: any;
4
+ };
5
+ declare type OperatorObject = {
3
6
  [x in Operator]: string | Date | boolean | number;
4
7
  };
5
- export declare type Filter = {
6
- [x: string]: string | Date | boolean | number | FilterObject | object;
8
+ export declare type FiltersField = FilterObject | OperatorObject | {
9
+ path: string;
10
+ } | {
11
+ value: string;
12
+ } | {
13
+ insensitive: boolean;
14
+ } | {
15
+ operator: Operator;
7
16
  };
17
+ export declare type Filter = Array<FiltersField | {
18
+ or: FiltersField[];
19
+ } | {
20
+ and: FiltersField[];
21
+ } | {
22
+ not: FiltersField[];
23
+ }>;
8
24
  export {};
@@ -1 +1 @@
1
- export declare type Operator = 'contains' | 'endsWith' | 'startsWith' | 'equals' | 'gt' | 'gte' | 'in' | 'lt' | 'lte' | 'not' | 'notIn';
1
+ export declare type Operator = 'contains' | 'endsWith' | 'startsWith' | 'equals' | 'gt' | 'gte' | 'in' | 'lt' | 'lte' | 'not' | 'notIn' | 'hasEvery' | 'hasSome' | 'has' | 'isEmpty';
@@ -1,6 +1,16 @@
1
- export interface Populate {
1
+ import { Filter } from './Filter';
2
+ declare type PopulateObject = {
3
+ [x: string]: string;
4
+ };
5
+ export declare type Populate = Array<PopulateObject | {
6
+ filter: Filter;
7
+ } | {
8
+ populate: Populate;
9
+ } | {
10
+ primaryKey: string;
11
+ } | {
2
12
  path: string;
13
+ } | {
3
14
  select: string;
4
- primaryKey?: string;
5
- populate?: Populate[];
6
- }
15
+ }>;
16
+ export {};
@@ -1,11 +1,11 @@
1
- import { FiltersFields } from './FiltersFields';
1
+ import { Filter } from './Filter';
2
2
  import { Populate } from './Populate';
3
3
  import { SortFields } from './SortFields';
4
4
  export interface Query {
5
- select: string;
5
+ select?: string;
6
6
  page?: number;
7
7
  limit?: number;
8
8
  sort?: SortFields;
9
- populate?: Populate[];
10
- filter?: FiltersFields;
9
+ populate?: Populate;
10
+ filter?: Filter;
11
11
  }
package/dist/teste.js CHANGED
@@ -1,41 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const Querybuilder_1 = require("./lib/Querybuilder");
4
- console.log((0, Querybuilder_1.QueryString)({
5
- select: 'name role createdAt',
3
+ const QueryBuilder_1 = require("./lib/QueryBuilder");
4
+ console.log((0, QueryBuilder_1.QueryString)({
5
+ select: 'name email createdAt',
6
6
  filter: [
7
- {
8
- coxinha: new Date()
9
- },
7
+ { path: 'name', value: 'wilian teste', operator: 'equals' },
8
+ { createdAt: { lte: new Date() } },
10
9
  {
11
10
  or: [
12
- {
13
- kibe: 'frito'
14
- },
15
- {
16
- risole: 2
17
- }
18
- ]
19
- },
20
- {
21
- and: [
22
- {
23
- kibe: 'frito'
24
- },
25
- {
26
- risole: 2
27
- }
11
+ { email: { contains: 'casca' } },
12
+ { email: { contains: 'WIL', insensitive: true } }
28
13
  ]
29
- },
14
+ }
15
+ ],
16
+ populate: [
30
17
  {
31
- or: [
32
- {
33
- kibe: 'frito'
34
- },
35
- {
36
- risole: 2
37
- }
38
- ]
18
+ path: 'residence',
19
+ select: 'identification createdAt',
20
+ primaryKey: 'id',
21
+ filter: [{ createdAt: { lte: new Date() } }],
22
+ populate: [{ createdBy: 'name email' }]
39
23
  }
40
24
  ]
41
25
  }));
package/dist/teste.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"teste.js","sourceRoot":"","sources":["../teste.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AACjD,OAAO,CAAC,GAAG,CACT,IAAA,0BAAW,EAAC;IACV,MAAM,EAAE,qBAAqB;IAC7B,MAAM,EAAE;QACN;YACE,OAAO,EAAE,IAAI,IAAI,EAAE;SACpB;QACD;YACE,EAAE,EAAE;gBACF;oBACE,IAAI,EAAE,OAAO;iBACd;gBACD;oBACE,MAAM,EAAE,CAAC;iBACV;aACF;SACF;QACD;YACE,GAAG,EAAE;gBACH;oBACE,IAAI,EAAE,OAAO;iBACd;gBACD;oBACE,MAAM,EAAE,CAAC;iBACV;aACF;SACF;QACD;YACE,EAAE,EAAE;gBACF;oBACE,IAAI,EAAE,OAAO;iBACd;gBACD;oBACE,MAAM,EAAE,CAAC;iBACV;aACF;SACF;KACF;CACF,CAAC,CACH,CAAC"}
1
+ {"version":3,"file":"teste.js","sourceRoot":"","sources":["../teste.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AAEjD,OAAO,CAAC,GAAG,CACT,IAAA,0BAAW,EAAC;IACV,MAAM,EAAE,sBAAsB;IAC9B,MAAM,EAAE;QACN,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE;QAC3D,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE;QAClC;YACE,EAAE,EAAE;gBACF,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;gBAChC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;aAClD;SACF;KACF;IACD,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,0BAA0B;YAClC,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC;YAC5C,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;SACxC;KACF;CACF,CAAC,CACH,CAAC"}
@@ -1 +1 @@
1
- {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../node_modules/typescript/lib/lib.scripthost.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2017.full.d.ts","../lib/interfaces/operator.ts","../lib/interfaces/filter.ts","../lib/interfaces/and.ts","../lib/interfaces/or.ts","../lib/interfaces/filtersfields.ts","../lib/interfaces/populate.ts","../lib/interfaces/sortfields.ts","../lib/interfaces/query.ts","../node_modules/@types/qs/index.d.ts","../lib/interfaces/parsedfilter.ts","../lib/functions/gettype.ts","../lib/functions/objectparse.ts","../lib/functions/filterparse.ts","../lib/functions/queryparse.ts","../lib/querybuilder.ts","../index.ts"],"fileInfos":[{"version":"3ac1b83264055b28c0165688fda6dfcc39001e9e7828f649299101c23ad0a0c3","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9",{"version":"72704b10d97777e15f1a581b73f88273037ef752d2e50b72287bd0a90af64fe6","affectsGlobalScope":true},{"version":"dbb73d4d99be496175cb432c74c2615f78c76f4272f1d83cba11ee0ed6dbddf0","affectsGlobalScope":true},{"version":"7fac8cb5fc820bc2a59ae11ef1c5b38d3832c6d0dfaec5acdb5569137d09a481","affectsGlobalScope":true},{"version":"097a57355ded99c68e6df1b738990448e0bf170e606707df5a7c0481ff2427cd","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},"d2f31f19e1ba6ed59be9259d660a239d9a3fcbbc8e038c6b2009bde34b175fed",{"version":"9ec08b7c87d843e26d8c371d8234955c747f998638760946c5eeb8296b34c783","signature":"e3f4eab8905e386fac5e7afd43189c3b0b7950920e3bc0ee8f15c51db5dbba5b"},{"version":"8494163d9e4b5e7575d1a2603ecd590be8021585d3e994288cd7149f5d25c0fa","signature":"a1f62fb6d95b3175b6f8ce236a61f7601b11a56a0f3fa8ee70249d50cd01d273"},{"version":"2eb6814ef4c565b6481f36e339b7e4e13810b6fd2d10ffc0a129de36fb89508c","signature":"1f8c2bbe2bd680011db9530b663fdbd66e0a60dcf827c921d96550fff4ec8ec6"},{"version":"4f4fe40dd8faf10255a46258dab4895c569e9f6b57fe284d9a1cafc204d0ac87","signature":"a5c9d23f969863fa1a3228daca81c483dfefb3fcf1c6b0803f95c64afd38afa3"},{"version":"ea9f5a5982b06f89006fab682eec49ca138b91b86524675b5729fe4519a264ed","signature":"148735f962d020cd65ec5a2af43c3281047862196f7e785d2cd93ab6a9ce54f2"},{"version":"359d451021b822a6d98933b80f78ba24b544ec9cdd67547634627a57db290dd4","signature":"4e981cc658fe6d48a8c5cdecce9cbe34693bfb2a6d78584d764a5ec7e920fb97"},{"version":"1687d1bb2a596cfbe84ca0bedc14a4b099d7488fe7cf4e0cd84ec55dab5697d4","signature":"10c723d50b6752fd0cec5815a7ebe4e4e5f7aa58a308748c3233bc64ed08adb3"},{"version":"37ecd7faa1beb0254eae822d50d4a909794b575b330fedd004a93794a4fc3125","signature":"4a5e12455adb0f3747abfc138d5e23524df76264f0ebb86eea5db71cc7244180"},"ba601641fac98c229ccd4a303f747de376d761babb33229bb7153bed9356c9cc",{"version":"d5c8e6dbbd3fb2e5e8e6a6badb81d5738d4b39d418f7e810836a92bee016008b","signature":"c0810a8d9c5c4b8518e4220f8a8c8c6c783d31800506afe66eec0fb5fdc6425e"},{"version":"7d8ffafd00e33781b36628cff24159f8a6ba665211f555569f5f3da041c15adc","signature":"b05f509d8cc6243d6b2a95b10bc3fbbc255abe7a79ada4f82d6d3350016bc5ed"},{"version":"36af49645e8ad675fadcc7b8c8c50f826b3f030f3a327161473175a778a8ac4a","signature":"ec2d190a8989929df0979c146e1d0fb93e9cd1f758edc78feb25f090f346072b"},{"version":"78c03ce3990b4e75899906f8fb0d7504ba876cc1d5c7e5416a31eb2265f49036","signature":"ab3805210479b8982ca658fbed9d8e5f24504f41c124f0940c689ead0f305e1b"},{"version":"d4e581d329f5ec0ab948a61bb2fa80336ffd7ed77225426b3537b4e5336e2bf6","signature":"7344382c89ea2f73cb953233c80ac78879be293802b6691e54de8fba83a13f71"},{"version":"a3a6667ebad50fb7680f79b0505ab714a7a51a6e3af222e2e4d14194bb15bb41","signature":"f1b4d7e012d8c6651d25ee44cfe1e3b82ce63c8ce484574fad79a79f73c80f87"},"1d2ec3dbf453347e42046fe00eedf5739cec0413c74d7109225575b9ec210d94"],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"experimentalDecorators":true,"module":1,"outDir":"./","removeComments":true,"sourceMap":true,"target":4},"fileIdsList":[[29,30,32,39],[36],[29,34,35,37],[36,37],[26],[25],[26,27,28],[29,30,31],[32,33,38],[29,34],[32]],"referencedMap":[[40,1],[37,2],[36,3],[38,4],[27,5],[26,6],[29,7],[28,5],[34,5],[32,8],[39,9]],"exportedModulesMap":[[40,1],[36,10],[27,5],[26,6],[29,7],[28,5],[34,5],[32,8],[39,11]],"semanticDiagnosticsPerFile":[40,37,35,36,38,27,26,29,25,28,34,30,32,31,39,33,5,6,10,9,2,11,12,13,14,15,16,17,18,3,4,24,22,19,20,21,23,1,8,7]},"version":"4.6.4"}
1
+ {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../node_modules/typescript/lib/lib.scripthost.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/typescript/lib/lib.es2021.full.d.ts","../lib/interfaces/operator.ts","../lib/interfaces/filter.ts","../lib/interfaces/populate.ts","../lib/interfaces/sortfields.ts","../lib/interfaces/query.ts","../node_modules/@types/qs/index.d.ts","../lib/functions/gettype.ts","../lib/functions/filterparse.ts","../lib/functions/filterresolver.ts","../lib/functions/populateparse.ts","../lib/querybuilder.ts","../index.ts","../teste.ts"],"fileInfos":[{"version":"3ac1b83264055b28c0165688fda6dfcc39001e9e7828f649299101c23ad0a0c3","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f",{"version":"72704b10d97777e15f1a581b73f88273037ef752d2e50b72287bd0a90af64fe6","affectsGlobalScope":true},{"version":"dbb73d4d99be496175cb432c74c2615f78c76f4272f1d83cba11ee0ed6dbddf0","affectsGlobalScope":true},{"version":"7fac8cb5fc820bc2a59ae11ef1c5b38d3832c6d0dfaec5acdb5569137d09a481","affectsGlobalScope":true},{"version":"097a57355ded99c68e6df1b738990448e0bf170e606707df5a7c0481ff2427cd","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"5075b36ab861c8c0c45377cb8c96270d7c65f0eeaf105d53fac6850da61f1027","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"e8c9f4e445a489991ca1a4232667de3ac36b07ba75ea335971fbeacf2d26fe67","affectsGlobalScope":true},"0ce99fa68940b918945c445a958e2568a5b7593f7e3a0eeef9f0f79d45651b91","454b0392263f594d9cd33159411df01beb09dda6d46d7d09aee506997fed134b","6fca10a5cb88a76c2603f0fc0ea3e6836ca2ccb89af0958bdd4ce48504217138","327fdcfc2fd5413bc62218325bd01c42702432fded09e3fe80f562fe2062a097","1687d1bb2a596cfbe84ca0bedc14a4b099d7488fe7cf4e0cd84ec55dab5697d4","a366eb3f5532eade55402eec82def264725b6a7be39b8114f083e183bcf21c10","ba601641fac98c229ccd4a303f747de376d761babb33229bb7153bed9356c9cc","5413e2cb35d9569bdb7bc1de3818c08ba7b0e290918c87296309ec0463b26418",{"version":"527cdf5f97076fcdb38e14d2f2e5eaa76f2c76a28df584858bd699b91d9d3ad3","signature":"7b9504b451529d09d7db528263bd0f2ce06acea78eb1f80f07f90a222a063caf"},{"version":"453992185af1f216ca04012ee39d356e3168ac02ffa015d258350c62db49ec13","signature":"bee5d82699b0989b4d85e69152a9ccb0f7d10cdee7fb4eba691dc4d1cc7dd756"},{"version":"3934b0079af06f8deb2b5ffc42ae6d57d0dab632340fad199e67cd24ae5b5d8b","signature":"418a1c232e1387107647efbc7e82f43d1c7556b8dc23df2fe1fd98fc7fd5e709"},{"version":"43197211b4af5cb3e20d8abc1b287efd4a08712e5738b2469ab4a9a26409e993","signature":"f1b4d7e012d8c6651d25ee44cfe1e3b82ce63c8ce484574fad79a79f73c80f87"},"aff4f2a54ae4d18ecbfe95fc8d0c0d5ddfffa6a0c96c4212231bd3660f4949ab",{"version":"7af17f917e083ff5c21428e01266b5f53dacd15a849790b401b199c732d30c04","signature":"f761c91419d0a89422a0004ef1a92929dd4d2d5e5c16758654d8b0467d1998c6"}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"experimentalDecorators":true,"module":1,"outDir":"./","removeComments":true,"sourceMap":true,"target":8},"fileIdsList":[[49,50,52,58],[49,54],[55],[50,55,56],[48],[49],[49,50,51],[52,53,56,57],[58],[50],[52]],"referencedMap":[[59,1],[55,2],[56,3],[57,4],[49,5],[50,6],[52,7],[58,8],[60,9]],"exportedModulesMap":[[59,1],[55,6],[57,10],[49,5],[50,6],[52,7],[58,11]],"semanticDiagnosticsPerFile":[59,55,56,54,57,49,48,50,52,51,58,53,9,10,14,13,2,15,16,17,18,19,20,21,22,3,4,26,23,24,25,27,28,29,5,30,31,32,33,6,34,35,36,37,7,42,38,39,40,41,8,47,46,43,44,45,1,12,11,60]},"version":"4.6.4"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-prisma-querybuilder-interface",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "Frontend interface to nestjs-prisma-querybuilder",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -22,7 +22,8 @@
22
22
  "scripts": {
23
23
  "test": "echo \"Error: no test specified\" && exit 1",
24
24
  "build": "tsc",
25
- "prepare": "npm run build"
25
+ "prepare": "npm run build",
26
+ "teste": "npm run build && node ./dist/teste.js"
26
27
  },
27
28
  "repository": {
28
29
  "type": "git",
@@ -1,2 +0,0 @@
1
- import { FiltersFields } from './FiltersFields';
2
- export declare const FilterParse: (filter: FiltersFields | any, filterGroup: 'and' | 'or') => any;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FilterParse = void 0;
4
- const FilterParse = (filter, filterGroup) => {
5
- if (filter?.length) {
6
- return filter.map(filter => {
7
- if (filter?.and) {
8
- return (0, exports.FilterParse)(filter.and, 'and');
9
- }
10
- if (filter?.or) {
11
- return (0, exports.FilterParse)(filter.or, 'or');
12
- }
13
- return { ...filter, filterGroup };
14
- });
15
- }
16
- };
17
- exports.FilterParse = FilterParse;
18
- //# sourceMappingURL=FilterParse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilterParse.js","sourceRoot":"","sources":["../../lib/FilterParse.ts"],"names":[],"mappings":";;;AAEO,MAAM,WAAW,GAAG,CACzB,MAA2B,EAC3B,WAAyB,EACzB,EAAE;IACF,IAAI,MAAM,EAAE,MAAM,EAAE;QAClB,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACzB,IAAI,MAAM,EAAE,GAAG,EAAE;gBACf,OAAO,IAAA,mBAAW,EAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aACvC;YACD,IAAI,MAAM,EAAE,EAAE,EAAE;gBACd,OAAO,IAAA,mBAAW,EAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;aACrC;YACD,OAAO,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,CAAC;QACpC,CAAC,CAAC,CAAC;KACJ;AACH,CAAC,CAAC;AAfW,QAAA,WAAW,eAetB"}
@@ -1,13 +0,0 @@
1
- declare type Filter = {
2
- path: string;
3
- value: string;
4
- operator?: 'contains' | 'endsWith' | 'startsWith' | 'equals' | 'gt' | 'gte' | 'in' | 'lt' | 'lte' | 'not' | 'notIn';
5
- };
6
- declare type Or = {
7
- or: Filter[];
8
- };
9
- declare type And = {
10
- and: Filter[];
11
- };
12
- export declare type FiltersFields = Array<Filter | Or | And>;
13
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=FiltersFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FiltersFields.js","sourceRoot":"","sources":["../../lib/FiltersFields.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- export interface Populate {
2
- path: string;
3
- select: string;
4
- primaryKey?: string;
5
- populate?: Populate[];
6
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=Populate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Populate.js","sourceRoot":"","sources":["../../lib/Populate.ts"],"names":[],"mappings":""}
@@ -1,13 +0,0 @@
1
- import { FiltersFields } from './FiltersFields';
2
- import { Populate } from './Populate';
3
- import { SortFields } from './SortFields';
4
- export interface Query {
5
- select: string;
6
- page?: number;
7
- limit?: number;
8
- sort?: SortFields;
9
- populate?: Populate[];
10
- and?: FiltersFields;
11
- or?: FiltersFields;
12
- [x: string]: any;
13
- }
package/dist/lib/Query.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=Query.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Query.js","sourceRoot":"","sources":["../../lib/Query.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- export interface SortFields {
2
- field: string;
3
- criteria?: 'asc' | 'desc';
4
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=SortFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SortFields.js","sourceRoot":"","sources":["../../lib/SortFields.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import { Filter } from 'lib/interfaces/Filter';
2
- import { ParsedFilter } from 'lib/interfaces/ParsedFilter';
3
- export declare const ObjectParse: (query: Filter) => ParsedFilter[];
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObjectParse = void 0;
4
- const GetType_1 = require("./GetType");
5
- const objects = {
6
- select: 'select',
7
- page: 'page',
8
- limit: 'limit',
9
- sort: 'sort',
10
- populate: 'populate',
11
- and: 'and',
12
- or: 'or'
13
- };
14
- const ObjectParse = (query) => {
15
- const filters = [];
16
- console.log(query);
17
- Object.keys(query)?.map((key, index) => {
18
- if (!objects[key]) {
19
- const type = (0, GetType_1.getType)(Object.values(query)[index]);
20
- filters.push({
21
- path: key,
22
- value: type === 'object'
23
- ? Object.values(Object.values(query)[index])[0]
24
- : Object.values(query)[index],
25
- operator: type === 'object'
26
- ? Object.keys(Object.values(query)[index])[0]
27
- : 'equals',
28
- type: type === 'object'
29
- ? (0, GetType_1.getType)(Object.values(Object.values(query)[index])[0])
30
- : type
31
- });
32
- }
33
- });
34
- return filters;
35
- };
36
- exports.ObjectParse = ObjectParse;
37
- //# sourceMappingURL=FilterObjectParse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FilterObjectParse.js","sourceRoot":"","sources":["../../../lib/functions/FilterObjectParse.ts"],"names":[],"mappings":";;;AAGA,uCAAoC;AAEpC,MAAM,OAAO,GAAG;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,KAAK;IACV,EAAE,EAAE,IAAI;CACT,CAAC;AAEK,MAAM,WAAW,GAAG,CAAC,KAAa,EAAkB,EAAE;IAC3D,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACrC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACjB,MAAM,IAAI,GAAG,IAAA,iBAAO,EAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAClD,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,GAAG;gBACT,KAAK,EACH,IAAI,KAAK,QAAQ;oBACf,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC/C,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;gBACjC,QAAQ,EACN,IAAI,KAAK,QAAQ;oBACf,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC7C,CAAC,CAAC,QAAQ;gBACd,IAAI,EACF,IAAI,KAAK,QAAQ;oBACf,CAAC,CAAC,IAAA,iBAAO,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACxD,CAAC,CAAC,IAAI;aACX,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAxBW,QAAA,WAAW,eAwBtB"}
@@ -1,3 +0,0 @@
1
- import { FiltersFields } from 'lib/interfaces/FiltersFields';
2
- import { ParsedFilter } from 'lib/interfaces/ParsedFilter';
3
- export declare const ObjectParse: (filter: FiltersFields) => ParsedFilter[];
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ObjectParse = void 0;
4
- const FilterParse_1 = require("./FilterParse");
5
- const GetType_1 = require("./GetType");
6
- const objects = {
7
- and: 'and',
8
- or: 'or'
9
- };
10
- const ObjectParse = (filter) => {
11
- var _a;
12
- return (_a = Object.keys(filter)) === null || _a === void 0 ? void 0 : _a.map((key, index) => {
13
- if (!objects[key]) {
14
- const type = (0, GetType_1.getType)(Object.values(filter)[index]);
15
- return {
16
- path: key,
17
- value: type === 'object'
18
- ? Object.values(Object.values(filter)[index])[0]
19
- : Object.values(filter)[index],
20
- operator: type === 'object'
21
- ? Object.keys(Object.values(filter)[index])[0]
22
- : 'equals',
23
- type: type === 'object'
24
- ? (0, GetType_1.getType)(Object.values(Object.values(filter)[index])[0])
25
- : type
26
- };
27
- }
28
- else {
29
- return (0, FilterParse_1.FilterParse)(filter, key);
30
- }
31
- });
32
- };
33
- exports.ObjectParse = ObjectParse;
34
- //# sourceMappingURL=ObjectParse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ObjectParse.js","sourceRoot":"","sources":["../../../lib/functions/ObjectParse.ts"],"names":[],"mappings":";;;AAEA,+CAA4C;AAC5C,uCAAoC;AAEpC,MAAM,OAAO,GAAG;IACd,GAAG,EAAE,KAAK;IACV,EAAE,EAAE,IAAI;CACT,CAAC;AAEK,MAAM,WAAW,GAAG,CAAC,MAAqB,EAAkB,EAAE;;IACnE,OAAO,MAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,0CAAE,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC7C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACjB,MAAM,IAAI,GAAG,IAAA,iBAAO,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACnD,OAAO;gBACL,IAAI,EAAE,GAAG;gBACT,KAAK,EACH,IAAI,KAAK,QAAQ;oBACf,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;oBAChD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC;gBAClC,QAAQ,EACN,IAAI,KAAK,QAAQ;oBACf,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC9C,CAAC,CAAC,QAAQ;gBACd,IAAI,EACF,IAAI,KAAK,QAAQ;oBACf,CAAC,CAAC,IAAA,iBAAO,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBACzD,CAAC,CAAC,IAAI;aACX,CAAC;SACH;aAAM;YACL,OAAO,IAAA,yBAAW,EAAC,MAAa,EAAE,GAAU,CAAC,CAAC;SAC/C;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAvBW,QAAA,WAAW,eAuBtB"}
@@ -1 +0,0 @@
1
- export declare const QueryParse: (filters: any) => any[];
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryParse = void 0;
4
- const FilterParse_1 = require("./FilterParse");
5
- const ObjectParse_1 = require("./ObjectParse");
6
- const QueryParse = (filters) => {
7
- const parsedFilter = [];
8
- filters.forEach(filter => {
9
- if (filter === null || filter === void 0 ? void 0 : filter.and) {
10
- return parsedFilter.push(...(0, FilterParse_1.FilterParse)(filter.and, 'and'));
11
- }
12
- if (filter === null || filter === void 0 ? void 0 : filter.or) {
13
- return parsedFilter.push(...(0, FilterParse_1.FilterParse)(filter.or, 'or'));
14
- }
15
- return parsedFilter.push(...(0, ObjectParse_1.ObjectParse)(filter));
16
- });
17
- return parsedFilter;
18
- };
19
- exports.QueryParse = QueryParse;
20
- //# sourceMappingURL=QueryParse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryParse.js","sourceRoot":"","sources":["../../../lib/functions/QueryParse.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAC5C,+CAA4C;AAErC,MAAM,UAAU,GAAG,CAAC,OAAY,EAAE,EAAE;IACzC,MAAM,YAAY,GAAG,EAAE,CAAC;IACxB,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACvB,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,EAAE;YACf,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAW,EAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;SAC7D;QACD,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE,EAAE;YACd,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAW,EAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;SAC3D;QACD,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAW,EAAC,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IACH,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAZW,QAAA,UAAU,cAYrB"}
@@ -1,4 +0,0 @@
1
- import { Filter } from './Filter';
2
- export declare type And = {
3
- and: Filter[];
4
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=And.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"And.js","sourceRoot":"","sources":["../../../lib/interfaces/And.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- import { And } from './And';
2
- import { Filter } from './Filter';
3
- import { Or } from './Or';
4
- export declare type FiltersFields = Array<Filter | Or | And>;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=FiltersFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FiltersFields.js","sourceRoot":"","sources":["../../../lib/interfaces/FiltersFields.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- import { Filter } from './Filter';
2
- export declare type Or = {
3
- or: Filter[];
4
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=Or.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Or.js","sourceRoot":"","sources":["../../../lib/interfaces/Or.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import { Filter } from './Filter';
2
- export interface ParsedFilter extends Filter {
3
- path: string;
4
- value: any;
5
- type: any;
6
- operator: any;
7
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ParsedFilter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ParsedFilter.js","sourceRoot":"","sources":["../../../lib/interfaces/ParsedFilter.ts"],"names":[],"mappings":""}