@autofleet/sheilta 1.4.3 → 1.4.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.
@@ -6,20 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.queryFormatMiddleware = exports.queryValidationMiddleware = exports.newQueryFormatMiddleware = exports.newQueryValidationMiddleware = void 0;
7
7
  const logger_1 = __importDefault(require("@autofleet/logger"));
8
8
  const errors_1 = require("@autofleet/errors");
9
- const joi_1 = require("joi");
9
+ const joi_1 = __importDefault(require("joi"));
10
10
  const formatter_1 = __importDefault(require("../formatter"));
11
11
  const validations_1 = require("../validations");
12
+ const { object, string, number, any, array, alternatives, } = joi_1.default.types();
12
13
  const logger = (0, logger_1.default)();
13
- const querySchema = (0, joi_1.object)({
14
- query: (0, joi_1.object)(),
15
- attributes: (0, joi_1.array)().items((0, joi_1.string)()),
16
- order: (0, joi_1.array)().items((0, joi_1.string)()),
17
- page: (0, joi_1.number)(),
18
- perPage: (0, joi_1.number)(),
19
- include: (0, joi_1.array)().items((0, joi_1.any)()),
20
- searchTerm: (0, joi_1.string)(),
21
- group: (0, joi_1.array)().items((0, joi_1.string)()),
22
- enrichments: (0, joi_1.alternatives)((0, joi_1.array)().items((0, joi_1.string)()), (0, joi_1.object)().pattern((0, joi_1.string)(), { exclude: (0, joi_1.array)().items((0, joi_1.string)()) })),
14
+ const querySchema = object.keys({
15
+ query: object,
16
+ attributes: array.items(string),
17
+ order: array.items(string),
18
+ page: number,
19
+ perPage: number,
20
+ include: array.items(any),
21
+ searchTerm: string,
22
+ group: array.items(string),
23
+ enrichments: alternatives.try(array.items(string), object.pattern(string, { exclude: array.items(string) })),
23
24
  });
24
25
  const newQueryValidationMiddleware = (inner = 'body') => (model, options = {}) => async (req, res, next) => {
25
26
  const { query, attributes, order, page, perPage, include, group, enrichments, } = req[inner];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sheilta",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "Middlewares for validation and parsing of endpoints meant for data querying.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",