@autofleet/sheilta 1.3.4 → 1.3.5-beta.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.
@@ -5,6 +5,7 @@ export declare type FormatPayloadOptions = {
5
5
  includeRawPayload?: boolean;
6
6
  literalAttributes?: LiteralAttribute[];
7
7
  DBFormatter?: any;
8
+ skipSearchTermFormat?: boolean;
8
9
  };
9
10
  declare const formatPayload: ({ order, page, perPage, include, query, attributes, searchTerm, }: {
10
11
  order?: any[];
@@ -43,13 +43,7 @@ const formatOrder = ({ order, associationModels = [], }) => order.map((o) => {
43
43
  const formatPage = page => page || utils_1.PAGE_DEFAULT;
44
44
  const formatPerPage = perPage => perPage || utils_1.PER_PAGE_DEFAULT;
45
45
  const formatInclude = (include, associationsMap = {}) => {
46
- let formattedInclude = include.map((i) => {
47
- var _a;
48
- const includedAssociation = associationsMap[i.association || i.model];
49
- return Object.assign(Object.assign(Object.assign({}, i), { association: includedAssociation, required: i.required !== false }), (i.include && {
50
- include: formatInclude(i.include, (_a = includedAssociation === null || includedAssociation === void 0 ? void 0 : includedAssociation.target) === null || _a === void 0 ? void 0 : _a.associations),
51
- }));
52
- });
46
+ let formattedInclude = include.map(i => (Object.assign(Object.assign({}, i), { association: associationsMap[i.association || i.model], required: i.required !== false })));
53
47
  formattedInclude = formattedInclude.map(i => lodash_1.default.omit(i, ['model']));
54
48
  return formattedInclude;
55
49
  };
@@ -65,9 +59,9 @@ const formatQuery = (query, associationModels) => {
65
59
  formattedScopeMap.get(CUSTOM_FIELDS_FILTER_SCOPE)[scopeKey] = queryItemValue;
66
60
  return;
67
61
  }
68
- const key = utils_1.isAttributeByAssociation(queryItemKey, associationModels) ?
69
- utils_1.wrapAttributeWithOperator(queryItemKey) :
70
- queryItemKey;
62
+ const key = utils_1.isAttributeByAssociation(queryItemKey, associationModels)
63
+ ? utils_1.wrapAttributeWithOperator(queryItemKey)
64
+ : queryItemKey;
71
65
  formattedQuery[key] = queryItemValue;
72
66
  });
73
67
  const formattedScopes = Array.from(formattedScopeMap.entries()).map(([scopeName, scopeValue]) => {
@@ -104,7 +98,7 @@ const formatPayload = ({ order = [], page = utils_1.PAGE_DEFAULT, perPage = util
104
98
  const formattedPerPage = formatPerPage(perPage);
105
99
  const result = formatQuery(query, associationModels);
106
100
  let { formattedQuery } = result;
107
- if (searchTerm) {
101
+ if (searchTerm && !(options === null || options === void 0 ? void 0 : options.skipSearchTermFormat)) {
108
102
  const attributesToSend = (attributes === null || attributes === void 0 ? void 0 : attributes.length) ? attributes : Object.keys(model.rawAttributes);
109
103
  const queryWithSearchTerm = formatSearchTerm(searchTerm, attributesToSend, model.rawAttributes);
110
104
  formattedQuery = lodash_1.default.isEmpty(formattedQuery) ? queryWithSearchTerm : {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sheilta",
3
- "version": "1.3.4",
3
+ "version": "1.3.5-beta.0",
4
4
  "description": "manage cache",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",