@autofleet/sheilta 1.3.6 → 1.3.7-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.
@@ -16,7 +16,9 @@ declare const formatPayload: ({ order, page, perPage, include, query, attributes
16
16
  attributes?: any;
17
17
  searchTerm?: any;
18
18
  }, model?: any, options?: any) => {
19
- attributes: any[];
19
+ attributes: any[] | {
20
+ include: any[];
21
+ };
20
22
  query: {};
21
23
  order: SequelizeOrder[];
22
24
  page: any;
@@ -98,6 +98,7 @@ const formatPayload = ({ order = [], page = utils_1.PAGE_DEFAULT, perPage = util
98
98
  });
99
99
  const [filteredFormattedOrder, filteredLiteralAttributes] = getAttributeFromOrder(formattedOrder, options);
100
100
  const allAttributes = [...filteredLiteralAttributes, ...(attributes || [])];
101
+ const formattedAttribute = (attributes === null || attributes === void 0 ? void 0 : attributes.length) ? allAttributes : { include: allAttributes };
101
102
  const formattedInclude = formatInclude(include, model === null || model === void 0 ? void 0 : model.associations);
102
103
  const formattedPage = formatPage(page);
103
104
  const formattedPerPage = formatPerPage(perPage);
@@ -113,6 +114,6 @@ const formatPayload = ({ order = [], page = utils_1.PAGE_DEFAULT, perPage = util
113
114
  ],
114
115
  };
115
116
  }
116
- return Object.assign({ query: formattedQuery, order: filteredFormattedOrder, page: formattedPage, perPage: formattedPerPage, include: formattedInclude, scopes: result.formattedScopes }, ((allAttributes.length > 0) && { attributes: allAttributes }));
117
+ return Object.assign({ query: formattedQuery, order: filteredFormattedOrder, page: formattedPage, perPage: formattedPerPage, include: formattedInclude, scopes: result.formattedScopes }, (formattedAttribute && { attributes: formattedAttribute }));
117
118
  };
118
119
  exports.default = formatPayload;
@@ -202,7 +202,7 @@ describe('formatting test', () => {
202
202
  });
203
203
  expect(JSON.stringify(order)).toBe(JSON.stringify([[`${literalAttribute.attribute} ASC`], ['id']]));
204
204
  expect(JSON.stringify(attributes))
205
- .toBe(JSON.stringify([literalAttribute.literal]));
205
+ .toBe(JSON.stringify({ include: [literalAttribute.literal] }));
206
206
  });
207
207
  it('by literal field descending', () => {
208
208
  const literalAttribute = { attribute: 'genericField', literal: ['void', 'field'] };
@@ -232,7 +232,7 @@ describe('formatting test', () => {
232
232
  literalAttributes: [literalAttribute],
233
233
  });
234
234
  expect(JSON.stringify(order)).toBe(JSON.stringify([[`O${literalAttribute.attribute}`, 'DESC'], ['id']]));
235
- expect(JSON.stringify(attributes)).toBe(JSON.stringify(undefined));
235
+ expect(JSON.stringify(attributes)).toBe(JSON.stringify({ include: [] }));
236
236
  });
237
237
  });
238
238
  describe('include formatting', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sheilta",
3
- "version": "1.3.6",
3
+ "version": "1.3.7-beta.0",
4
4
  "description": "manage cache",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -48,4 +48,4 @@
48
48
  "files": [
49
49
  "lib/**/*"
50
50
  ]
51
- }
51
+ }