@autofleet/sheilta 1.3.4-hilat-1 → 1.3.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.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ declare const formatPayload: ({ order, page, perPage, include, query, attributes
|
|
|
15
15
|
attributes?: any;
|
|
16
16
|
searchTerm?: any;
|
|
17
17
|
}, model?: any, options?: any) => {
|
|
18
|
-
attributes:
|
|
18
|
+
attributes: {
|
|
19
|
+
include: any[];
|
|
20
|
+
};
|
|
19
21
|
query: {};
|
|
20
22
|
order: SequelizeOrder[];
|
|
21
23
|
page: any;
|
package/lib/formatter/index.js
CHANGED
|
@@ -97,10 +97,8 @@ const formatPayload = ({ order = [], page = utils_1.PAGE_DEFAULT, perPage = util
|
|
|
97
97
|
associationModels,
|
|
98
98
|
});
|
|
99
99
|
const [filteredFormattedOrder, filteredLiteralAttributes] = getAttributeFromOrder(formattedOrder, options);
|
|
100
|
-
// here
|
|
101
|
-
console.log({ attributes });
|
|
102
100
|
const allAttributes = [...filteredLiteralAttributes, ...(attributes || [])];
|
|
103
|
-
|
|
101
|
+
const formattedAttribute = allAttributes.length ? { include: allAttributes } : null;
|
|
104
102
|
const formattedInclude = formatInclude(include, model === null || model === void 0 ? void 0 : model.associations);
|
|
105
103
|
const formattedPage = formatPage(page);
|
|
106
104
|
const formattedPerPage = formatPerPage(perPage);
|
|
@@ -116,8 +114,6 @@ const formatPayload = ({ order = [], page = utils_1.PAGE_DEFAULT, perPage = util
|
|
|
116
114
|
],
|
|
117
115
|
};
|
|
118
116
|
}
|
|
119
|
-
|
|
120
|
-
console.log({ attributes });
|
|
121
|
-
return Object.assign({ query: formattedQuery, order: filteredFormattedOrder, page: formattedPage, perPage: formattedPerPage, include: formattedInclude, scopes: result.formattedScopes }, (allAttributes && { attributes: allAttributes }));
|
|
117
|
+
return Object.assign({ query: formattedQuery, order: filteredFormattedOrder, page: formattedPage, perPage: formattedPerPage, include: formattedInclude, scopes: result.formattedScopes }, (formattedAttribute && { attributes: formattedAttribute }));
|
|
122
118
|
};
|
|
123
119
|
exports.default = formatPayload;
|
|
@@ -208,7 +208,6 @@ describe('formatting test', () => {
|
|
|
208
208
|
const literalAttribute = { attribute: 'genericField', literal: ['void', 'field'] };
|
|
209
209
|
const { order, attributes } = _1.default({
|
|
210
210
|
order: [`-${literalAttribute.attribute}`, 'currencySymbol'],
|
|
211
|
-
attributes: ['endTime'],
|
|
212
211
|
}, {
|
|
213
212
|
rawAttributes: {
|
|
214
213
|
startTime: '', endTime: '', currencySymbol: '', currencyCode: '', startStationId: '',
|
|
@@ -216,11 +215,10 @@ describe('formatting test', () => {
|
|
|
216
215
|
}, {
|
|
217
216
|
literalAttributes: [literalAttribute],
|
|
218
217
|
});
|
|
219
|
-
console.log({ attributes });
|
|
220
218
|
expect(JSON.stringify(order)).toBe(JSON.stringify([[`${literalAttribute.attribute} DESC`], ['currencySymbol'], ['id']]));
|
|
221
219
|
expect(JSON.stringify(attributes))
|
|
222
220
|
.toBe(JSON.stringify({
|
|
223
|
-
include: [[literalAttribute.literal[0], literalAttribute.literal[1]]
|
|
221
|
+
include: [[literalAttribute.literal[0], literalAttribute.literal[1]]],
|
|
224
222
|
}));
|
|
225
223
|
});
|
|
226
224
|
it('by literal field - not found', () => {
|
package/package.json
CHANGED