@spytecgps/lambda-utils 1.0.17 → 1.0.18

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.
@@ -2,8 +2,8 @@ import * as Joi from 'joi';
2
2
  import { ArraySchema, ObjectSchema, SchemaMap, StringSchema } from 'joi';
3
3
  export declare const json: any;
4
4
  export declare const urlEncoded: any;
5
- export declare const imeiSchema: Joi.StringSchema;
6
- export declare const iccidSchema: Joi.StringSchema;
5
+ export declare const imeiSchema: Joi.StringSchema<string>;
6
+ export declare const iccidSchema: Joi.StringSchema<string>;
7
7
  interface SpytecJoi extends Joi.Root {
8
8
  urlEncodedObject<TSchema = any, T = TSchema>(schema?: SchemaMap<T>): ObjectSchema<TSchema>;
9
9
  jsonObject<TSchema = any, T = TSchema>(schema?: SchemaMap<T>): ObjectSchema<TSchema>;
@@ -11,6 +11,7 @@ interface SpytecJoi extends Joi.Root {
11
11
  iccid(): StringSchema;
12
12
  delimitedArray(): ArraySchema;
13
13
  dateString(): StringSchema;
14
+ jsonArray<TSchema = any, T = TSchema>(schema?: Joi.SchemaMap<T>): ArraySchema<TSchema>;
14
15
  }
15
16
  export declare const SpytecJoi: SpytecJoi;
16
17
  export {};
@@ -85,7 +85,6 @@ exports.SpytecJoi = Joi.extend(function (joi) { return ({
85
85
  }); }, function (joi) { return ({
86
86
  type: 'jsonObject',
87
87
  base: joi.object(),
88
- messages: 'must be valid JSON',
89
88
  coerce: function (value) {
90
89
  try {
91
90
  return { value: JSON.parse(value) };
@@ -124,4 +123,21 @@ exports.SpytecJoi = Joi.extend(function (joi) { return ({
124
123
  return helpers.error('any.invalid');
125
124
  }
126
125
  },
126
+ }); }, function (joi) { return ({
127
+ type: 'jsonArray',
128
+ base: joi.array(),
129
+ coerce: function (value) {
130
+ try {
131
+ return { value: JSON.parse(value) };
132
+ }
133
+ catch (err) {
134
+ return { value: null };
135
+ }
136
+ },
137
+ validate: function (value, helpers) {
138
+ if (!Array.isArray(value)) {
139
+ return { value: value, errors: helpers.error('jsonArray.schema') };
140
+ }
141
+ return { value: value };
142
+ },
127
143
  }); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/lambda-utils",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "Lambda Utils",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -34,7 +34,7 @@
34
34
  "@middy/input-output-logger": "^2.5.7",
35
35
  "@spytecgps/sdk": "0.5.97",
36
36
  "dayjs": "^1.11.9",
37
- "joi": "^17.4.0",
37
+ "joi": "^17.12.2",
38
38
  "logform": "^2.4.0",
39
39
  "qs": "^6.10.1",
40
40
  "winston": "^3.7.2",