@autofleet/sheilta 1.3.11-beta.2 → 1.3.11-beta.4
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.js +12 -2
- package/package.json +3 -2
package/lib/formatter/index.js
CHANGED
|
@@ -13,11 +13,17 @@ const ASCENDING_KEY = 'ASC';
|
|
|
13
13
|
const CUSTOM_FIELDS_QUERY_PREFIX = 'customFields.';
|
|
14
14
|
const { CUSTOM_FIELDS_FILTER_SCOPE, CUSTOM_FIELDS_SORT_SCOPE } = common_types_1.customFields;
|
|
15
15
|
const parseCustomFieldScopeQueryValue = (value) => {
|
|
16
|
-
if (typeof value
|
|
16
|
+
if (['string', 'number'].includes(typeof value)) {
|
|
17
17
|
return value;
|
|
18
18
|
}
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
return [{
|
|
21
|
+
operator: operators_1.OPERATORS_TO_SQL.$in,
|
|
22
|
+
value
|
|
23
|
+
}];
|
|
24
|
+
}
|
|
19
25
|
return Object.entries(value).map(([operator, conditionValue]) => ({
|
|
20
|
-
operator: operators_1.OPERATORS_TO_SQL[operator]
|
|
26
|
+
operator: operators_1.OPERATORS_TO_SQL[operator],
|
|
21
27
|
value: conditionValue,
|
|
22
28
|
}));
|
|
23
29
|
};
|
|
@@ -90,7 +96,9 @@ const formatInclude = (include, associationsMap = {}) => {
|
|
|
90
96
|
const formatQuery = (query, associationModels) => {
|
|
91
97
|
const formattedQuery = {};
|
|
92
98
|
const formattedScopeMap = new Map();
|
|
99
|
+
console.log('query', query);
|
|
93
100
|
Object.entries(query).forEach(([queryItemKey, queryItemValue]) => {
|
|
101
|
+
console.log({ queryItemKey, queryItemValue });
|
|
94
102
|
if (queryItemKey.startsWith(CUSTOM_FIELDS_QUERY_PREFIX)) {
|
|
95
103
|
if (!formattedScopeMap.has(CUSTOM_FIELDS_FILTER_SCOPE)) {
|
|
96
104
|
formattedScopeMap.set(CUSTOM_FIELDS_FILTER_SCOPE, {});
|
|
@@ -111,6 +119,7 @@ const formatQuery = (query, associationModels) => {
|
|
|
111
119
|
}
|
|
112
120
|
return { method: [scopeName, scopeValue] };
|
|
113
121
|
});
|
|
122
|
+
console.log({ formattedQuery, formattedScopes });
|
|
114
123
|
return {
|
|
115
124
|
formattedQuery,
|
|
116
125
|
formattedScopes,
|
|
@@ -150,6 +159,7 @@ const formatPayload = ({ order = [], page = utils_1.PAGE_DEFAULT, perPage = util
|
|
|
150
159
|
],
|
|
151
160
|
};
|
|
152
161
|
}
|
|
162
|
+
console.log({ formattedQuery, filteredFormattedOrder, formattedPage, formattedPerPage, formattedInclude, queryScopes, orderScopes, formattedAttribute });
|
|
153
163
|
return Object.assign({ query: formattedQuery, order: filteredFormattedOrder, page: formattedPage, perPage: formattedPerPage, include: formattedInclude, scopes: [...queryScopes, ...orderScopes] }, (formattedAttribute && { attributes: formattedAttribute }));
|
|
154
164
|
};
|
|
155
165
|
exports.default = formatPayload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/sheilta",
|
|
3
|
-
"version": "1.3.11-beta.
|
|
3
|
+
"version": "1.3.11-beta.4",
|
|
4
4
|
"description": "manage cache",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
"@autofleet/common-types": "^1.7.42",
|
|
48
48
|
"@autofleet/errors": "^1.0.10",
|
|
49
49
|
"joi": "^17.9.2",
|
|
50
|
-
"lodash": "^4.17.21"
|
|
50
|
+
"lodash": "^4.17.21",
|
|
51
|
+
"npm-watch": "^0.13.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@types/jest": "^24.9.0",
|