json-schema-faker
Advanced tools
Comparing version 0.5.0-rcv.29 to 0.5.0-rcv.30
@@ -10,5 +10,7 @@ #!/usr/bin/env node | ||
// FIXME: validate types on given input.... | ||
const argv = require('wargs')(process.argv.slice(2), { | ||
const argv = require('../dist/wargs.min.js')(process.argv.slice(2), { | ||
boolean: 'DXMTFOxedrJUSE', | ||
alias: { | ||
c: 'currentWorkingDirectory', | ||
D: 'defaultInvalidTypeProduct', | ||
@@ -50,5 +52,2 @@ X: 'defaultRandExpMax', | ||
// FIXME: enable flags... | ||
// jsf.option(argv.flags); | ||
const { inspect } = require('util'); | ||
@@ -61,8 +60,12 @@ const { Transform } = require('stream'); | ||
// FIXME: enable flags... | ||
jsf.option({ | ||
alwaysFakeOptionals: true, | ||
resolveJsonPath: argv.flags.resolveJsonPath, | ||
alwaysFakeOptionals: argv.flags.alwaysFakeOptionals, | ||
}); | ||
const cwd = argv.flags.currentWorkingDirectory || process.cwd(); | ||
function generate(schema, callback) { | ||
jsf.resolve(JSON.parse(schema)).then(result => { | ||
jsf.resolve(JSON.parse(schema), cwd).then(result => { | ||
let sample; | ||
@@ -69,0 +72,0 @@ |
@@ -1,1 +0,1 @@ | ||
function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}var $RefParser=_interopDefault(require("json-schema-ref-parser")),jsonpathPlus=require("jsonpath-plus"),Registry=function(){this.data={}};Registry.prototype.unregister=function(e){e?delete this.data[e]:this.data={}},Registry.prototype.register=function(e,t){this.data[e]=t},Registry.prototype.registerMany=function(e){var t=this;Object.keys(e).forEach((function(r){t.data[r]=e[r]}))},Registry.prototype.get=function(e){return this.data[e]},Registry.prototype.list=function(){return this.data};var defaults={defaultInvalidTypeProduct:null,defaultRandExpMax:10,ignoreProperties:[],ignoreMissingRefs:!1,failOnInvalidTypes:!0,failOnInvalidFormat:!0,alwaysFakeOptionals:!1,optionalsProbability:!1,fixedProbabilities:!1,useExamplesValue:!1,useDefaultValue:!1,requiredOnly:!1,minItems:0,maxItems:null,minLength:0,maxLength:null,resolveJsonPath:!1,reuseProperties:!1,fillProperties:!0,replaceEmptyByRandomValue:!1};defaults.random=Math.random;var OptionRegistry=function(e){function t(){e.call(this),this.data=Object.assign({},defaults),this._defaults=defaults}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaults:{configurable:!0}};return r.defaults.get=function(){return Object.assign({},this._defaults)},Object.defineProperties(t.prototype,r),t}(Registry),registry=new OptionRegistry;function optionAPI(e,t){return"string"==typeof e?void 0!==t?registry.register(e,t):registry.get(e):registry.registerMany(e)}optionAPI.getDefaults=function(){return registry.defaults};var SCALAR_TYPES=["integer","number","string","boolean","null"],ALL_TYPES=["array","object"].concat(SCALAR_TYPES),MOST_NEAR_DATETIME=2524608e6,MIN_INTEGER=-1e8,MAX_INTEGER=1e8,MIN_NUMBER=-100,MAX_NUMBER=100,env={SCALAR_TYPES:SCALAR_TYPES,ALL_TYPES:ALL_TYPES,MIN_NUMBER:MIN_NUMBER,MAX_NUMBER:MAX_NUMBER,MIN_INTEGER:MIN_INTEGER,MAX_INTEGER:MAX_INTEGER,MOST_NEAR_DATETIME:MOST_NEAR_DATETIME};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var types={ROOT:0,GROUP:1,POSITION:2,SET:3,RANGE:4,REPETITION:5,REFERENCE:6,CHAR:7};const INTS=()=>[{type:types.RANGE,from:48,to:57}],WORDS=()=>[{type:types.CHAR,value:95},{type:types.RANGE,from:97,to:122},{type:types.RANGE,from:65,to:90}].concat(INTS()),WHITESPACE=()=>[{type:types.CHAR,value:9},{type:types.CHAR,value:10},{type:types.CHAR,value:11},{type:types.CHAR,value:12},{type:types.CHAR,value:13},{type:types.CHAR,value:32},{type:types.CHAR,value:160},{type:types.CHAR,value:5760},{type:types.RANGE,from:8192,to:8202},{type:types.CHAR,value:8232},{type:types.CHAR,value:8233},{type:types.CHAR,value:8239},{type:types.CHAR,value:8287},{type:types.CHAR,value:12288},{type:types.CHAR,value:65279}],NOTANYCHAR=()=>[{type:types.CHAR,value:10},{type:types.CHAR,value:13},{type:types.CHAR,value:8232},{type:types.CHAR,value:8233}];var words=()=>({type:types.SET,set:WORDS(),not:!1}),notWords=()=>({type:types.SET,set:WORDS(),not:!0}),ints=()=>({type:types.SET,set:INTS(),not:!1}),notInts=()=>({type:types.SET,set:INTS(),not:!0}),whitespace=()=>({type:types.SET,set:WHITESPACE(),not:!1}),notWhitespace=()=>({type:types.SET,set:WHITESPACE(),not:!0}),anyChar=()=>({type:types.SET,set:NOTANYCHAR(),not:!0}),sets={words:words,notWords:notWords,ints:ints,notInts:notInts,whitespace:whitespace,notWhitespace:notWhitespace,anyChar:anyChar},util=createCommonjsModule((function(e,t){const r={0:0,t:9,n:10,v:11,f:12,r:13};t.strToChars=function(e){return e=e.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(function(e,t,n,i,a,o,s,u){if(n)return e;var p=t?8:i?parseInt(i,16):a?parseInt(a,16):o?parseInt(o,8):s?"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s):r[u],l=String.fromCharCode(p);return/[[\]{}^$.|?*+()]/.test(l)&&(l="\\"+l),l}))},t.tokenizeClass=(e,r)=>{for(var n,i,a=[],o=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g;null!=(n=o.exec(e));)if(n[1])a.push(sets.words());else if(n[2])a.push(sets.ints());else if(n[3])a.push(sets.whitespace());else if(n[4])a.push(sets.notWords());else if(n[5])a.push(sets.notInts());else if(n[6])a.push(sets.notWhitespace());else if(n[7])a.push({type:types.RANGE,from:(n[8]||n[9]).charCodeAt(0),to:n[10].charCodeAt(0)});else{if(!(i=n[12]))return[a,o.lastIndex];a.push({type:types.CHAR,value:i.charCodeAt(0)})}t.error(r,"Unterminated character class")},t.error=(e,t)=>{throw new SyntaxError("Invalid regular expression: /"+e+"/: "+t)}})),util_1=util.strToChars,util_2=util.tokenizeClass,util_3=util.error,wordBoundary=()=>({type:types.POSITION,value:"b"}),nonWordBoundary=()=>({type:types.POSITION,value:"B"}),begin=()=>({type:types.POSITION,value:"^"}),end=()=>({type:types.POSITION,value:"$"}),positions={wordBoundary:wordBoundary,nonWordBoundary:nonWordBoundary,begin:begin,end:end},lib=e=>{var t,r,n=0,i={type:types.ROOT,stack:[]},a=i,o=i.stack,s=[],u=t=>{util.error(e,`Nothing to repeat at column ${t-1}`)},p=util.strToChars(e);for(t=p.length;n<t;)switch(r=p[n++]){case"\\":switch(r=p[n++]){case"b":o.push(positions.wordBoundary());break;case"B":o.push(positions.nonWordBoundary());break;case"w":o.push(sets.words());break;case"W":o.push(sets.notWords());break;case"d":o.push(sets.ints());break;case"D":o.push(sets.notInts());break;case"s":o.push(sets.whitespace());break;case"S":o.push(sets.notWhitespace());break;default:/\d/.test(r)?o.push({type:types.REFERENCE,value:parseInt(r,10)}):o.push({type:types.CHAR,value:r.charCodeAt(0)})}break;case"^":o.push(positions.begin());break;case"$":o.push(positions.end());break;case"[":var l;"^"===p[n]?(l=!0,n++):l=!1;var f=util.tokenizeClass(p.slice(n),e);n+=f[1],o.push({type:types.SET,set:f[0],not:l});break;case".":o.push(sets.anyChar());break;case"(":var c={type:types.GROUP,stack:[],remember:!0};"?"===(r=p[n])&&(r=p[n+1],n+=2,"="===r?c.followedBy=!0:"!"===r?c.notFollowedBy=!0:":"!==r&&util.error(e,`Invalid group, character '${r}'`+` after '?' at column ${n-1}`),c.remember=!1),o.push(c),s.push(a),a=c,o=c.stack;break;case")":0===s.length&&util.error(e,`Unmatched ) at column ${n-1}`),o=(a=s.pop()).options?a.options[a.options.length-1]:a.stack;break;case"|":a.options||(a.options=[a.stack],delete a.stack);var h=[];a.options.push(h),o=h;break;case"{":var m,d,y=/^(\d+)(,(\d+)?)?\}/.exec(p.slice(n));null!==y?(0===o.length&&u(n),m=parseInt(y[1],10),d=y[2]?y[3]?parseInt(y[3],10):Infinity:m,n+=y[0].length,o.push({type:types.REPETITION,min:m,max:d,value:o.pop()})):o.push({type:types.CHAR,value:123});break;case"?":0===o.length&&u(n),o.push({type:types.REPETITION,min:0,max:1,value:o.pop()});break;case"+":0===o.length&&u(n),o.push({type:types.REPETITION,min:1,max:Infinity,value:o.pop()});break;case"*":0===o.length&&u(n),o.push({type:types.REPETITION,min:0,max:Infinity,value:o.pop()});break;default:o.push({type:types.CHAR,value:r.charCodeAt(0)})}return 0!==s.length&&util.error(e,"Unterminated group"),i},types_1=types;lib.types=types_1;class SubRange{constructor(e,t){this.low=e,this.high=t,this.length=1+t-e}overlaps(e){return!(this.high<e.low||this.low>e.high)}touches(e){return!(this.high+1<e.low||this.low-1>e.high)}add(e){return new SubRange(Math.min(this.low,e.low),Math.max(this.high,e.high))}subtract(e){return e.low<=this.low&&e.high>=this.high?[]:e.low>this.low&&e.high<this.high?[new SubRange(this.low,e.low-1),new SubRange(e.high+1,this.high)]:e.low<=this.low?[new SubRange(e.high+1,this.high)]:[new SubRange(this.low,e.low-1)]}toString(){return this.low==this.high?this.low.toString():this.low+"-"+this.high}}class DRange{constructor(e,t){this.ranges=[],this.length=0,null!=e&&this.add(e,t)}_update_length(){this.length=this.ranges.reduce((e,t)=>e+t.length,0)}add(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.touches(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.touches(this.ranges[t]);)e=e.add(this.ranges[t]),t++;r.push(e),this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof DRange?e.ranges.forEach(r):(null==t&&(t=e),r(new SubRange(e,t))),this}subtract(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.overlaps(this.ranges[t]);)r=r.concat(this.ranges[t].subtract(e)),t++;this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof DRange?e.ranges.forEach(r):(null==t&&(t=e),r(new SubRange(e,t))),this}intersect(e,t){var r=[],n=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(;t<this.ranges.length&&e.overlaps(this.ranges[t]);){var n=Math.max(this.ranges[t].low,e.low),i=Math.min(this.ranges[t].high,e.high);r.push(new SubRange(n,i)),t++}};return e instanceof DRange?e.ranges.forEach(n):(null==t&&(t=e),n(new SubRange(e,t))),this.ranges=r,this._update_length(),this}index(e){for(var t=0;t<this.ranges.length&&this.ranges[t].length<=e;)e-=this.ranges[t].length,t++;return this.ranges[t].low+e}toString(){return"[ "+this.ranges.join(", ")+" ]"}clone(){return new DRange(this)}numbers(){return this.ranges.reduce((e,t)=>{for(var r=t.low;r<=t.high;)e.push(r),r++;return e},[])}subranges(){return this.ranges.map(e=>({low:e.low,high:e.high,length:1+e.high-e.low}))}}var lib$1=DRange;const types$1=lib.types;var randexp=class e{constructor(e,t){if(this._setDefaults(e),e instanceof RegExp)this.ignoreCase=e.ignoreCase,this.multiline=e.multiline,e=e.source;else{if("string"!=typeof e)throw new Error("Expected a regexp or string");this.ignoreCase=t&&-1!==t.indexOf("i"),this.multiline=t&&-1!==t.indexOf("m")}this.tokens=lib(e)}_setDefaults(t){this.max=null!=t.max?t.max:null!=e.prototype.max?e.prototype.max:100,this.defaultRange=t.defaultRange?t.defaultRange:this.defaultRange.clone(),t.randInt&&(this.randInt=t.randInt)}gen(){return this._gen(this.tokens,[])}_gen(e,t){var r,n,i,a,o;switch(e.type){case types$1.ROOT:case types$1.GROUP:if(e.followedBy||e.notFollowedBy)return"";for(e.remember&&e.groupNumber===undefined&&(e.groupNumber=t.push(null)-1),n="",a=0,o=(r=e.options?this._randSelect(e.options):e.stack).length;a<o;a++)n+=this._gen(r[a],t);return e.remember&&(t[e.groupNumber]=n),n;case types$1.POSITION:return"";case types$1.SET:var s=this._expand(e);return s.length?String.fromCharCode(this._randSelect(s)):"";case types$1.REPETITION:for(i=this.randInt(e.min,e.max===Infinity?e.min+this.max:e.max),n="",a=0;a<i;a++)n+=this._gen(e.value,t);return n;case types$1.REFERENCE:return t[e.value-1]||"";case types$1.CHAR:var u=this.ignoreCase&&this._randBool()?this._toOtherCase(e.value):e.value;return String.fromCharCode(u)}}_toOtherCase(e){return e+(97<=e&&e<=122?-32:65<=e&&e<=90?32:0)}_randBool(){return!this.randInt(0,1)}_randSelect(e){return e instanceof lib$1?e.index(this.randInt(0,e.length-1)):e[this.randInt(0,e.length-1)]}_expand(e){if(e.type===lib.types.CHAR)return new lib$1(e.value);if(e.type===lib.types.RANGE)return new lib$1(e.from,e.to);{let t=new lib$1;for(let r=0;r<e.set.length;r++){let n=this._expand(e.set[r]);if(t.add(n),this.ignoreCase)for(let e=0;e<n.length;e++){let r=n.index(e),i=this._toOtherCase(r);r!==i&&t.add(i)}}return e.not?this.defaultRange.clone().subtract(t):this.defaultRange.clone().intersect(t)}}randInt(e,t){return e+Math.floor(Math.random()*(1+t-e))}get defaultRange(){return this._range=this._range||new lib$1(32,126)}set defaultRange(e){this._range=e}static randexp(t,r){var n;return"string"==typeof t&&(t=new RegExp(t,r)),t._randexp===undefined?(n=new e(t,r),t._randexp=n):(n=t._randexp)._setDefaults(t),n.gen()}static sugar(){RegExp.prototype.gen=function(){return e.randexp(this)}}};function getRandomInteger(e,t){return e=void 0===e?env.MIN_INTEGER:e,t=void 0===t?env.MAX_INTEGER:t,Math.floor(optionAPI("random")()*(t-e+1))+e}function _randexp(e){return randexp.prototype.max=optionAPI("defaultRandExpMax"),randexp.prototype.randInt=function(e,t){return e+Math.floor(optionAPI("random")()*(t-e+1))},new randexp(e).gen()}function pick(e){return e[Math.floor(optionAPI("random")()*e.length)]}function shuffle(e){for(var t,r,n=e.length,i=e.slice();n>0;)r=Math.floor(optionAPI("random")()*n),t=i[n-=1],i[n]=i[r],i[r]=t;return i}function getRandom(e,t){return optionAPI("random")()*(t-e)+e}function number(e,t,r,n,i){return void 0===i&&(i=!1),r=void 0===r?env.MIN_NUMBER:r,n=void 0===n?env.MAX_NUMBER:n,(t=void 0===t?n:t)<(e=void 0===e?r:e)&&(t+=e),i?getRandom(e,t):getRandomInteger(e,t)}function by(e){switch(e){case"seconds":return 60*number(0,60);case"minutes":return 612*number(15,50);case"hours":return 36123*number(12,72);case"days":return 86412345*number(7,30);case"weeks":return 604812345*number(4,52);case"months":return 2592012345*number(2,13);case"years":return 31104012345*number(1,20)}}function date(e){if(e)return by(e);var t=new Date,r=number(-1e3,env.MOST_NEAR_DATETIME);return t.setTime(t.getTime()-r),t}var random={pick:pick,date:date,shuffle:shuffle,number:number,randexp:_randexp};function getSubAttribute(e,t){for(var r=t.split(".");r.length;){var n=r.shift();if(!e[n])break;e=e[n]}return e}function hasProperties(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return t.filter((function(t){return"undefined"!=typeof e[t]})).length>0}function typecast(e,t,r){var n={};switch(e||t.type){case"integer":case"number":if("undefined"!=typeof t.minimum&&(n.minimum=t.minimum),"undefined"!=typeof t.maximum&&(n.maximum=t.maximum),t["enum"]){var i=Math.max(n.minimum||0,0),a=Math.min(n.maximum||Infinity,Infinity);t.exclusiveMinimum&&i===t.minimum&&(i+=t.multipleOf||1),t.exclusiveMaximum&&a===t.maximum&&(a-=t.multipleOf||1),(i||a!==Infinity)&&(t["enum"]=t["enum"].filter((function(e){return e>=i&&e<=a})))}break;case"string":n.minLength=optionAPI("minLength")||0,n.maxLength=optionAPI("maxLength")||Number.MAX_SAFE_INTEGER,"undefined"!=typeof t.minLength&&(n.minLength=Math.max(n.minLength,t.minLength)),"undefined"!=typeof t.maxLength&&(n.maxLength=Math.min(n.maxLength,t.maxLength))}var o=r(n);if(null===o||o===undefined)return null;switch(e||t.type){case"number":o=parseFloat(o);break;case"integer":o=parseInt(o,10);break;case"boolean":o=!!o;break;case"string":o=String(o);for(var s,u=Math.max(n.minLength||0,0),p=Math.min(n.maxLength||Infinity,Infinity);o.length<u&&(s=o,t.pattern?o+=random.randexp(t.pattern):o+=""+random.pick([" ","/","_","-","+","=","@","^"])+o,o!==s););switch(o.length>p&&(o=o.substr(0,p)),t.format){case"date-time":case"datetime":o=new Date(o).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"date":o=new Date(o).toISOString().substr(0,10);break;case"time":o=new Date("1969-01-01 "+o).toISOString().substr(11)}}return o}function merge(e,t){return Object.keys(t).forEach((function(r){"object"!=typeof t[r]||null===t[r]?e[r]=t[r]:Array.isArray(t[r])?(e[r]=e[r]||[],t[r].forEach((function(t){Array.isArray(e[r])&&-1===e[r].indexOf(t)&&e[r].push(t)}))):"object"!=typeof e[r]||null===e[r]||Array.isArray(e[r])?e[r]=merge({},t[r]):e[r]=merge(e[r],t[r])})),e}function clone(e,t){if(void 0===t&&(t=new Map),!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){var r=[];return t.set(e,r),r.push.apply(r,e.map((function(e){return clone(e,t)}))),r}var n={};return t.set(e,n),Object.keys(e).reduce((function(r,n){return r[n]=clone(e[n],t),r}),n)}function short(e){var t=JSON.stringify(e),r=JSON.stringify(e,null,2);return t.length>400?r.substr(0,400)+"...":r}function anyValue(){return random.pick([!1,!0,null,-1,NaN,Math.PI,Infinity,undefined,[],{},Math.random(),Math.random().toString(36).substr(2)])}function notValue(e,t){var r=merge({},t);if("undefined"!=typeof e.minimum&&(r.maximum=e.minimum,r.exclusiveMaximum=!0),"undefined"!=typeof e.maximum&&(r.minimum=e.maximum>r.maximum?0:e.maximum,r.exclusiveMinimum=!0),"undefined"!=typeof e.minLength&&(r.maxLength=e.minLength),"undefined"!=typeof e.maxLength&&(r.minLength=e.maxLength>r.maxLength?0:e.maxLength),e.type)r.type=random.pick(env.SCALAR_TYPES.filter((function(t){return(Array.isArray(e.type)?e.type:[e.type]).every((function(e){return"number"===t||"integer"===t?"number"!==e&&"integer"!==e:t!==e}))})));else if(e["enum"]){var n;do{n=anyValue()}while(-1!==e["enum"].indexOf(n));r["enum"]=[n]}return e.required&&r.properties&&e.required.forEach((function(e){delete r.properties[e]})),r}function validateValueForSchema(e,t){var r=t.minimum!==undefined,n=t.maximum!==undefined;return(r||n)&&(!r||e>=t.minimum)&&(!n||e<=t.maximum)}function validate(e,t){return!t.every((function(t){return validateValueForSchema(e,t)}))}function validateValueForOneOf(e,t){return 1===t.reduce((function(t,r){return t+(validateValueForSchema(e,r)?1:0)}),0)}function isKey(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)}function omitProps(e,t){return Object.keys(e).filter((function(e){return!t.includes(e)})).reduce((function(t,r){return Array.isArray(e[r])?t[r]=e[r].slice():t[r]=e[r]instanceof Object?merge({},e[r]):e[r],t}),{})}function template(e,t){return Array.isArray(e)?e.map((function(e){return template(e,t)})):("string"==typeof e&&(e=e.replace(/#\{([\w.-]+)\}/g,(function(e,r){return t[r]}))),e)}function isEmpty(e){return"[object Object]"==={}.toString.call(e)&&!Object.keys(e).length}function shouldClean(e,t){var r=Array.isArray(t.required)&&t.required.includes(e),n="function"==typeof t.thunk||t.additionalProperties&&"function"==typeof t.additionalProperties.thunk;return!r&&!n}function clean(e,t,r){return void 0===r&&(r=!1),e&&"object"==typeof e?Array.isArray(e)?e.map((function(e){return clean(e,t,!0)})).filter((function(e){return void 0!==e})):(Object.keys(e).forEach((function(r){if(isEmpty(e[r]))shouldClean(r,t)&&delete e[r];else{var n=clean(e[r],t);isEmpty(n)||(e[r]=n)}"undefined"==typeof e[r]&&delete e[r]})),!Object.keys(e).length&&r?undefined:e):e}var utils={getSubAttribute:getSubAttribute,hasProperties:hasProperties,omitProps:omitProps,typecast:typecast,merge:merge,clone:clone,short:short,notValue:notValue,anyValue:anyValue,validate:validate,validateValueForSchema:validateValueForSchema,validateValueForOneOf:validateValueForOneOf,isKey:isKey,template:template,shouldClean:shouldClean,clean:clean,isEmpty:isEmpty};function proxy(e){return function(t,r,n,i){var a=t,o=[];"object"==typeof t&&(a=Object.keys(t)[0],Array.isArray(t[a])?o=t[a]:o.push(t[a]));for(var s=a.split("."),u=e();s.length>1;)u=u[s.shift()];return"function"==typeof(t="object"==typeof u?u[s[0]]:u)&&(t=t.apply(u,o.map((function(e){return utils.template(e,i)})))),"[object Object]"==={}.toString.call(t)&&Object.keys(t).forEach((function(e){if("function"==typeof t[e])throw new Error("Cannot resolve value for '"+n+": "+a+"', given: "+t)})),t}}var Container=function(){this.registry={},this.support={}};Container.prototype.reset=function(e){e?(delete this.registry[e],delete this.support[e]):(this.registry={},this.support={})},Container.prototype.extend=function(e,t){var r=this;this.registry[e]=t(this.registry[e]),this.support[e]||(this.support[e]=proxy((function(){return r.registry[e]})))},Container.prototype.define=function(e,t){this.support[e]=t},Container.prototype.get=function(e){if("undefined"==typeof this.registry[e])throw new ReferenceError("'"+e+"' dependency doesn't exist.");return this.registry[e]},Container.prototype.wrap=function(e){for(var t=this,r=Object.keys(e),n={},i=r.length,a=function(){var a=r[i].replace(/^x-/,""),o=t.support[a];if("function"==typeof o)return Object.defineProperty(e,"generate",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return o.call(n,e[r[i]],e,r[i],t)}}),"break"};i--;){if("break"===a())break}return e};var registry$1=new Registry;function formatAPI(e,t){if(void 0===e)return registry$1.list();if("string"==typeof e)if("function"==typeof t)registry$1.register(e,t);else{if(null!==t&&!1!==t)return registry$1.get(e);registry$1.unregister(e)}else registry$1.registerMany(e)}var ParseError=function(e){function t(t,r){e.call(this),e.captureStackTrace&&e.captureStackTrace(this,this.constructor),this.name="ParseError",this.message=t,this.path=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Error),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","format"]};inferredProperties.number=inferredProperties.integer;var subschemaProperties=["additionalItems","items","additionalProperties","dependencies","patternProperties","properties"];function matchesType(e,t,r){return Object.keys(e).filter((function(e){var n=subschemaProperties.indexOf(t)>-1;return!(!(r.indexOf(e)>-1)||n)})).length>0}function inferType(e,t){for(var r=Object.keys(inferredProperties),n=0;n<r.length;n+=1){var i=r[n];if(matchesType(e,t[t.length-1],inferredProperties[i]))return i}}function booleanGenerator(){return optionAPI("random")()>.5}var booleanType=booleanGenerator;function nullGenerator(){return null}var nullType=nullGenerator;function unique(e,t,r,n,i,a){var o=[],s=[];function u(e){var t=JSON.stringify(e);return-1===s.indexOf(t)&&(s.push(t),o.push(e),!0)}t.forEach(u);for(var p=100;o.length!==t.length&&(u(a(r.items||n,e,i))||(p-=1),p););return o}function arrayType(e,t,r,n){var i=[];if(!e.items&&!e.additionalItems){if(utils.hasProperties(e,"minItems","maxItems","uniqueItems"))throw new ParseError("missing items for "+utils.short(e),t);return i}if(Array.isArray(e.items))return e.items.map((function(e,i){var a=t.concat(["items",i]);return n(e,a,r)}));var a=e.minItems,o=e.maxItems;optionAPI("minItems")&&(a=o?Math.min(optionAPI("minItems"),o):optionAPI("minItems")),optionAPI("maxItems")&&((o=a?Math.min(optionAPI("maxItems"),a):optionAPI("maxItems"))&&o>optionAPI("maxItems")&&(o=optionAPI("maxItems")),a&&a>optionAPI("maxItems")&&(a=o));var s=!0===optionAPI("alwaysFakeOptionals")?1:optionAPI("optionalsProbability"),u=optionAPI("alwaysFakeOptionals")||optionAPI("fixedProbabilities")||!1,p=random.number(a,o,1,5);!1!==s&&(p=Math.max(u?Math.round((o||p)*s):Math.abs(random.number(a,o)*s),a||0));for(var l="object"==typeof e.additionalItems?e.additionalItems:{},f=i.length;f<p;f+=1){var c=t.concat(["items",f]),h=n(e.items||l,c,r);i.push(h)}return e.uniqueItems?unique(t.concat(["items"]),i,e,l,r,n):i}function numberType(e){var t="undefined"==typeof e.minimum?env.MIN_INTEGER:e.minimum,r="undefined"==typeof e.maximum?env.MAX_INTEGER:e.maximum,n=e.multipleOf;if(n&&(r=Math.floor(r/n)*n,t=Math.ceil(t/n)*n),e.exclusiveMinimum&&t===e.minimum&&(t+=n||1),e.exclusiveMaximum&&r===e.maximum&&(r-=n||1),t>r)return NaN;if(n){if(-1===String(n).indexOf(".")){for(var i=random.number(Math.floor(t/n),Math.floor(r/n))*n;i<t;)i+=e.multipleOf;return i}var a,o,s=(r-t)/n;do{o=(a=random.number(0,s)*n)/n%1}while(0!==o);return t+a}return random.number(t,r,undefined,undefined,!0)}function integerType(e){return numberType(Object.assign({multipleOf:1},e))}var LIPSUM_WORDS="Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore\net dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\ncommodo consequat Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\npariatur Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est\nlaborum".split(/\W/);function wordsGenerator(e){return random.shuffle(LIPSUM_WORDS).slice(0,e)}var anyType={type:["string","number","integer","boolean"]};function objectType(e,t,r,n){var i={},a=e.properties||{},o=e.patternProperties||{},s="boolean"==typeof e.required?[]:(e.required||[]).slice(),u=!1!==e.additionalProperties,p=Object.keys(a),l=Object.keys(o),f=p.concat(l).reduce((function(e,t){return-1===s.indexOf(t)&&e.push(t),e}),[]),c=s.concat(f),h=u&&!0===e.additionalProperties?anyType:e.additionalProperties;if(!u&&0===p.length&&0===l.length&&utils.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(!0===optionAPI("requiredOnly"))return s.forEach((function(e){a[e]&&(i[e]=a[e])})),n(i,t.concat(["properties"]),r,e);var m=!0===optionAPI("alwaysFakeOptionals")?1:optionAPI("optionalsProbability"),d=optionAPI("alwaysFakeOptionals")||optionAPI("fixedProbabilities")||!1,y=optionAPI("ignoreProperties")||[],g=Math.max(e.minProperties||0,s.length),v=e.maxProperties||c.length+(u?random.number(1,5):0),b=Math.max(0,c.length-g);1!==c.length||s.length||(b=random.number(b,c.length+(c.length-g))),!1!==m&&(b=!0===d?Math.round(g-s.length+m*(c.length-g)):random.number(g-s.length,m*(c.length-g)));var A=random.shuffle(f).slice(0,b),I=f.filter((function(e){return-1!==A.indexOf(e)})),x=!1!==m?v:random.number(0,v),E=s.concat(I.slice(0,x)),R=[];if(e.dependencies&&(Object.keys(e.dependencies).forEach((function(t){var r=e.dependencies[t];-1!==E.indexOf(t)&&(Array.isArray(r)?r.forEach((function(e){-1===E.indexOf(e)&&E.push(e)})):R.push(r))})),R.length))return delete e.dependencies,n({allOf:R.concat(e)},t.concat(["properties"]),r,e);var P=[];E.forEach((function(e){for(var t=0;t<y.length;t+=1)if(y[t]instanceof RegExp&&y[t].test(e)||"string"==typeof y[t]&&y[t]===e||"function"==typeof y[t]&&y[t](a[e],e))return void P.push(e);var r;if(!1===h&&-1!==s.indexOf(e)&&(i[e]=a[e]),a[e]&&(i[e]=a[e]),l.forEach((function(t){e.match(new RegExp(t))&&(r=!0,i[e]?utils.merge(i[e],o[t]):i[random.randexp(e)]=o[t])})),!r){var n=o[e]||h;n&&!1!==h&&(i[o[e]?random.randexp(e):e]=a[e]||n)}}));var O,w=optionAPI("fillProperties"),T=optionAPI("reuseProperties"),S=Object.keys(i).length+(w?0:P.length);function M(e){var t;do{if(!e.length)break;t=e.shift()}while(i[t]);return t}for(;w&&(l.length||u)&&!(S>=g);){if(u)if(T&&p.length-S>g){var _=0,k=void 0;do{if((_+=1)>1e3)break;k=M(s)||random.pick(p)}while("undefined"!=typeof i[k]);"undefined"==typeof i[k]&&(i[k]=a[k],S+=1)}else if(l.length&&!h){var N=random.pick(l),j=random.randexp(N);i[j]||(i[j]=o[N],S+=1)}else{var C=M(s)||wordsGenerator(1)+(O=void 0,random.randexp("_?[_a-f\\d]{1,3}"+(O?"\\$?":"")));i[C]||(i[C]=h||anyType,S+=1)}for(var $=0;S<g&&$<l.length;$+=1){var L=l[$],G=random.randexp(L);i[G]||(i[G]=o[L],S+=1)}}if(0===s.length&&(!u||!1===m))for(var D=random.number(g,v);S<D;){var F=M(p);F&&(i[F]=a[F]),S+=1}return n(i,t.concat(["properties"]),r,e)}function produce(){return wordsGenerator(random.number(1,5)).join(" ")}function thunkGenerator(e,t){void 0===e&&(e=0),void 0===t&&(t=140);for(var r=Math.max(0,e),n=random.number(r,t),i=produce();i.length<r;)i+=produce();return i.length>n&&(i=i.substr(0,n)),i}function ipv4Generator(){return[0,0,0,0].map((function(){return random.number(0,255)})).join(".")}function dateTimeGenerator(){return random.date().toISOString()}function dateGenerator(){return dateTimeGenerator().slice(0,10)}function timeGenerator(){return dateTimeGenerator().slice(11)}var FRAGMENT="[a-zA-Z][a-zA-Z0-9+-.]*",URI_PATTERN="https?://{hostname}(?:"+FRAGMENT+")+",PARAM_PATTERN="(?:\\?([a-z]{1,7}(=\\w{1,5})?&){0,3})?",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:URI_PATTERN,slug:"[a-zA-Z\\d_-]+","uri-reference":""+URI_PATTERN+PARAM_PATTERN,"uri-template":URI_PATTERN.replace("(?:","(?:/\\{[a-z][:a-zA-Z0-9-]*\\}|"),"json-pointer":"(/(?:"+FRAGMENT.replace("]*","/]*")+"|~[01]))+",uuid:"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"};regexps.iri=regexps["uri-reference"],regexps["iri-reference"]=regexps["uri-reference"],regexps["idn-email"]=regexps.email,regexps["idn-hostname"]=regexps.hostname;var ALLOWED_FORMATS=new RegExp("\\{("+Object.keys(regexps).join("|")+")\\}");function coreFormatGenerator(e){return random.randexp(regexps[e]).replace(ALLOWED_FORMATS,(function(e,t){return random.randexp(regexps[t])}))}function generateFormat(e,t){var r=formatAPI(e.format);if("function"==typeof r)return r(e);switch(e.format){case"date-time":case"datetime":return dateTimeGenerator();case"date":return dateGenerator();case"time":return timeGenerator();case"ipv4":return ipv4Generator();case"regex":return".+?";case"email":case"hostname":case"ipv6":case"uri":case"uri-reference":case"iri":case"iri-reference":case"idn-email":case"idn-hostname":case"json-pointer":case"slug":case"uri-template":case"uuid":return coreFormatGenerator(e.format);default:if(void 0===r){if(optionAPI("failOnInvalidFormat"))throw new Error("unknown registry key "+utils.short(e.format));return t()}throw new Error("unsupported format '"+e.format+"'")}}function stringType(e){return utils.typecast("string",e,(function(t){return e.format?generateFormat(e,(function(){return thunkGenerator(t.minLength,t.maxLength)})):e.pattern?random.randexp(e.pattern):thunkGenerator(t.minLength,t.maxLength)}))}var typeMap={boolean:booleanType,"null":nullType,array:arrayType,integer:integerType,number:numberType,object:objectType,string:stringType};function traverse(e,t,r,n){if(e=r(e,null,t)){if("properties"!==t[t.length-1]){if(optionAPI("useExamplesValue")&&Array.isArray(e.examples)){var i=e.examples.concat("default"in e?[e["default"]]:[]);return utils.typecast(null,e,(function(){return random.pick(i)}))}if(optionAPI("useDefaultValue")&&"default"in e&&(""!==e["default"]||!optionAPI("replaceEmptyByRandomValue")))return e["default"];if("template"in e)return utils.template(e.template,n);if("const"in e)return e["const"]}if(e.not&&"object"==typeof e.not&&(e=utils.notValue(e.not,utils.omitProps(e,["not"]))).type&&"object"===e.type){var a=traverse(e,t.concat(["not"]),r,n);return utils.clean(a,e,!1)}if("function"==typeof e.thunk)return traverse(e.thunk(n),t,r);if("function"==typeof e.generate)return utils.typecast(null,e,(function(){return e.generate(n)}));if("string"==typeof e.pattern)return utils.typecast("string",e,(function(){return random.randexp(e.pattern)}));if(Array.isArray(e["enum"]))return utils.typecast(null,e,(function(){return random.pick(e["enum"])}));if(e.jsonPath)return e;var o=e.type;if(Array.isArray(o)?o=random.pick(o):void 0===o&&(o=inferType(e,t)||o)&&(e.type=o),"string"==typeof o){if(!typeMap[o]){if(optionAPI("failOnInvalidTypes"))throw new ParseError("unknown primitive "+utils.short(o),t.concat(["type"]));return optionAPI("defaultInvalidTypeProduct")}try{return typeMap[o](e,t,r,traverse)}catch(u){if("undefined"==typeof u.path)throw new ParseError(u.stack,t);throw u}}var s={};return Array.isArray(e)&&(s=[]),Object.keys(e).forEach((function(n){if("object"==typeof e[n]&&"definitions"!==n){var i=traverse(e[n],t.concat([n]),r,s);s[n]=utils.clean(i,e[n],!1)}else s[n]=e[n]})),s}}var buildResolveSchema=function(e){var t,r=e.refs,n=e.schema,i=e.container,a=e.refDepthMax,o=e.refDepthMin,s=0,u={resolveSchema:function(e,p,l){if(null===e||e===undefined)return null;if("function"==typeof e.generate)return e;if("string"==typeof(e.$id||e.id)&&(delete e.id,delete e.$id,delete e.$schema),"string"==typeof e.$ref){var f,c=Math.max(o,a)-1;if("#"===e.$ref||t===e.$ref&&++s>c)return delete e.$ref,e;if(t=e.$ref,-1===e.$ref.indexOf("#/")&&(f=r[e.$ref]||null),0===e.$ref.indexOf("#/definitions/")&&(f=n.definitions[e.$ref.split("#/definitions/")[1]]||null),void 0!==f){if(!f&&!0!==optionAPI("ignoreMissingRefs"))throw new Error("Reference not found: "+e.$ref);utils.merge(e,f||{})}return delete e.$ref,e}if(Array.isArray(e.allOf)){var h=e.allOf;delete e.allOf,h.forEach((function(t){var r=u.resolveSchema(t,null,l);utils.merge(e,"function"==typeof r.thunk?r.thunk(e):r),Array.isArray(e.allOf)&&u.resolveSchema(e,p,l)}))}if(Array.isArray(e.oneOf||e.anyOf)){var m=e.oneOf||e.anyOf;return e["enum"]&&e.oneOf&&(e["enum"]=e["enum"].filter((function(e){return utils.validate(e,m)}))),{thunk:function(t){var r=utils.omitProps(e,["anyOf","oneOf"]),n=random.pick(m);return utils.merge(r,n),m.forEach((function(e){e.required&&e!==n&&e.required.forEach((function(e){var n=r.required&&r.required.includes(e);r.properties&&!n&&delete r.properties[e],t&&t.properties&&delete t.properties[e]}))})),r}}}if(Object.keys(e).forEach((function(t){!Array.isArray(e[t])&&"object"!=typeof e[t]||utils.isKey(t)||(e[t]=u.resolveSchema(e[t],t,l.concat(t)))})),l){var d=l[l.length-1];if("properties"===d||"items"===d)return e}return i.wrap(e)}};return u};function pick$1(e){return Array.isArray(e)?random.pick(e):e}function cycle(e,t){if(!Array.isArray(e))return e;var r=t?e.pop():e.shift();return t?e.unshift(r):e.push(r),r}function resolve(e,t,r,n){if(!e||"object"!=typeof e)return e;if(r||(r={}),t||(t=e),Array.isArray(e))return e.map((function(e){return resolve(e,t,r,n)}));if(e.jsonPath){var i="object"!=typeof e.jsonPath?{path:e.jsonPath}:e.jsonPath;i.group=e.group||i.group||n,i.cycle=e.cycle||i.cycle||!1,i.reverse=e.reverse||i.reverse||!1,i.count=e.count||i.count||1;var a=i.group+"__"+i.path;return r[a]||(i.count>1?r[a]=jsonpathPlus.JSONPath(i.path,t).slice(0,i.count):r[a]=jsonpathPlus.JSONPath(i.path,t)),i.cycle||i.reverse?cycle(r[a],i.reverse):pick$1(r[a])}return Object.keys(e).forEach((function(n){e[n]=resolve(e[n],t,r,n)})),e}function run(e,t,r){var n=optionAPI("refDepthMin")||0,i=optionAPI("refDepthMax")||3;try{var a=buildResolveSchema({refs:e,schema:t,container:r,refDepthMin:n,refDepthMax:i}).resolveSchema,o=traverse(utils.clone(t),[],a);return optionAPI("resolveJsonPath")?resolve(o):o}catch(s){throw s.path?new Error(s.message+" in /"+s.path.join("/")):s}}var container=new Container;function setupKeywords(){container.define("autoIncrement",(function(e,t){if(!this.offset){var r=t.minimum||1,n=r+env.MAX_NUMBER,i=e.initialOffset||t.initialOffset;this.offset=i||random.number(r,n)}return!0===e?this.offset++:t})),container.define("sequentialDate",(function(e,t){if(this.now||(this.now=random.date()),e){if(t=this.now.toISOString(),-1===["seconds","minutes","hours","days","weeks","months","years"].indexOf(e=!0===e?"days":e))throw new Error("Unsupported increment by "+utils.short(e));this.now.setTime(this.now.getTime()+random.date(e))}return t}))}function getRefs(e){var t={};return Array.isArray(e)?e.forEach((function(e){t[e.$id||e.id]=e})):t=e||{},t}var jsf=function(e,t,r){return jsf.generate(e,t)};jsf.generate=function(e,t){return run(getRefs(t),e,container)},jsf.resolve=function(e,t,r){"string"==typeof t&&(r=t,t={}),r=(r=r||("undefined"!=typeof process?process.cwd():"")).replace(/\/+$/,"")+"/";var n=getRefs(t),i={order:1,canRead:function(e){return n[e.url]||n[e.url.split("/").pop()]},read:function(e,t){try{t(null,n[e.url]||n[e.url.split("/").pop()])}catch(r){t(r)}}};return $RefParser.dereference(r,e,{resolve:{file:{order:100},http:{order:200},fixedRefs:i},dereference:{circular:"ignore"}}).then((function(e){return run(n,e,container)}))},setupKeywords(),jsf.format=formatAPI,jsf.option=optionAPI,jsf.random=random,jsf.extend=function(e,t){return container.extend(e,t),jsf},jsf.define=function(e,t){return container.define(e,t),jsf},jsf.reset=function(e){return container.reset(e),setupKeywords(),jsf},jsf.locate=function(e){return container.get(e)};var VERSION="0.5.0-rcv.29";void 0!==VERSION&&(jsf.version=VERSION),module.exports=jsf; | ||
function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}var $RefParser=_interopDefault(require("json-schema-ref-parser")),jsonpathPlus=require("jsonpath-plus"),Registry=function(){this.data={}};Registry.prototype.unregister=function(e){e?delete this.data[e]:this.data={}},Registry.prototype.register=function(e,t){this.data[e]=t},Registry.prototype.registerMany=function(e){var t=this;Object.keys(e).forEach((function(r){t.data[r]=e[r]}))},Registry.prototype.get=function(e){return this.data[e]},Registry.prototype.list=function(){return this.data};var defaults={};defaults.defaultInvalidTypeProduct=undefined,defaults.defaultRandExpMax=10,defaults.ignoreProperties=[],defaults.ignoreMissingRefs=!1,defaults.failOnInvalidTypes=!0,defaults.failOnInvalidFormat=!0,defaults.alwaysFakeOptionals=!1,defaults.optionalsProbability=null,defaults.fixedProbabilities=!1,defaults.useExamplesValue=!1,defaults.useDefaultValue=!1,defaults.requiredOnly=!1,defaults.minItems=0,defaults.maxItems=null,defaults.minLength=0,defaults.maxLength=null,defaults.resolveJsonPath=!1,defaults.reuseProperties=!1,defaults.fillProperties=!0,defaults.replaceEmptyByRandomValue=!1,defaults.random=Math.random;var OptionRegistry=function(e){function t(){e.call(this),this.data=Object.assign({},defaults),this._defaults=defaults}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaults:{configurable:!0}};return r.defaults.get=function(){return Object.assign({},this._defaults)},Object.defineProperties(t.prototype,r),t}(Registry),registry=new OptionRegistry;function optionAPI(e,t){return"string"==typeof e?void 0!==t?registry.register(e,t):registry.get(e):registry.registerMany(e)}optionAPI.getDefaults=function(){return registry.defaults};var SCALAR_TYPES=["integer","number","string","boolean","null"],ALL_TYPES=["array","object"].concat(SCALAR_TYPES),MOST_NEAR_DATETIME=2524608e6,MIN_INTEGER=-1e8,MAX_INTEGER=1e8,MIN_NUMBER=-100,MAX_NUMBER=100,env={SCALAR_TYPES:SCALAR_TYPES,ALL_TYPES:ALL_TYPES,MIN_NUMBER:MIN_NUMBER,MAX_NUMBER:MAX_NUMBER,MIN_INTEGER:MIN_INTEGER,MAX_INTEGER:MAX_INTEGER,MOST_NEAR_DATETIME:MOST_NEAR_DATETIME};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var types={ROOT:0,GROUP:1,POSITION:2,SET:3,RANGE:4,REPETITION:5,REFERENCE:6,CHAR:7};const INTS=()=>[{type:types.RANGE,from:48,to:57}],WORDS=()=>[{type:types.CHAR,value:95},{type:types.RANGE,from:97,to:122},{type:types.RANGE,from:65,to:90}].concat(INTS()),WHITESPACE=()=>[{type:types.CHAR,value:9},{type:types.CHAR,value:10},{type:types.CHAR,value:11},{type:types.CHAR,value:12},{type:types.CHAR,value:13},{type:types.CHAR,value:32},{type:types.CHAR,value:160},{type:types.CHAR,value:5760},{type:types.RANGE,from:8192,to:8202},{type:types.CHAR,value:8232},{type:types.CHAR,value:8233},{type:types.CHAR,value:8239},{type:types.CHAR,value:8287},{type:types.CHAR,value:12288},{type:types.CHAR,value:65279}],NOTANYCHAR=()=>[{type:types.CHAR,value:10},{type:types.CHAR,value:13},{type:types.CHAR,value:8232},{type:types.CHAR,value:8233}];var words=()=>({type:types.SET,set:WORDS(),not:!1}),notWords=()=>({type:types.SET,set:WORDS(),not:!0}),ints=()=>({type:types.SET,set:INTS(),not:!1}),notInts=()=>({type:types.SET,set:INTS(),not:!0}),whitespace=()=>({type:types.SET,set:WHITESPACE(),not:!1}),notWhitespace=()=>({type:types.SET,set:WHITESPACE(),not:!0}),anyChar=()=>({type:types.SET,set:NOTANYCHAR(),not:!0}),sets={words:words,notWords:notWords,ints:ints,notInts:notInts,whitespace:whitespace,notWhitespace:notWhitespace,anyChar:anyChar},util=createCommonjsModule((function(e,t){const r={0:0,t:9,n:10,v:11,f:12,r:13};t.strToChars=function(e){return e=e.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(function(e,t,n,i,a,o,s,u){if(n)return e;var p=t?8:i?parseInt(i,16):a?parseInt(a,16):o?parseInt(o,8):s?"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s):r[u],l=String.fromCharCode(p);return/[[\]{}^$.|?*+()]/.test(l)&&(l="\\"+l),l}))},t.tokenizeClass=(e,r)=>{for(var n,i,a=[],o=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g;null!=(n=o.exec(e));)if(n[1])a.push(sets.words());else if(n[2])a.push(sets.ints());else if(n[3])a.push(sets.whitespace());else if(n[4])a.push(sets.notWords());else if(n[5])a.push(sets.notInts());else if(n[6])a.push(sets.notWhitespace());else if(n[7])a.push({type:types.RANGE,from:(n[8]||n[9]).charCodeAt(0),to:n[10].charCodeAt(0)});else{if(!(i=n[12]))return[a,o.lastIndex];a.push({type:types.CHAR,value:i.charCodeAt(0)})}t.error(r,"Unterminated character class")},t.error=(e,t)=>{throw new SyntaxError("Invalid regular expression: /"+e+"/: "+t)}})),util_1=util.strToChars,util_2=util.tokenizeClass,util_3=util.error,wordBoundary=()=>({type:types.POSITION,value:"b"}),nonWordBoundary=()=>({type:types.POSITION,value:"B"}),begin=()=>({type:types.POSITION,value:"^"}),end=()=>({type:types.POSITION,value:"$"}),positions={wordBoundary:wordBoundary,nonWordBoundary:nonWordBoundary,begin:begin,end:end},lib=e=>{var t,r,n=0,i={type:types.ROOT,stack:[]},a=i,o=i.stack,s=[],u=t=>{util.error(e,`Nothing to repeat at column ${t-1}`)},p=util.strToChars(e);for(t=p.length;n<t;)switch(r=p[n++]){case"\\":switch(r=p[n++]){case"b":o.push(positions.wordBoundary());break;case"B":o.push(positions.nonWordBoundary());break;case"w":o.push(sets.words());break;case"W":o.push(sets.notWords());break;case"d":o.push(sets.ints());break;case"D":o.push(sets.notInts());break;case"s":o.push(sets.whitespace());break;case"S":o.push(sets.notWhitespace());break;default:/\d/.test(r)?o.push({type:types.REFERENCE,value:parseInt(r,10)}):o.push({type:types.CHAR,value:r.charCodeAt(0)})}break;case"^":o.push(positions.begin());break;case"$":o.push(positions.end());break;case"[":var l;"^"===p[n]?(l=!0,n++):l=!1;var f=util.tokenizeClass(p.slice(n),e);n+=f[1],o.push({type:types.SET,set:f[0],not:l});break;case".":o.push(sets.anyChar());break;case"(":var c={type:types.GROUP,stack:[],remember:!0};"?"===(r=p[n])&&(r=p[n+1],n+=2,"="===r?c.followedBy=!0:"!"===r?c.notFollowedBy=!0:":"!==r&&util.error(e,`Invalid group, character '${r}'`+` after '?' at column ${n-1}`),c.remember=!1),o.push(c),s.push(a),a=c,o=c.stack;break;case")":0===s.length&&util.error(e,`Unmatched ) at column ${n-1}`),o=(a=s.pop()).options?a.options[a.options.length-1]:a.stack;break;case"|":a.options||(a.options=[a.stack],delete a.stack);var h=[];a.options.push(h),o=h;break;case"{":var d,m,y=/^(\d+)(,(\d+)?)?\}/.exec(p.slice(n));null!==y?(0===o.length&&u(n),d=parseInt(y[1],10),m=y[2]?y[3]?parseInt(y[3],10):Infinity:d,n+=y[0].length,o.push({type:types.REPETITION,min:d,max:m,value:o.pop()})):o.push({type:types.CHAR,value:123});break;case"?":0===o.length&&u(n),o.push({type:types.REPETITION,min:0,max:1,value:o.pop()});break;case"+":0===o.length&&u(n),o.push({type:types.REPETITION,min:1,max:Infinity,value:o.pop()});break;case"*":0===o.length&&u(n),o.push({type:types.REPETITION,min:0,max:Infinity,value:o.pop()});break;default:o.push({type:types.CHAR,value:r.charCodeAt(0)})}return 0!==s.length&&util.error(e,"Unterminated group"),i},types_1=types;lib.types=types_1;class SubRange{constructor(e,t){this.low=e,this.high=t,this.length=1+t-e}overlaps(e){return!(this.high<e.low||this.low>e.high)}touches(e){return!(this.high+1<e.low||this.low-1>e.high)}add(e){return new SubRange(Math.min(this.low,e.low),Math.max(this.high,e.high))}subtract(e){return e.low<=this.low&&e.high>=this.high?[]:e.low>this.low&&e.high<this.high?[new SubRange(this.low,e.low-1),new SubRange(e.high+1,this.high)]:e.low<=this.low?[new SubRange(e.high+1,this.high)]:[new SubRange(this.low,e.low-1)]}toString(){return this.low==this.high?this.low.toString():this.low+"-"+this.high}}class DRange{constructor(e,t){this.ranges=[],this.length=0,null!=e&&this.add(e,t)}_update_length(){this.length=this.ranges.reduce((e,t)=>e+t.length,0)}add(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.touches(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.touches(this.ranges[t]);)e=e.add(this.ranges[t]),t++;r.push(e),this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof DRange?e.ranges.forEach(r):(null==t&&(t=e),r(new SubRange(e,t))),this}subtract(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.overlaps(this.ranges[t]);)r=r.concat(this.ranges[t].subtract(e)),t++;this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof DRange?e.ranges.forEach(r):(null==t&&(t=e),r(new SubRange(e,t))),this}intersect(e,t){var r=[],n=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(;t<this.ranges.length&&e.overlaps(this.ranges[t]);){var n=Math.max(this.ranges[t].low,e.low),i=Math.min(this.ranges[t].high,e.high);r.push(new SubRange(n,i)),t++}};return e instanceof DRange?e.ranges.forEach(n):(null==t&&(t=e),n(new SubRange(e,t))),this.ranges=r,this._update_length(),this}index(e){for(var t=0;t<this.ranges.length&&this.ranges[t].length<=e;)e-=this.ranges[t].length,t++;return this.ranges[t].low+e}toString(){return"[ "+this.ranges.join(", ")+" ]"}clone(){return new DRange(this)}numbers(){return this.ranges.reduce((e,t)=>{for(var r=t.low;r<=t.high;)e.push(r),r++;return e},[])}subranges(){return this.ranges.map(e=>({low:e.low,high:e.high,length:1+e.high-e.low}))}}var lib$1=DRange;const types$1=lib.types;var randexp=class e{constructor(e,t){if(this._setDefaults(e),e instanceof RegExp)this.ignoreCase=e.ignoreCase,this.multiline=e.multiline,e=e.source;else{if("string"!=typeof e)throw new Error("Expected a regexp or string");this.ignoreCase=t&&-1!==t.indexOf("i"),this.multiline=t&&-1!==t.indexOf("m")}this.tokens=lib(e)}_setDefaults(t){this.max=null!=t.max?t.max:null!=e.prototype.max?e.prototype.max:100,this.defaultRange=t.defaultRange?t.defaultRange:this.defaultRange.clone(),t.randInt&&(this.randInt=t.randInt)}gen(){return this._gen(this.tokens,[])}_gen(e,t){var r,n,i,a,o;switch(e.type){case types$1.ROOT:case types$1.GROUP:if(e.followedBy||e.notFollowedBy)return"";for(e.remember&&e.groupNumber===undefined&&(e.groupNumber=t.push(null)-1),n="",a=0,o=(r=e.options?this._randSelect(e.options):e.stack).length;a<o;a++)n+=this._gen(r[a],t);return e.remember&&(t[e.groupNumber]=n),n;case types$1.POSITION:return"";case types$1.SET:var s=this._expand(e);return s.length?String.fromCharCode(this._randSelect(s)):"";case types$1.REPETITION:for(i=this.randInt(e.min,e.max===Infinity?e.min+this.max:e.max),n="",a=0;a<i;a++)n+=this._gen(e.value,t);return n;case types$1.REFERENCE:return t[e.value-1]||"";case types$1.CHAR:var u=this.ignoreCase&&this._randBool()?this._toOtherCase(e.value):e.value;return String.fromCharCode(u)}}_toOtherCase(e){return e+(97<=e&&e<=122?-32:65<=e&&e<=90?32:0)}_randBool(){return!this.randInt(0,1)}_randSelect(e){return e instanceof lib$1?e.index(this.randInt(0,e.length-1)):e[this.randInt(0,e.length-1)]}_expand(e){if(e.type===lib.types.CHAR)return new lib$1(e.value);if(e.type===lib.types.RANGE)return new lib$1(e.from,e.to);{let t=new lib$1;for(let r=0;r<e.set.length;r++){let n=this._expand(e.set[r]);if(t.add(n),this.ignoreCase)for(let e=0;e<n.length;e++){let r=n.index(e),i=this._toOtherCase(r);r!==i&&t.add(i)}}return e.not?this.defaultRange.clone().subtract(t):this.defaultRange.clone().intersect(t)}}randInt(e,t){return e+Math.floor(Math.random()*(1+t-e))}get defaultRange(){return this._range=this._range||new lib$1(32,126)}set defaultRange(e){this._range=e}static randexp(t,r){var n;return"string"==typeof t&&(t=new RegExp(t,r)),t._randexp===undefined?(n=new e(t,r),t._randexp=n):(n=t._randexp)._setDefaults(t),n.gen()}static sugar(){RegExp.prototype.gen=function(){return e.randexp(this)}}};function getRandomInteger(e,t){return e=void 0===e?env.MIN_INTEGER:e,t=void 0===t?env.MAX_INTEGER:t,Math.floor(optionAPI("random")()*(t-e+1))+e}function _randexp(e){return randexp.prototype.max=optionAPI("defaultRandExpMax"),randexp.prototype.randInt=function(e,t){return e+Math.floor(optionAPI("random")()*(t-e+1))},new randexp(e).gen()}function pick(e){return e[Math.floor(optionAPI("random")()*e.length)]}function shuffle(e){for(var t,r,n=e.length,i=e.slice();n>0;)r=Math.floor(optionAPI("random")()*n),t=i[n-=1],i[n]=i[r],i[r]=t;return i}function getRandom(e,t){return optionAPI("random")()*(t-e)+e}function number(e,t,r,n,i){return void 0===i&&(i=!1),r=void 0===r?env.MIN_NUMBER:r,n=void 0===n?env.MAX_NUMBER:n,(t=void 0===t?n:t)<(e=void 0===e?r:e)&&(t+=e),i?getRandom(e,t):getRandomInteger(e,t)}function by(e){switch(e){case"seconds":return 60*number(0,60);case"minutes":return 612*number(15,50);case"hours":return 36123*number(12,72);case"days":return 86412345*number(7,30);case"weeks":return 604812345*number(4,52);case"months":return 2592012345*number(2,13);case"years":return 31104012345*number(1,20)}}function date(e){if(e)return by(e);var t=new Date,r=number(-1e3,env.MOST_NEAR_DATETIME);return t.setTime(t.getTime()-r),t}var random={pick:pick,date:date,shuffle:shuffle,number:number,randexp:_randexp};function getLocalRef(e,t){for(var r=t.replace("#/","").split("/");r.length;){var n=r.shift();if(!e[n])throw new Error("Prop not found: "+n+" ("+t+")");e=e[n]}return e}function hasProperties(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return t.filter((function(t){return"undefined"!=typeof e[t]})).length>0}function typecast(e,t,r){var n={};switch(e||t.type){case"integer":case"number":if("undefined"!=typeof t.minimum&&(n.minimum=t.minimum),"undefined"!=typeof t.maximum&&(n.maximum=t.maximum),t["enum"]){var i=Math.max(n.minimum||0,0),a=Math.min(n.maximum||Infinity,Infinity);t.exclusiveMinimum&&i===t.minimum&&(i+=t.multipleOf||1),t.exclusiveMaximum&&a===t.maximum&&(a-=t.multipleOf||1),(i||a!==Infinity)&&(t["enum"]=t["enum"].filter((function(e){return e>=i&&e<=a})))}break;case"string":n.minLength=optionAPI("minLength")||0,n.maxLength=optionAPI("maxLength")||Number.MAX_SAFE_INTEGER,"undefined"!=typeof t.minLength&&(n.minLength=Math.max(n.minLength,t.minLength)),"undefined"!=typeof t.maxLength&&(n.maxLength=Math.min(n.maxLength,t.maxLength))}var o=r(n);if(null===o||o===undefined)return null;switch(e||t.type){case"number":o=parseFloat(o);break;case"integer":o=parseInt(o,10);break;case"boolean":o=!!o;break;case"string":o=String(o);for(var s,u=Math.max(n.minLength||0,0),p=Math.min(n.maxLength||Infinity,Infinity);o.length<u&&(s=o,t.pattern?o+=random.randexp(t.pattern):o+=""+random.pick([" ","/","_","-","+","=","@","^"])+o,o!==s););switch(o.length>p&&(o=o.substr(0,p)),t.format){case"date-time":case"datetime":o=new Date(o).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"date":o=new Date(o).toISOString().substr(0,10);break;case"time":o=new Date("1969-01-01 "+o).toISOString().substr(11)}}return o}function merge(e,t){return Object.keys(t).forEach((function(r){"object"!=typeof t[r]||null===t[r]?e[r]=t[r]:Array.isArray(t[r])?(e[r]=e[r]||[],t[r].forEach((function(t){Array.isArray(e[r])&&-1===e[r].indexOf(t)&&e[r].push(t)}))):"object"!=typeof e[r]||null===e[r]||Array.isArray(e[r])?e[r]=merge({},t[r]):e[r]=merge(e[r],t[r])})),e}function clone(e,t){if(void 0===t&&(t=new Map),!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){var r=[];return t.set(e,r),r.push.apply(r,e.map((function(e){return clone(e,t)}))),r}var n={};return t.set(e,n),Object.keys(e).reduce((function(r,n){return r[n]=clone(e[n],t),r}),n)}function short(e){var t=JSON.stringify(e),r=JSON.stringify(e,null,2);return t.length>400?r.substr(0,400)+"...":r}function anyValue(){return random.pick([!1,!0,null,-1,NaN,Math.PI,Infinity,undefined,[],{},Math.random(),Math.random().toString(36).substr(2)])}function notValue(e,t){var r=merge({},t);if("undefined"!=typeof e.minimum&&(r.maximum=e.minimum,r.exclusiveMaximum=!0),"undefined"!=typeof e.maximum&&(r.minimum=e.maximum>r.maximum?0:e.maximum,r.exclusiveMinimum=!0),"undefined"!=typeof e.minLength&&(r.maxLength=e.minLength),"undefined"!=typeof e.maxLength&&(r.minLength=e.maxLength>r.maxLength?0:e.maxLength),e.type)r.type=random.pick(env.SCALAR_TYPES.filter((function(t){return(Array.isArray(e.type)?e.type:[e.type]).every((function(e){return"number"===t||"integer"===t?"number"!==e&&"integer"!==e:t!==e}))})));else if(e["enum"]){var n;do{n=anyValue()}while(-1!==e["enum"].indexOf(n));r["enum"]=[n]}return e.required&&r.properties&&e.required.forEach((function(e){delete r.properties[e]})),r}function validateValueForSchema(e,t){var r=t.minimum!==undefined,n=t.maximum!==undefined;return(r||n)&&(!r||e>=t.minimum)&&(!n||e<=t.maximum)}function validate(e,t){return!t.every((function(t){return validateValueForSchema(e,t)}))}function validateValueForOneOf(e,t){return 1===t.reduce((function(t,r){return t+(validateValueForSchema(e,r)?1:0)}),0)}function isKey(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)}function omitProps(e,t){return Object.keys(e).filter((function(e){return!t.includes(e)})).reduce((function(t,r){return Array.isArray(e[r])?t[r]=e[r].slice():t[r]=e[r]instanceof Object?merge({},e[r]):e[r],t}),{})}function template(e,t){return Array.isArray(e)?e.map((function(e){return template(e,t)})):("string"==typeof e&&(e=e.replace(/#\{([\w.-]+)\}/g,(function(e,r){return t[r]}))),e)}function isEmpty(e){return"[object Object]"==={}.toString.call(e)&&!Object.keys(e).length}function shouldClean(e,t){var r=Array.isArray(t.required)&&t.required.includes(e),n="function"==typeof t.thunk||t.additionalProperties&&"function"==typeof t.additionalProperties.thunk;return!r&&!n}function clean(e,t,r){return void 0===r&&(r=!1),e&&"object"==typeof e?Array.isArray(e)?e.map((function(e){return clean(e,t,!0)})).filter((function(e){return void 0!==e})):(Object.keys(e).forEach((function(r){if(isEmpty(e[r]))shouldClean(r,t)&&delete e[r];else{var n=clean(e[r],t);isEmpty(n)||(e[r]=n)}"undefined"==typeof e[r]&&delete e[r]})),!Object.keys(e).length&&r?undefined:e):e}var utils={hasProperties:hasProperties,getLocalRef:getLocalRef,omitProps:omitProps,typecast:typecast,merge:merge,clone:clone,short:short,notValue:notValue,anyValue:anyValue,validate:validate,validateValueForSchema:validateValueForSchema,validateValueForOneOf:validateValueForOneOf,isKey:isKey,template:template,shouldClean:shouldClean,clean:clean,isEmpty:isEmpty};function proxy(e){return function(t,r,n,i){var a=t,o=[];"object"==typeof t&&(a=Object.keys(t)[0],Array.isArray(t[a])?o=t[a]:o.push(t[a]));for(var s=a.split("."),u=e();s.length>1;)u=u[s.shift()];return"function"==typeof(t="object"==typeof u?u[s[0]]:u)&&(t=t.apply(u,o.map((function(e){return utils.template(e,i)})))),"[object Object]"==={}.toString.call(t)&&Object.keys(t).forEach((function(e){if("function"==typeof t[e])throw new Error("Cannot resolve value for '"+n+": "+a+"', given: "+t)})),t}}var Container=function(){this.registry={},this.support={}};Container.prototype.reset=function(e){e?(delete this.registry[e],delete this.support[e]):(this.registry={},this.support={})},Container.prototype.extend=function(e,t){var r=this;this.registry[e]=t(this.registry[e]),this.support[e]||(this.support[e]=proxy((function(){return r.registry[e]})))},Container.prototype.define=function(e,t){this.support[e]=t},Container.prototype.get=function(e){if("undefined"==typeof this.registry[e])throw new ReferenceError("'"+e+"' dependency doesn't exist.");return this.registry[e]},Container.prototype.wrap=function(e){for(var t=this,r=Object.keys(e),n={},i=r.length,a=function(){var a=r[i].replace(/^x-/,""),o=t.support[a];if("function"==typeof o)return Object.defineProperty(e,"generate",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return o.call(n,e[r[i]],e,r[i],t)}}),"break"};i--;){if("break"===a())break}return e};var registry$1=new Registry;function formatAPI(e,t){if(void 0===e)return registry$1.list();if("string"==typeof e)if("function"==typeof t)registry$1.register(e,t);else{if(null!==t&&!1!==t)return registry$1.get(e);registry$1.unregister(e)}else registry$1.registerMany(e)}var ParseError=function(e){function t(t,r){e.call(this),e.captureStackTrace&&e.captureStackTrace(this,this.constructor),this.name="ParseError",this.message=t,this.path=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Error),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","format"]};inferredProperties.number=inferredProperties.integer;var subschemaProperties=["additionalItems","items","additionalProperties","dependencies","patternProperties","properties"];function matchesType(e,t,r){return Object.keys(e).filter((function(e){var n=subschemaProperties.indexOf(t)>-1;return!(!(r.indexOf(e)>-1)||n)})).length>0}function inferType(e,t){for(var r=Object.keys(inferredProperties),n=0;n<r.length;n+=1){var i=r[n];if(matchesType(e,t[t.length-1],inferredProperties[i]))return i}}function booleanGenerator(){return optionAPI("random")()>.5}var booleanType=booleanGenerator;function nullGenerator(){return null}var nullType=nullGenerator;function unique(e,t,r,n,i,a){var o=[],s=[];function u(e){var t=JSON.stringify(e);return-1===s.indexOf(t)&&(s.push(t),o.push(e),!0)}t.forEach(u);for(var p=100;o.length!==t.length&&(u(a(r.items||n,e,i))||(p-=1),p););return o}function arrayType(e,t,r,n){var i=[];if(!e.items&&!e.additionalItems){if(utils.hasProperties(e,"minItems","maxItems","uniqueItems"))throw new ParseError("missing items for "+utils.short(e),t);return i}if(Array.isArray(e.items))return e.items.map((function(e,i){var a=t.concat(["items",i]);return n(e,a,r)}));var a=e.minItems,o=e.maxItems;optionAPI("minItems")&&(a=o?Math.min(optionAPI("minItems"),o):optionAPI("minItems")),optionAPI("maxItems")&&((o=a?Math.min(optionAPI("maxItems"),a):optionAPI("maxItems"))&&o>optionAPI("maxItems")&&(o=optionAPI("maxItems")),a&&a>optionAPI("maxItems")&&(a=o));var s=!0===optionAPI("alwaysFakeOptionals")?1:optionAPI("optionalsProbability"),u=optionAPI("alwaysFakeOptionals")||optionAPI("fixedProbabilities")||!1,p=random.number(a,o,1,5);null!==s&&(p=Math.max(u?Math.round((o||p)*s):Math.abs(random.number(a,o)*s),a||0));for(var l="object"==typeof e.additionalItems?e.additionalItems:{},f=i.length;f<p;f+=1){var c=t.concat(["items",f]),h=n(e.items||l,c,r);i.push(h)}return e.uniqueItems?unique(t.concat(["items"]),i,e,l,r,n):i}function numberType(e){var t="undefined"==typeof e.minimum?env.MIN_INTEGER:e.minimum,r="undefined"==typeof e.maximum?env.MAX_INTEGER:e.maximum,n=e.multipleOf;if(n&&(r=Math.floor(r/n)*n,t=Math.ceil(t/n)*n),e.exclusiveMinimum&&t===e.minimum&&(t+=n||1),e.exclusiveMaximum&&r===e.maximum&&(r-=n||1),t>r)return NaN;if(n){if(-1===String(n).indexOf(".")){for(var i=random.number(Math.floor(t/n),Math.floor(r/n))*n;i<t;)i+=e.multipleOf;return i}var a,o,s=(r-t)/n;do{o=(a=random.number(0,s)*n)/n%1}while(0!==o);return t+a}return random.number(t,r,undefined,undefined,!0)}function integerType(e){return numberType(Object.assign({multipleOf:1},e))}var LIPSUM_WORDS="Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore\net dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\ncommodo consequat Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\npariatur Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est\nlaborum".split(/\W/);function wordsGenerator(e){return random.shuffle(LIPSUM_WORDS).slice(0,e)}var anyType={type:["string","number","integer","boolean"]};function objectType(e,t,r,n){var i={},a=e.properties||{},o=e.patternProperties||{},s="boolean"==typeof e.required?[]:(e.required||[]).slice(),u=!1!==e.additionalProperties,p=Object.keys(a),l=Object.keys(o),f=p.concat(l).reduce((function(e,t){return-1===s.indexOf(t)&&e.push(t),e}),[]),c=s.concat(f),h=u&&!0===e.additionalProperties?anyType:e.additionalProperties;if(!u&&0===p.length&&0===l.length&&utils.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(!0===optionAPI("requiredOnly"))return s.forEach((function(e){a[e]&&(i[e]=a[e])})),n(i,t.concat(["properties"]),r,e);var d=!0===optionAPI("alwaysFakeOptionals")?1:optionAPI("optionalsProbability"),m=optionAPI("alwaysFakeOptionals")||optionAPI("fixedProbabilities")||!1,y=optionAPI("ignoreProperties")||[],g=optionAPI("reuseProperties"),v=optionAPI("fillProperties"),b=e.maxProperties||c.length+(u?random.number(1,5):0),A=Math.max(e.minProperties||0,s.length),I=Math.max(0,c.length-A);1!==c.length||s.length||(A=Math.max(random.number(v?1:0,b),A)),null!==d&&(I=!0===m?Math.round(A-s.length+d*(c.length-A)):random.number(A-s.length,d*(c.length-A)));var x=random.shuffle(f).slice(0,I),E=f.filter((function(e){return-1!==x.indexOf(e)})),R=null!==d?b:random.number(0,b),P=s.concat(random.shuffle(E).slice(0,R)),O=[];if(e.dependencies&&(Object.keys(e.dependencies).forEach((function(t){var r=e.dependencies[t];-1!==P.indexOf(t)&&(Array.isArray(r)?r.forEach((function(e){-1===P.indexOf(e)&&P.push(e)})):O.push(r))})),O.length))return delete e.dependencies,n({allOf:O.concat(e)},t.concat(["properties"]),r,e);var w=[];P.forEach((function(e){for(var t=0;t<y.length;t+=1)if(y[t]instanceof RegExp&&y[t].test(e)||"string"==typeof y[t]&&y[t]===e||"function"==typeof y[t]&&y[t](a[e],e))return void w.push(e);var r;if(!1===h&&-1!==s.indexOf(e)&&(i[e]=a[e]),a[e]&&(i[e]=a[e]),l.forEach((function(t){e.match(new RegExp(t))&&(r=!0,i[e]?utils.merge(i[e],o[t]):i[random.randexp(e)]=o[t])})),!r){var n=o[e]||h;n&&!1!==h&&(i[o[e]?random.randexp(e):e]=a[e]||n)}}));var T=Object.keys(i).length+(v?0:w.length);function M(e){var t;do{if(!e.length)break;t=e.shift()}while(i[t]);return t}var S,_=A;for(u&&!s.length&&(_=Math.max(null===d||h?random.number(v?1:0,b):0,A));v&&(l.length||u)&&!(T>=_);){if(u)if(g&&p.length-T>_){var k=0,j=void 0;do{if((k+=1)>1e3)break;j=M(s)||random.pick(p)}while("undefined"!=typeof i[j]);"undefined"==typeof i[j]&&(i[j]=a[j],T+=1)}else if(l.length&&!h){var N=random.pick(l),C=random.randexp(N);i[C]||(i[C]=o[N],T+=1)}else{var $=M(s)||wordsGenerator(1)+(S=void 0,random.randexp("_?[_a-f\\d]{1,3}"+(S?"\\$?":"")));i[$]||(i[$]=h||anyType,T+=1)}for(var L=0;T<A&&L<l.length;L+=1){var G=l[L],D=random.randexp(G);i[D]||(i[D]=o[G],T+=1)}}if(0===s.length&&(!u||!1===d))for(var F=random.number(A,b);T<F;){var H=M(p);H&&(i[H]=a[H]),T+=1}return n(i,t.concat(["properties"]),r,e)}function produce(){return wordsGenerator(random.number(1,5)).join(" ")}function thunkGenerator(e,t){void 0===e&&(e=0),void 0===t&&(t=140);for(var r=Math.max(0,e),n=random.number(r,t),i=produce();i.length<r;)i+=produce();return i.length>n&&(i=i.substr(0,n)),i}function ipv4Generator(){return[0,0,0,0].map((function(){return random.number(0,255)})).join(".")}function dateTimeGenerator(){return random.date().toISOString()}function dateGenerator(){return dateTimeGenerator().slice(0,10)}function timeGenerator(){return dateTimeGenerator().slice(11)}var FRAGMENT="[a-zA-Z][a-zA-Z0-9+-.]*",URI_PATTERN="https?://{hostname}(?:"+FRAGMENT+")+",PARAM_PATTERN="(?:\\?([a-z]{1,7}(=\\w{1,5})?&){0,3})?",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:URI_PATTERN,slug:"[a-zA-Z\\d_-]+","uri-reference":""+URI_PATTERN+PARAM_PATTERN,"uri-template":URI_PATTERN.replace("(?:","(?:/\\{[a-z][:a-zA-Z0-9-]*\\}|"),"json-pointer":"(/(?:"+FRAGMENT.replace("]*","/]*")+"|~[01]))+",uuid:"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"};regexps.iri=regexps["uri-reference"],regexps["iri-reference"]=regexps["uri-reference"],regexps["idn-email"]=regexps.email,regexps["idn-hostname"]=regexps.hostname;var ALLOWED_FORMATS=new RegExp("\\{("+Object.keys(regexps).join("|")+")\\}");function coreFormatGenerator(e){return random.randexp(regexps[e]).replace(ALLOWED_FORMATS,(function(e,t){return random.randexp(regexps[t])}))}function generateFormat(e,t){var r=formatAPI(e.format);if("function"==typeof r)return r(e);switch(e.format){case"date-time":case"datetime":return dateTimeGenerator();case"date":return dateGenerator();case"time":return timeGenerator();case"ipv4":return ipv4Generator();case"regex":return".+?";case"email":case"hostname":case"ipv6":case"uri":case"uri-reference":case"iri":case"iri-reference":case"idn-email":case"idn-hostname":case"json-pointer":case"slug":case"uri-template":case"uuid":return coreFormatGenerator(e.format);default:if(void 0===r){if(optionAPI("failOnInvalidFormat"))throw new Error("unknown registry key "+utils.short(e.format));return t()}throw new Error("unsupported format '"+e.format+"'")}}function stringType(e){return utils.typecast("string",e,(function(t){return e.format?generateFormat(e,(function(){return thunkGenerator(t.minLength,t.maxLength)})):e.pattern?random.randexp(e.pattern):thunkGenerator(t.minLength,t.maxLength)}))}var typeMap={boolean:booleanType,"null":nullType,array:arrayType,integer:integerType,number:numberType,object:objectType,string:stringType};function traverse(e,t,r,n){if(e=r(e,null,t)){if("properties"!==t[t.length-1]){if(optionAPI("useExamplesValue")&&Array.isArray(e.examples)){var i=e.examples.concat("default"in e?[e["default"]]:[]);return utils.typecast(null,e,(function(){return random.pick(i)}))}if(optionAPI("useDefaultValue")&&"default"in e&&(""!==e["default"]||!optionAPI("replaceEmptyByRandomValue")))return e["default"];if("template"in e)return utils.template(e.template,n);if("const"in e)return e["const"]}if(e.not&&"object"==typeof e.not&&(e=utils.notValue(e.not,utils.omitProps(e,["not"]))).type&&"object"===e.type){var a=traverse(e,t.concat(["not"]),r,n);return utils.clean(a,e,!1)}if("function"==typeof e.thunk)return traverse(e.thunk(n),t,r);if("function"==typeof e.generate)return utils.typecast(null,e,(function(){return e.generate(n)}));if("string"==typeof e.pattern)return utils.typecast("string",e,(function(){return random.randexp(e.pattern)}));if(Array.isArray(e["enum"]))return utils.typecast(null,e,(function(){return random.pick(e["enum"])}));if(e.jsonPath)return e;var o=e.type;if(Array.isArray(o)?o=random.pick(o):void 0===o&&(o=inferType(e,t)||o)&&(e.type=o),"string"==typeof o){if(!typeMap[o]){if(optionAPI("failOnInvalidTypes"))throw new ParseError("unknown primitive "+utils.short(o),t.concat(["type"]));var s=optionAPI("defaultInvalidTypeProduct");return"string"==typeof s&&typeMap[s]?typeMap[s](e,t,r,traverse):s}try{return typeMap[o](e,t,r,traverse)}catch(p){if("undefined"==typeof p.path)throw new ParseError(p.stack,t);throw p}}var u={};return Array.isArray(e)&&(u=[]),Object.keys(e).forEach((function(n){if("object"==typeof e[n]&&"definitions"!==n){var i=traverse(e[n],t.concat([n]),r,u);u[n]=utils.clean(i,e[n],!1)}else u[n]=e[n]})),u}}var buildResolveSchema=function(e){var t,r=e.refs,n=e.schema,i=e.container,a=e.refDepthMax,o=e.refDepthMin,s={},u={},p=0;return s.resolveSchema=function(e,l,f){if(null===e||e===undefined)return null;if("function"==typeof e.generate)return e;if("string"==typeof(e.$id||e.id)&&(delete e.id,delete e.$id,delete e.$schema),"string"==typeof e.$ref){var c,h=Math.max(o,a)-1;if("#"===e.$ref||u[e.$ref]<0||t===e.$ref&&++p>h)return delete e.$ref,e;if("undefined"==typeof u[e.$ref]&&(u[e.$ref]=random.number(o,a)-1),t=e.$ref,void 0!==(c=-1===e.$ref.indexOf("#/")?r[e.$ref]||null:utils.getLocalRef(n,e.$ref)||null)){if(!c&&!0!==optionAPI("ignoreMissingRefs"))throw new Error("Reference not found: "+e.$ref);u[e.$ref]-=1,utils.merge(e,c||{})}return delete e.$ref,e}if(Array.isArray(e.allOf)){var d=e.allOf;delete e.allOf,d.forEach((function(t){var r=s.resolveSchema(t,null,f);utils.merge(e,"function"==typeof r.thunk?r.thunk(e):r),Array.isArray(e.allOf)&&s.resolveSchema(e,l,f)}))}if(Array.isArray(e.oneOf||e.anyOf)){var m=e.oneOf||e.anyOf;return e["enum"]&&e.oneOf&&(e["enum"]=e["enum"].filter((function(e){return utils.validate(e,m)}))),{thunk:function(t){var r=utils.omitProps(e,["anyOf","oneOf"]),n=random.pick(m);return utils.merge(r,n),m.forEach((function(e){e.required&&e!==n&&e.required.forEach((function(e){var n=r.required&&r.required.includes(e);r.properties&&!n&&delete r.properties[e],t&&t.properties&&delete t.properties[e]}))})),r}}}if(Object.keys(e).forEach((function(t){!Array.isArray(e[t])&&"object"!=typeof e[t]||utils.isKey(t)||(e[t]=s.resolveSchema(e[t],t,f.concat(t)))})),f){var y=f[f.length-1];if("properties"===y||"items"===y)return e}return i.wrap(e)},s};function pick$1(e){return Array.isArray(e)?random.pick(e):e}function cycle(e,t){if(!Array.isArray(e))return e;var r=t?e.pop():e.shift();return t?e.unshift(r):e.push(r),r}function resolve(e,t,r,n){if(!e||"object"!=typeof e)return e;if(r||(r={}),t||(t=e),Array.isArray(e))return e.map((function(e){return resolve(e,t,r,n)}));if(e.jsonPath){var i="object"!=typeof e.jsonPath?{path:e.jsonPath}:e.jsonPath;i.group=e.group||i.group||n,i.cycle=e.cycle||i.cycle||!1,i.reverse=e.reverse||i.reverse||!1,i.count=e.count||i.count||1;var a=i.group+"__"+i.path;return r[a]||(i.count>1?r[a]=jsonpathPlus.JSONPath(i.path,t).slice(0,i.count):r[a]=jsonpathPlus.JSONPath(i.path,t)),i.cycle||i.reverse?cycle(r[a],i.reverse):pick$1(r[a])}return Object.keys(e).forEach((function(n){e[n]=resolve(e[n],t,r,n)})),e}function run(e,t,r){if("[object Object]"!=={}.toString.call(t))throw new Error("Invalid input, expecting object but given "+typeof t);var n=optionAPI("refDepthMin")||0,i=optionAPI("refDepthMax")||3;try{var a=buildResolveSchema({refs:e,schema:t,container:r,refDepthMin:n,refDepthMax:i}).resolveSchema,o=traverse(utils.clone(t),[],a);return optionAPI("resolveJsonPath")?resolve(o):o}catch(s){throw s.path?new Error(s.message+" in /"+s.path.join("/")):s}}var container=new Container;function setupKeywords(){container.define("autoIncrement",(function(e,t){if(!this.offset){var r=t.minimum||1,n=r+env.MAX_NUMBER,i=e.initialOffset||t.initialOffset;this.offset=i||random.number(r,n)}return!0===e?this.offset++:t})),container.define("sequentialDate",(function(e,t){if(this.now||(this.now=random.date()),e){if(t=this.now.toISOString(),-1===["seconds","minutes","hours","days","weeks","months","years"].indexOf(e=!0===e?"days":e))throw new Error("Unsupported increment by "+utils.short(e));this.now.setTime(this.now.getTime()+random.date(e))}return t}))}function getRefs(e,t){var r={};function n(e){if(e&&"object"==typeof e){if(Array.isArray(e))return e.forEach(n);var t=e.$id||e.id;"string"!=typeof t||r[t]||(r[t]=e),Object.keys(e).forEach((function(t){n(e[t])}))}}return Array.isArray(e)?e.forEach((function(e){r[e.$id||e.id]=e})):r=e||{},n(e),n(t),r}var jsf=function(e,t,r){return jsf.generate(e,t)};jsf.generate=function(e,t){return run(getRefs(t,e),e,container)},jsf.resolve=function(e,t,r){"string"==typeof t&&(r=t,t={}),r=(r=r||("undefined"!=typeof process?process.cwd():"")).replace(/\/+$/,"")+"/";var n=getRefs(t,e),i={order:1,canRead:function(e){var t=e.url.replace("/:",":");return n[t]||n[t.split("/").pop()]},read:function(e,t){try{t(null,this.canRead(e))}catch(r){t(r)}}};return $RefParser.dereference(r,e,{resolve:{file:{order:100},http:{order:200},fixedRefs:i},dereference:{circular:"ignore"}}).then((function(e){return run(n,e,container)}))["catch"]((function(e){throw new Error("Error while resolving schema ("+e.message+")")}))},setupKeywords(),jsf.format=formatAPI,jsf.option=optionAPI,jsf.random=random,jsf.extend=function(e,t){return container.extend(e,t),jsf},jsf.define=function(e,t){return container.define(e,t),jsf},jsf.reset=function(e){return container.reset(e),setupKeywords(),jsf},jsf.locate=function(e){return container.get(e)},"undefined"!=typeof VERSION&&(jsf.version=VERSION),module.exports=jsf; |
@@ -1,1 +0,1 @@ | ||
import $RefParser from"json-schema-ref-parser";import{JSONPath}from"jsonpath-plus";var Registry=function(){this.data={}};Registry.prototype.unregister=function(e){e?delete this.data[e]:this.data={}},Registry.prototype.register=function(e,t){this.data[e]=t},Registry.prototype.registerMany=function(e){var t=this;Object.keys(e).forEach((function(r){t.data[r]=e[r]}))},Registry.prototype.get=function(e){return this.data[e]},Registry.prototype.list=function(){return this.data};var defaults={defaultInvalidTypeProduct:null,defaultRandExpMax:10,ignoreProperties:[],ignoreMissingRefs:!1,failOnInvalidTypes:!0,failOnInvalidFormat:!0,alwaysFakeOptionals:!1,optionalsProbability:!1,fixedProbabilities:!1,useExamplesValue:!1,useDefaultValue:!1,requiredOnly:!1,minItems:0,maxItems:null,minLength:0,maxLength:null,resolveJsonPath:!1,reuseProperties:!1,fillProperties:!0,replaceEmptyByRandomValue:!1};defaults.random=Math.random;var OptionRegistry=function(e){function t(){e.call(this),this.data=Object.assign({},defaults),this._defaults=defaults}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaults:{configurable:!0}};return r.defaults.get=function(){return Object.assign({},this._defaults)},Object.defineProperties(t.prototype,r),t}(Registry),registry=new OptionRegistry;function optionAPI(e,t){return"string"==typeof e?void 0!==t?registry.register(e,t):registry.get(e):registry.registerMany(e)}optionAPI.getDefaults=function(){return registry.defaults};var SCALAR_TYPES=["integer","number","string","boolean","null"],ALL_TYPES=["array","object"].concat(SCALAR_TYPES),MOST_NEAR_DATETIME=2524608e6,MIN_INTEGER=-1e8,MAX_INTEGER=1e8,MIN_NUMBER=-100,MAX_NUMBER=100,env={SCALAR_TYPES:SCALAR_TYPES,ALL_TYPES:ALL_TYPES,MIN_NUMBER:MIN_NUMBER,MAX_NUMBER:MAX_NUMBER,MIN_INTEGER:MIN_INTEGER,MAX_INTEGER:MAX_INTEGER,MOST_NEAR_DATETIME:MOST_NEAR_DATETIME};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var types={ROOT:0,GROUP:1,POSITION:2,SET:3,RANGE:4,REPETITION:5,REFERENCE:6,CHAR:7};const INTS=()=>[{type:types.RANGE,from:48,to:57}],WORDS=()=>[{type:types.CHAR,value:95},{type:types.RANGE,from:97,to:122},{type:types.RANGE,from:65,to:90}].concat(INTS()),WHITESPACE=()=>[{type:types.CHAR,value:9},{type:types.CHAR,value:10},{type:types.CHAR,value:11},{type:types.CHAR,value:12},{type:types.CHAR,value:13},{type:types.CHAR,value:32},{type:types.CHAR,value:160},{type:types.CHAR,value:5760},{type:types.RANGE,from:8192,to:8202},{type:types.CHAR,value:8232},{type:types.CHAR,value:8233},{type:types.CHAR,value:8239},{type:types.CHAR,value:8287},{type:types.CHAR,value:12288},{type:types.CHAR,value:65279}],NOTANYCHAR=()=>[{type:types.CHAR,value:10},{type:types.CHAR,value:13},{type:types.CHAR,value:8232},{type:types.CHAR,value:8233}];var words=()=>({type:types.SET,set:WORDS(),not:!1}),notWords=()=>({type:types.SET,set:WORDS(),not:!0}),ints=()=>({type:types.SET,set:INTS(),not:!1}),notInts=()=>({type:types.SET,set:INTS(),not:!0}),whitespace=()=>({type:types.SET,set:WHITESPACE(),not:!1}),notWhitespace=()=>({type:types.SET,set:WHITESPACE(),not:!0}),anyChar=()=>({type:types.SET,set:NOTANYCHAR(),not:!0}),sets={words:words,notWords:notWords,ints:ints,notInts:notInts,whitespace:whitespace,notWhitespace:notWhitespace,anyChar:anyChar},util=createCommonjsModule((function(e,t){const r={0:0,t:9,n:10,v:11,f:12,r:13};t.strToChars=function(e){return e=e.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(function(e,t,n,i,a,o,s,u){if(n)return e;var p=t?8:i?parseInt(i,16):a?parseInt(a,16):o?parseInt(o,8):s?"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s):r[u],l=String.fromCharCode(p);return/[[\]{}^$.|?*+()]/.test(l)&&(l="\\"+l),l}))},t.tokenizeClass=(e,r)=>{for(var n,i,a=[],o=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g;null!=(n=o.exec(e));)if(n[1])a.push(sets.words());else if(n[2])a.push(sets.ints());else if(n[3])a.push(sets.whitespace());else if(n[4])a.push(sets.notWords());else if(n[5])a.push(sets.notInts());else if(n[6])a.push(sets.notWhitespace());else if(n[7])a.push({type:types.RANGE,from:(n[8]||n[9]).charCodeAt(0),to:n[10].charCodeAt(0)});else{if(!(i=n[12]))return[a,o.lastIndex];a.push({type:types.CHAR,value:i.charCodeAt(0)})}t.error(r,"Unterminated character class")},t.error=(e,t)=>{throw new SyntaxError("Invalid regular expression: /"+e+"/: "+t)}})),util_1=util.strToChars,util_2=util.tokenizeClass,util_3=util.error,wordBoundary=()=>({type:types.POSITION,value:"b"}),nonWordBoundary=()=>({type:types.POSITION,value:"B"}),begin=()=>({type:types.POSITION,value:"^"}),end=()=>({type:types.POSITION,value:"$"}),positions={wordBoundary:wordBoundary,nonWordBoundary:nonWordBoundary,begin:begin,end:end},lib=e=>{var t,r,n=0,i={type:types.ROOT,stack:[]},a=i,o=i.stack,s=[],u=t=>{util.error(e,`Nothing to repeat at column ${t-1}`)},p=util.strToChars(e);for(t=p.length;n<t;)switch(r=p[n++]){case"\\":switch(r=p[n++]){case"b":o.push(positions.wordBoundary());break;case"B":o.push(positions.nonWordBoundary());break;case"w":o.push(sets.words());break;case"W":o.push(sets.notWords());break;case"d":o.push(sets.ints());break;case"D":o.push(sets.notInts());break;case"s":o.push(sets.whitespace());break;case"S":o.push(sets.notWhitespace());break;default:/\d/.test(r)?o.push({type:types.REFERENCE,value:parseInt(r,10)}):o.push({type:types.CHAR,value:r.charCodeAt(0)})}break;case"^":o.push(positions.begin());break;case"$":o.push(positions.end());break;case"[":var l;"^"===p[n]?(l=!0,n++):l=!1;var f=util.tokenizeClass(p.slice(n),e);n+=f[1],o.push({type:types.SET,set:f[0],not:l});break;case".":o.push(sets.anyChar());break;case"(":var c={type:types.GROUP,stack:[],remember:!0};"?"===(r=p[n])&&(r=p[n+1],n+=2,"="===r?c.followedBy=!0:"!"===r?c.notFollowedBy=!0:":"!==r&&util.error(e,`Invalid group, character '${r}'`+` after '?' at column ${n-1}`),c.remember=!1),o.push(c),s.push(a),a=c,o=c.stack;break;case")":0===s.length&&util.error(e,`Unmatched ) at column ${n-1}`),o=(a=s.pop()).options?a.options[a.options.length-1]:a.stack;break;case"|":a.options||(a.options=[a.stack],delete a.stack);var h=[];a.options.push(h),o=h;break;case"{":var m,d,y=/^(\d+)(,(\d+)?)?\}/.exec(p.slice(n));null!==y?(0===o.length&&u(n),m=parseInt(y[1],10),d=y[2]?y[3]?parseInt(y[3],10):Infinity:m,n+=y[0].length,o.push({type:types.REPETITION,min:m,max:d,value:o.pop()})):o.push({type:types.CHAR,value:123});break;case"?":0===o.length&&u(n),o.push({type:types.REPETITION,min:0,max:1,value:o.pop()});break;case"+":0===o.length&&u(n),o.push({type:types.REPETITION,min:1,max:Infinity,value:o.pop()});break;case"*":0===o.length&&u(n),o.push({type:types.REPETITION,min:0,max:Infinity,value:o.pop()});break;default:o.push({type:types.CHAR,value:r.charCodeAt(0)})}return 0!==s.length&&util.error(e,"Unterminated group"),i},types_1=types;lib.types=types_1;class SubRange{constructor(e,t){this.low=e,this.high=t,this.length=1+t-e}overlaps(e){return!(this.high<e.low||this.low>e.high)}touches(e){return!(this.high+1<e.low||this.low-1>e.high)}add(e){return new SubRange(Math.min(this.low,e.low),Math.max(this.high,e.high))}subtract(e){return e.low<=this.low&&e.high>=this.high?[]:e.low>this.low&&e.high<this.high?[new SubRange(this.low,e.low-1),new SubRange(e.high+1,this.high)]:e.low<=this.low?[new SubRange(e.high+1,this.high)]:[new SubRange(this.low,e.low-1)]}toString(){return this.low==this.high?this.low.toString():this.low+"-"+this.high}}class DRange{constructor(e,t){this.ranges=[],this.length=0,null!=e&&this.add(e,t)}_update_length(){this.length=this.ranges.reduce((e,t)=>e+t.length,0)}add(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.touches(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.touches(this.ranges[t]);)e=e.add(this.ranges[t]),t++;r.push(e),this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof DRange?e.ranges.forEach(r):(null==t&&(t=e),r(new SubRange(e,t))),this}subtract(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.overlaps(this.ranges[t]);)r=r.concat(this.ranges[t].subtract(e)),t++;this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof DRange?e.ranges.forEach(r):(null==t&&(t=e),r(new SubRange(e,t))),this}intersect(e,t){var r=[],n=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(;t<this.ranges.length&&e.overlaps(this.ranges[t]);){var n=Math.max(this.ranges[t].low,e.low),i=Math.min(this.ranges[t].high,e.high);r.push(new SubRange(n,i)),t++}};return e instanceof DRange?e.ranges.forEach(n):(null==t&&(t=e),n(new SubRange(e,t))),this.ranges=r,this._update_length(),this}index(e){for(var t=0;t<this.ranges.length&&this.ranges[t].length<=e;)e-=this.ranges[t].length,t++;return this.ranges[t].low+e}toString(){return"[ "+this.ranges.join(", ")+" ]"}clone(){return new DRange(this)}numbers(){return this.ranges.reduce((e,t)=>{for(var r=t.low;r<=t.high;)e.push(r),r++;return e},[])}subranges(){return this.ranges.map(e=>({low:e.low,high:e.high,length:1+e.high-e.low}))}}var lib$1=DRange;const types$1=lib.types;var randexp=class e{constructor(e,t){if(this._setDefaults(e),e instanceof RegExp)this.ignoreCase=e.ignoreCase,this.multiline=e.multiline,e=e.source;else{if("string"!=typeof e)throw new Error("Expected a regexp or string");this.ignoreCase=t&&-1!==t.indexOf("i"),this.multiline=t&&-1!==t.indexOf("m")}this.tokens=lib(e)}_setDefaults(t){this.max=null!=t.max?t.max:null!=e.prototype.max?e.prototype.max:100,this.defaultRange=t.defaultRange?t.defaultRange:this.defaultRange.clone(),t.randInt&&(this.randInt=t.randInt)}gen(){return this._gen(this.tokens,[])}_gen(e,t){var r,n,i,a,o;switch(e.type){case types$1.ROOT:case types$1.GROUP:if(e.followedBy||e.notFollowedBy)return"";for(e.remember&&e.groupNumber===undefined&&(e.groupNumber=t.push(null)-1),n="",a=0,o=(r=e.options?this._randSelect(e.options):e.stack).length;a<o;a++)n+=this._gen(r[a],t);return e.remember&&(t[e.groupNumber]=n),n;case types$1.POSITION:return"";case types$1.SET:var s=this._expand(e);return s.length?String.fromCharCode(this._randSelect(s)):"";case types$1.REPETITION:for(i=this.randInt(e.min,e.max===Infinity?e.min+this.max:e.max),n="",a=0;a<i;a++)n+=this._gen(e.value,t);return n;case types$1.REFERENCE:return t[e.value-1]||"";case types$1.CHAR:var u=this.ignoreCase&&this._randBool()?this._toOtherCase(e.value):e.value;return String.fromCharCode(u)}}_toOtherCase(e){return e+(97<=e&&e<=122?-32:65<=e&&e<=90?32:0)}_randBool(){return!this.randInt(0,1)}_randSelect(e){return e instanceof lib$1?e.index(this.randInt(0,e.length-1)):e[this.randInt(0,e.length-1)]}_expand(e){if(e.type===lib.types.CHAR)return new lib$1(e.value);if(e.type===lib.types.RANGE)return new lib$1(e.from,e.to);{let t=new lib$1;for(let r=0;r<e.set.length;r++){let n=this._expand(e.set[r]);if(t.add(n),this.ignoreCase)for(let e=0;e<n.length;e++){let r=n.index(e),i=this._toOtherCase(r);r!==i&&t.add(i)}}return e.not?this.defaultRange.clone().subtract(t):this.defaultRange.clone().intersect(t)}}randInt(e,t){return e+Math.floor(Math.random()*(1+t-e))}get defaultRange(){return this._range=this._range||new lib$1(32,126)}set defaultRange(e){this._range=e}static randexp(t,r){var n;return"string"==typeof t&&(t=new RegExp(t,r)),t._randexp===undefined?(n=new e(t,r),t._randexp=n):(n=t._randexp)._setDefaults(t),n.gen()}static sugar(){RegExp.prototype.gen=function(){return e.randexp(this)}}};function getRandomInteger(e,t){return e=void 0===e?env.MIN_INTEGER:e,t=void 0===t?env.MAX_INTEGER:t,Math.floor(optionAPI("random")()*(t-e+1))+e}function _randexp(e){return randexp.prototype.max=optionAPI("defaultRandExpMax"),randexp.prototype.randInt=function(e,t){return e+Math.floor(optionAPI("random")()*(t-e+1))},new randexp(e).gen()}function pick(e){return e[Math.floor(optionAPI("random")()*e.length)]}function shuffle(e){for(var t,r,n=e.length,i=e.slice();n>0;)r=Math.floor(optionAPI("random")()*n),t=i[n-=1],i[n]=i[r],i[r]=t;return i}function getRandom(e,t){return optionAPI("random")()*(t-e)+e}function number(e,t,r,n,i){return void 0===i&&(i=!1),r=void 0===r?env.MIN_NUMBER:r,n=void 0===n?env.MAX_NUMBER:n,(t=void 0===t?n:t)<(e=void 0===e?r:e)&&(t+=e),i?getRandom(e,t):getRandomInteger(e,t)}function by(e){switch(e){case"seconds":return 60*number(0,60);case"minutes":return 612*number(15,50);case"hours":return 36123*number(12,72);case"days":return 86412345*number(7,30);case"weeks":return 604812345*number(4,52);case"months":return 2592012345*number(2,13);case"years":return 31104012345*number(1,20)}}function date(e){if(e)return by(e);var t=new Date,r=number(-1e3,env.MOST_NEAR_DATETIME);return t.setTime(t.getTime()-r),t}var random={pick:pick,date:date,shuffle:shuffle,number:number,randexp:_randexp};function getSubAttribute(e,t){for(var r=t.split(".");r.length;){var n=r.shift();if(!e[n])break;e=e[n]}return e}function hasProperties(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return t.filter((function(t){return"undefined"!=typeof e[t]})).length>0}function typecast(e,t,r){var n={};switch(e||t.type){case"integer":case"number":if("undefined"!=typeof t.minimum&&(n.minimum=t.minimum),"undefined"!=typeof t.maximum&&(n.maximum=t.maximum),t["enum"]){var i=Math.max(n.minimum||0,0),a=Math.min(n.maximum||Infinity,Infinity);t.exclusiveMinimum&&i===t.minimum&&(i+=t.multipleOf||1),t.exclusiveMaximum&&a===t.maximum&&(a-=t.multipleOf||1),(i||a!==Infinity)&&(t["enum"]=t["enum"].filter((function(e){return e>=i&&e<=a})))}break;case"string":n.minLength=optionAPI("minLength")||0,n.maxLength=optionAPI("maxLength")||Number.MAX_SAFE_INTEGER,"undefined"!=typeof t.minLength&&(n.minLength=Math.max(n.minLength,t.minLength)),"undefined"!=typeof t.maxLength&&(n.maxLength=Math.min(n.maxLength,t.maxLength))}var o=r(n);if(null===o||o===undefined)return null;switch(e||t.type){case"number":o=parseFloat(o);break;case"integer":o=parseInt(o,10);break;case"boolean":o=!!o;break;case"string":o=String(o);for(var s,u=Math.max(n.minLength||0,0),p=Math.min(n.maxLength||Infinity,Infinity);o.length<u&&(s=o,t.pattern?o+=random.randexp(t.pattern):o+=""+random.pick([" ","/","_","-","+","=","@","^"])+o,o!==s););switch(o.length>p&&(o=o.substr(0,p)),t.format){case"date-time":case"datetime":o=new Date(o).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"date":o=new Date(o).toISOString().substr(0,10);break;case"time":o=new Date("1969-01-01 "+o).toISOString().substr(11)}}return o}function merge(e,t){return Object.keys(t).forEach((function(r){"object"!=typeof t[r]||null===t[r]?e[r]=t[r]:Array.isArray(t[r])?(e[r]=e[r]||[],t[r].forEach((function(t){Array.isArray(e[r])&&-1===e[r].indexOf(t)&&e[r].push(t)}))):"object"!=typeof e[r]||null===e[r]||Array.isArray(e[r])?e[r]=merge({},t[r]):e[r]=merge(e[r],t[r])})),e}function clone(e,t){if(void 0===t&&(t=new Map),!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){var r=[];return t.set(e,r),r.push.apply(r,e.map((function(e){return clone(e,t)}))),r}var n={};return t.set(e,n),Object.keys(e).reduce((function(r,n){return r[n]=clone(e[n],t),r}),n)}function short(e){var t=JSON.stringify(e),r=JSON.stringify(e,null,2);return t.length>400?r.substr(0,400)+"...":r}function anyValue(){return random.pick([!1,!0,null,-1,NaN,Math.PI,Infinity,undefined,[],{},Math.random(),Math.random().toString(36).substr(2)])}function notValue(e,t){var r=merge({},t);if("undefined"!=typeof e.minimum&&(r.maximum=e.minimum,r.exclusiveMaximum=!0),"undefined"!=typeof e.maximum&&(r.minimum=e.maximum>r.maximum?0:e.maximum,r.exclusiveMinimum=!0),"undefined"!=typeof e.minLength&&(r.maxLength=e.minLength),"undefined"!=typeof e.maxLength&&(r.minLength=e.maxLength>r.maxLength?0:e.maxLength),e.type)r.type=random.pick(env.SCALAR_TYPES.filter((function(t){return(Array.isArray(e.type)?e.type:[e.type]).every((function(e){return"number"===t||"integer"===t?"number"!==e&&"integer"!==e:t!==e}))})));else if(e["enum"]){var n;do{n=anyValue()}while(-1!==e["enum"].indexOf(n));r["enum"]=[n]}return e.required&&r.properties&&e.required.forEach((function(e){delete r.properties[e]})),r}function validateValueForSchema(e,t){var r=t.minimum!==undefined,n=t.maximum!==undefined;return(r||n)&&(!r||e>=t.minimum)&&(!n||e<=t.maximum)}function validate(e,t){return!t.every((function(t){return validateValueForSchema(e,t)}))}function validateValueForOneOf(e,t){return 1===t.reduce((function(t,r){return t+(validateValueForSchema(e,r)?1:0)}),0)}function isKey(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)}function omitProps(e,t){return Object.keys(e).filter((function(e){return!t.includes(e)})).reduce((function(t,r){return Array.isArray(e[r])?t[r]=e[r].slice():t[r]=e[r]instanceof Object?merge({},e[r]):e[r],t}),{})}function template(e,t){return Array.isArray(e)?e.map((function(e){return template(e,t)})):("string"==typeof e&&(e=e.replace(/#\{([\w.-]+)\}/g,(function(e,r){return t[r]}))),e)}function isEmpty(e){return"[object Object]"==={}.toString.call(e)&&!Object.keys(e).length}function shouldClean(e,t){var r=Array.isArray(t.required)&&t.required.includes(e),n="function"==typeof t.thunk||t.additionalProperties&&"function"==typeof t.additionalProperties.thunk;return!r&&!n}function clean(e,t,r){return void 0===r&&(r=!1),e&&"object"==typeof e?Array.isArray(e)?e.map((function(e){return clean(e,t,!0)})).filter((function(e){return void 0!==e})):(Object.keys(e).forEach((function(r){if(isEmpty(e[r]))shouldClean(r,t)&&delete e[r];else{var n=clean(e[r],t);isEmpty(n)||(e[r]=n)}"undefined"==typeof e[r]&&delete e[r]})),!Object.keys(e).length&&r?undefined:e):e}var utils={getSubAttribute:getSubAttribute,hasProperties:hasProperties,omitProps:omitProps,typecast:typecast,merge:merge,clone:clone,short:short,notValue:notValue,anyValue:anyValue,validate:validate,validateValueForSchema:validateValueForSchema,validateValueForOneOf:validateValueForOneOf,isKey:isKey,template:template,shouldClean:shouldClean,clean:clean,isEmpty:isEmpty};function proxy(e){return function(t,r,n,i){var a=t,o=[];"object"==typeof t&&(a=Object.keys(t)[0],Array.isArray(t[a])?o=t[a]:o.push(t[a]));for(var s=a.split("."),u=e();s.length>1;)u=u[s.shift()];return"function"==typeof(t="object"==typeof u?u[s[0]]:u)&&(t=t.apply(u,o.map((function(e){return utils.template(e,i)})))),"[object Object]"==={}.toString.call(t)&&Object.keys(t).forEach((function(e){if("function"==typeof t[e])throw new Error("Cannot resolve value for '"+n+": "+a+"', given: "+t)})),t}}var Container=function(){this.registry={},this.support={}};Container.prototype.reset=function(e){e?(delete this.registry[e],delete this.support[e]):(this.registry={},this.support={})},Container.prototype.extend=function(e,t){var r=this;this.registry[e]=t(this.registry[e]),this.support[e]||(this.support[e]=proxy((function(){return r.registry[e]})))},Container.prototype.define=function(e,t){this.support[e]=t},Container.prototype.get=function(e){if("undefined"==typeof this.registry[e])throw new ReferenceError("'"+e+"' dependency doesn't exist.");return this.registry[e]},Container.prototype.wrap=function(e){for(var t=this,r=Object.keys(e),n={},i=r.length,a=function(){var a=r[i].replace(/^x-/,""),o=t.support[a];if("function"==typeof o)return Object.defineProperty(e,"generate",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return o.call(n,e[r[i]],e,r[i],t)}}),"break"};i--;){if("break"===a())break}return e};var registry$1=new Registry;function formatAPI(e,t){if(void 0===e)return registry$1.list();if("string"==typeof e)if("function"==typeof t)registry$1.register(e,t);else{if(null!==t&&!1!==t)return registry$1.get(e);registry$1.unregister(e)}else registry$1.registerMany(e)}var ParseError=function(e){function t(t,r){e.call(this),e.captureStackTrace&&e.captureStackTrace(this,this.constructor),this.name="ParseError",this.message=t,this.path=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Error),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","format"]};inferredProperties.number=inferredProperties.integer;var subschemaProperties=["additionalItems","items","additionalProperties","dependencies","patternProperties","properties"];function matchesType(e,t,r){return Object.keys(e).filter((function(e){var n=subschemaProperties.indexOf(t)>-1;return!(!(r.indexOf(e)>-1)||n)})).length>0}function inferType(e,t){for(var r=Object.keys(inferredProperties),n=0;n<r.length;n+=1){var i=r[n];if(matchesType(e,t[t.length-1],inferredProperties[i]))return i}}function booleanGenerator(){return optionAPI("random")()>.5}var booleanType=booleanGenerator;function nullGenerator(){return null}var nullType=nullGenerator;function unique(e,t,r,n,i,a){var o=[],s=[];function u(e){var t=JSON.stringify(e);return-1===s.indexOf(t)&&(s.push(t),o.push(e),!0)}t.forEach(u);for(var p=100;o.length!==t.length&&(u(a(r.items||n,e,i))||(p-=1),p););return o}function arrayType(e,t,r,n){var i=[];if(!e.items&&!e.additionalItems){if(utils.hasProperties(e,"minItems","maxItems","uniqueItems"))throw new ParseError("missing items for "+utils.short(e),t);return i}if(Array.isArray(e.items))return e.items.map((function(e,i){var a=t.concat(["items",i]);return n(e,a,r)}));var a=e.minItems,o=e.maxItems;optionAPI("minItems")&&(a=o?Math.min(optionAPI("minItems"),o):optionAPI("minItems")),optionAPI("maxItems")&&((o=a?Math.min(optionAPI("maxItems"),a):optionAPI("maxItems"))&&o>optionAPI("maxItems")&&(o=optionAPI("maxItems")),a&&a>optionAPI("maxItems")&&(a=o));var s=!0===optionAPI("alwaysFakeOptionals")?1:optionAPI("optionalsProbability"),u=optionAPI("alwaysFakeOptionals")||optionAPI("fixedProbabilities")||!1,p=random.number(a,o,1,5);!1!==s&&(p=Math.max(u?Math.round((o||p)*s):Math.abs(random.number(a,o)*s),a||0));for(var l="object"==typeof e.additionalItems?e.additionalItems:{},f=i.length;f<p;f+=1){var c=t.concat(["items",f]),h=n(e.items||l,c,r);i.push(h)}return e.uniqueItems?unique(t.concat(["items"]),i,e,l,r,n):i}function numberType(e){var t="undefined"==typeof e.minimum?env.MIN_INTEGER:e.minimum,r="undefined"==typeof e.maximum?env.MAX_INTEGER:e.maximum,n=e.multipleOf;if(n&&(r=Math.floor(r/n)*n,t=Math.ceil(t/n)*n),e.exclusiveMinimum&&t===e.minimum&&(t+=n||1),e.exclusiveMaximum&&r===e.maximum&&(r-=n||1),t>r)return NaN;if(n){if(-1===String(n).indexOf(".")){for(var i=random.number(Math.floor(t/n),Math.floor(r/n))*n;i<t;)i+=e.multipleOf;return i}var a,o,s=(r-t)/n;do{o=(a=random.number(0,s)*n)/n%1}while(0!==o);return t+a}return random.number(t,r,undefined,undefined,!0)}function integerType(e){return numberType(Object.assign({multipleOf:1},e))}var LIPSUM_WORDS="Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore\net dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\ncommodo consequat Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\npariatur Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est\nlaborum".split(/\W/);function wordsGenerator(e){return random.shuffle(LIPSUM_WORDS).slice(0,e)}var anyType={type:["string","number","integer","boolean"]};function objectType(e,t,r,n){var i={},a=e.properties||{},o=e.patternProperties||{},s="boolean"==typeof e.required?[]:(e.required||[]).slice(),u=!1!==e.additionalProperties,p=Object.keys(a),l=Object.keys(o),f=p.concat(l).reduce((function(e,t){return-1===s.indexOf(t)&&e.push(t),e}),[]),c=s.concat(f),h=u&&!0===e.additionalProperties?anyType:e.additionalProperties;if(!u&&0===p.length&&0===l.length&&utils.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(!0===optionAPI("requiredOnly"))return s.forEach((function(e){a[e]&&(i[e]=a[e])})),n(i,t.concat(["properties"]),r,e);var m=!0===optionAPI("alwaysFakeOptionals")?1:optionAPI("optionalsProbability"),d=optionAPI("alwaysFakeOptionals")||optionAPI("fixedProbabilities")||!1,y=optionAPI("ignoreProperties")||[],g=Math.max(e.minProperties||0,s.length),v=e.maxProperties||c.length+(u?random.number(1,5):0),b=Math.max(0,c.length-g);1!==c.length||s.length||(b=random.number(b,c.length+(c.length-g))),!1!==m&&(b=!0===d?Math.round(g-s.length+m*(c.length-g)):random.number(g-s.length,m*(c.length-g)));var A=random.shuffle(f).slice(0,b),I=f.filter((function(e){return-1!==A.indexOf(e)})),x=!1!==m?v:random.number(0,v),E=s.concat(I.slice(0,x)),R=[];if(e.dependencies&&(Object.keys(e.dependencies).forEach((function(t){var r=e.dependencies[t];-1!==E.indexOf(t)&&(Array.isArray(r)?r.forEach((function(e){-1===E.indexOf(e)&&E.push(e)})):R.push(r))})),R.length))return delete e.dependencies,n({allOf:R.concat(e)},t.concat(["properties"]),r,e);var P=[];E.forEach((function(e){for(var t=0;t<y.length;t+=1)if(y[t]instanceof RegExp&&y[t].test(e)||"string"==typeof y[t]&&y[t]===e||"function"==typeof y[t]&&y[t](a[e],e))return void P.push(e);var r;if(!1===h&&-1!==s.indexOf(e)&&(i[e]=a[e]),a[e]&&(i[e]=a[e]),l.forEach((function(t){e.match(new RegExp(t))&&(r=!0,i[e]?utils.merge(i[e],o[t]):i[random.randexp(e)]=o[t])})),!r){var n=o[e]||h;n&&!1!==h&&(i[o[e]?random.randexp(e):e]=a[e]||n)}}));var O,w=optionAPI("fillProperties"),T=optionAPI("reuseProperties"),S=Object.keys(i).length+(w?0:P.length);function M(e){var t;do{if(!e.length)break;t=e.shift()}while(i[t]);return t}for(;w&&(l.length||u)&&!(S>=g);){if(u)if(T&&p.length-S>g){var k=0,_=void 0;do{if((k+=1)>1e3)break;_=M(s)||random.pick(p)}while("undefined"!=typeof i[_]);"undefined"==typeof i[_]&&(i[_]=a[_],S+=1)}else if(l.length&&!h){var N=random.pick(l),C=random.randexp(N);i[C]||(i[C]=o[N],S+=1)}else{var j=M(s)||wordsGenerator(1)+(O=void 0,random.randexp("_?[_a-f\\d]{1,3}"+(O?"\\$?":"")));i[j]||(i[j]=h||anyType,S+=1)}for(var $=0;S<g&&$<l.length;$+=1){var L=l[$],G=random.randexp(L);i[G]||(i[G]=o[L],S+=1)}}if(0===s.length&&(!u||!1===m))for(var D=random.number(g,v);S<D;){var F=M(p);F&&(i[F]=a[F]),S+=1}return n(i,t.concat(["properties"]),r,e)}function produce(){return wordsGenerator(random.number(1,5)).join(" ")}function thunkGenerator(e,t){void 0===e&&(e=0),void 0===t&&(t=140);for(var r=Math.max(0,e),n=random.number(r,t),i=produce();i.length<r;)i+=produce();return i.length>n&&(i=i.substr(0,n)),i}function ipv4Generator(){return[0,0,0,0].map((function(){return random.number(0,255)})).join(".")}function dateTimeGenerator(){return random.date().toISOString()}function dateGenerator(){return dateTimeGenerator().slice(0,10)}function timeGenerator(){return dateTimeGenerator().slice(11)}var FRAGMENT="[a-zA-Z][a-zA-Z0-9+-.]*",URI_PATTERN="https?://{hostname}(?:"+FRAGMENT+")+",PARAM_PATTERN="(?:\\?([a-z]{1,7}(=\\w{1,5})?&){0,3})?",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:URI_PATTERN,slug:"[a-zA-Z\\d_-]+","uri-reference":""+URI_PATTERN+PARAM_PATTERN,"uri-template":URI_PATTERN.replace("(?:","(?:/\\{[a-z][:a-zA-Z0-9-]*\\}|"),"json-pointer":"(/(?:"+FRAGMENT.replace("]*","/]*")+"|~[01]))+",uuid:"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"};regexps.iri=regexps["uri-reference"],regexps["iri-reference"]=regexps["uri-reference"],regexps["idn-email"]=regexps.email,regexps["idn-hostname"]=regexps.hostname;var ALLOWED_FORMATS=new RegExp("\\{("+Object.keys(regexps).join("|")+")\\}");function coreFormatGenerator(e){return random.randexp(regexps[e]).replace(ALLOWED_FORMATS,(function(e,t){return random.randexp(regexps[t])}))}function generateFormat(e,t){var r=formatAPI(e.format);if("function"==typeof r)return r(e);switch(e.format){case"date-time":case"datetime":return dateTimeGenerator();case"date":return dateGenerator();case"time":return timeGenerator();case"ipv4":return ipv4Generator();case"regex":return".+?";case"email":case"hostname":case"ipv6":case"uri":case"uri-reference":case"iri":case"iri-reference":case"idn-email":case"idn-hostname":case"json-pointer":case"slug":case"uri-template":case"uuid":return coreFormatGenerator(e.format);default:if(void 0===r){if(optionAPI("failOnInvalidFormat"))throw new Error("unknown registry key "+utils.short(e.format));return t()}throw new Error("unsupported format '"+e.format+"'")}}function stringType(e){return utils.typecast("string",e,(function(t){return e.format?generateFormat(e,(function(){return thunkGenerator(t.minLength,t.maxLength)})):e.pattern?random.randexp(e.pattern):thunkGenerator(t.minLength,t.maxLength)}))}var typeMap={boolean:booleanType,"null":nullType,array:arrayType,integer:integerType,number:numberType,object:objectType,string:stringType};function traverse(e,t,r,n){if(e=r(e,null,t)){if("properties"!==t[t.length-1]){if(optionAPI("useExamplesValue")&&Array.isArray(e.examples)){var i=e.examples.concat("default"in e?[e["default"]]:[]);return utils.typecast(null,e,(function(){return random.pick(i)}))}if(optionAPI("useDefaultValue")&&"default"in e&&(""!==e["default"]||!optionAPI("replaceEmptyByRandomValue")))return e["default"];if("template"in e)return utils.template(e.template,n);if("const"in e)return e["const"]}if(e.not&&"object"==typeof e.not&&(e=utils.notValue(e.not,utils.omitProps(e,["not"]))).type&&"object"===e.type){var a=traverse(e,t.concat(["not"]),r,n);return utils.clean(a,e,!1)}if("function"==typeof e.thunk)return traverse(e.thunk(n),t,r);if("function"==typeof e.generate)return utils.typecast(null,e,(function(){return e.generate(n)}));if("string"==typeof e.pattern)return utils.typecast("string",e,(function(){return random.randexp(e.pattern)}));if(Array.isArray(e["enum"]))return utils.typecast(null,e,(function(){return random.pick(e["enum"])}));if(e.jsonPath)return e;var o=e.type;if(Array.isArray(o)?o=random.pick(o):void 0===o&&(o=inferType(e,t)||o)&&(e.type=o),"string"==typeof o){if(!typeMap[o]){if(optionAPI("failOnInvalidTypes"))throw new ParseError("unknown primitive "+utils.short(o),t.concat(["type"]));return optionAPI("defaultInvalidTypeProduct")}try{return typeMap[o](e,t,r,traverse)}catch(u){if("undefined"==typeof u.path)throw new ParseError(u.stack,t);throw u}}var s={};return Array.isArray(e)&&(s=[]),Object.keys(e).forEach((function(n){if("object"==typeof e[n]&&"definitions"!==n){var i=traverse(e[n],t.concat([n]),r,s);s[n]=utils.clean(i,e[n],!1)}else s[n]=e[n]})),s}}var buildResolveSchema=function(e){var t,r=e.refs,n=e.schema,i=e.container,a=e.refDepthMax,o=e.refDepthMin,s=0,u={resolveSchema:function(e,p,l){if(null===e||e===undefined)return null;if("function"==typeof e.generate)return e;if("string"==typeof(e.$id||e.id)&&(delete e.id,delete e.$id,delete e.$schema),"string"==typeof e.$ref){var f,c=Math.max(o,a)-1;if("#"===e.$ref||t===e.$ref&&++s>c)return delete e.$ref,e;if(t=e.$ref,-1===e.$ref.indexOf("#/")&&(f=r[e.$ref]||null),0===e.$ref.indexOf("#/definitions/")&&(f=n.definitions[e.$ref.split("#/definitions/")[1]]||null),void 0!==f){if(!f&&!0!==optionAPI("ignoreMissingRefs"))throw new Error("Reference not found: "+e.$ref);utils.merge(e,f||{})}return delete e.$ref,e}if(Array.isArray(e.allOf)){var h=e.allOf;delete e.allOf,h.forEach((function(t){var r=u.resolveSchema(t,null,l);utils.merge(e,"function"==typeof r.thunk?r.thunk(e):r),Array.isArray(e.allOf)&&u.resolveSchema(e,p,l)}))}if(Array.isArray(e.oneOf||e.anyOf)){var m=e.oneOf||e.anyOf;return e["enum"]&&e.oneOf&&(e["enum"]=e["enum"].filter((function(e){return utils.validate(e,m)}))),{thunk:function(t){var r=utils.omitProps(e,["anyOf","oneOf"]),n=random.pick(m);return utils.merge(r,n),m.forEach((function(e){e.required&&e!==n&&e.required.forEach((function(e){var n=r.required&&r.required.includes(e);r.properties&&!n&&delete r.properties[e],t&&t.properties&&delete t.properties[e]}))})),r}}}if(Object.keys(e).forEach((function(t){!Array.isArray(e[t])&&"object"!=typeof e[t]||utils.isKey(t)||(e[t]=u.resolveSchema(e[t],t,l.concat(t)))})),l){var d=l[l.length-1];if("properties"===d||"items"===d)return e}return i.wrap(e)}};return u};function pick$1(e){return Array.isArray(e)?random.pick(e):e}function cycle(e,t){if(!Array.isArray(e))return e;var r=t?e.pop():e.shift();return t?e.unshift(r):e.push(r),r}function resolve(e,t,r,n){if(!e||"object"!=typeof e)return e;if(r||(r={}),t||(t=e),Array.isArray(e))return e.map((function(e){return resolve(e,t,r,n)}));if(e.jsonPath){var i="object"!=typeof e.jsonPath?{path:e.jsonPath}:e.jsonPath;i.group=e.group||i.group||n,i.cycle=e.cycle||i.cycle||!1,i.reverse=e.reverse||i.reverse||!1,i.count=e.count||i.count||1;var a=i.group+"__"+i.path;return r[a]||(i.count>1?r[a]=JSONPath(i.path,t).slice(0,i.count):r[a]=JSONPath(i.path,t)),i.cycle||i.reverse?cycle(r[a],i.reverse):pick$1(r[a])}return Object.keys(e).forEach((function(n){e[n]=resolve(e[n],t,r,n)})),e}function run(e,t,r){var n=optionAPI("refDepthMin")||0,i=optionAPI("refDepthMax")||3;try{var a=buildResolveSchema({refs:e,schema:t,container:r,refDepthMin:n,refDepthMax:i}).resolveSchema,o=traverse(utils.clone(t),[],a);return optionAPI("resolveJsonPath")?resolve(o):o}catch(s){throw s.path?new Error(s.message+" in /"+s.path.join("/")):s}}var container=new Container;function setupKeywords(){container.define("autoIncrement",(function(e,t){if(!this.offset){var r=t.minimum||1,n=r+env.MAX_NUMBER,i=e.initialOffset||t.initialOffset;this.offset=i||random.number(r,n)}return!0===e?this.offset++:t})),container.define("sequentialDate",(function(e,t){if(this.now||(this.now=random.date()),e){if(t=this.now.toISOString(),-1===["seconds","minutes","hours","days","weeks","months","years"].indexOf(e=!0===e?"days":e))throw new Error("Unsupported increment by "+utils.short(e));this.now.setTime(this.now.getTime()+random.date(e))}return t}))}function getRefs(e){var t={};return Array.isArray(e)?e.forEach((function(e){t[e.$id||e.id]=e})):t=e||{},t}var jsf=function(e,t,r){return jsf.generate(e,t)};jsf.generate=function(e,t){return run(getRefs(t),e,container)},jsf.resolve=function(e,t,r){"string"==typeof t&&(r=t,t={}),r=(r=r||("undefined"!=typeof process?process.cwd():"")).replace(/\/+$/,"")+"/";var n=getRefs(t),i={order:1,canRead:function(e){return n[e.url]||n[e.url.split("/").pop()]},read:function(e,t){try{t(null,n[e.url]||n[e.url.split("/").pop()])}catch(r){t(r)}}};return $RefParser.dereference(r,e,{resolve:{file:{order:100},http:{order:200},fixedRefs:i},dereference:{circular:"ignore"}}).then((function(e){return run(n,e,container)}))},setupKeywords(),jsf.format=formatAPI,jsf.option=optionAPI,jsf.random=random,jsf.extend=function(e,t){return container.extend(e,t),jsf},jsf.define=function(e,t){return container.define(e,t),jsf},jsf.reset=function(e){return container.reset(e),setupKeywords(),jsf},jsf.locate=function(e){return container.get(e)};var VERSION="0.5.0-rcv.29";void 0!==VERSION&&(jsf.version=VERSION);export default jsf; | ||
import $RefParser from"json-schema-ref-parser";import{JSONPath}from"jsonpath-plus";var Registry=function(){this.data={}};Registry.prototype.unregister=function(e){e?delete this.data[e]:this.data={}},Registry.prototype.register=function(e,t){this.data[e]=t},Registry.prototype.registerMany=function(e){var t=this;Object.keys(e).forEach((function(r){t.data[r]=e[r]}))},Registry.prototype.get=function(e){return this.data[e]},Registry.prototype.list=function(){return this.data};var defaults={};defaults.defaultInvalidTypeProduct=undefined,defaults.defaultRandExpMax=10,defaults.ignoreProperties=[],defaults.ignoreMissingRefs=!1,defaults.failOnInvalidTypes=!0,defaults.failOnInvalidFormat=!0,defaults.alwaysFakeOptionals=!1,defaults.optionalsProbability=null,defaults.fixedProbabilities=!1,defaults.useExamplesValue=!1,defaults.useDefaultValue=!1,defaults.requiredOnly=!1,defaults.minItems=0,defaults.maxItems=null,defaults.minLength=0,defaults.maxLength=null,defaults.resolveJsonPath=!1,defaults.reuseProperties=!1,defaults.fillProperties=!0,defaults.replaceEmptyByRandomValue=!1,defaults.random=Math.random;var OptionRegistry=function(e){function t(){e.call(this),this.data=Object.assign({},defaults),this._defaults=defaults}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaults:{configurable:!0}};return r.defaults.get=function(){return Object.assign({},this._defaults)},Object.defineProperties(t.prototype,r),t}(Registry),registry=new OptionRegistry;function optionAPI(e,t){return"string"==typeof e?void 0!==t?registry.register(e,t):registry.get(e):registry.registerMany(e)}optionAPI.getDefaults=function(){return registry.defaults};var SCALAR_TYPES=["integer","number","string","boolean","null"],ALL_TYPES=["array","object"].concat(SCALAR_TYPES),MOST_NEAR_DATETIME=2524608e6,MIN_INTEGER=-1e8,MAX_INTEGER=1e8,MIN_NUMBER=-100,MAX_NUMBER=100,env={SCALAR_TYPES:SCALAR_TYPES,ALL_TYPES:ALL_TYPES,MIN_NUMBER:MIN_NUMBER,MAX_NUMBER:MAX_NUMBER,MIN_INTEGER:MIN_INTEGER,MAX_INTEGER:MAX_INTEGER,MOST_NEAR_DATETIME:MOST_NEAR_DATETIME};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var types={ROOT:0,GROUP:1,POSITION:2,SET:3,RANGE:4,REPETITION:5,REFERENCE:6,CHAR:7};const INTS=()=>[{type:types.RANGE,from:48,to:57}],WORDS=()=>[{type:types.CHAR,value:95},{type:types.RANGE,from:97,to:122},{type:types.RANGE,from:65,to:90}].concat(INTS()),WHITESPACE=()=>[{type:types.CHAR,value:9},{type:types.CHAR,value:10},{type:types.CHAR,value:11},{type:types.CHAR,value:12},{type:types.CHAR,value:13},{type:types.CHAR,value:32},{type:types.CHAR,value:160},{type:types.CHAR,value:5760},{type:types.RANGE,from:8192,to:8202},{type:types.CHAR,value:8232},{type:types.CHAR,value:8233},{type:types.CHAR,value:8239},{type:types.CHAR,value:8287},{type:types.CHAR,value:12288},{type:types.CHAR,value:65279}],NOTANYCHAR=()=>[{type:types.CHAR,value:10},{type:types.CHAR,value:13},{type:types.CHAR,value:8232},{type:types.CHAR,value:8233}];var words=()=>({type:types.SET,set:WORDS(),not:!1}),notWords=()=>({type:types.SET,set:WORDS(),not:!0}),ints=()=>({type:types.SET,set:INTS(),not:!1}),notInts=()=>({type:types.SET,set:INTS(),not:!0}),whitespace=()=>({type:types.SET,set:WHITESPACE(),not:!1}),notWhitespace=()=>({type:types.SET,set:WHITESPACE(),not:!0}),anyChar=()=>({type:types.SET,set:NOTANYCHAR(),not:!0}),sets={words:words,notWords:notWords,ints:ints,notInts:notInts,whitespace:whitespace,notWhitespace:notWhitespace,anyChar:anyChar},util=createCommonjsModule((function(e,t){const r={0:0,t:9,n:10,v:11,f:12,r:13};t.strToChars=function(e){return e=e.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(function(e,t,n,i,a,o,s,u){if(n)return e;var p=t?8:i?parseInt(i,16):a?parseInt(a,16):o?parseInt(o,8):s?"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s):r[u],l=String.fromCharCode(p);return/[[\]{}^$.|?*+()]/.test(l)&&(l="\\"+l),l}))},t.tokenizeClass=(e,r)=>{for(var n,i,a=[],o=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g;null!=(n=o.exec(e));)if(n[1])a.push(sets.words());else if(n[2])a.push(sets.ints());else if(n[3])a.push(sets.whitespace());else if(n[4])a.push(sets.notWords());else if(n[5])a.push(sets.notInts());else if(n[6])a.push(sets.notWhitespace());else if(n[7])a.push({type:types.RANGE,from:(n[8]||n[9]).charCodeAt(0),to:n[10].charCodeAt(0)});else{if(!(i=n[12]))return[a,o.lastIndex];a.push({type:types.CHAR,value:i.charCodeAt(0)})}t.error(r,"Unterminated character class")},t.error=(e,t)=>{throw new SyntaxError("Invalid regular expression: /"+e+"/: "+t)}})),util_1=util.strToChars,util_2=util.tokenizeClass,util_3=util.error,wordBoundary=()=>({type:types.POSITION,value:"b"}),nonWordBoundary=()=>({type:types.POSITION,value:"B"}),begin=()=>({type:types.POSITION,value:"^"}),end=()=>({type:types.POSITION,value:"$"}),positions={wordBoundary:wordBoundary,nonWordBoundary:nonWordBoundary,begin:begin,end:end},lib=e=>{var t,r,n=0,i={type:types.ROOT,stack:[]},a=i,o=i.stack,s=[],u=t=>{util.error(e,`Nothing to repeat at column ${t-1}`)},p=util.strToChars(e);for(t=p.length;n<t;)switch(r=p[n++]){case"\\":switch(r=p[n++]){case"b":o.push(positions.wordBoundary());break;case"B":o.push(positions.nonWordBoundary());break;case"w":o.push(sets.words());break;case"W":o.push(sets.notWords());break;case"d":o.push(sets.ints());break;case"D":o.push(sets.notInts());break;case"s":o.push(sets.whitespace());break;case"S":o.push(sets.notWhitespace());break;default:/\d/.test(r)?o.push({type:types.REFERENCE,value:parseInt(r,10)}):o.push({type:types.CHAR,value:r.charCodeAt(0)})}break;case"^":o.push(positions.begin());break;case"$":o.push(positions.end());break;case"[":var l;"^"===p[n]?(l=!0,n++):l=!1;var f=util.tokenizeClass(p.slice(n),e);n+=f[1],o.push({type:types.SET,set:f[0],not:l});break;case".":o.push(sets.anyChar());break;case"(":var c={type:types.GROUP,stack:[],remember:!0};"?"===(r=p[n])&&(r=p[n+1],n+=2,"="===r?c.followedBy=!0:"!"===r?c.notFollowedBy=!0:":"!==r&&util.error(e,`Invalid group, character '${r}'`+` after '?' at column ${n-1}`),c.remember=!1),o.push(c),s.push(a),a=c,o=c.stack;break;case")":0===s.length&&util.error(e,`Unmatched ) at column ${n-1}`),o=(a=s.pop()).options?a.options[a.options.length-1]:a.stack;break;case"|":a.options||(a.options=[a.stack],delete a.stack);var h=[];a.options.push(h),o=h;break;case"{":var d,m,y=/^(\d+)(,(\d+)?)?\}/.exec(p.slice(n));null!==y?(0===o.length&&u(n),d=parseInt(y[1],10),m=y[2]?y[3]?parseInt(y[3],10):Infinity:d,n+=y[0].length,o.push({type:types.REPETITION,min:d,max:m,value:o.pop()})):o.push({type:types.CHAR,value:123});break;case"?":0===o.length&&u(n),o.push({type:types.REPETITION,min:0,max:1,value:o.pop()});break;case"+":0===o.length&&u(n),o.push({type:types.REPETITION,min:1,max:Infinity,value:o.pop()});break;case"*":0===o.length&&u(n),o.push({type:types.REPETITION,min:0,max:Infinity,value:o.pop()});break;default:o.push({type:types.CHAR,value:r.charCodeAt(0)})}return 0!==s.length&&util.error(e,"Unterminated group"),i},types_1=types;lib.types=types_1;class SubRange{constructor(e,t){this.low=e,this.high=t,this.length=1+t-e}overlaps(e){return!(this.high<e.low||this.low>e.high)}touches(e){return!(this.high+1<e.low||this.low-1>e.high)}add(e){return new SubRange(Math.min(this.low,e.low),Math.max(this.high,e.high))}subtract(e){return e.low<=this.low&&e.high>=this.high?[]:e.low>this.low&&e.high<this.high?[new SubRange(this.low,e.low-1),new SubRange(e.high+1,this.high)]:e.low<=this.low?[new SubRange(e.high+1,this.high)]:[new SubRange(this.low,e.low-1)]}toString(){return this.low==this.high?this.low.toString():this.low+"-"+this.high}}class DRange{constructor(e,t){this.ranges=[],this.length=0,null!=e&&this.add(e,t)}_update_length(){this.length=this.ranges.reduce((e,t)=>e+t.length,0)}add(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.touches(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.touches(this.ranges[t]);)e=e.add(this.ranges[t]),t++;r.push(e),this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof DRange?e.ranges.forEach(r):(null==t&&(t=e),r(new SubRange(e,t))),this}subtract(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.overlaps(this.ranges[t]);)r=r.concat(this.ranges[t].subtract(e)),t++;this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof DRange?e.ranges.forEach(r):(null==t&&(t=e),r(new SubRange(e,t))),this}intersect(e,t){var r=[],n=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(;t<this.ranges.length&&e.overlaps(this.ranges[t]);){var n=Math.max(this.ranges[t].low,e.low),i=Math.min(this.ranges[t].high,e.high);r.push(new SubRange(n,i)),t++}};return e instanceof DRange?e.ranges.forEach(n):(null==t&&(t=e),n(new SubRange(e,t))),this.ranges=r,this._update_length(),this}index(e){for(var t=0;t<this.ranges.length&&this.ranges[t].length<=e;)e-=this.ranges[t].length,t++;return this.ranges[t].low+e}toString(){return"[ "+this.ranges.join(", ")+" ]"}clone(){return new DRange(this)}numbers(){return this.ranges.reduce((e,t)=>{for(var r=t.low;r<=t.high;)e.push(r),r++;return e},[])}subranges(){return this.ranges.map(e=>({low:e.low,high:e.high,length:1+e.high-e.low}))}}var lib$1=DRange;const types$1=lib.types;var randexp=class e{constructor(e,t){if(this._setDefaults(e),e instanceof RegExp)this.ignoreCase=e.ignoreCase,this.multiline=e.multiline,e=e.source;else{if("string"!=typeof e)throw new Error("Expected a regexp or string");this.ignoreCase=t&&-1!==t.indexOf("i"),this.multiline=t&&-1!==t.indexOf("m")}this.tokens=lib(e)}_setDefaults(t){this.max=null!=t.max?t.max:null!=e.prototype.max?e.prototype.max:100,this.defaultRange=t.defaultRange?t.defaultRange:this.defaultRange.clone(),t.randInt&&(this.randInt=t.randInt)}gen(){return this._gen(this.tokens,[])}_gen(e,t){var r,n,i,a,o;switch(e.type){case types$1.ROOT:case types$1.GROUP:if(e.followedBy||e.notFollowedBy)return"";for(e.remember&&e.groupNumber===undefined&&(e.groupNumber=t.push(null)-1),n="",a=0,o=(r=e.options?this._randSelect(e.options):e.stack).length;a<o;a++)n+=this._gen(r[a],t);return e.remember&&(t[e.groupNumber]=n),n;case types$1.POSITION:return"";case types$1.SET:var s=this._expand(e);return s.length?String.fromCharCode(this._randSelect(s)):"";case types$1.REPETITION:for(i=this.randInt(e.min,e.max===Infinity?e.min+this.max:e.max),n="",a=0;a<i;a++)n+=this._gen(e.value,t);return n;case types$1.REFERENCE:return t[e.value-1]||"";case types$1.CHAR:var u=this.ignoreCase&&this._randBool()?this._toOtherCase(e.value):e.value;return String.fromCharCode(u)}}_toOtherCase(e){return e+(97<=e&&e<=122?-32:65<=e&&e<=90?32:0)}_randBool(){return!this.randInt(0,1)}_randSelect(e){return e instanceof lib$1?e.index(this.randInt(0,e.length-1)):e[this.randInt(0,e.length-1)]}_expand(e){if(e.type===lib.types.CHAR)return new lib$1(e.value);if(e.type===lib.types.RANGE)return new lib$1(e.from,e.to);{let t=new lib$1;for(let r=0;r<e.set.length;r++){let n=this._expand(e.set[r]);if(t.add(n),this.ignoreCase)for(let e=0;e<n.length;e++){let r=n.index(e),i=this._toOtherCase(r);r!==i&&t.add(i)}}return e.not?this.defaultRange.clone().subtract(t):this.defaultRange.clone().intersect(t)}}randInt(e,t){return e+Math.floor(Math.random()*(1+t-e))}get defaultRange(){return this._range=this._range||new lib$1(32,126)}set defaultRange(e){this._range=e}static randexp(t,r){var n;return"string"==typeof t&&(t=new RegExp(t,r)),t._randexp===undefined?(n=new e(t,r),t._randexp=n):(n=t._randexp)._setDefaults(t),n.gen()}static sugar(){RegExp.prototype.gen=function(){return e.randexp(this)}}};function getRandomInteger(e,t){return e=void 0===e?env.MIN_INTEGER:e,t=void 0===t?env.MAX_INTEGER:t,Math.floor(optionAPI("random")()*(t-e+1))+e}function _randexp(e){return randexp.prototype.max=optionAPI("defaultRandExpMax"),randexp.prototype.randInt=function(e,t){return e+Math.floor(optionAPI("random")()*(t-e+1))},new randexp(e).gen()}function pick(e){return e[Math.floor(optionAPI("random")()*e.length)]}function shuffle(e){for(var t,r,n=e.length,i=e.slice();n>0;)r=Math.floor(optionAPI("random")()*n),t=i[n-=1],i[n]=i[r],i[r]=t;return i}function getRandom(e,t){return optionAPI("random")()*(t-e)+e}function number(e,t,r,n,i){return void 0===i&&(i=!1),r=void 0===r?env.MIN_NUMBER:r,n=void 0===n?env.MAX_NUMBER:n,(t=void 0===t?n:t)<(e=void 0===e?r:e)&&(t+=e),i?getRandom(e,t):getRandomInteger(e,t)}function by(e){switch(e){case"seconds":return 60*number(0,60);case"minutes":return 612*number(15,50);case"hours":return 36123*number(12,72);case"days":return 86412345*number(7,30);case"weeks":return 604812345*number(4,52);case"months":return 2592012345*number(2,13);case"years":return 31104012345*number(1,20)}}function date(e){if(e)return by(e);var t=new Date,r=number(-1e3,env.MOST_NEAR_DATETIME);return t.setTime(t.getTime()-r),t}var random={pick:pick,date:date,shuffle:shuffle,number:number,randexp:_randexp};function getLocalRef(e,t){for(var r=t.replace("#/","").split("/");r.length;){var n=r.shift();if(!e[n])throw new Error("Prop not found: "+n+" ("+t+")");e=e[n]}return e}function hasProperties(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return t.filter((function(t){return"undefined"!=typeof e[t]})).length>0}function typecast(e,t,r){var n={};switch(e||t.type){case"integer":case"number":if("undefined"!=typeof t.minimum&&(n.minimum=t.minimum),"undefined"!=typeof t.maximum&&(n.maximum=t.maximum),t["enum"]){var i=Math.max(n.minimum||0,0),a=Math.min(n.maximum||Infinity,Infinity);t.exclusiveMinimum&&i===t.minimum&&(i+=t.multipleOf||1),t.exclusiveMaximum&&a===t.maximum&&(a-=t.multipleOf||1),(i||a!==Infinity)&&(t["enum"]=t["enum"].filter((function(e){return e>=i&&e<=a})))}break;case"string":n.minLength=optionAPI("minLength")||0,n.maxLength=optionAPI("maxLength")||Number.MAX_SAFE_INTEGER,"undefined"!=typeof t.minLength&&(n.minLength=Math.max(n.minLength,t.minLength)),"undefined"!=typeof t.maxLength&&(n.maxLength=Math.min(n.maxLength,t.maxLength))}var o=r(n);if(null===o||o===undefined)return null;switch(e||t.type){case"number":o=parseFloat(o);break;case"integer":o=parseInt(o,10);break;case"boolean":o=!!o;break;case"string":o=String(o);for(var s,u=Math.max(n.minLength||0,0),p=Math.min(n.maxLength||Infinity,Infinity);o.length<u&&(s=o,t.pattern?o+=random.randexp(t.pattern):o+=""+random.pick([" ","/","_","-","+","=","@","^"])+o,o!==s););switch(o.length>p&&(o=o.substr(0,p)),t.format){case"date-time":case"datetime":o=new Date(o).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"date":o=new Date(o).toISOString().substr(0,10);break;case"time":o=new Date("1969-01-01 "+o).toISOString().substr(11)}}return o}function merge(e,t){return Object.keys(t).forEach((function(r){"object"!=typeof t[r]||null===t[r]?e[r]=t[r]:Array.isArray(t[r])?(e[r]=e[r]||[],t[r].forEach((function(t){Array.isArray(e[r])&&-1===e[r].indexOf(t)&&e[r].push(t)}))):"object"!=typeof e[r]||null===e[r]||Array.isArray(e[r])?e[r]=merge({},t[r]):e[r]=merge(e[r],t[r])})),e}function clone(e,t){if(void 0===t&&(t=new Map),!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){var r=[];return t.set(e,r),r.push.apply(r,e.map((function(e){return clone(e,t)}))),r}var n={};return t.set(e,n),Object.keys(e).reduce((function(r,n){return r[n]=clone(e[n],t),r}),n)}function short(e){var t=JSON.stringify(e),r=JSON.stringify(e,null,2);return t.length>400?r.substr(0,400)+"...":r}function anyValue(){return random.pick([!1,!0,null,-1,NaN,Math.PI,Infinity,undefined,[],{},Math.random(),Math.random().toString(36).substr(2)])}function notValue(e,t){var r=merge({},t);if("undefined"!=typeof e.minimum&&(r.maximum=e.minimum,r.exclusiveMaximum=!0),"undefined"!=typeof e.maximum&&(r.minimum=e.maximum>r.maximum?0:e.maximum,r.exclusiveMinimum=!0),"undefined"!=typeof e.minLength&&(r.maxLength=e.minLength),"undefined"!=typeof e.maxLength&&(r.minLength=e.maxLength>r.maxLength?0:e.maxLength),e.type)r.type=random.pick(env.SCALAR_TYPES.filter((function(t){return(Array.isArray(e.type)?e.type:[e.type]).every((function(e){return"number"===t||"integer"===t?"number"!==e&&"integer"!==e:t!==e}))})));else if(e["enum"]){var n;do{n=anyValue()}while(-1!==e["enum"].indexOf(n));r["enum"]=[n]}return e.required&&r.properties&&e.required.forEach((function(e){delete r.properties[e]})),r}function validateValueForSchema(e,t){var r=t.minimum!==undefined,n=t.maximum!==undefined;return(r||n)&&(!r||e>=t.minimum)&&(!n||e<=t.maximum)}function validate(e,t){return!t.every((function(t){return validateValueForSchema(e,t)}))}function validateValueForOneOf(e,t){return 1===t.reduce((function(t,r){return t+(validateValueForSchema(e,r)?1:0)}),0)}function isKey(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)}function omitProps(e,t){return Object.keys(e).filter((function(e){return!t.includes(e)})).reduce((function(t,r){return Array.isArray(e[r])?t[r]=e[r].slice():t[r]=e[r]instanceof Object?merge({},e[r]):e[r],t}),{})}function template(e,t){return Array.isArray(e)?e.map((function(e){return template(e,t)})):("string"==typeof e&&(e=e.replace(/#\{([\w.-]+)\}/g,(function(e,r){return t[r]}))),e)}function isEmpty(e){return"[object Object]"==={}.toString.call(e)&&!Object.keys(e).length}function shouldClean(e,t){var r=Array.isArray(t.required)&&t.required.includes(e),n="function"==typeof t.thunk||t.additionalProperties&&"function"==typeof t.additionalProperties.thunk;return!r&&!n}function clean(e,t,r){return void 0===r&&(r=!1),e&&"object"==typeof e?Array.isArray(e)?e.map((function(e){return clean(e,t,!0)})).filter((function(e){return void 0!==e})):(Object.keys(e).forEach((function(r){if(isEmpty(e[r]))shouldClean(r,t)&&delete e[r];else{var n=clean(e[r],t);isEmpty(n)||(e[r]=n)}"undefined"==typeof e[r]&&delete e[r]})),!Object.keys(e).length&&r?undefined:e):e}var utils={hasProperties:hasProperties,getLocalRef:getLocalRef,omitProps:omitProps,typecast:typecast,merge:merge,clone:clone,short:short,notValue:notValue,anyValue:anyValue,validate:validate,validateValueForSchema:validateValueForSchema,validateValueForOneOf:validateValueForOneOf,isKey:isKey,template:template,shouldClean:shouldClean,clean:clean,isEmpty:isEmpty};function proxy(e){return function(t,r,n,i){var a=t,o=[];"object"==typeof t&&(a=Object.keys(t)[0],Array.isArray(t[a])?o=t[a]:o.push(t[a]));for(var s=a.split("."),u=e();s.length>1;)u=u[s.shift()];return"function"==typeof(t="object"==typeof u?u[s[0]]:u)&&(t=t.apply(u,o.map((function(e){return utils.template(e,i)})))),"[object Object]"==={}.toString.call(t)&&Object.keys(t).forEach((function(e){if("function"==typeof t[e])throw new Error("Cannot resolve value for '"+n+": "+a+"', given: "+t)})),t}}var Container=function(){this.registry={},this.support={}};Container.prototype.reset=function(e){e?(delete this.registry[e],delete this.support[e]):(this.registry={},this.support={})},Container.prototype.extend=function(e,t){var r=this;this.registry[e]=t(this.registry[e]),this.support[e]||(this.support[e]=proxy((function(){return r.registry[e]})))},Container.prototype.define=function(e,t){this.support[e]=t},Container.prototype.get=function(e){if("undefined"==typeof this.registry[e])throw new ReferenceError("'"+e+"' dependency doesn't exist.");return this.registry[e]},Container.prototype.wrap=function(e){for(var t=this,r=Object.keys(e),n={},i=r.length,a=function(){var a=r[i].replace(/^x-/,""),o=t.support[a];if("function"==typeof o)return Object.defineProperty(e,"generate",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return o.call(n,e[r[i]],e,r[i],t)}}),"break"};i--;){if("break"===a())break}return e};var registry$1=new Registry;function formatAPI(e,t){if(void 0===e)return registry$1.list();if("string"==typeof e)if("function"==typeof t)registry$1.register(e,t);else{if(null!==t&&!1!==t)return registry$1.get(e);registry$1.unregister(e)}else registry$1.registerMany(e)}var ParseError=function(e){function t(t,r){e.call(this),e.captureStackTrace&&e.captureStackTrace(this,this.constructor),this.name="ParseError",this.message=t,this.path=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Error),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","format"]};inferredProperties.number=inferredProperties.integer;var subschemaProperties=["additionalItems","items","additionalProperties","dependencies","patternProperties","properties"];function matchesType(e,t,r){return Object.keys(e).filter((function(e){var n=subschemaProperties.indexOf(t)>-1;return!(!(r.indexOf(e)>-1)||n)})).length>0}function inferType(e,t){for(var r=Object.keys(inferredProperties),n=0;n<r.length;n+=1){var i=r[n];if(matchesType(e,t[t.length-1],inferredProperties[i]))return i}}function booleanGenerator(){return optionAPI("random")()>.5}var booleanType=booleanGenerator;function nullGenerator(){return null}var nullType=nullGenerator;function unique(e,t,r,n,i,a){var o=[],s=[];function u(e){var t=JSON.stringify(e);return-1===s.indexOf(t)&&(s.push(t),o.push(e),!0)}t.forEach(u);for(var p=100;o.length!==t.length&&(u(a(r.items||n,e,i))||(p-=1),p););return o}function arrayType(e,t,r,n){var i=[];if(!e.items&&!e.additionalItems){if(utils.hasProperties(e,"minItems","maxItems","uniqueItems"))throw new ParseError("missing items for "+utils.short(e),t);return i}if(Array.isArray(e.items))return e.items.map((function(e,i){var a=t.concat(["items",i]);return n(e,a,r)}));var a=e.minItems,o=e.maxItems;optionAPI("minItems")&&(a=o?Math.min(optionAPI("minItems"),o):optionAPI("minItems")),optionAPI("maxItems")&&((o=a?Math.min(optionAPI("maxItems"),a):optionAPI("maxItems"))&&o>optionAPI("maxItems")&&(o=optionAPI("maxItems")),a&&a>optionAPI("maxItems")&&(a=o));var s=!0===optionAPI("alwaysFakeOptionals")?1:optionAPI("optionalsProbability"),u=optionAPI("alwaysFakeOptionals")||optionAPI("fixedProbabilities")||!1,p=random.number(a,o,1,5);null!==s&&(p=Math.max(u?Math.round((o||p)*s):Math.abs(random.number(a,o)*s),a||0));for(var l="object"==typeof e.additionalItems?e.additionalItems:{},f=i.length;f<p;f+=1){var c=t.concat(["items",f]),h=n(e.items||l,c,r);i.push(h)}return e.uniqueItems?unique(t.concat(["items"]),i,e,l,r,n):i}function numberType(e){var t="undefined"==typeof e.minimum?env.MIN_INTEGER:e.minimum,r="undefined"==typeof e.maximum?env.MAX_INTEGER:e.maximum,n=e.multipleOf;if(n&&(r=Math.floor(r/n)*n,t=Math.ceil(t/n)*n),e.exclusiveMinimum&&t===e.minimum&&(t+=n||1),e.exclusiveMaximum&&r===e.maximum&&(r-=n||1),t>r)return NaN;if(n){if(-1===String(n).indexOf(".")){for(var i=random.number(Math.floor(t/n),Math.floor(r/n))*n;i<t;)i+=e.multipleOf;return i}var a,o,s=(r-t)/n;do{o=(a=random.number(0,s)*n)/n%1}while(0!==o);return t+a}return random.number(t,r,undefined,undefined,!0)}function integerType(e){return numberType(Object.assign({multipleOf:1},e))}var LIPSUM_WORDS="Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore\net dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\ncommodo consequat Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\npariatur Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est\nlaborum".split(/\W/);function wordsGenerator(e){return random.shuffle(LIPSUM_WORDS).slice(0,e)}var anyType={type:["string","number","integer","boolean"]};function objectType(e,t,r,n){var i={},a=e.properties||{},o=e.patternProperties||{},s="boolean"==typeof e.required?[]:(e.required||[]).slice(),u=!1!==e.additionalProperties,p=Object.keys(a),l=Object.keys(o),f=p.concat(l).reduce((function(e,t){return-1===s.indexOf(t)&&e.push(t),e}),[]),c=s.concat(f),h=u&&!0===e.additionalProperties?anyType:e.additionalProperties;if(!u&&0===p.length&&0===l.length&&utils.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(!0===optionAPI("requiredOnly"))return s.forEach((function(e){a[e]&&(i[e]=a[e])})),n(i,t.concat(["properties"]),r,e);var d=!0===optionAPI("alwaysFakeOptionals")?1:optionAPI("optionalsProbability"),m=optionAPI("alwaysFakeOptionals")||optionAPI("fixedProbabilities")||!1,y=optionAPI("ignoreProperties")||[],g=optionAPI("reuseProperties"),v=optionAPI("fillProperties"),b=e.maxProperties||c.length+(u?random.number(1,5):0),A=Math.max(e.minProperties||0,s.length),I=Math.max(0,c.length-A);1!==c.length||s.length||(A=Math.max(random.number(v?1:0,b),A)),null!==d&&(I=!0===m?Math.round(A-s.length+d*(c.length-A)):random.number(A-s.length,d*(c.length-A)));var x=random.shuffle(f).slice(0,I),E=f.filter((function(e){return-1!==x.indexOf(e)})),R=null!==d?b:random.number(0,b),P=s.concat(random.shuffle(E).slice(0,R)),O=[];if(e.dependencies&&(Object.keys(e.dependencies).forEach((function(t){var r=e.dependencies[t];-1!==P.indexOf(t)&&(Array.isArray(r)?r.forEach((function(e){-1===P.indexOf(e)&&P.push(e)})):O.push(r))})),O.length))return delete e.dependencies,n({allOf:O.concat(e)},t.concat(["properties"]),r,e);var w=[];P.forEach((function(e){for(var t=0;t<y.length;t+=1)if(y[t]instanceof RegExp&&y[t].test(e)||"string"==typeof y[t]&&y[t]===e||"function"==typeof y[t]&&y[t](a[e],e))return void w.push(e);var r;if(!1===h&&-1!==s.indexOf(e)&&(i[e]=a[e]),a[e]&&(i[e]=a[e]),l.forEach((function(t){e.match(new RegExp(t))&&(r=!0,i[e]?utils.merge(i[e],o[t]):i[random.randexp(e)]=o[t])})),!r){var n=o[e]||h;n&&!1!==h&&(i[o[e]?random.randexp(e):e]=a[e]||n)}}));var T=Object.keys(i).length+(v?0:w.length);function M(e){var t;do{if(!e.length)break;t=e.shift()}while(i[t]);return t}var S,k=A;for(u&&!s.length&&(k=Math.max(null===d||h?random.number(v?1:0,b):0,A));v&&(l.length||u)&&!(T>=k);){if(u)if(g&&p.length-T>k){var _=0,N=void 0;do{if((_+=1)>1e3)break;N=M(s)||random.pick(p)}while("undefined"!=typeof i[N]);"undefined"==typeof i[N]&&(i[N]=a[N],T+=1)}else if(l.length&&!h){var j=random.pick(l),C=random.randexp(j);i[C]||(i[C]=o[j],T+=1)}else{var $=M(s)||wordsGenerator(1)+(S=void 0,random.randexp("_?[_a-f\\d]{1,3}"+(S?"\\$?":"")));i[$]||(i[$]=h||anyType,T+=1)}for(var L=0;T<A&&L<l.length;L+=1){var G=l[L],D=random.randexp(G);i[D]||(i[D]=o[G],T+=1)}}if(0===s.length&&(!u||!1===d))for(var F=random.number(A,b);T<F;){var H=M(p);H&&(i[H]=a[H]),T+=1}return n(i,t.concat(["properties"]),r,e)}function produce(){return wordsGenerator(random.number(1,5)).join(" ")}function thunkGenerator(e,t){void 0===e&&(e=0),void 0===t&&(t=140);for(var r=Math.max(0,e),n=random.number(r,t),i=produce();i.length<r;)i+=produce();return i.length>n&&(i=i.substr(0,n)),i}function ipv4Generator(){return[0,0,0,0].map((function(){return random.number(0,255)})).join(".")}function dateTimeGenerator(){return random.date().toISOString()}function dateGenerator(){return dateTimeGenerator().slice(0,10)}function timeGenerator(){return dateTimeGenerator().slice(11)}var FRAGMENT="[a-zA-Z][a-zA-Z0-9+-.]*",URI_PATTERN="https?://{hostname}(?:"+FRAGMENT+")+",PARAM_PATTERN="(?:\\?([a-z]{1,7}(=\\w{1,5})?&){0,3})?",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:URI_PATTERN,slug:"[a-zA-Z\\d_-]+","uri-reference":""+URI_PATTERN+PARAM_PATTERN,"uri-template":URI_PATTERN.replace("(?:","(?:/\\{[a-z][:a-zA-Z0-9-]*\\}|"),"json-pointer":"(/(?:"+FRAGMENT.replace("]*","/]*")+"|~[01]))+",uuid:"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"};regexps.iri=regexps["uri-reference"],regexps["iri-reference"]=regexps["uri-reference"],regexps["idn-email"]=regexps.email,regexps["idn-hostname"]=regexps.hostname;var ALLOWED_FORMATS=new RegExp("\\{("+Object.keys(regexps).join("|")+")\\}");function coreFormatGenerator(e){return random.randexp(regexps[e]).replace(ALLOWED_FORMATS,(function(e,t){return random.randexp(regexps[t])}))}function generateFormat(e,t){var r=formatAPI(e.format);if("function"==typeof r)return r(e);switch(e.format){case"date-time":case"datetime":return dateTimeGenerator();case"date":return dateGenerator();case"time":return timeGenerator();case"ipv4":return ipv4Generator();case"regex":return".+?";case"email":case"hostname":case"ipv6":case"uri":case"uri-reference":case"iri":case"iri-reference":case"idn-email":case"idn-hostname":case"json-pointer":case"slug":case"uri-template":case"uuid":return coreFormatGenerator(e.format);default:if(void 0===r){if(optionAPI("failOnInvalidFormat"))throw new Error("unknown registry key "+utils.short(e.format));return t()}throw new Error("unsupported format '"+e.format+"'")}}function stringType(e){return utils.typecast("string",e,(function(t){return e.format?generateFormat(e,(function(){return thunkGenerator(t.minLength,t.maxLength)})):e.pattern?random.randexp(e.pattern):thunkGenerator(t.minLength,t.maxLength)}))}var typeMap={boolean:booleanType,"null":nullType,array:arrayType,integer:integerType,number:numberType,object:objectType,string:stringType};function traverse(e,t,r,n){if(e=r(e,null,t)){if("properties"!==t[t.length-1]){if(optionAPI("useExamplesValue")&&Array.isArray(e.examples)){var i=e.examples.concat("default"in e?[e["default"]]:[]);return utils.typecast(null,e,(function(){return random.pick(i)}))}if(optionAPI("useDefaultValue")&&"default"in e&&(""!==e["default"]||!optionAPI("replaceEmptyByRandomValue")))return e["default"];if("template"in e)return utils.template(e.template,n);if("const"in e)return e["const"]}if(e.not&&"object"==typeof e.not&&(e=utils.notValue(e.not,utils.omitProps(e,["not"]))).type&&"object"===e.type){var a=traverse(e,t.concat(["not"]),r,n);return utils.clean(a,e,!1)}if("function"==typeof e.thunk)return traverse(e.thunk(n),t,r);if("function"==typeof e.generate)return utils.typecast(null,e,(function(){return e.generate(n)}));if("string"==typeof e.pattern)return utils.typecast("string",e,(function(){return random.randexp(e.pattern)}));if(Array.isArray(e["enum"]))return utils.typecast(null,e,(function(){return random.pick(e["enum"])}));if(e.jsonPath)return e;var o=e.type;if(Array.isArray(o)?o=random.pick(o):void 0===o&&(o=inferType(e,t)||o)&&(e.type=o),"string"==typeof o){if(!typeMap[o]){if(optionAPI("failOnInvalidTypes"))throw new ParseError("unknown primitive "+utils.short(o),t.concat(["type"]));var s=optionAPI("defaultInvalidTypeProduct");return"string"==typeof s&&typeMap[s]?typeMap[s](e,t,r,traverse):s}try{return typeMap[o](e,t,r,traverse)}catch(p){if("undefined"==typeof p.path)throw new ParseError(p.stack,t);throw p}}var u={};return Array.isArray(e)&&(u=[]),Object.keys(e).forEach((function(n){if("object"==typeof e[n]&&"definitions"!==n){var i=traverse(e[n],t.concat([n]),r,u);u[n]=utils.clean(i,e[n],!1)}else u[n]=e[n]})),u}}var buildResolveSchema=function(e){var t,r=e.refs,n=e.schema,i=e.container,a=e.refDepthMax,o=e.refDepthMin,s={},u={},p=0;return s.resolveSchema=function(e,l,f){if(null===e||e===undefined)return null;if("function"==typeof e.generate)return e;if("string"==typeof(e.$id||e.id)&&(delete e.id,delete e.$id,delete e.$schema),"string"==typeof e.$ref){var c,h=Math.max(o,a)-1;if("#"===e.$ref||u[e.$ref]<0||t===e.$ref&&++p>h)return delete e.$ref,e;if("undefined"==typeof u[e.$ref]&&(u[e.$ref]=random.number(o,a)-1),t=e.$ref,void 0!==(c=-1===e.$ref.indexOf("#/")?r[e.$ref]||null:utils.getLocalRef(n,e.$ref)||null)){if(!c&&!0!==optionAPI("ignoreMissingRefs"))throw new Error("Reference not found: "+e.$ref);u[e.$ref]-=1,utils.merge(e,c||{})}return delete e.$ref,e}if(Array.isArray(e.allOf)){var d=e.allOf;delete e.allOf,d.forEach((function(t){var r=s.resolveSchema(t,null,f);utils.merge(e,"function"==typeof r.thunk?r.thunk(e):r),Array.isArray(e.allOf)&&s.resolveSchema(e,l,f)}))}if(Array.isArray(e.oneOf||e.anyOf)){var m=e.oneOf||e.anyOf;return e["enum"]&&e.oneOf&&(e["enum"]=e["enum"].filter((function(e){return utils.validate(e,m)}))),{thunk:function(t){var r=utils.omitProps(e,["anyOf","oneOf"]),n=random.pick(m);return utils.merge(r,n),m.forEach((function(e){e.required&&e!==n&&e.required.forEach((function(e){var n=r.required&&r.required.includes(e);r.properties&&!n&&delete r.properties[e],t&&t.properties&&delete t.properties[e]}))})),r}}}if(Object.keys(e).forEach((function(t){!Array.isArray(e[t])&&"object"!=typeof e[t]||utils.isKey(t)||(e[t]=s.resolveSchema(e[t],t,f.concat(t)))})),f){var y=f[f.length-1];if("properties"===y||"items"===y)return e}return i.wrap(e)},s};function pick$1(e){return Array.isArray(e)?random.pick(e):e}function cycle(e,t){if(!Array.isArray(e))return e;var r=t?e.pop():e.shift();return t?e.unshift(r):e.push(r),r}function resolve(e,t,r,n){if(!e||"object"!=typeof e)return e;if(r||(r={}),t||(t=e),Array.isArray(e))return e.map((function(e){return resolve(e,t,r,n)}));if(e.jsonPath){var i="object"!=typeof e.jsonPath?{path:e.jsonPath}:e.jsonPath;i.group=e.group||i.group||n,i.cycle=e.cycle||i.cycle||!1,i.reverse=e.reverse||i.reverse||!1,i.count=e.count||i.count||1;var a=i.group+"__"+i.path;return r[a]||(i.count>1?r[a]=JSONPath(i.path,t).slice(0,i.count):r[a]=JSONPath(i.path,t)),i.cycle||i.reverse?cycle(r[a],i.reverse):pick$1(r[a])}return Object.keys(e).forEach((function(n){e[n]=resolve(e[n],t,r,n)})),e}function run(e,t,r){if("[object Object]"!=={}.toString.call(t))throw new Error("Invalid input, expecting object but given "+typeof t);var n=optionAPI("refDepthMin")||0,i=optionAPI("refDepthMax")||3;try{var a=buildResolveSchema({refs:e,schema:t,container:r,refDepthMin:n,refDepthMax:i}).resolveSchema,o=traverse(utils.clone(t),[],a);return optionAPI("resolveJsonPath")?resolve(o):o}catch(s){throw s.path?new Error(s.message+" in /"+s.path.join("/")):s}}var container=new Container;function setupKeywords(){container.define("autoIncrement",(function(e,t){if(!this.offset){var r=t.minimum||1,n=r+env.MAX_NUMBER,i=e.initialOffset||t.initialOffset;this.offset=i||random.number(r,n)}return!0===e?this.offset++:t})),container.define("sequentialDate",(function(e,t){if(this.now||(this.now=random.date()),e){if(t=this.now.toISOString(),-1===["seconds","minutes","hours","days","weeks","months","years"].indexOf(e=!0===e?"days":e))throw new Error("Unsupported increment by "+utils.short(e));this.now.setTime(this.now.getTime()+random.date(e))}return t}))}function getRefs(e,t){var r={};function n(e){if(e&&"object"==typeof e){if(Array.isArray(e))return e.forEach(n);var t=e.$id||e.id;"string"!=typeof t||r[t]||(r[t]=e),Object.keys(e).forEach((function(t){n(e[t])}))}}return Array.isArray(e)?e.forEach((function(e){r[e.$id||e.id]=e})):r=e||{},n(e),n(t),r}var jsf=function(e,t,r){return jsf.generate(e,t)};jsf.generate=function(e,t){return run(getRefs(t,e),e,container)},jsf.resolve=function(e,t,r){"string"==typeof t&&(r=t,t={}),r=(r=r||("undefined"!=typeof process?process.cwd():"")).replace(/\/+$/,"")+"/";var n=getRefs(t,e),i={order:1,canRead:function(e){var t=e.url.replace("/:",":");return n[t]||n[t.split("/").pop()]},read:function(e,t){try{t(null,this.canRead(e))}catch(r){t(r)}}};return $RefParser.dereference(r,e,{resolve:{file:{order:100},http:{order:200},fixedRefs:i},dereference:{circular:"ignore"}}).then((function(e){return run(n,e,container)}))["catch"]((function(e){throw new Error("Error while resolving schema ("+e.message+")")}))},setupKeywords(),jsf.format=formatAPI,jsf.option=optionAPI,jsf.random=random,jsf.extend=function(e,t){return container.extend(e,t),jsf},jsf.define=function(e,t){return container.define(e,t),jsf},jsf.reset=function(e){return container.reset(e),setupKeywords(),jsf},jsf.locate=function(e){return container.get(e)},"undefined"!=typeof VERSION&&(jsf.version=VERSION);export default jsf; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("json-schema-ref-parser"),require("jsonpath-plus")):"function"==typeof define&&define.amd?define(["json-schema-ref-parser","jsonpath-plus"],t):(e=e||self).JSONSchemaFaker=t(e.$RefParser,e.jsonpathPlus)}(this,(function(e,t){e=e&&{}.hasOwnProperty.call(e,"default")?e["default"]:e;var r=function(){this.data={}};r.prototype.unregister=function(e){e?delete this.data[e]:this.data={}},r.prototype.register=function(e,t){this.data[e]=t},r.prototype.registerMany=function(e){var t=this;Object.keys(e).forEach((function(r){t.data[r]=e[r]}))},r.prototype.get=function(e){return this.data[e]},r.prototype.list=function(){return this.data};var n={defaultInvalidTypeProduct:null,defaultRandExpMax:10,ignoreProperties:[],ignoreMissingRefs:!1,failOnInvalidTypes:!0,failOnInvalidFormat:!0,alwaysFakeOptionals:!1,optionalsProbability:!1,fixedProbabilities:!1,useExamplesValue:!1,useDefaultValue:!1,requiredOnly:!1,minItems:0,maxItems:null,minLength:0,maxLength:null,resolveJsonPath:!1,reuseProperties:!1,fillProperties:!0,replaceEmptyByRandomValue:!1};n.random=Math.random;var i=new(function(e){function t(){e.call(this),this.data=Object.assign({},n),this._defaults=n}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaults:{configurable:!0}};return r.defaults.get=function(){return Object.assign({},this._defaults)},Object.defineProperties(t.prototype,r),t}(r));function a(e,t){return"string"==typeof e?void 0!==t?i.register(e,t):i.get(e):i.registerMany(e)}a.getDefaults=function(){return i.defaults};var o=["integer","number","string","boolean","null"],s={SCALAR_TYPES:o,ALL_TYPES:["array","object"].concat(o),MIN_NUMBER:-100,MAX_NUMBER:100,MIN_INTEGER:-1e8,MAX_INTEGER:1e8,MOST_NEAR_DATETIME:2524608e6};var u={ROOT:0,GROUP:1,POSITION:2,SET:3,RANGE:4,REPETITION:5,REFERENCE:6,CHAR:7};const f=()=>[{type:u.RANGE,from:48,to:57}],c=()=>[{type:u.CHAR,value:95},{type:u.RANGE,from:97,to:122},{type:u.RANGE,from:65,to:90}].concat(f()),l=()=>[{type:u.CHAR,value:9},{type:u.CHAR,value:10},{type:u.CHAR,value:11},{type:u.CHAR,value:12},{type:u.CHAR,value:13},{type:u.CHAR,value:32},{type:u.CHAR,value:160},{type:u.CHAR,value:5760},{type:u.RANGE,from:8192,to:8202},{type:u.CHAR,value:8232},{type:u.CHAR,value:8233},{type:u.CHAR,value:8239},{type:u.CHAR,value:8287},{type:u.CHAR,value:12288},{type:u.CHAR,value:65279}],h=()=>[{type:u.CHAR,value:10},{type:u.CHAR,value:13},{type:u.CHAR,value:8232},{type:u.CHAR,value:8233}];var p=()=>({type:u.SET,set:c(),not:!1}),m=()=>({type:u.SET,set:c(),not:!0}),d=()=>({type:u.SET,set:f(),not:!1}),g=()=>({type:u.SET,set:f(),not:!0}),y=()=>({type:u.SET,set:l(),not:!1}),v=()=>({type:u.SET,set:l(),not:!0}),x=()=>({type:u.SET,set:h(),not:!0}),b=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){const r={0:0,t:9,n:10,v:11,f:12,r:13};t.strToChars=function(e){return e=e.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(function(e,t,n,i,a,o,s,u){if(n)return e;var f=t?8:i?parseInt(i,16):a?parseInt(a,16):o?parseInt(o,8):s?"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s):r[u],c=String.fromCharCode(f);return/[[\]{}^$.|?*+()]/.test(c)&&(c="\\"+c),c}))},t.tokenizeClass=(e,r)=>{for(var n,i,a=[],o=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g;null!=(n=o.exec(e));)if(n[1])a.push(p());else if(n[2])a.push(d());else if(n[3])a.push(y());else if(n[4])a.push(m());else if(n[5])a.push(g());else if(n[6])a.push(v());else if(n[7])a.push({type:u.RANGE,from:(n[8]||n[9]).charCodeAt(0),to:n[10].charCodeAt(0)});else{if(!(i=n[12]))return[a,o.lastIndex];a.push({type:u.CHAR,value:i.charCodeAt(0)})}t.error(r,"Unterminated character class")},t.error=(e,t)=>{throw new SyntaxError("Invalid regular expression: /"+e+"/: "+t)}})),O=(b.strToChars,b.tokenizeClass,b.error,()=>({type:u.POSITION,value:"b"})),E=()=>({type:u.POSITION,value:"B"}),w=()=>({type:u.POSITION,value:"^"}),A=()=>({type:u.POSITION,value:"$"}),I=e=>{var t,r,n=0,i={type:u.ROOT,stack:[]},a=i,o=i.stack,s=[],f=t=>{b.error(e,`Nothing to repeat at column ${t-1}`)},c=b.strToChars(e);for(t=c.length;n<t;)switch(r=c[n++]){case"\\":switch(r=c[n++]){case"b":o.push(O());break;case"B":o.push(E());break;case"w":o.push(p());break;case"W":o.push(m());break;case"d":o.push(d());break;case"D":o.push(g());break;case"s":o.push(y());break;case"S":o.push(v());break;default:/\d/.test(r)?o.push({type:u.REFERENCE,value:parseInt(r,10)}):o.push({type:u.CHAR,value:r.charCodeAt(0)})}break;case"^":o.push(w());break;case"$":o.push(A());break;case"[":var l;"^"===c[n]?(l=!0,n++):l=!1;var h=b.tokenizeClass(c.slice(n),e);n+=h[1],o.push({type:u.SET,set:h[0],not:l});break;case".":o.push(x());break;case"(":var I={type:u.GROUP,stack:[],remember:!0};"?"===(r=c[n])&&(r=c[n+1],n+=2,"="===r?I.followedBy=!0:"!"===r?I.notFollowedBy=!0:":"!==r&&b.error(e,`Invalid group, character '${r}'`+` after '?' at column ${n-1}`),I.remember=!1),o.push(I),s.push(a),a=I,o=I.stack;break;case")":0===s.length&&b.error(e,`Unmatched ) at column ${n-1}`),o=(a=s.pop()).options?a.options[a.options.length-1]:a.stack;break;case"|":a.options||(a.options=[a.stack],delete a.stack);var k=[];a.options.push(k),o=k;break;case"{":var R,M,P=/^(\d+)(,(\d+)?)?\}/.exec(c.slice(n));null!==P?(0===o.length&&f(n),R=parseInt(P[1],10),M=P[2]?P[3]?parseInt(P[3],10):Infinity:R,n+=P[0].length,o.push({type:u.REPETITION,min:R,max:M,value:o.pop()})):o.push({type:u.CHAR,value:123});break;case"?":0===o.length&&f(n),o.push({type:u.REPETITION,min:0,max:1,value:o.pop()});break;case"+":0===o.length&&f(n),o.push({type:u.REPETITION,min:1,max:Infinity,value:o.pop()});break;case"*":0===o.length&&f(n),o.push({type:u.REPETITION,min:0,max:Infinity,value:o.pop()});break;default:o.push({type:u.CHAR,value:r.charCodeAt(0)})}return 0!==s.length&&b.error(e,"Unterminated group"),i};class k{constructor(e,t){this.low=e,this.high=t,this.length=1+t-e}overlaps(e){return!(this.high<e.low||this.low>e.high)}touches(e){return!(this.high+1<e.low||this.low-1>e.high)}add(e){return new k(Math.min(this.low,e.low),Math.max(this.high,e.high))}subtract(e){return e.low<=this.low&&e.high>=this.high?[]:e.low>this.low&&e.high<this.high?[new k(this.low,e.low-1),new k(e.high+1,this.high)]:e.low<=this.low?[new k(e.high+1,this.high)]:[new k(this.low,e.low-1)]}toString(){return this.low==this.high?this.low.toString():this.low+"-"+this.high}}class R{constructor(e,t){this.ranges=[],this.length=0,null!=e&&this.add(e,t)}_update_length(){this.length=this.ranges.reduce((e,t)=>e+t.length,0)}add(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.touches(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.touches(this.ranges[t]);)e=e.add(this.ranges[t]),t++;r.push(e),this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof R?e.ranges.forEach(r):(null==t&&(t=e),r(new k(e,t))),this}subtract(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.overlaps(this.ranges[t]);)r=r.concat(this.ranges[t].subtract(e)),t++;this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof R?e.ranges.forEach(r):(null==t&&(t=e),r(new k(e,t))),this}intersect(e,t){var r=[],n=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(;t<this.ranges.length&&e.overlaps(this.ranges[t]);){var n=Math.max(this.ranges[t].low,e.low),i=Math.min(this.ranges[t].high,e.high);r.push(new k(n,i)),t++}};return e instanceof R?e.ranges.forEach(n):(null==t&&(t=e),n(new k(e,t))),this.ranges=r,this._update_length(),this}index(e){for(var t=0;t<this.ranges.length&&this.ranges[t].length<=e;)e-=this.ranges[t].length,t++;return this.ranges[t].low+e}toString(){return"[ "+this.ranges.join(", ")+" ]"}clone(){return new R(this)}numbers(){return this.ranges.reduce((e,t)=>{for(var r=t.low;r<=t.high;)e.push(r),r++;return e},[])}subranges(){return this.ranges.map(e=>({low:e.low,high:e.high,length:1+e.high-e.low}))}}var M=R;const P=I.types=u;var S=class e{constructor(e,t){if(this._setDefaults(e),e instanceof RegExp)this.ignoreCase=e.ignoreCase,this.multiline=e.multiline,e=e.source;else{if("string"!=typeof e)throw new Error("Expected a regexp or string");this.ignoreCase=t&&-1!==t.indexOf("i"),this.multiline=t&&-1!==t.indexOf("m")}this.tokens=I(e)}_setDefaults(t){this.max=null!=t.max?t.max:null!=e.prototype.max?e.prototype.max:100,this.defaultRange=t.defaultRange?t.defaultRange:this.defaultRange.clone(),t.randInt&&(this.randInt=t.randInt)}gen(){return this._gen(this.tokens,[])}_gen(e,t){var r,n,i,a,o;switch(e.type){case P.ROOT:case P.GROUP:if(e.followedBy||e.notFollowedBy)return"";for(e.remember&&e.groupNumber===undefined&&(e.groupNumber=t.push(null)-1),n="",a=0,o=(r=e.options?this._randSelect(e.options):e.stack).length;a<o;a++)n+=this._gen(r[a],t);return e.remember&&(t[e.groupNumber]=n),n;case P.POSITION:return"";case P.SET:var s=this._expand(e);return s.length?String.fromCharCode(this._randSelect(s)):"";case P.REPETITION:for(i=this.randInt(e.min,e.max===Infinity?e.min+this.max:e.max),n="",a=0;a<i;a++)n+=this._gen(e.value,t);return n;case P.REFERENCE:return t[e.value-1]||"";case P.CHAR:var u=this.ignoreCase&&this._randBool()?this._toOtherCase(e.value):e.value;return String.fromCharCode(u)}}_toOtherCase(e){return e+(97<=e&&e<=122?-32:65<=e&&e<=90?32:0)}_randBool(){return!this.randInt(0,1)}_randSelect(e){return e instanceof M?e.index(this.randInt(0,e.length-1)):e[this.randInt(0,e.length-1)]}_expand(e){if(e.type===I.types.CHAR)return new M(e.value);if(e.type===I.types.RANGE)return new M(e.from,e.to);{let t=new M;for(let r=0;r<e.set.length;r++){let n=this._expand(e.set[r]);if(t.add(n),this.ignoreCase)for(let e=0;e<n.length;e++){let r=n.index(e),i=this._toOtherCase(r);r!==i&&t.add(i)}}return e.not?this.defaultRange.clone().subtract(t):this.defaultRange.clone().intersect(t)}}randInt(e,t){return e+Math.floor(Math.random()*(1+t-e))}get defaultRange(){return this._range=this._range||new M(32,126)}set defaultRange(e){this._range=e}static randexp(t,r){var n;return"string"==typeof t&&(t=new RegExp(t,r)),t._randexp===undefined?(n=new e(t,r),t._randexp=n):(n=t._randexp)._setDefaults(t),n.gen()}static sugar(){RegExp.prototype.gen=function(){return e.randexp(this)}}};function _(e,t,r,n,i){return void 0===i&&(i=!1),r=void 0===r?s.MIN_NUMBER:r,n=void 0===n?s.MAX_NUMBER:n,(t=void 0===t?n:t)<(e=void 0===e?r:e)&&(t+=e),i?function(e,t){return a("random")()*(t-e)+e}(e,t):function(e,t){return e=void 0===e?s.MIN_INTEGER:e,t=void 0===t?s.MAX_INTEGER:t,Math.floor(a("random")()*(t-e+1))+e}(e,t)}var j={pick:function(e){return e[Math.floor(a("random")()*e.length)]},date:function(e){if(e)return function(e){switch(e){case"seconds":return 60*_(0,60);case"minutes":return 612*_(15,50);case"hours":return 36123*_(12,72);case"days":return 86412345*_(7,30);case"weeks":return 604812345*_(4,52);case"months":return 2592012345*_(2,13);case"years":return 31104012345*_(1,20)}}(e);var t=new Date,r=_(-1e3,s.MOST_NEAR_DATETIME);return t.setTime(t.getTime()-r),t},shuffle:function(e){for(var t,r,n=e.length,i=e.slice();n>0;)r=Math.floor(a("random")()*n),t=i[n-=1],i[n]=i[r],i[r]=t;return i},number:_,randexp:function(e){return S.prototype.max=a("defaultRandExpMax"),S.prototype.randInt=function(e,t){return e+Math.floor(a("random")()*(t-e+1))},new S(e).gen()}};function T(e,t){return Object.keys(t).forEach((function(r){"object"!=typeof t[r]||null===t[r]?e[r]=t[r]:Array.isArray(t[r])?(e[r]=e[r]||[],t[r].forEach((function(t){Array.isArray(e[r])&&-1===e[r].indexOf(t)&&e[r].push(t)}))):"object"!=typeof e[r]||null===e[r]||Array.isArray(e[r])?e[r]=T({},t[r]):e[r]=T(e[r],t[r])})),e}function C(){return j.pick([!1,!0,null,-1,NaN,Math.PI,Infinity,undefined,[],{},Math.random(),Math.random().toString(36).substr(2)])}function N(e,t){var r=t.minimum!==undefined,n=t.maximum!==undefined;return(r||n)&&(!r||e>=t.minimum)&&(!n||e<=t.maximum)}function L(e){return"[object Object]"==={}.toString.call(e)&&!Object.keys(e).length}function $(e,t){var r=Array.isArray(t.required)&&t.required.includes(e),n="function"==typeof t.thunk||t.additionalProperties&&"function"==typeof t.additionalProperties.thunk;return!r&&!n}var H={getSubAttribute:function(e,t){for(var r=t.split(".");r.length;){var n=r.shift();if(!e[n])break;e=e[n]}return e},hasProperties:function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return t.filter((function(t){return"undefined"!=typeof e[t]})).length>0},omitProps:function(e,t){return Object.keys(e).filter((function(e){return!t.includes(e)})).reduce((function(t,r){return Array.isArray(e[r])?t[r]=e[r].slice():t[r]=e[r]instanceof Object?T({},e[r]):e[r],t}),{})},typecast:function(e,t,r){var n={};switch(e||t.type){case"integer":case"number":if("undefined"!=typeof t.minimum&&(n.minimum=t.minimum),"undefined"!=typeof t.maximum&&(n.maximum=t.maximum),t["enum"]){var i=Math.max(n.minimum||0,0),o=Math.min(n.maximum||Infinity,Infinity);t.exclusiveMinimum&&i===t.minimum&&(i+=t.multipleOf||1),t.exclusiveMaximum&&o===t.maximum&&(o-=t.multipleOf||1),(i||o!==Infinity)&&(t["enum"]=t["enum"].filter((function(e){return e>=i&&e<=o})))}break;case"string":n.minLength=a("minLength")||0,n.maxLength=a("maxLength")||Number.MAX_SAFE_INTEGER,"undefined"!=typeof t.minLength&&(n.minLength=Math.max(n.minLength,t.minLength)),"undefined"!=typeof t.maxLength&&(n.maxLength=Math.min(n.maxLength,t.maxLength))}var s=r(n);if(null===s||s===undefined)return null;switch(e||t.type){case"number":s=parseFloat(s);break;case"integer":s=parseInt(s,10);break;case"boolean":s=!!s;break;case"string":s=String(s);for(var u,f=Math.max(n.minLength||0,0),c=Math.min(n.maxLength||Infinity,Infinity);s.length<f&&(u=s,t.pattern?s+=j.randexp(t.pattern):s+=""+j.pick([" ","/","_","-","+","=","@","^"])+s,s!==u););switch(s.length>c&&(s=s.substr(0,c)),t.format){case"date-time":case"datetime":s=new Date(s).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"date":s=new Date(s).toISOString().substr(0,10);break;case"time":s=new Date("1969-01-01 "+s).toISOString().substr(11)}}return s},merge:T,clone:function me(e,t){if(void 0===t&&(t=new Map),!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){var r=[];return t.set(e,r),r.push.apply(r,e.map((function(e){return me(e,t)}))),r}var n={};return t.set(e,n),Object.keys(e).reduce((function(r,n){return r[n]=me(e[n],t),r}),n)},short:function(e){var t=JSON.stringify(e),r=JSON.stringify(e,null,2);return t.length>400?r.substr(0,400)+"...":r},notValue:function(e,t){var r=T({},t);if("undefined"!=typeof e.minimum&&(r.maximum=e.minimum,r.exclusiveMaximum=!0),"undefined"!=typeof e.maximum&&(r.minimum=e.maximum>r.maximum?0:e.maximum,r.exclusiveMinimum=!0),"undefined"!=typeof e.minLength&&(r.maxLength=e.minLength),"undefined"!=typeof e.maxLength&&(r.minLength=e.maxLength>r.maxLength?0:e.maxLength),e.type)r.type=j.pick(s.SCALAR_TYPES.filter((function(t){return(Array.isArray(e.type)?e.type:[e.type]).every((function(e){return"number"===t||"integer"===t?"number"!==e&&"integer"!==e:t!==e}))})));else if(e["enum"]){var n;do{n=C()}while(-1!==e["enum"].indexOf(n));r["enum"]=[n]}return e.required&&r.properties&&e.required.forEach((function(e){delete r.properties[e]})),r},anyValue:C,validate:function(e,t){return!t.every((function(t){return N(e,t)}))},validateValueForSchema:N,validateValueForOneOf:function(e,t){return 1===t.reduce((function(t,r){return t+(N(e,r)?1:0)}),0)},isKey:function(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)},template:function de(e,t){return Array.isArray(e)?e.map((function(e){return de(e,t)})):("string"==typeof e&&(e=e.replace(/#\{([\w.-]+)\}/g,(function(e,r){return t[r]}))),e)},shouldClean:$,clean:function ge(e,t,r){return void 0===r&&(r=!1),e&&"object"==typeof e?Array.isArray(e)?e.map((function(e){return ge(e,t,!0)})).filter((function(e){return void 0!==e})):(Object.keys(e).forEach((function(r){if(L(e[r]))$(r,t)&&delete e[r];else{var n=ge(e[r],t);L(n)||(e[r]=n)}"undefined"==typeof e[r]&&delete e[r]})),!Object.keys(e).length&&r?undefined:e):e},isEmpty:L};var q=function(){this.registry={},this.support={}};q.prototype.reset=function(e){e?(delete this.registry[e],delete this.support[e]):(this.registry={},this.support={})},q.prototype.extend=function(e,t){var r,n=this;this.registry[e]=t(this.registry[e]),this.support[e]||(this.support[e]=(r=function(){return n.registry[e]},function(e,t,n,i){var a=e,o=[];"object"==typeof e&&(a=Object.keys(e)[0],Array.isArray(e[a])?o=e[a]:o.push(e[a]));for(var s=a.split("."),u=r();s.length>1;)u=u[s.shift()];return"function"==typeof(e="object"==typeof u?u[s[0]]:u)&&(e=e.apply(u,o.map((function(e){return H.template(e,i)})))),"[object Object]"==={}.toString.call(e)&&Object.keys(e).forEach((function(t){if("function"==typeof e[t])throw new Error("Cannot resolve value for '"+n+": "+a+"', given: "+e)})),e}))},q.prototype.define=function(e,t){this.support[e]=t},q.prototype.get=function(e){if("undefined"==typeof this.registry[e])throw new ReferenceError("'"+e+"' dependency doesn't exist.");return this.registry[e]},q.prototype.wrap=function(e){for(var t=this,r=Object.keys(e),n={},i=r.length,a=function(){var a=r[i].replace(/^x-/,""),o=t.support[a];if("function"==typeof o)return Object.defineProperty(e,"generate",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return o.call(n,e[r[i]],e,r[i],t)}}),"break"};i--;){if("break"===a())break}return e};var D=new r;function F(e,t){if(void 0===e)return D.list();if("string"==typeof e)if("function"==typeof t)D.register(e,t);else{if(null!==t&&!1!==t)return D.get(e);D.unregister(e)}else D.registerMany(e)}var G=function(e){function t(t,r){e.call(this),e.captureStackTrace&&e.captureStackTrace(this,this.constructor),this.name="ParseError",this.message=t,this.path=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Error),z={array:["additionalItems","items","maxItems","minItems","uniqueItems"],integer:["exclusiveMaximum","exclusiveMinimum","maximum","minimum","multipleOf"],object:["additionalProperties","dependencies","maxProperties","minProperties","patternProperties","properties","required"],string:["maxLength","minLength","pattern","format"]};z.number=z.integer;var B=["additionalItems","items","additionalProperties","dependencies","patternProperties","properties"];function U(e,t,r){return Object.keys(e).filter((function(e){var n=B.indexOf(t)>-1;return!(!(r.indexOf(e)>-1)||n)})).length>0}var Z=function(){return a("random")()>.5};var V=function(){return null};function J(e){var t="undefined"==typeof e.minimum?s.MIN_INTEGER:e.minimum,r="undefined"==typeof e.maximum?s.MAX_INTEGER:e.maximum,n=e.multipleOf;if(n&&(r=Math.floor(r/n)*n,t=Math.ceil(t/n)*n),e.exclusiveMinimum&&t===e.minimum&&(t+=n||1),e.exclusiveMaximum&&r===e.maximum&&(r-=n||1),t>r)return NaN;if(n){if(-1===String(n).indexOf(".")){for(var i=j.number(Math.floor(t/n),Math.floor(r/n))*n;i<t;)i+=e.multipleOf;return i}var a,o,u=(r-t)/n;do{o=(a=j.number(0,u)*n)/n%1}while(0!==o);return t+a}return j.number(t,r,undefined,undefined,!0)}var X="Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore\net dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\ncommodo consequat Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\npariatur Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est\nlaborum".split(/\W/);function W(e){return j.shuffle(X).slice(0,e)}var Y={type:["string","number","integer","boolean"]};function K(){return W(j.number(1,5)).join(" ")}function Q(e,t){void 0===e&&(e=0),void 0===t&&(t=140);for(var r=Math.max(0,e),n=j.number(r,t),i=K();i.length<r;)i+=K();return i.length>n&&(i=i.substr(0,n)),i}function ee(){return j.date().toISOString()}var te="https?://{hostname}(?:[a-zA-Z][a-zA-Z0-9+-.]*)+",re={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:te,slug:"[a-zA-Z\\d_-]+","uri-reference":te+"(?:\\?([a-z]{1,7}(=\\w{1,5})?&){0,3})?","uri-template":te.replace("(?:","(?:/\\{[a-z][:a-zA-Z0-9-]*\\}|"),"json-pointer":"(/(?:"+"[a-zA-Z][a-zA-Z0-9+-.]*".replace("]*","/]*")+"|~[01]))+",uuid:"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"};re.iri=re["uri-reference"],re["iri-reference"]=re["uri-reference"],re["idn-email"]=re.email,re["idn-hostname"]=re.hostname;var ne=new RegExp("\\{("+Object.keys(re).join("|")+")\\}");function ie(e,t){var r,n=F(e.format);if("function"==typeof n)return n(e);switch(e.format){case"date-time":case"datetime":return ee();case"date":return ee().slice(0,10);case"time":return ee().slice(11);case"ipv4":return[0,0,0,0].map((function(){return j.number(0,255)})).join(".");case"regex":return".+?";case"email":case"hostname":case"ipv6":case"uri":case"uri-reference":case"iri":case"iri-reference":case"idn-email":case"idn-hostname":case"json-pointer":case"slug":case"uri-template":case"uuid":return r=e.format,j.randexp(re[r]).replace(ne,(function(e,t){return j.randexp(re[t])}));default:if(void 0===n){if(a("failOnInvalidFormat"))throw new Error("unknown registry key "+H.short(e.format));return t()}throw new Error("unsupported format '"+e.format+"'")}}var ae={boolean:Z,"null":V,array:function(e,t,r,n){var i=[];if(!e.items&&!e.additionalItems){if(H.hasProperties(e,"minItems","maxItems","uniqueItems"))throw new G("missing items for "+H.short(e),t);return i}if(Array.isArray(e.items))return e.items.map((function(e,i){var a=t.concat(["items",i]);return n(e,a,r)}));var o=e.minItems,s=e.maxItems;a("minItems")&&(o=s?Math.min(a("minItems"),s):a("minItems")),a("maxItems")&&((s=o?Math.min(a("maxItems"),o):a("maxItems"))&&s>a("maxItems")&&(s=a("maxItems")),o&&o>a("maxItems")&&(o=s));var u=!0===a("alwaysFakeOptionals")?1:a("optionalsProbability"),f=a("alwaysFakeOptionals")||a("fixedProbabilities")||!1,c=j.number(o,s,1,5);!1!==u&&(c=Math.max(f?Math.round((s||c)*u):Math.abs(j.number(o,s)*u),o||0));for(var l="object"==typeof e.additionalItems?e.additionalItems:{},h=i.length;h<c;h+=1){var p=t.concat(["items",h]),m=n(e.items||l,p,r);i.push(m)}return e.uniqueItems?function(e,t,r,n,i,a){var o=[],s=[];function u(e){var t=JSON.stringify(e);return-1===s.indexOf(t)&&(s.push(t),o.push(e),!0)}t.forEach(u);for(var f=100;o.length!==t.length&&(u(a(r.items||n,e,i))||(f-=1),f););return o}(t.concat(["items"]),i,e,l,r,n):i},integer:function(e){return J(Object.assign({multipleOf:1},e))},number:J,object:function(e,t,r,n){var i={},o=e.properties||{},s=e.patternProperties||{},u="boolean"==typeof e.required?[]:(e.required||[]).slice(),f=!1!==e.additionalProperties,c=Object.keys(o),l=Object.keys(s),h=c.concat(l).reduce((function(e,t){return-1===u.indexOf(t)&&e.push(t),e}),[]),p=u.concat(h),m=f&&!0===e.additionalProperties?Y:e.additionalProperties;if(!f&&0===c.length&&0===l.length&&H.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(!0===a("requiredOnly"))return u.forEach((function(e){o[e]&&(i[e]=o[e])})),n(i,t.concat(["properties"]),r,e);var d=!0===a("alwaysFakeOptionals")?1:a("optionalsProbability"),g=a("alwaysFakeOptionals")||a("fixedProbabilities")||!1,y=a("ignoreProperties")||[],v=Math.max(e.minProperties||0,u.length),x=e.maxProperties||p.length+(f?j.number(1,5):0),b=Math.max(0,p.length-v);1!==p.length||u.length||(b=j.number(b,p.length+(p.length-v))),!1!==d&&(b=!0===g?Math.round(v-u.length+d*(p.length-v)):j.number(v-u.length,d*(p.length-v)));var O=j.shuffle(h).slice(0,b),E=h.filter((function(e){return-1!==O.indexOf(e)})),w=!1!==d?x:j.number(0,x),A=u.concat(E.slice(0,w)),I=[];if(e.dependencies&&(Object.keys(e.dependencies).forEach((function(t){var r=e.dependencies[t];-1!==A.indexOf(t)&&(Array.isArray(r)?r.forEach((function(e){-1===A.indexOf(e)&&A.push(e)})):I.push(r))})),I.length))return delete e.dependencies,n({allOf:I.concat(e)},t.concat(["properties"]),r,e);var k=[];A.forEach((function(e){for(var t=0;t<y.length;t+=1)if(y[t]instanceof RegExp&&y[t].test(e)||"string"==typeof y[t]&&y[t]===e||"function"==typeof y[t]&&y[t](o[e],e))return void k.push(e);var r;if(!1===m&&-1!==u.indexOf(e)&&(i[e]=o[e]),o[e]&&(i[e]=o[e]),l.forEach((function(t){e.match(new RegExp(t))&&(r=!0,i[e]?H.merge(i[e],s[t]):i[j.randexp(e)]=s[t])})),!r){var n=s[e]||m;n&&!1!==m&&(i[s[e]?j.randexp(e):e]=o[e]||n)}}));var R,M=a("fillProperties"),P=a("reuseProperties"),S=Object.keys(i).length+(M?0:k.length);function _(e){var t;do{if(!e.length)break;t=e.shift()}while(i[t]);return t}for(;M&&(l.length||f)&&!(S>=v);){if(f)if(P&&c.length-S>v){var T=0,C=void 0;do{if((T+=1)>1e3)break;C=_(u)||j.pick(c)}while("undefined"!=typeof i[C]);"undefined"==typeof i[C]&&(i[C]=o[C],S+=1)}else if(l.length&&!m){var N=j.pick(l),L=j.randexp(N);i[L]||(i[L]=s[N],S+=1)}else{var $=_(u)||W(1)+(R=void 0,j.randexp("_?[_a-f\\d]{1,3}"+(R?"\\$?":"")));i[$]||(i[$]=m||Y,S+=1)}for(var q=0;S<v&&q<l.length;q+=1){var D=l[q],F=j.randexp(D);i[F]||(i[F]=s[D],S+=1)}}if(0===u.length&&(!f||!1===d))for(var G=j.number(v,x);S<G;){var z=_(c);z&&(i[z]=o[z]),S+=1}return n(i,t.concat(["properties"]),r,e)},string:function(e){return H.typecast("string",e,(function(t){return e.format?ie(e,(function(){return Q(t.minLength,t.maxLength)})):e.pattern?j.randexp(e.pattern):Q(t.minLength,t.maxLength)}))}};function oe(e,t,r,n){if(e=r(e,null,t)){if("properties"!==t[t.length-1]){if(a("useExamplesValue")&&Array.isArray(e.examples)){var i=e.examples.concat("default"in e?[e["default"]]:[]);return H.typecast(null,e,(function(){return j.pick(i)}))}if(a("useDefaultValue")&&"default"in e&&(""!==e["default"]||!a("replaceEmptyByRandomValue")))return e["default"];if("template"in e)return H.template(e.template,n);if("const"in e)return e["const"]}if(e.not&&"object"==typeof e.not&&(e=H.notValue(e.not,H.omitProps(e,["not"]))).type&&"object"===e.type){var o=oe(e,t.concat(["not"]),r,n);return H.clean(o,e,!1)}if("function"==typeof e.thunk)return oe(e.thunk(n),t,r);if("function"==typeof e.generate)return H.typecast(null,e,(function(){return e.generate(n)}));if("string"==typeof e.pattern)return H.typecast("string",e,(function(){return j.randexp(e.pattern)}));if(Array.isArray(e["enum"]))return H.typecast(null,e,(function(){return j.pick(e["enum"])}));if(e.jsonPath)return e;var s=e.type;if(Array.isArray(s)?s=j.pick(s):void 0===s&&(s=function(e,t){for(var r=Object.keys(z),n=0;n<r.length;n+=1){var i=r[n];if(U(e,t[t.length-1],z[i]))return i}}(e,t)||s)&&(e.type=s),"string"==typeof s){if(!ae[s]){if(a("failOnInvalidTypes"))throw new G("unknown primitive "+H.short(s),t.concat(["type"]));return a("defaultInvalidTypeProduct")}try{return ae[s](e,t,r,oe)}catch(f){if("undefined"==typeof f.path)throw new G(f.stack,t);throw f}}var u={};return Array.isArray(e)&&(u=[]),Object.keys(e).forEach((function(n){if("object"==typeof e[n]&&"definitions"!==n){var i=oe(e[n],t.concat([n]),r,u);u[n]=H.clean(i,e[n],!1)}else u[n]=e[n]})),u}}var se=function(e){var t,r=e.refs,n=e.schema,i=e.container,o=e.refDepthMax,s=e.refDepthMin,u=0,f={resolveSchema:function(e,c,l){if(null===e||e===undefined)return null;if("function"==typeof e.generate)return e;if("string"==typeof(e.$id||e.id)&&(delete e.id,delete e.$id,delete e.$schema),"string"==typeof e.$ref){var h,p=Math.max(s,o)-1;if("#"===e.$ref||t===e.$ref&&++u>p)return delete e.$ref,e;if(t=e.$ref,-1===e.$ref.indexOf("#/")&&(h=r[e.$ref]||null),0===e.$ref.indexOf("#/definitions/")&&(h=n.definitions[e.$ref.split("#/definitions/")[1]]||null),void 0!==h){if(!h&&!0!==a("ignoreMissingRefs"))throw new Error("Reference not found: "+e.$ref);H.merge(e,h||{})}return delete e.$ref,e}if(Array.isArray(e.allOf)){var m=e.allOf;delete e.allOf,m.forEach((function(t){var r=f.resolveSchema(t,null,l);H.merge(e,"function"==typeof r.thunk?r.thunk(e):r),Array.isArray(e.allOf)&&f.resolveSchema(e,c,l)}))}if(Array.isArray(e.oneOf||e.anyOf)){var d=e.oneOf||e.anyOf;return e["enum"]&&e.oneOf&&(e["enum"]=e["enum"].filter((function(e){return H.validate(e,d)}))),{thunk:function(t){var r=H.omitProps(e,["anyOf","oneOf"]),n=j.pick(d);return H.merge(r,n),d.forEach((function(e){e.required&&e!==n&&e.required.forEach((function(e){var n=r.required&&r.required.includes(e);r.properties&&!n&&delete r.properties[e],t&&t.properties&&delete t.properties[e]}))})),r}}}if(Object.keys(e).forEach((function(t){!Array.isArray(e[t])&&"object"!=typeof e[t]||H.isKey(t)||(e[t]=f.resolveSchema(e[t],t,l.concat(t)))})),l){var g=l[l.length-1];if("properties"===g||"items"===g)return e}return i.wrap(e)}};return f};function ue(e,r,n,i){if(!e||"object"!=typeof e)return e;if(n||(n={}),r||(r=e),Array.isArray(e))return e.map((function(e){return ue(e,r,n,i)}));if(e.jsonPath){var a="object"!=typeof e.jsonPath?{path:e.jsonPath}:e.jsonPath;a.group=e.group||a.group||i,a.cycle=e.cycle||a.cycle||!1,a.reverse=e.reverse||a.reverse||!1,a.count=e.count||a.count||1;var o=a.group+"__"+a.path;return n[o]||(a.count>1?n[o]=t.JSONPath(a.path,r).slice(0,a.count):n[o]=t.JSONPath(a.path,r)),a.cycle||a.reverse?function(e,t){if(!Array.isArray(e))return e;var r=t?e.pop():e.shift();return t?e.unshift(r):e.push(r),r}(n[o],a.reverse):function(e){return Array.isArray(e)?j.pick(e):e}(n[o])}return Object.keys(e).forEach((function(t){e[t]=ue(e[t],r,n,t)})),e}function fe(e,t,r){var n=a("refDepthMin")||0,i=a("refDepthMax")||3;try{var o=se({refs:e,schema:t,container:r,refDepthMin:n,refDepthMax:i}).resolveSchema,s=oe(H.clone(t),[],o);return a("resolveJsonPath")?ue(s):s}catch(u){throw u.path?new Error(u.message+" in /"+u.path.join("/")):u}}var ce=new q;function le(){ce.define("autoIncrement",(function(e,t){if(!this.offset){var r=t.minimum||1,n=r+s.MAX_NUMBER,i=e.initialOffset||t.initialOffset;this.offset=i||j.number(r,n)}return!0===e?this.offset++:t})),ce.define("sequentialDate",(function(e,t){if(this.now||(this.now=j.date()),e){if(t=this.now.toISOString(),-1===["seconds","minutes","hours","days","weeks","months","years"].indexOf(e=!0===e?"days":e))throw new Error("Unsupported increment by "+H.short(e));this.now.setTime(this.now.getTime()+j.date(e))}return t}))}function he(e){var t={};return Array.isArray(e)?e.forEach((function(e){t[e.$id||e.id]=e})):t=e||{},t}var pe=function(e,t,r){return pe.generate(e,t)};pe.generate=function(e,t){return fe(he(t),e,ce)},pe.resolve=function(t,r,n){"string"==typeof r&&(n=r,r={}),n=(n=n||("undefined"!=typeof process?process.cwd():"")).replace(/\/+$/,"")+"/";var i=he(r),a={order:1,canRead:function(e){return i[e.url]||i[e.url.split("/").pop()]},read:function(e,t){try{t(null,i[e.url]||i[e.url.split("/").pop()])}catch(r){t(r)}}};return e.dereference(n,t,{resolve:{file:{order:100},http:{order:200},fixedRefs:a},dereference:{circular:"ignore"}}).then((function(e){return fe(i,e,ce)}))},le(),pe.format=F,pe.option=a,pe.random=j,pe.extend=function(e,t){return ce.extend(e,t),pe},pe.define=function(e,t){return ce.define(e,t),pe},pe.reset=function(e){return ce.reset(e),le(),pe},pe.locate=function(e){return ce.get(e)};return pe.version="0.5.0-rcv.29",pe})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("json-schema-ref-parser"),require("jsonpath-plus")):"function"==typeof define&&define.amd?define(["json-schema-ref-parser","jsonpath-plus"],t):(e=e||self).JSONSchemaFaker=t(e.$RefParser,e.jsonpathPlus)}(this,(function(e,t){e=e&&{}.hasOwnProperty.call(e,"default")?e["default"]:e;var r=function(){this.data={}};r.prototype.unregister=function(e){e?delete this.data[e]:this.data={}},r.prototype.register=function(e,t){this.data[e]=t},r.prototype.registerMany=function(e){var t=this;Object.keys(e).forEach((function(r){t.data[r]=e[r]}))},r.prototype.get=function(e){return this.data[e]},r.prototype.list=function(){return this.data};var n={};n.defaultInvalidTypeProduct=undefined,n.defaultRandExpMax=10,n.ignoreProperties=[],n.ignoreMissingRefs=!1,n.failOnInvalidTypes=!0,n.failOnInvalidFormat=!0,n.alwaysFakeOptionals=!1,n.optionalsProbability=null,n.fixedProbabilities=!1,n.useExamplesValue=!1,n.useDefaultValue=!1,n.requiredOnly=!1,n.minItems=0,n.maxItems=null,n.minLength=0,n.maxLength=null,n.resolveJsonPath=!1,n.reuseProperties=!1,n.fillProperties=!0,n.replaceEmptyByRandomValue=!1,n.random=Math.random;var i=new(function(e){function t(){e.call(this),this.data=Object.assign({},n),this._defaults=n}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var r={defaults:{configurable:!0}};return r.defaults.get=function(){return Object.assign({},this._defaults)},Object.defineProperties(t.prototype,r),t}(r));function a(e,t){return"string"==typeof e?void 0!==t?i.register(e,t):i.get(e):i.registerMany(e)}a.getDefaults=function(){return i.defaults};var o=["integer","number","string","boolean","null"],s={SCALAR_TYPES:o,ALL_TYPES:["array","object"].concat(o),MIN_NUMBER:-100,MAX_NUMBER:100,MIN_INTEGER:-1e8,MAX_INTEGER:1e8,MOST_NEAR_DATETIME:2524608e6};var u={ROOT:0,GROUP:1,POSITION:2,SET:3,RANGE:4,REPETITION:5,REFERENCE:6,CHAR:7};const f=()=>[{type:u.RANGE,from:48,to:57}],c=()=>[{type:u.CHAR,value:95},{type:u.RANGE,from:97,to:122},{type:u.RANGE,from:65,to:90}].concat(f()),l=()=>[{type:u.CHAR,value:9},{type:u.CHAR,value:10},{type:u.CHAR,value:11},{type:u.CHAR,value:12},{type:u.CHAR,value:13},{type:u.CHAR,value:32},{type:u.CHAR,value:160},{type:u.CHAR,value:5760},{type:u.RANGE,from:8192,to:8202},{type:u.CHAR,value:8232},{type:u.CHAR,value:8233},{type:u.CHAR,value:8239},{type:u.CHAR,value:8287},{type:u.CHAR,value:12288},{type:u.CHAR,value:65279}],h=()=>[{type:u.CHAR,value:10},{type:u.CHAR,value:13},{type:u.CHAR,value:8232},{type:u.CHAR,value:8233}];var p=()=>({type:u.SET,set:c(),not:!1}),m=()=>({type:u.SET,set:c(),not:!0}),d=()=>({type:u.SET,set:f(),not:!1}),g=()=>({type:u.SET,set:f(),not:!0}),y=()=>({type:u.SET,set:l(),not:!1}),v=()=>({type:u.SET,set:l(),not:!0}),x=()=>({type:u.SET,set:h(),not:!0}),b=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){const r={0:0,t:9,n:10,v:11,f:12,r:13};t.strToChars=function(e){return e=e.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(function(e,t,n,i,a,o,s,u){if(n)return e;var f=t?8:i?parseInt(i,16):a?parseInt(a,16):o?parseInt(o,8):s?"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s):r[u],c=String.fromCharCode(f);return/[[\]{}^$.|?*+()]/.test(c)&&(c="\\"+c),c}))},t.tokenizeClass=(e,r)=>{for(var n,i,a=[],o=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g;null!=(n=o.exec(e));)if(n[1])a.push(p());else if(n[2])a.push(d());else if(n[3])a.push(y());else if(n[4])a.push(m());else if(n[5])a.push(g());else if(n[6])a.push(v());else if(n[7])a.push({type:u.RANGE,from:(n[8]||n[9]).charCodeAt(0),to:n[10].charCodeAt(0)});else{if(!(i=n[12]))return[a,o.lastIndex];a.push({type:u.CHAR,value:i.charCodeAt(0)})}t.error(r,"Unterminated character class")},t.error=(e,t)=>{throw new SyntaxError("Invalid regular expression: /"+e+"/: "+t)}})),O=(b.strToChars,b.tokenizeClass,b.error,()=>({type:u.POSITION,value:"b"})),E=()=>({type:u.POSITION,value:"B"}),w=()=>({type:u.POSITION,value:"^"}),A=()=>({type:u.POSITION,value:"$"}),I=e=>{var t,r,n=0,i={type:u.ROOT,stack:[]},a=i,o=i.stack,s=[],f=t=>{b.error(e,`Nothing to repeat at column ${t-1}`)},c=b.strToChars(e);for(t=c.length;n<t;)switch(r=c[n++]){case"\\":switch(r=c[n++]){case"b":o.push(O());break;case"B":o.push(E());break;case"w":o.push(p());break;case"W":o.push(m());break;case"d":o.push(d());break;case"D":o.push(g());break;case"s":o.push(y());break;case"S":o.push(v());break;default:/\d/.test(r)?o.push({type:u.REFERENCE,value:parseInt(r,10)}):o.push({type:u.CHAR,value:r.charCodeAt(0)})}break;case"^":o.push(w());break;case"$":o.push(A());break;case"[":var l;"^"===c[n]?(l=!0,n++):l=!1;var h=b.tokenizeClass(c.slice(n),e);n+=h[1],o.push({type:u.SET,set:h[0],not:l});break;case".":o.push(x());break;case"(":var I={type:u.GROUP,stack:[],remember:!0};"?"===(r=c[n])&&(r=c[n+1],n+=2,"="===r?I.followedBy=!0:"!"===r?I.notFollowedBy=!0:":"!==r&&b.error(e,`Invalid group, character '${r}'`+` after '?' at column ${n-1}`),I.remember=!1),o.push(I),s.push(a),a=I,o=I.stack;break;case")":0===s.length&&b.error(e,`Unmatched ) at column ${n-1}`),o=(a=s.pop()).options?a.options[a.options.length-1]:a.stack;break;case"|":a.options||(a.options=[a.stack],delete a.stack);var R=[];a.options.push(R),o=R;break;case"{":var k,M,P=/^(\d+)(,(\d+)?)?\}/.exec(c.slice(n));null!==P?(0===o.length&&f(n),k=parseInt(P[1],10),M=P[2]?P[3]?parseInt(P[3],10):Infinity:k,n+=P[0].length,o.push({type:u.REPETITION,min:k,max:M,value:o.pop()})):o.push({type:u.CHAR,value:123});break;case"?":0===o.length&&f(n),o.push({type:u.REPETITION,min:0,max:1,value:o.pop()});break;case"+":0===o.length&&f(n),o.push({type:u.REPETITION,min:1,max:Infinity,value:o.pop()});break;case"*":0===o.length&&f(n),o.push({type:u.REPETITION,min:0,max:Infinity,value:o.pop()});break;default:o.push({type:u.CHAR,value:r.charCodeAt(0)})}return 0!==s.length&&b.error(e,"Unterminated group"),i};class R{constructor(e,t){this.low=e,this.high=t,this.length=1+t-e}overlaps(e){return!(this.high<e.low||this.low>e.high)}touches(e){return!(this.high+1<e.low||this.low-1>e.high)}add(e){return new R(Math.min(this.low,e.low),Math.max(this.high,e.high))}subtract(e){return e.low<=this.low&&e.high>=this.high?[]:e.low>this.low&&e.high<this.high?[new R(this.low,e.low-1),new R(e.high+1,this.high)]:e.low<=this.low?[new R(e.high+1,this.high)]:[new R(this.low,e.low-1)]}toString(){return this.low==this.high?this.low.toString():this.low+"-"+this.high}}class k{constructor(e,t){this.ranges=[],this.length=0,null!=e&&this.add(e,t)}_update_length(){this.length=this.ranges.reduce((e,t)=>e+t.length,0)}add(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.touches(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.touches(this.ranges[t]);)e=e.add(this.ranges[t]),t++;r.push(e),this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof k?e.ranges.forEach(r):(null==t&&(t=e),r(new R(e,t))),this}subtract(e,t){var r=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(var r=this.ranges.slice(0,t);t<this.ranges.length&&e.overlaps(this.ranges[t]);)r=r.concat(this.ranges[t].subtract(e)),t++;this.ranges=r.concat(this.ranges.slice(t)),this._update_length()};return e instanceof k?e.ranges.forEach(r):(null==t&&(t=e),r(new R(e,t))),this}intersect(e,t){var r=[],n=e=>{for(var t=0;t<this.ranges.length&&!e.overlaps(this.ranges[t]);)t++;for(;t<this.ranges.length&&e.overlaps(this.ranges[t]);){var n=Math.max(this.ranges[t].low,e.low),i=Math.min(this.ranges[t].high,e.high);r.push(new R(n,i)),t++}};return e instanceof k?e.ranges.forEach(n):(null==t&&(t=e),n(new R(e,t))),this.ranges=r,this._update_length(),this}index(e){for(var t=0;t<this.ranges.length&&this.ranges[t].length<=e;)e-=this.ranges[t].length,t++;return this.ranges[t].low+e}toString(){return"[ "+this.ranges.join(", ")+" ]"}clone(){return new k(this)}numbers(){return this.ranges.reduce((e,t)=>{for(var r=t.low;r<=t.high;)e.push(r),r++;return e},[])}subranges(){return this.ranges.map(e=>({low:e.low,high:e.high,length:1+e.high-e.low}))}}var M=k;const P=I.types=u;var j=class e{constructor(e,t){if(this._setDefaults(e),e instanceof RegExp)this.ignoreCase=e.ignoreCase,this.multiline=e.multiline,e=e.source;else{if("string"!=typeof e)throw new Error("Expected a regexp or string");this.ignoreCase=t&&-1!==t.indexOf("i"),this.multiline=t&&-1!==t.indexOf("m")}this.tokens=I(e)}_setDefaults(t){this.max=null!=t.max?t.max:null!=e.prototype.max?e.prototype.max:100,this.defaultRange=t.defaultRange?t.defaultRange:this.defaultRange.clone(),t.randInt&&(this.randInt=t.randInt)}gen(){return this._gen(this.tokens,[])}_gen(e,t){var r,n,i,a,o;switch(e.type){case P.ROOT:case P.GROUP:if(e.followedBy||e.notFollowedBy)return"";for(e.remember&&e.groupNumber===undefined&&(e.groupNumber=t.push(null)-1),n="",a=0,o=(r=e.options?this._randSelect(e.options):e.stack).length;a<o;a++)n+=this._gen(r[a],t);return e.remember&&(t[e.groupNumber]=n),n;case P.POSITION:return"";case P.SET:var s=this._expand(e);return s.length?String.fromCharCode(this._randSelect(s)):"";case P.REPETITION:for(i=this.randInt(e.min,e.max===Infinity?e.min+this.max:e.max),n="",a=0;a<i;a++)n+=this._gen(e.value,t);return n;case P.REFERENCE:return t[e.value-1]||"";case P.CHAR:var u=this.ignoreCase&&this._randBool()?this._toOtherCase(e.value):e.value;return String.fromCharCode(u)}}_toOtherCase(e){return e+(97<=e&&e<=122?-32:65<=e&&e<=90?32:0)}_randBool(){return!this.randInt(0,1)}_randSelect(e){return e instanceof M?e.index(this.randInt(0,e.length-1)):e[this.randInt(0,e.length-1)]}_expand(e){if(e.type===I.types.CHAR)return new M(e.value);if(e.type===I.types.RANGE)return new M(e.from,e.to);{let t=new M;for(let r=0;r<e.set.length;r++){let n=this._expand(e.set[r]);if(t.add(n),this.ignoreCase)for(let e=0;e<n.length;e++){let r=n.index(e),i=this._toOtherCase(r);r!==i&&t.add(i)}}return e.not?this.defaultRange.clone().subtract(t):this.defaultRange.clone().intersect(t)}}randInt(e,t){return e+Math.floor(Math.random()*(1+t-e))}get defaultRange(){return this._range=this._range||new M(32,126)}set defaultRange(e){this._range=e}static randexp(t,r){var n;return"string"==typeof t&&(t=new RegExp(t,r)),t._randexp===undefined?(n=new e(t,r),t._randexp=n):(n=t._randexp)._setDefaults(t),n.gen()}static sugar(){RegExp.prototype.gen=function(){return e.randexp(this)}}};function S(e,t,r,n,i){return void 0===i&&(i=!1),r=void 0===r?s.MIN_NUMBER:r,n=void 0===n?s.MAX_NUMBER:n,(t=void 0===t?n:t)<(e=void 0===e?r:e)&&(t+=e),i?function(e,t){return a("random")()*(t-e)+e}(e,t):function(e,t){return e=void 0===e?s.MIN_INTEGER:e,t=void 0===t?s.MAX_INTEGER:t,Math.floor(a("random")()*(t-e+1))+e}(e,t)}var _={pick:function(e){return e[Math.floor(a("random")()*e.length)]},date:function(e){if(e)return function(e){switch(e){case"seconds":return 60*S(0,60);case"minutes":return 612*S(15,50);case"hours":return 36123*S(12,72);case"days":return 86412345*S(7,30);case"weeks":return 604812345*S(4,52);case"months":return 2592012345*S(2,13);case"years":return 31104012345*S(1,20)}}(e);var t=new Date,r=S(-1e3,s.MOST_NEAR_DATETIME);return t.setTime(t.getTime()-r),t},shuffle:function(e){for(var t,r,n=e.length,i=e.slice();n>0;)r=Math.floor(a("random")()*n),t=i[n-=1],i[n]=i[r],i[r]=t;return i},number:S,randexp:function(e){return j.prototype.max=a("defaultRandExpMax"),j.prototype.randInt=function(e,t){return e+Math.floor(a("random")()*(t-e+1))},new j(e).gen()}};function T(e,t){return Object.keys(t).forEach((function(r){"object"!=typeof t[r]||null===t[r]?e[r]=t[r]:Array.isArray(t[r])?(e[r]=e[r]||[],t[r].forEach((function(t){Array.isArray(e[r])&&-1===e[r].indexOf(t)&&e[r].push(t)}))):"object"!=typeof e[r]||null===e[r]||Array.isArray(e[r])?e[r]=T({},t[r]):e[r]=T(e[r],t[r])})),e}function C(){return _.pick([!1,!0,null,-1,NaN,Math.PI,Infinity,undefined,[],{},Math.random(),Math.random().toString(36).substr(2)])}function N(e,t){var r=t.minimum!==undefined,n=t.maximum!==undefined;return(r||n)&&(!r||e>=t.minimum)&&(!n||e<=t.maximum)}function L(e){return"[object Object]"==={}.toString.call(e)&&!Object.keys(e).length}function $(e,t){var r=Array.isArray(t.required)&&t.required.includes(e),n="function"==typeof t.thunk||t.additionalProperties&&"function"==typeof t.additionalProperties.thunk;return!r&&!n}var H={hasProperties:function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];return t.filter((function(t){return"undefined"!=typeof e[t]})).length>0},getLocalRef:function(e,t){for(var r=t.replace("#/","").split("/");r.length;){var n=r.shift();if(!e[n])throw new Error("Prop not found: "+n+" ("+t+")");e=e[n]}return e},omitProps:function(e,t){return Object.keys(e).filter((function(e){return!t.includes(e)})).reduce((function(t,r){return Array.isArray(e[r])?t[r]=e[r].slice():t[r]=e[r]instanceof Object?T({},e[r]):e[r],t}),{})},typecast:function(e,t,r){var n={};switch(e||t.type){case"integer":case"number":if("undefined"!=typeof t.minimum&&(n.minimum=t.minimum),"undefined"!=typeof t.maximum&&(n.maximum=t.maximum),t["enum"]){var i=Math.max(n.minimum||0,0),o=Math.min(n.maximum||Infinity,Infinity);t.exclusiveMinimum&&i===t.minimum&&(i+=t.multipleOf||1),t.exclusiveMaximum&&o===t.maximum&&(o-=t.multipleOf||1),(i||o!==Infinity)&&(t["enum"]=t["enum"].filter((function(e){return e>=i&&e<=o})))}break;case"string":n.minLength=a("minLength")||0,n.maxLength=a("maxLength")||Number.MAX_SAFE_INTEGER,"undefined"!=typeof t.minLength&&(n.minLength=Math.max(n.minLength,t.minLength)),"undefined"!=typeof t.maxLength&&(n.maxLength=Math.min(n.maxLength,t.maxLength))}var s=r(n);if(null===s||s===undefined)return null;switch(e||t.type){case"number":s=parseFloat(s);break;case"integer":s=parseInt(s,10);break;case"boolean":s=!!s;break;case"string":s=String(s);for(var u,f=Math.max(n.minLength||0,0),c=Math.min(n.maxLength||Infinity,Infinity);s.length<f&&(u=s,t.pattern?s+=_.randexp(t.pattern):s+=""+_.pick([" ","/","_","-","+","=","@","^"])+s,s!==u););switch(s.length>c&&(s=s.substr(0,c)),t.format){case"date-time":case"datetime":s=new Date(s).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"date":s=new Date(s).toISOString().substr(0,10);break;case"time":s=new Date("1969-01-01 "+s).toISOString().substr(11)}}return s},merge:T,clone:function me(e,t){if(void 0===t&&(t=new Map),!e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){var r=[];return t.set(e,r),r.push.apply(r,e.map((function(e){return me(e,t)}))),r}var n={};return t.set(e,n),Object.keys(e).reduce((function(r,n){return r[n]=me(e[n],t),r}),n)},short:function(e){var t=JSON.stringify(e),r=JSON.stringify(e,null,2);return t.length>400?r.substr(0,400)+"...":r},notValue:function(e,t){var r=T({},t);if("undefined"!=typeof e.minimum&&(r.maximum=e.minimum,r.exclusiveMaximum=!0),"undefined"!=typeof e.maximum&&(r.minimum=e.maximum>r.maximum?0:e.maximum,r.exclusiveMinimum=!0),"undefined"!=typeof e.minLength&&(r.maxLength=e.minLength),"undefined"!=typeof e.maxLength&&(r.minLength=e.maxLength>r.maxLength?0:e.maxLength),e.type)r.type=_.pick(s.SCALAR_TYPES.filter((function(t){return(Array.isArray(e.type)?e.type:[e.type]).every((function(e){return"number"===t||"integer"===t?"number"!==e&&"integer"!==e:t!==e}))})));else if(e["enum"]){var n;do{n=C()}while(-1!==e["enum"].indexOf(n));r["enum"]=[n]}return e.required&&r.properties&&e.required.forEach((function(e){delete r.properties[e]})),r},anyValue:C,validate:function(e,t){return!t.every((function(t){return N(e,t)}))},validateValueForSchema:N,validateValueForOneOf:function(e,t){return 1===t.reduce((function(t,r){return t+(N(e,r)?1:0)}),0)},isKey:function(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)},template:function de(e,t){return Array.isArray(e)?e.map((function(e){return de(e,t)})):("string"==typeof e&&(e=e.replace(/#\{([\w.-]+)\}/g,(function(e,r){return t[r]}))),e)},shouldClean:$,clean:function ge(e,t,r){return void 0===r&&(r=!1),e&&"object"==typeof e?Array.isArray(e)?e.map((function(e){return ge(e,t,!0)})).filter((function(e){return void 0!==e})):(Object.keys(e).forEach((function(r){if(L(e[r]))$(r,t)&&delete e[r];else{var n=ge(e[r],t);L(n)||(e[r]=n)}"undefined"==typeof e[r]&&delete e[r]})),!Object.keys(e).length&&r?undefined:e):e},isEmpty:L};var q=function(){this.registry={},this.support={}};q.prototype.reset=function(e){e?(delete this.registry[e],delete this.support[e]):(this.registry={},this.support={})},q.prototype.extend=function(e,t){var r,n=this;this.registry[e]=t(this.registry[e]),this.support[e]||(this.support[e]=(r=function(){return n.registry[e]},function(e,t,n,i){var a=e,o=[];"object"==typeof e&&(a=Object.keys(e)[0],Array.isArray(e[a])?o=e[a]:o.push(e[a]));for(var s=a.split("."),u=r();s.length>1;)u=u[s.shift()];return"function"==typeof(e="object"==typeof u?u[s[0]]:u)&&(e=e.apply(u,o.map((function(e){return H.template(e,i)})))),"[object Object]"==={}.toString.call(e)&&Object.keys(e).forEach((function(t){if("function"==typeof e[t])throw new Error("Cannot resolve value for '"+n+": "+a+"', given: "+e)})),e}))},q.prototype.define=function(e,t){this.support[e]=t},q.prototype.get=function(e){if("undefined"==typeof this.registry[e])throw new ReferenceError("'"+e+"' dependency doesn't exist.");return this.registry[e]},q.prototype.wrap=function(e){for(var t=this,r=Object.keys(e),n={},i=r.length,a=function(){var a=r[i].replace(/^x-/,""),o=t.support[a];if("function"==typeof o)return Object.defineProperty(e,"generate",{configurable:!1,enumerable:!1,writable:!1,value:function(t){return o.call(n,e[r[i]],e,r[i],t)}}),"break"};i--;){if("break"===a())break}return e};var D=new r;function F(e,t){if(void 0===e)return D.list();if("string"==typeof e)if("function"==typeof t)D.register(e,t);else{if(null!==t&&!1!==t)return D.get(e);D.unregister(e)}else D.registerMany(e)}var G=function(e){function t(t,r){e.call(this),e.captureStackTrace&&e.captureStackTrace(this,this.constructor),this.name="ParseError",this.message=t,this.path=r}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t}(Error),z={array:["additionalItems","items","maxItems","minItems","uniqueItems"],integer:["exclusiveMaximum","exclusiveMinimum","maximum","minimum","multipleOf"],object:["additionalProperties","dependencies","maxProperties","minProperties","patternProperties","properties","required"],string:["maxLength","minLength","pattern","format"]};z.number=z.integer;var B=["additionalItems","items","additionalProperties","dependencies","patternProperties","properties"];function U(e,t,r){return Object.keys(e).filter((function(e){var n=B.indexOf(t)>-1;return!(!(r.indexOf(e)>-1)||n)})).length>0}var V=function(){return a("random")()>.5};var Z=function(){return null};function J(e){var t="undefined"==typeof e.minimum?s.MIN_INTEGER:e.minimum,r="undefined"==typeof e.maximum?s.MAX_INTEGER:e.maximum,n=e.multipleOf;if(n&&(r=Math.floor(r/n)*n,t=Math.ceil(t/n)*n),e.exclusiveMinimum&&t===e.minimum&&(t+=n||1),e.exclusiveMaximum&&r===e.maximum&&(r-=n||1),t>r)return NaN;if(n){if(-1===String(n).indexOf(".")){for(var i=_.number(Math.floor(t/n),Math.floor(r/n))*n;i<t;)i+=e.multipleOf;return i}var a,o,u=(r-t)/n;do{o=(a=_.number(0,u)*n)/n%1}while(0!==o);return t+a}return _.number(t,r,undefined,undefined,!0)}var X="Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore\net dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea\ncommodo consequat Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\npariatur Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est\nlaborum".split(/\W/);function W(e){return _.shuffle(X).slice(0,e)}var Y={type:["string","number","integer","boolean"]};function K(){return W(_.number(1,5)).join(" ")}function Q(e,t){void 0===e&&(e=0),void 0===t&&(t=140);for(var r=Math.max(0,e),n=_.number(r,t),i=K();i.length<r;)i+=K();return i.length>n&&(i=i.substr(0,n)),i}function ee(){return _.date().toISOString()}var te="https?://{hostname}(?:[a-zA-Z][a-zA-Z0-9+-.]*)+",re={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:te,slug:"[a-zA-Z\\d_-]+","uri-reference":te+"(?:\\?([a-z]{1,7}(=\\w{1,5})?&){0,3})?","uri-template":te.replace("(?:","(?:/\\{[a-z][:a-zA-Z0-9-]*\\}|"),"json-pointer":"(/(?:"+"[a-zA-Z][a-zA-Z0-9+-.]*".replace("]*","/]*")+"|~[01]))+",uuid:"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$"};re.iri=re["uri-reference"],re["iri-reference"]=re["uri-reference"],re["idn-email"]=re.email,re["idn-hostname"]=re.hostname;var ne=new RegExp("\\{("+Object.keys(re).join("|")+")\\}");function ie(e,t){var r,n=F(e.format);if("function"==typeof n)return n(e);switch(e.format){case"date-time":case"datetime":return ee();case"date":return ee().slice(0,10);case"time":return ee().slice(11);case"ipv4":return[0,0,0,0].map((function(){return _.number(0,255)})).join(".");case"regex":return".+?";case"email":case"hostname":case"ipv6":case"uri":case"uri-reference":case"iri":case"iri-reference":case"idn-email":case"idn-hostname":case"json-pointer":case"slug":case"uri-template":case"uuid":return r=e.format,_.randexp(re[r]).replace(ne,(function(e,t){return _.randexp(re[t])}));default:if(void 0===n){if(a("failOnInvalidFormat"))throw new Error("unknown registry key "+H.short(e.format));return t()}throw new Error("unsupported format '"+e.format+"'")}}var ae={boolean:V,"null":Z,array:function(e,t,r,n){var i=[];if(!e.items&&!e.additionalItems){if(H.hasProperties(e,"minItems","maxItems","uniqueItems"))throw new G("missing items for "+H.short(e),t);return i}if(Array.isArray(e.items))return e.items.map((function(e,i){var a=t.concat(["items",i]);return n(e,a,r)}));var o=e.minItems,s=e.maxItems;a("minItems")&&(o=s?Math.min(a("minItems"),s):a("minItems")),a("maxItems")&&((s=o?Math.min(a("maxItems"),o):a("maxItems"))&&s>a("maxItems")&&(s=a("maxItems")),o&&o>a("maxItems")&&(o=s));var u=!0===a("alwaysFakeOptionals")?1:a("optionalsProbability"),f=a("alwaysFakeOptionals")||a("fixedProbabilities")||!1,c=_.number(o,s,1,5);null!==u&&(c=Math.max(f?Math.round((s||c)*u):Math.abs(_.number(o,s)*u),o||0));for(var l="object"==typeof e.additionalItems?e.additionalItems:{},h=i.length;h<c;h+=1){var p=t.concat(["items",h]),m=n(e.items||l,p,r);i.push(m)}return e.uniqueItems?function(e,t,r,n,i,a){var o=[],s=[];function u(e){var t=JSON.stringify(e);return-1===s.indexOf(t)&&(s.push(t),o.push(e),!0)}t.forEach(u);for(var f=100;o.length!==t.length&&(u(a(r.items||n,e,i))||(f-=1),f););return o}(t.concat(["items"]),i,e,l,r,n):i},integer:function(e){return J(Object.assign({multipleOf:1},e))},number:J,object:function(e,t,r,n){var i={},o=e.properties||{},s=e.patternProperties||{},u="boolean"==typeof e.required?[]:(e.required||[]).slice(),f=!1!==e.additionalProperties,c=Object.keys(o),l=Object.keys(s),h=c.concat(l).reduce((function(e,t){return-1===u.indexOf(t)&&e.push(t),e}),[]),p=u.concat(h),m=f&&!0===e.additionalProperties?Y:e.additionalProperties;if(!f&&0===c.length&&0===l.length&&H.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(!0===a("requiredOnly"))return u.forEach((function(e){o[e]&&(i[e]=o[e])})),n(i,t.concat(["properties"]),r,e);var d=!0===a("alwaysFakeOptionals")?1:a("optionalsProbability"),g=a("alwaysFakeOptionals")||a("fixedProbabilities")||!1,y=a("ignoreProperties")||[],v=a("reuseProperties"),x=a("fillProperties"),b=e.maxProperties||p.length+(f?_.number(1,5):0),O=Math.max(e.minProperties||0,u.length),E=Math.max(0,p.length-O);1!==p.length||u.length||(O=Math.max(_.number(x?1:0,b),O)),null!==d&&(E=!0===g?Math.round(O-u.length+d*(p.length-O)):_.number(O-u.length,d*(p.length-O)));var w=_.shuffle(h).slice(0,E),A=h.filter((function(e){return-1!==w.indexOf(e)})),I=null!==d?b:_.number(0,b),R=u.concat(_.shuffle(A).slice(0,I)),k=[];if(e.dependencies&&(Object.keys(e.dependencies).forEach((function(t){var r=e.dependencies[t];-1!==R.indexOf(t)&&(Array.isArray(r)?r.forEach((function(e){-1===R.indexOf(e)&&R.push(e)})):k.push(r))})),k.length))return delete e.dependencies,n({allOf:k.concat(e)},t.concat(["properties"]),r,e);var M=[];R.forEach((function(e){for(var t=0;t<y.length;t+=1)if(y[t]instanceof RegExp&&y[t].test(e)||"string"==typeof y[t]&&y[t]===e||"function"==typeof y[t]&&y[t](o[e],e))return void M.push(e);var r;if(!1===m&&-1!==u.indexOf(e)&&(i[e]=o[e]),o[e]&&(i[e]=o[e]),l.forEach((function(t){e.match(new RegExp(t))&&(r=!0,i[e]?H.merge(i[e],s[t]):i[_.randexp(e)]=s[t])})),!r){var n=s[e]||m;n&&!1!==m&&(i[s[e]?_.randexp(e):e]=o[e]||n)}}));var P=Object.keys(i).length+(x?0:M.length);function j(e){var t;do{if(!e.length)break;t=e.shift()}while(i[t]);return t}var S,T=O;for(f&&!u.length&&(T=Math.max(null===d||m?_.number(x?1:0,b):0,O));x&&(l.length||f)&&!(P>=T);){if(f)if(v&&c.length-P>T){var C=0,N=void 0;do{if((C+=1)>1e3)break;N=j(u)||_.pick(c)}while("undefined"!=typeof i[N]);"undefined"==typeof i[N]&&(i[N]=o[N],P+=1)}else if(l.length&&!m){var L=_.pick(l),$=_.randexp(L);i[$]||(i[$]=s[L],P+=1)}else{var q=j(u)||W(1)+(S=void 0,_.randexp("_?[_a-f\\d]{1,3}"+(S?"\\$?":"")));i[q]||(i[q]=m||Y,P+=1)}for(var D=0;P<O&&D<l.length;D+=1){var F=l[D],G=_.randexp(F);i[G]||(i[G]=s[F],P+=1)}}if(0===u.length&&(!f||!1===d))for(var z=_.number(O,b);P<z;){var B=j(c);B&&(i[B]=o[B]),P+=1}return n(i,t.concat(["properties"]),r,e)},string:function(e){return H.typecast("string",e,(function(t){return e.format?ie(e,(function(){return Q(t.minLength,t.maxLength)})):e.pattern?_.randexp(e.pattern):Q(t.minLength,t.maxLength)}))}};function oe(e,t,r,n){if(e=r(e,null,t)){if("properties"!==t[t.length-1]){if(a("useExamplesValue")&&Array.isArray(e.examples)){var i=e.examples.concat("default"in e?[e["default"]]:[]);return H.typecast(null,e,(function(){return _.pick(i)}))}if(a("useDefaultValue")&&"default"in e&&(""!==e["default"]||!a("replaceEmptyByRandomValue")))return e["default"];if("template"in e)return H.template(e.template,n);if("const"in e)return e["const"]}if(e.not&&"object"==typeof e.not&&(e=H.notValue(e.not,H.omitProps(e,["not"]))).type&&"object"===e.type){var o=oe(e,t.concat(["not"]),r,n);return H.clean(o,e,!1)}if("function"==typeof e.thunk)return oe(e.thunk(n),t,r);if("function"==typeof e.generate)return H.typecast(null,e,(function(){return e.generate(n)}));if("string"==typeof e.pattern)return H.typecast("string",e,(function(){return _.randexp(e.pattern)}));if(Array.isArray(e["enum"]))return H.typecast(null,e,(function(){return _.pick(e["enum"])}));if(e.jsonPath)return e;var s=e.type;if(Array.isArray(s)?s=_.pick(s):void 0===s&&(s=function(e,t){for(var r=Object.keys(z),n=0;n<r.length;n+=1){var i=r[n];if(U(e,t[t.length-1],z[i]))return i}}(e,t)||s)&&(e.type=s),"string"==typeof s){if(!ae[s]){if(a("failOnInvalidTypes"))throw new G("unknown primitive "+H.short(s),t.concat(["type"]));var u=a("defaultInvalidTypeProduct");return"string"==typeof u&&ae[u]?ae[u](e,t,r,oe):u}try{return ae[s](e,t,r,oe)}catch(c){if("undefined"==typeof c.path)throw new G(c.stack,t);throw c}}var f={};return Array.isArray(e)&&(f=[]),Object.keys(e).forEach((function(n){if("object"==typeof e[n]&&"definitions"!==n){var i=oe(e[n],t.concat([n]),r,f);f[n]=H.clean(i,e[n],!1)}else f[n]=e[n]})),f}}var se=function(e){var t,r=e.refs,n=e.schema,i=e.container,o=e.refDepthMax,s=e.refDepthMin,u={},f={},c=0;return u.resolveSchema=function(e,l,h){if(null===e||e===undefined)return null;if("function"==typeof e.generate)return e;if("string"==typeof(e.$id||e.id)&&(delete e.id,delete e.$id,delete e.$schema),"string"==typeof e.$ref){var p,m=Math.max(s,o)-1;if("#"===e.$ref||f[e.$ref]<0||t===e.$ref&&++c>m)return delete e.$ref,e;if("undefined"==typeof f[e.$ref]&&(f[e.$ref]=_.number(s,o)-1),t=e.$ref,void 0!==(p=-1===e.$ref.indexOf("#/")?r[e.$ref]||null:H.getLocalRef(n,e.$ref)||null)){if(!p&&!0!==a("ignoreMissingRefs"))throw new Error("Reference not found: "+e.$ref);f[e.$ref]-=1,H.merge(e,p||{})}return delete e.$ref,e}if(Array.isArray(e.allOf)){var d=e.allOf;delete e.allOf,d.forEach((function(t){var r=u.resolveSchema(t,null,h);H.merge(e,"function"==typeof r.thunk?r.thunk(e):r),Array.isArray(e.allOf)&&u.resolveSchema(e,l,h)}))}if(Array.isArray(e.oneOf||e.anyOf)){var g=e.oneOf||e.anyOf;return e["enum"]&&e.oneOf&&(e["enum"]=e["enum"].filter((function(e){return H.validate(e,g)}))),{thunk:function(t){var r=H.omitProps(e,["anyOf","oneOf"]),n=_.pick(g);return H.merge(r,n),g.forEach((function(e){e.required&&e!==n&&e.required.forEach((function(e){var n=r.required&&r.required.includes(e);r.properties&&!n&&delete r.properties[e],t&&t.properties&&delete t.properties[e]}))})),r}}}if(Object.keys(e).forEach((function(t){!Array.isArray(e[t])&&"object"!=typeof e[t]||H.isKey(t)||(e[t]=u.resolveSchema(e[t],t,h.concat(t)))})),h){var y=h[h.length-1];if("properties"===y||"items"===y)return e}return i.wrap(e)},u};function ue(e,r,n,i){if(!e||"object"!=typeof e)return e;if(n||(n={}),r||(r=e),Array.isArray(e))return e.map((function(e){return ue(e,r,n,i)}));if(e.jsonPath){var a="object"!=typeof e.jsonPath?{path:e.jsonPath}:e.jsonPath;a.group=e.group||a.group||i,a.cycle=e.cycle||a.cycle||!1,a.reverse=e.reverse||a.reverse||!1,a.count=e.count||a.count||1;var o=a.group+"__"+a.path;return n[o]||(a.count>1?n[o]=t.JSONPath(a.path,r).slice(0,a.count):n[o]=t.JSONPath(a.path,r)),a.cycle||a.reverse?function(e,t){if(!Array.isArray(e))return e;var r=t?e.pop():e.shift();return t?e.unshift(r):e.push(r),r}(n[o],a.reverse):function(e){return Array.isArray(e)?_.pick(e):e}(n[o])}return Object.keys(e).forEach((function(t){e[t]=ue(e[t],r,n,t)})),e}function fe(e,t,r){if("[object Object]"!=={}.toString.call(t))throw new Error("Invalid input, expecting object but given "+typeof t);var n=a("refDepthMin")||0,i=a("refDepthMax")||3;try{var o=se({refs:e,schema:t,container:r,refDepthMin:n,refDepthMax:i}).resolveSchema,s=oe(H.clone(t),[],o);return a("resolveJsonPath")?ue(s):s}catch(u){throw u.path?new Error(u.message+" in /"+u.path.join("/")):u}}var ce=new q;function le(){ce.define("autoIncrement",(function(e,t){if(!this.offset){var r=t.minimum||1,n=r+s.MAX_NUMBER,i=e.initialOffset||t.initialOffset;this.offset=i||_.number(r,n)}return!0===e?this.offset++:t})),ce.define("sequentialDate",(function(e,t){if(this.now||(this.now=_.date()),e){if(t=this.now.toISOString(),-1===["seconds","minutes","hours","days","weeks","months","years"].indexOf(e=!0===e?"days":e))throw new Error("Unsupported increment by "+H.short(e));this.now.setTime(this.now.getTime()+_.date(e))}return t}))}function he(e,t){var r={};function n(e){if(e&&"object"==typeof e){if(Array.isArray(e))return e.forEach(n);var t=e.$id||e.id;"string"!=typeof t||r[t]||(r[t]=e),Object.keys(e).forEach((function(t){n(e[t])}))}}return Array.isArray(e)?e.forEach((function(e){r[e.$id||e.id]=e})):r=e||{},n(e),n(t),r}var pe=function(e,t,r){return pe.generate(e,t)};return pe.generate=function(e,t){return fe(he(t,e),e,ce)},pe.resolve=function(t,r,n){"string"==typeof r&&(n=r,r={}),n=(n=n||("undefined"!=typeof process?process.cwd():"")).replace(/\/+$/,"")+"/";var i=he(r,t),a={order:1,canRead:function(e){var t=e.url.replace("/:",":");return i[t]||i[t.split("/").pop()]},read:function(e,t){try{t(null,this.canRead(e))}catch(r){t(r)}}};return e.dereference(n,t,{resolve:{file:{order:100},http:{order:200},fixedRefs:a},dereference:{circular:"ignore"}}).then((function(e){return fe(i,e,ce)}))["catch"]((function(e){throw new Error("Error while resolving schema ("+e.message+")")}))},le(),pe.format=F,pe.option=a,pe.random=_,pe.extend=function(e,t){return ce.extend(e,t),pe},pe.define=function(e,t){return ce.define(e,t),pe},pe.reset=function(e){return ce.reset(e),le(),pe},pe.locate=function(e){return ce.get(e)},"undefined"!=typeof VERSION&&(pe.version=VERSION),pe})); |
{ | ||
"name": "json-schema-faker", | ||
"version": "0.5.0-rcv.29", | ||
"version": "0.5.0-rcv.30", | ||
"description": "JSON-Schema + fake data generators", | ||
@@ -16,12 +16,12 @@ "homepage": "http://json-schema-faker.js.org", | ||
"test": "npm run test:unit -- && npm run test:schema", | ||
"_test:ci": "npm run coverage:all && npm run report -- -r lcov", | ||
"_test:all": "npm run test:run tests && npm run report -- -r html", | ||
"test:run": "cross-env NODE_ENV=test _mocha --exit --recursive --watch-extensions js,json -r esm -bR spec", | ||
"test:ci": "npm run coverage:unit && npm run report -- -r lcov", | ||
"test:all": "npm run coverage:all && npm run report -- -r html", | ||
"test:run": "cross-env NODE_ENV=test _mocha --exit --recursive --watch-files 'tests/**' --watch-files 'src/**' --watch-extensions js,json -r esm -bR spec", | ||
"test:unit": "npm run test:run tests/unit --", | ||
"test:schema": "npm run test:run tests/schema --", | ||
"_coverage": "nyc -x '**/tests/**' -x '**/*.spec.js'", | ||
"_coverage:all": "npm run coverage -- npm run test:all", | ||
"_coverage:unit": "npm run coverage -- npm run test:unit", | ||
"_codecov": "codecov --file=coverage/lcov.info -e TRAVIS_NODE_VERSION", | ||
"_report": "nyc report", | ||
"coverage": "nyc -x '**/tests/**' -x '**/*.spec.js'", | ||
"coverage:all": "npm run coverage -- npm run test:all", | ||
"coverage:unit": "npm run coverage -- npm run test:unit", | ||
"codecov": "codecov --file=coverage/lcov.info -e TRAVIS_NODE_VERSION", | ||
"report": "nyc report", | ||
"lint": "eslint src tests", | ||
@@ -35,3 +35,4 @@ "_pretest": "npm run lint", | ||
"copy:vendor": "concat -o dist/vendor.js node_modules/json-schema-ref-parser/dist/ref-parser.min.js node_modules/jsonpath-plus/dist/index-umd.min.js", | ||
"postbuild": "npm run copy:vendor && concat -o dist/bundle.js dist/vendor.js dist/main.umd.min.js" | ||
"copy:wargs": "concat -o dist/wargs.min.js node_modules/wargs/dist/wargs.min.js", | ||
"postbuild": "npm run copy:vendor && npm run copy:wargs && concat -o dist/bundle.js dist/vendor.js dist/main.umd.min.js" | ||
}, | ||
@@ -129,2 +130,3 @@ "author": "Alvaro Cabrera <pateketrueke@gmail.com> (https://soypache.co)", | ||
"is-my-json-valid": "^2.19.0", | ||
"kind-of": ">=6.0.3", | ||
"less": "^3.10.3", | ||
@@ -151,6 +153,6 @@ "less-plugin-autoprefix": "^2.0.0", | ||
"vue-template-compiler": "^2.6.10", | ||
"wargs": "^0.9.0", | ||
"wargs": "^0.9.2", | ||
"yargs-parser": ">=13.1.2", | ||
"yrv": "^0.0.24", | ||
"z-schema": "^4.1.0", | ||
"kind-of": ">=6.0.3" | ||
"z-schema": "^4.1.0" | ||
}, | ||
@@ -157,0 +159,0 @@ "dependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
784106
14
9236
46