@autofleet/sheilta 1.2.6 → 1.2.7

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.
@@ -24,7 +24,7 @@ const formatOrder = ({ order = [], associationModels = [], }) => (order.length =
24
24
  const formatPage = page => page || utils_1.PAGE_DEFAULT;
25
25
  const formatPerPage = perPage => perPage || utils_1.PER_PAGE_DEFAULT;
26
26
  const formatInclude = (include, associationsMap = {}) => {
27
- let formattedInclude = include.map(i => (Object.assign(Object.assign({}, i), { association: associationsMap[i.association || i.model], required: i.required !== 'false' })));
27
+ let formattedInclude = include.map(i => (Object.assign(Object.assign({}, i), { association: associationsMap[i.association || i.model], required: i.required !== false })));
28
28
  formattedInclude = formattedInclude.map(i => lodash_1.default.omit(i, ['model']));
29
29
  return formattedInclude;
30
30
  };
@@ -190,4 +190,33 @@ describe('formatting test', () => {
190
190
  expect(JSON.stringify(order)).toBe(JSON.stringify([['status.name', 'DESC']]));
191
191
  });
192
192
  });
193
+ describe('include formatting', () => {
194
+ it('include required should be true', () => {
195
+ const { include } = _1.default({
196
+ order: [],
197
+ include: [{
198
+ model: 'status',
199
+ }],
200
+ }, {
201
+ associations: {
202
+ status: {},
203
+ },
204
+ });
205
+ expect(include[0].required).toBe(true);
206
+ });
207
+ it('include required should be false', () => {
208
+ const { include } = _1.default({
209
+ order: [],
210
+ include: [{
211
+ model: 'status',
212
+ required: false,
213
+ }],
214
+ }, {
215
+ associations: {
216
+ status: {},
217
+ },
218
+ });
219
+ expect(include[0].required).toBe(false);
220
+ });
221
+ });
193
222
  });
@@ -24,6 +24,7 @@ const querySchema = joi_1.object({
24
24
  page: joi_1.number(),
25
25
  perPage: joi_1.number(),
26
26
  include: joi_1.array().items(joi_1.any()),
27
+ searchTerm: joi_1.string(),
27
28
  });
28
29
  exports.newQueryValidationMiddleware = (inner = 'body') => model => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
29
30
  const { query, attributes, order, page, perPage, include, } = req[inner];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sheilta",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "manage cache",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",