nestjs-prisma-querybuilder-interface 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -63
- package/dist/lib/Querybuilder.js +2 -2
- package/dist/lib/Querybuilder.js.map +1 -1
- package/dist/lib/functions/FilterParse.d.ts +1 -1
- package/dist/lib/functions/FilterParse.js +10 -8
- package/dist/lib/functions/FilterParse.js.map +1 -1
- package/dist/lib/functions/FilterResolver.js +5 -2
- package/dist/lib/functions/FilterResolver.js.map +1 -1
- package/dist/lib/functions/PopulateParse.js +7 -6
- package/dist/lib/functions/PopulateParse.js.map +1 -1
- package/dist/lib/interfaces/Filter.d.ts +4 -4
- package/dist/lib/interfaces/Operator.d.ts +1 -1
- package/dist/lib/interfaces/Populate.d.ts +2 -2
- package/dist/teste.js +24 -13
- package/dist/teste.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -30,72 +30,20 @@
|
|
|
30
30
|
|
|
31
31
|
- **How to install it?**
|
|
32
32
|
|
|
33
|
+
#### npm
|
|
34
|
+
|
|
33
35
|
```sh
|
|
34
36
|
npm install --save nestjs-prisma-querybuilder-interface
|
|
35
|
-
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### yarn
|
|
40
|
+
|
|
41
|
+
```sh
|
|
36
42
|
yarn add nestjs-prisma-querybuilder-interface
|
|
37
43
|
```
|
|
38
44
|
|
|
39
|
-
- **How to use it?**
|
|
40
|
-
|
|
41
|
-
- use in PARAMS with **AXIOS**
|
|
42
|
-
|
|
43
|
-
<br/>
|
|
44
|
-
|
|
45
|
-
```tsx
|
|
46
|
-
import { QueryString, Query } from 'nestjs-prisma-querybuilder-interface';
|
|
47
|
-
|
|
48
|
-
const query: Query = {
|
|
49
|
-
select: 'message title date',
|
|
50
|
-
populate: [
|
|
51
|
-
{
|
|
52
|
-
path: 'user',
|
|
53
|
-
select: 'name email'
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
sort: { field: name, criteria: 'asc' },
|
|
57
|
-
page: 1,
|
|
58
|
-
limit: 20
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
axios.get('http://example.com/movies', {
|
|
62
|
-
params: query,
|
|
63
|
-
paramsSerializer: params => QueryString(params)
|
|
64
|
-
});
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
<br/>
|
|
68
|
-
|
|
69
|
-
- use in URL
|
|
70
45
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```tsx
|
|
74
|
-
import { QueryString } from 'nestjs-prisma-querybuilder-interface';
|
|
75
|
-
|
|
76
|
-
const query = QueryString({
|
|
77
|
-
select: 'message title date',
|
|
78
|
-
populate: [
|
|
79
|
-
{
|
|
80
|
-
path: 'user',
|
|
81
|
-
select: 'name email'
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
|
-
sort: 'asc',
|
|
85
|
-
sortField: 'date',
|
|
86
|
-
limit: 20
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
fetch(`http://example.com/movies?${query}`);
|
|
90
|
-
|
|
91
|
-
// with axios
|
|
92
|
-
|
|
93
|
-
axios.get(`http://example.com/movies?${query}`);
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
<br/>
|
|
97
|
-
|
|
98
|
-
- **Property**
|
|
46
|
+
- **Properties**
|
|
99
47
|
|
|
100
48
|
- Usage
|
|
101
49
|
|
|
@@ -108,7 +56,7 @@
|
|
|
108
56
|
| populate | Populate | populate: [{path: 'car', select: 'model plate'}] |
|
|
109
57
|
| filter | Filter | filter: [{name: 'jonas'}, {value: { gte: 4 }}] |
|
|
110
58
|
|
|
111
|
-
|
|
59
|
+
<br/>
|
|
112
60
|
|
|
113
61
|
- **Exported Interfaces**
|
|
114
62
|
|
|
@@ -194,7 +142,7 @@
|
|
|
194
142
|
primaryKey: 'yourTablePrimaryKey' // default 'id'
|
|
195
143
|
},
|
|
196
144
|
|
|
197
|
-
//
|
|
145
|
+
// Non verbose syntax
|
|
198
146
|
|
|
199
147
|
{
|
|
200
148
|
car: 'model plate',
|
|
@@ -246,7 +194,7 @@
|
|
|
246
194
|
}
|
|
247
195
|
];
|
|
248
196
|
|
|
249
|
-
//
|
|
197
|
+
// Non verbose syntax
|
|
250
198
|
|
|
251
199
|
const filter: Filter = [
|
|
252
200
|
{
|
package/dist/lib/Querybuilder.js
CHANGED
|
@@ -5,10 +5,10 @@ const qs_1 = require("qs");
|
|
|
5
5
|
const FilterResolver_1 = require("./functions/FilterResolver");
|
|
6
6
|
const PopulateParse_1 = require("./functions/PopulateParse");
|
|
7
7
|
function QueryString(query) {
|
|
8
|
-
if (query
|
|
8
|
+
if (query && query.filter) {
|
|
9
9
|
query.filter = (0, FilterResolver_1.FilterResolver)(query.filter);
|
|
10
10
|
}
|
|
11
|
-
if (query
|
|
11
|
+
if (query && query.populate) {
|
|
12
12
|
query.populate = (0, PopulateParse_1.PopulateParse)(query.populate);
|
|
13
13
|
}
|
|
14
14
|
return (0, qs_1.stringify)(query);
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,IAAI,KAAK,CAAC,MAAM,EAAE;QACzB,KAAK,CAAC,MAAM,GAAG,IAAA,+BAAc,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAC7C;IACD,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE;QAC3B,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,2 +1,2 @@
|
|
|
1
1
|
import { Filter } from '../interfaces/Filter';
|
|
2
|
-
export declare const FilterParse: (filters
|
|
2
|
+
export declare const FilterParse: (filters?: any[], filterGroup?: string) => Filter;
|
|
@@ -2,40 +2,42 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FilterParse = void 0;
|
|
4
4
|
const GetType_1 = require("./GetType");
|
|
5
|
-
const FilterParse = (filters, filterGroup) => {
|
|
5
|
+
const FilterParse = (filters = [], filterGroup) => {
|
|
6
6
|
return filters.map(filter => {
|
|
7
|
+
var _a;
|
|
7
8
|
let parsedFilter = {};
|
|
8
|
-
Object.keys(filter)
|
|
9
|
+
(_a = Object.keys(filter)) === null || _a === void 0 ? void 0 : _a.forEach(key => {
|
|
10
|
+
var _a, _b;
|
|
9
11
|
if (key === 'path') {
|
|
10
12
|
parsedFilter = {
|
|
11
13
|
...parsedFilter,
|
|
12
|
-
path: filter
|
|
14
|
+
path: filter === null || filter === void 0 ? void 0 : filter.path
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
17
|
else if (key === 'value') {
|
|
16
18
|
parsedFilter = {
|
|
17
19
|
...parsedFilter,
|
|
18
|
-
value: filter
|
|
20
|
+
value: filter === null || filter === void 0 ? void 0 : filter.value
|
|
19
21
|
};
|
|
20
22
|
}
|
|
21
23
|
else if (key === 'insensitive') {
|
|
22
24
|
parsedFilter = {
|
|
23
25
|
...parsedFilter,
|
|
24
|
-
insensitive: filter
|
|
26
|
+
insensitive: filter === null || filter === void 0 ? void 0 : filter.insensitive
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
else if (key === 'operator') {
|
|
28
30
|
parsedFilter = {
|
|
29
31
|
...parsedFilter,
|
|
30
|
-
operator: filter
|
|
32
|
+
operator: filter === null || filter === void 0 ? void 0 : filter.operator
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
else {
|
|
34
36
|
if ((0, GetType_1.getType)(filter[key]) === 'object') {
|
|
35
|
-
if (filter[key]
|
|
37
|
+
if ((_a = filter[key]) === null || _a === void 0 ? void 0 : _a.insensitive) {
|
|
36
38
|
parsedFilter = {
|
|
37
39
|
...parsedFilter,
|
|
38
|
-
insensitive: filter[key]
|
|
40
|
+
insensitive: (_b = filter[key]) === null || _b === void 0 ? void 0 : _b.insensitive
|
|
39
41
|
};
|
|
40
42
|
delete filter[key].insensitive;
|
|
41
43
|
}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"FilterParse.js","sourceRoot":"","sources":["../../../lib/functions/FilterParse.ts"],"names":[],"mappings":";;;AACA,uCAAoC;AAE7B,MAAM,WAAW,GAAG,CAAC,OAAO,GAAG,EAAE,EAAE,WAAoB,EAAU,EAAE;IACxE,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;;QAC1B,IAAI,YAAY,GAAiB,EAAE,CAAC;QACpC,MAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,0CAAE,OAAO,CAAC,GAAG,CAAC,EAAE;;YACjC,IAAI,GAAG,KAAK,MAAM,EAAE;gBAClB,YAAY,GAAG;oBACb,GAAG,YAAY;oBACf,IAAI,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI;iBACnB,CAAC;aACH;iBAAM,IAAI,GAAG,KAAK,OAAO,EAAE;gBAC1B,YAAY,GAAG;oBACb,GAAG,YAAY;oBACf,KAAK,EAAE,MA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C;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"}
|
|
@@ -5,12 +5,15 @@ const FilterParse_1 = require("./FilterParse");
|
|
|
5
5
|
const FilterResolver = filters => {
|
|
6
6
|
const FilterResolved = [];
|
|
7
7
|
filters.forEach(filter => {
|
|
8
|
-
if (filter
|
|
8
|
+
if (filter === null || filter === void 0 ? void 0 : filter.and) {
|
|
9
9
|
return FilterResolved.push(...(0, FilterParse_1.FilterParse)(filter.and, 'and'));
|
|
10
10
|
}
|
|
11
|
-
if (filter
|
|
11
|
+
if (filter === null || filter === void 0 ? void 0 : filter.or) {
|
|
12
12
|
return FilterResolved.push(...(0, FilterParse_1.FilterParse)(filter.or, 'or'));
|
|
13
13
|
}
|
|
14
|
+
if (filter === null || filter === void 0 ? void 0 : filter.not) {
|
|
15
|
+
return FilterResolved.push(...(0, FilterParse_1.FilterParse)(filter.or, 'not'));
|
|
16
|
+
}
|
|
14
17
|
return FilterResolved.push(...(0, FilterParse_1.FilterParse)([filter]));
|
|
15
18
|
});
|
|
16
19
|
return FilterResolved;
|
|
@@ -1 +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,
|
|
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,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,EAAE;YACf,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAW,EAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;SAC/D;QAED,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,EAAE,EAAE;YACd,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAW,EAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;SAC7D;QAED,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,EAAE;YACf,OAAO,cAAc,CAAC,IAAI,CAAC,GAAG,IAAA,yBAAW,EAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;SAC9D;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;AAlBW,QAAA,cAAc,kBAkBzB"}
|
|
@@ -4,36 +4,37 @@ exports.PopulateParse = void 0;
|
|
|
4
4
|
const FilterResolver_1 = require("./FilterResolver");
|
|
5
5
|
const PopulateParse = (populates) => {
|
|
6
6
|
return populates.map(populate => {
|
|
7
|
+
var _a;
|
|
7
8
|
let parsedPopulate = {};
|
|
8
|
-
Object.keys(populate)
|
|
9
|
+
(_a = Object.keys(populate)) === null || _a === void 0 ? void 0 : _a.forEach(key => {
|
|
9
10
|
if (key === 'filter') {
|
|
10
11
|
parsedPopulate = {
|
|
11
12
|
...parsedPopulate,
|
|
12
|
-
filter: (0, FilterResolver_1.FilterResolver)(populate
|
|
13
|
+
filter: (0, FilterResolver_1.FilterResolver)(populate === null || populate === void 0 ? void 0 : populate.filter)
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
else if (key === 'populate') {
|
|
16
17
|
parsedPopulate = {
|
|
17
18
|
...parsedPopulate,
|
|
18
|
-
populate: (0, exports.PopulateParse)(populate
|
|
19
|
+
populate: (0, exports.PopulateParse)(populate === null || populate === void 0 ? void 0 : populate.populate)
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
else if (key === 'primaryKey') {
|
|
22
23
|
parsedPopulate = {
|
|
23
24
|
...parsedPopulate,
|
|
24
|
-
primaryKey: populate
|
|
25
|
+
primaryKey: populate === null || populate === void 0 ? void 0 : populate.primaryKey
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
else if (key === 'path') {
|
|
28
29
|
parsedPopulate = {
|
|
29
30
|
...parsedPopulate,
|
|
30
|
-
path: populate
|
|
31
|
+
path: populate === null || populate === void 0 ? void 0 : populate.path
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
else if (key === 'select') {
|
|
34
35
|
parsedPopulate = {
|
|
35
36
|
...parsedPopulate,
|
|
36
|
-
select: populate
|
|
37
|
+
select: populate === null || populate === void 0 ? void 0 : populate.select
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
else {
|
|
@@ -1 +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
|
|
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,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,11 +1,11 @@
|
|
|
1
1
|
import { Operator } from './Operator';
|
|
2
|
-
|
|
2
|
+
type FilterObject = {
|
|
3
3
|
[x in string]: any;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
type OperatorObject = {
|
|
6
6
|
[x in Operator]: string | Date | boolean | number;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type FiltersField = FilterObject | OperatorObject | {
|
|
9
9
|
path: string;
|
|
10
10
|
} | {
|
|
11
11
|
value: string;
|
|
@@ -14,7 +14,7 @@ export declare type FiltersField = FilterObject | OperatorObject | {
|
|
|
14
14
|
} | {
|
|
15
15
|
operator: Operator;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type Filter = Array<FiltersField | {
|
|
18
18
|
or: FiltersField[];
|
|
19
19
|
} | {
|
|
20
20
|
and: FiltersField[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Operator = 'contains' | 'endsWith' | 'startsWith' | 'equals' | 'gt' | 'gte' | 'in' | 'lt' | 'lte' | 'not' | 'notIn' | 'hasEvery' | 'hasSome' | 'has' | 'isEmpty';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Filter } from './Filter';
|
|
2
|
-
|
|
2
|
+
type PopulateObject = {
|
|
3
3
|
[x: string]: string;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export type Populate = Array<PopulateObject | {
|
|
6
6
|
filter: Filter;
|
|
7
7
|
} | {
|
|
8
8
|
populate: Populate;
|
package/dist/teste.js
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
console.log((0,
|
|
5
|
-
select: '
|
|
3
|
+
const Querybuilder_1 = require("./lib/Querybuilder");
|
|
4
|
+
console.log((0, Querybuilder_1.QueryString)({
|
|
5
|
+
select: 'firstName lastName',
|
|
6
|
+
limit: 10,
|
|
7
|
+
sort: { field: 'firstName', criteria: 'asc' },
|
|
6
8
|
filter: [
|
|
7
|
-
{ path: 'name', value: 'wilian teste', operator: 'equals' },
|
|
8
|
-
{ createdAt: { lte: new Date() } },
|
|
9
9
|
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
path: 'firstName',
|
|
11
|
+
operator: 'contains',
|
|
12
|
+
value: 'Will',
|
|
13
|
+
insensitive: true
|
|
14
14
|
}
|
|
15
15
|
],
|
|
16
|
+
page: 2,
|
|
16
17
|
populate: [
|
|
17
18
|
{
|
|
18
|
-
path: '
|
|
19
|
-
select: 'identification createdAt',
|
|
19
|
+
path: 'post',
|
|
20
20
|
primaryKey: 'id',
|
|
21
|
-
|
|
22
|
-
populate: [{
|
|
21
|
+
select: 'title description',
|
|
22
|
+
populate: [{ path: 'reactions', select: 'type', primaryKey: 'id' }],
|
|
23
|
+
filter: [
|
|
24
|
+
{
|
|
25
|
+
path: 'reactions',
|
|
26
|
+
operator: 'equals',
|
|
27
|
+
value: 'like',
|
|
28
|
+
and: [
|
|
29
|
+
{ path: 'reactions', operator: 'contains', value: 'li' },
|
|
30
|
+
{ path: 'reactions', operator: 'endsWith', value: 'e' }
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
]
|
|
23
34
|
}
|
|
24
35
|
]
|
|
25
36
|
}));
|
package/dist/teste.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,oBAAoB;IAC5B,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE;IAC7C,MAAM,EAAE;QACN;YACE,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,UAAU;YACpB,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,IAAI;SAClB;KACF;IACD,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE;QACR;YACE,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,mBAAmB;YAC3B,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;YACnE,MAAM,EAAE;gBACN;oBACE,IAAI,EAAE,WAAW;oBACjB,QAAQ,EAAE,QAAQ;oBAClB,KAAK,EAAE,MAAM;oBACb,GAAG,EAAE;wBACH,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE;wBACxD,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE;qBACxD;iBACF;aACF;SACF;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.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.
|
|
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.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.es2019.intl.d.ts","../node_modules/typescript/lib/lib.es2019.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":"8730f4bf322026ff5229336391a18bcaa1f94d4f82416c8b2f3954e2ccaae2ba","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","4b421cbfb3a38a27c279dec1e9112c3d1da296f77a1a85ddadf7e7a425d45d18",{"version":"3aafcb693fe5b5c3bd277bd4c3a617b53db474fe498fc5df067c5603b1eebde7","affectsGlobalScope":true},{"version":"f3d4da15233e593eacb3965cde7960f3fddf5878528d882bcedd5cbaba0193c7","affectsGlobalScope":true},{"version":"7fac8cb5fc820bc2a59ae11ef1c5b38d3832c6d0dfaec5acdb5569137d09a481","affectsGlobalScope":true},{"version":"097a57355ded99c68e6df1b738990448e0bf170e606707df5a7c0481ff2427cd","affectsGlobalScope":true},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"5f406584aef28a331c36523df688ca3650288d14f39c5d2e555c95f0d2ff8f6f","affectsGlobalScope":true},{"version":"22f230e544b35349cfb3bd9110b6ef37b41c6d6c43c3314a31bd0d9652fcec72","affectsGlobalScope":true},{"version":"7ea0b55f6b315cf9ac2ad622b0a7813315bb6e97bf4bb3fbf8f8affbca7dc695","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"eb26de841c52236d8222f87e9e6a235332e0788af8c87a71e9e210314300410a","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","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":"5e5e095c4470c8bab227dbbc61374878ecead104c74ab9960d3adcccfee23205","affectsGlobalScope":true},"1f03b495671c3a1bd24510f38b8947f0991dfd6bf0278c68eca14af15b306e1f",{"version":"454b0392263f594d9cd33159411df01beb09dda6d46d7d09aee506997fed134b","signature":"d50052c34f5768eb4d8311450ab3b9fc1ddb57628c2b9e3acd97cfe8d0c13c92"},{"version":"6fca10a5cb88a76c2603f0fc0ea3e6836ca2ccb89af0958bdd4ce48504217138","signature":"e53d385a5987d1310ea46a4c1c20b10cbc75d596fdac2ef5e47944f0e25ae373"},{"version":"327fdcfc2fd5413bc62218325bd01c42702432fded09e3fe80f562fe2062a097","signature":"8b3ab6706ae2347540bdb4dbd9ee65a58cfba62daa3720dc00a8c78eb185c6e9"},{"version":"1687d1bb2a596cfbe84ca0bedc14a4b099d7488fe7cf4e0cd84ec55dab5697d4","signature":"10c723d50b6752fd0cec5815a7ebe4e4e5f7aa58a308748c3233bc64ed08adb3"},{"version":"a366eb3f5532eade55402eec82def264725b6a7be39b8114f083e183bcf21c10","signature":"28f4ea53a76945101ce2c8b50b1ef1defc2731a70221c8a95718eeb1afd89ac5"},"ba601641fac98c229ccd4a303f747de376d761babb33229bb7153bed9356c9cc",{"version":"5413e2cb35d9569bdb7bc1de3818c08ba7b0e290918c87296309ec0463b26418","signature":"b05f509d8cc6243d6b2a95b10bc3fbbc255abe7a79ada4f82d6d3350016bc5ed"},{"version":"db633166368d8a390cfa5db43b932e000fa6b71b9be78e8e9bbb5ff7e12282e8","signature":"dde3fb80309c7d9d85f1cc9befb766d2f39031312605f6700cc5ea5204a19f32"},{"version":"093553e6a595a1d3c1e541303c0809714984b815d9bf2bf1c24a7979a6b1a076","signature":"bee5d82699b0989b4d85e69152a9ccb0f7d10cdee7fb4eba691dc4d1cc7dd756"},{"version":"3934b0079af06f8deb2b5ffc42ae6d57d0dab632340fad199e67cd24ae5b5d8b","signature":"418a1c232e1387107647efbc7e82f43d1c7556b8dc23df2fe1fd98fc7fd5e709"},{"version":"4f0d5fd89af48beb20334a67fc5c665784995223000887400967612364675416","signature":"f1b4d7e012d8c6651d25ee44cfe1e3b82ce63c8ce484574fad79a79f73c80f87"},"35935f295ebfd5a1127b235d0437879f367d1842e6c8f1968d1e80c777654787",{"version":"130cd7a77f32e4cd201d77ca82b957d8c5425a8d875613a6a277119deb0c80f4","signature":"f761c91419d0a89422a0004ef1a92929dd4d2d5e5c16758654d8b0467d1998c6"}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"emitDecoratorMetadata":true,"experimentalDecorators":true,"module":1,"outDir":"./","removeComments":true,"sourceMap":true,"target":6},"fileIdsList":[[38,39,41,47],[38,43],[44],[39,44,45],[37],[38],[38,39,40],[41,42,45,46],[47],[39],[41]],"referencedMap":[[48,1],[44,2],[45,3],[46,4],[38,5],[39,6],[41,7],[47,8],[49,9]],"exportedModulesMap":[[48,1],[44,6],[46,10],[38,5],[39,6],[41,7],[47,11]],"semanticDiagnosticsPerFile":[48,44,45,43,46,38,37,39,41,40,47,42,7,8,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,36,35,32,33,34,1,10,9,49]},"version":"4.9.4"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestjs-prisma-querybuilder-interface",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Frontend interface to nestjs-prisma-querybuilder",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/qs": "^6.9.7",
|
|
39
|
-
"typescript": "^4.
|
|
39
|
+
"typescript": "^4.9.4"
|
|
40
40
|
}
|
|
41
41
|
}
|