http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/ajv.d.ts ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/ajv.d.ts b/node_modules/ajv/lib/ajv.d.ts deleted file mode 100644 index a45f931..0000000 --- a/node_modules/ajv/lib/ajv.d.ts +++ /dev/null @@ -1,282 +0,0 @@ -declare var ajv: { - (options?: ajv.Options): ajv.Ajv; - new (options?: ajv.Options): ajv.Ajv; -} - -declare namespace ajv { - interface Ajv { - /** - * Validate data using schema - * Schema will be compiled and cached (using serialized JSON as key. [json-stable-stringify](https://github.com/substack/json-stable-stringify) is used to serialize. - * @param {String|Object} schemaKeyRef key, ref or schema object - * @param {Any} data to be validated - * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`). - */ - validate(schemaKeyRef: Object | string, data: any): boolean; - /** - * Create validating function for passed schema. - * @param {Object} schema schema object - * @return {Function} validating function - */ - compile(schema: Object): ValidateFunction; - /** - * Creates validating function for passed schema with asynchronous loading of missing schemas. - * `loadSchema` option should be a function that accepts schema uri and node-style callback. - * @this Ajv - * @param {Object} schema schema object - * @param {Function} callback node-style callback, it is always called with 2 parameters: error (or null) and validating function. - */ - compileAsync(schema: Object, callback: (err: Error, validate: ValidateFunction) => any): void; - /** - * Adds schema to the instance. - * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored. - * @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`. - */ - addSchema(schema: Array<Object> | Object, key?: string): void; - /** - * Add schema that will be used to validate other schemas - * options in META_IGNORE_OPTIONS are alway set to false - * @param {Object} schema schema object - * @param {String} key optional schema key - */ - addMetaSchema(schema: Object, key?: string): void; - /** - * Validate schema - * @param {Object} schema schema to validate - * @return {Boolean} true if schema is valid - */ - validateSchema(schema: Object): boolean; - /** - * Get compiled schema from the instance by `key` or `ref`. - * @param {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id). - * @return {Function} schema validating function (with property `schema`). - */ - getSchema(keyRef: string): ValidateFunction; - /** - * Remove cached schema(s). - * If no parameter is passed all schemas but meta-schemas are removed. - * If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed. - * Even if schema is referenced by other schemas it still can be removed as other schemas have local references. - * @param {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object - */ - removeSchema(schemaKeyRef?: Object | string | RegExp): void; - /** - * Add custom format - * @param {String} name format name - * @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid) - */ - addFormat(name: string, format: FormatValidator | FormatDefinition): void; - /** - * Define custom keyword - * @this Ajv - * @param {String} keyword custom keyword, should be a valid identifier, should be different from all standard, custom and macro keywords. - * @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`. - */ - addKeyword(keyword: string, definition: KeywordDefinition): void; - /** - * Get keyword definition - * @this Ajv - * @param {String} keyword pre-defined or custom keyword. - * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise. - */ - getKeyword(keyword: string): Object | boolean; - /** - * Remove keyword - * @this Ajv - * @param {String} keyword pre-defined or custom keyword. - */ - removeKeyword(keyword: string): void; - /** - * Convert array of error message objects to string - * @param {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used. - * @param {Object} options optional options with properties `separator` and `dataVar`. - * @return {String} human readable string with all errors descriptions - */ - errorsText(errors?: Array<ErrorObject>, options?: ErrorsTextOptions): string; - errors?: Array<ErrorObject>; - } - - interface Thenable <R> { - then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>; - } - - interface ValidateFunction { - ( - data: any, - dataPath?: string, - parentData?: Object | Array<any>, - parentDataProperty?: string | number, - rootData?: Object | Array<any> - ): boolean | Thenable<boolean>; - errors?: Array<ErrorObject>; - schema?: Object; - } - - interface Options { - v5?: boolean; - allErrors?: boolean; - verbose?: boolean; - jsonPointers?: boolean; - uniqueItems?: boolean; - unicode?: boolean; - format?: string; - formats?: Object; - unknownFormats?: boolean | string | Array<string>; - schemas?: Array<Object> | Object; - ownProperties?: boolean; - missingRefs?: boolean | string; - loadSchema?: (uri: string, cb: (err: Error, schema: Object) => any) => any; - removeAdditional?: boolean | string; - useDefaults?: boolean | string; - coerceTypes?: boolean | string; - async?: boolean | string; - transpile?: string | ((code: string) => string); - meta?: boolean | Object; - validateSchema?: boolean | string; - addUsedSchema?: boolean; - inlineRefs?: boolean | number; - passContext?: boolean; - loopRequired?: number; - multipleOfPrecision?: number; - errorDataPath?: string; - messages?: boolean; - beautify?: boolean | Object; - cache?: Object; - } - - type FormatValidator = string | RegExp | ((data: string) => boolean); - - interface FormatDefinition { - validate: FormatValidator; - compare: (data1: string, data2: string) => number; - async?: boolean; - } - - interface KeywordDefinition { - type?: string | Array<string>; - async?: boolean; - errors?: boolean | string; - // schema: false makes validate not to expect schema (ValidateFunction) - schema?: boolean; - modifying?: boolean; - valid?: boolean; - // one and only one of the following properties should be present - validate?: ValidateFunction | SchemaValidateFunction; - compile?: (schema: Object, parentSchema: Object) => ValidateFunction; - macro?: (schema: Object, parentSchema: Object) => Object; - inline?: (it: Object, keyword: string, schema: Object, parentSchema: Object) => string; - } - - interface SchemaValidateFunction { - ( - schema: Object, - data: any, - parentSchema?: Object, - dataPath?: string, - parentData?: Object | Array<any>, - parentDataProperty?: string | number - ): boolean | Thenable<boolean>; - errors?: Array<ErrorObject>; - } - - interface ErrorsTextOptions { - separator?: string; - dataVar?: string; - } - - interface ErrorObject { - keyword: string; - dataPath: string; - schemaPath: string; - params: ErrorParameters; - // Excluded if messages set to false. - message?: string; - // These are added with the `verbose` option. - schema?: Object; - parentSchema?: Object; - data?: any; - } - - type ErrorParameters = RefParams | LimitParams | AdditionalPropertiesParams | - DependenciesParams | FormatParams | ComparisonParams | - MultipleOfParams | PatternParams | RequiredParams | - TypeParams | UniqueItemsParams | CustomParams | - PatternGroupsParams | PatternRequiredParams | - SwitchParams | NoParams | EnumParams; - - interface RefParams { - ref: string; - } - - interface LimitParams { - limit: number; - } - - interface AdditionalPropertiesParams { - additionalProperty: string; - } - - interface DependenciesParams { - property: string; - missingProperty: string; - depsCount: number; - deps: string; - } - - interface FormatParams { - format: string - } - - interface ComparisonParams { - comparison: string; - limit: number | string; - exclusive: boolean; - } - - interface MultipleOfParams { - multipleOf: number; - } - - interface PatternParams { - pattern: string; - } - - interface RequiredParams { - missingProperty: string; - } - - interface TypeParams { - type: string; - } - - interface UniqueItemsParams { - i: number; - j: number; - } - - interface CustomParams { - keyword: string; - } - - interface PatternGroupsParams { - reason: string; - limit: number; - pattern: string; - } - - interface PatternRequiredParams { - missingPattern: string; - } - - interface SwitchParams { - caseIndex: number; - } - - interface NoParams {} - - interface EnumParams { - allowedValues: Array<any>; - } -} - -export = ajv;
http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/ajv.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/ajv.js b/node_modules/ajv/lib/ajv.js deleted file mode 100644 index 0502c1f..0000000 --- a/node_modules/ajv/lib/ajv.js +++ /dev/null @@ -1,420 +0,0 @@ -'use strict'; - -var compileSchema = require('./compile') - , resolve = require('./compile/resolve') - , Cache = require('./cache') - , SchemaObject = require('./compile/schema_obj') - , stableStringify = require('json-stable-stringify') - , formats = require('./compile/formats') - , rules = require('./compile/rules') - , v5 = require('./v5') - , util = require('./compile/util') - , async = require('./async') - , co = require('co'); - -module.exports = Ajv; - -Ajv.prototype.compileAsync = async.compile; - -var customKeyword = require('./keyword'); -Ajv.prototype.addKeyword = customKeyword.add; -Ajv.prototype.getKeyword = customKeyword.get; -Ajv.prototype.removeKeyword = customKeyword.remove; -Ajv.ValidationError = require('./compile/validation_error'); - -var META_SCHEMA_ID = 'http://json-schema.org/draft-04/schema'; -var SCHEMA_URI_FORMAT = /^(?:(?:[a-z][a-z0-9+-.]*:)?\/\/)?[^\s]*$/i; -function SCHEMA_URI_FORMAT_FUNC(str) { - return SCHEMA_URI_FORMAT.test(str); -} - -var META_IGNORE_OPTIONS = [ 'removeAdditional', 'useDefaults', 'coerceTypes' ]; - -/** - * Creates validator instance. - * Usage: `Ajv(opts)` - * @param {Object} opts optional options - * @return {Object} ajv instance - */ -function Ajv(opts) { - if (!(this instanceof Ajv)) return new Ajv(opts); - var self = this; - - opts = this._opts = util.copy(opts) || {}; - this._schemas = {}; - this._refs = {}; - this._fragments = {}; - this._formats = formats(opts.format); - this._cache = opts.cache || new Cache; - this._loadingSchemas = {}; - this._compilations = []; - this.RULES = rules(); - - // this is done on purpose, so that methods are bound to the instance - // (without using bind) so that they can be used without the instance - this.validate = validate; - this.compile = compile; - this.addSchema = addSchema; - this.addMetaSchema = addMetaSchema; - this.validateSchema = validateSchema; - this.getSchema = getSchema; - this.removeSchema = removeSchema; - this.addFormat = addFormat; - this.errorsText = errorsText; - - this._addSchema = _addSchema; - this._compile = _compile; - - opts.loopRequired = opts.loopRequired || Infinity; - if (opts.async || opts.transpile) async.setup(opts); - if (opts.beautify === true) opts.beautify = { indent_size: 2 }; - if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true; - this._metaOpts = getMetaSchemaOptions(); - - if (opts.formats) addInitialFormats(); - addDraft4MetaSchema(); - if (opts.v5) v5.enable(this); - if (typeof opts.meta == 'object') addMetaSchema(opts.meta); - addInitialSchemas(); - - - /** - * Validate data using schema - * Schema will be compiled and cached (using serialized JSON as key. [json-stable-stringify](https://github.com/substack/json-stable-stringify) is used to serialize. - * @param {String|Object} schemaKeyRef key, ref or schema object - * @param {Any} data to be validated - * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`). - */ - function validate(schemaKeyRef, data) { - var v; - if (typeof schemaKeyRef == 'string') { - v = getSchema(schemaKeyRef); - if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"'); - } else { - var schemaObj = _addSchema(schemaKeyRef); - v = schemaObj.validate || _compile(schemaObj); - } - - var valid = v(data); - if (v.$async === true) - return self._opts.async == '*' ? co(valid) : valid; - self.errors = v.errors; - return valid; - } - - - /** - * Create validating function for passed schema. - * @param {Object} schema schema object - * @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords. - * @return {Function} validating function - */ - function compile(schema, _meta) { - var schemaObj = _addSchema(schema, undefined, _meta); - return schemaObj.validate || _compile(schemaObj); - } - - - /** - * Adds schema to the instance. - * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored. - * @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`. - * @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead. - * @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead. - */ - function addSchema(schema, key, _skipValidation, _meta) { - if (Array.isArray(schema)){ - for (var i=0; i<schema.length; i++) addSchema(schema[i], undefined, _skipValidation, _meta); - return; - } - // can key/id have # inside? - key = resolve.normalizeId(key || schema.id); - checkUnique(key); - self._schemas[key] = _addSchema(schema, _skipValidation, _meta, true); - } - - - /** - * Add schema that will be used to validate other schemas - * options in META_IGNORE_OPTIONS are alway set to false - * @param {Object} schema schema object - * @param {String} key optional schema key - * @param {Boolean} skipValidation true to skip schema validation, can be used to override validateSchema option for meta-schema - */ - function addMetaSchema(schema, key, skipValidation) { - addSchema(schema, key, skipValidation, true); - } - - - /** - * Validate schema - * @param {Object} schema schema to validate - * @param {Boolean} throwOrLogError pass true to throw (or log) an error if invalid - * @return {Boolean} true if schema is valid - */ - function validateSchema(schema, throwOrLogError) { - var $schema = schema.$schema || self._opts.defaultMeta || defaultMeta(); - var currentUriFormat = self._formats.uri; - self._formats.uri = typeof currentUriFormat == 'function' - ? SCHEMA_URI_FORMAT_FUNC - : SCHEMA_URI_FORMAT; - var valid; - try { valid = validate($schema, schema); } - finally { self._formats.uri = currentUriFormat; } - if (!valid && throwOrLogError) { - var message = 'schema is invalid: ' + errorsText(); - if (self._opts.validateSchema == 'log') console.error(message); - else throw new Error(message); - } - return valid; - } - - - function defaultMeta() { - var meta = self._opts.meta; - self._opts.defaultMeta = typeof meta == 'object' - ? meta.id || meta - : self._opts.v5 - ? v5.META_SCHEMA_ID - : META_SCHEMA_ID; - return self._opts.defaultMeta; - } - - - /** - * Get compiled schema from the instance by `key` or `ref`. - * @param {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id). - * @return {Function} schema validating function (with property `schema`). - */ - function getSchema(keyRef) { - var schemaObj = _getSchemaObj(keyRef); - switch (typeof schemaObj) { - case 'object': return schemaObj.validate || _compile(schemaObj); - case 'string': return getSchema(schemaObj); - case 'undefined': return _getSchemaFragment(keyRef); - } - } - - - function _getSchemaFragment(ref) { - var res = resolve.schema.call(self, { schema: {} }, ref); - if (res) { - var schema = res.schema - , root = res.root - , baseId = res.baseId; - var v = compileSchema.call(self, schema, root, undefined, baseId); - self._fragments[ref] = new SchemaObject({ - ref: ref, - fragment: true, - schema: schema, - root: root, - baseId: baseId, - validate: v - }); - return v; - } - } - - - function _getSchemaObj(keyRef) { - keyRef = resolve.normalizeId(keyRef); - return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef]; - } - - - /** - * Remove cached schema(s). - * If no parameter is passed all schemas but meta-schemas are removed. - * If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed. - * Even if schema is referenced by other schemas it still can be removed as other schemas have local references. - * @param {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object - */ - function removeSchema(schemaKeyRef) { - if (schemaKeyRef instanceof RegExp) { - _removeAllSchemas(self._schemas, schemaKeyRef); - _removeAllSchemas(self._refs, schemaKeyRef); - return; - } - switch (typeof schemaKeyRef) { - case 'undefined': - _removeAllSchemas(self._schemas); - _removeAllSchemas(self._refs); - self._cache.clear(); - return; - case 'string': - var schemaObj = _getSchemaObj(schemaKeyRef); - if (schemaObj) self._cache.del(schemaObj.jsonStr); - delete self._schemas[schemaKeyRef]; - delete self._refs[schemaKeyRef]; - return; - case 'object': - var jsonStr = stableStringify(schemaKeyRef); - self._cache.del(jsonStr); - var id = schemaKeyRef.id; - if (id) { - id = resolve.normalizeId(id); - delete self._schemas[id]; - delete self._refs[id]; - } - } - } - - - function _removeAllSchemas(schemas, regex) { - for (var keyRef in schemas) { - var schemaObj = schemas[keyRef]; - if (!schemaObj.meta && (!regex || regex.test(keyRef))) { - self._cache.del(schemaObj.jsonStr); - delete schemas[keyRef]; - } - } - } - - - function _addSchema(schema, skipValidation, meta, shouldAddSchema) { - if (typeof schema != 'object') throw new Error('schema should be object'); - var jsonStr = stableStringify(schema); - var cached = self._cache.get(jsonStr); - if (cached) return cached; - - shouldAddSchema = shouldAddSchema || self._opts.addUsedSchema !== false; - - var id = resolve.normalizeId(schema.id); - if (id && shouldAddSchema) checkUnique(id); - - var willValidate = self._opts.validateSchema !== false && !skipValidation; - var recursiveMeta; - if (willValidate && !(recursiveMeta = schema.id && schema.id == schema.$schema)) - validateSchema(schema, true); - - var localRefs = resolve.ids.call(self, schema); - - var schemaObj = new SchemaObject({ - id: id, - schema: schema, - localRefs: localRefs, - jsonStr: jsonStr, - meta: meta - }); - - if (id[0] != '#' && shouldAddSchema) self._refs[id] = schemaObj; - self._cache.put(jsonStr, schemaObj); - - if (willValidate && recursiveMeta) validateSchema(schema, true); - - return schemaObj; - } - - - function _compile(schemaObj, root) { - if (schemaObj.compiling) { - schemaObj.validate = callValidate; - callValidate.schema = schemaObj.schema; - callValidate.errors = null; - callValidate.root = root ? root : callValidate; - if (schemaObj.schema.$async === true) - callValidate.$async = true; - return callValidate; - } - schemaObj.compiling = true; - - var currentOpts; - if (schemaObj.meta) { - currentOpts = self._opts; - self._opts = self._metaOpts; - } - - var v; - try { v = compileSchema.call(self, schemaObj.schema, root, schemaObj.localRefs); } - finally { - schemaObj.compiling = false; - if (schemaObj.meta) self._opts = currentOpts; - } - - schemaObj.validate = v; - schemaObj.refs = v.refs; - schemaObj.refVal = v.refVal; - schemaObj.root = v.root; - return v; - - - function callValidate() { - var _validate = schemaObj.validate; - var result = _validate.apply(null, arguments); - callValidate.errors = _validate.errors; - return result; - } - } - - - /** - * Convert array of error message objects to string - * @param {Array<Object>} errors optional array of validation errors, if not passed errors from the instance are used. - * @param {Object} options optional options with properties `separator` and `dataVar`. - * @return {String} human readable string with all errors descriptions - */ - function errorsText(errors, options) { - errors = errors || self.errors; - if (!errors) return 'No errors'; - options = options || {}; - var separator = options.separator === undefined ? ', ' : options.separator; - var dataVar = options.dataVar === undefined ? 'data' : options.dataVar; - - var text = ''; - for (var i=0; i<errors.length; i++) { - var e = errors[i]; - if (e) text += dataVar + e.dataPath + ' ' + e.message + separator; - } - return text.slice(0, -separator.length); - } - - - /** - * Add custom format - * @param {String} name format name - * @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid) - */ - function addFormat(name, format) { - if (typeof format == 'string') format = new RegExp(format); - self._formats[name] = format; - } - - - function addDraft4MetaSchema() { - if (self._opts.meta !== false) { - var metaSchema = require('./refs/json-schema-draft-04.json'); - addMetaSchema(metaSchema, META_SCHEMA_ID, true); - self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID; - } - } - - - function addInitialSchemas() { - var optsSchemas = self._opts.schemas; - if (!optsSchemas) return; - if (Array.isArray(optsSchemas)) addSchema(optsSchemas); - else for (var key in optsSchemas) addSchema(optsSchemas[key], key); - } - - - function addInitialFormats() { - for (var name in self._opts.formats) { - var format = self._opts.formats[name]; - addFormat(name, format); - } - } - - - function checkUnique(id) { - if (self._schemas[id] || self._refs[id]) - throw new Error('schema with key or id "' + id + '" already exists'); - } - - - function getMetaSchemaOptions() { - var metaOpts = util.copy(self._opts); - for (var i=0; i<META_IGNORE_OPTIONS.length; i++) - delete metaOpts[META_IGNORE_OPTIONS[i]]; - return metaOpts; - } -} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/async.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/async.js b/node_modules/ajv/lib/async.js deleted file mode 100644 index 173c2c0..0000000 --- a/node_modules/ajv/lib/async.js +++ /dev/null @@ -1,218 +0,0 @@ -'use strict'; - -module.exports = { - setup: setupAsync, - compile: compileAsync -}; - - -var util = require('./compile/util'); - -var ASYNC = { - '*': checkGenerators, - 'co*': checkGenerators, - 'es7': checkAsyncFunction -}; - -var TRANSPILE = { - 'nodent': getNodent, - 'regenerator': getRegenerator -}; - -var MODES = [ - { async: 'co*' }, - { async: 'es7', transpile: 'nodent' }, - { async: 'co*', transpile: 'regenerator' } -]; - - -var regenerator, nodent; - - -function setupAsync(opts, required) { - if (required !== false) required = true; - var async = opts.async - , transpile = opts.transpile - , check; - - switch (typeof transpile) { - case 'string': - var get = TRANSPILE[transpile]; - if (!get) throw new Error('bad transpiler: ' + transpile); - return (opts._transpileFunc = get(opts, required)); - case 'undefined': - case 'boolean': - if (typeof async == 'string') { - check = ASYNC[async]; - if (!check) throw new Error('bad async mode: ' + async); - return (opts.transpile = check(opts, required)); - } - - for (var i=0; i<MODES.length; i++) { - var _opts = MODES[i]; - if (setupAsync(_opts, false)) { - util.copy(_opts, opts); - return opts.transpile; - } - } - /* istanbul ignore next */ - throw new Error('generators, nodent and regenerator are not available'); - case 'function': - return (opts._transpileFunc = opts.transpile); - default: - throw new Error('bad transpiler: ' + transpile); - } -} - - -function checkGenerators(opts, required) { - /* jshint evil: true */ - try { - (new Function('(function*(){})()'))(); - return true; - } catch(e) { - /* istanbul ignore next */ - if (required) throw new Error('generators not supported'); - } -} - - -function checkAsyncFunction(opts, required) { - /* jshint evil: true */ - try { - (new Function('(async function(){})()'))(); - /* istanbul ignore next */ - return true; - } catch(e) { - if (required) throw new Error('es7 async functions not supported'); - } -} - - -function getRegenerator(opts, required) { - try { - if (!regenerator) { - var name = 'regenerator'; - regenerator = require(name); - regenerator.runtime(); - } - if (!opts.async || opts.async === true) - opts.async = 'es7'; - return regeneratorTranspile; - } catch(e) { - /* istanbul ignore next */ - if (required) throw new Error('regenerator not available'); - } -} - - -function regeneratorTranspile(code) { - return regenerator.compile(code).code; -} - - -function getNodent(opts, required) { - /* jshint evil: true */ - try { - if (!nodent) { - var name = 'nodent'; - nodent = require(name)({ log: false, dontInstallRequireHook: true }); - } - if (opts.async != 'es7') { - if (opts.async && opts.async !== true) console.warn('nodent transpiles only es7 async functions'); - opts.async = 'es7'; - } - return nodentTranspile; - } catch(e) { - /* istanbul ignore next */ - if (required) throw new Error('nodent not available'); - } -} - - -function nodentTranspile(code) { - return nodent.compile(code, '', { promises: true, sourcemap: false }).code; -} - - -/** - * Creates validating function for passed schema with asynchronous loading of missing schemas. - * `loadSchema` option should be a function that accepts schema uri and node-style callback. - * @this Ajv - * @param {Object} schema schema object - * @param {Function} callback node-style callback, it is always called with 2 parameters: error (or null) and validating function. - */ -function compileAsync(schema, callback) { - /* eslint no-shadow: 0 */ - /* jshint validthis: true */ - var schemaObj; - var self = this; - try { - schemaObj = this._addSchema(schema); - } catch(e) { - setTimeout(function() { callback(e); }); - return; - } - if (schemaObj.validate) { - setTimeout(function() { callback(null, schemaObj.validate); }); - } else { - if (typeof this._opts.loadSchema != 'function') - throw new Error('options.loadSchema should be a function'); - _compileAsync(schema, callback, true); - } - - - function _compileAsync(schema, callback, firstCall) { - var validate; - try { validate = self.compile(schema); } - catch(e) { - if (e.missingSchema) loadMissingSchema(e); - else deferCallback(e); - return; - } - deferCallback(null, validate); - - function loadMissingSchema(e) { - var ref = e.missingSchema; - if (self._refs[ref] || self._schemas[ref]) - return callback(new Error('Schema ' + ref + ' is loaded but ' + e.missingRef + ' cannot be resolved')); - var _callbacks = self._loadingSchemas[ref]; - if (_callbacks) { - if (typeof _callbacks == 'function') - self._loadingSchemas[ref] = [_callbacks, schemaLoaded]; - else - _callbacks[_callbacks.length] = schemaLoaded; - } else { - self._loadingSchemas[ref] = schemaLoaded; - self._opts.loadSchema(ref, function (err, sch) { - var _callbacks = self._loadingSchemas[ref]; - delete self._loadingSchemas[ref]; - if (typeof _callbacks == 'function') { - _callbacks(err, sch); - } else { - for (var i=0; i<_callbacks.length; i++) - _callbacks[i](err, sch); - } - }); - } - - function schemaLoaded(err, sch) { - if (err) return callback(err); - if (!(self._refs[ref] || self._schemas[ref])) { - try { - self.addSchema(sch, ref); - } catch(e) { - callback(e); - return; - } - } - _compileAsync(schema, callback); - } - } - - function deferCallback(err, validate) { - if (firstCall) setTimeout(function() { callback(err, validate); }); - else return callback(err, validate); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/cache.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/cache.js b/node_modules/ajv/lib/cache.js deleted file mode 100644 index 7558874..0000000 --- a/node_modules/ajv/lib/cache.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - - -var Cache = module.exports = function Cache() { - this._cache = {}; -}; - - -Cache.prototype.put = function Cache_put(key, value) { - this._cache[key] = value; -}; - - -Cache.prototype.get = function Cache_get(key) { - return this._cache[key]; -}; - - -Cache.prototype.del = function Cache_del(key) { - delete this._cache[key]; -}; - - -Cache.prototype.clear = function Cache_clear() { - this._cache = {}; -}; http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/compile/_rules.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/compile/_rules.js b/node_modules/ajv/lib/compile/_rules.js deleted file mode 100644 index c98610e..0000000 --- a/node_modules/ajv/lib/compile/_rules.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -//all requires must be explicit because browserify won't work with dynamic requires -module.exports = { - '$ref': require('../dotjs/ref'), - allOf: require('../dotjs/allOf'), - anyOf: require('../dotjs/anyOf'), - dependencies: require('../dotjs/dependencies'), - 'enum': require('../dotjs/enum'), - format: require('../dotjs/format'), - items: require('../dotjs/items'), - maximum: require('../dotjs/_limit'), - minimum: require('../dotjs/_limit'), - maxItems: require('../dotjs/_limitItems'), - minItems: require('../dotjs/_limitItems'), - maxLength: require('../dotjs/_limitLength'), - minLength: require('../dotjs/_limitLength'), - maxProperties: require('../dotjs/_limitProperties'), - minProperties: require('../dotjs/_limitProperties'), - multipleOf: require('../dotjs/multipleOf'), - not: require('../dotjs/not'), - oneOf: require('../dotjs/oneOf'), - pattern: require('../dotjs/pattern'), - properties: require('../dotjs/properties'), - required: require('../dotjs/required'), - uniqueItems: require('../dotjs/uniqueItems'), - validate: require('../dotjs/validate') -}; http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/compile/equal.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/compile/equal.js b/node_modules/ajv/lib/compile/equal.js deleted file mode 100644 index 2a91874..0000000 --- a/node_modules/ajv/lib/compile/equal.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -/*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; -}; http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/compile/formats.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/compile/formats.js b/node_modules/ajv/lib/compile/formats.js deleted file mode 100644 index 415389e..0000000 --- a/node_modules/ajv/lib/compile/formats.js +++ /dev/null @@ -1,164 +0,0 @@ -'use strict'; - -var util = require('./util'); - -var DATE = /^\d\d\d\d-(\d\d)-(\d\d)$/; -var DAYS = [0,31,29,31,30,31,30,31,31,30,31,30,31]; -var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d:\d\d)?$/i; -var HOSTNAME = /^[0-9a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?(\.[0-9a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?)*$/i; -var URI = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{ 2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9a-f]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9a-f]{2})*)?$/i; -var UUID = /^(?:urn\:uuid\:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i; -var JSON_POINTER = /^(?:\/(?:[^~\/]|~0|~1)*)*$|^\#(?:\/(?:[a-z0-9_\-\.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i; -var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:\#|(?:\/(?:[^~\/]|~0|~1)*)*)$/; - - -module.exports = formats; - -function formats(mode) { - mode = mode == 'full' ? 'full' : 'fast'; - var formatDefs = util.copy(formats[mode]); - for (var fName in formats.compare) { - formatDefs[fName] = { - validate: formatDefs[fName], - compare: formats.compare[fName] - }; - } - return formatDefs; -} - - -formats.fast = { - // date: http://tools.ietf.org/html/rfc3339#section-5.6 - date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/, - // date-time: http://tools.ietf.org/html/rfc3339#section-5.6 - time: /^[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)?$/i, - 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s][0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:z|[+-]\d\d:\d\d)$/i, - // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js - uri: /^(?:[a-z][a-z0-9+-.]*)?(?:\:|\/)\/?[^\s]*$/i, - // email (sources from jsen validator): - // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363 - // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation') - email: /^[a-z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i, - hostname: HOSTNAME, - // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html - ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, - // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses - ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1 -9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i, - regex: regex, - // uuid: http://tools.ietf.org/html/rfc4122 - uuid: UUID, - // JSON-pointer: https://tools.ietf.org/html/rfc6901 - // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A - 'json-pointer': JSON_POINTER, - // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00 - 'relative-json-pointer': RELATIVE_JSON_POINTER -}; - - -formats.full = { - date: date, - time: time, - 'date-time': date_time, - uri: uri, - email: /^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&''*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i, - hostname: hostname, - ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, - ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1 -9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i, - regex: regex, - uuid: UUID, - 'json-pointer': JSON_POINTER, - 'relative-json-pointer': RELATIVE_JSON_POINTER -}; - - -formats.compare = { - date: compareDate, - time: compareTime, - 'date-time': compareDateTime -}; - - -function date(str) { - // full-date from http://tools.ietf.org/html/rfc3339#section-5.6 - var matches = str.match(DATE); - if (!matches) return false; - - var month = +matches[1]; - var day = +matches[2]; - return month >= 1 && month <= 12 && day >= 1 && day <= DAYS[month]; -} - - -function time(str, full) { - var matches = str.match(TIME); - if (!matches) return false; - - var hour = matches[1]; - var minute = matches[2]; - var second = matches[3]; - var timeZone = matches[5]; - return hour <= 23 && minute <= 59 && second <= 59 && (!full || timeZone); -} - - -var DATE_TIME_SEPARATOR = /t|\s/i; -function date_time(str) { - // http://tools.ietf.org/html/rfc3339#section-5.6 - var dateTime = str.split(DATE_TIME_SEPARATOR); - return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true); -} - - -function hostname(str) { - // https://tools.ietf.org/html/rfc1034#section-3.5 - // https://tools.ietf.org/html/rfc1123#section-2 - return str.length <= 255 && HOSTNAME.test(str); -} - - -var NOT_URI_FRAGMENT = /\/|\:/; -function uri(str) { - // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "." - return NOT_URI_FRAGMENT.test(str) && URI.test(str); -} - - -function regex(str) { - try { - new RegExp(str); - return true; - } catch(e) { - return false; - } -} - - -function compareDate(d1, d2) { - if (!(d1 && d2)) return; - if (d1 > d2) return 1; - if (d1 < d2) return -1; - if (d1 === d2) return 0; -} - - -function compareTime(t1, t2) { - if (!(t1 && t2)) return; - t1 = t1.match(TIME); - t2 = t2.match(TIME); - if (!(t1 && t2)) return; - t1 = t1[1] + t1[2] + t1[3] + (t1[4]||''); - t2 = t2[1] + t2[2] + t2[3] + (t2[4]||''); - if (t1 > t2) return 1; - if (t1 < t2) return -1; - if (t1 === t2) return 0; -} - - -function compareDateTime(dt1, dt2) { - if (!(dt1 && dt2)) return; - dt1 = dt1.split(DATE_TIME_SEPARATOR); - dt2 = dt2.split(DATE_TIME_SEPARATOR); - var res = compareDate(dt1[0], dt2[0]); - if (res === undefined) return; - return res || compareTime(dt1[1], dt2[1]); -} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/compile/index.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/compile/index.js b/node_modules/ajv/lib/compile/index.js deleted file mode 100644 index c9c6730..0000000 --- a/node_modules/ajv/lib/compile/index.js +++ /dev/null @@ -1,390 +0,0 @@ -'use strict'; - -var resolve = require('./resolve') - , util = require('./util') - , stableStringify = require('json-stable-stringify') - , async = require('../async'); - -var beautify; - -function loadBeautify(){ - if (beautify === undefined) { - var name = 'js-beautify'; - try { beautify = require(name).js_beautify; } - catch(e) { beautify = false; } - } -} - -var validateGenerator = require('../dotjs/validate'); - -/** - * Functions below are used inside compiled validations function - */ - -var co = require('co'); -var ucs2length = util.ucs2length; -var equal = require('./equal'); - -// this error is thrown by async schemas to return validation errors via exception -var ValidationError = require('./validation_error'); - -module.exports = compile; - - -/** - * Compiles schema to validation function - * @this Ajv - * @param {Object} schema schema object - * @param {Object} root object with information about the root schema for this schema - * @param {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution - * @param {String} baseId base ID for IDs in the schema - * @return {Function} validation function - */ -function compile(schema, root, localRefs, baseId) { - /* jshint validthis: true, evil: true */ - /* eslint no-shadow: 0 */ - var self = this - , opts = this._opts - , refVal = [ undefined ] - , refs = {} - , patterns = [] - , patternsHash = {} - , defaults = [] - , defaultsHash = {} - , customRules = [] - , keepSourceCode = opts.sourceCode !== false; - - root = root || { schema: schema, refVal: refVal, refs: refs }; - - var c = checkCompiling.call(this, schema, root, baseId); - var compilation = this._compilations[c.index]; - if (c.compiling) return (compilation.callValidate = callValidate); - - var formats = this._formats; - var RULES = this.RULES; - - try { - var v = localCompile(schema, root, localRefs, baseId); - compilation.validate = v; - var cv = compilation.callValidate; - if (cv) { - cv.schema = v.schema; - cv.errors = null; - cv.refs = v.refs; - cv.refVal = v.refVal; - cv.root = v.root; - cv.$async = v.$async; - if (keepSourceCode) cv.sourceCode = v.sourceCode; - } - return v; - } finally { - endCompiling.call(this, schema, root, baseId); - } - - function callValidate() { - var validate = compilation.validate; - var result = validate.apply(null, arguments); - callValidate.errors = validate.errors; - return result; - } - - function localCompile(_schema, _root, localRefs, baseId) { - var isRoot = !_root || (_root && _root.schema == _schema); - if (_root.schema != root.schema) - return compile.call(self, _schema, _root, localRefs, baseId); - - var $async = _schema.$async === true; - if ($async && !opts.transpile) async.setup(opts); - - var sourceCode = validateGenerator({ - isTop: true, - schema: _schema, - isRoot: isRoot, - baseId: baseId, - root: _root, - schemaPath: '', - errSchemaPath: '#', - errorPath: '""', - RULES: RULES, - validate: validateGenerator, - util: util, - resolve: resolve, - resolveRef: resolveRef, - usePattern: usePattern, - useDefault: useDefault, - useCustomRule: useCustomRule, - opts: opts, - formats: formats, - self: self - }); - - sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode) - + vars(defaults, defaultCode) + vars(customRules, customRuleCode) - + sourceCode; - - if (opts.beautify) { - loadBeautify(); - /* istanbul ignore else */ - if (beautify) sourceCode = beautify(sourceCode, opts.beautify); - else console.error('"npm install js-beautify" to use beautify option'); - } - // console.log('\n\n\n *** \n', sourceCode); - var validate, validateCode - , transpile = opts._transpileFunc; - try { - validateCode = $async && transpile - ? transpile(sourceCode) - : sourceCode; - - var makeValidate = new Function( - 'self', - 'RULES', - 'formats', - 'root', - 'refVal', - 'defaults', - 'customRules', - 'co', - 'equal', - 'ucs2length', - 'ValidationError', - validateCode - ); - - validate = makeValidate( - self, - RULES, - formats, - root, - refVal, - defaults, - customRules, - co, - equal, - ucs2length, - ValidationError - ); - - refVal[0] = validate; - } catch(e) { - console.error('Error compiling schema, function code:', validateCode); - throw e; - } - - validate.schema = _schema; - validate.errors = null; - validate.refs = refs; - validate.refVal = refVal; - validate.root = isRoot ? validate : _root; - if ($async) validate.$async = true; - if (keepSourceCode) validate.sourceCode = sourceCode; - if (opts.sourceCode === true) { - validate.source = { - patterns: patterns, - defaults: defaults - }; - } - - return validate; - } - - function resolveRef(baseId, ref, isRoot) { - ref = resolve.url(baseId, ref); - var refIndex = refs[ref]; - var _refVal, refCode; - if (refIndex !== undefined) { - _refVal = refVal[refIndex]; - refCode = 'refVal[' + refIndex + ']'; - return resolvedRef(_refVal, refCode); - } - if (!isRoot && root.refs) { - var rootRefId = root.refs[ref]; - if (rootRefId !== undefined) { - _refVal = root.refVal[rootRefId]; - refCode = addLocalRef(ref, _refVal); - return resolvedRef(_refVal, refCode); - } - } - - refCode = addLocalRef(ref); - var v = resolve.call(self, localCompile, root, ref); - if (!v) { - var localSchema = localRefs && localRefs[ref]; - if (localSchema) { - v = resolve.inlineRef(localSchema, opts.inlineRefs) - ? localSchema - : compile.call(self, localSchema, root, localRefs, baseId); - } - } - - if (v) { - replaceLocalRef(ref, v); - return resolvedRef(v, refCode); - } - } - - function addLocalRef(ref, v) { - var refId = refVal.length; - refVal[refId] = v; - refs[ref] = refId; - return 'refVal' + refId; - } - - function replaceLocalRef(ref, v) { - var refId = refs[ref]; - refVal[refId] = v; - } - - function resolvedRef(refVal, code) { - return typeof refVal == 'object' - ? { code: code, schema: refVal, inline: true } - : { code: code, $async: refVal && refVal.$async }; - } - - function usePattern(regexStr) { - var index = patternsHash[regexStr]; - if (index === undefined) { - index = patternsHash[regexStr] = patterns.length; - patterns[index] = regexStr; - } - return 'pattern' + index; - } - - function useDefault(value) { - switch (typeof value) { - case 'boolean': - case 'number': - return '' + value; - case 'string': - return util.toQuotedString(value); - case 'object': - if (value === null) return 'null'; - var valueStr = stableStringify(value); - var index = defaultsHash[valueStr]; - if (index === undefined) { - index = defaultsHash[valueStr] = defaults.length; - defaults[index] = value; - } - return 'default' + index; - } - } - - function useCustomRule(rule, schema, parentSchema, it) { - var validateSchema = rule.definition.validateSchema; - if (validateSchema && self._opts.validateSchema !== false) { - var valid = validateSchema(schema); - if (!valid) { - var message = 'keyword schema is invalid: ' + self.errorsText(validateSchema.errors); - if (self._opts.validateSchema == 'log') console.error(message); - else throw new Error(message); - } - } - - var compile = rule.definition.compile - , inline = rule.definition.inline - , macro = rule.definition.macro; - - var validate; - if (compile) { - validate = compile.call(self, schema, parentSchema, it); - } else if (macro) { - validate = macro.call(self, schema, parentSchema, it); - if (opts.validateSchema !== false) self.validateSchema(validate, true); - } else if (inline) { - validate = inline.call(self, it, rule.keyword, schema, parentSchema); - } else { - validate = rule.definition.validate; - } - - var index = customRules.length; - customRules[index] = validate; - - return { - code: 'customRule' + index, - validate: validate - }; - } -} - - -/** - * Checks if the schema is currently compiled - * @this Ajv - * @param {Object} schema schema to compile - * @param {Object} root root object - * @param {String} baseId base schema ID - * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean) - */ -function checkCompiling(schema, root, baseId) { - /* jshint validthis: true */ - var index = compIndex.call(this, schema, root, baseId); - if (index >= 0) return { index: index, compiling: true }; - index = this._compilations.length; - this._compilations[index] = { - schema: schema, - root: root, - baseId: baseId - }; - return { index: index, compiling: false }; -} - - -/** - * Removes the schema from the currently compiled list - * @this Ajv - * @param {Object} schema schema to compile - * @param {Object} root root object - * @param {String} baseId base schema ID - */ -function endCompiling(schema, root, baseId) { - /* jshint validthis: true */ - var i = compIndex.call(this, schema, root, baseId); - if (i >= 0) this._compilations.splice(i, 1); -} - - -/** - * Index of schema compilation in the currently compiled list - * @this Ajv - * @param {Object} schema schema to compile - * @param {Object} root root object - * @param {String} baseId base schema ID - * @return {Integer} compilation index - */ -function compIndex(schema, root, baseId) { - /* jshint validthis: true */ - for (var i=0; i<this._compilations.length; i++) { - var c = this._compilations[i]; - if (c.schema == schema && c.root == root && c.baseId == baseId) return i; - } - return -1; -} - - -function patternCode(i, patterns) { - return 'var pattern' + i + ' = new RegExp(' + util.toQuotedString(patterns[i]) + ');'; -} - - -function defaultCode(i) { - return 'var default' + i + ' = defaults[' + i + '];'; -} - - -function refValCode(i, refVal) { - return refVal[i] ? 'var refVal' + i + ' = refVal[' + i + '];' : ''; -} - - -function customRuleCode(i) { - return 'var customRule' + i + ' = customRules[' + i + '];'; -} - - -function vars(arr, statement) { - if (!arr.length) return ''; - var code = ''; - for (var i=0; i<arr.length; i++) - code += statement(i, arr); - return code; -} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/compile/resolve.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/compile/resolve.js b/node_modules/ajv/lib/compile/resolve.js deleted file mode 100644 index db2b91f..0000000 --- a/node_modules/ajv/lib/compile/resolve.js +++ /dev/null @@ -1,267 +0,0 @@ -'use strict'; - -var url = require('url') - , equal = require('./equal') - , util = require('./util') - , SchemaObject = require('./schema_obj'); - -module.exports = resolve; - -resolve.normalizeId = normalizeId; -resolve.fullPath = getFullPath; -resolve.url = resolveUrl; -resolve.ids = resolveIds; -resolve.inlineRef = inlineRef; -resolve.schema = resolveSchema; - -/** - * [resolve and compile the references ($ref)] - * @this Ajv - * @param {Function} compile reference to schema compilation funciton (localCompile) - * @param {Object} root object with information about the root schema for the current schema - * @param {String} ref reference to resolve - * @return {Object|Function} schema object (if the schema can be inlined) or validation function - */ -function resolve(compile, root, ref) { - /* jshint validthis: true */ - var refVal = this._refs[ref]; - if (typeof refVal == 'string') { - if (this._refs[refVal]) refVal = this._refs[refVal]; - else return resolve.call(this, compile, root, refVal); - } - - refVal = refVal || this._schemas[ref]; - if (refVal instanceof SchemaObject) { - return inlineRef(refVal.schema, this._opts.inlineRefs) - ? refVal.schema - : refVal.validate || this._compile(refVal); - } - - var res = resolveSchema.call(this, root, ref); - var schema, v, baseId; - if (res) { - schema = res.schema; - root = res.root; - baseId = res.baseId; - } - - if (schema instanceof SchemaObject) { - v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId); - } else if (schema) { - v = inlineRef(schema, this._opts.inlineRefs) - ? schema - : compile.call(this, schema, root, undefined, baseId); - } - - return v; -} - - -/** - * Resolve schema, its root and baseId - * @this Ajv - * @param {Object} root root object with properties schema, refVal, refs - * @param {String} ref reference to resolve - * @return {Object} object with properties schema, root, baseId - */ -function resolveSchema(root, ref) { - /* jshint validthis: true */ - var p = url.parse(ref, false, true) - , refPath = _getFullPath(p) - , baseId = getFullPath(root.schema.id); - if (refPath !== baseId) { - var id = normalizeId(refPath); - var refVal = this._refs[id]; - if (typeof refVal == 'string') { - return resolveRecursive.call(this, root, refVal, p); - } else if (refVal instanceof SchemaObject) { - if (!refVal.validate) this._compile(refVal); - root = refVal; - } else { - refVal = this._schemas[id]; - if (refVal instanceof SchemaObject) { - if (!refVal.validate) this._compile(refVal); - if (id == normalizeId(ref)) - return { schema: refVal, root: root, baseId: baseId }; - root = refVal; - } else { - return; - } - } - if (!root.schema) return; - baseId = getFullPath(root.schema.id); - } - return getJsonPointer.call(this, p, baseId, root.schema, root); -} - - -/* @this Ajv */ -function resolveRecursive(root, ref, parsedRef) { - /* jshint validthis: true */ - var res = resolveSchema.call(this, root, ref); - if (res) { - var schema = res.schema; - var baseId = res.baseId; - root = res.root; - if (schema.id) baseId = resolveUrl(baseId, schema.id); - return getJsonPointer.call(this, parsedRef, baseId, schema, root); - } -} - - -var PREVENT_SCOPE_CHANGE = util.toHash(['properties', 'patternProperties', 'enum', 'dependencies', 'definitions']); -/* @this Ajv */ -function getJsonPointer(parsedRef, baseId, schema, root) { - /* jshint validthis: true */ - parsedRef.hash = parsedRef.hash || ''; - if (parsedRef.hash.slice(0,2) != '#/') return; - var parts = parsedRef.hash.split('/'); - - for (var i = 1; i < parts.length; i++) { - var part = parts[i]; - if (part) { - part = util.unescapeFragment(part); - schema = schema[part]; - if (!schema) break; - if (schema.id && !PREVENT_SCOPE_CHANGE[part]) baseId = resolveUrl(baseId, schema.id); - if (schema.$ref) { - var $ref = resolveUrl(baseId, schema.$ref); - var res = resolveSchema.call(this, root, $ref); - if (res) { - schema = res.schema; - root = res.root; - baseId = res.baseId; - } - } - } - } - if (schema && schema != root.schema) - return { schema: schema, root: root, baseId: baseId }; -} - - -var SIMPLE_INLINED = util.toHash([ - 'type', 'format', 'pattern', - 'maxLength', 'minLength', - 'maxProperties', 'minProperties', - 'maxItems', 'minItems', - 'maximum', 'minimum', - 'uniqueItems', 'multipleOf', - 'required', 'enum' -]); -function inlineRef(schema, limit) { - if (limit === false) return false; - if (limit === undefined || limit === true) return checkNoRef(schema); - else if (limit) return countKeys(schema) <= limit; -} - - -function checkNoRef(schema) { - var item; - if (Array.isArray(schema)) { - for (var i=0; i<schema.length; i++) { - item = schema[i]; - if (typeof item == 'object' && !checkNoRef(item)) return false; - } - } else { - for (var key in schema) { - if (key == '$ref') return false; - item = schema[key]; - if (typeof item == 'object' && !checkNoRef(item)) return false; - } - } - return true; -} - - -function countKeys(schema) { - var count = 0, item; - if (Array.isArray(schema)) { - for (var i=0; i<schema.length; i++) { - item = schema[i]; - if (typeof item == 'object') count += countKeys(item); - if (count == Infinity) return Infinity; - } - } else { - for (var key in schema) { - if (key == '$ref') return Infinity; - if (SIMPLE_INLINED[key]) { - count++; - } else { - item = schema[key]; - if (typeof item == 'object') count += countKeys(item) + 1; - if (count == Infinity) return Infinity; - } - } - } - return count; -} - - -function getFullPath(id, normalize) { - if (normalize !== false) id = normalizeId(id); - var p = url.parse(id, false, true); - return _getFullPath(p); -} - - -function _getFullPath(p) { - var protocolSeparator = p.protocol || p.href.slice(0,2) == '//' ? '//' : ''; - return (p.protocol||'') + protocolSeparator + (p.host||'') + (p.path||'') + '#'; -} - - -var TRAILING_SLASH_HASH = /#\/?$/; -function normalizeId(id) { - return id ? id.replace(TRAILING_SLASH_HASH, '') : ''; -} - - -function resolveUrl(baseId, id) { - id = normalizeId(id); - return url.resolve(baseId, id); -} - - -/* @this Ajv */ -function resolveIds(schema) { - /* eslint no-shadow: 0 */ - /* jshint validthis: true */ - var id = normalizeId(schema.id); - var localRefs = {}; - _resolveIds.call(this, schema, getFullPath(id, false), id); - return localRefs; - - /* @this Ajv */ - function _resolveIds(schema, fullPath, baseId) { - /* jshint validthis: true */ - if (Array.isArray(schema)) { - for (var i=0; i<schema.length; i++) - _resolveIds.call(this, schema[i], fullPath+'/'+i, baseId); - } else if (schema && typeof schema == 'object') { - if (typeof schema.id == 'string') { - var id = baseId = baseId - ? url.resolve(baseId, schema.id) - : schema.id; - id = normalizeId(id); - - var refVal = this._refs[id]; - if (typeof refVal == 'string') refVal = this._refs[refVal]; - if (refVal && refVal.schema) { - if (!equal(schema, refVal.schema)) - throw new Error('id "' + id + '" resolves to more than one schema'); - } else if (id != normalizeId(fullPath)) { - if (id[0] == '#') { - if (localRefs[id] && !equal(schema, localRefs[id])) - throw new Error('id "' + id + '" resolves to more than one schema'); - localRefs[id] = schema; - } else { - this._refs[id] = fullPath; - } - } - } - for (var key in schema) - _resolveIds.call(this, schema[key], fullPath+'/'+util.escapeFragment(key), baseId); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/compile/rules.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/compile/rules.js b/node_modules/ajv/lib/compile/rules.js deleted file mode 100644 index 39b1708..0000000 --- a/node_modules/ajv/lib/compile/rules.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -var ruleModules = require('./_rules') - , toHash = require('./util').toHash; - -module.exports = function rules() { - var RULES = [ - { type: 'number', - rules: [ 'maximum', 'minimum', 'multipleOf'] }, - { type: 'string', - rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] }, - { type: 'array', - rules: [ 'maxItems', 'minItems', 'uniqueItems', 'items' ] }, - { type: 'object', - rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'properties' ] }, - { rules: [ '$ref', 'enum', 'not', 'anyOf', 'oneOf', 'allOf' ] } - ]; - - var ALL = [ 'type', 'additionalProperties', 'patternProperties' ]; - var KEYWORDS = [ 'additionalItems', '$schema', 'id', 'title', 'description', 'default' ]; - var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ]; - RULES.all = toHash(ALL); - - RULES.forEach(function (group) { - group.rules = group.rules.map(function (keyword) { - ALL.push(keyword); - var rule = RULES.all[keyword] = { - keyword: keyword, - code: ruleModules[keyword] - }; - return rule; - }); - }); - - RULES.keywords = toHash(ALL.concat(KEYWORDS)); - RULES.types = toHash(TYPES); - RULES.custom = {}; - - return RULES; -}; http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/compile/schema_obj.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/compile/schema_obj.js b/node_modules/ajv/lib/compile/schema_obj.js deleted file mode 100644 index e7903b0..0000000 --- a/node_modules/ajv/lib/compile/schema_obj.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var util = require('./util'); - -module.exports = SchemaObject; - -function SchemaObject(obj) { - util.copy(obj, this); -} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/compile/ucs2length.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/compile/ucs2length.js b/node_modules/ajv/lib/compile/ucs2length.js deleted file mode 100644 index d193fb1..0000000 --- a/node_modules/ajv/lib/compile/ucs2length.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -// https://mathiasbynens.be/notes/javascript-encoding -// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode -module.exports = function ucs2length(str) { - var length = 0 - , len = str.length - , pos = 0 - , value; - while (pos < len) { - length++; - value = str.charCodeAt(pos++); - if (value >= 0xD800 && value <= 0xDBFF && pos < len) { - // high surrogate, and there is a next character - value = str.charCodeAt(pos); - if ((value & 0xFC00) == 0xDC00) pos++; // low surrogate - } - } - return length; -}; http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/compile/util.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/compile/util.js b/node_modules/ajv/lib/compile/util.js deleted file mode 100644 index 8451f83..0000000 --- a/node_modules/ajv/lib/compile/util.js +++ /dev/null @@ -1,257 +0,0 @@ -'use strict'; - - -module.exports = { - copy: copy, - checkDataType: checkDataType, - checkDataTypes: checkDataTypes, - coerceToTypes: coerceToTypes, - toHash: toHash, - getProperty: getProperty, - escapeQuotes: escapeQuotes, - ucs2length: require('./ucs2length'), - varOccurences: varOccurences, - varReplace: varReplace, - cleanUpCode: cleanUpCode, - cleanUpVarErrors: cleanUpVarErrors, - schemaHasRules: schemaHasRules, - schemaHasRulesExcept: schemaHasRulesExcept, - stableStringify: require('json-stable-stringify'), - toQuotedString: toQuotedString, - getPathExpr: getPathExpr, - getPath: getPath, - getData: getData, - unescapeFragment: unescapeFragment, - escapeFragment: escapeFragment, - escapeJsonPointer: escapeJsonPointer -}; - - -function copy(o, to) { - to = to || {}; - for (var key in o) to[key] = o[key]; - return to; -} - - -function checkDataType(dataType, data, negate) { - var EQUAL = negate ? ' !== ' : ' === ' - , AND = negate ? ' || ' : ' && ' - , OK = negate ? '!' : '' - , NOT = negate ? '' : '!'; - switch (dataType) { - case 'null': return data + EQUAL + 'null'; - case 'array': return OK + 'Array.isArray(' + data + ')'; - case 'object': return '(' + OK + data + AND + - 'typeof ' + data + EQUAL + '"object"' + AND + - NOT + 'Array.isArray(' + data + '))'; - case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND + - NOT + '(' + data + ' % 1)' + - AND + data + EQUAL + data + ')'; - default: return 'typeof ' + data + EQUAL + '"' + dataType + '"'; - } -} - - -function checkDataTypes(dataTypes, data) { - switch (dataTypes.length) { - case 1: return checkDataType(dataTypes[0], data, true); - default: - var code = ''; - var types = toHash(dataTypes); - if (types.array && types.object) { - code = types.null ? '(': '(!' + data + ' || '; - code += 'typeof ' + data + ' !== "object")'; - delete types.null; - delete types.array; - delete types.object; - } - if (types.number) delete types.integer; - for (var t in types) - code += (code ? ' && ' : '' ) + checkDataType(t, data, true); - - return code; - } -} - - -var COERCE_TO_TYPES = toHash([ 'string', 'number', 'integer', 'boolean', 'null' ]); -function coerceToTypes(optionCoerceTypes, dataTypes) { - if (Array.isArray(dataTypes)) { - var types = []; - for (var i=0; i<dataTypes.length; i++) { - var t = dataTypes[i]; - if (COERCE_TO_TYPES[t]) types[types.length] = t; - else if (optionCoerceTypes === 'array' && t === 'array') types[types.length] = t; - } - if (types.length) return types; - } else if (COERCE_TO_TYPES[dataTypes]) { - return [dataTypes]; - } else if (optionCoerceTypes === 'array' && dataTypes === 'array') { - return ['array']; - } -} - - -function toHash(arr) { - var hash = {}; - for (var i=0; i<arr.length; i++) hash[arr[i]] = true; - return hash; -} - - -var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i; -var SINGLE_QUOTE = /'|\\/g; -function getProperty(key) { - return typeof key == 'number' - ? '[' + key + ']' - : IDENTIFIER.test(key) - ? '.' + key - : "['" + escapeQuotes(key) + "']"; -} - - -function escapeQuotes(str) { - return str.replace(SINGLE_QUOTE, '\\$&') - .replace(/\n/g, '\\n') - .replace(/\r/g, '\\r') - .replace(/\f/g, '\\f') - .replace(/\t/g, '\\t'); -} - - -function varOccurences(str, dataVar) { - dataVar += '[^0-9]'; - var matches = str.match(new RegExp(dataVar, 'g')); - return matches ? matches.length : 0; -} - - -function varReplace(str, dataVar, expr) { - dataVar += '([^0-9])'; - expr = expr.replace(/\$/g, '$$$$'); - return str.replace(new RegExp(dataVar, 'g'), expr + '$1'); -} - - -var EMPTY_ELSE = /else\s*{\s*}/g - , EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g - , EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g; -function cleanUpCode(out) { - return out.replace(EMPTY_ELSE, '') - .replace(EMPTY_IF_NO_ELSE, '') - .replace(EMPTY_IF_WITH_ELSE, 'if (!($1))'); -} - - -var ERRORS_REGEXP = /[^v\.]errors/g - , REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g - , REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g - , RETURN_VALID = 'return errors === 0;' - , RETURN_TRUE = 'validate.errors = null; return true;' - , RETURN_ASYNC = /if \(errors === 0\) return true;\s*else throw new ValidationError\(vErrors\);/ - , RETURN_TRUE_ASYNC = 'return true;'; - -function cleanUpVarErrors(out, async) { - var matches = out.match(ERRORS_REGEXP); - if (!matches || matches.length !== 2) return out; - return async - ? out.replace(REMOVE_ERRORS_ASYNC, '') - .replace(RETURN_ASYNC, RETURN_TRUE_ASYNC) - : out.replace(REMOVE_ERRORS, '') - .replace(RETURN_VALID, RETURN_TRUE); -} - - -function schemaHasRules(schema, rules) { - for (var key in schema) if (rules[key]) return true; -} - - -function schemaHasRulesExcept(schema, rules, exceptKeyword) { - for (var key in schema) if (key != exceptKeyword && rules[key]) return true; -} - - -function toQuotedString(str) { - return '\'' + escapeQuotes(str) + '\''; -} - - -function getPathExpr(currentPath, expr, jsonPointers, isNumber) { - var path = jsonPointers // false by default - ? '\'/\' + ' + expr + (isNumber ? '' : '.replace(/~/g, \'~0\').replace(/\\//g, \'~1\')') - : (isNumber ? '\'[\' + ' + expr + ' + \']\'' : '\'[\\\'\' + ' + expr + ' + \'\\\']\''); - return joinPaths(currentPath, path); -} - - -function getPath(currentPath, prop, jsonPointers) { - var path = jsonPointers // false by default - ? toQuotedString('/' + escapeJsonPointer(prop)) - : toQuotedString(getProperty(prop)); - return joinPaths(currentPath, path); -} - - -var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/; -var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/; -function getData($data, lvl, paths) { - var up, jsonPointer, data, matches; - if ($data === '') return 'rootData'; - if ($data[0] == '/') { - if (!JSON_POINTER.test($data)) throw new Error('Invalid JSON-pointer: ' + $data); - jsonPointer = $data; - data = 'rootData'; - } else { - matches = $data.match(RELATIVE_JSON_POINTER); - if (!matches) throw new Error('Invalid JSON-pointer: ' + $data); - up = +matches[1]; - jsonPointer = matches[2]; - if (jsonPointer == '#') { - if (up >= lvl) throw new Error('Cannot access property/index ' + up + ' levels up, current level is ' + lvl); - return paths[lvl - up]; - } - - if (up > lvl) throw new Error('Cannot access data ' + up + ' levels up, current level is ' + lvl); - data = 'data' + ((lvl - up) || ''); - if (!jsonPointer) return data; - } - - var expr = data; - var segments = jsonPointer.split('/'); - for (var i=0; i<segments.length; i++) { - var segment = segments[i]; - if (segment) { - data += getProperty(unescapeJsonPointer(segment)); - expr += ' && ' + data; - } - } - return expr; -} - - -function joinPaths (a, b) { - if (a == '""') return b; - return (a + ' + ' + b).replace(/' \+ '/g, ''); -} - - -function unescapeFragment(str) { - return unescapeJsonPointer(decodeURIComponent(str)); -} - - -function escapeFragment(str) { - return encodeURIComponent(escapeJsonPointer(str)); -} - - -function escapeJsonPointer(str) { - return str.replace(/~/g, '~0').replace(/\//g, '~1'); -} - - -function unescapeJsonPointer(str) { - return str.replace(/~1/g, '/').replace(/~0/g, '~'); -} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/compile/validation_error.js ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/compile/validation_error.js b/node_modules/ajv/lib/compile/validation_error.js deleted file mode 100644 index 3c5c594..0000000 --- a/node_modules/ajv/lib/compile/validation_error.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = ValidationError; - - -function ValidationError(errors) { - this.message = 'validation failed'; - this.errors = errors; - this.ajv = this.validation = true; -} - - -ValidationError.prototype = Object.create(Error.prototype); -ValidationError.prototype.constructor = ValidationError; http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/dot/_limit.jst ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/dot/_limit.jst b/node_modules/ajv/lib/dot/_limit.jst deleted file mode 100644 index 21793d8..0000000 --- a/node_modules/ajv/lib/dot/_limit.jst +++ /dev/null @@ -1,49 +0,0 @@ -{{# def.definitions }} -{{# def.errors }} -{{# def.setupKeyword }} -{{# def.$data }} - -{{ - var $isMax = $keyword == 'maximum' - , $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum' - , $schemaExcl = it.schema[$exclusiveKeyword] - , $isDataExcl = it.opts.v5 && $schemaExcl && $schemaExcl.$data - , $op = $isMax ? '<' : '>' - , $notOp = $isMax ? '>' : '<'; -}} - -{{? $isDataExcl }} - {{ - var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr) - , $exclusive = 'exclusive' + $lvl - , $opExpr = 'op' + $lvl - , $opStr = '\' + ' + $opExpr + ' + \''; - }} - var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}}; - {{ $schemaValueExcl = 'schemaExcl' + $lvl; }} - - var exclusive{{=$lvl}}; - if (typeof {{=$schemaValueExcl}} != 'boolean' && typeof {{=$schemaValueExcl}} != 'undefined') { - {{ var $errorKeyword = $exclusiveKeyword; }} - {{# def.error:'_exclusiveLimit' }} - } else if({{# def.$dataNotType:'number' }} - ((exclusive{{=$lvl}} = {{=$schemaValueExcl}} === true) - ? {{=$data}} {{=$notOp}}= {{=$schemaValue}} - : {{=$data}} {{=$notOp}} {{=$schemaValue}}) - || {{=$data}} !== {{=$data}}) { - var op{{=$lvl}} = exclusive{{=$lvl}} ? '{{=$op}}' : '{{=$op}}='; -{{??}} - {{ - var $exclusive = $schemaExcl === true - , $opStr = $op; /*used in error*/ - if (!$exclusive) $opStr += '='; - var $opExpr = '\'' + $opStr + '\''; /*used in error*/ - }} - - if ({{# def.$dataNotType:'number' }} - {{=$data}} {{=$notOp}}{{?$exclusive}}={{?}} {{=$schemaValue}} - || {{=$data}} !== {{=$data}}) { -{{?}} - {{ var $errorKeyword = $keyword; }} - {{# def.error:'_limit' }} - } {{? $breakOnError }} else { {{?}} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/dot/_limitItems.jst ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/dot/_limitItems.jst b/node_modules/ajv/lib/dot/_limitItems.jst deleted file mode 100644 index a3e078e..0000000 --- a/node_modules/ajv/lib/dot/_limitItems.jst +++ /dev/null @@ -1,10 +0,0 @@ -{{# def.definitions }} -{{# def.errors }} -{{# def.setupKeyword }} -{{# def.$data }} - -{{ var $op = $keyword == 'maxItems' ? '>' : '<'; }} -if ({{# def.$dataNotType:'number' }} {{=$data}}.length {{=$op}} {{=$schemaValue}}) { - {{ var $errorKeyword = $keyword; }} - {{# def.error:'_limitItems' }} -} {{? $breakOnError }} else { {{?}} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/dot/_limitLength.jst ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/dot/_limitLength.jst b/node_modules/ajv/lib/dot/_limitLength.jst deleted file mode 100644 index cfc8dbb..0000000 --- a/node_modules/ajv/lib/dot/_limitLength.jst +++ /dev/null @@ -1,10 +0,0 @@ -{{# def.definitions }} -{{# def.errors }} -{{# def.setupKeyword }} -{{# def.$data }} - -{{ var $op = $keyword == 'maxLength' ? '>' : '<'; }} -if ({{# def.$dataNotType:'number' }} {{# def.strLength }} {{=$op}} {{=$schemaValue}}) { - {{ var $errorKeyword = $keyword; }} - {{# def.error:'_limitLength' }} -} {{? $breakOnError }} else { {{?}} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/dot/_limitProperties.jst ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/dot/_limitProperties.jst b/node_modules/ajv/lib/dot/_limitProperties.jst deleted file mode 100644 index da7ea77..0000000 --- a/node_modules/ajv/lib/dot/_limitProperties.jst +++ /dev/null @@ -1,10 +0,0 @@ -{{# def.definitions }} -{{# def.errors }} -{{# def.setupKeyword }} -{{# def.$data }} - -{{ var $op = $keyword == 'maxProperties' ? '>' : '<'; }} -if ({{# def.$dataNotType:'number' }} Object.keys({{=$data}}).length {{=$op}} {{=$schemaValue}}) { - {{ var $errorKeyword = $keyword; }} - {{# def.error:'_limitProperties' }} -} {{? $breakOnError }} else { {{?}} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/dot/allOf.jst ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/dot/allOf.jst b/node_modules/ajv/lib/dot/allOf.jst deleted file mode 100644 index 4c28363..0000000 --- a/node_modules/ajv/lib/dot/allOf.jst +++ /dev/null @@ -1,34 +0,0 @@ -{{# def.definitions }} -{{# def.errors }} -{{# def.setupKeyword }} -{{# def.setupNextLevel }} - -{{ - var $currentBaseId = $it.baseId - , $allSchemasEmpty = true; -}} - -{{~ $schema:$sch:$i }} - {{? {{# def.nonEmptySchema:$sch }} }} - {{ - $allSchemasEmpty = false; - $it.schema = $sch; - $it.schemaPath = $schemaPath + '[' + $i + ']'; - $it.errSchemaPath = $errSchemaPath + '/' + $i; - }} - - {{# def.insertSubschemaCode }} - - {{# def.ifResultValid }} - {{?}} -{{~}} - -{{? $breakOnError }} - {{? $allSchemasEmpty }} - if (true) { - {{??}} - {{= $closingBraces.slice(0,-1) }} - {{?}} -{{?}} - -{{# def.cleanUp }} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/dot/anyOf.jst ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/dot/anyOf.jst b/node_modules/ajv/lib/dot/anyOf.jst deleted file mode 100644 index 93c3cd8..0000000 --- a/node_modules/ajv/lib/dot/anyOf.jst +++ /dev/null @@ -1,48 +0,0 @@ -{{# def.definitions }} -{{# def.errors }} -{{# def.setupKeyword }} -{{# def.setupNextLevel }} - -{{ - var $noEmptySchema = $schema.every(function($sch) { - return {{# def.nonEmptySchema:$sch }}; - }); -}} -{{? $noEmptySchema }} - {{ var $currentBaseId = $it.baseId; }} - var {{=$errs}} = errors; - var {{=$valid}} = false; - - {{# def.setCompositeRule }} - - {{~ $schema:$sch:$i }} - {{ - $it.schema = $sch; - $it.schemaPath = $schemaPath + '[' + $i + ']'; - $it.errSchemaPath = $errSchemaPath + '/' + $i; - }} - - {{# def.insertSubschemaCode }} - - {{=$valid}} = {{=$valid}} || {{=$nextValid}}; - - if (!{{=$valid}}) { - {{ $closingBraces += '}'; }} - {{~}} - - {{# def.resetCompositeRule }} - - {{= $closingBraces }} - - if (!{{=$valid}}) { - {{# def.addError:'anyOf' }} - } else { - {{# def.resetErrors }} - {{? it.opts.allErrors }} } {{?}} - - {{# def.cleanUp }} -{{??}} - {{? $breakOnError }} - if (true) { - {{?}} -{{?}} http://git-wip-us.apache.org/repos/asf/incubator-griffin-site/blob/ca1c37a7/node_modules/ajv/lib/dot/coerce.def ---------------------------------------------------------------------- diff --git a/node_modules/ajv/lib/dot/coerce.def b/node_modules/ajv/lib/dot/coerce.def deleted file mode 100644 index 86e0e18..0000000 --- a/node_modules/ajv/lib/dot/coerce.def +++ /dev/null @@ -1,61 +0,0 @@ -{{## def.coerceType: - {{ - var $dataType = 'dataType' + $lvl - , $coerced = 'coerced' + $lvl; - }} - var {{=$dataType}} = typeof {{=$data}}; - {{? it.opts.coerceTypes == 'array'}} - if ({{=$dataType}} == 'object' && Array.isArray({{=$data}})) {{=$dataType}} = 'array'; - {{?}} - - var {{=$coerced}} = undefined; - - {{ var $bracesCoercion = ''; }} - {{~ $coerceToTypes:$type:$i }} - {{? $i }} - if ({{=$coerced}} === undefined) { - {{ $bracesCoercion += '}'; }} - {{?}} - - {{? it.opts.coerceTypes == 'array' && $type != 'array' }} - if ({{=$dataType}} == 'array' && {{=$data}}.length == 1) { - {{=$coerced}} = {{=$data}} = {{=$data}}[0]; - {{=$dataType}} = typeof {{=$data}}; - /*if ({{=$dataType}} == 'object' && Array.isArray({{=$data}})) {{=$dataType}} = 'array';*/ - } - {{?}} - - {{? $type == 'string' }} - if ({{=$dataType}} == 'number' || {{=$dataType}} == 'boolean') - {{=$coerced}} = '' + {{=$data}}; - else if ({{=$data}} === null) {{=$coerced}} = ''; - {{?? $type == 'number' || $type == 'integer' }} - if ({{=$dataType}} == 'boolean' || {{=$data}} === null - || ({{=$dataType}} == 'string' && {{=$data}} && {{=$data}} == +{{=$data}} - {{? $type == 'integer' }} && !({{=$data}} % 1){{?}})) - {{=$coerced}} = +{{=$data}}; - {{?? $type == 'boolean' }} - if ({{=$data}} === 'false' || {{=$data}} === 0 || {{=$data}} === null) - {{=$coerced}} = false; - else if ({{=$data}} === 'true' || {{=$data}} === 1) - {{=$coerced}} = true; - {{?? $type == 'null' }} - if ({{=$data}} === '' || {{=$data}} === 0 || {{=$data}} === false) - {{=$coerced}} = null; - {{?? it.opts.coerceTypes == 'array' && $type == 'array' }} - if ({{=$dataType}} == 'string' || {{=$dataType}} == 'number' || {{=$dataType}} == 'boolean' || {{=$data}} == null) - {{=$coerced}} = [{{=$data}}]; - {{?}} - {{~}} - - {{= $bracesCoercion }} - - if ({{=$coerced}} === undefined) { - {{# def.error:'type' }} - } else { - {{# def.setParentData }} - {{=$data}} = {{=$coerced}}; - {{? !$dataLvl }}if ({{=$parentData}} !== undefined){{?}} - {{=$parentData}}[{{=$parentDataProperty}}] = {{=$coerced}}; - } -#}}