From 759bffea49e473b07cc9e623afbd27ef1fb7418f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rouven=20We=C3=9Fling?= Date: Wed, 7 Nov 2018 02:48:03 +0100 Subject: [PATCH] Update AJV to version 6 (#109) Fixes, #107, closes #105 --- lib/async.js | 15 +++++++++++---- lib/promise.js | 15 +++++++++++---- package-lock.json | 42 +++++++++++++++++++++++++++++------------- package.json | 2 +- 4 files changed, 52 insertions(+), 22 deletions(-) diff --git a/lib/async.js b/lib/async.js index fc41667..90701f2 100644 --- a/lib/async.js +++ b/lib/async.js @@ -4,14 +4,21 @@ var schemas = require('har-schema') var ajv +function createAjvInstance () { + var ajv = new Ajv({ + allErrors: true + }) + ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')) + ajv.addSchema(schemas) + + return ajv +} + function validate (name, data, next) { data = data || {} // validator config - ajv = ajv || new Ajv({ - allErrors: true, - schemas: schemas - }) + ajv = ajv || createAjvInstance() var validate = ajv.getSchema(name + '.json') diff --git a/lib/promise.js b/lib/promise.js index 1ab308c..46f4647 100644 --- a/lib/promise.js +++ b/lib/promise.js @@ -4,14 +4,21 @@ var schemas = require('har-schema') var ajv +function createAjvInstance () { + var ajv = new Ajv({ + allErrors: true + }) + ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')) + ajv.addSchema(schemas) + + return ajv +} + function validate (name, data) { data = data || {} // validator config - ajv = ajv || new Ajv({ - allErrors: true, - schemas: schemas - }) + ajv = ajv || createAjvInstance() var validate = ajv.getSchema(name + '.json') diff --git a/package-lock.json b/package-lock.json index b0fcd29..1c0f09d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,14 +28,14 @@ } }, "ajv": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.3.0.tgz", - "integrity": "sha1-RBT/dKUIecII7l/cgm4ywwNUnto=", + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.2.tgz", + "integrity": "sha512-hOs7GfvI6tUI1LfZddH82ky6mOMyTuY0mk7kE2pWpmhhUSkumzaTO5vbVwij39MdwPQWCV4Zv57Eo06NtL/GVA==", "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", + "fast-deep-equal": "2.0.1", "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" + "json-schema-traverse": "0.4.1", + "uri-js": "4.2.2" } }, "ajv-keywords": { @@ -259,7 +259,8 @@ "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true }, "code-point-at": { "version": "1.1.0", @@ -881,9 +882,9 @@ "dev": true }, "fast-deep-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" }, "fast-json-stable-stringify": { "version": "2.0.0", @@ -1328,9 +1329,9 @@ "dev": true }, "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, "json-stable-stringify": { "version": "1.0.1", @@ -5008,6 +5009,21 @@ "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", "dev": true }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "requires": { + "punycode": "2.1.1" + }, + "dependencies": { + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + } + } + }, "user-home": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", diff --git a/package.json b/package.json index c2b4517..f9f300d 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "tap": "^12.0.0" }, "dependencies": { - "ajv": "^5.3.0", + "ajv": "^6.5.2", "har-schema": "^2.0.0" } }