very-express 0.5.13 → 0.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +214 -110
- package/dist/templates/_middlewares/Authentication.ts +8 -6
- package/dist/templates/_routes/oauth/OAuthRouteFactory.ts +7 -42
- package/dist/templates/_services/VexDbConnector.ts +8 -8
- package/dist/templates/_services/VexSystem.ts +5 -6
- package/dist/templates/_services/auth/JWTService.ts +168 -0
- package/dist/templates/_services/oauth/OAuthProfileMap.ts +69 -0
- package/dist/templates/_services/oauth/OAuthStrategyService.ts +92 -0
- package/dist/templates/_types/VexResponseError.ts +20 -0
- package/dist/templates/_types/responseObject.ts +7 -0
- package/dist/templates/_utils/hash.ts +47 -0
- package/dist/templates/_utils/index.ts +5 -3
- package/dist/templates/_utils/response.ts +102 -32
- package/dist/templates/jsonSchema/User.json +3 -0
- package/package.json +1 -1
- package/vex.config.json +3 -2
- package/dist/templates/_plugins/auth/jwt.ts +0 -85
- package/dist/templates/_plugins/auth/oauthVerify.ts +0 -86
- package/dist/templates/_plugins/auth/profileMapping.ts +0 -68
- package/dist/templates/_plugins/auth/token.ts +0 -29
- package/dist/templates/_types/response/index.ts +0 -10
- package/dist/templates/_types/response/responseCode.ts +0 -15
- package/dist/templates/_types/response/responseMsg.ts +0 -28
- package/dist/templates/_types/response/responseStatusCodeMap.ts +0 -70
- /package/dist/templates/{_plugins → _services}/auth/JWTKeyStore.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -917,15 +917,15 @@ Parsed value is empty`))):p(w)},h=function(w){!w&&s.continueOnError?f(new NO.Unm
|
|
|
917
917
|
`,v=1;v<=s.linesAfter&&!(h+v>=f.length);v++)x=Rde(n.buffer,p[h+v],f[h+v],n.position-(p[h]-p[h+v]),w),g+=aX.repeat(" ",s.indent)+jde((n.line+v+1).toString(),C)+" | "+x.str+`
|
|
918
918
|
`;return g.replace(/\n$/,"")}G5e.exports=XIr});var jg=fs((AZr,Y5e)=>{"use strict";var W5e=m$(),QIr=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],ZIr=["scalar","sequence","mapping"];function eBr(n){var s={};return n!==null&&Object.keys(n).forEach(function(c){n[c].forEach(function(p){s[String(p)]=c})}),s}function tBr(n,s){if(s=s||{},Object.keys(s).forEach(function(c){if(QIr.indexOf(c)===-1)throw new W5e('Unknown option "'+c+'" is met in definition of "'+n+'" YAML type.')}),this.options=s,this.tag=n,this.kind=s.kind||null,this.resolve=s.resolve||function(){return!0},this.construct=s.construct||function(c){return c},this.instanceOf=s.instanceOf||null,this.predicate=s.predicate||null,this.represent=s.represent||null,this.representName=s.representName||null,this.defaultStyle=s.defaultStyle||null,this.multi=s.multi||!1,this.styleAliases=eBr(s.styleAliases||null),ZIr.indexOf(this.kind)===-1)throw new W5e('Unknown kind "'+this.kind+'" is specified for "'+n+'" YAML type.')}Y5e.exports=tBr});var $de=fs((SZr,Q5e)=>{"use strict";var sX=m$(),Mde=jg();function X5e(n,s){var c=[];return n[s].forEach(function(p){var f=c.length;c.forEach(function(_,h){_.tag===p.tag&&_.kind===p.kind&&_.multi===p.multi&&(f=h)}),c[f]=p}),c}function rBr(){var n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},s,c;function p(f){f.multi?(n.multi[f.kind].push(f),n.multi.fallback.push(f)):n[f.kind][f.tag]=n.fallback[f.tag]=f}for(s=0,c=arguments.length;s<c;s+=1)arguments[s].forEach(p);return n}function qde(n){return this.extend(n)}qde.prototype.extend=function(s){var c=[],p=[];if(s instanceof Mde)p.push(s);else if(Array.isArray(s))p=p.concat(s);else if(s&&(Array.isArray(s.implicit)||Array.isArray(s.explicit)))s.implicit&&(c=c.concat(s.implicit)),s.explicit&&(p=p.concat(s.explicit));else throw new sX("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");c.forEach(function(_){if(!(_ instanceof Mde))throw new sX("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(_.loadKind&&_.loadKind!=="scalar")throw new sX("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(_.multi)throw new sX("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),p.forEach(function(_){if(!(_ instanceof Mde))throw new sX("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var f=Object.create(qde.prototype);return f.implicit=(this.implicit||[]).concat(c),f.explicit=(this.explicit||[]).concat(p),f.compiledImplicit=X5e(f,"implicit"),f.compiledExplicit=X5e(f,"explicit"),f.compiledTypeMap=rBr(f.compiledImplicit,f.compiledExplicit),f};Q5e.exports=qde});var Ude=fs((wZr,Z5e)=>{"use strict";var nBr=jg();Z5e.exports=new nBr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(n){return n!==null?n:""}})});var Kde=fs((TZr,eTe)=>{"use strict";var iBr=jg();eTe.exports=new iBr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(n){return n!==null?n:[]}})});var Vde=fs((kZr,tTe)=>{"use strict";var aBr=jg();tTe.exports=new aBr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(n){return n!==null?n:{}}})});var Hde=fs((FZr,rTe)=>{"use strict";var sBr=$de();rTe.exports=new sBr({explicit:[Ude(),Kde(),Vde()]})});var Jde=fs((PZr,nTe)=>{"use strict";var oBr=jg();function uBr(n){if(n===null)return!0;var s=n.length;return s===1&&n==="~"||s===4&&(n==="null"||n==="Null"||n==="NULL")}function cBr(){return null}function lBr(n){return n===null}nTe.exports=new oBr("tag:yaml.org,2002:null",{kind:"scalar",resolve:uBr,construct:cBr,predicate:lBr,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"})});var Gde=fs((OZr,iTe)=>{"use strict";var pBr=jg();function fBr(n){if(n===null)return!1;var s=n.length;return s===4&&(n==="true"||n==="True"||n==="TRUE")||s===5&&(n==="false"||n==="False"||n==="FALSE")}function dBr(n){return n==="true"||n==="True"||n==="TRUE"}function _Br(n){return Object.prototype.toString.call(n)==="[object Boolean]"}iTe.exports=new pBr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:fBr,construct:dBr,predicate:_Br,represent:{lowercase:function(n){return n?"true":"false"},uppercase:function(n){return n?"TRUE":"FALSE"},camelcase:function(n){return n?"True":"False"}},defaultStyle:"lowercase"})});var zde=fs((NZr,aTe)=>{"use strict";var hBr=h$(),mBr=jg();function gBr(n){return 48<=n&&n<=57||65<=n&&n<=70||97<=n&&n<=102}function yBr(n){return 48<=n&&n<=55}function vBr(n){return 48<=n&&n<=57}function xBr(n){if(n===null)return!1;var s=n.length,c=0,p=!1,f;if(!s)return!1;if(f=n[c],(f==="-"||f==="+")&&(f=n[++c]),f==="0"){if(c+1===s)return!0;if(f=n[++c],f==="b"){for(c++;c<s;c++)if(f=n[c],f!=="_"){if(f!=="0"&&f!=="1")return!1;p=!0}return p&&f!=="_"}if(f==="x"){for(c++;c<s;c++)if(f=n[c],f!=="_"){if(!gBr(n.charCodeAt(c)))return!1;p=!0}return p&&f!=="_"}if(f==="o"){for(c++;c<s;c++)if(f=n[c],f!=="_"){if(!yBr(n.charCodeAt(c)))return!1;p=!0}return p&&f!=="_"}}if(f==="_")return!1;for(;c<s;c++)if(f=n[c],f!=="_"){if(!vBr(n.charCodeAt(c)))return!1;p=!0}return!(!p||f==="_")}function DBr(n){var s=n,c=1,p;if(s.indexOf("_")!==-1&&(s=s.replace(/_/g,"")),p=s[0],(p==="-"||p==="+")&&(p==="-"&&(c=-1),s=s.slice(1),p=s[0]),s==="0")return 0;if(p==="0"){if(s[1]==="b")return c*parseInt(s.slice(2),2);if(s[1]==="x")return c*parseInt(s.slice(2),16);if(s[1]==="o")return c*parseInt(s.slice(2),8)}return c*parseInt(s,10)}function bBr(n){return Object.prototype.toString.call(n)==="[object Number]"&&n%1===0&&!hBr.isNegativeZero(n)}aTe.exports=new mBr("tag:yaml.org,2002:int",{kind:"scalar",resolve:xBr,construct:DBr,predicate:bBr,represent:{binary:function(n){return n>=0?"0b"+n.toString(2):"-0b"+n.toString(2).slice(1)},octal:function(n){return n>=0?"0o"+n.toString(8):"-0o"+n.toString(8).slice(1)},decimal:function(n){return n.toString(10)},hexadecimal:function(n){return n>=0?"0x"+n.toString(16).toUpperCase():"-0x"+n.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var Wde=fs((IZr,oTe)=>{"use strict";var sTe=h$(),EBr=jg(),CBr=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function ABr(n){return!(n===null||!CBr.test(n)||n[n.length-1]==="_")}function SBr(n){var s,c;return s=n.replace(/_/g,"").toLowerCase(),c=s[0]==="-"?-1:1,"+-".indexOf(s[0])>=0&&(s=s.slice(1)),s===".inf"?c===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:s===".nan"?NaN:c*parseFloat(s,10)}var wBr=/^[-+]?[0-9]+e/;function TBr(n,s){var c;if(isNaN(n))switch(s){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===n)switch(s){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===n)switch(s){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(sTe.isNegativeZero(n))return"-0.0";return c=n.toString(10),wBr.test(c)?c.replace("e",".e"):c}function kBr(n){return Object.prototype.toString.call(n)==="[object Number]"&&(n%1!==0||sTe.isNegativeZero(n))}oTe.exports=new EBr("tag:yaml.org,2002:float",{kind:"scalar",resolve:ABr,construct:SBr,predicate:kBr,represent:TBr,defaultStyle:"lowercase"})});var Yde=fs((BZr,uTe)=>{"use strict";uTe.exports=Hde().extend({implicit:[Jde(),Gde(),zde(),Wde()]})});var Xde=fs((LZr,cTe)=>{"use strict";cTe.exports=Yde()});var Qde=fs((RZr,fTe)=>{"use strict";var FBr=jg(),lTe=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),pTe=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function PBr(n){return n===null?!1:lTe.exec(n)!==null||pTe.exec(n)!==null}function OBr(n){var s,c,p,f,_,h,g,v=0,x=null,C,w,O;if(s=lTe.exec(n),s===null&&(s=pTe.exec(n)),s===null)throw new Error("Date resolve error");if(c=+s[1],p=+s[2]-1,f=+s[3],!s[4])return new Date(Date.UTC(c,p,f));if(_=+s[4],h=+s[5],g=+s[6],s[7]){for(v=s[7].slice(0,3);v.length<3;)v+="0";v=+v}return s[9]&&(C=+s[10],w=+(s[11]||0),x=(C*60+w)*6e4,s[9]==="-"&&(x=-x)),O=new Date(Date.UTC(c,p,f,_,h,g,v)),x&&O.setTime(O.getTime()-x),O}function NBr(n){return n.toISOString()}fTe.exports=new FBr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:PBr,construct:OBr,instanceOf:Date,represent:NBr})});var Zde=fs((jZr,dTe)=>{"use strict";var IBr=jg();function BBr(n){return n==="<<"||n===null}dTe.exports=new IBr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:BBr})});var t_e=fs((MZr,_Te)=>{"use strict";var LBr=jg(),e_e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
919
919
|
\r`;function RBr(n){if(n===null)return!1;var s,c,p=0,f=n.length,_=e_e;for(c=0;c<f;c++)if(s=_.indexOf(n.charAt(c)),!(s>64)){if(s<0)return!1;p+=6}return p%8===0}function jBr(n){var s,c,p=n.replace(/[\r\n=]/g,""),f=p.length,_=e_e,h=0,g=[];for(s=0;s<f;s++)s%4===0&&s&&(g.push(h>>16&255),g.push(h>>8&255),g.push(h&255)),h=h<<6|_.indexOf(p.charAt(s));return c=f%4*6,c===0?(g.push(h>>16&255),g.push(h>>8&255),g.push(h&255)):c===18?(g.push(h>>10&255),g.push(h>>2&255)):c===12&&g.push(h>>4&255),new Uint8Array(g)}function MBr(n){var s="",c=0,p,f,_=n.length,h=e_e;for(p=0;p<_;p++)p%3===0&&p&&(s+=h[c>>18&63],s+=h[c>>12&63],s+=h[c>>6&63],s+=h[c&63]),c=(c<<8)+n[p];return f=_%3,f===0?(s+=h[c>>18&63],s+=h[c>>12&63],s+=h[c>>6&63],s+=h[c&63]):f===2?(s+=h[c>>10&63],s+=h[c>>4&63],s+=h[c<<2&63],s+=h[64]):f===1&&(s+=h[c>>2&63],s+=h[c<<4&63],s+=h[64],s+=h[64]),s}function qBr(n){return Object.prototype.toString.call(n)==="[object Uint8Array]"}_Te.exports=new LBr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:RBr,construct:jBr,predicate:qBr,represent:MBr})});var r_e=fs((qZr,hTe)=>{"use strict";var $Br=jg(),UBr=Object.prototype.hasOwnProperty,KBr=Object.prototype.toString;function VBr(n){if(n===null)return!0;var s=[],c,p,f,_,h,g=n;for(c=0,p=g.length;c<p;c+=1){if(f=g[c],h=!1,KBr.call(f)!=="[object Object]")return!1;for(_ in f)if(UBr.call(f,_))if(!h)h=!0;else return!1;if(!h)return!1;if(s.indexOf(_)===-1)s.push(_);else return!1}return!0}function HBr(n){return n!==null?n:[]}hTe.exports=new $Br("tag:yaml.org,2002:omap",{kind:"sequence",resolve:VBr,construct:HBr})});var n_e=fs(($Zr,mTe)=>{"use strict";var JBr=jg(),GBr=Object.prototype.toString;function zBr(n){if(n===null)return!0;var s,c,p,f,_,h=n;for(_=new Array(h.length),s=0,c=h.length;s<c;s+=1){if(p=h[s],GBr.call(p)!=="[object Object]"||(f=Object.keys(p),f.length!==1))return!1;_[s]=[f[0],p[f[0]]]}return!0}function WBr(n){if(n===null)return[];var s,c,p,f,_,h=n;for(_=new Array(h.length),s=0,c=h.length;s<c;s+=1)p=h[s],f=Object.keys(p),_[s]=[f[0],p[f[0]]];return _}mTe.exports=new JBr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:zBr,construct:WBr})});var i_e=fs((UZr,gTe)=>{"use strict";var YBr=jg(),XBr=Object.prototype.hasOwnProperty;function QBr(n){if(n===null)return!0;var s,c=n;for(s in c)if(XBr.call(c,s)&&c[s]!==null)return!1;return!0}function ZBr(n){return n!==null?n:{}}gTe.exports=new YBr("tag:yaml.org,2002:set",{kind:"mapping",resolve:QBr,construct:ZBr})});var nae=fs((KZr,yTe)=>{"use strict";yTe.exports=Xde().extend({implicit:[Qde(),Zde()],explicit:[t_e(),r_e(),n_e(),i_e()]})});var ITe=fs((VZr,u_e)=>{"use strict";var LO=h$(),ATe=m$(),eLr=z5e(),tLr=nae(),DT=Object.prototype.hasOwnProperty,iae=1,STe=2,wTe=3,aae=4,a_e=1,rLr=2,vTe=3,nLr=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,iLr=/[\x85\u2028\u2029]/,aLr=/[,\[\]\{\}]/,TTe=/^(?:!|!!|![a-z\-]+!)$/i,kTe=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function xTe(n){return Object.prototype.toString.call(n)}function _6(n){return n===10||n===13}function RO(n){return n===9||n===32}function lx(n){return n===9||n===32||n===10||n===13}function g$(n){return n===44||n===91||n===93||n===123||n===125}function sLr(n){var s;return 48<=n&&n<=57?n-48:(s=n|32,97<=s&&s<=102?s-97+10:-1)}function oLr(n){return n===120?2:n===117?4:n===85?8:0}function uLr(n){return 48<=n&&n<=57?n-48:-1}function DTe(n){return n===48?"\0":n===97?"\x07":n===98?"\b":n===116||n===9?" ":n===110?`
|
|
920
|
-
`:n===118?"\v":n===102?"\f":n===114?"\r":n===101?"\x1B":n===32?" ":n===34?'"':n===47?"/":n===92?"\\":n===78?"\x85":n===95?"\xA0":n===76?"\u2028":n===80?"\u2029":""}function cLr(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}var FTe=new Array(256),PTe=new Array(256);for(BO=0;BO<256;BO++)FTe[BO]=DTe(BO)?1:0,PTe[BO]=DTe(BO);var BO;function lLr(n,s){this.input=n,this.filename=s.filename||null,this.schema=s.schema||tLr,this.onWarning=s.onWarning||null,this.legacy=s.legacy||!1,this.json=s.json||!1,this.listener=s.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=n.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function OTe(n,s){var c={name:n.filename,buffer:n.input.slice(0,-1),position:n.position,line:n.line,column:n.position-n.lineStart};return c.snippet=eLr(c),new ATe(s,c)}function
|
|
921
|
-
`,s-1))}function pLr(n,s,c){var p,f,_,h,g,v,x,C,w=n.kind,O=n.result,F;if(F=n.input.charCodeAt(n.position),lx(F)||g$(F)||F===35||F===38||F===42||F===33||F===124||F===62||F===39||F===34||F===37||F===64||F===96||(F===63||F===45)&&(f=n.input.charCodeAt(n.position+1),lx(f)||c&&g$(f)))return!1;for(n.kind="scalar",n.result="",_=h=n.position,g=!1;F!==0;){if(F===58){if(f=n.input.charCodeAt(n.position+1),lx(f)||c&&g$(f))break}else if(F===35){if(p=n.input.charCodeAt(n.position-1),lx(p))break}else{if(n.position===n.lineStart&&oae(n)||c&&g$(F))break;if(_6(F))if(v=n.line,x=n.lineStart,C=n.lineIndent,Lh(n,!1,-1),n.lineIndent>=s){g=!0,F=n.input.charCodeAt(n.position);continue}else{n.position=h,n.line=v,n.lineStart=x,n.lineIndent=C;break}}g&&(xT(n,_,h,!1),o_e(n,n.line-v),_=h=n.position,g=!1),RO(F)||(h=n.position+1),F=n.input.charCodeAt(++n.position)}return xT(n,_,h,!1),n.result?!0:(n.kind=w,n.result=O,!1)}function fLr(n,s){var c,p,f;if(c=n.input.charCodeAt(n.position),c!==39)return!1;for(n.kind="scalar",n.result="",n.position++,p=f=n.position;(c=n.input.charCodeAt(n.position))!==0;)if(c===39)if(xT(n,p,n.position,!0),c=n.input.charCodeAt(++n.position),c===39)p=n.position,n.position++,f=n.position;else return!0;else _6(c)?(xT(n,p,f,!0),o_e(n,Lh(n,!1,s)),p=f=n.position):n.position===n.lineStart&&oae(n)?
|
|
920
|
+
`:n===118?"\v":n===102?"\f":n===114?"\r":n===101?"\x1B":n===32?" ":n===34?'"':n===47?"/":n===92?"\\":n===78?"\x85":n===95?"\xA0":n===76?"\u2028":n===80?"\u2029":""}function cLr(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}var FTe=new Array(256),PTe=new Array(256);for(BO=0;BO<256;BO++)FTe[BO]=DTe(BO)?1:0,PTe[BO]=DTe(BO);var BO;function lLr(n,s){this.input=n,this.filename=s.filename||null,this.schema=s.schema||tLr,this.onWarning=s.onWarning||null,this.legacy=s.legacy||!1,this.json=s.json||!1,this.listener=s.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=n.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function OTe(n,s){var c={name:n.filename,buffer:n.input.slice(0,-1),position:n.position,line:n.line,column:n.position-n.lineStart};return c.snippet=eLr(c),new ATe(s,c)}function Xl(n,s){throw OTe(n,s)}function sae(n,s){n.onWarning&&n.onWarning.call(null,OTe(n,s))}var bTe={YAML:function(s,c,p){var f,_,h;s.version!==null&&Xl(s,"duplication of %YAML directive"),p.length!==1&&Xl(s,"YAML directive accepts exactly one argument"),f=/^([0-9]+)\.([0-9]+)$/.exec(p[0]),f===null&&Xl(s,"ill-formed argument of the YAML directive"),_=parseInt(f[1],10),h=parseInt(f[2],10),_!==1&&Xl(s,"unacceptable YAML version of the document"),s.version=p[0],s.checkLineBreaks=h<2,h!==1&&h!==2&&sae(s,"unsupported YAML version of the document")},TAG:function(s,c,p){var f,_;p.length!==2&&Xl(s,"TAG directive accepts exactly two arguments"),f=p[0],_=p[1],TTe.test(f)||Xl(s,"ill-formed tag handle (first argument) of the TAG directive"),DT.call(s.tagMap,f)&&Xl(s,'there is a previously declared suffix for "'+f+'" tag handle'),kTe.test(_)||Xl(s,"ill-formed tag prefix (second argument) of the TAG directive");try{_=decodeURIComponent(_)}catch(h){Xl(s,"tag prefix is malformed: "+_)}s.tagMap[f]=_}};function xT(n,s,c,p){var f,_,h,g;if(s<c){if(g=n.input.slice(s,c),p)for(f=0,_=g.length;f<_;f+=1)h=g.charCodeAt(f),h===9||32<=h&&h<=1114111||Xl(n,"expected valid JSON character");else nLr.test(g)&&Xl(n,"the stream contains non-printable characters");n.result+=g}}function ETe(n,s,c,p){var f,_,h,g;for(LO.isObject(c)||Xl(n,"cannot merge mappings; the provided source object is unacceptable"),f=Object.keys(c),h=0,g=f.length;h<g;h+=1)_=f[h],DT.call(s,_)||(s[_]=c[_],p[_]=!0)}function y$(n,s,c,p,f,_,h,g,v){var x,C;if(Array.isArray(f))for(f=Array.prototype.slice.call(f),x=0,C=f.length;x<C;x+=1)Array.isArray(f[x])&&Xl(n,"nested arrays are not supported inside keys"),typeof f=="object"&&xTe(f[x])==="[object Object]"&&(f[x]="[object Object]");if(typeof f=="object"&&xTe(f)==="[object Object]"&&(f="[object Object]"),f=String(f),s===null&&(s={}),p==="tag:yaml.org,2002:merge")if(Array.isArray(_))for(x=0,C=_.length;x<C;x+=1)ETe(n,s,_[x],c);else ETe(n,s,_,c);else!n.json&&!DT.call(c,f)&&DT.call(s,f)&&(n.line=h||n.line,n.lineStart=g||n.lineStart,n.position=v||n.position,Xl(n,"duplicated mapping key")),f==="__proto__"?Object.defineProperty(s,f,{configurable:!0,enumerable:!0,writable:!0,value:_}):s[f]=_,delete c[f];return s}function s_e(n){var s;s=n.input.charCodeAt(n.position),s===10?n.position++:s===13?(n.position++,n.input.charCodeAt(n.position)===10&&n.position++):Xl(n,"a line break is expected"),n.line+=1,n.lineStart=n.position,n.firstTabInLine=-1}function Lh(n,s,c){for(var p=0,f=n.input.charCodeAt(n.position);f!==0;){for(;RO(f);)f===9&&n.firstTabInLine===-1&&(n.firstTabInLine=n.position),f=n.input.charCodeAt(++n.position);if(s&&f===35)do f=n.input.charCodeAt(++n.position);while(f!==10&&f!==13&&f!==0);if(_6(f))for(s_e(n),f=n.input.charCodeAt(n.position),p++,n.lineIndent=0;f===32;)n.lineIndent++,f=n.input.charCodeAt(++n.position);else break}return c!==-1&&p!==0&&n.lineIndent<c&&sae(n,"deficient indentation"),p}function oae(n){var s=n.position,c;return c=n.input.charCodeAt(s),!!((c===45||c===46)&&c===n.input.charCodeAt(s+1)&&c===n.input.charCodeAt(s+2)&&(s+=3,c=n.input.charCodeAt(s),c===0||lx(c)))}function o_e(n,s){s===1?n.result+=" ":s>1&&(n.result+=LO.repeat(`
|
|
921
|
+
`,s-1))}function pLr(n,s,c){var p,f,_,h,g,v,x,C,w=n.kind,O=n.result,F;if(F=n.input.charCodeAt(n.position),lx(F)||g$(F)||F===35||F===38||F===42||F===33||F===124||F===62||F===39||F===34||F===37||F===64||F===96||(F===63||F===45)&&(f=n.input.charCodeAt(n.position+1),lx(f)||c&&g$(f)))return!1;for(n.kind="scalar",n.result="",_=h=n.position,g=!1;F!==0;){if(F===58){if(f=n.input.charCodeAt(n.position+1),lx(f)||c&&g$(f))break}else if(F===35){if(p=n.input.charCodeAt(n.position-1),lx(p))break}else{if(n.position===n.lineStart&&oae(n)||c&&g$(F))break;if(_6(F))if(v=n.line,x=n.lineStart,C=n.lineIndent,Lh(n,!1,-1),n.lineIndent>=s){g=!0,F=n.input.charCodeAt(n.position);continue}else{n.position=h,n.line=v,n.lineStart=x,n.lineIndent=C;break}}g&&(xT(n,_,h,!1),o_e(n,n.line-v),_=h=n.position,g=!1),RO(F)||(h=n.position+1),F=n.input.charCodeAt(++n.position)}return xT(n,_,h,!1),n.result?!0:(n.kind=w,n.result=O,!1)}function fLr(n,s){var c,p,f;if(c=n.input.charCodeAt(n.position),c!==39)return!1;for(n.kind="scalar",n.result="",n.position++,p=f=n.position;(c=n.input.charCodeAt(n.position))!==0;)if(c===39)if(xT(n,p,n.position,!0),c=n.input.charCodeAt(++n.position),c===39)p=n.position,n.position++,f=n.position;else return!0;else _6(c)?(xT(n,p,f,!0),o_e(n,Lh(n,!1,s)),p=f=n.position):n.position===n.lineStart&&oae(n)?Xl(n,"unexpected end of the document within a single quoted scalar"):(n.position++,f=n.position);Xl(n,"unexpected end of the stream within a single quoted scalar")}function dLr(n,s){var c,p,f,_,h,g;if(g=n.input.charCodeAt(n.position),g!==34)return!1;for(n.kind="scalar",n.result="",n.position++,c=p=n.position;(g=n.input.charCodeAt(n.position))!==0;){if(g===34)return xT(n,c,n.position,!0),n.position++,!0;if(g===92){if(xT(n,c,n.position,!0),g=n.input.charCodeAt(++n.position),_6(g))Lh(n,!1,s);else if(g<256&&FTe[g])n.result+=PTe[g],n.position++;else if((h=oLr(g))>0){for(f=h,_=0;f>0;f--)g=n.input.charCodeAt(++n.position),(h=sLr(g))>=0?_=(_<<4)+h:Xl(n,"expected hexadecimal character");n.result+=cLr(_),n.position++}else Xl(n,"unknown escape sequence");c=p=n.position}else _6(g)?(xT(n,c,p,!0),o_e(n,Lh(n,!1,s)),c=p=n.position):n.position===n.lineStart&&oae(n)?Xl(n,"unexpected end of the document within a double quoted scalar"):(n.position++,p=n.position)}Xl(n,"unexpected end of the stream within a double quoted scalar")}function _Lr(n,s){var c=!0,p,f,_,h=n.tag,g,v=n.anchor,x,C,w,O,F,P=Object.create(null),M,Z,ie,$;if($=n.input.charCodeAt(n.position),$===91)C=93,F=!1,g=[];else if($===123)C=125,F=!0,g={};else return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=g),$=n.input.charCodeAt(++n.position);$!==0;){if(Lh(n,!0,s),$=n.input.charCodeAt(n.position),$===C)return n.position++,n.tag=h,n.anchor=v,n.kind=F?"mapping":"sequence",n.result=g,!0;c?$===44&&Xl(n,"expected the node content, but found ','"):Xl(n,"missed comma between flow collection entries"),Z=M=ie=null,w=O=!1,$===63&&(x=n.input.charCodeAt(n.position+1),lx(x)&&(w=O=!0,n.position++,Lh(n,!0,s))),p=n.line,f=n.lineStart,_=n.position,v$(n,s,iae,!1,!0),Z=n.tag,M=n.result,Lh(n,!0,s),$=n.input.charCodeAt(n.position),(O||n.line===p)&&$===58&&(w=!0,$=n.input.charCodeAt(++n.position),Lh(n,!0,s),v$(n,s,iae,!1,!0),ie=n.result),F?y$(n,g,P,Z,M,ie,p,f,_):w?g.push(y$(n,null,P,Z,M,ie,p,f,_)):g.push(M),Lh(n,!0,s),$=n.input.charCodeAt(n.position),$===44?(c=!0,$=n.input.charCodeAt(++n.position)):c=!1}Xl(n,"unexpected end of the stream within a flow collection")}function hLr(n,s){var c,p,f=a_e,_=!1,h=!1,g=s,v=0,x=!1,C,w;if(w=n.input.charCodeAt(n.position),w===124)p=!1;else if(w===62)p=!0;else return!1;for(n.kind="scalar",n.result="";w!==0;)if(w=n.input.charCodeAt(++n.position),w===43||w===45)a_e===f?f=w===43?vTe:rLr:Xl(n,"repeat of a chomping mode identifier");else if((C=uLr(w))>=0)C===0?Xl(n,"bad explicit indentation width of a block scalar; it cannot be less than one"):h?Xl(n,"repeat of an indentation width identifier"):(g=s+C-1,h=!0);else break;if(RO(w)){do w=n.input.charCodeAt(++n.position);while(RO(w));if(w===35)do w=n.input.charCodeAt(++n.position);while(!_6(w)&&w!==0)}for(;w!==0;){for(s_e(n),n.lineIndent=0,w=n.input.charCodeAt(n.position);(!h||n.lineIndent<g)&&w===32;)n.lineIndent++,w=n.input.charCodeAt(++n.position);if(!h&&n.lineIndent>g&&(g=n.lineIndent),_6(w)){v++;continue}if(n.lineIndent<g){f===vTe?n.result+=LO.repeat(`
|
|
922
922
|
`,_?1+v:v):f===a_e&&_&&(n.result+=`
|
|
923
923
|
`);break}for(p?RO(w)?(x=!0,n.result+=LO.repeat(`
|
|
924
924
|
`,_?1+v:v)):x?(x=!1,n.result+=LO.repeat(`
|
|
925
925
|
`,v+1)):v===0?_&&(n.result+=" "):n.result+=LO.repeat(`
|
|
926
926
|
`,v):n.result+=LO.repeat(`
|
|
927
|
-
`,_?1+v:v),_=!0,h=!0,v=0,c=n.position;!_6(w)&&w!==0;)w=n.input.charCodeAt(++n.position);xT(n,c,n.position,!1)}return!0}function CTe(n,s){var c,p=n.tag,f=n.anchor,_=[],h,g=!1,v;if(n.firstTabInLine!==-1)return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=_),v=n.input.charCodeAt(n.position);v!==0&&(n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,
|
|
928
|
-
`),n.charCodeAt(0)===65279&&(n=n.slice(1)));var c=new lLr(n,s),p=n.indexOf("\0");for(p!==-1&&(c.position=p,
|
|
927
|
+
`,_?1+v:v),_=!0,h=!0,v=0,c=n.position;!_6(w)&&w!==0;)w=n.input.charCodeAt(++n.position);xT(n,c,n.position,!1)}return!0}function CTe(n,s){var c,p=n.tag,f=n.anchor,_=[],h,g=!1,v;if(n.firstTabInLine!==-1)return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=_),v=n.input.charCodeAt(n.position);v!==0&&(n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,Xl(n,"tab characters must not be used in indentation")),!(v!==45||(h=n.input.charCodeAt(n.position+1),!lx(h))));){if(g=!0,n.position++,Lh(n,!0,-1)&&n.lineIndent<=s){_.push(null),v=n.input.charCodeAt(n.position);continue}if(c=n.line,v$(n,s,wTe,!1,!0),_.push(n.result),Lh(n,!0,-1),v=n.input.charCodeAt(n.position),(n.line===c||n.lineIndent>s)&&v!==0)Xl(n,"bad indentation of a sequence entry");else if(n.lineIndent<s)break}return g?(n.tag=p,n.anchor=f,n.kind="sequence",n.result=_,!0):!1}function mLr(n,s,c){var p,f,_,h,g,v,x=n.tag,C=n.anchor,w={},O=Object.create(null),F=null,P=null,M=null,Z=!1,ie=!1,$;if(n.firstTabInLine!==-1)return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=w),$=n.input.charCodeAt(n.position);$!==0;){if(!Z&&n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,Xl(n,"tab characters must not be used in indentation")),p=n.input.charCodeAt(n.position+1),_=n.line,($===63||$===58)&&lx(p))$===63?(Z&&(y$(n,w,O,F,P,null,h,g,v),F=P=M=null),ie=!0,Z=!0,f=!0):Z?(Z=!1,f=!0):Xl(n,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),n.position+=1,$=p;else{if(h=n.line,g=n.lineStart,v=n.position,!v$(n,c,STe,!1,!0))break;if(n.line===_){for($=n.input.charCodeAt(n.position);RO($);)$=n.input.charCodeAt(++n.position);if($===58)$=n.input.charCodeAt(++n.position),lx($)||Xl(n,"a whitespace character is expected after the key-value separator within a block mapping"),Z&&(y$(n,w,O,F,P,null,h,g,v),F=P=M=null),ie=!0,Z=!1,f=!1,F=n.tag,P=n.result;else if(ie)Xl(n,"can not read an implicit mapping pair; a colon is missed");else return n.tag=x,n.anchor=C,!0}else if(ie)Xl(n,"can not read a block mapping entry; a multiline key may not be an implicit key");else return n.tag=x,n.anchor=C,!0}if((n.line===_||n.lineIndent>s)&&(Z&&(h=n.line,g=n.lineStart,v=n.position),v$(n,s,aae,!0,f)&&(Z?P=n.result:M=n.result),Z||(y$(n,w,O,F,P,M,h,g,v),F=P=M=null),Lh(n,!0,-1),$=n.input.charCodeAt(n.position)),(n.line===_||n.lineIndent>s)&&$!==0)Xl(n,"bad indentation of a mapping entry");else if(n.lineIndent<s)break}return Z&&y$(n,w,O,F,P,null,h,g,v),ie&&(n.tag=x,n.anchor=C,n.kind="mapping",n.result=w),ie}function gLr(n){var s,c=!1,p=!1,f,_,h;if(h=n.input.charCodeAt(n.position),h!==33)return!1;if(n.tag!==null&&Xl(n,"duplication of a tag property"),h=n.input.charCodeAt(++n.position),h===60?(c=!0,h=n.input.charCodeAt(++n.position)):h===33?(p=!0,f="!!",h=n.input.charCodeAt(++n.position)):f="!",s=n.position,c){do h=n.input.charCodeAt(++n.position);while(h!==0&&h!==62);n.position<n.length?(_=n.input.slice(s,n.position),h=n.input.charCodeAt(++n.position)):Xl(n,"unexpected end of the stream within a verbatim tag")}else{for(;h!==0&&!lx(h);)h===33&&(p?Xl(n,"tag suffix cannot contain exclamation marks"):(f=n.input.slice(s-1,n.position+1),TTe.test(f)||Xl(n,"named tag handle cannot contain such characters"),p=!0,s=n.position+1)),h=n.input.charCodeAt(++n.position);_=n.input.slice(s,n.position),aLr.test(_)&&Xl(n,"tag suffix cannot contain flow indicator characters")}_&&!kTe.test(_)&&Xl(n,"tag name cannot contain such characters: "+_);try{_=decodeURIComponent(_)}catch(g){Xl(n,"tag name is malformed: "+_)}return c?n.tag=_:DT.call(n.tagMap,f)?n.tag=n.tagMap[f]+_:f==="!"?n.tag="!"+_:f==="!!"?n.tag="tag:yaml.org,2002:"+_:Xl(n,'undeclared tag handle "'+f+'"'),!0}function yLr(n){var s,c;if(c=n.input.charCodeAt(n.position),c!==38)return!1;for(n.anchor!==null&&Xl(n,"duplication of an anchor property"),c=n.input.charCodeAt(++n.position),s=n.position;c!==0&&!lx(c)&&!g$(c);)c=n.input.charCodeAt(++n.position);return n.position===s&&Xl(n,"name of an anchor node must contain at least one character"),n.anchor=n.input.slice(s,n.position),!0}function vLr(n){var s,c,p;if(p=n.input.charCodeAt(n.position),p!==42)return!1;for(p=n.input.charCodeAt(++n.position),s=n.position;p!==0&&!lx(p)&&!g$(p);)p=n.input.charCodeAt(++n.position);return n.position===s&&Xl(n,"name of an alias node must contain at least one character"),c=n.input.slice(s,n.position),DT.call(n.anchorMap,c)||Xl(n,'unidentified alias "'+c+'"'),n.result=n.anchorMap[c],Lh(n,!0,-1),!0}function v$(n,s,c,p,f){var _,h,g,v=1,x=!1,C=!1,w,O,F,P,M,Z;if(n.listener!==null&&n.listener("open",n),n.tag=null,n.anchor=null,n.kind=null,n.result=null,_=h=g=aae===c||wTe===c,p&&Lh(n,!0,-1)&&(x=!0,n.lineIndent>s?v=1:n.lineIndent===s?v=0:n.lineIndent<s&&(v=-1)),v===1)for(;gLr(n)||yLr(n);)Lh(n,!0,-1)?(x=!0,g=_,n.lineIndent>s?v=1:n.lineIndent===s?v=0:n.lineIndent<s&&(v=-1)):g=!1;if(g&&(g=x||f),(v===1||aae===c)&&(iae===c||STe===c?M=s:M=s+1,Z=n.position-n.lineStart,v===1?g&&(CTe(n,Z)||mLr(n,Z,M))||_Lr(n,M)?C=!0:(h&&hLr(n,M)||fLr(n,M)||dLr(n,M)?C=!0:vLr(n)?(C=!0,(n.tag!==null||n.anchor!==null)&&Xl(n,"alias node should not have any properties")):pLr(n,M,iae===c)&&(C=!0,n.tag===null&&(n.tag="?")),n.anchor!==null&&(n.anchorMap[n.anchor]=n.result)):v===0&&(C=g&&CTe(n,Z))),n.tag===null)n.anchor!==null&&(n.anchorMap[n.anchor]=n.result);else if(n.tag==="?"){for(n.result!==null&&n.kind!=="scalar"&&Xl(n,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+n.kind+'"'),w=0,O=n.implicitTypes.length;w<O;w+=1)if(P=n.implicitTypes[w],P.resolve(n.result)){n.result=P.construct(n.result),n.tag=P.tag,n.anchor!==null&&(n.anchorMap[n.anchor]=n.result);break}}else if(n.tag!=="!"){if(DT.call(n.typeMap[n.kind||"fallback"],n.tag))P=n.typeMap[n.kind||"fallback"][n.tag];else for(P=null,F=n.typeMap.multi[n.kind||"fallback"],w=0,O=F.length;w<O;w+=1)if(n.tag.slice(0,F[w].tag.length)===F[w].tag){P=F[w];break}P||Xl(n,"unknown tag !<"+n.tag+">"),n.result!==null&&P.kind!==n.kind&&Xl(n,"unacceptable node kind for !<"+n.tag+'> tag; it should be "'+P.kind+'", not "'+n.kind+'"'),P.resolve(n.result,n.tag)?(n.result=P.construct(n.result,n.tag),n.anchor!==null&&(n.anchorMap[n.anchor]=n.result)):Xl(n,"cannot resolve a node with !<"+n.tag+"> explicit tag")}return n.listener!==null&&n.listener("close",n),n.tag!==null||n.anchor!==null||C}function xLr(n){var s=n.position,c,p,f,_=!1,h;for(n.version=null,n.checkLineBreaks=n.legacy,n.tagMap=Object.create(null),n.anchorMap=Object.create(null);(h=n.input.charCodeAt(n.position))!==0&&(Lh(n,!0,-1),h=n.input.charCodeAt(n.position),!(n.lineIndent>0||h!==37));){for(_=!0,h=n.input.charCodeAt(++n.position),c=n.position;h!==0&&!lx(h);)h=n.input.charCodeAt(++n.position);for(p=n.input.slice(c,n.position),f=[],p.length<1&&Xl(n,"directive name must not be less than one character in length");h!==0;){for(;RO(h);)h=n.input.charCodeAt(++n.position);if(h===35){do h=n.input.charCodeAt(++n.position);while(h!==0&&!_6(h));break}if(_6(h))break;for(c=n.position;h!==0&&!lx(h);)h=n.input.charCodeAt(++n.position);f.push(n.input.slice(c,n.position))}h!==0&&s_e(n),DT.call(bTe,p)?bTe[p](n,p,f):sae(n,'unknown document directive "'+p+'"')}if(Lh(n,!0,-1),n.lineIndent===0&&n.input.charCodeAt(n.position)===45&&n.input.charCodeAt(n.position+1)===45&&n.input.charCodeAt(n.position+2)===45?(n.position+=3,Lh(n,!0,-1)):_&&Xl(n,"directives end mark is expected"),v$(n,n.lineIndent-1,aae,!1,!0),Lh(n,!0,-1),n.checkLineBreaks&&iLr.test(n.input.slice(s,n.position))&&sae(n,"non-ASCII line breaks are interpreted as content"),n.documents.push(n.result),n.position===n.lineStart&&oae(n)){n.input.charCodeAt(n.position)===46&&(n.position+=3,Lh(n,!0,-1));return}if(n.position<n.length-1)Xl(n,"end of the stream or a document separator is expected");else return}function NTe(n,s){n=String(n),s=s||{},n.length!==0&&(n.charCodeAt(n.length-1)!==10&&n.charCodeAt(n.length-1)!==13&&(n+=`
|
|
928
|
+
`),n.charCodeAt(0)===65279&&(n=n.slice(1)));var c=new lLr(n,s),p=n.indexOf("\0");for(p!==-1&&(c.position=p,Xl(c,"null byte is not allowed in input")),c.input+="\0";c.input.charCodeAt(c.position)===32;)c.lineIndent+=1,c.position+=1;for(;c.position<c.length-1;)xLr(c);return c.documents}function DLr(n,s,c){s!==null&&typeof s=="object"&&typeof c=="undefined"&&(c=s,s=null);var p=NTe(n,c);if(typeof s!="function")return p;for(var f=0,_=p.length;f<_;f+=1)s(p[f])}function bLr(n,s){var c=NTe(n,s);if(c.length!==0){if(c.length===1)return c[0];throw new ATe("expected a single document in the stream, but found more")}}u_e.exports.loadAll=DLr;u_e.exports.load=bLr});var tke=fs((HZr,eke)=>{"use strict";var lae=h$(),pX=m$(),ELr=nae(),KTe=Object.prototype.toString,VTe=Object.prototype.hasOwnProperty,d_e=65279,CLr=9,uX=10,ALr=13,SLr=32,wLr=33,TLr=34,c_e=35,kLr=37,FLr=38,PLr=39,OLr=42,HTe=44,NLr=45,uae=58,ILr=61,BLr=62,LLr=63,RLr=64,JTe=91,GTe=93,jLr=96,zTe=123,MLr=124,WTe=125,Mg={};Mg[0]="\\0";Mg[7]="\\a";Mg[8]="\\b";Mg[9]="\\t";Mg[10]="\\n";Mg[11]="\\v";Mg[12]="\\f";Mg[13]="\\r";Mg[27]="\\e";Mg[34]='\\"';Mg[92]="\\\\";Mg[133]="\\N";Mg[160]="\\_";Mg[8232]="\\L";Mg[8233]="\\P";var qLr=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],$Lr=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function ULr(n,s){var c,p,f,_,h,g,v;if(s===null)return{};for(c={},p=Object.keys(s),f=0,_=p.length;f<_;f+=1)h=p[f],g=String(s[h]),h.slice(0,2)==="!!"&&(h="tag:yaml.org,2002:"+h.slice(2)),v=n.compiledTypeMap.fallback[h],v&&VTe.call(v.styleAliases,g)&&(g=v.styleAliases[g]),c[h]=g;return c}function KLr(n){var s,c,p;if(s=n.toString(16).toUpperCase(),n<=255)c="x",p=2;else if(n<=65535)c="u",p=4;else if(n<=4294967295)c="U",p=8;else throw new pX("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+c+lae.repeat("0",p-s.length)+s}var VLr=1,cX=2;function HLr(n){this.schema=n.schema||ELr,this.indent=Math.max(1,n.indent||2),this.noArrayIndent=n.noArrayIndent||!1,this.skipInvalid=n.skipInvalid||!1,this.flowLevel=lae.isNothing(n.flowLevel)?-1:n.flowLevel,this.styleMap=ULr(this.schema,n.styles||null),this.sortKeys=n.sortKeys||!1,this.lineWidth=n.lineWidth||80,this.noRefs=n.noRefs||!1,this.noCompatMode=n.noCompatMode||!1,this.condenseFlow=n.condenseFlow||!1,this.quotingType=n.quotingType==='"'?cX:VLr,this.forceQuotes=n.forceQuotes||!1,this.replacer=typeof n.replacer=="function"?n.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function BTe(n,s){for(var c=lae.repeat(" ",s),p=0,f=-1,_="",h,g=n.length;p<g;)f=n.indexOf(`
|
|
929
929
|
`,p),f===-1?(h=n.slice(p),p=g):(h=n.slice(p,f+1),p=f+1),h.length&&h!==`
|
|
930
930
|
`&&(_+=c),_+=h;return _}function l_e(n,s){return`
|
|
931
931
|
`+lae.repeat(" ",n.indent*s)}function JLr(n,s){var c,p,f;for(c=0,p=n.implicitTypes.length;c<p;c+=1)if(f=n.implicitTypes[c],f.resolve(s))return!0;return!1}function cae(n){return n===SLr||n===CLr}function lX(n){return 32<=n&&n<=126||161<=n&&n<=55295&&n!==8232&&n!==8233||57344<=n&&n<=65533&&n!==d_e||65536<=n&&n<=1114111}function LTe(n){return lX(n)&&n!==d_e&&n!==ALr&&n!==uX}function RTe(n,s,c){var p=LTe(n),f=p&&!cae(n);return(c?p:p&&n!==HTe&&n!==JTe&&n!==GTe&&n!==zTe&&n!==WTe)&&n!==c_e&&!(s===uae&&!f)||LTe(s)&&!cae(s)&&n===c_e||s===uae&&f}function GLr(n){return lX(n)&&n!==d_e&&!cae(n)&&n!==NLr&&n!==LLr&&n!==uae&&n!==HTe&&n!==JTe&&n!==GTe&&n!==zTe&&n!==WTe&&n!==c_e&&n!==FLr&&n!==OLr&&n!==wLr&&n!==MLr&&n!==ILr&&n!==BLr&&n!==PLr&&n!==TLr&&n!==kLr&&n!==RLr&&n!==jLr}function zLr(n){return!cae(n)&&n!==uae}function oX(n,s){var c=n.charCodeAt(s),p;return c>=55296&&c<=56319&&s+1<n.length&&(p=n.charCodeAt(s+1),p>=56320&&p<=57343)?(c-55296)*1024+p-56320+65536:c}function YTe(n){var s=/^\n* /;return s.test(n)}var XTe=1,p_e=2,QTe=3,ZTe=4,x$=5;function WLr(n,s,c,p,f,_,h,g){var v,x=0,C=null,w=!1,O=!1,F=p!==-1,P=-1,M=GLr(oX(n,0))&&zLr(oX(n,n.length-1));if(s||h)for(v=0;v<n.length;x>=65536?v+=2:v++){if(x=oX(n,v),!lX(x))return x$;M=M&&RTe(x,C,g),C=x}else{for(v=0;v<n.length;x>=65536?v+=2:v++){if(x=oX(n,v),x===uX)w=!0,F&&(O=O||v-P-1>p&&n[P+1]!==" ",P=v);else if(!lX(x))return x$;M=M&&RTe(x,C,g),C=x}O=O||F&&v-P-1>p&&n[P+1]!==" "}return!w&&!O?M&&!h&&!f(n)?XTe:_===cX?x$:p_e:c>9&&YTe(n)?x$:h?_===cX?x$:p_e:O?ZTe:QTe}function YLr(n,s,c,p,f){n.dump=function(){if(s.length===0)return n.quotingType===cX?'""':"''";if(!n.noCompatMode&&(qLr.indexOf(s)!==-1||$Lr.test(s)))return n.quotingType===cX?'"'+s+'"':"'"+s+"'";var _=n.indent*Math.max(1,c),h=n.lineWidth===-1?-1:Math.max(Math.min(n.lineWidth,40),n.lineWidth-_),g=p||n.flowLevel>-1&&c>=n.flowLevel;function v(x){return JLr(n,x)}switch(WLr(s,g,n.indent,h,v,n.quotingType,n.forceQuotes&&!p,f)){case XTe:return s;case p_e:return"'"+s.replace(/'/g,"''")+"'";case QTe:return"|"+jTe(s,n.indent)+MTe(BTe(s,_));case ZTe:return">"+jTe(s,n.indent)+MTe(BTe(XLr(s,h),_));case x$:return'"'+QLr(s,h)+'"';default:throw new pX("impossible error: invalid scalar style")}}()}function jTe(n,s){var c=YTe(n)?String(s):"",p=n[n.length-1]===`
|
|
@@ -986,15 +986,15 @@ export const {{documentName}}Model: Model<{{documentName}}Document> = model<{{do
|
|
|
986
986
|
`,v=1;v<=s.linesAfter&&!(h+v>=f.length);v++)x=ihe(n.buffer,p[h+v],f[h+v],n.position-(p[h]-p[h+v]),w),g+=fm.repeat(" ",s.indent)+ahe((n.line+v+1).toString(),C)+" | "+x.str+`
|
|
987
987
|
`;return g.replace(/\n$/,"")}var NMr=OMr,IMr=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],BMr=["scalar","sequence","mapping"];function LMr(n){var s={};return n!==null&&Object.keys(n).forEach(function(c){n[c].forEach(function(p){s[String(p)]=c})}),s}function RMr(n,s){if(s=s||{},Object.keys(s).forEach(function(c){if(IMr.indexOf(c)===-1)throw new Hy('Unknown option "'+c+'" is met in definition of "'+n+'" YAML type.')}),this.options=s,this.tag=n,this.kind=s.kind||null,this.resolve=s.resolve||function(){return!0},this.construct=s.construct||function(c){return c},this.instanceOf=s.instanceOf||null,this.predicate=s.predicate||null,this.represent=s.represent||null,this.representName=s.representName||null,this.defaultStyle=s.defaultStyle||null,this.multi=s.multi||!1,this.styleAliases=LMr(s.styleAliases||null),BMr.indexOf(this.kind)===-1)throw new Hy('Unknown kind "'+this.kind+'" is specified for "'+n+'" YAML type.')}var $2=RMr;function RFe(n,s){var c=[];return n[s].forEach(function(p){var f=c.length;c.forEach(function(_,h){_.tag===p.tag&&_.kind===p.kind&&_.multi===p.multi&&(f=h)}),c[f]=p}),c}function jMr(){var n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},s,c;function p(f){f.multi?(n.multi[f.kind].push(f),n.multi.fallback.push(f)):n[f.kind][f.tag]=n.fallback[f.tag]=f}for(s=0,c=arguments.length;s<c;s+=1)arguments[s].forEach(p);return n}function ohe(n){return this.extend(n)}ohe.prototype.extend=function(s){var c=[],p=[];if(s instanceof $2)p.push(s);else if(Array.isArray(s))p=p.concat(s);else if(s&&(Array.isArray(s.implicit)||Array.isArray(s.explicit)))s.implicit&&(c=c.concat(s.implicit)),s.explicit&&(p=p.concat(s.explicit));else throw new Hy("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");c.forEach(function(_){if(!(_ instanceof $2))throw new Hy("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(_.loadKind&&_.loadKind!=="scalar")throw new Hy("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(_.multi)throw new Hy("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),p.forEach(function(_){if(!(_ instanceof $2))throw new Hy("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var f=Object.create(ohe.prototype);return f.implicit=(this.implicit||[]).concat(c),f.explicit=(this.explicit||[]).concat(p),f.compiledImplicit=RFe(f,"implicit"),f.compiledExplicit=RFe(f,"explicit"),f.compiledTypeMap=jMr(f.compiledImplicit,f.compiledExplicit),f};var e9e=ohe,t9e=new $2("tag:yaml.org,2002:str",{kind:"scalar",construct:function(n){return n!==null?n:""}}),r9e=new $2("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(n){return n!==null?n:[]}}),n9e=new $2("tag:yaml.org,2002:map",{kind:"mapping",construct:function(n){return n!==null?n:{}}}),i9e=new e9e({explicit:[t9e,r9e,n9e]});function MMr(n){if(n===null)return!0;var s=n.length;return s===1&&n==="~"||s===4&&(n==="null"||n==="Null"||n==="NULL")}function qMr(){return null}function $Mr(n){return n===null}var a9e=new $2("tag:yaml.org,2002:null",{kind:"scalar",resolve:MMr,construct:qMr,predicate:$Mr,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function UMr(n){if(n===null)return!1;var s=n.length;return s===4&&(n==="true"||n==="True"||n==="TRUE")||s===5&&(n==="false"||n==="False"||n==="FALSE")}function KMr(n){return n==="true"||n==="True"||n==="TRUE"}function VMr(n){return Object.prototype.toString.call(n)==="[object Boolean]"}var s9e=new $2("tag:yaml.org,2002:bool",{kind:"scalar",resolve:UMr,construct:KMr,predicate:VMr,represent:{lowercase:function(n){return n?"true":"false"},uppercase:function(n){return n?"TRUE":"FALSE"},camelcase:function(n){return n?"True":"False"}},defaultStyle:"lowercase"});function HMr(n){return 48<=n&&n<=57||65<=n&&n<=70||97<=n&&n<=102}function JMr(n){return 48<=n&&n<=55}function GMr(n){return 48<=n&&n<=57}function zMr(n){if(n===null)return!1;var s=n.length,c=0,p=!1,f;if(!s)return!1;if(f=n[c],(f==="-"||f==="+")&&(f=n[++c]),f==="0"){if(c+1===s)return!0;if(f=n[++c],f==="b"){for(c++;c<s;c++)if(f=n[c],f!=="_"){if(f!=="0"&&f!=="1")return!1;p=!0}return p&&f!=="_"}if(f==="x"){for(c++;c<s;c++)if(f=n[c],f!=="_"){if(!HMr(n.charCodeAt(c)))return!1;p=!0}return p&&f!=="_"}if(f==="o"){for(c++;c<s;c++)if(f=n[c],f!=="_"){if(!JMr(n.charCodeAt(c)))return!1;p=!0}return p&&f!=="_"}}if(f==="_")return!1;for(;c<s;c++)if(f=n[c],f!=="_"){if(!GMr(n.charCodeAt(c)))return!1;p=!0}return!(!p||f==="_")}function WMr(n){var s=n,c=1,p;if(s.indexOf("_")!==-1&&(s=s.replace(/_/g,"")),p=s[0],(p==="-"||p==="+")&&(p==="-"&&(c=-1),s=s.slice(1),p=s[0]),s==="0")return 0;if(p==="0"){if(s[1]==="b")return c*parseInt(s.slice(2),2);if(s[1]==="x")return c*parseInt(s.slice(2),16);if(s[1]==="o")return c*parseInt(s.slice(2),8)}return c*parseInt(s,10)}function YMr(n){return Object.prototype.toString.call(n)==="[object Number]"&&n%1===0&&!fm.isNegativeZero(n)}var o9e=new $2("tag:yaml.org,2002:int",{kind:"scalar",resolve:zMr,construct:WMr,predicate:YMr,represent:{binary:function(n){return n>=0?"0b"+n.toString(2):"-0b"+n.toString(2).slice(1)},octal:function(n){return n>=0?"0o"+n.toString(8):"-0o"+n.toString(8).slice(1)},decimal:function(n){return n.toString(10)},hexadecimal:function(n){return n>=0?"0x"+n.toString(16).toUpperCase():"-0x"+n.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),XMr=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function QMr(n){return!(n===null||!XMr.test(n)||n[n.length-1]==="_")}function ZMr(n){var s,c;return s=n.replace(/_/g,"").toLowerCase(),c=s[0]==="-"?-1:1,"+-".indexOf(s[0])>=0&&(s=s.slice(1)),s===".inf"?c===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:s===".nan"?NaN:c*parseFloat(s,10)}var eqr=/^[-+]?[0-9]+e/;function tqr(n,s){var c;if(isNaN(n))switch(s){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===n)switch(s){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===n)switch(s){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(fm.isNegativeZero(n))return"-0.0";return c=n.toString(10),eqr.test(c)?c.replace("e",".e"):c}function rqr(n){return Object.prototype.toString.call(n)==="[object Number]"&&(n%1!==0||fm.isNegativeZero(n))}var u9e=new $2("tag:yaml.org,2002:float",{kind:"scalar",resolve:QMr,construct:ZMr,predicate:rqr,represent:tqr,defaultStyle:"lowercase"}),c9e=i9e.extend({implicit:[a9e,s9e,o9e,u9e]}),l9e=c9e,p9e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),f9e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function nqr(n){return n===null?!1:p9e.exec(n)!==null||f9e.exec(n)!==null}function iqr(n){var s,c,p,f,_,h,g,v=0,x=null,C,w,O;if(s=p9e.exec(n),s===null&&(s=f9e.exec(n)),s===null)throw new Error("Date resolve error");if(c=+s[1],p=+s[2]-1,f=+s[3],!s[4])return new Date(Date.UTC(c,p,f));if(_=+s[4],h=+s[5],g=+s[6],s[7]){for(v=s[7].slice(0,3);v.length<3;)v+="0";v=+v}return s[9]&&(C=+s[10],w=+(s[11]||0),x=(C*60+w)*6e4,s[9]==="-"&&(x=-x)),O=new Date(Date.UTC(c,p,f,_,h,g,v)),x&&O.setTime(O.getTime()-x),O}function aqr(n){return n.toISOString()}var d9e=new $2("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:nqr,construct:iqr,instanceOf:Date,represent:aqr});function sqr(n){return n==="<<"||n===null}var _9e=new $2("tag:yaml.org,2002:merge",{kind:"scalar",resolve:sqr}),fhe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
988
988
|
\r`;function oqr(n){if(n===null)return!1;var s,c,p=0,f=n.length,_=fhe;for(c=0;c<f;c++)if(s=_.indexOf(n.charAt(c)),!(s>64)){if(s<0)return!1;p+=6}return p%8===0}function uqr(n){var s,c,p=n.replace(/[\r\n=]/g,""),f=p.length,_=fhe,h=0,g=[];for(s=0;s<f;s++)s%4===0&&s&&(g.push(h>>16&255),g.push(h>>8&255),g.push(h&255)),h=h<<6|_.indexOf(p.charAt(s));return c=f%4*6,c===0?(g.push(h>>16&255),g.push(h>>8&255),g.push(h&255)):c===18?(g.push(h>>10&255),g.push(h>>2&255)):c===12&&g.push(h>>4&255),new Uint8Array(g)}function cqr(n){var s="",c=0,p,f,_=n.length,h=fhe;for(p=0;p<_;p++)p%3===0&&p&&(s+=h[c>>18&63],s+=h[c>>12&63],s+=h[c>>6&63],s+=h[c&63]),c=(c<<8)+n[p];return f=_%3,f===0?(s+=h[c>>18&63],s+=h[c>>12&63],s+=h[c>>6&63],s+=h[c&63]):f===2?(s+=h[c>>10&63],s+=h[c>>4&63],s+=h[c<<2&63],s+=h[64]):f===1&&(s+=h[c>>2&63],s+=h[c<<4&63],s+=h[64],s+=h[64]),s}function lqr(n){return Object.prototype.toString.call(n)==="[object Uint8Array]"}var h9e=new $2("tag:yaml.org,2002:binary",{kind:"scalar",resolve:oqr,construct:uqr,predicate:lqr,represent:cqr}),pqr=Object.prototype.hasOwnProperty,fqr=Object.prototype.toString;function dqr(n){if(n===null)return!0;var s=[],c,p,f,_,h,g=n;for(c=0,p=g.length;c<p;c+=1){if(f=g[c],h=!1,fqr.call(f)!=="[object Object]")return!1;for(_ in f)if(pqr.call(f,_))if(!h)h=!0;else return!1;if(!h)return!1;if(s.indexOf(_)===-1)s.push(_);else return!1}return!0}function _qr(n){return n!==null?n:[]}var m9e=new $2("tag:yaml.org,2002:omap",{kind:"sequence",resolve:dqr,construct:_qr}),hqr=Object.prototype.toString;function mqr(n){if(n===null)return!0;var s,c,p,f,_,h=n;for(_=new Array(h.length),s=0,c=h.length;s<c;s+=1){if(p=h[s],hqr.call(p)!=="[object Object]"||(f=Object.keys(p),f.length!==1))return!1;_[s]=[f[0],p[f[0]]]}return!0}function gqr(n){if(n===null)return[];var s,c,p,f,_,h=n;for(_=new Array(h.length),s=0,c=h.length;s<c;s+=1)p=h[s],f=Object.keys(p),_[s]=[f[0],p[f[0]]];return _}var g9e=new $2("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:mqr,construct:gqr}),yqr=Object.prototype.hasOwnProperty;function vqr(n){if(n===null)return!0;var s,c=n;for(s in c)if(yqr.call(c,s)&&c[s]!==null)return!1;return!0}function xqr(n){return n!==null?n:{}}var y9e=new $2("tag:yaml.org,2002:set",{kind:"mapping",resolve:vqr,construct:xqr}),dhe=l9e.extend({implicit:[d9e,_9e],explicit:[h9e,m9e,g9e,y9e]}),CT=Object.prototype.hasOwnProperty,Eae=1,v9e=2,x9e=3,Cae=4,she=1,Dqr=2,jFe=3,bqr=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Eqr=/[\x85\u2028\u2029]/,Cqr=/[,\[\]\{\}]/,D9e=/^(?:!|!!|![a-z\-]+!)$/i,b9e=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function MFe(n){return Object.prototype.toString.call(n)}function v6(n){return n===10||n===13}function UO(n){return n===9||n===32}function fx(n){return n===9||n===32||n===10||n===13}function S$(n){return n===44||n===91||n===93||n===123||n===125}function Aqr(n){var s;return 48<=n&&n<=57?n-48:(s=n|32,97<=s&&s<=102?s-97+10:-1)}function Sqr(n){return n===120?2:n===117?4:n===85?8:0}function wqr(n){return 48<=n&&n<=57?n-48:-1}function qFe(n){return n===48?"\0":n===97?"\x07":n===98?"\b":n===116||n===9?" ":n===110?`
|
|
989
|
-
`:n===118?"\v":n===102?"\f":n===114?"\r":n===101?"\x1B":n===32?" ":n===34?'"':n===47?"/":n===92?"\\":n===78?"\x85":n===95?"\xA0":n===76?"\u2028":n===80?"\u2029":""}function Tqr(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}var E9e=new Array(256),C9e=new Array(256);for($O=0;$O<256;$O++)E9e[$O]=qFe($O)?1:0,C9e[$O]=qFe($O);var $O;function kqr(n,s){this.input=n,this.filename=s.filename||null,this.schema=s.schema||dhe,this.onWarning=s.onWarning||null,this.legacy=s.legacy||!1,this.json=s.json||!1,this.listener=s.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=n.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function A9e(n,s){var c={name:n.filename,buffer:n.input.slice(0,-1),position:n.position,line:n.line,column:n.position-n.lineStart};return c.snippet=NMr(c),new Hy(s,c)}function
|
|
990
|
-
`,s-1))}function Fqr(n,s,c){var p,f,_,h,g,v,x,C,w=n.kind,O=n.result,F;if(F=n.input.charCodeAt(n.position),fx(F)||S$(F)||F===35||F===38||F===42||F===33||F===124||F===62||F===39||F===34||F===37||F===64||F===96||(F===63||F===45)&&(f=n.input.charCodeAt(n.position+1),fx(f)||c&&S$(f)))return!1;for(n.kind="scalar",n.result="",_=h=n.position,g=!1;F!==0;){if(F===58){if(f=n.input.charCodeAt(n.position+1),fx(f)||c&&S$(f))break}else if(F===35){if(p=n.input.charCodeAt(n.position-1),fx(p))break}else{if(n.position===n.lineStart&&Tae(n)||c&&S$(F))break;if(v6(F))if(v=n.line,x=n.lineStart,C=n.lineIndent,jh(n,!1,-1),n.lineIndent>=s){g=!0,F=n.input.charCodeAt(n.position);continue}else{n.position=h,n.line=v,n.lineStart=x,n.lineIndent=C;break}}g&&(ET(n,_,h,!1),hhe(n,n.line-v),_=h=n.position,g=!1),UO(F)||(h=n.position+1),F=n.input.charCodeAt(++n.position)}return ET(n,_,h,!1),n.result?!0:(n.kind=w,n.result=O,!1)}function Pqr(n,s){var c,p,f;if(c=n.input.charCodeAt(n.position),c!==39)return!1;for(n.kind="scalar",n.result="",n.position++,p=f=n.position;(c=n.input.charCodeAt(n.position))!==0;)if(c===39)if(ET(n,p,n.position,!0),c=n.input.charCodeAt(++n.position),c===39)p=n.position,n.position++,f=n.position;else return!0;else v6(c)?(ET(n,p,f,!0),hhe(n,jh(n,!1,s)),p=f=n.position):n.position===n.lineStart&&Tae(n)?
|
|
989
|
+
`:n===118?"\v":n===102?"\f":n===114?"\r":n===101?"\x1B":n===32?" ":n===34?'"':n===47?"/":n===92?"\\":n===78?"\x85":n===95?"\xA0":n===76?"\u2028":n===80?"\u2029":""}function Tqr(n){return n<=65535?String.fromCharCode(n):String.fromCharCode((n-65536>>10)+55296,(n-65536&1023)+56320)}var E9e=new Array(256),C9e=new Array(256);for($O=0;$O<256;$O++)E9e[$O]=qFe($O)?1:0,C9e[$O]=qFe($O);var $O;function kqr(n,s){this.input=n,this.filename=s.filename||null,this.schema=s.schema||dhe,this.onWarning=s.onWarning||null,this.legacy=s.legacy||!1,this.json=s.json||!1,this.listener=s.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=n.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function A9e(n,s){var c={name:n.filename,buffer:n.input.slice(0,-1),position:n.position,line:n.line,column:n.position-n.lineStart};return c.snippet=NMr(c),new Hy(s,c)}function Ql(n,s){throw A9e(n,s)}function Aae(n,s){n.onWarning&&n.onWarning.call(null,A9e(n,s))}var $Fe={YAML:function(s,c,p){var f,_,h;s.version!==null&&Ql(s,"duplication of %YAML directive"),p.length!==1&&Ql(s,"YAML directive accepts exactly one argument"),f=/^([0-9]+)\.([0-9]+)$/.exec(p[0]),f===null&&Ql(s,"ill-formed argument of the YAML directive"),_=parseInt(f[1],10),h=parseInt(f[2],10),_!==1&&Ql(s,"unacceptable YAML version of the document"),s.version=p[0],s.checkLineBreaks=h<2,h!==1&&h!==2&&Aae(s,"unsupported YAML version of the document")},TAG:function(s,c,p){var f,_;p.length!==2&&Ql(s,"TAG directive accepts exactly two arguments"),f=p[0],_=p[1],D9e.test(f)||Ql(s,"ill-formed tag handle (first argument) of the TAG directive"),CT.call(s.tagMap,f)&&Ql(s,'there is a previously declared suffix for "'+f+'" tag handle'),b9e.test(_)||Ql(s,"ill-formed tag prefix (second argument) of the TAG directive");try{_=decodeURIComponent(_)}catch(h){Ql(s,"tag prefix is malformed: "+_)}s.tagMap[f]=_}};function ET(n,s,c,p){var f,_,h,g;if(s<c){if(g=n.input.slice(s,c),p)for(f=0,_=g.length;f<_;f+=1)h=g.charCodeAt(f),h===9||32<=h&&h<=1114111||Ql(n,"expected valid JSON character");else bqr.test(g)&&Ql(n,"the stream contains non-printable characters");n.result+=g}}function UFe(n,s,c,p){var f,_,h,g;for(fm.isObject(c)||Ql(n,"cannot merge mappings; the provided source object is unacceptable"),f=Object.keys(c),h=0,g=f.length;h<g;h+=1)_=f[h],CT.call(s,_)||(s[_]=c[_],p[_]=!0)}function w$(n,s,c,p,f,_,h,g,v){var x,C;if(Array.isArray(f))for(f=Array.prototype.slice.call(f),x=0,C=f.length;x<C;x+=1)Array.isArray(f[x])&&Ql(n,"nested arrays are not supported inside keys"),typeof f=="object"&&MFe(f[x])==="[object Object]"&&(f[x]="[object Object]");if(typeof f=="object"&&MFe(f)==="[object Object]"&&(f="[object Object]"),f=String(f),s===null&&(s={}),p==="tag:yaml.org,2002:merge")if(Array.isArray(_))for(x=0,C=_.length;x<C;x+=1)UFe(n,s,_[x],c);else UFe(n,s,_,c);else!n.json&&!CT.call(c,f)&&CT.call(s,f)&&(n.line=h||n.line,n.lineStart=g||n.lineStart,n.position=v||n.position,Ql(n,"duplicated mapping key")),f==="__proto__"?Object.defineProperty(s,f,{configurable:!0,enumerable:!0,writable:!0,value:_}):s[f]=_,delete c[f];return s}function _he(n){var s;s=n.input.charCodeAt(n.position),s===10?n.position++:s===13?(n.position++,n.input.charCodeAt(n.position)===10&&n.position++):Ql(n,"a line break is expected"),n.line+=1,n.lineStart=n.position,n.firstTabInLine=-1}function jh(n,s,c){for(var p=0,f=n.input.charCodeAt(n.position);f!==0;){for(;UO(f);)f===9&&n.firstTabInLine===-1&&(n.firstTabInLine=n.position),f=n.input.charCodeAt(++n.position);if(s&&f===35)do f=n.input.charCodeAt(++n.position);while(f!==10&&f!==13&&f!==0);if(v6(f))for(_he(n),f=n.input.charCodeAt(n.position),p++,n.lineIndent=0;f===32;)n.lineIndent++,f=n.input.charCodeAt(++n.position);else break}return c!==-1&&p!==0&&n.lineIndent<c&&Aae(n,"deficient indentation"),p}function Tae(n){var s=n.position,c;return c=n.input.charCodeAt(s),!!((c===45||c===46)&&c===n.input.charCodeAt(s+1)&&c===n.input.charCodeAt(s+2)&&(s+=3,c=n.input.charCodeAt(s),c===0||fx(c)))}function hhe(n,s){s===1?n.result+=" ":s>1&&(n.result+=fm.repeat(`
|
|
990
|
+
`,s-1))}function Fqr(n,s,c){var p,f,_,h,g,v,x,C,w=n.kind,O=n.result,F;if(F=n.input.charCodeAt(n.position),fx(F)||S$(F)||F===35||F===38||F===42||F===33||F===124||F===62||F===39||F===34||F===37||F===64||F===96||(F===63||F===45)&&(f=n.input.charCodeAt(n.position+1),fx(f)||c&&S$(f)))return!1;for(n.kind="scalar",n.result="",_=h=n.position,g=!1;F!==0;){if(F===58){if(f=n.input.charCodeAt(n.position+1),fx(f)||c&&S$(f))break}else if(F===35){if(p=n.input.charCodeAt(n.position-1),fx(p))break}else{if(n.position===n.lineStart&&Tae(n)||c&&S$(F))break;if(v6(F))if(v=n.line,x=n.lineStart,C=n.lineIndent,jh(n,!1,-1),n.lineIndent>=s){g=!0,F=n.input.charCodeAt(n.position);continue}else{n.position=h,n.line=v,n.lineStart=x,n.lineIndent=C;break}}g&&(ET(n,_,h,!1),hhe(n,n.line-v),_=h=n.position,g=!1),UO(F)||(h=n.position+1),F=n.input.charCodeAt(++n.position)}return ET(n,_,h,!1),n.result?!0:(n.kind=w,n.result=O,!1)}function Pqr(n,s){var c,p,f;if(c=n.input.charCodeAt(n.position),c!==39)return!1;for(n.kind="scalar",n.result="",n.position++,p=f=n.position;(c=n.input.charCodeAt(n.position))!==0;)if(c===39)if(ET(n,p,n.position,!0),c=n.input.charCodeAt(++n.position),c===39)p=n.position,n.position++,f=n.position;else return!0;else v6(c)?(ET(n,p,f,!0),hhe(n,jh(n,!1,s)),p=f=n.position):n.position===n.lineStart&&Tae(n)?Ql(n,"unexpected end of the document within a single quoted scalar"):(n.position++,f=n.position);Ql(n,"unexpected end of the stream within a single quoted scalar")}function Oqr(n,s){var c,p,f,_,h,g;if(g=n.input.charCodeAt(n.position),g!==34)return!1;for(n.kind="scalar",n.result="",n.position++,c=p=n.position;(g=n.input.charCodeAt(n.position))!==0;){if(g===34)return ET(n,c,n.position,!0),n.position++,!0;if(g===92){if(ET(n,c,n.position,!0),g=n.input.charCodeAt(++n.position),v6(g))jh(n,!1,s);else if(g<256&&E9e[g])n.result+=C9e[g],n.position++;else if((h=Sqr(g))>0){for(f=h,_=0;f>0;f--)g=n.input.charCodeAt(++n.position),(h=Aqr(g))>=0?_=(_<<4)+h:Ql(n,"expected hexadecimal character");n.result+=Tqr(_),n.position++}else Ql(n,"unknown escape sequence");c=p=n.position}else v6(g)?(ET(n,c,p,!0),hhe(n,jh(n,!1,s)),c=p=n.position):n.position===n.lineStart&&Tae(n)?Ql(n,"unexpected end of the document within a double quoted scalar"):(n.position++,p=n.position)}Ql(n,"unexpected end of the stream within a double quoted scalar")}function Nqr(n,s){var c=!0,p,f,_,h=n.tag,g,v=n.anchor,x,C,w,O,F,P=Object.create(null),M,Z,ie,$;if($=n.input.charCodeAt(n.position),$===91)C=93,F=!1,g=[];else if($===123)C=125,F=!0,g={};else return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=g),$=n.input.charCodeAt(++n.position);$!==0;){if(jh(n,!0,s),$=n.input.charCodeAt(n.position),$===C)return n.position++,n.tag=h,n.anchor=v,n.kind=F?"mapping":"sequence",n.result=g,!0;c?$===44&&Ql(n,"expected the node content, but found ','"):Ql(n,"missed comma between flow collection entries"),Z=M=ie=null,w=O=!1,$===63&&(x=n.input.charCodeAt(n.position+1),fx(x)&&(w=O=!0,n.position++,jh(n,!0,s))),p=n.line,f=n.lineStart,_=n.position,T$(n,s,Eae,!1,!0),Z=n.tag,M=n.result,jh(n,!0,s),$=n.input.charCodeAt(n.position),(O||n.line===p)&&$===58&&(w=!0,$=n.input.charCodeAt(++n.position),jh(n,!0,s),T$(n,s,Eae,!1,!0),ie=n.result),F?w$(n,g,P,Z,M,ie,p,f,_):w?g.push(w$(n,null,P,Z,M,ie,p,f,_)):g.push(M),jh(n,!0,s),$=n.input.charCodeAt(n.position),$===44?(c=!0,$=n.input.charCodeAt(++n.position)):c=!1}Ql(n,"unexpected end of the stream within a flow collection")}function Iqr(n,s){var c,p,f=she,_=!1,h=!1,g=s,v=0,x=!1,C,w;if(w=n.input.charCodeAt(n.position),w===124)p=!1;else if(w===62)p=!0;else return!1;for(n.kind="scalar",n.result="";w!==0;)if(w=n.input.charCodeAt(++n.position),w===43||w===45)she===f?f=w===43?jFe:Dqr:Ql(n,"repeat of a chomping mode identifier");else if((C=wqr(w))>=0)C===0?Ql(n,"bad explicit indentation width of a block scalar; it cannot be less than one"):h?Ql(n,"repeat of an indentation width identifier"):(g=s+C-1,h=!0);else break;if(UO(w)){do w=n.input.charCodeAt(++n.position);while(UO(w));if(w===35)do w=n.input.charCodeAt(++n.position);while(!v6(w)&&w!==0)}for(;w!==0;){for(_he(n),n.lineIndent=0,w=n.input.charCodeAt(n.position);(!h||n.lineIndent<g)&&w===32;)n.lineIndent++,w=n.input.charCodeAt(++n.position);if(!h&&n.lineIndent>g&&(g=n.lineIndent),v6(w)){v++;continue}if(n.lineIndent<g){f===jFe?n.result+=fm.repeat(`
|
|
991
991
|
`,_?1+v:v):f===she&&_&&(n.result+=`
|
|
992
992
|
`);break}for(p?UO(w)?(x=!0,n.result+=fm.repeat(`
|
|
993
993
|
`,_?1+v:v)):x?(x=!1,n.result+=fm.repeat(`
|
|
994
994
|
`,v+1)):v===0?_&&(n.result+=" "):n.result+=fm.repeat(`
|
|
995
995
|
`,v):n.result+=fm.repeat(`
|
|
996
|
-
`,_?1+v:v),_=!0,h=!0,v=0,c=n.position;!v6(w)&&w!==0;)w=n.input.charCodeAt(++n.position);ET(n,c,n.position,!1)}return!0}function KFe(n,s){var c,p=n.tag,f=n.anchor,_=[],h,g=!1,v;if(n.firstTabInLine!==-1)return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=_),v=n.input.charCodeAt(n.position);v!==0&&(n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,
|
|
997
|
-
`),n.charCodeAt(0)===65279&&(n=n.slice(1)));var c=new kqr(n,s),p=n.indexOf("\0");for(p!==-1&&(c.position=p,
|
|
996
|
+
`,_?1+v:v),_=!0,h=!0,v=0,c=n.position;!v6(w)&&w!==0;)w=n.input.charCodeAt(++n.position);ET(n,c,n.position,!1)}return!0}function KFe(n,s){var c,p=n.tag,f=n.anchor,_=[],h,g=!1,v;if(n.firstTabInLine!==-1)return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=_),v=n.input.charCodeAt(n.position);v!==0&&(n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,Ql(n,"tab characters must not be used in indentation")),!(v!==45||(h=n.input.charCodeAt(n.position+1),!fx(h))));){if(g=!0,n.position++,jh(n,!0,-1)&&n.lineIndent<=s){_.push(null),v=n.input.charCodeAt(n.position);continue}if(c=n.line,T$(n,s,x9e,!1,!0),_.push(n.result),jh(n,!0,-1),v=n.input.charCodeAt(n.position),(n.line===c||n.lineIndent>s)&&v!==0)Ql(n,"bad indentation of a sequence entry");else if(n.lineIndent<s)break}return g?(n.tag=p,n.anchor=f,n.kind="sequence",n.result=_,!0):!1}function Bqr(n,s,c){var p,f,_,h,g,v,x=n.tag,C=n.anchor,w={},O=Object.create(null),F=null,P=null,M=null,Z=!1,ie=!1,$;if(n.firstTabInLine!==-1)return!1;for(n.anchor!==null&&(n.anchorMap[n.anchor]=w),$=n.input.charCodeAt(n.position);$!==0;){if(!Z&&n.firstTabInLine!==-1&&(n.position=n.firstTabInLine,Ql(n,"tab characters must not be used in indentation")),p=n.input.charCodeAt(n.position+1),_=n.line,($===63||$===58)&&fx(p))$===63?(Z&&(w$(n,w,O,F,P,null,h,g,v),F=P=M=null),ie=!0,Z=!0,f=!0):Z?(Z=!1,f=!0):Ql(n,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),n.position+=1,$=p;else{if(h=n.line,g=n.lineStart,v=n.position,!T$(n,c,v9e,!1,!0))break;if(n.line===_){for($=n.input.charCodeAt(n.position);UO($);)$=n.input.charCodeAt(++n.position);if($===58)$=n.input.charCodeAt(++n.position),fx($)||Ql(n,"a whitespace character is expected after the key-value separator within a block mapping"),Z&&(w$(n,w,O,F,P,null,h,g,v),F=P=M=null),ie=!0,Z=!1,f=!1,F=n.tag,P=n.result;else if(ie)Ql(n,"can not read an implicit mapping pair; a colon is missed");else return n.tag=x,n.anchor=C,!0}else if(ie)Ql(n,"can not read a block mapping entry; a multiline key may not be an implicit key");else return n.tag=x,n.anchor=C,!0}if((n.line===_||n.lineIndent>s)&&(Z&&(h=n.line,g=n.lineStart,v=n.position),T$(n,s,Cae,!0,f)&&(Z?P=n.result:M=n.result),Z||(w$(n,w,O,F,P,M,h,g,v),F=P=M=null),jh(n,!0,-1),$=n.input.charCodeAt(n.position)),(n.line===_||n.lineIndent>s)&&$!==0)Ql(n,"bad indentation of a mapping entry");else if(n.lineIndent<s)break}return Z&&w$(n,w,O,F,P,null,h,g,v),ie&&(n.tag=x,n.anchor=C,n.kind="mapping",n.result=w),ie}function Lqr(n){var s,c=!1,p=!1,f,_,h;if(h=n.input.charCodeAt(n.position),h!==33)return!1;if(n.tag!==null&&Ql(n,"duplication of a tag property"),h=n.input.charCodeAt(++n.position),h===60?(c=!0,h=n.input.charCodeAt(++n.position)):h===33?(p=!0,f="!!",h=n.input.charCodeAt(++n.position)):f="!",s=n.position,c){do h=n.input.charCodeAt(++n.position);while(h!==0&&h!==62);n.position<n.length?(_=n.input.slice(s,n.position),h=n.input.charCodeAt(++n.position)):Ql(n,"unexpected end of the stream within a verbatim tag")}else{for(;h!==0&&!fx(h);)h===33&&(p?Ql(n,"tag suffix cannot contain exclamation marks"):(f=n.input.slice(s-1,n.position+1),D9e.test(f)||Ql(n,"named tag handle cannot contain such characters"),p=!0,s=n.position+1)),h=n.input.charCodeAt(++n.position);_=n.input.slice(s,n.position),Cqr.test(_)&&Ql(n,"tag suffix cannot contain flow indicator characters")}_&&!b9e.test(_)&&Ql(n,"tag name cannot contain such characters: "+_);try{_=decodeURIComponent(_)}catch(g){Ql(n,"tag name is malformed: "+_)}return c?n.tag=_:CT.call(n.tagMap,f)?n.tag=n.tagMap[f]+_:f==="!"?n.tag="!"+_:f==="!!"?n.tag="tag:yaml.org,2002:"+_:Ql(n,'undeclared tag handle "'+f+'"'),!0}function Rqr(n){var s,c;if(c=n.input.charCodeAt(n.position),c!==38)return!1;for(n.anchor!==null&&Ql(n,"duplication of an anchor property"),c=n.input.charCodeAt(++n.position),s=n.position;c!==0&&!fx(c)&&!S$(c);)c=n.input.charCodeAt(++n.position);return n.position===s&&Ql(n,"name of an anchor node must contain at least one character"),n.anchor=n.input.slice(s,n.position),!0}function jqr(n){var s,c,p;if(p=n.input.charCodeAt(n.position),p!==42)return!1;for(p=n.input.charCodeAt(++n.position),s=n.position;p!==0&&!fx(p)&&!S$(p);)p=n.input.charCodeAt(++n.position);return n.position===s&&Ql(n,"name of an alias node must contain at least one character"),c=n.input.slice(s,n.position),CT.call(n.anchorMap,c)||Ql(n,'unidentified alias "'+c+'"'),n.result=n.anchorMap[c],jh(n,!0,-1),!0}function T$(n,s,c,p,f){var _,h,g,v=1,x=!1,C=!1,w,O,F,P,M,Z;if(n.listener!==null&&n.listener("open",n),n.tag=null,n.anchor=null,n.kind=null,n.result=null,_=h=g=Cae===c||x9e===c,p&&jh(n,!0,-1)&&(x=!0,n.lineIndent>s?v=1:n.lineIndent===s?v=0:n.lineIndent<s&&(v=-1)),v===1)for(;Lqr(n)||Rqr(n);)jh(n,!0,-1)?(x=!0,g=_,n.lineIndent>s?v=1:n.lineIndent===s?v=0:n.lineIndent<s&&(v=-1)):g=!1;if(g&&(g=x||f),(v===1||Cae===c)&&(Eae===c||v9e===c?M=s:M=s+1,Z=n.position-n.lineStart,v===1?g&&(KFe(n,Z)||Bqr(n,Z,M))||Nqr(n,M)?C=!0:(h&&Iqr(n,M)||Pqr(n,M)||Oqr(n,M)?C=!0:jqr(n)?(C=!0,(n.tag!==null||n.anchor!==null)&&Ql(n,"alias node should not have any properties")):Fqr(n,M,Eae===c)&&(C=!0,n.tag===null&&(n.tag="?")),n.anchor!==null&&(n.anchorMap[n.anchor]=n.result)):v===0&&(C=g&&KFe(n,Z))),n.tag===null)n.anchor!==null&&(n.anchorMap[n.anchor]=n.result);else if(n.tag==="?"){for(n.result!==null&&n.kind!=="scalar"&&Ql(n,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+n.kind+'"'),w=0,O=n.implicitTypes.length;w<O;w+=1)if(P=n.implicitTypes[w],P.resolve(n.result)){n.result=P.construct(n.result),n.tag=P.tag,n.anchor!==null&&(n.anchorMap[n.anchor]=n.result);break}}else if(n.tag!=="!"){if(CT.call(n.typeMap[n.kind||"fallback"],n.tag))P=n.typeMap[n.kind||"fallback"][n.tag];else for(P=null,F=n.typeMap.multi[n.kind||"fallback"],w=0,O=F.length;w<O;w+=1)if(n.tag.slice(0,F[w].tag.length)===F[w].tag){P=F[w];break}P||Ql(n,"unknown tag !<"+n.tag+">"),n.result!==null&&P.kind!==n.kind&&Ql(n,"unacceptable node kind for !<"+n.tag+'> tag; it should be "'+P.kind+'", not "'+n.kind+'"'),P.resolve(n.result,n.tag)?(n.result=P.construct(n.result,n.tag),n.anchor!==null&&(n.anchorMap[n.anchor]=n.result)):Ql(n,"cannot resolve a node with !<"+n.tag+"> explicit tag")}return n.listener!==null&&n.listener("close",n),n.tag!==null||n.anchor!==null||C}function Mqr(n){var s=n.position,c,p,f,_=!1,h;for(n.version=null,n.checkLineBreaks=n.legacy,n.tagMap=Object.create(null),n.anchorMap=Object.create(null);(h=n.input.charCodeAt(n.position))!==0&&(jh(n,!0,-1),h=n.input.charCodeAt(n.position),!(n.lineIndent>0||h!==37));){for(_=!0,h=n.input.charCodeAt(++n.position),c=n.position;h!==0&&!fx(h);)h=n.input.charCodeAt(++n.position);for(p=n.input.slice(c,n.position),f=[],p.length<1&&Ql(n,"directive name must not be less than one character in length");h!==0;){for(;UO(h);)h=n.input.charCodeAt(++n.position);if(h===35){do h=n.input.charCodeAt(++n.position);while(h!==0&&!v6(h));break}if(v6(h))break;for(c=n.position;h!==0&&!fx(h);)h=n.input.charCodeAt(++n.position);f.push(n.input.slice(c,n.position))}h!==0&&_he(n),CT.call($Fe,p)?$Fe[p](n,p,f):Aae(n,'unknown document directive "'+p+'"')}if(jh(n,!0,-1),n.lineIndent===0&&n.input.charCodeAt(n.position)===45&&n.input.charCodeAt(n.position+1)===45&&n.input.charCodeAt(n.position+2)===45?(n.position+=3,jh(n,!0,-1)):_&&Ql(n,"directives end mark is expected"),T$(n,n.lineIndent-1,Cae,!1,!0),jh(n,!0,-1),n.checkLineBreaks&&Eqr.test(n.input.slice(s,n.position))&&Aae(n,"non-ASCII line breaks are interpreted as content"),n.documents.push(n.result),n.position===n.lineStart&&Tae(n)){n.input.charCodeAt(n.position)===46&&(n.position+=3,jh(n,!0,-1));return}if(n.position<n.length-1)Ql(n,"end of the stream or a document separator is expected");else return}function S9e(n,s){n=String(n),s=s||{},n.length!==0&&(n.charCodeAt(n.length-1)!==10&&n.charCodeAt(n.length-1)!==13&&(n+=`
|
|
997
|
+
`),n.charCodeAt(0)===65279&&(n=n.slice(1)));var c=new kqr(n,s),p=n.indexOf("\0");for(p!==-1&&(c.position=p,Ql(c,"null byte is not allowed in input")),c.input+="\0";c.input.charCodeAt(c.position)===32;)c.lineIndent+=1,c.position+=1;for(;c.position<c.length-1;)Mqr(c);return c.documents}function qqr(n,s,c){s!==null&&typeof s=="object"&&typeof c=="undefined"&&(c=s,s=null);var p=S9e(n,c);if(typeof s!="function")return p;for(var f=0,_=p.length;f<_;f+=1)s(p[f])}function $qr(n,s){var c=S9e(n,s);if(c.length!==0){if(c.length===1)return c[0];throw new Hy("expected a single document in the stream, but found more")}}var Uqr=qqr,Kqr=$qr,w9e={loadAll:Uqr,load:Kqr},T9e=Object.prototype.toString,k9e=Object.prototype.hasOwnProperty,mhe=65279,Vqr=9,vX=10,Hqr=13,Jqr=32,Gqr=33,zqr=34,uhe=35,Wqr=37,Yqr=38,Xqr=39,Qqr=42,F9e=44,Zqr=45,Sae=58,e$r=61,t$r=62,r$r=63,n$r=64,P9e=91,O9e=93,i$r=96,N9e=123,a$r=124,I9e=125,$g={};$g[0]="\\0";$g[7]="\\a";$g[8]="\\b";$g[9]="\\t";$g[10]="\\n";$g[11]="\\v";$g[12]="\\f";$g[13]="\\r";$g[27]="\\e";$g[34]='\\"';$g[92]="\\\\";$g[133]="\\N";$g[160]="\\_";$g[8232]="\\L";$g[8233]="\\P";var s$r=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],o$r=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function u$r(n,s){var c,p,f,_,h,g,v;if(s===null)return{};for(c={},p=Object.keys(s),f=0,_=p.length;f<_;f+=1)h=p[f],g=String(s[h]),h.slice(0,2)==="!!"&&(h="tag:yaml.org,2002:"+h.slice(2)),v=n.compiledTypeMap.fallback[h],v&&k9e.call(v.styleAliases,g)&&(g=v.styleAliases[g]),c[h]=g;return c}function c$r(n){var s,c,p;if(s=n.toString(16).toUpperCase(),n<=255)c="x",p=2;else if(n<=65535)c="u",p=4;else if(n<=4294967295)c="U",p=8;else throw new Hy("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+c+fm.repeat("0",p-s.length)+s}var l$r=1,xX=2;function p$r(n){this.schema=n.schema||dhe,this.indent=Math.max(1,n.indent||2),this.noArrayIndent=n.noArrayIndent||!1,this.skipInvalid=n.skipInvalid||!1,this.flowLevel=fm.isNothing(n.flowLevel)?-1:n.flowLevel,this.styleMap=u$r(this.schema,n.styles||null),this.sortKeys=n.sortKeys||!1,this.lineWidth=n.lineWidth||80,this.noRefs=n.noRefs||!1,this.noCompatMode=n.noCompatMode||!1,this.condenseFlow=n.condenseFlow||!1,this.quotingType=n.quotingType==='"'?xX:l$r,this.forceQuotes=n.forceQuotes||!1,this.replacer=typeof n.replacer=="function"?n.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function VFe(n,s){for(var c=fm.repeat(" ",s),p=0,f=-1,_="",h,g=n.length;p<g;)f=n.indexOf(`
|
|
998
998
|
`,p),f===-1?(h=n.slice(p),p=g):(h=n.slice(p,f+1),p=f+1),h.length&&h!==`
|
|
999
999
|
`&&(_+=c),_+=h;return _}function che(n,s){return`
|
|
1000
1000
|
`+fm.repeat(" ",n.indent*s)}function f$r(n,s){var c,p,f;for(c=0,p=n.implicitTypes.length;c<p;c+=1)if(f=n.implicitTypes[c],f.resolve(s))return!0;return!1}function wae(n){return n===Jqr||n===Vqr}function DX(n){return 32<=n&&n<=126||161<=n&&n<=55295&&n!==8232&&n!==8233||57344<=n&&n<=65533&&n!==mhe||65536<=n&&n<=1114111}function HFe(n){return DX(n)&&n!==mhe&&n!==Hqr&&n!==vX}function JFe(n,s,c){var p=HFe(n),f=p&&!wae(n);return(c?p:p&&n!==F9e&&n!==P9e&&n!==O9e&&n!==N9e&&n!==I9e)&&n!==uhe&&!(s===Sae&&!f)||HFe(s)&&!wae(s)&&n===uhe||s===Sae&&f}function d$r(n){return DX(n)&&n!==mhe&&!wae(n)&&n!==Zqr&&n!==r$r&&n!==Sae&&n!==F9e&&n!==P9e&&n!==O9e&&n!==N9e&&n!==I9e&&n!==uhe&&n!==Yqr&&n!==Qqr&&n!==Gqr&&n!==a$r&&n!==e$r&&n!==t$r&&n!==Xqr&&n!==zqr&&n!==Wqr&&n!==n$r&&n!==i$r}function _$r(n){return!wae(n)&&n!==Sae}function gX(n,s){var c=n.charCodeAt(s),p;return c>=55296&&c<=56319&&s+1<n.length&&(p=n.charCodeAt(s+1),p>=56320&&p<=57343)?(c-55296)*1024+p-56320+65536:c}function B9e(n){var s=/^\n* /;return s.test(n)}var L9e=1,lhe=2,R9e=3,j9e=4,A$=5;function h$r(n,s,c,p,f,_,h,g){var v,x=0,C=null,w=!1,O=!1,F=p!==-1,P=-1,M=d$r(gX(n,0))&&_$r(gX(n,n.length-1));if(s||h)for(v=0;v<n.length;x>=65536?v+=2:v++){if(x=gX(n,v),!DX(x))return A$;M=M&&JFe(x,C,g),C=x}else{for(v=0;v<n.length;x>=65536?v+=2:v++){if(x=gX(n,v),x===vX)w=!0,F&&(O=O||v-P-1>p&&n[P+1]!==" ",P=v);else if(!DX(x))return A$;M=M&&JFe(x,C,g),C=x}O=O||F&&v-P-1>p&&n[P+1]!==" "}return!w&&!O?M&&!h&&!f(n)?L9e:_===xX?A$:lhe:c>9&&B9e(n)?A$:h?_===xX?A$:lhe:O?j9e:R9e}function m$r(n,s,c,p,f){n.dump=function(){if(s.length===0)return n.quotingType===xX?'""':"''";if(!n.noCompatMode&&(s$r.indexOf(s)!==-1||o$r.test(s)))return n.quotingType===xX?'"'+s+'"':"'"+s+"'";var _=n.indent*Math.max(1,c),h=n.lineWidth===-1?-1:Math.max(Math.min(n.lineWidth,40),n.lineWidth-_),g=p||n.flowLevel>-1&&c>=n.flowLevel;function v(x){return f$r(n,x)}switch(h$r(s,g,n.indent,h,v,n.quotingType,n.forceQuotes&&!p,f)){case L9e:return s;case lhe:return"'"+s.replace(/'/g,"''")+"'";case R9e:return"|"+GFe(s,n.indent)+zFe(VFe(s,_));case j9e:return">"+GFe(s,n.indent)+zFe(VFe(g$r(s,h),_));case A$:return'"'+y$r(s)+'"';default:throw new Hy("impossible error: invalid scalar style")}}()}function GFe(n,s){var c=B9e(n)?String(s):"",p=n[n.length-1]===`
|
|
@@ -1009,7 +1009,7 @@ export const {{documentName}}Model: Model<{{documentName}}Document> = model<{{do
|
|
|
1009
1009
|
`+n.slice(f,_),f=_+1),h=g;return v+=`
|
|
1010
1010
|
`,n.length-f>s&&h>f?v+=n.slice(f,h)+`
|
|
1011
1011
|
`+n.slice(h+1):v+=n.slice(f),v.slice(1)}function y$r(n){for(var s="",c=0,p,f=0;f<n.length;c>=65536?f+=2:f++)c=gX(n,f),p=$g[c],!p&&DX(c)?(s+=n[f],c>=65536&&(s+=n[f+1])):s+=p||c$r(c);return s}function v$r(n,s,c){var p="",f=n.tag,_,h,g;for(_=0,h=c.length;_<h;_+=1)g=c[_],n.replacer&&(g=n.replacer.call(c,String(_),g)),(JS(n,s,g,!1,!1)||typeof g=="undefined"&&JS(n,s,null,!1,!1))&&(p!==""&&(p+=","+(n.condenseFlow?"":" ")),p+=n.dump);n.tag=f,n.dump="["+p+"]"}function YFe(n,s,c,p){var f="",_=n.tag,h,g,v;for(h=0,g=c.length;h<g;h+=1)v=c[h],n.replacer&&(v=n.replacer.call(c,String(h),v)),(JS(n,s+1,v,!0,!0,!1,!0)||typeof v=="undefined"&&JS(n,s+1,null,!0,!0,!1,!0))&&((!p||f!=="")&&(f+=che(n,s)),n.dump&&vX===n.dump.charCodeAt(0)?f+="-":f+="- ",f+=n.dump);n.tag=_,n.dump=f||"[]"}function x$r(n,s,c){var p="",f=n.tag,_=Object.keys(c),h,g,v,x,C;for(h=0,g=_.length;h<g;h+=1)C="",p!==""&&(C+=", "),n.condenseFlow&&(C+='"'),v=_[h],x=c[v],n.replacer&&(x=n.replacer.call(c,v,x)),JS(n,s,v,!1,!1)&&(n.dump.length>1024&&(C+="? "),C+=n.dump+(n.condenseFlow?'"':"")+":"+(n.condenseFlow?"":" "),JS(n,s,x,!1,!1)&&(C+=n.dump,p+=C));n.tag=f,n.dump="{"+p+"}"}function D$r(n,s,c,p){var f="",_=n.tag,h=Object.keys(c),g,v,x,C,w,O;if(n.sortKeys===!0)h.sort();else if(typeof n.sortKeys=="function")h.sort(n.sortKeys);else if(n.sortKeys)throw new Hy("sortKeys must be a boolean or a function");for(g=0,v=h.length;g<v;g+=1)O="",(!p||f!=="")&&(O+=che(n,s)),x=h[g],C=c[x],n.replacer&&(C=n.replacer.call(c,x,C)),JS(n,s+1,x,!0,!0,!0)&&(w=n.tag!==null&&n.tag!=="?"||n.dump&&n.dump.length>1024,w&&(n.dump&&vX===n.dump.charCodeAt(0)?O+="?":O+="? "),O+=n.dump,w&&(O+=che(n,s)),JS(n,s+1,C,!0,w)&&(n.dump&&vX===n.dump.charCodeAt(0)?O+=":":O+=": ",O+=n.dump,f+=O));n.tag=_,n.dump=f||"{}"}function XFe(n,s,c){var p,f,_,h,g,v;for(f=c?n.explicitTypes:n.implicitTypes,_=0,h=f.length;_<h;_+=1)if(g=f[_],(g.instanceOf||g.predicate)&&(!g.instanceOf||typeof s=="object"&&s instanceof g.instanceOf)&&(!g.predicate||g.predicate(s))){if(c?g.multi&&g.representName?n.tag=g.representName(s):n.tag=g.tag:n.tag="?",g.represent){if(v=n.styleMap[g.tag]||g.defaultStyle,T9e.call(g.represent)==="[object Function]")p=g.represent(s,v);else if(k9e.call(g.represent,v))p=g.represent[v](s,v);else throw new Hy("!<"+g.tag+'> tag resolver accepts not "'+v+'" style');n.dump=p}return!0}return!1}function JS(n,s,c,p,f,_,h){n.tag=null,n.dump=c,XFe(n,c,!1)||XFe(n,c,!0);var g=T9e.call(n.dump),v=p,x;p&&(p=n.flowLevel<0||n.flowLevel>s);var C=g==="[object Object]"||g==="[object Array]",w,O;if(C&&(w=n.duplicates.indexOf(c),O=w!==-1),(n.tag!==null&&n.tag!=="?"||O||n.indent!==2&&s>0)&&(f=!1),O&&n.usedDuplicates[w])n.dump="*ref_"+w;else{if(C&&O&&!n.usedDuplicates[w]&&(n.usedDuplicates[w]=!0),g==="[object Object]")p&&Object.keys(n.dump).length!==0?(D$r(n,s,n.dump,f),O&&(n.dump="&ref_"+w+n.dump)):(x$r(n,s,n.dump),O&&(n.dump="&ref_"+w+" "+n.dump));else if(g==="[object Array]")p&&n.dump.length!==0?(n.noArrayIndent&&!h&&s>0?YFe(n,s-1,n.dump,f):YFe(n,s,n.dump,f),O&&(n.dump="&ref_"+w+n.dump)):(v$r(n,s,n.dump),O&&(n.dump="&ref_"+w+" "+n.dump));else if(g==="[object String]")n.tag!=="?"&&m$r(n,n.dump,s,_,v);else{if(g==="[object Undefined]")return!1;if(n.skipInvalid)return!1;throw new Hy("unacceptable kind of an object to dump "+g)}n.tag!==null&&n.tag!=="?"&&(x=encodeURI(n.tag[0]==="!"?n.tag.slice(1):n.tag).replace(/!/g,"%21"),n.tag[0]==="!"?x="!"+x:x.slice(0,18)==="tag:yaml.org,2002:"?x="!!"+x.slice(18):x="!<"+x+">",n.dump=x+" "+n.dump)}return!0}function b$r(n,s){var c=[],p=[],f,_;for(phe(n,c,p),f=0,_=p.length;f<_;f+=1)s.duplicates.push(c[p[f]]);s.usedDuplicates=new Array(_)}function phe(n,s,c){var p,f,_;if(n!==null&&typeof n=="object")if(f=s.indexOf(n),f!==-1)c.indexOf(f)===-1&&c.push(f);else if(s.push(n),Array.isArray(n))for(f=0,_=n.length;f<_;f+=1)phe(n[f],s,c);else for(p=Object.keys(n),f=0,_=p.length;f<_;f+=1)phe(n[p[f]],s,c)}function E$r(n,s){s=s||{};var c=new p$r(s);c.noRefs||b$r(n,c);var p=n;return c.replacer&&(p=c.replacer.call({"":p},"",p)),JS(c,0,p,!0,!0)?c.dump+`
|
|
1012
|
-
`:""}var C$r=E$r,A$r={dump:C$r};function ghe(n,s){return function(){throw new Error("Function yaml."+n+" is removed in js-yaml 4. Use yaml."+s+" instead, which is now safe by default.")}}var S$r=$2,w$r=e9e,T$r=i9e,k$r=c9e,F$r=l9e,P$r=dhe,O$r=w9e.load,N$r=w9e.loadAll,I$r=A$r.dump,B$r=Hy,L$r={binary:h9e,float:u9e,map:n9e,null:a9e,pairs:g9e,set:y9e,timestamp:d9e,bool:s9e,int:o9e,merge:_9e,omap:m9e,seq:r9e,str:t9e},R$r=ghe("safeLoad","load"),j$r=ghe("safeLoadAll","loadAll"),M$r=ghe("safeDump","dump"),q$r={Type:S$r,Schema:w$r,FAILSAFE_SCHEMA:T$r,JSON_SCHEMA:k$r,CORE_SCHEMA:F$r,DEFAULT_SCHEMA:P$r,load:O$r,loadAll:N$r,dump:I$r,YAMLException:B$r,types:L$r,safeLoad:R$r,safeLoadAll:j$r,safeDump:M$r},kae=q$r;var L3=S_(require("fs")),Pae=S_(require("path"));function $$r(n,...s){console.log("\x1B[34m%s\x1B[0m","[PROCESSING]",n,s.length>0?s:"")}function U$r(n,...s){console.log("\x1B[32m%s\x1B[0m","[WRITING]",n,s.length>0?s:"")}function K$r(n,...s){console.log("\x1B[36m%s\x1B[0m","[INFO]",n,s.length>0?s:"")}function V$r(n,...s){console.log("\x1B[33m%s\x1B[0m","[WARN]",n,s.length>0?s:"")}function H$r(n,...s){console.log("\x1B[41m%s\x1B[0m","[ERROR]",n,s.length>0?s:""),process.exit(1)}var
|
|
1012
|
+
`:""}var C$r=E$r,A$r={dump:C$r};function ghe(n,s){return function(){throw new Error("Function yaml."+n+" is removed in js-yaml 4. Use yaml."+s+" instead, which is now safe by default.")}}var S$r=$2,w$r=e9e,T$r=i9e,k$r=c9e,F$r=l9e,P$r=dhe,O$r=w9e.load,N$r=w9e.loadAll,I$r=A$r.dump,B$r=Hy,L$r={binary:h9e,float:u9e,map:n9e,null:a9e,pairs:g9e,set:y9e,timestamp:d9e,bool:s9e,int:o9e,merge:_9e,omap:m9e,seq:r9e,str:t9e},R$r=ghe("safeLoad","load"),j$r=ghe("safeLoadAll","loadAll"),M$r=ghe("safeDump","dump"),q$r={Type:S$r,Schema:w$r,FAILSAFE_SCHEMA:T$r,JSON_SCHEMA:k$r,CORE_SCHEMA:F$r,DEFAULT_SCHEMA:P$r,load:O$r,loadAll:N$r,dump:I$r,YAMLException:B$r,types:L$r,safeLoad:R$r,safeLoadAll:j$r,safeDump:M$r},kae=q$r;var L3=S_(require("fs")),Pae=S_(require("path"));function $$r(n,...s){console.log("\x1B[34m%s\x1B[0m","[PROCESSING]",n,s.length>0?s:"")}function U$r(n,...s){console.log("\x1B[32m%s\x1B[0m","[WRITING]",n,s.length>0?s:"")}function K$r(n,...s){console.log("\x1B[36m%s\x1B[0m","[INFO]",n,s.length>0?s:"")}function V$r(n,...s){console.log("\x1B[33m%s\x1B[0m","[WARN]",n,s.length>0?s:"")}function H$r(n,...s){console.log("\x1B[41m%s\x1B[0m","[ERROR]",n,s.length>0?s:""),process.exit(1)}var Yl={process:$$r,writing:U$r,info:K$r,warn:V$r,error:H$r};var k$={name:"very-express",version:"0.5.14",description:"based on json schema and openapi, generate Express RestApi server with mongoDb ",author:"Justin26l",license:"MIT",main:"index.js",bin:{vex:"./dist/index.js"},scripts:{start:"node ./dist/index.js",dev:"npm run compile && npm run start",build:"npm run lint && npm run compile",lint:"eslint ./src --ext .ts --fix",compile:"node ./scripts/build.js && node ./scripts/copyTsTemplates.js"},keywords:["jsonSchema","express","RestApi","mongoDb","mongoose","json2mongoose"],repository:{type:"git",url:"git+https://github.com/Justin26l/VeryExpress.git"},devDependencies:{"@types/js-yaml":"^4.0.9","@types/minimist":"^1.2.5","@types/ms":"^2.1.0","@types/node":"^20.10.5","@types/passport":"^1.0.16","@typescript-eslint/eslint-plugin":"^6.18.1","@typescript-eslint/parser":"^6.18.1","diff-match-patch":"^1.0.5",dotenv:"^16.3.1",esbuild:"0.23.0",eslint:"^8.57.1","js-yaml":"^4.1.0","json-schema-to-openapi-schema":"^0.4.0","json-schema-to-typescript":"^13.1.1",json2mongoose:"^0.4.8",minimist:"^1.2.8",mongoose:"^8.7.1","ts-node":"^10.9.2",typescript:"^5.3.3"}};function yhe(n){return`/**
|
|
1013
1013
|
* Generated by veryExpress@${n}
|
|
1014
1014
|
* https://github.com/Justin26l/VeryExpress
|
|
1015
1015
|
*/
|
|
@@ -1017,10 +1017,10 @@ export const {{documentName}}Model: Model<{{documentName}}Document> = model<{{do
|
|
|
1017
1017
|
* Generated by veryExpress
|
|
1018
1018
|
* https://github.com/Justin26l/VeryExpress
|
|
1019
1019
|
*/
|
|
1020
|
-
`}function z$r(){return`// Generated by veryExpress@${k$.version}`}function W$r(){return"// Generated by veryExpress"}function Fae(n){return Object.keys(n.
|
|
1021
|
-
`).replace(/[ \t]+$/gm,"").trim()}var X$r=(n,s)=>Pae.default.relative(n,s).replace(/\\/g,"/");function Q$r(n,s){let c=L3.default.existsSync(n);if(!c&&s)return s();if(c)try{let p=JSON.parse(L3.default.readFileSync(n,"utf8"));return p||
|
|
1022
|
-
`,p.message)}else return
|
|
1023
|
-
`,s.message||s,n)}}function G9e(n,s){let c=JSON.parse(JSON.stringify(n)),p=Array.isArray(s),f=p?s:[],_=p?{}:s;for(let h in c)h.startsWith("x-")||p&&f.includes(h)||!p&&typeof _[h]!="undefined"&&_[h]==typeof c[h]?delete c[h]:typeof c[h]=="object"&&(c[h]=G9e(c[h],s));return c}function nUr(n,s){if(n=="getList")return"get";if(Oae.includes(n))return n;Ql.error(`httpMethod : invalid method "${n}" in "${s}".`),process.exit(1)}var z9e={cleanXcustomValue:G9e,httpMethod:nUr,loadJsonSchema:rUr};function iUr(n){if(!n)throw new Error("vex.config is undefined");if(!n.srcDir)throw new Error("vex.config.srcDir is undefined");if(!n.sysDir)throw new Error("vex.config.sysDir is undefined");if(!n.openapiDir)throw new Error("vex.config.openapiDir is undefined");if(!n.jsonSchemaDir)throw new Error("vex.config.jsonSchemaDir is undefined")}var W9e={checkConfigValid:iUr};var Wc={common:V9e,generator:M9e,template:H9e,jsonSchema:z9e,logger:Ql,configChecker:W9e};function X9e(n,s){return wp(this,null,function*(){let c={openapi:"3.0.0",info:{title:"veryExpress generated api server",description:"OpenApi Spec generated by veryExpress",version:"1.0.0"},paths:{},components:{securitySchemes:{},schemas:{}}};Wc.generator.isOAuthEnabled(s)&&(c.components.securitySchemes={BearerAuth:{type:"http",scheme:"bearer",bearerFormat:"JWT"},AuthIndex:{type:"apiKey",in:"header",name:"X-Auth-Index"}}),Ehe.default.readdirSync(s.jsonSchemaDir).forEach(g=>{if(!g.endsWith(".json"))return;let v=Y9e.default.posix.join(s.jsonSchemaDir,g);Ql.process(`OpenApi : ${v}`);let x=Ehe.default.readFileSync(`${s.jsonSchemaDir}/${g}`),C=JSON.parse(x.toString());c=aUr(c,C,{jsonSchemaFilePath:v},s),c=sUr(c,C,{jsonSchemaFilePath:v},s)});let f=(0,F$.default)(c,{version:3}),_=kae.dump(f),h=s.openapiDir+n;Wc.common.writeFile("OpenApi",h,_)})}function aUr(n,s,c,p){let f=s["x-documentConfig"],_=f.documentName.toLowerCase(),h=f.documentName,g=[{BearerAuth:[]},{AuthIndex:[]}],v=s.properties,x={["/api/"+_]:{"x-documentName":h},["/api/"+_+"/{id}"]:{"x-documentName":h}};return f.methods.forEach(C=>{let w=["get","put","patch","delete"].includes(C),O=["post","put","patch"].includes(C),F="/api/"+_+(w?"/{id}":""),P=Wc.jsonSchema.httpMethod(C,c),M=[],Z,ie={200:{description:"OK",content:{"application/json":{schema:{$ref:`#/components/schemas/${P}${h}Response`}}}}};if(w&&v._id){let $={name:"id",in:"path",description:v._id.description,required:!0,schema:{type:v._id.type,format:v._id.format,"x-format":v._id["x-format"],minLength:v._id.minLength,maxLength:v._id.maxLength,minimum:v._id.minimum,maximum:v._id.maximum,enum:v._id.enum}};M.push($)}P=="post"?(ie[201]=Object.assign({},ie[200]),ie[201].description="Crerated",delete ie[200]):P=="delete"&&delete ie[200].content,O&&(Z={description:`${P} ${f.documentName}`,required:!1,content:{"application/json":{schema:{$ref:`#/components/schemas/${P}${h}Body`}}}}),x[F][P]={operationId:C+h,tags:[_],security:Wc.generator.isOAuthEnabled(p)?g:void 0,parameters:M,requestBody:Z,responses:Object.assign({400:{description:"Bad Request"},401:{description:"Unauthorized"},403:{description:"Forbidden"},404:{description:"Not Found"},405:{description:"Method Not Allowed"},413:{description:"Payload Too Large"},429:{description:"Too Many Requests"},500:{description:"Internal Server Error"},502:{description:"Bad Gateway"},503:{description:"Service Unavailable"}},ie)}}),n.paths=Object.assign(n.paths,x),n}function sUr(n,s,c,p){let f={},_=s["x-documentConfig"],h=_.documentName.toLowerCase(),g=_.documentName,v={type:"object",properties:(0,F$.default)(Wc.jsonSchema.cleanXcustomValue(s.properties,["index","unique","required"]),{version:3})},x={type:"object",properties:(0,F$.default)(Wc.jsonSchema.cleanXcustomValue(s.properties,{index:"boolean",unique:"boolean",required:"boolean"}),{version:3}),required:s.required},C={type:"object",properties:(0,F$.default)(Wc.jsonSchema.cleanXcustomValue(x.properties,{_id:"object"}),{version:3}),required:s.required},w={type:"object",properties:(0,F$.default)(Wc.jsonSchema.cleanXcustomValue(C.properties,["required"]),{version:3})};return _.methods.forEach(O=>{let F=Wc.jsonSchema.httpMethod(O,c);switch(O){case"delete":break;case"get":f[F+g+"Response"]=v;break;case"getList":{let P=[];Object.keys(s.properties).forEach(M=>{let Z=s.properties[M];if(Z.type!="object")switch(Z.type=="array"&&(Z.type="string"),P.push({name:M,in:"query",required:!1,schema:{type:Z.type,format:Z.format,"x-format":Z["x-format"],minLength:Z.minLength,maxLength:Z.maxLength,minimum:Z.minimum,maximum:Z.maximum,enum:Z.enum}}),Z["x-format"]){case"minMax":P.push({name:"min_"+M,in:"query",required:!1,schema:{type:Z.type,format:Z.format,"x-format":Z["x-format"],minLength:Z.minLength,maxLength:Z.maxLength,minimum:Z.minimum,maximum:Z.maximum,enum:Z.enum}}),P.push({name:"max_"+M,in:"query",required:!1,schema:{type:Z.type,format:Z.format,"x-format":Z["x-format"],minLength:Z.minLength,maxLength:Z.maxLength,minimum:Z.minimum,maximum:Z.maximum,enum:Z.enum}});break;default:break}}),n.paths["/api/"+h][F].parameters=P,f[F+g+"Response"]=v,f[F+g+"ResponseList"]={type:"array",items:v};break}case"patch":f[F+g+"Body"]=w,f[F+g+"Response"]=v;break;case"post":f[F+g+"Body"]=p.app.allowApiCreateUpdate_id?x:C,f[F+g+"Response"]=v;break;case"put":f[F+g+"Body"]=p.app.allowApiCreateUpdate_id?x:C,f[F+g+"Response"]=v;break;default:break}}),n.components.schemas=Object.assign(n.components.schemas,f),n}function Q9e(n,s){var f;let c=((f=n.split("/").pop())==null?void 0:f.split(".")[0])||"Unknown_File_Name",p=Wc.jsonSchema.loadJsonSchema(n);return p["x-documentConfig"]||Ql.error(`Json Schema Formatting: "${n}" x-documentConfig not found.`),p["x-documentConfig"].documentName||(Ql.warn(`Json Schema Formatting: "${n}" x-documentConfig.documentName added.`),p["x-documentConfig"].documentName=c),p["x-documentConfig"].methods||(Ql.warn(`Json Schema Formatting: "${n}" x-documentConfig.methods not found, supported methods added.`),p["x-documentConfig"].methods=Object.assign([],J9e)),p["x-documentConfig"].documentName!=c&&Ql.error(`Json Schema Formatting: "${n}" x-documentConfig.documentName is not consistant with file name.`),typeof p.properties!="object"&&Ql.error(`properties is invalid in ${n}`),s.app.useObjectID&&uUr(p,n),p.required=Che(p,n),Wc.common.writeFile("Json Schema Formatting",n,JSON.stringify(p,null,4)),p}function Che(n,s){let c,p=[],f=_=>!!(_.type=="array"&&_.items&&_.items.type=="object");if(f(n))c=n.items.properties,p=typeof n.items.required=="object"?n.items.required:[];else if(n.type=="object")c=n.properties,p=typeof n.required=="object"?n.required:[];else return;return c==null?Ql.error(`formatJsonSchema > formatRequired : invalid "schema.properties" in ${s}`,n):Object.keys(c).forEach(_=>{let h=c==null?void 0:c[_],g=!p.includes(_);h&&h.type!=="object"&&h.required===!0&&g?p.push(_):h&&h.items&&f(h)?h.items.required=Che(h.items,s):h&&h.type=="object"&&(h.required=Che(h,s),h.required&&h.required.length>0&&g&&p.push(_))}),p}function uUr(n,s){n.properties&&!n.properties._id&&(n.properties._id={type:"string",description:"Unique Identifier",example:"60c8c9d2b2b4f2c3e8d6f3e1"},Ql.info(`formatJsonSchema : "_id" field added to ${s}`))}var Z9e=S_(require("fs"));function ePe(n){var c;if(!n.compilerOptions.useRBAC)return;let s=["create","read","update","delete"];(c=n.compilerOptions.useRBAC)==null||c.roles.forEach(p=>{Ql.process(`Role Setting File : ${p}`);let f=`${n.roleSetupDir}/${p}.json`,_={};Z9e.default.existsSync(f)&&Object.assign(_,Wc.common.loadJson(f)),n.collectionList.forEach(h=>{_[h]||(_[h]=s)}),Wc.common.writeFile(`Role Setting File : ${f}`,f,JSON.stringify(_,null,4))})}function tPe(n){var s;n.compilerOptions.useRBAC&&((s=n.compilerOptions.useRBAC)==null||s.schemaIncluded.forEach(c=>{var _,h;Ql.process(`Schema Role Formatting : ${c}.json`);let p=`${n.compilerOptions.jsonSchemaDir}/${c}.json`,f=Wc.common.loadJson(p);for(let g in f.properties){let v=f.properties[g];if(v["x-vexData"]==="role"){v.type="array",v.default=[(_=n.compilerOptions.useRBAC)==null?void 0:_.default],v.items||(v.items={type:""}),v.items.type="string",v.items.enum=(h=n.compilerOptions.useRBAC)==null?void 0:h.roles;break}}Wc.common.writeFile("Schema Role Formatting",p,JSON.stringify(f,null,4))}))}function rPe(n){return wp(this,null,function*(){if(!n.compilerOptions.app.useUserSchema)return;Ql.process("UserSchmea");let s=`${n.compilerOptions.jsonSchemaDir}/User.json`,c=Wc.common.loadJson(__dirname+"/templates/jsonSchema/User.json"),p=Wc.common.loadJson(s,()=>c);Object.keys(c.properties).forEach(f=>{var _,h;p.properties[f]||(p.properties[f]=c.properties[f]),((_=p.properties[f])==null?void 0:_["x-vexData"])=="role"&&(p.properties[f].items.enum=((h=n.compilerOptions.useRBAC)==null?void 0:h.roles)||["user"])}),Wc.common.writeFile("UserSchmea",s,JSON.stringify(p,null,4))})}var She=S_(require("path"));var Ahe=S_(require("fs"));var nPe={main:"index.js",scripts:{build:"tsc -p . && node scripts/build.js",start:"node dist/server.js",dev:"nodemon --watch src --exec ts-node src/server.ts","docker-build":"docker build -t very-express .","docker-start":"docker run -p 3000:3000 very-express"},dependencies:{cookie:"^0.6.0","cookie-parser":"^1.4.6",dotenv:"^16.4.4",express:"^4.18.2","express-validator":"^7.0.1",helmet:"^7.1.0","js-yaml":"^4.1.0",jsonwebtoken:"^9.0.2","mongo-ts-querystring":"^1.0.4",mongodb:"^5.6.0",mongoose:"^7.4.0",passport:"^0.7.0","passport-google-oauth20":"^2.0.0","passport-github":"^1.1.0","passport-jwt":"^4.0.1","swagger-ui-express":"^5.0.0"},devDependencies:{"@types/cookie-parser":"^1.4.7","@types/jsonwebtoken":"^9.0.7","@types/crypto-js":"^4.1.2","@types/dotenv":"^8.2.0","@types/express":"^4.17.17","@types/express-validator":"^3.0.0","@types/js-yaml":"^4.0.9","@types/mongodb":"^4.0.7","@types/ms":"^2.1.0","@types/node":"^20.4.2","@types/passport":"^1.0.16","@types/passport-google-oauth20":"^2.0.14","@types/passport-github":"^1.1.12","@types/sequelize":"^4.28.15","@types/swagger-ui-express":"^4.1.6","@types/ws":"^8.5.5",nodemon:"^2.0.22","strip-json-comments":"^5.0.1","ts-node":"^10.9.1",typescript:"^5.1.6"}};function pUr(n,s){return wp(this,null,function*(){Ql.process(`Project Settings : ${n}`);let c="";Ahe.default.existsSync(n)?c=Ahe.default.readFileSync(n).toString():c=JSON.stringify(nPe);let p=JSON.parse(c);p.scripts.build||(Ql.process(`package.json : Update script : build > ${p.scripts.build}`),p.scripts.build="tsc -p . && node scripts/build.js"),p.scripts.dev||(Ql.process(`package.json : Update script : dev > ${p.scripts.dev}`),p.scripts.dev=`nodemon --watch src --exec ts-node ${s.srcDir}/server.ts`),p.scripts.start||(Ql.process(`package.json : Update script : start > ${p.scripts.start}`),p.scripts.start="node ./dist/server.js"),Wc.common.writeFile(`Project Settings : ${n}`,n,JSON.stringify(p,null,4))})}var iPe={compile:pUr};var aPe=S_(require("fs")),sPe=S_(require("path"));function fUr(n){return wp(this,null,function*(){let s=aPe.default.readFileSync(__dirname+"/templates/root/scripts/build.js","utf8"),c=Wc.common.relativePath(n.rootDir,n.openapiDir);s=s.replace("{{openapiDir}}",c),Wc.common.writeFile("Build Scripts",sPe.default.join(n.rootDir,"scripts/build.js"),s)})}var oPe={compile:fUr};var Nae=S_(require("fs"));function dUr(n){return wp(this,null,function*(){Ql.process(`Project Settings : ${n}`);let s="",c=Nae.default.readFileSync(__dirname+"/templates/_projectSettings/env","utf8");if(console.log(`Processing .env file at ${n}`),!Nae.default.existsSync(n))s=c;else{s=Nae.default.readFileSync(n,"utf-8");let p=[],f=[],_=[];s.split(`
|
|
1020
|
+
`}function z$r(){return`// Generated by veryExpress@${k$.version}`}function W$r(){return"// Generated by veryExpress"}function Fae(n){return Object.keys(n.auth.oauthProviders).filter(s=>n.auth.oauthProviders[s]===!0)}function bX(n){return Fae(n).length>0}var vhe={rootDir:".",srcDir:"./src",sysDir:"./src/system",jsonSchemaDir:"./jsonSchema",openapiDir:"./openapi",generator:{commitBeforeGenerate:!1},app:{enableSwagger:!0,useUserSchema:!0,useStatefulRedisAuth:!1,useObjectID:!0,allowApiCreateUpdate_id:!1},useRBAC:{roles:["user"],default:"user",schemaIncluded:["user"]},auth:{localAuth:!0,useHttpOnlyCookieToken:!1,oauthProviders:{google:!1,microsoft:!1,apple:!1,github:!1}},_:{writtedDir:[]}},M9e={defaultCompilerOptions:vhe,getDefaultHeaderComment:yhe,getStaticHeaderComment:G$r,getSimpleHeaderComment:z$r,getSimpleStaticHeaderComment:W$r,OAuthProviders:Fae,isOAuthEnabled:bX};var $9e=vhe,Y$r=yhe(k$.version);function q9e(n){return n.replace(/\r\n/g,`
|
|
1021
|
+
`).replace(/[ \t]+$/gm,"").trim()}var X$r=(n,s)=>Pae.default.relative(n,s).replace(/\\/g,"/");function Q$r(n,s){let c=L3.default.existsSync(n);if(!c&&s)return s();if(c)try{let p=JSON.parse(L3.default.readFileSync(n,"utf8"));return p||Yl.error(`FILE JSON : Read Error ${n}`)}catch(p){return Yl.error(`FILE : ${n}
|
|
1022
|
+
`,p.message)}else return Yl.error(`FILE : ${n} not found`)}function U9e(n,s,c){let p=L3.default.existsSync(s)?L3.default.readFileSync(s,"utf8"):"",f=/\/\*\*\s*\r?\n \* Generated by veryExpress@[^\r\n]+\r?\n \* https:\/\/github\.com\/Justin26l\/VeryExpress\s*\r?\n \*\/\s*/g,_=q9e(p.replace(f,"")),h=/^.*({{headerComment}}|\/\/ {{headerComment}}).*$(\r?\n)?/gm,g=q9e(c.replace(h,""));return _===g?!1:(Yl.writing(`${n} : "${s}"`),c=c.replace(/\/\/ {{headerComment}}|{{headerComment}}/g,Y$r||"// generated files by very-express"),L3.default.writeFileSync(s,c),!0)}function K9e(n,s,c,p){L3.default.existsSync(s)||L3.default.mkdirSync(s);let f=L3.default.readdirSync(n);for(let _=0;_<f.length;_++){let h=Pae.default.posix.join(n,f[_]),g=Pae.default.posix.join(s,f[_].replace(".ts",".gen.ts"));if(L3.default.lstatSync(h).isDirectory())K9e(h,g,c,p);else if(!p&&L3.default.existsSync(g))Yl.info(`FILE : AVOID OVERWRITE, skip "${g}"`);else{let v=L3.default.readFileSync(h,"utf8");U9e(`FILE : ${g}`,g,v)}}}function Z$r(n){$9e=n}function eUr(){return $9e}var V9e={relativePath:X$r,copyDir:K9e,loadJson:Q$r,writeFile:U9e,setCompilerOptions:Z$r,getCompilerOptions:eUr};function tUr(n){let s=/'FUNC{{(.*?)}}'/g,c;for(c=s.exec(n);c!=null;)n=n.replace(c[0],c[1]),c=s.exec(n);return n}var H9e={format:tUr};var bhe=S_(require("fs"));var J9e=["get","getList","post","put","patch","delete","options","head","trace"],Oae=["get","post","put","patch","delete","options","head","trace"];function rUr(n){if(!bhe.default.existsSync(n))return Yl.error(`loadJsonSchema : File Not Found ${n}`);try{return JSON.parse(bhe.default.readFileSync(n,"utf8"))}catch(s){return Yl.error(`Error Load JsonSchema :
|
|
1023
|
+
`,s.message||s,n)}}function G9e(n,s){let c=JSON.parse(JSON.stringify(n)),p=Array.isArray(s),f=p?s:[],_=p?{}:s;for(let h in c)h.startsWith("x-")||p&&f.includes(h)||!p&&typeof _[h]!="undefined"&&_[h]==typeof c[h]?delete c[h]:typeof c[h]=="object"&&(c[h]=G9e(c[h],s));return c}function nUr(n,s){if(n=="getList")return"get";if(Oae.includes(n))return n;Yl.error(`httpMethod : invalid method "${n}" in "${s}".`),process.exit(1)}var z9e={cleanXcustomValue:G9e,httpMethod:nUr,loadJsonSchema:rUr};function iUr(n){if(!n)throw new Error("vex.config is undefined");if(!n.srcDir)throw new Error("vex.config.srcDir is undefined");if(!n.sysDir)throw new Error("vex.config.sysDir is undefined");if(!n.openapiDir)throw new Error("vex.config.openapiDir is undefined");if(!n.jsonSchemaDir)throw new Error("vex.config.jsonSchemaDir is undefined")}var W9e={checkConfigValid:iUr};var Wc={common:V9e,generator:M9e,template:H9e,jsonSchema:z9e,logger:Yl,configChecker:W9e};function X9e(n,s){return wp(this,null,function*(){let c={openapi:"3.0.0",info:{title:"veryExpress generated api server",description:"OpenApi Spec generated by veryExpress",version:"1.0.0"},paths:{},components:{securitySchemes:{},schemas:{}}};Wc.generator.isOAuthEnabled(s)&&(c.components.securitySchemes={BearerAuth:{type:"http",scheme:"bearer",bearerFormat:"JWT"},AuthIndex:{type:"apiKey",in:"header",name:"X-Auth-Index"}}),Ehe.default.readdirSync(s.jsonSchemaDir).forEach(g=>{if(!g.endsWith(".json"))return;let v=Y9e.default.posix.join(s.jsonSchemaDir,g);Yl.process(`OpenApi : ${v}`);let x=Ehe.default.readFileSync(`${s.jsonSchemaDir}/${g}`),C=JSON.parse(x.toString());c=aUr(c,C,{jsonSchemaFilePath:v},s),c=sUr(c,C,{jsonSchemaFilePath:v},s)});let f=(0,F$.default)(c,{version:3}),_=kae.dump(f),h=s.openapiDir+n;Wc.common.writeFile("OpenApi",h,_)})}function aUr(n,s,c,p){let f=s["x-documentConfig"],_=f.documentName.toLowerCase(),h=f.documentName,g=[{BearerAuth:[]},{AuthIndex:[]}],v=s.properties,x={["/api/"+_]:{"x-documentName":h},["/api/"+_+"/{id}"]:{"x-documentName":h}};return f.methods.forEach(C=>{let w=["get","put","patch","delete"].includes(C),O=["post","put","patch"].includes(C),F="/api/"+_+(w?"/{id}":""),P=Wc.jsonSchema.httpMethod(C,c),M=[],Z,ie={200:{description:"OK",content:{"application/json":{schema:{$ref:`#/components/schemas/${P}${h}Response`}}}}};if(w&&v._id){let $={name:"id",in:"path",description:v._id.description,required:!0,schema:{type:v._id.type,format:v._id.format,"x-format":v._id["x-format"],minLength:v._id.minLength,maxLength:v._id.maxLength,minimum:v._id.minimum,maximum:v._id.maximum,enum:v._id.enum}};M.push($)}P=="post"?(ie[201]=Object.assign({},ie[200]),ie[201].description="Crerated",delete ie[200]):P=="delete"&&delete ie[200].content,O&&(Z={description:`${P} ${f.documentName}`,required:!1,content:{"application/json":{schema:{$ref:`#/components/schemas/${P}${h}Body`}}}}),x[F][P]={operationId:C+h,tags:[_],security:Wc.generator.isOAuthEnabled(p)?g:void 0,parameters:M,requestBody:Z,responses:Object.assign({400:{description:"Bad Request"},401:{description:"Unauthorized"},403:{description:"Forbidden"},404:{description:"Not Found"},405:{description:"Method Not Allowed"},413:{description:"Payload Too Large"},429:{description:"Too Many Requests"},500:{description:"Internal Server Error"},502:{description:"Bad Gateway"},503:{description:"Service Unavailable"}},ie)}}),n.paths=Object.assign(n.paths,x),n}function sUr(n,s,c,p){let f={},_=s["x-documentConfig"],h=_.documentName.toLowerCase(),g=_.documentName,v={type:"object",properties:(0,F$.default)(Wc.jsonSchema.cleanXcustomValue(s.properties,["index","unique","required"]),{version:3})},x={type:"object",properties:(0,F$.default)(Wc.jsonSchema.cleanXcustomValue(s.properties,{index:"boolean",unique:"boolean",required:"boolean"}),{version:3}),required:s.required},C={type:"object",properties:(0,F$.default)(Wc.jsonSchema.cleanXcustomValue(x.properties,{_id:"object"}),{version:3}),required:s.required},w={type:"object",properties:(0,F$.default)(Wc.jsonSchema.cleanXcustomValue(C.properties,["required"]),{version:3})};return _.methods.forEach(O=>{let F=Wc.jsonSchema.httpMethod(O,c);switch(O){case"delete":break;case"get":f[F+g+"Response"]=v;break;case"getList":{let P=[];Object.keys(s.properties).forEach(M=>{let Z=s.properties[M];if(Z.type!="object")switch(Z.type=="array"&&(Z.type="string"),P.push({name:M,in:"query",required:!1,schema:{type:Z.type,format:Z.format,"x-format":Z["x-format"],minLength:Z.minLength,maxLength:Z.maxLength,minimum:Z.minimum,maximum:Z.maximum,enum:Z.enum}}),Z["x-format"]){case"minMax":P.push({name:"min_"+M,in:"query",required:!1,schema:{type:Z.type,format:Z.format,"x-format":Z["x-format"],minLength:Z.minLength,maxLength:Z.maxLength,minimum:Z.minimum,maximum:Z.maximum,enum:Z.enum}}),P.push({name:"max_"+M,in:"query",required:!1,schema:{type:Z.type,format:Z.format,"x-format":Z["x-format"],minLength:Z.minLength,maxLength:Z.maxLength,minimum:Z.minimum,maximum:Z.maximum,enum:Z.enum}});break;default:break}}),n.paths["/api/"+h][F].parameters=P,f[F+g+"Response"]=v,f[F+g+"ResponseList"]={type:"array",items:v};break}case"patch":f[F+g+"Body"]=w,f[F+g+"Response"]=v;break;case"post":f[F+g+"Body"]=p.app.allowApiCreateUpdate_id?x:C,f[F+g+"Response"]=v;break;case"put":f[F+g+"Body"]=p.app.allowApiCreateUpdate_id?x:C,f[F+g+"Response"]=v;break;default:break}}),n.components.schemas=Object.assign(n.components.schemas,f),n}function Q9e(n,s){var f;let c=((f=n.split("/").pop())==null?void 0:f.split(".")[0])||"Unknown_File_Name",p=Wc.jsonSchema.loadJsonSchema(n);return p["x-documentConfig"]||Yl.error(`Json Schema Formatting: "${n}" x-documentConfig not found.`),p["x-documentConfig"].documentName||(Yl.warn(`Json Schema Formatting: "${n}" x-documentConfig.documentName added.`),p["x-documentConfig"].documentName=c),p["x-documentConfig"].methods||(Yl.warn(`Json Schema Formatting: "${n}" x-documentConfig.methods not found, supported methods added.`),p["x-documentConfig"].methods=Object.assign([],J9e)),p["x-documentConfig"].documentName!=c&&Yl.error(`Json Schema Formatting: "${n}" x-documentConfig.documentName is not consistant with file name.`),typeof p.properties!="object"&&Yl.error(`properties is invalid in ${n}`),s.app.useObjectID&&uUr(p,n),p.required=Che(p,n),Wc.common.writeFile("Json Schema Formatting",n,JSON.stringify(p,null,4)),p}function Che(n,s){let c,p=[],f=_=>!!(_.type=="array"&&_.items&&_.items.type=="object");if(f(n))c=n.items.properties,p=typeof n.items.required=="object"?n.items.required:[];else if(n.type=="object")c=n.properties,p=typeof n.required=="object"?n.required:[];else return;return c==null?Yl.error(`formatJsonSchema > formatRequired : invalid "schema.properties" in ${s}`,n):Object.keys(c).forEach(_=>{let h=c==null?void 0:c[_],g=!p.includes(_);h&&h.type!=="object"&&h.required===!0&&g?p.push(_):h&&h.items&&f(h)?h.items.required=Che(h.items,s):h&&h.type=="object"&&(h.required=Che(h,s),h.required&&h.required.length>0&&g&&p.push(_))}),p}function uUr(n,s){n.properties&&!n.properties._id&&(n.properties._id={type:"string",description:"Unique Identifier",example:"60c8c9d2b2b4f2c3e8d6f3e1"},Yl.info(`formatJsonSchema : "_id" field added to ${s}`))}var Z9e=S_(require("fs"));function ePe(n){var c;if(!n.compilerOptions.useRBAC)return;let s=["create","read","update","delete"];(c=n.compilerOptions.useRBAC)==null||c.roles.forEach(p=>{Yl.process(`Role Setting File : ${p}`);let f=`${n.roleSetupDir}/${p}.json`,_={};Z9e.default.existsSync(f)&&Object.assign(_,Wc.common.loadJson(f)),n.collectionList.forEach(h=>{_[h]||(_[h]=s)}),Wc.common.writeFile(`Role Setting File : ${f}`,f,JSON.stringify(_,null,4))})}function tPe(n){var s;n.compilerOptions.useRBAC&&((s=n.compilerOptions.useRBAC)==null||s.schemaIncluded.forEach(c=>{var _,h;Yl.process(`Schema Role Formatting : ${c}.json`);let p=`${n.compilerOptions.jsonSchemaDir}/${c}.json`,f=Wc.common.loadJson(p);for(let g in f.properties){let v=f.properties[g];if(v["x-vexData"]==="role"){v.type="array",v.default=[(_=n.compilerOptions.useRBAC)==null?void 0:_.default],v.items||(v.items={type:""}),v.items.type="string",v.items.enum=(h=n.compilerOptions.useRBAC)==null?void 0:h.roles;break}}Wc.common.writeFile("Schema Role Formatting",p,JSON.stringify(f,null,4))}))}function rPe(n){return wp(this,null,function*(){if(!n.compilerOptions.app.useUserSchema)return;Yl.process("UserSchmea");let s=`${n.compilerOptions.jsonSchemaDir}/User.json`,c=Wc.common.loadJson(__dirname+"/templates/jsonSchema/User.json"),p=Wc.common.loadJson(s,()=>c);Object.keys(c.properties).forEach(f=>{var _,h;p.properties[f]||(p.properties[f]=c.properties[f]),((_=p.properties[f])==null?void 0:_["x-vexData"])=="role"&&(p.properties[f].items.enum=((h=n.compilerOptions.useRBAC)==null?void 0:h.roles)||["user"])}),Wc.common.writeFile("UserSchmea",s,JSON.stringify(p,null,4))})}var She=S_(require("path"));var Ahe=S_(require("fs"));var nPe={main:"index.js",scripts:{build:"tsc -p . && node scripts/build.js",start:"node dist/server.js",dev:"nodemon --watch src --exec ts-node src/server.ts","docker-build":"docker build -t very-express .","docker-start":"docker run -p 3000:3000 very-express"},dependencies:{cookie:"^0.6.0","cookie-parser":"^1.4.6",dotenv:"^16.4.4",express:"^4.18.2","express-validator":"^7.0.1",helmet:"^7.1.0","js-yaml":"^4.1.0",jsonwebtoken:"^9.0.2","mongo-ts-querystring":"^1.0.4",mongodb:"^5.6.0",mongoose:"^7.4.0",passport:"^0.7.0","passport-google-oauth20":"^2.0.0","passport-github":"^1.1.0","passport-jwt":"^4.0.1","swagger-ui-express":"^5.0.0"},devDependencies:{"@types/cookie-parser":"^1.4.7","@types/jsonwebtoken":"^9.0.7","@types/crypto-js":"^4.1.2","@types/dotenv":"^8.2.0","@types/express":"^4.17.17","@types/express-validator":"^3.0.0","@types/js-yaml":"^4.0.9","@types/mongodb":"^4.0.7","@types/ms":"^2.1.0","@types/node":"^20.4.2","@types/passport":"^1.0.16","@types/passport-google-oauth20":"^2.0.14","@types/passport-github":"^1.1.12","@types/sequelize":"^4.28.15","@types/swagger-ui-express":"^4.1.6","@types/ws":"^8.5.5",nodemon:"^2.0.22","strip-json-comments":"^5.0.1","ts-node":"^10.9.1",typescript:"^5.1.6"}};function pUr(n,s){return wp(this,null,function*(){Yl.process(`Project Settings : ${n}`);let c="";Ahe.default.existsSync(n)?c=Ahe.default.readFileSync(n).toString():c=JSON.stringify(nPe);let p=JSON.parse(c);p.scripts.build||(Yl.process(`package.json : Update script : build > ${p.scripts.build}`),p.scripts.build="tsc -p . && node scripts/build.js"),p.scripts.dev||(Yl.process(`package.json : Update script : dev > ${p.scripts.dev}`),p.scripts.dev=`nodemon --watch src --exec ts-node ${s.srcDir}/server.ts`),p.scripts.start||(Yl.process(`package.json : Update script : start > ${p.scripts.start}`),p.scripts.start="node ./dist/server.js"),Wc.common.writeFile(`Project Settings : ${n}`,n,JSON.stringify(p,null,4))})}var iPe={compile:pUr};var aPe=S_(require("fs")),sPe=S_(require("path"));function fUr(n){return wp(this,null,function*(){let s=aPe.default.readFileSync(__dirname+"/templates/root/scripts/build.js","utf8"),c=Wc.common.relativePath(n.rootDir,n.openapiDir);s=s.replace("{{openapiDir}}",c),Wc.common.writeFile("Build Scripts",sPe.default.join(n.rootDir,"scripts/build.js"),s)})}var oPe={compile:fUr};var Nae=S_(require("fs"));function dUr(n){return wp(this,null,function*(){Yl.process(`Project Settings : ${n}`);let s="",c=Nae.default.readFileSync(__dirname+"/templates/_projectSettings/env","utf8");if(console.log(`Processing .env file at ${n}`),!Nae.default.existsSync(n))s=c;else{s=Nae.default.readFileSync(n,"utf-8");let p=[],f=[],_=[];s.split(`
|
|
1024
1024
|
`).forEach(h=>{if(!/=/g.test(h))return;let g=h.split("=",2)[0];g&&p.push(g)}),c.split(`
|
|
1025
1025
|
`).forEach(h=>{if(!/=/g.test(h))return;let g=h.split("=",2)[0];g&&f.push(g)}),f.forEach(h=>{p.includes(h)||_.push(h)}),_.length>0&&(s+=`
|
|
1026
1026
|
|
|
@@ -1040,7 +1040,7 @@ export default class Role{{role}} extends roleFactory._RoleFactory<accessAction{
|
|
|
1040
1040
|
`;return s=s.replace(/{{role}}/g,n.role),s=s.replace(/{{roleContent}}/g,JSON.stringify(n.roleContent,null,4)),s=s.replace(/{{RoleAccessActionString}}/g,n.RoleAccessActionString.join(" | ")),s}var lPe=["create","read","update","delete"];function The(n){let s=n.template||`{{headerComment}}
|
|
1041
1041
|
import { Request, Response, NextFunction } from "express";
|
|
1042
1042
|
import * as roles from "../_roles";
|
|
1043
|
-
import
|
|
1043
|
+
import utils from "../_utils";
|
|
1044
1044
|
import log from "../_utils/logger.gen";
|
|
1045
1045
|
|
|
1046
1046
|
export { roles };
|
|
@@ -1074,10 +1074,10 @@ export default class RoleBaseAccessControl {
|
|
|
1074
1074
|
catch (e: any) {
|
|
1075
1075
|
log.errorNoExit(e);
|
|
1076
1076
|
if (typeof e === 'number') {
|
|
1077
|
-
|
|
1077
|
+
utils.response.send(res, e);
|
|
1078
1078
|
}
|
|
1079
1079
|
else {
|
|
1080
|
-
|
|
1080
|
+
utils.response.send(res, 500, { message: e.errorMessages });
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
1083
1083
|
}
|
|
@@ -1086,14 +1086,14 @@ export default class RoleBaseAccessControl {
|
|
|
1086
1086
|
next();
|
|
1087
1087
|
}`,p++}),c+=`else{
|
|
1088
1088
|
throw 403;
|
|
1089
|
-
}`,s=s.replace(/{{roleSwitch}}/g,c),s}var khe=S_(require("fs"));function pPe(n){return wp(this,null,function*(){
|
|
1089
|
+
}`,s=s.replace(/{{roleSwitch}}/g,c),s}var khe=S_(require("fs"));function pPe(n){return wp(this,null,function*(){Yl.process("RBAC Middleware"),khe.default.existsSync(n.middlewareDir)||khe.default.mkdirSync(n.middlewareDir);let s=`${n.middlewareDir}/RoleBaseAccessControl.gen.ts`;Wc.common.writeFile("RBAC Middleware",s,The({roles:n.roles,compilerOptions:n.compilerOptions}))})}function fPe(n){return wp(this,null,function*(){var _;if(!n.compilerOptions.useRBAC)return;ePe({collectionList:n.collectionList,roleSetupDir:n.roleSourceDir,compilerOptions:n.compilerOptions});let s=[];(_=n.compilerOptions.useRBAC)==null||_.roles.forEach(h=>{Yl.process(`RBAC Class : ${h}`);let g=[],v=`${n.compilerOptions.srcDir}/roles/${h}.json`,x=`${n.roleOutDir}/${h}.gen.ts`,C=Wc.common.loadJson(v);Object.values(C).forEach(O=>{Array.isArray(O)&&O.forEach(F=>{!g.includes(F)&&!lPe.includes(F)&&g.push(F)})});let w=Object.keys(g).map(O=>`"${O}"`);w.push("roleFactory.accessAction"),Wc.common.writeFile("RBAC Role",x,whe({role:h,roleContent:C,RoleAccessActionString:w,compilerOptions:n.compilerOptions})),s.push({name:h,from:x})});let c=`${n.roleOutDir}/index.ts`,p=`{{headerComment}}
|
|
1090
1090
|
`+s.map(h=>`export { default as ${h.name} } from "./${h.name}.gen";`).join(`
|
|
1091
1091
|
`);Wc.common.writeFile("RBAC Index",c,p);let f=s.map(h=>h.name);pPe({middlewareDir:n.middlewareDir,roles:f,compilerOptions:n.compilerOptions})})}var dPe=S_(require("fs"));var _Pe=S_(require("path"));var KO=S_(require("util"));function Fhe(n){let s=n.template||`{{headerComment}}
|
|
1092
1092
|
import * as controllerFactory from "./_ControllerFactory.gen";
|
|
1093
1093
|
import { Router, Request, Response } from 'express';
|
|
1094
1094
|
|
|
1095
1095
|
import { checkSchema, validationResult } from 'express-validator';
|
|
1096
|
-
import
|
|
1096
|
+
import utils from "./../../system/_utils";
|
|
1097
1097
|
import MongoQS from 'mongo-ts-querystring';
|
|
1098
1098
|
|
|
1099
1099
|
import { {{documentName}}Model } from '{{modelPath}}';
|
|
@@ -1127,8 +1127,8 @@ class {{documentName}}Controller extends controllerFactory._ControllerFactory {
|
|
|
1127
1127
|
try {
|
|
1128
1128
|
const validationError = validationResult(req);
|
|
1129
1129
|
if ( ! validationError.isEmpty() ) {
|
|
1130
|
-
return
|
|
1131
|
-
code:
|
|
1130
|
+
return utils.response.send(res, 400, {
|
|
1131
|
+
code: utils.response.code.err_validation,
|
|
1132
1132
|
result: validationError.array()
|
|
1133
1133
|
});
|
|
1134
1134
|
};
|
|
@@ -1136,13 +1136,13 @@ class {{documentName}}Controller extends controllerFactory._ControllerFactory {
|
|
|
1136
1136
|
const result = await {{documentName}}Model.findById(req.params.id){{populateAll}};
|
|
1137
1137
|
|
|
1138
1138
|
if (!result) {
|
|
1139
|
-
return
|
|
1139
|
+
return utils.response.send(res, 404);
|
|
1140
1140
|
}
|
|
1141
1141
|
else {
|
|
1142
|
-
return
|
|
1142
|
+
return utils.response.send(res, 200, { result });
|
|
1143
1143
|
};
|
|
1144
1144
|
} catch (err:any) {
|
|
1145
|
-
return
|
|
1145
|
+
return utils.response.send(res, 500, { message: err.message });
|
|
1146
1146
|
}
|
|
1147
1147
|
}
|
|
1148
1148
|
|
|
@@ -1150,8 +1150,8 @@ class {{documentName}}Controller extends controllerFactory._ControllerFactory {
|
|
|
1150
1150
|
try {
|
|
1151
1151
|
const validationError = validationResult(req);
|
|
1152
1152
|
if ( ! validationError.isEmpty() ) {
|
|
1153
|
-
return
|
|
1154
|
-
code:
|
|
1153
|
+
return utils.response.send(res, 400, {
|
|
1154
|
+
code: utils.response.code.err_validation,
|
|
1155
1155
|
result: validationError.array()
|
|
1156
1156
|
});
|
|
1157
1157
|
};
|
|
@@ -1164,20 +1164,20 @@ class {{documentName}}Controller extends controllerFactory._ControllerFactory {
|
|
|
1164
1164
|
let populateOptions : any | undefined = undefined;
|
|
1165
1165
|
|
|
1166
1166
|
try {
|
|
1167
|
-
selectedFields =
|
|
1168
|
-
populateOptions =
|
|
1167
|
+
selectedFields = utils.common.parseFieldsSelect(req);
|
|
1168
|
+
populateOptions = utils.common.parseCollectionJoin(req, {{populateOptions}});
|
|
1169
1169
|
}
|
|
1170
1170
|
catch (err:any) {
|
|
1171
|
-
return
|
|
1172
|
-
code:
|
|
1171
|
+
return utils.response.send(res, 400, {
|
|
1172
|
+
code: utils.response.code.err_validation,
|
|
1173
1173
|
result: err.message
|
|
1174
1174
|
});
|
|
1175
1175
|
};
|
|
1176
1176
|
|
|
1177
1177
|
const result = await {{documentName}}Model.find(searchFilter, selectedFields).populate(populateOptions);
|
|
1178
|
-
return
|
|
1178
|
+
return utils.response.send(res, 200, { result });
|
|
1179
1179
|
} catch (err:any) {
|
|
1180
|
-
return
|
|
1180
|
+
return utils.response.send(res, 500, { result: err.message });
|
|
1181
1181
|
}
|
|
1182
1182
|
}
|
|
1183
1183
|
|
|
@@ -1185,23 +1185,23 @@ class {{documentName}}Controller extends controllerFactory._ControllerFactory {
|
|
|
1185
1185
|
try {
|
|
1186
1186
|
const validationError = validationResult(req);
|
|
1187
1187
|
if ( ! validationError.isEmpty() ) {
|
|
1188
|
-
return
|
|
1189
|
-
code:
|
|
1188
|
+
return utils.response.send(res, 400, {
|
|
1189
|
+
code: utils.response.code.err_validation,
|
|
1190
1190
|
result: validationError.array()
|
|
1191
1191
|
});
|
|
1192
1192
|
};{{check_id}}
|
|
1193
1193
|
|
|
1194
1194
|
const result = await {{documentName}}Model.create(req.body);
|
|
1195
1195
|
if (!result) {
|
|
1196
|
-
return
|
|
1197
|
-
code:
|
|
1196
|
+
return utils.response.send(res, 400, {
|
|
1197
|
+
code: utils.response.code.err_create
|
|
1198
1198
|
});
|
|
1199
1199
|
}
|
|
1200
1200
|
else {
|
|
1201
|
-
return
|
|
1201
|
+
return utils.response.send(res, 201, {result});
|
|
1202
1202
|
};
|
|
1203
1203
|
} catch (err:any) {
|
|
1204
|
-
return
|
|
1204
|
+
return utils.response.send(res, 500, { message: err.message });
|
|
1205
1205
|
};
|
|
1206
1206
|
};
|
|
1207
1207
|
|
|
@@ -1209,23 +1209,23 @@ class {{documentName}}Controller extends controllerFactory._ControllerFactory {
|
|
|
1209
1209
|
try {
|
|
1210
1210
|
const validationError = validationResult(req);
|
|
1211
1211
|
if ( ! validationError.isEmpty() ) {
|
|
1212
|
-
return
|
|
1213
|
-
code:
|
|
1212
|
+
return utils.response.send(res, 400, {
|
|
1213
|
+
code: utils.response.code.err_validation,
|
|
1214
1214
|
result: validationError.array()
|
|
1215
1215
|
});
|
|
1216
1216
|
};{{check_id}}
|
|
1217
1217
|
|
|
1218
1218
|
const result = await {{documentName}}Model.findByIdAndUpdate(req.params.id, req.body, { new: true });
|
|
1219
1219
|
if (!result) {
|
|
1220
|
-
return
|
|
1221
|
-
code:
|
|
1220
|
+
return utils.response.send(res, 404, {
|
|
1221
|
+
code: utils.response.code.err_update
|
|
1222
1222
|
});
|
|
1223
1223
|
}
|
|
1224
1224
|
else {
|
|
1225
|
-
return
|
|
1225
|
+
return utils.response.send(res, 200, { result });
|
|
1226
1226
|
};
|
|
1227
1227
|
} catch (err:any) {
|
|
1228
|
-
return
|
|
1228
|
+
return utils.response.send(res, 500, { message: err.message });
|
|
1229
1229
|
}
|
|
1230
1230
|
}
|
|
1231
1231
|
|
|
@@ -1233,23 +1233,23 @@ class {{documentName}}Controller extends controllerFactory._ControllerFactory {
|
|
|
1233
1233
|
try {
|
|
1234
1234
|
const validationError = validationResult(req);
|
|
1235
1235
|
if ( ! validationError.isEmpty() ) {
|
|
1236
|
-
return
|
|
1237
|
-
code:
|
|
1236
|
+
return utils.response.send(res, 400, {
|
|
1237
|
+
code: utils.response.code.err_validation,
|
|
1238
1238
|
result: validationError.array()
|
|
1239
1239
|
});
|
|
1240
1240
|
};{{check_id}}
|
|
1241
1241
|
|
|
1242
1242
|
const result = await {{documentName}}Model.replaceOne({_id: req.params.id}, req.body);
|
|
1243
1243
|
if (!result) {
|
|
1244
|
-
return
|
|
1245
|
-
code:
|
|
1244
|
+
return utils.response.send(res, 404, {
|
|
1245
|
+
code: utils.response.code.err_update
|
|
1246
1246
|
});
|
|
1247
1247
|
}
|
|
1248
1248
|
else {
|
|
1249
|
-
return
|
|
1249
|
+
return utils.response.send(res, 200, { result });
|
|
1250
1250
|
};
|
|
1251
1251
|
} catch (err:any) {
|
|
1252
|
-
return
|
|
1252
|
+
return utils.response.send(res, 500, { message: err.message });
|
|
1253
1253
|
}
|
|
1254
1254
|
}
|
|
1255
1255
|
|
|
@@ -1257,23 +1257,23 @@ class {{documentName}}Controller extends controllerFactory._ControllerFactory {
|
|
|
1257
1257
|
try {
|
|
1258
1258
|
const validationError = validationResult(req);
|
|
1259
1259
|
if ( ! validationError.isEmpty() ) {
|
|
1260
|
-
return
|
|
1261
|
-
code:
|
|
1260
|
+
return utils.response.send(res, 400, {
|
|
1261
|
+
code: utils.response.code.err_validation,
|
|
1262
1262
|
result: validationError.array()
|
|
1263
1263
|
});
|
|
1264
1264
|
};
|
|
1265
1265
|
|
|
1266
1266
|
const result = await {{documentName}}Model.findByIdAndDelete(req.params.id);
|
|
1267
1267
|
if (!result) {
|
|
1268
|
-
return
|
|
1269
|
-
code:
|
|
1268
|
+
return utils.response.send(res, 404, {
|
|
1269
|
+
code: utils.response.code.err_delete
|
|
1270
1270
|
});
|
|
1271
1271
|
}
|
|
1272
1272
|
else {
|
|
1273
|
-
return
|
|
1273
|
+
return utils.response.send(res, 204, { result });
|
|
1274
1274
|
};
|
|
1275
1275
|
} catch (err:any) {
|
|
1276
|
-
return
|
|
1276
|
+
return utils.response.send(res, 500, { message: err.message });
|
|
1277
1277
|
}
|
|
1278
1278
|
}
|
|
1279
1279
|
}
|
|
@@ -1313,7 +1313,7 @@ ${_}.populate(${g})`:""}return s=s.replace(/{{populateAll}}/g,h),s=s.replace(/{{
|
|
|
1313
1313
|
// deleteRoute disabled`),s=s.replace(/{{check_id}}/g,n.compilerOptions.app.allowApiCreateUpdate_id?"":`
|
|
1314
1314
|
if (req.body._id) {
|
|
1315
1315
|
delete req.body._id;
|
|
1316
|
-
};`),Wc.template.format(s)}function hPe(n){return wp(this,null,function*(){let s=dPe.default.readFileSync(_Pe.default.posix.join(n.compilerOptions.openapiDir,n.openapiFile),"utf8"),c=Wc.common.relativePath(n.compilerOptions.sysDir,n.modelDir),p=kae.load(s),f={},_=[];Object.keys(p.paths).forEach(h=>{
|
|
1316
|
+
};`),Wc.template.format(s)}function hPe(n){return wp(this,null,function*(){let s=dPe.default.readFileSync(_Pe.default.posix.join(n.compilerOptions.openapiDir,n.openapiFile),"utf8"),c=Wc.common.relativePath(n.compilerOptions.sysDir,n.modelDir),p=kae.load(s),f={},_=[];Object.keys(p.paths).forEach(h=>{Yl.process(`Controller : ${n.compilerOptions.openapiDir} > ${h}`),f[h]={},Object.keys(p.paths[h]).forEach(g=>{if(!Object.values(Oae).includes(g))return;let v=g,x=Object.assign(yUr(h,v,p),vUr(h,v,p));f[h][g]=x})}),Object.keys(p.paths).forEach(h=>{let g=p.paths[h]["x-documentName"],v=h.replace("/{id}","").toLowerCase();if(g===void 0){Yl.error(`"x-documentName" not found in openapi spec's path "${h}"
|
|
1317
1317
|
- opanapi source: ${n.compilerOptions.openapiDir}`);return}else{if(_.includes(v))return;{let x=Wc.common.loadJson(n.documentPaths[g]),C=mPe(x),w=`${n.controllerOutDir}/${g}Controller.gen.ts`,O=`../${c}/${g}Model.gen`;Wc.common.writeFile("Controller",w,Fhe({endpoint:h,modelPath:O,documentName:g,validators:f,populateOptions:C,compilerOptions:n.compilerOptions})),_.push(v)}}})})}function yUr(n,s,c){let p={};return c.paths[n][s].parameters.forEach(f=>{Object.assign(p,Phe({fieldName:f.name,required:f.required,param:f}))}),p}function vUr(n,s,c){var g,v,x,C;let p={},f=(x=(v=(g=c.paths[n][s])==null?void 0:g.requestBody)==null?void 0:v.content)==null?void 0:x["application/json"].schema.$ref,_=f?f.split("/").pop():void 0,h=_?c.components.schemas[_]:void 0;if(h!==void 0)for(let w in h.properties)Object.assign(p,Phe({fieldName:w,body:h.properties[w],required:((C=h.required)==null?void 0:C.includes(w))||h.properties[w].required}));return p}function mPe(n){var c,p,f;if(n.type!=="object")throw new Error("buildForeinKeyOptions : root schema type must be object");let s={};for(let _ in n.properties)n.properties[_]["x-foreignKey"]?s[_]=((c=n.properties[_]["x-foreignValue"])==null?void 0:c.join(" "))||"":n.properties[_].type==="array"&&((p=n.properties[_].items)!=null&&p["x-foreignKey"])?s[_]=((f=n.properties[_].items["x-foreignValue"])==null?void 0:f.join(" "))||"":n.properties[_].type==="object"&&(s=Object.assign(s,mPe(n.properties[_])));return s}function Phe(n){var w,O,F,P,M,Z,ie,$,K,B,G,oe,Ae,ae,le,pe,xe,ce,ye,Oe,Ke,ke,at,ar,fr,Pt,mt,Vr,bt,vn;let s=((w=n.param)==null?void 0:w.in)=="path",c=((O=n.param)==null?void 0:O.in)=="query",p=n.body,f={[n.fieldName]:{in:s?"params":c?"query":p?"body":[],optional:n.required?!1:{options:{values:"falsy",checkFalsy:!0}},notEmpty:!0}},_=f[n.fieldName],h=n.body!==void 0&&n.param==null,g=h?(F=n.body)==null?void 0:F.type:(P=n.param)==null?void 0:P.schema.type,v=($=(Z=(M=n.param)==null?void 0:M.schema)==null?void 0:Z.enum)!=null?$:(ie=n.body)==null?void 0:ie.enum,x={min:(xe=(le=(Ae=(B=(K=n.param)==null?void 0:K.schema)==null?void 0:B.minLength)!=null?Ae:(oe=(G=n.param)==null?void 0:G.schema)==null?void 0:oe.minimum)!=null?le:(ae=n.body)==null?void 0:ae.minLength)!=null?xe:(pe=n.body)==null?void 0:pe.minimum,max:(Pt=(ar=(ke=(ye=(ce=n.param)==null?void 0:ce.schema)==null?void 0:ye.maxLength)!=null?ke:(Ke=(Oe=n.param)==null?void 0:Oe.schema)==null?void 0:Ke.maximum)!=null?ar:(at=n.body)==null?void 0:at.maxLength)!=null?Pt:(fr=n.body)==null?void 0:fr.maximum},C=x.min&&x.max?{options:x}:void 0;switch(g){case"string":switch(_.isString=!0,x.min&&x.max&&(_.isLength={options:x}),v&&(_.isEmpty=!1,_.isIn={options:v}),(Vr=(mt=n==null?void 0:n.param)==null?void 0:mt.schema)==null?void 0:Vr["x-format"]){case"ObjectId":(typeof _.custom!="object"||_.custom===null)&&(_.custom={}),_.custom.options="FUNC{{this.isObjectId}}";break}break;case"integer":_.isInt=C;break;case"float":_.isFloat=C;break;case"number":_.isNumeric=!0;break;case"boolean":_.isBoolean=!0;break;case"array":_.isArray=!0;break;case"object":if(h)for(let Ir in(bt=n.body)==null?void 0:bt.properties)Object.assign(f,Phe({fieldName:n.fieldName+"."+Ir,body:n.body.properties[Ir],required:(vn=n.body.required)==null?void 0:vn.includes(Ir)}));break}return f}function Ohe(n){let s=n.template||`{{headerComment}}
|
|
1318
1318
|
import { Router } from 'express';
|
|
1319
1319
|
|
|
@@ -1335,51 +1335,28 @@ export default class ApiRouter{
|
|
|
1335
1335
|
`)),s=s.replace(/{{useRoutes}}/g,p.join(`
|
|
1336
1336
|
`)),s}function Nhe(n){let s=`{{headerComment}}
|
|
1337
1337
|
import { Router } from 'express';
|
|
1338
|
-
import
|
|
1339
|
-
|
|
1340
|
-
import
|
|
1341
|
-
import
|
|
1338
|
+
import utils from '../_utils';
|
|
1339
|
+
|
|
1340
|
+
import JWTService from '../_services/auth/JWTService.gen';
|
|
1341
|
+
import OAuthStrategyService from '../_services/oauth/OAuthStrategyService.gen';
|
|
1342
1342
|
|
|
1343
1343
|
import OAuthRouteFactory from './oauth/OAuthRouteFactory.gen';
|
|
1344
1344
|
import { Strategy as GithubStrategy } from 'passport-github';
|
|
1345
1345
|
import { Strategy as GoogleStrategy } from 'passport-google-oauth20';
|
|
1346
1346
|
import { SessionDocument, SessionModel } from '../_models/SessionModel.gen';
|
|
1347
|
+
{{localAuthImport}}
|
|
1347
1348
|
import VexSystem from '../_services/VexSystem.gen';
|
|
1348
1349
|
|
|
1349
1350
|
export default class AuthRouter {
|
|
1350
|
-
|
|
1351
|
+
|
|
1352
|
+
private JWTService = new JWTService();
|
|
1353
|
+
private OAuthStrategyService = new OAuthStrategyService();
|
|
1351
1354
|
private router: Router = Router();
|
|
1352
1355
|
|
|
1353
1356
|
constructor() {
|
|
1354
1357
|
const vexSystem = new VexSystem();
|
|
1355
|
-
|
|
1356
|
-
{{
|
|
1357
|
-
|
|
1358
|
-
// refresh expired tokens by refresh token.
|
|
1359
|
-
this.router.post('/refresh', (req, res) => vexSystem.RouteHandler(req, res, async () => {
|
|
1360
|
-
|
|
1361
|
-
// todo: change this return if use httpOnly Cookie
|
|
1362
|
-
|
|
1363
|
-
if (
|
|
1364
|
-
!req.body.refreshToken ||
|
|
1365
|
-
!req.body.refreshTokenIndex
|
|
1366
|
-
) {
|
|
1367
|
-
console.log("invalid /refresh payload");
|
|
1368
|
-
return responseGen.send(res, 401);
|
|
1369
|
-
};
|
|
1370
|
-
|
|
1371
|
-
let refreshTokenPayload = verifyToken(req.body.refreshToken, req.body.refreshTokenIndex);
|
|
1372
|
-
|
|
1373
|
-
// new tokens generated
|
|
1374
|
-
const accessToken = await generateAccessToken(refreshTokenPayload._id);
|
|
1375
|
-
|
|
1376
|
-
return responseGen.send(res, 200, {
|
|
1377
|
-
result: {
|
|
1378
|
-
accessToken: accessToken.token,
|
|
1379
|
-
accessTokenIndex: accessToken.clientIndex
|
|
1380
|
-
}
|
|
1381
|
-
});
|
|
1382
|
-
}));
|
|
1358
|
+
{{pathTokenExchangeAndRefresh}}
|
|
1359
|
+
{{localAuthRoutes}}
|
|
1383
1360
|
|
|
1384
1361
|
this.initOAuthRoutes();
|
|
1385
1362
|
}
|
|
@@ -1401,7 +1378,7 @@ export default class AuthRouter {
|
|
|
1401
1378
|
clientSecret: process.env.OAUTH_GOOGLE_CLIENTSECRET || "",
|
|
1402
1379
|
callbackURL: \`\${process.env.APP_HOST}/auth/\${google}/callback\`,
|
|
1403
1380
|
},
|
|
1404
|
-
|
|
1381
|
+
this.OAuthStrategyService.verify
|
|
1405
1382
|
)
|
|
1406
1383
|
});
|
|
1407
1384
|
this.router.use(\`/\${google}\`, OAuthGoogle.getRouter());
|
|
@@ -1415,19 +1392,19 @@ export default class AuthRouter {
|
|
|
1415
1392
|
clientSecret: process.env.OAUTH_GITHUB_CLIENTSECRET || "",
|
|
1416
1393
|
callbackURL: \`\${process.env.APP_HOST}/auth/\${github}/callback\`,
|
|
1417
1394
|
},
|
|
1418
|
-
|
|
1395
|
+
this.OAuthStrategyService.verify
|
|
1419
1396
|
)
|
|
1420
1397
|
});
|
|
1421
1398
|
this.router.use(\`/\${github}\`, OAuthGithub.getRouter());
|
|
1422
1399
|
`}}).join(`
|
|
1423
|
-
`);return s=s.replace(/{{OAuthRouteProviders}}/g,p),s=s.replace(/{{
|
|
1424
|
-
//
|
|
1400
|
+
`);return s=s.replace(/{{OAuthRouteProviders}}/g,p),(n.auth.localAuth||n.auth.oauthProviders)&&(s=s.replace(/{{pathTokenExchangeAndRefresh}}/g,`
|
|
1401
|
+
// Exchange an authorization code for tokens.
|
|
1425
1402
|
this.router.post('/token', (req, res) => vexSystem.RouteHandler(req, res, async ()=> {
|
|
1426
1403
|
|
|
1427
1404
|
// todo: disable this route if use httpOnly Cookie
|
|
1428
1405
|
|
|
1429
1406
|
if (!req.query.code) {
|
|
1430
|
-
return
|
|
1407
|
+
return utils.response.send(res, 401);
|
|
1431
1408
|
}
|
|
1432
1409
|
|
|
1433
1410
|
const sessionCode = req.query.code;
|
|
@@ -1435,7 +1412,7 @@ export default class AuthRouter {
|
|
|
1435
1412
|
const sessionDoc = await SessionModel.findOne<SessionDocument>({ sessionCode: sessionCode }).exec();
|
|
1436
1413
|
|
|
1437
1414
|
if (!sessionDoc) {
|
|
1438
|
-
return
|
|
1415
|
+
return utils.response.send(res, 404, { message: 'invalid code' });
|
|
1439
1416
|
}
|
|
1440
1417
|
else {
|
|
1441
1418
|
await SessionModel.deleteOne({ sessionCode: sessionCode }).exec();
|
|
@@ -1443,14 +1420,14 @@ export default class AuthRouter {
|
|
|
1443
1420
|
};
|
|
1444
1421
|
|
|
1445
1422
|
if (sessionDoc?.get('expired') < Date.now()) {
|
|
1446
|
-
return
|
|
1423
|
+
return utils.response.send(res, 401, { message: 'code expired' });
|
|
1447
1424
|
};
|
|
1448
1425
|
|
|
1449
1426
|
// generate tokens based on code's user profile
|
|
1450
|
-
const accessToken = await generateAccessToken(sessionDoc.get("userId"));
|
|
1451
|
-
const refreshToken = generateRefreshToken({_id: sessionDoc.get("userId")});
|
|
1427
|
+
const accessToken = await this.JWTService.generateAccessToken(sessionDoc.get("userId"));
|
|
1428
|
+
const refreshToken = this.JWTService.generateRefreshToken({_id: sessionDoc.get("userId")});
|
|
1452
1429
|
|
|
1453
|
-
return
|
|
1430
|
+
return utils.response.send(res, 200, {
|
|
1454
1431
|
result: {
|
|
1455
1432
|
accessToken: accessToken.token,
|
|
1456
1433
|
accessTokenIndex: accessToken.clientIndex,
|
|
@@ -1458,7 +1435,111 @@ export default class AuthRouter {
|
|
|
1458
1435
|
refreshTokenIndex: refreshToken.clientIndex
|
|
1459
1436
|
}
|
|
1460
1437
|
});
|
|
1461
|
-
}))
|
|
1438
|
+
}));
|
|
1439
|
+
|
|
1440
|
+
// Refresh expired tokens by refresh token.
|
|
1441
|
+
this.router.post('/refresh', (req, res) => vexSystem.RouteHandler(req, res, async () => {
|
|
1442
|
+
|
|
1443
|
+
// todo: change this return if use httpOnly Cookie
|
|
1444
|
+
|
|
1445
|
+
if (
|
|
1446
|
+
!req.body.refreshToken ||
|
|
1447
|
+
!req.body.refreshTokenIndex
|
|
1448
|
+
) {
|
|
1449
|
+
console.log("invalid /refresh payload");
|
|
1450
|
+
return utils.response.send(res, 401);
|
|
1451
|
+
};
|
|
1452
|
+
|
|
1453
|
+
let refreshTokenPayload = this.JWTService.verifyToken(req.body.refreshToken, req.body.refreshTokenIndex);
|
|
1454
|
+
|
|
1455
|
+
// new tokens generated
|
|
1456
|
+
const accessToken = await this.JWTService.generateAccessToken(refreshTokenPayload._id);
|
|
1457
|
+
|
|
1458
|
+
return utils.response.send(res, 200, {
|
|
1459
|
+
result: {
|
|
1460
|
+
accessToken: accessToken.token,
|
|
1461
|
+
accessTokenIndex: accessToken.clientIndex
|
|
1462
|
+
}
|
|
1463
|
+
});
|
|
1464
|
+
}));`)),n.auth.localAuth&&(s=s.replace(/{{localAuthImport}}/g,`import { UserModel } from '../_models/UserModel.gen';
|
|
1465
|
+
`),s=s.replace(/{{localAuthRoutes}}/g,`
|
|
1466
|
+
// Local Auth register & login
|
|
1467
|
+
this.router.post('/register', async (req, res) => {
|
|
1468
|
+
try {
|
|
1469
|
+
const { email, password } = req.body;
|
|
1470
|
+
if (!email || !password) {
|
|
1471
|
+
return utils.response.send(res, 400, { message: "Email and password are required." });
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
// Check if user already exists
|
|
1475
|
+
const existingUser = await UserModel.findOne({ email }).exec();
|
|
1476
|
+
if (existingUser) {
|
|
1477
|
+
return utils.response.send(res, 409, { message: "Email already registered." });
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
// Hash password with salt (email)
|
|
1481
|
+
const hashedPassword = utils.hash.hashPassword(password, email);
|
|
1482
|
+
|
|
1483
|
+
// Create user with local auth profile
|
|
1484
|
+
const user = new UserModel({
|
|
1485
|
+
name: email.split('@')[0],
|
|
1486
|
+
email,
|
|
1487
|
+
authProfiles: [
|
|
1488
|
+
{
|
|
1489
|
+
provider: 'local',
|
|
1490
|
+
password: hashedPassword
|
|
1491
|
+
}
|
|
1492
|
+
]
|
|
1493
|
+
});
|
|
1494
|
+
await user.save();
|
|
1495
|
+
|
|
1496
|
+
return utils.response.send(res, 201, { message: "Registration successful." });
|
|
1497
|
+
} catch (err:any) {
|
|
1498
|
+
return utils.response.send(res, 500, { message: err?.message || "Registration failed." });
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1501
|
+
|
|
1502
|
+
|
|
1503
|
+
this.router.use('/local',
|
|
1504
|
+
async (req, res, next) => {
|
|
1505
|
+
const { email, password } = req.body;
|
|
1506
|
+
if (!email || !password) {
|
|
1507
|
+
return utils.response.send(res, 400, { message: "Email and password are required." });
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
try {
|
|
1511
|
+
// verify user credentials
|
|
1512
|
+
const user = await UserModel.findOne({ email }).exec();
|
|
1513
|
+
if (!user) {
|
|
1514
|
+
return utils.response.send(res, 400, { message:"incorrect email or password." });
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
const localAuthProfile = user.authProfiles?.find(profile => profile.provider === 'local');
|
|
1518
|
+
if (!localAuthProfile) {
|
|
1519
|
+
return utils.response.send(res, 400, { message:"incorrect email or password." });
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
const isMatch = await utils.hash.verifyPassword(user, password);
|
|
1523
|
+
if (!isMatch) {
|
|
1524
|
+
return utils.response.send(res, 400, { message:"incorrect email or password." });
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
// return tokens to client
|
|
1528
|
+
const redirectUrl = await this.JWTService.assignTokens(user, res);
|
|
1529
|
+
return utils.response.send(res, 302, {
|
|
1530
|
+
result: {
|
|
1531
|
+
url: redirectUrl,
|
|
1532
|
+
}
|
|
1533
|
+
});
|
|
1534
|
+
|
|
1535
|
+
} catch (err: any) {
|
|
1536
|
+
console.error("Login error:", err);
|
|
1537
|
+
return utils.response.send(res, 500, { message: err?.message || "Login failed." });
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
);
|
|
1541
|
+
|
|
1542
|
+
`)),s}function gPe(n){return Nhe(n)}function yPe(){return`{{headerComment}}
|
|
1462
1543
|
import { Router } from "express";
|
|
1463
1544
|
import swaggerUi, { JsonObject } from "swagger-ui-express";
|
|
1464
1545
|
import { loadYaml } from "./../_utils/common.gen";
|
|
@@ -1475,7 +1556,7 @@ export default class SwaggerRouter{
|
|
|
1475
1556
|
return this.router;
|
|
1476
1557
|
}
|
|
1477
1558
|
|
|
1478
|
-
}`}function vPe(n){return wp(this,null,function*(){
|
|
1559
|
+
}`}function vPe(n){return wp(this,null,function*(){Yl.process("Route");let s=`${n.routesDir}/ApiRouter.gen.ts`,c=`${n.routesDir}/AuthRouter.gen.ts`,p=`${n.routesDir}/SwaggerRouter.gen.ts`;Wc.generator.isOAuthEnabled(n.compilerOptions)&&Wc.common.writeFile("Route Auth",c,gPe(n.compilerOptions)),n.compilerOptions.app.enableSwagger&&Wc.common.writeFile("Route Swagger",p,yPe(n.compilerOptions)),Wc.common.writeFile("Route API",s,Ohe({routes:n.routesArr,openapiFile:n.openapiFile,compilerOptions:n.compilerOptions}))})}var xPe=S_(require("path"));var CUr="import cookieParser from 'cookie-parser';",AUr="import SwaggerRouter from './system/_routes/SwaggerRouter.gen';",SUr="import AuthRouter from './system/_routes/AuthRouter.gen';",wUr="const SwaggerRoute = new SwaggerRouter();",TUr="const AuthRoute = new AuthRouter();",kUr="const ApiRoute = new ApiRouter();",FUr="app.use(cookieParser());",PUr='app.use("/auth", AuthRoute.getRouter());',OUr='app.use("/swagger", SwaggerRoute.getRouter());',NUr='app.use("/api", ApiRoute.getRouter());';function Ihe(n){let s=n.template||`{{headerComment}}
|
|
1479
1560
|
import express from 'express';
|
|
1480
1561
|
import dotenv from 'dotenv';
|
|
1481
1562
|
import crypto from 'crypto';
|
|
@@ -1526,7 +1607,7 @@ async function main(): Promise<void> {
|
|
|
1526
1607
|
// Routes
|
|
1527
1608
|
{{AppRouter}}
|
|
1528
1609
|
|
|
1529
|
-
{{
|
|
1610
|
+
{{loginUI}}
|
|
1530
1611
|
|
|
1531
1612
|
app.listen(3000, () => {
|
|
1532
1613
|
if (!process.env.MONGODB_URI) throw new Error('MONGODB_URI is not defined');
|
|
@@ -1537,12 +1618,35 @@ async function main(): Promise<void> {
|
|
|
1537
1618
|
}
|
|
1538
1619
|
|
|
1539
1620
|
main();
|
|
1540
|
-
`,c=Wc.generator.OAuthProviders(n.compilerOptions),p=[],f=[],_=[],h=[];return f.push(kUr),h.push(NUr),n.compilerOptions.app.enableSwagger&&(p.push(AUr),f.push(wUr),h.push(OUr)),c.length>0&&(p.push(CUr),_.push(FUr),p.push(SUr),f.push(TUr),h.push(PUr)),s=s.replace(/{{
|
|
1621
|
+
`,c=Wc.generator.OAuthProviders(n.compilerOptions),p=[],f=[],_=[],h=[];return f.push(kUr),h.push(NUr),n.compilerOptions.app.enableSwagger&&(p.push(AUr),f.push(wUr),h.push(OUr)),c.length>0&&(p.push(CUr),_.push(FUr),p.push(SUr),f.push(TUr),h.push(PUr)),s=s.replace(/{{loginUI}}/g,BUr(c,n.compilerOptions)),s=s.replace(/{{Import}}/g,p.join(`
|
|
1541
1622
|
`)),s=s.replace(/{{Config}}/g,f.join(`
|
|
1542
1623
|
`)),s=s.replace(/{{AppUse}}/g,_.join(`
|
|
1543
1624
|
`)),s=s.replace(/{{AppRouter}}/g,h.join(`
|
|
1544
|
-
`)),s}function IUr(n){let
|
|
1545
|
-
|
|
1625
|
+
`)),s}function IUr(n,s){let c="",p="";return s.auth.localAuth&&(p+=`
|
|
1626
|
+
<p>Email:</p>
|
|
1627
|
+
<input type="email" id="email"/>
|
|
1628
|
+
<p>Password:</p>
|
|
1629
|
+
<input type="password" id="password"/>
|
|
1630
|
+
<br/>
|
|
1631
|
+
<br/>
|
|
1632
|
+
<button id="localLoginBtn">Login</button>
|
|
1633
|
+
<button id="localRegisterBtn">Register</button>
|
|
1634
|
+
<br/>
|
|
1635
|
+
<br/>
|
|
1636
|
+
`),p+=` <p> login with sso : </p>
|
|
1637
|
+
`,n.length===0?p+=` <p> No OAuth provider configured. </p>
|
|
1638
|
+
`:n.forEach(f=>{p+=` <a href="\${process.env.APP_HOST}/auth/${f}">${f}</a><br/>
|
|
1639
|
+
`}),c=s.auth.localAuth?`
|
|
1640
|
+
const nonce = crypto.randomBytes(16).toString("base64");
|
|
1641
|
+
res.setHeader("Content-Security-Policy", \`script-src 'self' 'nonce-\${nonce}'\`);
|
|
1642
|
+
res.send(\`
|
|
1643
|
+
<script nonce="\${nonce}" src="\${process.env.APP_HOST}/js/login.js"></script>
|
|
1644
|
+
<body>${p}
|
|
1645
|
+
</body>\`);
|
|
1646
|
+
`:`
|
|
1647
|
+
res.send(\`<body>${p}
|
|
1648
|
+
</body>\`);
|
|
1649
|
+
`,c}function BUr(n,s){return`
|
|
1546
1650
|
app.get('/', (req, res) => {
|
|
1547
1651
|
res.send(\`
|
|
1548
1652
|
<div>
|
|
@@ -1569,7 +1673,7 @@ main();
|
|
|
1569
1673
|
* - list all available provider
|
|
1570
1674
|
*/
|
|
1571
1675
|
app.get('/login', (req, res) => {
|
|
1572
|
-
|
|
1676
|
+
${IUr(n,s)}
|
|
1573
1677
|
});
|
|
1574
1678
|
|
|
1575
1679
|
/**
|
|
@@ -1641,11 +1745,11 @@ main();
|
|
|
1641
1745
|
</script>
|
|
1642
1746
|
\`);
|
|
1643
1747
|
});
|
|
1644
|
-
`}function DPe(n){return wp(this,null,function*(){let s=xPe.default.posix.join(n.srcDir,"server.ts");Wc.common.writeFile("Server",s,Ihe({compilerOptions:n}))})}function bPe(n){return wp(this,null,function*(){Wc.configChecker.checkConfigValid(n);let s="/openapi.gen.yaml",c=[],p={};n._={writtedDir:[]};let f={roleSrcDir:X7.default.posix.join(n.srcDir,"roles"),roleDir:X7.default.posix.join(n.sysDir,"_roles"),routeDir:X7.default.posix.join(n.sysDir,"_routes"),middlewareDir:X7.default.posix.join(n.sysDir,"_middlewares"),controllerDir:X7.default.posix.join(n.sysDir,"_controllers"),modelDir:X7.default.posix.join(n.sysDir,"_models"),typeDir:X7.default.posix.join(n.sysDir,"_types"),serviceDir:X7.default.posix.join(n.sysDir,"_services"),pluginDir:X7.default.posix.join(n.sysDir,"_plugins"),utilsDir:X7.default.posix.join(n.sysDir,"_utils")},_=[];Jy.default.existsSync(n.rootDir)||Jy.default.mkdirSync(n.rootDir),Jy.default.existsSync(n.srcDir)||Jy.default.mkdirSync(n.srcDir),Jy.default.existsSync(n.sysDir)||Jy.default.mkdirSync(n.sysDir),Jy.default.existsSync(n.openapiDir)||Jy.default.mkdirSync(n.openapiDir),Jy.default.existsSync(f.roleSrcDir)||Jy.default.mkdirSync(f.roleSrcDir),Object.values(f).forEach(g=>{Jy.default.existsSync(g)||Jy.default.mkdirSync(g)}),Wc.common.copyDir(`${__dirname}/templates/_controllers`,f.controllerDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_middlewares`,f.middlewareDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_plugins`,f.pluginDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_roles`,f.roleDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_routes`,f.routeDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_services`,f.serviceDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_types`,f.typeDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_utils`,f.utilsDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/root`,n.rootDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/jsonSchema`,n.jsonSchemaDir,n,!0),tPe({compilerOptions:n||Wc.generator.defaultCompilerOptions}),yield rPe({compilerOptions:n||Wc.generator.defaultCompilerOptions}),Jy.default.readdirSync(n.jsonSchemaDir).forEach(g=>{let v=`${n.jsonSchemaDir}/${g}`;try{if(!g.endsWith(".json")){
|
|
1748
|
+
`}function DPe(n){return wp(this,null,function*(){let s=xPe.default.posix.join(n.srcDir,"server.ts");Wc.common.writeFile("Server",s,Ihe({compilerOptions:n}))})}function bPe(n){return wp(this,null,function*(){Wc.configChecker.checkConfigValid(n);let s="/openapi.gen.yaml",c=[],p={};n._={writtedDir:[]};let f={roleSrcDir:X7.default.posix.join(n.srcDir,"roles"),roleDir:X7.default.posix.join(n.sysDir,"_roles"),routeDir:X7.default.posix.join(n.sysDir,"_routes"),middlewareDir:X7.default.posix.join(n.sysDir,"_middlewares"),controllerDir:X7.default.posix.join(n.sysDir,"_controllers"),modelDir:X7.default.posix.join(n.sysDir,"_models"),typeDir:X7.default.posix.join(n.sysDir,"_types"),serviceDir:X7.default.posix.join(n.sysDir,"_services"),pluginDir:X7.default.posix.join(n.sysDir,"_plugins"),utilsDir:X7.default.posix.join(n.sysDir,"_utils")},_=[];Jy.default.existsSync(n.rootDir)||Jy.default.mkdirSync(n.rootDir),Jy.default.existsSync(n.srcDir)||Jy.default.mkdirSync(n.srcDir),Jy.default.existsSync(n.sysDir)||Jy.default.mkdirSync(n.sysDir),Jy.default.existsSync(n.openapiDir)||Jy.default.mkdirSync(n.openapiDir),Jy.default.existsSync(f.roleSrcDir)||Jy.default.mkdirSync(f.roleSrcDir),Object.values(f).forEach(g=>{Jy.default.existsSync(g)||Jy.default.mkdirSync(g)}),Wc.common.copyDir(`${__dirname}/templates/_controllers`,f.controllerDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_middlewares`,f.middlewareDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_plugins`,f.pluginDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_roles`,f.roleDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_routes`,f.routeDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_services`,f.serviceDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_types`,f.typeDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/_utils`,f.utilsDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/root`,n.rootDir,n,!0),Wc.common.copyDir(`${__dirname}/templates/jsonSchema`,n.jsonSchemaDir,n,!0),tPe({compilerOptions:n||Wc.generator.defaultCompilerOptions}),yield rPe({compilerOptions:n||Wc.generator.defaultCompilerOptions}),Jy.default.readdirSync(n.jsonSchemaDir).forEach(g=>{let v=`${n.jsonSchemaDir}/${g}`;try{if(!g.endsWith(".json")){Yl.warn(`Skipping Non Json File : ${v}`);return}let x=Q9e(v,n);c.push({path:v,config:x["x-documentConfig"]}),p[x["x-documentConfig"].documentName]=v}catch(x){Yl.error(`Processing File : ${v}
|
|
1645
1749
|
`,x)}}),n.useRBAC&&n.useRBAC.roles.length>0&&(yield fPe({collectionList:c.map(g=>g.config.documentName),roleSourceDir:f.roleSrcDir,roleOutDir:f.roleDir,middlewareDir:f.middlewareDir,compilerOptions:n||Wc.generator.defaultCompilerOptions})),yield X9e(s,n),Wc.common.copyDir(`${n.openapiDir}`,X7.default.posix.join(n.srcDir,"openapi"),n,!0),yield Promise.all(c.map(g=>wp(this,null,function*(){Bhe.default.modelsGen.compileFromFile(`${g.path}`,`${Wc.common.relativePath(f.modelDir,f.typeDir)}/${g.config.documentName}.gen`,`${f.modelDir}/${g.config.documentName}Model.gen.ts`,n||Wc.generator.defaultCompilerOptions),yield Bhe.default.typesGen.compileFromFile(`${g.path}`,`${f.typeDir}/${g.config.documentName}.gen.ts`,n||Wc.generator.defaultCompilerOptions);let x=Jy.default.readFileSync(`${f.typeDir}/${g.config.documentName}.gen.ts`,"utf8").replace(/import (.*) from ".\/(.*)";/g,(C,w,O)=>`import ${w} from "./${O}.gen";`);Wc.common.writeFile("Type-Remap",`${f.typeDir}/${g.config.documentName}.gen.ts`,x),_.push({route:`/${g.config.documentName}`,documentName:g.config.documentName,controllerPath:X7.default.posix.join(Wc.common.relativePath(f.routeDir,f.controllerDir),g.config.documentName+"Controller.gen")})}))),yield hPe({documentPaths:p,openapiFile:s,controllerOutDir:f.controllerDir,modelDir:f.modelDir,compilerOptions:n||Wc.generator.defaultCompilerOptions}),yield vPe({routesArr:_,openapiFile:s,routesDir:f.routeDir,compilerOptions:n||Wc.generator.defaultCompilerOptions}),yield DPe(n),yield cPe(n)})}function RUr(){return wp(this,null,function*(){var c,p;console.log("\x1B[35m%s\x1B[0m",`
|
|
1646
1750
|
========== veryExpress CLI (vex) Start ==========
|
|
1647
|
-
`);let n=(0,CPe.default)(process.argv.slice(2)),s=Wc.generator.defaultCompilerOptions;if(VO.default.existsSync("vex.config.json"))try{s=JSON.parse(VO.default.readFileSync("vex.config.json","utf8"))}catch(f){
|
|
1648
|
-
this may cause
|
|
1751
|
+
`);let n=(0,CPe.default)(process.argv.slice(2)),s=Wc.generator.defaultCompilerOptions;if(VO.default.existsSync("vex.config.json"))try{s=JSON.parse(VO.default.readFileSync("vex.config.json","utf8"))}catch(f){Yl.error("failed to parse vex.config.json",f),process.exit(1)}if(s.jsonSchemaDir=n.j||n.jsonSchemaDir||s.jsonSchemaDir||"./jsonSchema",s.rootDir=n.o||n.rootDir||s.rootDir||".",s.srcDir=s.srcDir||s.rootDir+"/src",s.sysDir=s.sysDir||s.srcDir+"/system",s.openapiDir=s.srcDir+"/openapi",s.generator=(c=s.generator)!=null?c:{},s.generator.commitBeforeGenerate=(p=s.generator.commitBeforeGenerate)!=null?p:!1,s.app=s.app||{},s.app.enableSwagger=s.app.enableSwagger||!0,s.app.useUserSchema=s.app.useUserSchema||!0,s.app.useObjectID=s.app.useObjectID||!0,s.app.allowApiCreateUpdate_id=s.app.allowApiCreateUpdate_id||!1,s.useRBAC=s.useRBAC||{roles:[],default:"",schemaIncluded:[]},s.useRBAC.roles=s.useRBAC.roles||["user"],s.useRBAC.default=s.useRBAC.default||"user",s.useRBAC.schemaIncluded=s.useRBAC.schemaIncluded||["user"],s.auth=s.auth||{},s.auth.localAuth=s.auth.localAuth||!1,s.auth.oauthProviders=s.auth.oauthProviders||{},s.auth.oauthProviders.google=s.auth.oauthProviders.google||!1,s.auth.oauthProviders.github=s.auth.oauthProviders.github||!1,s.app.useObjectID&&s.app.allowApiCreateUpdate_id&&Yl.warn(`Not recommended to use "useObjectID" with "allowApiCreateUpdate_id",
|
|
1752
|
+
this may cause logic issues`),s.auth.localAuth&&!s.app.useUserSchema&&(Yl.error('localAuth requires useUserSchema to be true, please change vex.config.json "app.useUserSchema" to true or disable "auth.localAuth".'),process.exit(1)),Yl.process("validate vex.config.json"),Wc.common.setCompilerOptions(s),Wc.common.writeFile("vex.config","vex.config.json",JSON.stringify(s,null,4)),String(n._[0]).toLowerCase()==="h"||n.h)Yl.info(`Very Express CLI Usage:
|
|
1649
1753
|
|
|
1650
1754
|
Information:
|
|
1651
1755
|
vex <args>
|
|
@@ -1660,7 +1764,7 @@ this may cause some logic issues`),Ql.process("validate vex.config.json"),Wc.com
|
|
|
1660
1764
|
-o : Set rootDir (configured: ${s.rootDir})
|
|
1661
1765
|
|
|
1662
1766
|
note: no args
|
|
1663
|
-
`),process.exit(0);else if(String(n._[0]).toLowerCase()==="v"||n.v)
|
|
1767
|
+
`),process.exit(0);else if(String(n._[0]).toLowerCase()==="v"||n.v)Yl.info(`Very Express Version : ${k$.version}`),Lhe();else if(String(n._[0]).toLowerCase()==="i"||n.i){if(!VO.default.existsSync(s.jsonSchemaDir)){let f=s.jsonSchemaDir.split("/"),_="";f.forEach(h=>{_+=h,VO.default.existsSync(_)||VO.default.mkdirSync(_),_+="/"})}Lhe("Very Express CLI : Initialization Complete.")}else{if(VO.default.existsSync(s.jsonSchemaDir)||(Yl.error("Schema Dir Not Found:",s.jsonSchemaDir),process.exit(1)),s.generator.commitBeforeGenerate===!0)try{Yl.info('git commit "before vex-gen"'),EPe.default.execSync('git add . && git commit -m "before vex-gen"',{stdio:"inherit"})}catch(f){Yl.error('git commit "before vex-gen" failed',f)}Yl.process("generate with config",s),yield bPe(s),console.log(`next step:
|
|
1664
1768
|
cd ${s.rootDir}
|
|
1665
1769
|
npm install
|
|
1666
1770
|
npm run dev
|