@autofleet/sheilta 1.3.11-beta.3 → 1.3.11-beta.5

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.
@@ -16,10 +16,16 @@ const parseCustomFieldScopeQueryValue = (value) => {
16
16
  if (['string', 'number'].includes(typeof value)) {
17
17
  return value;
18
18
  }
19
- return Object.entries(value).reduce((acc, [operator, conditionValue]) => {
20
- acc[operators_1.OPERATORS_TO_SQL[operator] || operators_1.OPERATORS_TO_SQL.$in] = conditionValue;
21
- return acc;
22
- }, {});
19
+ if (Array.isArray(value)) {
20
+ return [{
21
+ operator: operators_1.OPERATORS_TO_SQL.$in,
22
+ value
23
+ }];
24
+ }
25
+ return Object.entries(value).map(([operator, conditionValue]) => ({
26
+ operator: operators_1.OPERATORS_TO_SQL[operator],
27
+ value: conditionValue,
28
+ }));
23
29
  };
24
30
  const getAttributeFromOrder = (order, options = {}) => {
25
31
  const { literalAttributes = [], DBFormatter = undefined } = options;
@@ -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",
3
+ "version": "1.3.11-beta.5",
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",