@autofleet/sheilta 1.3.5 → 1.3.6-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.
package/lib/formatter/index.d.ts
CHANGED
|
@@ -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[];
|
package/lib/formatter/index.js
CHANGED
|
@@ -65,9 +65,9 @@ const formatQuery = (query, associationModels) => {
|
|
|
65
65
|
formattedScopeMap.get(CUSTOM_FIELDS_FILTER_SCOPE)[scopeKey] = queryItemValue;
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
const key = utils_1.isAttributeByAssociation(queryItemKey, associationModels)
|
|
69
|
-
utils_1.wrapAttributeWithOperator(queryItemKey)
|
|
70
|
-
queryItemKey;
|
|
68
|
+
const key = utils_1.isAttributeByAssociation(queryItemKey, associationModels)
|
|
69
|
+
? utils_1.wrapAttributeWithOperator(queryItemKey)
|
|
70
|
+
: queryItemKey;
|
|
71
71
|
formattedQuery[key] = queryItemValue;
|
|
72
72
|
});
|
|
73
73
|
const formattedScopes = Array.from(formattedScopeMap.entries()).map(([scopeName, scopeValue]) => {
|
|
@@ -103,7 +103,7 @@ const formatPayload = ({ order = [], page = utils_1.PAGE_DEFAULT, perPage = util
|
|
|
103
103
|
const formattedPerPage = formatPerPage(perPage);
|
|
104
104
|
const result = formatQuery(query, associationModels);
|
|
105
105
|
let { formattedQuery } = result;
|
|
106
|
-
if (searchTerm) {
|
|
106
|
+
if (searchTerm && !(options === null || options === void 0 ? void 0 : options.skipSearchTermFormat)) {
|
|
107
107
|
const attributesToSend = (attributes === null || attributes === void 0 ? void 0 : attributes.length) ? attributes : Object.keys(model.rawAttributes);
|
|
108
108
|
const queryWithSearchTerm = formatSearchTerm(searchTerm, attributesToSend, model.rawAttributes);
|
|
109
109
|
formattedQuery = lodash_1.default.isEmpty(formattedQuery) ? queryWithSearchTerm : {
|