initial
This commit is contained in:
96
node_modules/har-validator/lib/browser/async.js
generated
vendored
Normal file
96
node_modules/har-validator/lib/browser/async.js
generated
vendored
Normal file
@@ -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);
|
||||
}
|
||||
15
node_modules/har-validator/lib/browser/error.js
generated
vendored
Normal file
15
node_modules/har-validator/lib/browser/error.js
generated
vendored
Normal file
@@ -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;
|
||||
93
node_modules/har-validator/lib/browser/promise.js
generated
vendored
Normal file
93
node_modules/har-validator/lib/browser/promise.js
generated
vendored
Normal file
@@ -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);
|
||||
}
|
||||
136
node_modules/har-validator/lib/node4/async.js
generated
vendored
Normal file
136
node_modules/har-validator/lib/node4/async.js
generated
vendored
Normal file
@@ -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);
|
||||
}
|
||||
22
node_modules/har-validator/lib/node4/error.js
generated
vendored
Normal file
22
node_modules/har-validator/lib/node4/error.js
generated
vendored
Normal file
@@ -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'];
|
||||
132
node_modules/har-validator/lib/node4/promise.js
generated
vendored
Normal file
132
node_modules/har-validator/lib/node4/promise.js
generated
vendored
Normal file
@@ -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);
|
||||
}
|
||||
133
node_modules/har-validator/lib/node6/async.js
generated
vendored
Normal file
133
node_modules/har-validator/lib/node6/async.js
generated
vendored
Normal file
@@ -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);
|
||||
}
|
||||
22
node_modules/har-validator/lib/node6/error.js
generated
vendored
Normal file
22
node_modules/har-validator/lib/node6/error.js
generated
vendored
Normal file
@@ -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'];
|
||||
130
node_modules/har-validator/lib/node6/promise.js
generated
vendored
Normal file
130
node_modules/har-validator/lib/node6/promise.js
generated
vendored
Normal file
@@ -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);
|
||||
}
|
||||
133
node_modules/har-validator/lib/node7/async.js
generated
vendored
Normal file
133
node_modules/har-validator/lib/node7/async.js
generated
vendored
Normal file
@@ -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);
|
||||
}
|
||||
22
node_modules/har-validator/lib/node7/error.js
generated
vendored
Normal file
22
node_modules/har-validator/lib/node7/error.js
generated
vendored
Normal file
@@ -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'];
|
||||
130
node_modules/har-validator/lib/node7/promise.js
generated
vendored
Normal file
130
node_modules/har-validator/lib/node7/promise.js
generated
vendored
Normal file
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user