@autofleet/sheilta 1.0.0 → 1.0.1-aaron-test
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/lib/formatter/index.d.ts +18 -0
- package/lib/formatter/index.js +65 -10
- package/lib/formatter/index.test.d.ts +1 -0
- package/lib/formatter/index.test.js +185 -10
- package/lib/index.d.ts +3 -0
- package/lib/index.js +0 -1
- package/lib/middleware/index.d.ts +4 -0
- package/lib/middleware/index.js +40 -10
- package/lib/operators/index.d.ts +3 -0
- package/lib/operators/index.js +8 -4
- package/lib/utils.d.ts +13 -0
- package/lib/utils.js +27 -3
- package/lib/validations/index.d.ts +8 -0
- package/lib/validations/index.js +69 -21
- package/lib/validations/index.test.d.ts +1 -0
- package/lib/validations/index.test.js +141 -23
- package/package.json +8 -7
- package/lib/formatter/index.js.map +0 -1
- package/lib/formatter/index.test.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/middleware/index.js.map +0 -1
- package/lib/operators/index.js.map +0 -1
- package/lib/utils.js.map +0 -1
- package/lib/validations/index.js.map +0 -1
- package/lib/validations/index.test.js.map +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare type OrderItem = string | [string, string];
|
|
2
|
+
declare type SequelizeOrder = string | OrderItem[];
|
|
3
|
+
declare const formatPayload: ({ order, page, perPage, include, query, attributes, searchTerm, }: {
|
|
4
|
+
order: any;
|
|
5
|
+
page?: number;
|
|
6
|
+
perPage?: number;
|
|
7
|
+
include?: any[];
|
|
8
|
+
query?: {};
|
|
9
|
+
attributes?: any;
|
|
10
|
+
searchTerm?: any;
|
|
11
|
+
}, model?: any) => {
|
|
12
|
+
query: {};
|
|
13
|
+
order: SequelizeOrder[];
|
|
14
|
+
page: any;
|
|
15
|
+
perPage: any;
|
|
16
|
+
include: any;
|
|
17
|
+
};
|
|
18
|
+
export default formatPayload;
|
package/lib/formatter/index.js
CHANGED
|
@@ -1,15 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
6
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
4
7
|
const utils_1 = require("../utils");
|
|
5
8
|
const DESCENDING_KEY = 'DESC';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const formatOrder = ({ order = [], associationModels = [], }) => (order.length === 0 ? undefined :
|
|
10
|
+
order.map((o) => {
|
|
11
|
+
const formattedOrder = [utils_1.extractAttributeNameFromOrder(o, associationModels)];
|
|
12
|
+
const isOrderDescOrder = utils_1.isOrderDesc(o);
|
|
13
|
+
const isOrderAssociation = utils_1.isAttributeByAssociation(isOrderDescOrder
|
|
14
|
+
? o.split(utils_1.ORDER_PREFIX)[1]
|
|
15
|
+
: o, associationModels);
|
|
16
|
+
if (isOrderAssociation) {
|
|
17
|
+
formattedOrder.push(utils_1.extractAssociatedAttributeNameFromOrder(o));
|
|
18
|
+
}
|
|
19
|
+
if (isOrderDescOrder) {
|
|
20
|
+
formattedOrder.push(DESCENDING_KEY);
|
|
21
|
+
}
|
|
22
|
+
return formattedOrder;
|
|
23
|
+
}));
|
|
24
|
+
const formatPage = page => page || utils_1.PAGE_DEFAULT;
|
|
25
|
+
const formatPerPage = perPage => perPage || utils_1.PER_PAGE_DEFAULT;
|
|
26
|
+
const formatInclude = (include, associationsMap = {}) => {
|
|
27
|
+
let formattedInclude = include.map(i => (Object.assign(Object.assign({}, i), { association: associationsMap[i.association || i.model], required: i.required !== 'false' })));
|
|
28
|
+
formattedInclude = formattedInclude.map(i => lodash_1.default.omit(i, ['model']));
|
|
29
|
+
return formattedInclude;
|
|
30
|
+
};
|
|
31
|
+
const formatQuery = (query, associationModels) => Object.keys(query).reduce((acc, queryItemKey) => (Object.assign(Object.assign({}, acc), { [utils_1.isAttributeByAssociation(queryItemKey, associationModels)
|
|
32
|
+
? utils_1.wrapAttributeWithOperator(queryItemKey) : queryItemKey]: query[queryItemKey] })), {});
|
|
33
|
+
const formatSearchTerm = (searchTerm, attributesToSend, rawAttributes) => ({
|
|
34
|
+
$and: searchTerm.split(' ').map(term => ({
|
|
35
|
+
$or: attributesToSend.filter(attrKey => rawAttributes[attrKey].type.key === 'STRING').map(attr => ({
|
|
36
|
+
[attr]: {
|
|
37
|
+
$iLike: `%${term}%`,
|
|
38
|
+
},
|
|
39
|
+
})),
|
|
40
|
+
})),
|
|
14
41
|
});
|
|
15
|
-
|
|
42
|
+
const formatPayload = ({ order, page = utils_1.PAGE_DEFAULT, perPage = utils_1.PER_PAGE_DEFAULT, include = [], query = {}, attributes = null, searchTerm = null, }, model) => {
|
|
43
|
+
const associationModels = Object.keys((model === null || model === void 0 ? void 0 : model.associations) || {});
|
|
44
|
+
const formattedOrder = formatOrder({
|
|
45
|
+
order,
|
|
46
|
+
associationModels,
|
|
47
|
+
});
|
|
48
|
+
const formattedInclude = formatInclude(include, model === null || model === void 0 ? void 0 : model.associations);
|
|
49
|
+
const formattedPage = formatPage(page);
|
|
50
|
+
const formattedPerPage = formatPerPage(perPage);
|
|
51
|
+
let formattedQuery = formatQuery(query, associationModels);
|
|
52
|
+
if (searchTerm) {
|
|
53
|
+
const attributesToSend = (attributes === null || attributes === void 0 ? void 0 : attributes.length) ? attributes : Object.keys(model.rawAttributes);
|
|
54
|
+
const queryWithSearchTerm = formatSearchTerm(searchTerm, attributesToSend, model.rawAttributes);
|
|
55
|
+
formattedQuery = lodash_1.default.isEmpty(formattedQuery) ? queryWithSearchTerm : {
|
|
56
|
+
$and: [
|
|
57
|
+
formattedQuery,
|
|
58
|
+
queryWithSearchTerm,
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
query: formattedQuery,
|
|
64
|
+
order: formattedOrder,
|
|
65
|
+
page: formattedPage,
|
|
66
|
+
perPage: formattedPerPage,
|
|
67
|
+
include: formattedInclude,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
exports.default = formatPayload;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,18 +1,193 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const _1 = require(".");
|
|
6
|
+
const _1 = __importDefault(require("."));
|
|
4
7
|
describe('formatting test', () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
describe('query formatting', () => {
|
|
9
|
+
it('query json field', () => {
|
|
10
|
+
const { query } = _1.default({
|
|
11
|
+
order: [],
|
|
12
|
+
query: {
|
|
13
|
+
'json.field': {
|
|
14
|
+
$gt: 4,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}, {
|
|
18
|
+
rawAttributes: {
|
|
19
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '', json: '',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
expect(JSON.stringify(query)).toBe(JSON.stringify({ 'json.field': { $gt: 4 } }));
|
|
23
|
+
});
|
|
24
|
+
it('query included model field', () => {
|
|
25
|
+
const { query } = _1.default({
|
|
26
|
+
order: [],
|
|
27
|
+
query: {
|
|
28
|
+
'status.field': {
|
|
29
|
+
$gt: 4,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}, {
|
|
33
|
+
rawAttributes: {
|
|
34
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
35
|
+
},
|
|
36
|
+
associations: {
|
|
37
|
+
status: {},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
expect(JSON.stringify(query)).toBe(JSON.stringify({ '$status.field$': { $gt: 4 } }));
|
|
41
|
+
});
|
|
42
|
+
it('query with searchTerm', () => {
|
|
43
|
+
const searchTerm = 'aviv';
|
|
44
|
+
const { query } = _1.default({
|
|
45
|
+
order: [],
|
|
46
|
+
query: {
|
|
47
|
+
'json.field': {
|
|
48
|
+
$gt: 4,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
searchTerm,
|
|
52
|
+
}, {
|
|
53
|
+
rawAttributes: {
|
|
54
|
+
startTime: {
|
|
55
|
+
type: {
|
|
56
|
+
key: 'STRING',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
endTime: {
|
|
60
|
+
type: {
|
|
61
|
+
key: 'NUMBER',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
expect(JSON.stringify(query)).toBe(JSON.stringify({
|
|
67
|
+
$and: [{ 'json.field': { $gt: 4 } }, {
|
|
68
|
+
$and: [{
|
|
69
|
+
$or: [
|
|
70
|
+
{
|
|
71
|
+
startTime: {
|
|
72
|
+
$iLike: `%${searchTerm}%`,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
}],
|
|
77
|
+
}],
|
|
78
|
+
}));
|
|
79
|
+
});
|
|
80
|
+
it('query with searchTerm with spaces', () => {
|
|
81
|
+
const searchTerm = 'aviv good guy';
|
|
82
|
+
const splitSearch = searchTerm.split(' ');
|
|
83
|
+
const { query } = _1.default({
|
|
84
|
+
order: [],
|
|
85
|
+
query: {
|
|
86
|
+
'json.field': {
|
|
87
|
+
$gt: 4,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
searchTerm,
|
|
91
|
+
}, {
|
|
92
|
+
rawAttributes: {
|
|
93
|
+
startTime: {
|
|
94
|
+
type: {
|
|
95
|
+
key: 'STRING',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
endTime: {
|
|
99
|
+
type: {
|
|
100
|
+
key: 'NUMBER',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
expect(JSON.stringify(query)).toBe(JSON.stringify({
|
|
106
|
+
$and: [{ 'json.field': { $gt: 4 } }, {
|
|
107
|
+
$and: [{
|
|
108
|
+
$or: [
|
|
109
|
+
{
|
|
110
|
+
startTime: {
|
|
111
|
+
$iLike: `%${splitSearch[0]}%`,
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
}, {
|
|
116
|
+
$or: [{
|
|
117
|
+
startTime: {
|
|
118
|
+
$iLike: `%${splitSearch[1]}%`,
|
|
119
|
+
},
|
|
120
|
+
}],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
$or: [{
|
|
124
|
+
startTime: {
|
|
125
|
+
$iLike: `%${splitSearch[2]}%`,
|
|
126
|
+
},
|
|
127
|
+
}],
|
|
128
|
+
}],
|
|
129
|
+
}],
|
|
130
|
+
}));
|
|
8
131
|
});
|
|
9
|
-
expect(JSON.stringify(payload)).toBe(JSON.stringify([['startTime'], ['endTime', 'DESC']]));
|
|
10
132
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
order
|
|
133
|
+
describe('order formatting', () => {
|
|
134
|
+
it('simple check', () => {
|
|
135
|
+
const { order } = _1.default({
|
|
136
|
+
order: ['startTime', '-endTime'],
|
|
137
|
+
});
|
|
138
|
+
expect(JSON.stringify(order)).toBe(JSON.stringify([['startTime'], ['endTime', 'DESC']]));
|
|
139
|
+
});
|
|
140
|
+
it('simple check asc', () => {
|
|
141
|
+
const { order } = _1.default({
|
|
142
|
+
order: ['startTime', 'endTime'],
|
|
143
|
+
});
|
|
144
|
+
expect(JSON.stringify(order)).toBe(JSON.stringify([['startTime'], ['endTime']]));
|
|
145
|
+
});
|
|
146
|
+
it('by included model', () => {
|
|
147
|
+
const { order } = _1.default({
|
|
148
|
+
order: ['status.name'],
|
|
149
|
+
}, {
|
|
150
|
+
rawAttributes: {
|
|
151
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
152
|
+
},
|
|
153
|
+
associations: {
|
|
154
|
+
status: {},
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
expect(JSON.stringify(order)).toBe(JSON.stringify([['status', 'name']]));
|
|
158
|
+
});
|
|
159
|
+
it('by included model descending', () => {
|
|
160
|
+
const { order } = _1.default({
|
|
161
|
+
order: ['-status.name'],
|
|
162
|
+
}, {
|
|
163
|
+
rawAttributes: {
|
|
164
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
165
|
+
},
|
|
166
|
+
associations: {
|
|
167
|
+
status: {},
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
expect(JSON.stringify(order)).toBe(JSON.stringify([['status', 'name', 'DESC']]));
|
|
171
|
+
});
|
|
172
|
+
it('by json field', () => {
|
|
173
|
+
const { order } = _1.default({
|
|
174
|
+
order: ['status.name'],
|
|
175
|
+
}, {
|
|
176
|
+
rawAttributes: {
|
|
177
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '', json: '',
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
expect(JSON.stringify(order)).toBe(JSON.stringify([['status.name']]));
|
|
181
|
+
});
|
|
182
|
+
it('by json field descending', () => {
|
|
183
|
+
const { order } = _1.default({
|
|
184
|
+
order: ['-status.name'],
|
|
185
|
+
}, {
|
|
186
|
+
rawAttributes: {
|
|
187
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '', json: '',
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
expect(JSON.stringify(order)).toBe(JSON.stringify([['status.name', 'DESC']]));
|
|
14
191
|
});
|
|
15
|
-
expect(JSON.stringify(payload)).toBe(JSON.stringify([['startTime'], ['endTime']]));
|
|
16
192
|
});
|
|
17
193
|
});
|
|
18
|
-
//# sourceMappingURL=index.test.js.map
|
package/lib/index.d.ts
ADDED
package/lib/index.js
CHANGED
|
@@ -6,4 +6,3 @@ Object.defineProperty(exports, "formatOperators", { enumerable: true, get: funct
|
|
|
6
6
|
const middleware_1 = require("./middleware");
|
|
7
7
|
Object.defineProperty(exports, "queryFormatMiddleware", { enumerable: true, get: function () { return middleware_1.queryFormatMiddleware; } });
|
|
8
8
|
Object.defineProperty(exports, "queryValidationMiddleware", { enumerable: true, get: function () { return middleware_1.queryValidationMiddleware; } });
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const newQueryValidationMiddleware: (inner?: string) => (model: any) => (req: any, res: any, next: any) => Promise<any>;
|
|
2
|
+
export declare const newQueryFormatMiddleware: (inner?: string) => (model: any) => (req: any, res: any, next: any) => Promise<any>;
|
|
3
|
+
export declare const queryValidationMiddleware: (model: any) => (req: any, res: any, next: any) => Promise<any>;
|
|
4
|
+
export declare const queryFormatMiddleware: (model: any) => (req: any, res: any, next: any) => Promise<any>;
|
package/lib/middleware/index.js
CHANGED
|
@@ -8,18 +8,37 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.queryFormatMiddleware = exports.queryValidationMiddleware = void 0;
|
|
15
|
+
exports.queryFormatMiddleware = exports.queryValidationMiddleware = exports.newQueryFormatMiddleware = exports.newQueryValidationMiddleware = void 0;
|
|
13
16
|
const errors_1 = require("@autofleet/errors");
|
|
14
|
-
const
|
|
17
|
+
const joi_1 = require("joi");
|
|
18
|
+
const formatter_1 = __importDefault(require("../formatter"));
|
|
15
19
|
const validations_1 = require("../validations");
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
const querySchema = joi_1.object({
|
|
21
|
+
query: joi_1.any(),
|
|
22
|
+
attributes: joi_1.array().items(joi_1.string()),
|
|
23
|
+
order: joi_1.array().items(joi_1.string()),
|
|
24
|
+
page: joi_1.number(),
|
|
25
|
+
perPage: joi_1.number(),
|
|
26
|
+
include: joi_1.array().items(joi_1.any()),
|
|
27
|
+
});
|
|
28
|
+
exports.newQueryValidationMiddleware = (inner = 'body') => model => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
const { query, attributes, order, page, perPage, include, } = req[inner];
|
|
18
30
|
try {
|
|
31
|
+
const result = querySchema.validate(req[inner]);
|
|
32
|
+
if (result.error) {
|
|
33
|
+
throw new errors_1.BadRequest([result.error], null);
|
|
34
|
+
}
|
|
19
35
|
validations_1.validatePayload({
|
|
20
36
|
query,
|
|
21
37
|
attributes,
|
|
22
38
|
order,
|
|
39
|
+
page,
|
|
40
|
+
perPage,
|
|
41
|
+
include,
|
|
23
42
|
}, model);
|
|
24
43
|
return next();
|
|
25
44
|
}
|
|
@@ -35,12 +54,23 @@ exports.queryValidationMiddleware = model => (req, res, next) => __awaiter(void
|
|
|
35
54
|
});
|
|
36
55
|
}
|
|
37
56
|
});
|
|
38
|
-
exports.
|
|
39
|
-
const { order, } = req
|
|
40
|
-
const formattedOrder = formatter_1.
|
|
57
|
+
exports.newQueryFormatMiddleware = (inner = 'body') => model => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const { order, page, perPage, include, query, attributes, searchTerm, } = req[inner];
|
|
59
|
+
const { query: formattedQuery, order: formattedOrder, page: formattedPage, perPage: formattedPerPage, include: formattedInclude, } = formatter_1.default({
|
|
60
|
+
query,
|
|
41
61
|
order,
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
page,
|
|
63
|
+
perPage,
|
|
64
|
+
include,
|
|
65
|
+
attributes,
|
|
66
|
+
searchTerm,
|
|
67
|
+
}, model);
|
|
68
|
+
req[inner].query = formattedQuery;
|
|
69
|
+
req[inner].order = formattedOrder;
|
|
70
|
+
req[inner].page = formattedPage;
|
|
71
|
+
req[inner].perPage = formattedPerPage;
|
|
72
|
+
req[inner].include = formattedInclude;
|
|
44
73
|
return next();
|
|
45
74
|
});
|
|
46
|
-
|
|
75
|
+
exports.queryValidationMiddleware = exports.newQueryValidationMiddleware();
|
|
76
|
+
exports.queryFormatMiddleware = exports.newQueryFormatMiddleware();
|
package/lib/operators/index.js
CHANGED
|
@@ -13,16 +13,20 @@ exports.OPERATORS = [
|
|
|
13
13
|
'notIn',
|
|
14
14
|
'is',
|
|
15
15
|
'like',
|
|
16
|
+
'iLike',
|
|
16
17
|
'notLike',
|
|
17
18
|
'between',
|
|
18
19
|
'and',
|
|
19
20
|
'or',
|
|
21
|
+
'overlap',
|
|
22
|
+
'contains',
|
|
20
23
|
];
|
|
21
24
|
exports.OPERATOR_PREFIX = '$';
|
|
22
25
|
exports.formatOperators = (Sequelize) => {
|
|
23
26
|
const { Op } = Sequelize;
|
|
24
|
-
return exports.OPERATORS.map
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
return exports.OPERATORS.reduce((map, o) => {
|
|
28
|
+
// eslint-disable-next-line no-param-reassign
|
|
29
|
+
map[`${exports.OPERATOR_PREFIX + o}`] = Op[o];
|
|
30
|
+
return map;
|
|
31
|
+
}, {});
|
|
27
32
|
};
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const ORDER_PREFIX = "-";
|
|
2
|
+
export declare const ASSOCIATION_PREFIX = ".";
|
|
3
|
+
export declare const PER_PAGE_DEFAULT = 20;
|
|
4
|
+
export declare const PAGE_DEFAULT = 1;
|
|
5
|
+
export declare const PER_PAGE_MAX_LIMIT = 100;
|
|
6
|
+
export declare const PER_PAGE_MIN_LIMIT = 1;
|
|
7
|
+
export declare const PAGE_MIN = 1;
|
|
8
|
+
export declare const wrapAttributeWithOperator: (attribute: any) => string;
|
|
9
|
+
export declare const isAttributeByAssociation: (attributeName: any, associatedModels: any) => boolean;
|
|
10
|
+
export declare const extractAttributeNameFromOrder: (order: any, associationModels: any) => string;
|
|
11
|
+
export declare const isOrderDesc: (order: any) => boolean;
|
|
12
|
+
export declare const throwBadRequestError: (message: string) => never;
|
|
13
|
+
export declare const extractAssociatedAttributeNameFromOrder: (order: any) => string;
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isOrderDesc = exports.extractAttributeNameFromOrder = exports.ORDER_PREFIX = void 0;
|
|
3
|
+
exports.extractAssociatedAttributeNameFromOrder = exports.throwBadRequestError = exports.isOrderDesc = exports.extractAttributeNameFromOrder = exports.isAttributeByAssociation = exports.wrapAttributeWithOperator = exports.PAGE_MIN = exports.PER_PAGE_MIN_LIMIT = exports.PER_PAGE_MAX_LIMIT = exports.PAGE_DEFAULT = exports.PER_PAGE_DEFAULT = exports.ASSOCIATION_PREFIX = exports.ORDER_PREFIX = void 0;
|
|
4
|
+
const errors_1 = require("@autofleet/errors");
|
|
5
|
+
const operators_1 = require("./operators");
|
|
4
6
|
exports.ORDER_PREFIX = '-';
|
|
5
|
-
exports.
|
|
7
|
+
exports.ASSOCIATION_PREFIX = '.';
|
|
8
|
+
exports.PER_PAGE_DEFAULT = 20;
|
|
9
|
+
exports.PAGE_DEFAULT = 1;
|
|
10
|
+
exports.PER_PAGE_MAX_LIMIT = 100;
|
|
11
|
+
exports.PER_PAGE_MIN_LIMIT = 1;
|
|
12
|
+
exports.PAGE_MIN = 1;
|
|
13
|
+
exports.wrapAttributeWithOperator = attribute => `${operators_1.OPERATOR_PREFIX}${attribute}${operators_1.OPERATOR_PREFIX}`;
|
|
14
|
+
exports.isAttributeByAssociation = (attributeName, associatedModels) => attributeName.includes(exports.ASSOCIATION_PREFIX)
|
|
15
|
+
&& associatedModels.includes(attributeName.split(exports.ASSOCIATION_PREFIX)[0]);
|
|
16
|
+
exports.extractAttributeNameFromOrder = (order, associationModels) => {
|
|
17
|
+
let formattedOrder = order;
|
|
18
|
+
if (order.includes(exports.ORDER_PREFIX)) {
|
|
19
|
+
// eslint-disable-next-line prefer-destructuring
|
|
20
|
+
formattedOrder = formattedOrder.split(exports.ORDER_PREFIX)[1];
|
|
21
|
+
}
|
|
22
|
+
if (exports.isAttributeByAssociation(formattedOrder, associationModels)) {
|
|
23
|
+
[formattedOrder] = formattedOrder.split(exports.ASSOCIATION_PREFIX);
|
|
24
|
+
}
|
|
25
|
+
return formattedOrder;
|
|
26
|
+
};
|
|
6
27
|
exports.isOrderDesc = (order) => order.includes(exports.ORDER_PREFIX);
|
|
7
|
-
|
|
28
|
+
exports.throwBadRequestError = (message) => {
|
|
29
|
+
throw new errors_1.BadRequest([{ message }], null);
|
|
30
|
+
};
|
|
31
|
+
exports.extractAssociatedAttributeNameFromOrder = (order) => order.split(exports.ASSOCIATION_PREFIX)[1];
|
package/lib/validations/index.js
CHANGED
|
@@ -4,56 +4,95 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.validatePayload = void 0;
|
|
7
|
-
const errors_1 = require("@autofleet/errors");
|
|
8
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
8
|
const utils_1 = require("../utils");
|
|
10
9
|
const operators_1 = require("../operators");
|
|
11
10
|
const validateOperator = (operator) => operators_1.OPERATORS.includes(operator.split(operators_1.OPERATOR_PREFIX)[1]);
|
|
12
|
-
const validateQueryAttribute = (attribute, modelAttributes) => modelAttributes
|
|
13
|
-
|
|
11
|
+
const validateQueryAttribute = (attribute, modelAttributes = [], associationModels = []) => [...modelAttributes, ...associationModels]
|
|
12
|
+
.includes(attribute.includes(utils_1.ASSOCIATION_PREFIX)
|
|
13
|
+
? attribute.split(utils_1.ASSOCIATION_PREFIX)[0] : attribute);
|
|
14
|
+
const validateSingleOrder = (currentOrder, rawAttributes, associationModels) => {
|
|
14
15
|
const isOrderDescOrder = utils_1.isOrderDesc(currentOrder);
|
|
15
16
|
if (isOrderDescOrder && currentOrder[0] !== utils_1.ORDER_PREFIX) {
|
|
16
|
-
|
|
17
|
+
utils_1.throwBadRequestError(`${utils_1.ORDER_PREFIX} must be only at the beginning of the word`);
|
|
17
18
|
}
|
|
18
|
-
const
|
|
19
|
-
utils_1.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const orderStringWithoutDesc = isOrderDescOrder ?
|
|
20
|
+
currentOrder.split(utils_1.ORDER_PREFIX)[1] : currentOrder;
|
|
21
|
+
const isOrderAssociation = utils_1.isAttributeByAssociation(orderStringWithoutDesc, associationModels);
|
|
22
|
+
let formattedOrderString = utils_1.extractAttributeNameFromOrder(currentOrder, associationModels);
|
|
23
|
+
if (!isOrderAssociation && formattedOrderString.includes(utils_1.ASSOCIATION_PREFIX)) {
|
|
24
|
+
[formattedOrderString] = formattedOrderString.split(utils_1.ASSOCIATION_PREFIX);
|
|
25
|
+
}
|
|
26
|
+
if (!(rawAttributes.includes(formattedOrderString) || isOrderAssociation)) {
|
|
27
|
+
utils_1.throwBadRequestError(`${currentOrder} is invalid`);
|
|
23
28
|
}
|
|
24
29
|
};
|
|
25
30
|
const validateSingleAttribute = (currentAttribute, rawAttributes) => {
|
|
26
31
|
if (!rawAttributes.includes(currentAttribute)) {
|
|
27
|
-
|
|
32
|
+
utils_1.throwBadRequestError(`${currentAttribute} is invalid`);
|
|
28
33
|
}
|
|
29
34
|
};
|
|
30
|
-
const validateOrderAttributes = (order, rawAttributes) => {
|
|
31
|
-
order.map(o => validateSingleOrder(o, rawAttributes));
|
|
35
|
+
const validateOrderAttributes = (order, rawAttributes, associationModels = []) => {
|
|
36
|
+
order.map(o => validateSingleOrder(o, rawAttributes, associationModels));
|
|
32
37
|
};
|
|
33
38
|
const validateAttributes = (attributes, rawAttributes) => {
|
|
34
39
|
attributes.map(a => validateSingleAttribute(a, rawAttributes));
|
|
35
40
|
};
|
|
36
|
-
const validateQueryPayload = (query, rawAttributes) => {
|
|
41
|
+
const validateQueryPayload = (query, rawAttributes, associationModels = []) => {
|
|
37
42
|
// eslint-disable-next-line array-callback-return
|
|
38
43
|
Object.keys(query).map((key) => {
|
|
39
44
|
const value = query[key];
|
|
40
45
|
if (lodash_1.default.isArray(value)) {
|
|
41
46
|
if (lodash_1.default.isObject(value[0])) {
|
|
42
|
-
value.map(v => validateQueryPayload(v, rawAttributes));
|
|
47
|
+
value.map(v => validateQueryPayload(v, rawAttributes, associationModels));
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
|
-
else if (validateOperator(key)
|
|
50
|
+
else if (validateOperator(key)
|
|
51
|
+
|| validateQueryAttribute(key, rawAttributes, associationModels)) {
|
|
46
52
|
if (lodash_1.default.isObject(value)) {
|
|
47
53
|
validateQueryPayload(value, rawAttributes);
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
else {
|
|
51
|
-
|
|
57
|
+
utils_1.throwBadRequestError(`invalid key: ${key}`);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const validatePagination = ({ page, perPage, }) => {
|
|
62
|
+
if (page < utils_1.PAGE_MIN) {
|
|
63
|
+
utils_1.throwBadRequestError('Page must be greater than 0');
|
|
64
|
+
}
|
|
65
|
+
if (perPage > utils_1.PER_PAGE_MAX_LIMIT || perPage < utils_1.PER_PAGE_MIN_LIMIT) {
|
|
66
|
+
utils_1.throwBadRequestError(`PerPage must be between ${utils_1.PER_PAGE_MIN_LIMIT} to ${utils_1.PER_PAGE_MAX_LIMIT}`);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const validateIncludePayload = (include, associations) => {
|
|
70
|
+
const associationsKeys = Object.keys(associations);
|
|
71
|
+
include.forEach((i) => {
|
|
72
|
+
var _a;
|
|
73
|
+
validateQueryAttribute(i.model, associationsKeys);
|
|
74
|
+
const target = (_a = associations[i.model]) === null || _a === void 0 ? void 0 : _a.target;
|
|
75
|
+
if (!target) {
|
|
76
|
+
utils_1.throwBadRequestError('model not found in associations');
|
|
77
|
+
}
|
|
78
|
+
const { rawAttributes } = target;
|
|
79
|
+
if (include.where) {
|
|
80
|
+
validateQueryPayload(i.where, rawAttributes);
|
|
81
|
+
}
|
|
82
|
+
if (include.order) {
|
|
83
|
+
validateOrderAttributes(i.order, rawAttributes);
|
|
84
|
+
}
|
|
85
|
+
if (include.attributes) {
|
|
86
|
+
validateAttributes(i.attributes, rawAttributes);
|
|
87
|
+
}
|
|
88
|
+
if (!lodash_1.default.isNil(include.required) && !lodash_1.default.isBoolean(include.required)) {
|
|
89
|
+
utils_1.throwBadRequestError('include.required must be a boolean');
|
|
52
90
|
}
|
|
53
91
|
});
|
|
54
92
|
};
|
|
55
|
-
exports.validatePayload = ({ query = {}, order = [], attributes = [], }, model) => {
|
|
56
|
-
const
|
|
93
|
+
exports.validatePayload = ({ query = {}, order = [], attributes = [], include = [], page = utils_1.PAGE_DEFAULT, perPage = utils_1.PER_PAGE_DEFAULT, }, model) => {
|
|
94
|
+
const rawAttributes = Object.keys(model.rawAttributes);
|
|
95
|
+
const associationModels = Object.keys((model === null || model === void 0 ? void 0 : model.associations) || {});
|
|
57
96
|
if (!attributes || attributes.length === 0) {
|
|
58
97
|
// eslint-disable-next-line no-param-reassign
|
|
59
98
|
attributes = rawAttributes;
|
|
@@ -61,8 +100,17 @@ exports.validatePayload = ({ query = {}, order = [], attributes = [], }, model)
|
|
|
61
100
|
else {
|
|
62
101
|
validateAttributes(attributes, rawAttributes);
|
|
63
102
|
}
|
|
64
|
-
validateOrderAttributes(order, rawAttributes);
|
|
65
|
-
validateQueryPayload(query, rawAttributes);
|
|
103
|
+
validateOrderAttributes(order, rawAttributes, associationModels);
|
|
104
|
+
validateQueryPayload(query, rawAttributes, associationModels);
|
|
105
|
+
if (include.length && typeof include === 'object') {
|
|
106
|
+
validateIncludePayload(include, model === null || model === void 0 ? void 0 : model.associations);
|
|
107
|
+
}
|
|
108
|
+
else if (include && typeof include !== 'object') {
|
|
109
|
+
utils_1.throwBadRequestError('include must be an array');
|
|
110
|
+
}
|
|
111
|
+
validatePagination({
|
|
112
|
+
page,
|
|
113
|
+
perPage,
|
|
114
|
+
});
|
|
66
115
|
return true;
|
|
67
116
|
};
|
|
68
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -38,29 +38,147 @@ const query = {
|
|
|
38
38
|
};
|
|
39
39
|
const order = ['startTime', '-endTime'];
|
|
40
40
|
describe('validations test', () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
_1.validatePayload({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
describe('query validation', () => {
|
|
42
|
+
it('check query validation', () => {
|
|
43
|
+
const payload = _1.validatePayload({ query }, {
|
|
44
|
+
rawAttributes: {
|
|
45
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
expect(payload).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
it('check query by json property field', () => {
|
|
51
|
+
const payload = _1.validatePayload({
|
|
52
|
+
query: {
|
|
53
|
+
'jsonField.exampleField': {
|
|
54
|
+
$eq: 'a',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
}, {
|
|
58
|
+
rawAttributes: {
|
|
59
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '', jsonField: {},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
expect(payload).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
it('check query by included model field', () => {
|
|
65
|
+
const payload = _1.validatePayload({
|
|
66
|
+
query: {
|
|
67
|
+
'status.name': {
|
|
68
|
+
$eq: 'a',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
}, {
|
|
72
|
+
rawAttributes: {
|
|
73
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
74
|
+
},
|
|
75
|
+
associations: {
|
|
76
|
+
status: {},
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
expect(payload).toBe(true);
|
|
80
|
+
});
|
|
81
|
+
it('check query by non existent field', () => {
|
|
82
|
+
try {
|
|
83
|
+
_1.validatePayload({
|
|
84
|
+
query: {
|
|
85
|
+
nonExistent: {
|
|
86
|
+
$eq: 'a',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
}, {
|
|
90
|
+
rawAttributes: {
|
|
91
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
expect(error.statusCode).toBe(400);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
56
99
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
_1.validatePayload({ order
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
100
|
+
describe('order validation', () => {
|
|
101
|
+
it('check order validation', () => {
|
|
102
|
+
const payload = _1.validatePayload({ order }, {
|
|
103
|
+
rawAttributes: {
|
|
104
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
expect(payload).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
it('order does not exist', () => {
|
|
110
|
+
try {
|
|
111
|
+
_1.validatePayload({ order: ['aviv'] }, {
|
|
112
|
+
rawAttributes: {
|
|
113
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
expect(error.statusCode).toBe(400);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
it('prefix in the wrong place', () => {
|
|
122
|
+
try {
|
|
123
|
+
_1.validatePayload({ order: ['startTime-', 'currencySymbol'] }, {
|
|
124
|
+
rawAttributes: {
|
|
125
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
expect(error.statusCode).toBe(400);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
it('order by included model', () => {
|
|
134
|
+
const payload = _1.validatePayload({ order: ['status.title'] }, {
|
|
135
|
+
rawAttributes: {
|
|
136
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
137
|
+
},
|
|
138
|
+
associations: {
|
|
139
|
+
status: {},
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
expect(payload).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
it('order by included model descending', () => {
|
|
145
|
+
const payload = _1.validatePayload({ order: ['-status.title'] }, {
|
|
146
|
+
rawAttributes: {
|
|
147
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
148
|
+
},
|
|
149
|
+
associations: {
|
|
150
|
+
status: {},
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
expect(payload).toBe(true);
|
|
154
|
+
});
|
|
155
|
+
it('order by json field', () => {
|
|
156
|
+
const payload = _1.validatePayload({ order: ['status.title'] }, {
|
|
157
|
+
rawAttributes: {
|
|
158
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '', status: '',
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
expect(payload).toBe(true);
|
|
162
|
+
});
|
|
163
|
+
it('order by json field desc', () => {
|
|
164
|
+
const payload = _1.validatePayload({ order: ['-status.title'] }, {
|
|
165
|
+
rawAttributes: {
|
|
166
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '', status: '',
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
expect(payload).toBe(true);
|
|
170
|
+
});
|
|
171
|
+
it('try order by json field that doesnt exist', () => {
|
|
172
|
+
try {
|
|
173
|
+
_1.validatePayload({ order: ['-stas.title'] }, {
|
|
174
|
+
rawAttributes: {
|
|
175
|
+
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '', status: '',
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
expect(error.statusCode).toBe(400);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
64
183
|
});
|
|
65
184
|
});
|
|
66
|
-
//# sourceMappingURL=index.test.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/sheilta",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-aaron-test",
|
|
4
4
|
"description": "manage cache",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -29,19 +29,20 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@autofleet/errors": "^1.0.10",
|
|
31
31
|
"@types/node": "^14.14.20",
|
|
32
|
+
"joi": "^17.9.2",
|
|
32
33
|
"lodash": "^4.17.21"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"
|
|
36
|
+
"@types/jest": "^24.9.0",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
|
38
|
+
"@typescript-eslint/parser": "^2.23.0",
|
|
36
39
|
"eslint": "^6.8.0",
|
|
37
40
|
"eslint-config-airbnb": "^16.1.0",
|
|
38
41
|
"eslint-plugin-import": "^2.20.1",
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
|
40
|
-
"@typescript-eslint/parser": "^2.23.0",
|
|
41
|
-
"typescript-eslint": "0.0.1-alpha.0",
|
|
42
|
-
"ts-jest": "^25.0.0",
|
|
43
42
|
"jest": "^25.1.0",
|
|
44
|
-
"
|
|
43
|
+
"ts-jest": "^25.0.0",
|
|
44
|
+
"typescript": "^3.9.5",
|
|
45
|
+
"typescript-eslint": "0.0.1-alpha.0"
|
|
45
46
|
},
|
|
46
47
|
"files": [
|
|
47
48
|
"lib/**/*"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;;AAAA,oCAAsE;AAEtE,MAAM,cAAc,GAAG,MAAM,CAAC;AAIjB,QAAA,WAAW,GAAG,CAAC,EAC1B,KAAK,GAAG,EAAE,GACX,EAAoB,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAS,EAAkB,EAAE;IAC9D,MAAM,gBAAgB,GAAG,mBAAW,CAAC,CAAC,CAAC,CAAC;IACxC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,gBAAgB,EAAE;QACpB,MAAM,GAAG,qCAA6B,CAAC,CAAC,CAAC,CAAC;QAC1C,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;KACjC;IAED,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/formatter/index.test.ts"],"names":[],"mappings":";;AAAA,wBAAgC;AAEhC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,OAAO,GAAG,cAAW,CAAC;YAC1B,KAAK,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC;SACjC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,MAAM,OAAO,GAAG,cAAW,CAAC;YAC1B,KAAK,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;SAChC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2CAA8C;AAO5C,gGAPO,2BAAe,OAOP;AANjB,6CAGsB;AAIpB,sGANA,kCAAqB,OAMA;AACrB,0GANA,sCAAyB,OAMA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAgD;AAChD,4CAA2C;AAC3C,gDAAiD;AAEpC,QAAA,yBAAyB,GAAG,KAAK,CAAC,EAAE,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,IAAI,EAAgB,EAAE;IACvF,MAAM,EACJ,KAAK,EACL,UAAU,EACV,KAAK,GACN,GAAG,GAAG,CAAC,IAAI,CAAC;IAEb,IAAI;QACF,6BAAe,CAAC;YACd,KAAK;YACL,UAAU;YACV,KAAK;SAC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AC"}
|
package/lib/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,GAAG,CAAC;AAEnB,QAAA,6BAA6B,GAAG,CAAC,KAAK,EAAU,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF,QAAA,WAAW,GAAG,CAAC,KAAK,EAAW,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,oBAAY,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/validations/index.ts"],"names":[],"mappings":";;;;;;AAAA,8CAA+C;AAC/C,oDAAuB;AACvB,oCAAoF;AACpF,4CAA0D;AAG1D,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAW,EAAE,CACrD,qBAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,2BAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEzD,MAAM,sBAAsB,GACxB,CAAC,SAAiB,EAAE,eAAyB,EAAW,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAEnG,MAAM,mBAAmB,GAAG,CAAC,YAAoB,EAAE,aAAuB,EAAQ,EAAE;IAClF,MAAM,gBAAgB,GAAG,mBAAW,CAAC,YAAY,CAAC,CAAC;IACnD,IAAI,gBAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,oBAAY,EAAE;QACxD,MAAM,IAAI,mBAAU,CAAC,GAAG,oBAAY,4CAA4C,EAAE,IAAI,CAAC,CAAC;KACzF;IAED,MAAM,oBAAoB,GAC1B,gBAAgB,CAAC,CAAC;QAChB,qCAA6B,CAAC,YAAY,CAAC,CAAC,CAAC;QAC7C,YAAY,CAAC;IAEf,IAAI,CAAC,aAAa,CAAC,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