From 6952631a5ad1dd1847a6761ca4b35508152398fe Mon Sep 17 00:00:00 2001 From: hellosean1025 Date: Tue, 6 Nov 2018 16:02:51 +0800 Subject: [PATCH] opti: npm publish --- .npmignore | 6 + .package.json.swp | Bin 16384 -> 0 bytes common/json-schema-mockjs.js | 1113 ----------------- common/parse-json-schema/index.js | 72 -- common/parse-json-schema/util/clone-obj.js | 33 - .../parse-json-schema/util/find-reference.js | 56 - common/parse-json-schema/util/helpers.js | 107 -- .../util/normalize-schema.js | 65 - .../parse-json-schema/util/resolve-schema.js | 53 - package.json | 6 +- 10 files changed, 9 insertions(+), 1502 deletions(-) create mode 100644 .npmignore delete mode 100644 .package.json.swp delete mode 100644 common/json-schema-mockjs.js delete mode 100644 common/parse-json-schema/index.js delete mode 100644 common/parse-json-schema/util/clone-obj.js delete mode 100644 common/parse-json-schema/util/find-reference.js delete mode 100644 common/parse-json-schema/util/helpers.js delete mode 100644 common/parse-json-schema/util/normalize-schema.js delete mode 100644 common/parse-json-schema/util/resolve-schema.js diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..b9ac133e --- /dev/null +++ b/.npmignore @@ -0,0 +1,6 @@ +/docs +/test +/static/doc +/iconfont +/ydoc.js +/ydocfile.js diff --git a/.package.json.swp b/.package.json.swp deleted file mode 100644 index 0fe17186392d4970b02594b1a3c28169ecc535b1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 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 diff --git a/common/json-schema-mockjs.js b/common/json-schema-mockjs.js deleted file mode 100644 index 736e8739..00000000 --- a/common/json-schema-mockjs.js +++ /dev/null @@ -1,1113 +0,0 @@ -function _interopDefault(ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } - -var $RefParser = _interopDefault(require('json-schema-ref-parser')); -var deref = _interopDefault(require('./parse-json-schema')); -var tslib_1 = require('tslib'); - -// dynamic proxy for custom generators -function proxy(gen) { - return function (value, schema, property) { - var fn = value; - var args = []; - // support for nested object, first-key is the generator - if (typeof value === 'object') { - fn = Object.keys(value)[0]; - // treat the given array as arguments, - if (Array.isArray(value[fn])) { - // if the generator is expecting arrays they should be nested, e.g. `[[1, 2, 3], true, ...]` - args = value[fn]; - } - else { - args.push(value[fn]); - } - } - // support for keypaths, e.g. "internet.email" - var props = fn.split('.'); - // retrieve a fresh dependency - var ctx = gen(); - while (props.length > 1) { - ctx = ctx[props.shift()]; - } - // retrieve last value from context object - value = typeof ctx === 'object' ? ctx[props[0]] : ctx; - // invoke dynamic generators - if (typeof value === 'function') { - value = value.apply(ctx, args); - } - // test for pending callbacks - if (Object.prototype.toString.call(value) === '[object Object]') { - for (var key in value) { - if (typeof value[key] === 'function') { - throw new Error('Cannot resolve value for "' + property + ': ' + fn + '", given: ' + value); - } - } - } - return value; - }; -} -/** - * Container is used to wrap external generators (faker, chance, casual, etc.) and its dependencies. - * - * - `jsf.extend('faker')` will enhance or define the given dependency. - * - `jsf.define('faker')` will provide the "faker" keyword support. - * - * RandExp is not longer considered an "extension". - */ -var Container = (function () { - function Container() { - // dynamic requires - handle all dependencies - // they will NOT be included on the bundle - this.registry = {}; - this.support = {}; - } - /** - * Override dependency given by name - * @param name - * @param callback - */ - Container.prototype.extend = function (name, callback) { - var _this = this; - this.registry[name] = callback(this.registry[name]); - // built-in proxy (can be overridden) - if (!this.support[name]) { - this.support[name] = proxy(function () { return _this.registry[name]; }); - } - }; - /** - * Set keyword support by name - * @param name - * @param callback - */ - Container.prototype.define = function (name, callback) { - this.support[name] = callback; - }; - /** - * Returns dependency given by name - * @param name - * @returns {Dependency} - */ - Container.prototype.get = function (name) { - if (typeof this.registry[name] === 'undefined') { - throw new ReferenceError('"' + name + '" dependency doesn\'t exist.'); - } - return this.registry[name]; - }; - /** - * Apply a custom keyword - * @param schema - */ - Container.prototype.wrap = function (schema) { - var keys = Object.keys(schema); - var length = keys.length; - while (length--) { - var fn = keys[length].replace(/^x-/, ''); - var gen = this.support[fn]; - if (typeof gen === 'function') { - schema.generate = function () { return gen(schema[keys[length]], schema, keys[length]); }; - break; - } - } - return schema; - }; - return Container; -}()); - -/** - * This class defines a registry for custom formats used within JSF. - */ -var Registry = (function () { - function Registry() { - // empty by default - this.data = {}; - } - /** - * Registers custom format - */ - Registry.prototype.register = function (name, callback) { - this.data[name] = callback; - }; - /** - * Register many formats at one shot - */ - Registry.prototype.registerMany = function (formats) { - for (var name in formats) { - this.data[name] = formats[name]; - } - }; - /** - * Returns element by registry key - */ - Registry.prototype.get = function (name) { - var format = this.data[name]; - return format; - }; - /** - * Returns the whole registry content - */ - Registry.prototype.list = function () { - return this.data; - }; - return Registry; -}()); - -// instantiate -var registry = new Registry(); -/** - * Custom format API - * - * @see https://github.com/json-schema-faker/json-schema-faker#custom-formats - * @param nameOrFormatMap - * @param callback - * @returns {any} - */ -function formatAPI$1(nameOrFormatMap, callback) { - if (typeof nameOrFormatMap === 'undefined') { - return registry.list(); - } - else if (typeof nameOrFormatMap === 'string') { - if (typeof callback === 'function') { - registry.register(nameOrFormatMap, callback); - } - else { - return registry.get(nameOrFormatMap); - } - } - else { - registry.registerMany(nameOrFormatMap); - } -} - -/** - * This class defines a registry for custom settings used within JSF. - */ -var OptionRegistry = (function (_super) { - tslib_1.__extends(OptionRegistry, _super); - function OptionRegistry() { - var _this = _super.call(this) || this; - _this.data['failOnInvalidTypes'] = true; - _this.data['defaultInvalidTypeProduct'] = null; - _this.data['failOnInvalidFormat'] = true; - _this.data['useDefaultValue'] = false; - _this.data['requiredOnly'] = false; - _this.data['maxItems'] = null; - _this.data['maxLength'] = null; - _this.data['defaultMinItems'] = 0; - _this.data['defaultRandExpMax'] = 10; - _this.data['alwaysFakeOptionals'] = false; - _this.data['random'] = Math.random; - return _this; - } - return OptionRegistry; -}(Registry)); - -// instantiate -var registry$1 = new OptionRegistry(); -/** - * Custom option API - * - * @param nameOrOptionMap - * @returns {any} - */ -function optionAPI(nameOrOptionMap) { - if (typeof nameOrOptionMap === 'string') { - return registry$1.get(nameOrOptionMap); - } - else { - return registry$1.registerMany(nameOrOptionMap); - } -} - -var RandExp = require('randexp'); -// set maximum default, see #193 -RandExp.prototype.max = 10; -// same implementation as the original except using our random -RandExp.prototype.randInt = function (a, b) { - return a + Math.floor(optionAPI('random')() * (1 + b - a)); -}; -function _randexp(value) { - var re = new RandExp(value); - // apply given setting - re.max = optionAPI('defaultRandExpMax'); - return re.gen(); -} -function getSubAttribute(obj, dotSeparatedKey) { - var keyElements = dotSeparatedKey.split('.'); - while (keyElements.length) { - var prop = keyElements.shift(); - if (!obj[prop]) { - break; - } - obj = obj[prop]; - } - return obj; -} -/** - * Returns true/false whether the object parameter has its own properties defined - * - * @param obj - * @param properties - * @returns {boolean} - */ -function hasProperties(obj) { - var properties = []; - for (var _i = 1; _i < arguments.length; _i++) { - properties[_i - 1] = arguments[_i]; - } - return properties.filter(function (key) { - return typeof obj[key] !== 'undefined'; - }).length > 0; -} -/** - * Returns typecasted value. - * External generators (faker, chance, casual) may return data in non-expected formats, such as string, when you might expect an - * integer. This function is used to force the typecast. - * - * @param value - * @param targetType - * @returns {any} - */ -function typecast(value, schema) { - // FIXME this function should cover most cases and should be reused within generators - switch (schema.type) { - case 'integer': - return parseInt(value, 10); - case 'number': - return parseFloat(value); - case 'string': - value = String(value); - var min = Math.max(schema.minLength || 0, 0); - var max = Math.min(schema.maxLength || Infinity, Infinity); - while (value.length < min) { - value += ' ' + value; - } - if (value.length > max) { - value = value.substr(0, max); - } - return value; - case 'boolean': - return !!value; - default: - return value; - } -} -function merge(a, b) { - for (var key in b) { - if (typeof b[key] !== 'object' || b[key] === null) { - a[key] = b[key]; - } - else if (Array.isArray(b[key])) { - a[key] = a[key] || []; - // fix #292 - skip duplicated values from merge object (b) - b[key].forEach(function (value) { - if (a[key].indexOf(value)) { - a[key].push(value); - } - }); - } - else if (typeof a[key] !== 'object' || a[key] === null || Array.isArray(a[key])) { - a[key] = merge({}, b[key]); - } - else { - a[key] = merge(a[key], b[key]); - } - } - return a; -} -function clean(obj, isArray, requiredProps) { - if (!obj || typeof obj !== 'object') { - return obj; - } - if (Array.isArray(obj)) { - obj = obj - .map(function (value) { return clean(value, true); }) - .filter(function (value) { return typeof value !== 'undefined'; }); - return obj; - } - Object.keys(obj).forEach(function (k) { - if (!requiredProps || requiredProps.indexOf(k) === -1) { - if (Array.isArray(obj[k]) && !obj[k].length) { - delete obj[k]; - } - } - else { - obj[k] = clean(obj[k]); - } - }); - if (!Object.keys(obj).length && isArray) { - return undefined; - } - return obj; -} -function short(schema) { - var s = JSON.stringify(schema); - var l = JSON.stringify(schema, null, 2); - return s.length > 400 ? l.substr(0, 400) + '...' : l; -} -var utils = { - getSubAttribute: getSubAttribute, - hasProperties: hasProperties, - typecast: typecast, - merge: merge, - clean: clean, - short: short, - randexp: _randexp -}; - -/// -/** - * Returns random element of a collection - * - * @param collection - * @returns {T} - */ -function pick(collection) { - return collection[Math.floor(optionAPI('random')() * collection.length)]; -} -/** - * Returns shuffled collection of elements - * - * @param collection - * @returns {T[]} - */ -function shuffle(collection) { - var tmp, key, copy = collection.slice(), length = collection.length; - for (; length > 0;) { - key = Math.floor(optionAPI('random')() * length); - // swap - tmp = copy[--length]; - copy[length] = copy[key]; - copy[key] = tmp; - } - return copy; -} -/** - * These values determine default range for random.number function - * - * @type {number} - */ -var MIN_NUMBER = -100; -var MAX_NUMBER = 100; -/** - * Returns a random integer between min (inclusive) and max (inclusive) - * Using Math.round() will give you a non-uniform distribution! - * @see http://stackoverflow.com/a/1527820/769384 - */ -function getRandom(min, max) { - return optionAPI('random')() * (max - min) + min; -} -/** - * Generates random number according to parameters passed - * - * @param min - * @param max - * @param defMin - * @param defMax - * @param hasPrecision - * @returns {number} - */ -function number(min, max, defMin, defMax, hasPrecision) { - if (hasPrecision === void 0) { hasPrecision = false; } - defMin = typeof defMin === 'undefined' ? MIN_NUMBER : defMin; - defMax = typeof defMax === 'undefined' ? MAX_NUMBER : defMax; - min = typeof min === 'undefined' ? defMin : min; - max = typeof max === 'undefined' ? defMax : max; - if (max < min) { - max += min; - } - var result = getRandom(min, max); - if (!hasPrecision) { - return Math.round(result); - } - return result; -} -var random = { - pick: pick, - shuffle: shuffle, - number: number, -}; - -var ParseError = (function (_super) { - tslib_1.__extends(ParseError, _super); - function ParseError(message, path) { - var _this = _super.call(this) || this; - _this.path = path; - if (Error.captureStackTrace) { - Error.captureStackTrace(_this, _this.constructor); - } - _this.name = 'ParseError'; - _this.message = message; - _this.path = path; - return _this; - } - return ParseError; -}(Error)); - -var inferredProperties = { - array: [ - 'additionalItems', - 'items', - 'maxItems', - 'minItems', - 'uniqueItems' - ], - integer: [ - 'exclusiveMaximum', - 'exclusiveMinimum', - 'maximum', - 'minimum', - 'multipleOf' - ], - object: [ - 'additionalProperties', - 'dependencies', - 'maxProperties', - 'minProperties', - 'patternProperties', - 'properties', - 'required' - ], - string: [ - 'maxLength', - 'minLength', - 'pattern' - ] -}; -inferredProperties.number = inferredProperties.integer; -var subschemaProperties = [ - 'additionalItems', - 'items', - 'additionalProperties', - 'dependencies', - 'patternProperties', - 'properties' -]; -/** - * Iterates through all keys of `obj` and: - * - checks whether those keys match properties of a given inferred type - * - makes sure that `obj` is not a subschema; _Do not attempt to infer properties named as subschema containers. The - * reason for this is that any property name within those containers that matches one of the properties used for - * inferring missing type values causes the container itself to get processed which leads to invalid output. (Issue 62)_ - * - * @returns {boolean} - */ -function matchesType(obj, lastElementInPath, inferredTypeProperties) { - return Object.keys(obj).filter(function (prop) { - var isSubschema = subschemaProperties.indexOf(lastElementInPath) > -1, inferredPropertyFound = inferredTypeProperties.indexOf(prop) > -1; - if (inferredPropertyFound && !isSubschema) { - return true; - } - }).length > 0; -} -/** - * Checks whether given `obj` type might be inferred. The mechanism iterates through all inferred types definitions, - * tries to match allowed properties with properties of given `obj`. Returns type name, if inferred, or null. - * - * @returns {string|null} - */ -function inferType(obj, schemaPath) { - for (var typeName in inferredProperties) { - var lastElementInPath = schemaPath[schemaPath.length - 1]; - if (matchesType(obj, lastElementInPath, inferredProperties[typeName])) { - return typeName; - } - } -} - -/** - * Generates randomized boolean value. - * - * @returns {boolean} - */ -function booleanGenerator() { - return optionAPI('random')() > 0.5; -} - -var booleanType = booleanGenerator; - -/** - * Generates null value. - * - * @returns {null} - */ -function nullGenerator() { - return null; -} - -var nullType = nullGenerator; - -// TODO provide types -function unique(path, items, value, sample, resolve, traverseCallback) { - var tmp = [], seen = []; - function walk(obj) { - var json = JSON.stringify(obj); - if (seen.indexOf(json) === -1) { - seen.push(json); - tmp.push(obj); - } - } - items.forEach(walk); - // TODO: find a better solution? - var limit = 100; - while (tmp.length !== items.length) { - walk(traverseCallback(value.items || sample, path, resolve)); - if (!limit--) { - break; - } - } - return tmp; -} -// TODO provide types -var arrayType = function arrayType(value, path, resolve, traverseCallback) { - var items = []; - if (!(value.items || value.additionalItems)) { - if (utils.hasProperties(value, 'minItems', 'maxItems', 'uniqueItems')) { - throw new ParseError('missing items for ' + utils.short(value), path); - } - return items; - } - // see http://stackoverflow.com/a/38355228/769384 - // after type guards support subproperties (in TS 2.0) we can simplify below to (value.items instanceof Array) - // so that value.items.map becomes recognized for typescript compiler - var tmpItems = value.items; - if (tmpItems instanceof Array) { - return Array.prototype.concat.call(items, tmpItems.map(function (item, key) { - var itemSubpath = path.concat(['items', key + '']); - return traverseCallback(item, itemSubpath, resolve); - })); - } - var minItems = value.minItems; - //var maxItems = value.maxItems; - var maxItems = 1; - if (optionAPI('defaultMinItems') && minItems === undefined) { - // fix boundaries - minItems = !maxItems - ? optionAPI('defaultMinItems') - : Math.min(optionAPI('defaultMinItems'), maxItems); - } - if (optionAPI('maxItems')) { - // Don't allow user to set max items above our maximum - if (maxItems && maxItems > optionAPI('maxItems')) { - maxItems = optionAPI('maxItems'); - } - // Don't allow user to set min items above our maximum - if (minItems && minItems > optionAPI('maxItems')) { - minItems = maxItems; - } - } - var length = (maxItems != null && optionAPI('alwaysFakeOptionals')) ? - maxItems : random.number(minItems, maxItems, 1, 5), - // TODO below looks bad. Should additionalItems be copied as-is? - sample = typeof value.additionalItems === 'object' ? value.additionalItems : {}; - for (var current = items.length; current < length; current++) { - var itemSubpath = path.concat(['items', current + '']); - var element = traverseCallback(value.items || sample, itemSubpath, resolve); - items.push(element); - } - if (value.uniqueItems) { - return unique(path.concat(['items']), items, value, sample, resolve, traverseCallback); - } - return items; -}; - -var MIN_INTEGER = -100000000; -var MAX_INTEGER = 100000000; -var numberType$1 = function numberType(value) { - var min = typeof value.minimum === 'undefined' ? MIN_INTEGER : value.minimum, max = typeof value.maximum === 'undefined' ? MAX_INTEGER : value.maximum, multipleOf = value.multipleOf; - if (multipleOf) { - max = Math.floor(max / multipleOf) * multipleOf; - min = Math.ceil(min / multipleOf) * multipleOf; - } - if (value.exclusiveMinimum && value.minimum && min === value.minimum) { - min += multipleOf || 1; - } - if (value.exclusiveMaximum && value.maximum && max === value.maximum) { - max -= multipleOf || 1; - } - if (min > max) { - return NaN; - } - if (multipleOf) { - return Math.floor(random.number(min, max) / multipleOf) * multipleOf; - } - return random.number(min, max, undefined, undefined, true); -}; - -// The `integer` type is just a wrapper for the `number` type. The `number` type -// returns floating point numbers, and `integer` type truncates the fraction -// part, leaving the result as an integer. -var integerType = function integerType(value) { - var generated = numberType$1(value); - // whether the generated number is positive or negative, need to use either - // floor (positive) or ceil (negative) function to get rid of the fraction - return generated > 0 ? Math.floor(generated) : Math.ceil(generated); -}; - -var LIPSUM_WORDS = ('Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore' - + ' et dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea' - + ' commodo consequat Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla' - + ' pariatur Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est' - + ' laborum').split(' '); -/** - * Generates randomized array of single lorem ipsum words. - * - * @param length - * @returns {Array.} - */ -function wordsGenerator$1(length) { - var words = random.shuffle(LIPSUM_WORDS); - return words.slice(0, length); -} - -// fallback generator -var anyType = { type: ['string', 'number', 'integer', 'boolean'] }; -// TODO provide types -var objectType = function objectType(value, path, resolve, traverseCallback) { - var props = {}; - var properties = value.properties || {}; - var propertyKeys = value.required = Object.keys(properties); - var patternProperties = value.patternProperties || {}; - var requiredProperties = (value.required || []).slice(); - var allowsAdditional = value.additionalProperties === false ? false : true; - - var patternPropertyKeys = Object.keys(patternProperties); - var additionalProperties = allowsAdditional - ? (value.additionalProperties === true ? {} : value.additionalProperties) - : null; - if (!allowsAdditional && - propertyKeys.length === 0 && - patternPropertyKeys.length === 0 && - utils.hasProperties(value, 'minProperties', 'maxProperties', 'dependencies', 'required')) { - throw new ParseError('missing properties for:\n' + utils.short(value), path); - } - if (optionAPI('requiredOnly') === true) { - requiredProperties.forEach(function (key) { - if (properties[key]) { - props[key] = properties[key]; - } - }); - return traverseCallback(props, path.concat(['properties']), resolve); - } - var min = Math.max(value.minProperties || 0, requiredProperties.length); - var max = Math.max(value.maxProperties || random.number(min, min + 5)); - random.shuffle(patternPropertyKeys.concat(propertyKeys)).forEach(function (_key) { - if (requiredProperties.indexOf(_key) === -1) { - requiredProperties.push(_key); - } - }); - // properties are read from right-to-left - var _props = optionAPI('alwaysFakeOptionals') ? requiredProperties - : requiredProperties.slice(0, random.number(min, max)); - _props.forEach(function (key) { - // first ones are the required properies - if (properties[key]) { - props[key] = properties[key]; - } - else { - var found; - // then try patternProperties - patternPropertyKeys.forEach(function (_key) { - if (key.match(new RegExp(_key))) { - found = true; - props[utils.randexp(key)] = patternProperties[_key]; - } - }); - if (!found) { - // try patternProperties again, - var subschema = patternProperties[key] || additionalProperties; - if (subschema) { - // otherwise we can use additionalProperties? - props[patternProperties[key] ? utils.randexp(key) : key] = subschema; - } - } - } - }); - var current = Object.keys(props).length; - while (true) { - if (!(patternPropertyKeys.length || allowsAdditional)) { - break; - } - if (current >= min) { - break; - } - if (allowsAdditional) { - var word = wordsGenerator$1(1) + utils.randexp('[a-f\\d]{1,3}'); - if (!props[word]) { - props[word] = additionalProperties || anyType; - current += 1; - } - } - patternPropertyKeys.forEach(function (_key) { - var word = utils.randexp(_key); - if (!props[word]) { - props[word] = patternProperties[_key]; - current += 1; - } - }); - } - if (!allowsAdditional && current < min) { - throw new ParseError('properties constraints were too strong to successfully generate a valid object for:\n' + - utils.short(value), path); - } - return traverseCallback(props, path.concat(['properties']), resolve); -}; - -/** - * Helper function used by thunkGenerator to produce some words for the final result. - * - * @returns {string} - */ -function produce() { - var length = random.number(1, 5); - return wordsGenerator$1(length).join(' '); -} -/** - * Generates randomized concatenated string based on words generator. - * - * @returns {string} - */ -function thunkGenerator$1(min, max) { - if (min === void 0) { min = 0; } - if (max === void 0) { max = 140; } - var min = Math.max(0, min), max = random.number(min, max), result = produce(); - // append until length is reached - while (result.length < min) { - result += produce(); - } - // cut if needed - if (result.length > max) { - result = result.substr(0, max); - } - return result; -} - -/** - * Generates randomized ipv4 address. - * - * @returns {string} - */ -function ipv4Generator() { - return [0, 0, 0, 0].map(function () { - return random.number(0, 255); - }).join('.'); -} - -var MOST_NEAR_DATETIME = 2524608000000; -/** - * Generates randomized date time ISO format string. - * - * @returns {string} - */ -function dateTimeGenerator$1() { - var date = new Date(); - var days = random.number(-1000, MOST_NEAR_DATETIME); - date.setTime(date.getTime() - days); - return date.toISOString(); -} - -/** - * Predefined core formats - * @type {[key: string]: string} - */ -var regexps = { - email: '[a-zA-Z\\d][a-zA-Z\\d-]{1,13}[a-zA-Z\\d]@{hostname}', - hostname: '[a-zA-Z]{1,33}\\.[a-z]{2,4}', - ipv6: '[a-f\\d]{4}(:[a-f\\d]{4}){7}', - uri: '[a-zA-Z][a-zA-Z0-9+-.]*' -}; -/** - * Generates randomized string basing on a built-in regex format - * - * @param coreFormat - * @returns {string} - */ -function coreFormatGenerator(coreFormat) { - return utils.randexp(regexps[coreFormat]).replace(/\{(\w+)\}/, function (match, key) { - return utils.randexp(regexps[key]); - }); -} - -function generateFormat(value, invalid) { - var callback = formatAPI$1(value.format); - if (typeof callback === 'function') { - return callback(value); - } - switch (value.format) { - case 'date-time': - return dateTimeGenerator$1(); - case 'ipv4': - return ipv4Generator(); - case 'regex': - // TODO: discuss - return '.+?'; - case 'email': - case 'hostname': - case 'ipv6': - case 'uri': - return coreFormatGenerator(value.format); - default: - if (typeof callback === 'undefined') { - if (optionAPI('failOnInvalidFormat')) { - throw new Error('unknown registry key ' + utils.short(value.format)); - } - else { - return invalid(); - } - } - throw new Error('unsupported format "' + value.format + '"'); - } -} -var stringType = function stringType(value) { - var output; - var minLength = value.minLength; - var maxLength = value.maxLength; - if (optionAPI('maxLength')) { - // Don't allow user to set max length above our maximum - if (maxLength && maxLength > optionAPI('maxLength')) { - maxLength = optionAPI('maxLength'); - } - // Don't allow user to set min length above our maximum - if (minLength && minLength > optionAPI('maxLength')) { - minLength = optionAPI('maxLength'); - } - } - if (value.format) { - output = generateFormat(value, function () { return thunkGenerator$1(minLength, maxLength); }); - } - else if (value.pattern) { - output = utils.randexp(value.pattern); - } - else { - output = thunkGenerator$1(minLength, maxLength); - } - while (output.length < minLength) { - output += optionAPI('random')() > 0.7 ? thunkGenerator$1() : utils.randexp('.+'); - } - if (output.length > maxLength) { - output = output.substr(0, maxLength); - } - return output; -}; - -// var typeMap = { -// boolean: booleanType, -// null: nullType, -// array: arrayType, -// integer: integerType, -// number: numberType$1, -// object: objectType, -// string: stringType -// }; - -var typeMap = { - boolean: () => '@boolean', - null: nullType, - array: arrayType, - integer: () => '@integer', - number: () => '@natural', - object: objectType, - string: () => '@string' -}; - -// TODO provide types -function traverse(schema, path, resolve) { - schema = resolve(schema); - if (!schema) { - return; - } - if (Array.isArray(schema.enum)) { - return random.pick(schema.enum); - } - // thunks can return sub-schemas - if (typeof schema.thunk === 'function') { - return traverse(schema.thunk(), path, resolve); - } - if (typeof schema.generate === 'function') { - return utils.typecast(schema.generate(), schema); - } - if (optionAPI('useDefaultValue') && 'default' in schema) { - return schema.default; - } - // TODO remove the ugly overcome - var type = schema.type; - if (Array.isArray(type)) { - type = random.pick(type); - } - else if (typeof type === 'undefined') { - // Attempt to infer the type - type = inferType(schema, path) || type; - } - if (typeof type === 'string') { - if (!typeMap[type]) { - if (optionAPI('failOnInvalidTypes')) { - throw new ParseError('unknown primitive ' + utils.short(type), path.concat(['type'])); - } - else { - return optionAPI('defaultInvalidTypeProduct'); - } - } - else { - try { - return utils.clean(typeMap[type](schema, path, resolve, traverse), null, schema.required); - } - catch (e) { - if (typeof e.path === 'undefined') { - throw new ParseError(e.message, path); - } - throw e; - } - } - } - var copy = {}; - if (Array.isArray(schema)) { - copy = []; - } - for (var prop in schema) { - if (typeof schema[prop] === 'object' && prop !== 'definitions') { - copy[prop] = traverse(schema[prop], path.concat([prop]), resolve); - } - else { - copy[prop] = schema[prop]; - } - } - return copy; -} - -function isKey(prop) { - return prop === 'enum' || prop === 'default' || prop === 'required' || prop === 'definitions'; -} -// TODO provide types -function run(refs, schema, container) { - try { - return traverse(schema, [], function reduce(sub, maxReduceDepth) { - if (typeof maxReduceDepth === 'undefined') { - maxReduceDepth = random.number(1, 3); - } - if (!sub) { - return null; - } - // cleanup - if (sub.id && typeof sub.id === 'string') { - delete sub.id; - delete sub.$schema; - } - if (typeof sub.$ref === 'string') { - if (sub.$ref.indexOf('#/') === -1) { - var ref = deref.util.findByRef(sub.$ref, refs); - if (!ref) { - throw new Error('Reference not found: ' + sub.$ref); - } - return ref; - } - // just remove the reference - delete sub.$ref; - return sub; - } - if (Array.isArray(sub.allOf)) { - var schemas = sub.allOf; - delete sub.allOf; - // this is the only case where all sub-schemas - // must be resolved before any merge - schemas.forEach(function (subSchema) { - var _sub = reduce(subSchema, maxReduceDepth + 1); - // call given thunks if present - utils.merge(sub, typeof _sub.thunk === 'function' - ? _sub.thunk() - : _sub); - }); - } - if (Array.isArray(sub.oneOf || sub.anyOf)) { - var mix = sub.oneOf || sub.anyOf; - delete sub.anyOf; - delete sub.oneOf; - return { - thunk: function () { - var copy = utils.merge({}, sub); - utils.merge(copy, random.pick(mix)); - return copy; - }, - }; - } - for (var prop in sub) { - if ((Array.isArray(sub[prop]) || typeof sub[prop] === 'object') && !isKey(prop)) { - sub[prop] = reduce(sub[prop], maxReduceDepth); - } - } - return container.wrap(sub); - }); - } - catch (e) { - if (e.path) { - throw new Error(e.message + ' in ' + '/' + e.path.join('/')); - } - else { - throw e; - } - } -} - -var container = new Container(); -function getRefs(refs) { - var $refs = {}; - if (Array.isArray(refs)) { - refs.map(deref.util.normalizeSchema).forEach(function (schema) { - $refs[schema.id] = schema; - }); - } - else { - $refs = refs || {}; - } - return $refs; -} -var jsf = function (schema, refs) { - var $ = deref(); - var $refs = getRefs(refs); - return run($refs, $(schema, $refs, true), container); -}; -jsf.resolve = function (schema, refs, cwd) { - if (typeof refs === 'string') { - cwd = refs; - refs = {}; - } - // normalize basedir (browser aware) - cwd = cwd || (typeof process !== 'undefined' ? process.cwd() : ''); - cwd = cwd.replace(/\/+$/, '') + '/'; - var $refs = getRefs(refs); - // identical setup as json-schema-sequelizer - var fixedRefs = { - order: 300, - canRead: true, - read: function (file, callback) { - callback(null, deref.util.findByRef(cwd !== '/' - ? file.url.replace(cwd, '') - : file.url, $refs)); - }, - }; - return $RefParser - .dereference(cwd, schema, { - resolve: { fixedRefs: fixedRefs }, - dereference: { - circular: 'ignore', - }, - }).then(function (sub) { return jsf(sub, refs); }); -}; -jsf.utils = utils; -jsf.format = formatAPI$1; -jsf.option = optionAPI; -// built-in support -container.define('pattern', utils.randexp); -// returns itself for chaining -jsf.extend = function (name, cb) { - container.extend(name, cb); - return jsf; -}; -jsf.define = function (name, cb) { - container.define(name, cb); - return jsf; -}; -jsf.locate = function (name) { - return container.get(name); -}; -var VERSION = "0.5.0-rc11"; -jsf.version = VERSION; - -module.exports = jsf; \ No newline at end of file diff --git a/common/parse-json-schema/index.js b/common/parse-json-schema/index.js deleted file mode 100644 index 5886c9a6..00000000 --- a/common/parse-json-schema/index.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; - -var $ = require('./util/helpers'); - -$.findByRef = require('./util/find-reference'); -$.resolveSchema = require('./util/resolve-schema'); -$.normalizeSchema = require('./util/normalize-schema'); - -var instance = module.exports = function(f) { - function $ref(fakeroot, schema, refs, ex) { - if (typeof fakeroot === 'object') { - ex = refs; - refs = schema; - schema = fakeroot; - fakeroot = undefined; - } - - if (typeof schema !== 'object') { - throw new Error('schema must be an object'); - } - - if (typeof refs === 'object' && refs !== null) { - var aux = refs; - - refs = []; - - for (var k in aux) { - aux[k].id = aux[k].id || k; - refs.push(aux[k]); - } - } - - if (typeof refs !== 'undefined' && !Array.isArray(refs)) { - ex = !!refs; - refs = []; - } - - function push(ref) { - if (typeof ref.id === 'string') { - var id = $.resolveURL(fakeroot, ref.id).replace(/\/#?$/, ''); - - if (id.indexOf('#') > -1) { - var parts = id.split('#'); - - if (parts[1].charAt() === '/') { - id = parts[0]; - } else { - id = parts[1] || parts[0]; - } - } - - if (!$ref.refs[id]) { - $ref.refs[id] = ref; - } - } - } - - (refs || []).concat([schema]).forEach(function(ref) { - schema = $.normalizeSchema(fakeroot, ref, push); - push(schema); - }); - - return $.resolveSchema(schema, $ref.refs, ex, f); - } - - $ref.refs = {}; - $ref.util = $; - - return $ref; -}; - -instance.util = $; diff --git a/common/parse-json-schema/util/clone-obj.js b/common/parse-json-schema/util/clone-obj.js deleted file mode 100644 index 4895eb41..00000000 --- a/common/parse-json-schema/util/clone-obj.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; - -var clone = module.exports = function(obj, seen) { - seen = seen || []; - - if (seen.indexOf(obj) > -1) { - throw new Error('unable dereference circular structures'); - } - - if (!obj || typeof obj !== 'object') { - return obj; - } - - seen = seen.concat([obj]); - - var target = Array.isArray(obj) ? [] : {}; - - function copy(key, value) { - target[key] = clone(value, seen); - } - - if (Array.isArray(target)) { - obj.forEach(function(value, key) { - copy(key, value); - }); - } else if (Object.prototype.toString.call(obj) === '[object Object]') { - Object.keys(obj).forEach(function(key) { - copy(key, obj[key]); - }); - } - - return target; -}; diff --git a/common/parse-json-schema/util/find-reference.js b/common/parse-json-schema/util/find-reference.js deleted file mode 100644 index 4627479c..00000000 --- a/common/parse-json-schema/util/find-reference.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -var $ = require('./helpers'); - -function get(obj, path) { - var hash = path.split('#')[1]; - - var parts = hash.split('/').slice(1); - - while (parts.length) { - var key = decodeURIComponent(parts.shift()).replace(/~1/g, '/').replace(/~0/g, '~'); - - if (typeof obj[key] === 'undefined') { - throw new Error('JSON pointer not found: ' + path); - } - - obj = obj[key]; - } - - return obj; -} - -var find = module.exports = function(id, refs, filter) { - - var target = refs[id] || refs[id.split('#')[1]] || refs[$.getDocumentURI(id)]; - - try { - if (target) { - target = id.indexOf('#/') > -1 ? get(target, id) : target; - - } else { - for (var key in refs) { - if ($.resolveURL(refs[key].id, id) === refs[key].id) { - target = refs[key]; - break; - } - } - } - } catch (e) { - if (typeof filter === 'function') { - target = filter(id, refs); - } else { - throw e; - } - } - - if (!target) { - throw new Error('Reference not found: ' + id); - } - - - while (target.$ref) { - target = find(target.$ref, refs); - } - return target; -}; diff --git a/common/parse-json-schema/util/helpers.js b/common/parse-json-schema/util/helpers.js deleted file mode 100644 index b4c5891e..00000000 --- a/common/parse-json-schema/util/helpers.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -// https://gist.github.com/pjt33/efb2f1134bab986113fd - -function URLUtils(url, baseURL) { - // remove leading ./ - url = url.replace(/^\.\//, ''); - - var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@]*)(?::([^:@]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/); - if (!m) { - throw new RangeError(); - } - var href = m[0] || ''; - var protocol = m[1] || ''; - var username = m[2] || ''; - var password = m[3] || ''; - var host = m[4] || ''; - var hostname = m[5] || ''; - var port = m[6] || ''; - var pathname = m[7] || ''; - var search = m[8] || ''; - var hash = m[9] || ''; - if (baseURL !== undefined) { - var base = new URLUtils(baseURL); - var flag = protocol === '' && host === '' && username === ''; - if (flag && pathname === '' && search === '') { - search = base.search; - } - if (flag && pathname.charAt(0) !== '/') { - pathname = (pathname !== '' ? (base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + pathname) : base.pathname); - } - // dot segments removal - var output = []; - - pathname.replace(/\/?[^\/]+/g, function(p) { - if (p === '/..') { - output.pop(); - } else { - output.push(p); - } - }); - - pathname = output.join('') || '/'; - - if (flag) { - port = base.port; - hostname = base.hostname; - host = base.host; - password = base.password; - username = base.username; - } - if (protocol === '') { - protocol = base.protocol; - } - href = protocol + (host !== '' ? '//' : '') + (username !== '' ? username + (password !== '' ? ':' + password : '') + '@' : '') + host + pathname + search + hash; - } - this.href = href; - this.origin = protocol + (host !== '' ? '//' + host : ''); - this.protocol = protocol; - this.username = username; - this.password = password; - this.host = host; - this.hostname = hostname; - this.port = port; - this.pathname = pathname; - this.search = search; - this.hash = hash; -} - -function isURL(path) { - if (typeof path === 'string' && /^\w+:\/\//.test(path)) { - return true; - } -} - -function parseURI(href, base) { - return new URLUtils(href, base); -} - -function resolveURL(base, href) { - base = base || 'http://json-schema.org/schema#'; - - href = parseURI(href, base); - base = parseURI(base); - - if (base.hash && !href.hash) { - return href.href + base.hash; - } - - return href.href; -} - -function getDocumentURI(uri) { - return typeof uri === 'string' && uri.split('#')[0]; -} - -function isKeyword(prop) { - return prop === 'enum' || prop === 'default' || prop === 'required'; -} - -module.exports = { - isURL: isURL, - parseURI: parseURI, - isKeyword: isKeyword, - resolveURL: resolveURL, - getDocumentURI: getDocumentURI -}; diff --git a/common/parse-json-schema/util/normalize-schema.js b/common/parse-json-schema/util/normalize-schema.js deleted file mode 100644 index 6f7fb1ee..00000000 --- a/common/parse-json-schema/util/normalize-schema.js +++ /dev/null @@ -1,65 +0,0 @@ -'use strict'; - -var $ = require('./helpers'); - -var cloneObj = require('./clone-obj'); - -var SCHEMA_URI = [ - 'http://json-schema.org/schema#', - 'http://json-schema.org/schema', - 'http://json-schema.org/draft-04/schema#', - 'http://json-schema.org/draft-04/schema' -]; - -function expand(obj, parent, callback) { - if (obj) { - var id = typeof obj.id === 'string' ? obj.id : '#'; - - if (!$.isURL(id)) { - id = $.resolveURL(parent === id ? null : parent, id); - } - - if (typeof obj.$ref === 'string' && !$.isURL(obj.$ref)) { - obj.$ref = $.resolveURL(id, obj.$ref); - } - - if (typeof obj.id === 'string') { - obj.id = parent = id; - } - } - - for (var key in obj) { - var value = obj[key]; - - if (typeof value === 'object' && value !== null && !$.isKeyword(key)) { - expand(value, parent, callback); - } - } - - if (typeof callback === 'function') { - callback(obj); - } -} - -module.exports = function(fakeroot, schema, push) { - if (typeof fakeroot === 'object') { - push = schema; - schema = fakeroot; - fakeroot = null; - } - - var base = fakeroot || '', - copy = cloneObj(schema); - - if (copy.$schema && SCHEMA_URI.indexOf(copy.$schema) === -1) { - throw new Error('Unsupported schema version (v4 only)'); - } - - base = $.resolveURL(copy.$schema || SCHEMA_URI[0], base); - - expand(copy, $.resolveURL(copy.id || '#', base), push); - - copy.id = copy.id || base; - - return copy; -}; diff --git a/common/parse-json-schema/util/resolve-schema.js b/common/parse-json-schema/util/resolve-schema.js deleted file mode 100644 index 34b67fd6..00000000 --- a/common/parse-json-schema/util/resolve-schema.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -var $ = require('./helpers'); - -var find = require('./find-reference'); - -var deepExtend = require('deep-extend'); - -function copy(_, obj, refs, parent, resolve, callback) { - var target = Array.isArray(obj) ? [] : {}; - - if (typeof obj.$ref === 'string') { - var id = obj.$ref; - var base = $.getDocumentURI(id); - var local = id.indexOf('#/') > -1; - - if (local || (resolve && base !== parent)) { - var fixed = find(id, refs, callback); - - deepExtend(obj, fixed); - - delete obj.$ref; - delete obj.id; - } - - if (_[id] > 10) { - return obj; - }else if(_[id]){ - _[id] += 1; - }else{ - _[id] = 1; - } - } - - - for (var prop in obj) { - - if (typeof obj[prop] === 'object' && obj[prop] !== null && !$.isKeyword(prop)) { - target[prop] = copy(_, obj[prop], refs, parent, resolve, callback); - } else { - target[prop] = obj[prop]; - } - } - - return target; -} - -module.exports = function(obj, refs, resolve, callback) { - var fixedId = $.resolveURL(obj.$schema, obj.id), - parent = $.getDocumentURI(fixedId); - - return copy({}, obj, refs, parent, resolve, callback); -}; diff --git a/package.json b/package.json index a7d1fdd7..6cd6e59d 100755 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "yapi", + "name": "yapi-verndor", "version": "1.4.1", "description": "YAPI", - "main": "index.js", + "main": "server/app.js", "scripts": { "dev-copy-icon": "cp -r static/iconfont ./", "dev-server": " nodemon server/app.js dev -L", @@ -168,7 +168,7 @@ "maxSubjectLength": 100, "subjectPattern": ".+", "subjectPatternErrorMsg": "请输入message信息!", - "helpMessage": "Commit message 格式错误, \n请查看规范: http://wiki.corp.qunar.com/pages/viewpage.action?pageId=159698767" + "helpMessage": "Commit message 格式错误, http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html" } }, "engines": {