Commit bf137ad8 authored by Patrick's avatar Patrick
Browse files

CHANGES.md, README.md und 248 weitere dateien aktualisiert...

Showing with 5167 additions and 4904 deletions
+5167 -4904
{
"$id": "timings.json#",
"$schema": "http://json-schema.org/draft-06/schema#",
"id": "timings.json#",
"required": [
"send",
"wait",
......
{
"_from": "har-schema@^2.0.0",
"_id": "har-schema@2.0.0",
"_from": "har-schema@^1.0.5",
"_id": "har-schema@1.0.5",
"_inBundle": false,
"_integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=",
"_integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=",
"_location": "/har-schema",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "har-schema@^2.0.0",
"raw": "har-schema@^1.0.5",
"name": "har-schema",
"escapedName": "har-schema",
"rawSpec": "^2.0.0",
"rawSpec": "^1.0.5",
"saveSpec": null,
"fetchSpec": "^2.0.0"
"fetchSpec": "^1.0.5"
},
"_requiredBy": [
"/har-validator"
],
"_resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
"_shasum": "a94c2224ebcac04782a0d9035521f24735b7ec92",
"_spec": "har-schema@^2.0.0",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\TV3\\NewVersion01\\dev\\node_modules\\har-validator",
"_resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz",
"_shasum": "d263135f43307c02c602afc8fe95970c0151369e",
"_spec": "har-schema@^1.0.5",
"_where": "C:\\Work\\OneDrive - bwstaff\\M4_Lab\\Main\\02_Plattform_Main\\m4labplatform\\node_modules\\har-validator",
"author": {
"name": "Ahmad Nassri",
"email": "ahmad@ahmadnassri.com",
......@@ -45,7 +45,7 @@
"deprecated": false,
"description": "JSON Schema for HTTP Archive (HAR)",
"devDependencies": {
"ajv": "^5.0.0",
"ajv": "^4.9.1",
"codeclimate-test-reporter": "^0.4.0",
"cz-conventional-changelog": "^1.2.0",
"echint": "^2.1.0",
......@@ -82,5 +82,5 @@
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"test": "tap test --reporter spec"
},
"version": "2.0.0"
"version": "1.0.5"
}
MIT License
Copyright (c) 2018 Ahmad Nassri <ahmad@ahmadnassri.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2015, Ahmad Nassri <ahmad@ahmadnassri.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# HAR Validator
[![License][license-image]][license-url] [![version][npm-image]][npm-url] [![Build Status][circle-image]][circle-url]
# HAR Validator [![version][npm-version]][npm-url] [![License][npm-license]][license-url]
> Extremely fast HTTP Archive ([HAR](https://github.com/ahmadnassri/har-spec/blob/master/versions/1.2.md)) validator using JSON Schema.
[![Build Status][travis-image]][travis-url]
[![Downloads][npm-downloads]][npm-url]
[![Code Climate][codeclimate-quality]][codeclimate-url]
[![Coverage Status][codeclimate-coverage]][codeclimate-url]
[![Dependency Status][dependencyci-image]][dependencyci-url]
[![Dependencies][david-image]][david-url]
## Install
```bash
npm install har-validator
npm install --only=production --save har-validator
```
## Usage
I recommend using an optimized build matching your Node.js environment version, otherwise, the standard `require` would work just fine with any version of Node `>= v4.0` .
```js
/*
* Node 7
*/
const validate = require('har-validator/lib/node7')
/*
* Node 6
*/
const validate = require('har-validator/lib/node6')
/*
* Node 4 (Default)
*/
var validate = require('har-validator')
```
## CLI Usage
......@@ -16,22 +42,34 @@ Please refer to [`har-cli`](https://github.com/ahmadnassri/har-cli) for more inf
## API
**Note**: as of [`v2.0.0`](https://github.com/ahmadnassri/node-har-validator/releases/tag/v2.0.0) this module defaults to Promise based API. _For backward compatibility with `v1.x` an [async/callback API](docs/async.md) is also provided_
**Note**: as of [`v2.0.0`](https://github.com/ahmadnassri/har-validator/releases/tag/v2.0.0) this module defaults to Promise based API. *For backward comptability with `v1.x` an [async/callback API](docs/async.md) is also provided*
- [async API](docs/async.md)
- [callback API](docs/async.md)
- [Promise API](docs/promise.md) _(default)_
- [Promise API](docs/promise.md) *(default)*
---
> Author: [Ahmad Nassri](https://www.ahmadnassri.com/) &bull;
> Github: [@ahmadnassri](https://github.com/ahmadnassri) &bull;
----
> :copyright: [ahmadnassri.com](https://www.ahmadnassri.com/) &nbsp;&middot;&nbsp;
> License: [ISC][license-url] &nbsp;&middot;&nbsp;
> Github: [@ahmadnassri](https://github.com/ahmadnassri) &nbsp;&middot;&nbsp;
> Twitter: [@ahmadnassri](https://twitter.com/ahmadnassri)
[license-url]: LICENSE
[license-image]: https://img.shields.io/github/license/ahmadnassri/node-har-validator.svg?style=for-the-badge&logo=circleci
[license-url]: http://choosealicense.com/licenses/isc/
[circle-url]: https://circleci.com/gh/ahmadnassri/workflows/node-har-validator
[circle-image]: https://img.shields.io/circleci/project/github/ahmadnassri/node-har-validator/master.svg?style=for-the-badge&logo=circleci
[travis-url]: https://travis-ci.org/ahmadnassri/har-validator
[travis-image]: https://img.shields.io/travis/ahmadnassri/har-validator.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/har-validator
[npm-image]: https://img.shields.io/npm/v/har-validator.svg?style=for-the-badge&logo=npm
[npm-license]: https://img.shields.io/npm/l/har-validator.svg?style=flat-square
[npm-version]: https://img.shields.io/npm/v/har-validator.svg?style=flat-square
[npm-downloads]: https://img.shields.io/npm/dm/har-validator.svg?style=flat-square
[codeclimate-url]: https://codeclimate.com/github/ahmadnassri/har-validator
[codeclimate-quality]: https://img.shields.io/codeclimate/github/ahmadnassri/har-validator.svg?style=flat-square
[codeclimate-coverage]: https://img.shields.io/codeclimate/coverage/github/ahmadnassri/har-validator.svg?style=flat-square
[david-url]: https://david-dm.org/ahmadnassri/har-validator
[david-image]: https://img.shields.io/david/ahmadnassri/har-validator.svg?style=flat-square
[dependencyci-url]: https://dependencyci.com/github/ahmadnassri/har-validator
[dependencyci-image]: https://dependencyci.com/github/ahmadnassri/har-validator/badge?style=flat-square
var Ajv = require('ajv')
var HARError = require('./error')
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 || createAjvInstance()
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)
}
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
var Ajv = require('ajv')
var HARError = require('./error')
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 || createAjvInstance()
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)
}
var Ajv = require('ajv');
var ajv = new Ajv({allErrors: true});
var ajv = Ajv({allErrors: true});
var schema = {
"properties": {
......
The MIT License (MIT)
Copyright (c) 2015-2017 Evgeny Poberezkin
Copyright (c) 2015 Evgeny Poberezkin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
'use strict';
var MissingRefError = require('./error_classes').MissingRef;
module.exports = compileAsync;
/**
* Creates validating function for passed schema with asynchronous loading of missing schemas.
* `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema.
* @this Ajv
* @param {Object} schema schema object
* @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped
* @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function.
* @return {Promise} promise that resolves with a validating function.
*/
function compileAsync(schema, meta, callback) {
/* eslint no-shadow: 0 */
/* global Promise */
/* jshint validthis: true */
var self = this;
if (typeof this._opts.loadSchema != 'function')
throw new Error('options.loadSchema should be a function');
if (typeof meta == 'function') {
callback = meta;
meta = undefined;
}
var p = loadMetaSchemaOf(schema).then(function () {
var schemaObj = self._addSchema(schema, undefined, meta);
return schemaObj.validate || _compileAsync(schemaObj);
});
if (callback) {
p.then(
function(v) { callback(null, v); },
callback
);
}
return p;
function loadMetaSchemaOf(sch) {
var $schema = sch.$schema;
return $schema && !self.getSchema($schema)
? compileAsync.call(self, { $ref: $schema }, true)
: Promise.resolve();
}
function _compileAsync(schemaObj) {
try { return self._compile(schemaObj); }
catch(e) {
if (e instanceof MissingRefError) return loadMissingSchema(e);
throw e;
}
function loadMissingSchema(e) {
var ref = e.missingSchema;
if (added(ref)) throw new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved');
var schemaPromise = self._loadingSchemas[ref];
if (!schemaPromise) {
schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
schemaPromise.then(removePromise, removePromise);
}
return schemaPromise.then(function (sch) {
if (!added(ref)) {
return loadMetaSchemaOf(sch).then(function () {
if (!added(ref)) self.addSchema(sch, ref, undefined, meta);
});
}
}).then(function() {
return _compileAsync(schemaObj);
});
function removePromise() {
delete self._loadingSchemas[ref];
}
function added(ref) {
return self._refs[ref] || self._schemas[ref];
}
}
}
}
'use strict';
// do NOT remove this file - it would break pre-compiled schemas
// https://github.com/epoberezkin/ajv/issues/889
module.exports = require('fast-deep-equal');
/*eslint complexity: 0*/
module.exports = function equal(a, b) {
if (a === b) return true;
var arrA = Array.isArray(a)
, arrB = Array.isArray(b)
, i;
if (arrA && arrB) {
if (a.length != b.length) return false;
for (i = 0; i < a.length; i++)
if (!equal(a[i], b[i])) return false;
return true;
}
if (arrA != arrB) return false;
if (a && b && typeof a === 'object' && typeof b === 'object') {
var keys = Object.keys(a);
if (keys.length !== Object.keys(b).length) return false;
var dateA = a instanceof Date
, dateB = b instanceof Date;
if (dateA && dateB) return a.getTime() == b.getTime();
if (dateA != dateB) return false;
var regexpA = a instanceof RegExp
, regexpB = b instanceof RegExp;
if (regexpA && regexpB) return a.toString() == b.toString();
if (regexpA != regexpB) return false;
for (i = 0; i < keys.length; i++)
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
for (i = 0; i < keys.length; i++)
if(!equal(a[keys[i]], b[keys[i]])) return false;
return true;
}
return false;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment