diff options
Diffstat (limited to 'deps/npm/node_modules/har-validator/lib')
15 files changed, 1064 insertions, 210 deletions
diff --git a/deps/npm/node_modules/har-validator/lib/async.js b/deps/npm/node_modules/har-validator/lib/async.js deleted file mode 100644 index fc41667e81..0000000000 --- a/deps/npm/node_modules/har-validator/lib/async.js +++ /dev/null @@ -1,98 +0,0 @@ -var Ajv = require('ajv') -var HARError = require('./error') -var schemas = require('har-schema') - -var ajv - -function validate (name, data, next) { - data = data || {} - - // validator config - ajv = ajv || new Ajv({ - allErrors: true, - schemas: schemas - }) - - var validate = ajv.getSchema(name + '.json') - - var valid = validate(data) - - // callback? - if (typeof next === 'function') { - return next(!valid ? new HARError(validate.errors) : null, valid) - } - - return valid -} - -exports.afterRequest = function (data, next) { - return validate('afterRequest', data, next) -} - -exports.beforeRequest = function (data, next) { - return validate('beforeRequest', data, next) -} - -exports.browser = function (data, next) { - return validate('browser', data, next) -} - -exports.cache = function (data, next) { - return validate('cache', data, next) -} - -exports.content = function (data, next) { - return validate('content', data, next) -} - -exports.cookie = function (data, next) { - return validate('cookie', data, next) -} - -exports.creator = function (data, next) { - return validate('creator', data, next) -} - -exports.entry = function (data, next) { - return validate('entry', data, next) -} - -exports.har = function (data, next) { - return validate('har', data, next) -} - -exports.header = function (data, next) { - return validate('header', data, next) -} - -exports.log = function (data, next) { - return validate('log', data, next) -} - -exports.page = function (data, next) { - return validate('page', data, next) -} - -exports.pageTimings = function (data, next) { - return validate('pageTimings', data, next) -} - -exports.postData = function (data, next) { - return validate('postData', data, next) -} - -exports.query = function (data, next) { - return validate('query', data, next) -} - -exports.request = function (data, next) { - return validate('request', data, next) -} - -exports.response = function (data, next) { - return validate('response', data, next) -} - -exports.timings = function (data, next) { - return validate('timings', data, next) -} diff --git a/deps/npm/node_modules/har-validator/lib/browser/async.js b/deps/npm/node_modules/har-validator/lib/browser/async.js new file mode 100644 index 0000000000..676356aafd --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/browser/async.js @@ -0,0 +1,96 @@ +import * as schemas from 'har-schema'; +import Ajv from 'ajv'; +import HARError from './error'; + +let ajv; + +export function validate(name, data = {}, next) { + // validator config + ajv = ajv || new Ajv({ + allErrors: true, + schemas: schemas + }); + + let validate = ajv.getSchema(name + '.json'); + + let valid = validate(data); + + // callback? + if (typeof next === 'function') { + return next(!valid ? new HARError(validate.errors) : null, valid); + } + + return valid; +} + +export function afterRequest(data, next) { + return validate('afterRequest', data, next); +} + +export function beforeRequest(data, next) { + return validate('beforeRequest', data, next); +} + +export function browser(data, next) { + return validate('browser', data, next); +} + +export function cache(data, next) { + return validate('cache', data, next); +} + +export function content(data, next) { + return validate('content', data, next); +} + +export function cookie(data, next) { + return validate('cookie', data, next); +} + +export function creator(data, next) { + return validate('creator', data, next); +} + +export function entry(data, next) { + return validate('entry', data, next); +} + +export function har(data, next) { + return validate('har', data, next); +} + +export function header(data, next) { + return validate('header', data, next); +} + +export function log(data, next) { + return validate('log', data, next); +} + +export function page(data, next) { + return validate('page', data, next); +} + +export function pageTimings(data, next) { + return validate('pageTimings', data, next); +} + +export function postData(data, next) { + return validate('postData', data, next); +} + +export function query(data, next) { + return validate('query', data, next); +} + +export function request(data, next) { + return validate('request', data, next); +} + +export function response(data, next) { + return validate('response', data, next); +} + +export function timings(data, next) { + return validate('timings', data, next); +}
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/browser/error.js b/deps/npm/node_modules/har-validator/lib/browser/error.js new file mode 100644 index 0000000000..f49fcf231a --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/browser/error.js @@ -0,0 +1,15 @@ +export default function HARError(errors) { + let message = 'validation failed'; + + this.name = 'HARError'; + this.message = message; + this.errors = errors; + + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, this.constructor); + } else { + this.stack = new Error(message).stack; + } +} + +HARError.prototype = Error.prototype;
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/browser/promise.js b/deps/npm/node_modules/har-validator/lib/browser/promise.js new file mode 100644 index 0000000000..bc1b18c3f7 --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/browser/promise.js @@ -0,0 +1,93 @@ +import * as schemas from 'har-schema'; +import Ajv from 'ajv'; +import HARError from './error'; + +let ajv; + +export function validate(name, data = {}) { + // validator config + ajv = ajv || new Ajv({ + allErrors: true, + schemas: schemas + }); + + let validate = ajv.getSchema(name + '.json'); + + return new Promise((resolve, reject) => { + let valid = validate(data); + + !valid ? reject(new HARError(validate.errors)) : resolve(data); + }); +} + +export function afterRequest(data) { + return validate('afterRequest', data); +} + +export function beforeRequest(data) { + return validate('beforeRequest', data); +} + +export function browser(data) { + return validate('browser', data); +} + +export function cache(data) { + return validate('cache', data); +} + +export function content(data) { + return validate('content', data); +} + +export function cookie(data) { + return validate('cookie', data); +} + +export function creator(data) { + return validate('creator', data); +} + +export function entry(data) { + return validate('entry', data); +} + +export function har(data) { + return validate('har', data); +} + +export function header(data) { + return validate('header', data); +} + +export function log(data) { + return validate('log', data); +} + +export function page(data) { + return validate('page', data); +} + +export function pageTimings(data) { + return validate('pageTimings', data); +} + +export function postData(data) { + return validate('postData', data); +} + +export function query(data) { + return validate('query', data); +} + +export function request(data) { + return validate('request', data); +} + +export function response(data) { + return validate('response', data); +} + +export function timings(data) { + return validate('timings', data); +}
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/error.js b/deps/npm/node_modules/har-validator/lib/error.js deleted file mode 100644 index f2618dc4f3..0000000000 --- a/deps/npm/node_modules/har-validator/lib/error.js +++ /dev/null @@ -1,17 +0,0 @@ -function HARError (errors) { - var message = 'validation failed' - - this.name = 'HARError' - this.message = message - this.errors = errors - - if (typeof Error.captureStackTrace === 'function') { - Error.captureStackTrace(this, this.constructor) - } else { - this.stack = (new Error(message)).stack - } -} - -HARError.prototype = Error.prototype - -module.exports = HARError diff --git a/deps/npm/node_modules/har-validator/lib/node4/async.js b/deps/npm/node_modules/har-validator/lib/node4/async.js new file mode 100644 index 0000000000..e9c4854307 --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/node4/async.js @@ -0,0 +1,136 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.validate = validate; +exports.afterRequest = afterRequest; +exports.beforeRequest = beforeRequest; +exports.browser = browser; +exports.cache = cache; +exports.content = content; +exports.cookie = cookie; +exports.creator = creator; +exports.entry = entry; +exports.har = har; +exports.header = header; +exports.log = log; +exports.page = page; +exports.pageTimings = pageTimings; +exports.postData = postData; +exports.query = query; +exports.request = request; +exports.response = response; +exports.timings = timings; + +var _harSchema = require('har-schema'); + +var schemas = _interopRequireWildcard(_harSchema); + +var _ajv = require('ajv'); + +var _ajv2 = _interopRequireDefault(_ajv); + +var _error = require('./error'); + +var _error2 = _interopRequireDefault(_error); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +var ajv = void 0; + +function validate(name) { + var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var next = arguments[2]; + + // validator config + ajv = ajv || new _ajv2.default({ + allErrors: true, + schemas: schemas + }); + + var validate = ajv.getSchema(name + '.json'); + + var valid = validate(data); + + // callback? + if (typeof next === 'function') { + return next(!valid ? new _error2.default(validate.errors) : null, valid); + } + + return valid; +} + +function afterRequest(data, next) { + return validate('afterRequest', data, next); +} + +function beforeRequest(data, next) { + return validate('beforeRequest', data, next); +} + +function browser(data, next) { + return validate('browser', data, next); +} + +function cache(data, next) { + return validate('cache', data, next); +} + +function content(data, next) { + return validate('content', data, next); +} + +function cookie(data, next) { + return validate('cookie', data, next); +} + +function creator(data, next) { + return validate('creator', data, next); +} + +function entry(data, next) { + return validate('entry', data, next); +} + +function har(data, next) { + return validate('har', data, next); +} + +function header(data, next) { + return validate('header', data, next); +} + +function log(data, next) { + return validate('log', data, next); +} + +function page(data, next) { + return validate('page', data, next); +} + +function pageTimings(data, next) { + return validate('pageTimings', data, next); +} + +function postData(data, next) { + return validate('postData', data, next); +} + +function query(data, next) { + return validate('query', data, next); +} + +function request(data, next) { + return validate('request', data, next); +} + +function response(data, next) { + return validate('response', data, next); +} + +function timings(data, next) { + return validate('timings', data, next); +}
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/node4/error.js b/deps/npm/node_modules/har-validator/lib/node4/error.js new file mode 100644 index 0000000000..0ae01bd18c --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/node4/error.js @@ -0,0 +1,22 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = HARError; +function HARError(errors) { + var message = 'validation failed'; + + this.name = 'HARError'; + this.message = message; + this.errors = errors; + + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, this.constructor); + } else { + this.stack = new Error(message).stack; + } +} + +HARError.prototype = Error.prototype; +module.exports = exports['default'];
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/node4/promise.js b/deps/npm/node_modules/har-validator/lib/node4/promise.js new file mode 100644 index 0000000000..d37ca52ad7 --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/node4/promise.js @@ -0,0 +1,132 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.validate = validate; +exports.afterRequest = afterRequest; +exports.beforeRequest = beforeRequest; +exports.browser = browser; +exports.cache = cache; +exports.content = content; +exports.cookie = cookie; +exports.creator = creator; +exports.entry = entry; +exports.har = har; +exports.header = header; +exports.log = log; +exports.page = page; +exports.pageTimings = pageTimings; +exports.postData = postData; +exports.query = query; +exports.request = request; +exports.response = response; +exports.timings = timings; + +var _harSchema = require('har-schema'); + +var schemas = _interopRequireWildcard(_harSchema); + +var _ajv = require('ajv'); + +var _ajv2 = _interopRequireDefault(_ajv); + +var _error = require('./error'); + +var _error2 = _interopRequireDefault(_error); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +var ajv = void 0; + +function validate(name) { + var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + // validator config + ajv = ajv || new _ajv2.default({ + allErrors: true, + schemas: schemas + }); + + var validate = ajv.getSchema(name + '.json'); + + return new Promise(function (resolve, reject) { + var valid = validate(data); + + !valid ? reject(new _error2.default(validate.errors)) : resolve(data); + }); +} + +function afterRequest(data) { + return validate('afterRequest', data); +} + +function beforeRequest(data) { + return validate('beforeRequest', data); +} + +function browser(data) { + return validate('browser', data); +} + +function cache(data) { + return validate('cache', data); +} + +function content(data) { + return validate('content', data); +} + +function cookie(data) { + return validate('cookie', data); +} + +function creator(data) { + return validate('creator', data); +} + +function entry(data) { + return validate('entry', data); +} + +function har(data) { + return validate('har', data); +} + +function header(data) { + return validate('header', data); +} + +function log(data) { + return validate('log', data); +} + +function page(data) { + return validate('page', data); +} + +function pageTimings(data) { + return validate('pageTimings', data); +} + +function postData(data) { + return validate('postData', data); +} + +function query(data) { + return validate('query', data); +} + +function request(data) { + return validate('request', data); +} + +function response(data) { + return validate('response', data); +} + +function timings(data) { + return validate('timings', data); +}
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/node6/async.js b/deps/npm/node_modules/har-validator/lib/node6/async.js new file mode 100644 index 0000000000..e707043adf --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/node6/async.js @@ -0,0 +1,133 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.validate = validate; +exports.afterRequest = afterRequest; +exports.beforeRequest = beforeRequest; +exports.browser = browser; +exports.cache = cache; +exports.content = content; +exports.cookie = cookie; +exports.creator = creator; +exports.entry = entry; +exports.har = har; +exports.header = header; +exports.log = log; +exports.page = page; +exports.pageTimings = pageTimings; +exports.postData = postData; +exports.query = query; +exports.request = request; +exports.response = response; +exports.timings = timings; + +var _harSchema = require('har-schema'); + +var schemas = _interopRequireWildcard(_harSchema); + +var _ajv = require('ajv'); + +var _ajv2 = _interopRequireDefault(_ajv); + +var _error = require('./error'); + +var _error2 = _interopRequireDefault(_error); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +let ajv; + +function validate(name, data = {}, next) { + // validator config + ajv = ajv || new _ajv2.default({ + allErrors: true, + schemas: schemas + }); + + let validate = ajv.getSchema(name + '.json'); + + let valid = validate(data); + + // callback? + if (typeof next === 'function') { + return next(!valid ? new _error2.default(validate.errors) : null, valid); + } + + return valid; +} + +function afterRequest(data, next) { + return validate('afterRequest', data, next); +} + +function beforeRequest(data, next) { + return validate('beforeRequest', data, next); +} + +function browser(data, next) { + return validate('browser', data, next); +} + +function cache(data, next) { + return validate('cache', data, next); +} + +function content(data, next) { + return validate('content', data, next); +} + +function cookie(data, next) { + return validate('cookie', data, next); +} + +function creator(data, next) { + return validate('creator', data, next); +} + +function entry(data, next) { + return validate('entry', data, next); +} + +function har(data, next) { + return validate('har', data, next); +} + +function header(data, next) { + return validate('header', data, next); +} + +function log(data, next) { + return validate('log', data, next); +} + +function page(data, next) { + return validate('page', data, next); +} + +function pageTimings(data, next) { + return validate('pageTimings', data, next); +} + +function postData(data, next) { + return validate('postData', data, next); +} + +function query(data, next) { + return validate('query', data, next); +} + +function request(data, next) { + return validate('request', data, next); +} + +function response(data, next) { + return validate('response', data, next); +} + +function timings(data, next) { + return validate('timings', data, next); +}
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/node6/error.js b/deps/npm/node_modules/har-validator/lib/node6/error.js new file mode 100644 index 0000000000..4149ed7371 --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/node6/error.js @@ -0,0 +1,22 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = HARError; +function HARError(errors) { + let message = 'validation failed'; + + this.name = 'HARError'; + this.message = message; + this.errors = errors; + + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, this.constructor); + } else { + this.stack = new Error(message).stack; + } +} + +HARError.prototype = Error.prototype; +module.exports = exports['default'];
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/node6/promise.js b/deps/npm/node_modules/har-validator/lib/node6/promise.js new file mode 100644 index 0000000000..be7017ae05 --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/node6/promise.js @@ -0,0 +1,130 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.validate = validate; +exports.afterRequest = afterRequest; +exports.beforeRequest = beforeRequest; +exports.browser = browser; +exports.cache = cache; +exports.content = content; +exports.cookie = cookie; +exports.creator = creator; +exports.entry = entry; +exports.har = har; +exports.header = header; +exports.log = log; +exports.page = page; +exports.pageTimings = pageTimings; +exports.postData = postData; +exports.query = query; +exports.request = request; +exports.response = response; +exports.timings = timings; + +var _harSchema = require('har-schema'); + +var schemas = _interopRequireWildcard(_harSchema); + +var _ajv = require('ajv'); + +var _ajv2 = _interopRequireDefault(_ajv); + +var _error = require('./error'); + +var _error2 = _interopRequireDefault(_error); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +let ajv; + +function validate(name, data = {}) { + // validator config + ajv = ajv || new _ajv2.default({ + allErrors: true, + schemas: schemas + }); + + let validate = ajv.getSchema(name + '.json'); + + return new Promise((resolve, reject) => { + let valid = validate(data); + + !valid ? reject(new _error2.default(validate.errors)) : resolve(data); + }); +} + +function afterRequest(data) { + return validate('afterRequest', data); +} + +function beforeRequest(data) { + return validate('beforeRequest', data); +} + +function browser(data) { + return validate('browser', data); +} + +function cache(data) { + return validate('cache', data); +} + +function content(data) { + return validate('content', data); +} + +function cookie(data) { + return validate('cookie', data); +} + +function creator(data) { + return validate('creator', data); +} + +function entry(data) { + return validate('entry', data); +} + +function har(data) { + return validate('har', data); +} + +function header(data) { + return validate('header', data); +} + +function log(data) { + return validate('log', data); +} + +function page(data) { + return validate('page', data); +} + +function pageTimings(data) { + return validate('pageTimings', data); +} + +function postData(data) { + return validate('postData', data); +} + +function query(data) { + return validate('query', data); +} + +function request(data) { + return validate('request', data); +} + +function response(data) { + return validate('response', data); +} + +function timings(data) { + return validate('timings', data); +}
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/node7/async.js b/deps/npm/node_modules/har-validator/lib/node7/async.js new file mode 100644 index 0000000000..e707043adf --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/node7/async.js @@ -0,0 +1,133 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.validate = validate; +exports.afterRequest = afterRequest; +exports.beforeRequest = beforeRequest; +exports.browser = browser; +exports.cache = cache; +exports.content = content; +exports.cookie = cookie; +exports.creator = creator; +exports.entry = entry; +exports.har = har; +exports.header = header; +exports.log = log; +exports.page = page; +exports.pageTimings = pageTimings; +exports.postData = postData; +exports.query = query; +exports.request = request; +exports.response = response; +exports.timings = timings; + +var _harSchema = require('har-schema'); + +var schemas = _interopRequireWildcard(_harSchema); + +var _ajv = require('ajv'); + +var _ajv2 = _interopRequireDefault(_ajv); + +var _error = require('./error'); + +var _error2 = _interopRequireDefault(_error); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +let ajv; + +function validate(name, data = {}, next) { + // validator config + ajv = ajv || new _ajv2.default({ + allErrors: true, + schemas: schemas + }); + + let validate = ajv.getSchema(name + '.json'); + + let valid = validate(data); + + // callback? + if (typeof next === 'function') { + return next(!valid ? new _error2.default(validate.errors) : null, valid); + } + + return valid; +} + +function afterRequest(data, next) { + return validate('afterRequest', data, next); +} + +function beforeRequest(data, next) { + return validate('beforeRequest', data, next); +} + +function browser(data, next) { + return validate('browser', data, next); +} + +function cache(data, next) { + return validate('cache', data, next); +} + +function content(data, next) { + return validate('content', data, next); +} + +function cookie(data, next) { + return validate('cookie', data, next); +} + +function creator(data, next) { + return validate('creator', data, next); +} + +function entry(data, next) { + return validate('entry', data, next); +} + +function har(data, next) { + return validate('har', data, next); +} + +function header(data, next) { + return validate('header', data, next); +} + +function log(data, next) { + return validate('log', data, next); +} + +function page(data, next) { + return validate('page', data, next); +} + +function pageTimings(data, next) { + return validate('pageTimings', data, next); +} + +function postData(data, next) { + return validate('postData', data, next); +} + +function query(data, next) { + return validate('query', data, next); +} + +function request(data, next) { + return validate('request', data, next); +} + +function response(data, next) { + return validate('response', data, next); +} + +function timings(data, next) { + return validate('timings', data, next); +}
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/node7/error.js b/deps/npm/node_modules/har-validator/lib/node7/error.js new file mode 100644 index 0000000000..4149ed7371 --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/node7/error.js @@ -0,0 +1,22 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = HARError; +function HARError(errors) { + let message = 'validation failed'; + + this.name = 'HARError'; + this.message = message; + this.errors = errors; + + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, this.constructor); + } else { + this.stack = new Error(message).stack; + } +} + +HARError.prototype = Error.prototype; +module.exports = exports['default'];
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/node7/promise.js b/deps/npm/node_modules/har-validator/lib/node7/promise.js new file mode 100644 index 0000000000..be7017ae05 --- /dev/null +++ b/deps/npm/node_modules/har-validator/lib/node7/promise.js @@ -0,0 +1,130 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.validate = validate; +exports.afterRequest = afterRequest; +exports.beforeRequest = beforeRequest; +exports.browser = browser; +exports.cache = cache; +exports.content = content; +exports.cookie = cookie; +exports.creator = creator; +exports.entry = entry; +exports.har = har; +exports.header = header; +exports.log = log; +exports.page = page; +exports.pageTimings = pageTimings; +exports.postData = postData; +exports.query = query; +exports.request = request; +exports.response = response; +exports.timings = timings; + +var _harSchema = require('har-schema'); + +var schemas = _interopRequireWildcard(_harSchema); + +var _ajv = require('ajv'); + +var _ajv2 = _interopRequireDefault(_ajv); + +var _error = require('./error'); + +var _error2 = _interopRequireDefault(_error); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + +let ajv; + +function validate(name, data = {}) { + // validator config + ajv = ajv || new _ajv2.default({ + allErrors: true, + schemas: schemas + }); + + let validate = ajv.getSchema(name + '.json'); + + return new Promise((resolve, reject) => { + let valid = validate(data); + + !valid ? reject(new _error2.default(validate.errors)) : resolve(data); + }); +} + +function afterRequest(data) { + return validate('afterRequest', data); +} + +function beforeRequest(data) { + return validate('beforeRequest', data); +} + +function browser(data) { + return validate('browser', data); +} + +function cache(data) { + return validate('cache', data); +} + +function content(data) { + return validate('content', data); +} + +function cookie(data) { + return validate('cookie', data); +} + +function creator(data) { + return validate('creator', data); +} + +function entry(data) { + return validate('entry', data); +} + +function har(data) { + return validate('har', data); +} + +function header(data) { + return validate('header', data); +} + +function log(data) { + return validate('log', data); +} + +function page(data) { + return validate('page', data); +} + +function pageTimings(data) { + return validate('pageTimings', data); +} + +function postData(data) { + return validate('postData', data); +} + +function query(data) { + return validate('query', data); +} + +function request(data) { + return validate('request', data); +} + +function response(data) { + return validate('response', data); +} + +function timings(data) { + return validate('timings', data); +}
\ No newline at end of file diff --git a/deps/npm/node_modules/har-validator/lib/promise.js b/deps/npm/node_modules/har-validator/lib/promise.js deleted file mode 100644 index 1ab308cf71..0000000000 --- a/deps/npm/node_modules/har-validator/lib/promise.js +++ /dev/null @@ -1,95 +0,0 @@ -var Ajv = require('ajv') -var HARError = require('./error') -var schemas = require('har-schema') - -var ajv - -function validate (name, data) { - data = data || {} - - // validator config - ajv = ajv || new Ajv({ - allErrors: true, - schemas: schemas - }) - - var validate = ajv.getSchema(name + '.json') - - return new Promise(function (resolve, reject) { - var valid = validate(data) - - !valid ? reject(new HARError(validate.errors)) : resolve(data) - }) -} - -exports.afterRequest = function (data) { - return validate('afterRequest', data) -} - -exports.beforeRequest = function (data) { - return validate('beforeRequest', data) -} - -exports.browser = function (data) { - return validate('browser', data) -} - -exports.cache = function (data) { - return validate('cache', data) -} - -exports.content = function (data) { - return validate('content', data) -} - -exports.cookie = function (data) { - return validate('cookie', data) -} - -exports.creator = function (data) { - return validate('creator', data) -} - -exports.entry = function (data) { - return validate('entry', data) -} - -exports.har = function (data) { - return validate('har', data) -} - -exports.header = function (data) { - return validate('header', data) -} - -exports.log = function (data) { - return validate('log', data) -} - -exports.page = function (data) { - return validate('page', data) -} - -exports.pageTimings = function (data) { - return validate('pageTimings', data) -} - -exports.postData = function (data) { - return validate('postData', data) -} - -exports.query = function (data) { - return validate('query', data) -} - -exports.request = function (data) { - return validate('request', data) -} - -exports.response = function (data) { - return validate('response', data) -} - -exports.timings = function (data) { - return validate('timings', data) -} |