very-express 0.8.5 → 0.9.0
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/AGENTS.md +4 -1
- package/dist/index.js +5 -6
- package/dist/templates/_middlewares/Authentication.ts +0 -3
- package/dist/templates/_services/TypeOrmRepositoryAdapter.ts +0 -6
- package/dist/templates/_services/VexDbConnector.ts +1 -26
- package/dist/templates/_services/auth/JWTService.ts +0 -15
- package/dist/templates/_utils/hash.ts +0 -16
- package/docs/architecture/databaseTargets.md +3 -1
- package/docs/releaseNote/v0-9-0.md +43 -0
- package/docs/vexJsonSchema.md +17 -0
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -73,7 +73,10 @@ Read from `vex.config.json → jsonSchemaDir` (this repo: `./output/jsonSchema`)
|
|
|
73
73
|
- **Read-only mode means troubleshoot.** When the file policy is read-only, diagnose and report. Do not
|
|
74
74
|
attempt the edit, and do not request a wider mode — the user grants it when they want the change.
|
|
75
75
|
- **Only write js-doc/comment when need.** only leave js-doc/comment when things is complex and name does not tell what it does, only write short and clean comment. A comment earns its place only for what the code cannot say: a non-obvious rule, a workaround, a failure mode. If a comment would have to be edited together with the line below it, delete the comment. no history, no restating the signature.
|
|
76
|
-
- **never
|
|
76
|
+
- **Bump the version with `npm version`, never by hand.** `npm version <patch|minor|major>` runs the
|
|
77
|
+
`preversion` / `postversion` hooks; editing `version` in `package.json` / `package-lock.json`
|
|
78
|
+
yourself skips them. The `postversion` hook runs the build and pushes, so a bump is a publish
|
|
79
|
+
action — do it only when the user asks.
|
|
77
80
|
|
|
78
81
|
## Conventions
|
|
79
82
|
|
package/dist/index.js
CHANGED
|
@@ -978,7 +978,7 @@ export const {{documentName}}Model: Model<{{documentName}}Document> = model<{{do
|
|
|
978
978
|
*/
|
|
979
979
|
`}c6.getGenaratorHeaderComment=Q_e;c6.defaultCompilerOptions={headerComment:Q_e(),use_id:!1};c6.default={getGenaratorHeaderComment:Q_e,defaultCompilerOptions:c6.defaultCompilerOptions}});var UFe=vs(Vg=>{"use strict";var xMr=Vg&&Vg.__createBinding||(Object.create?function(a,s,c,p){p===void 0&&(p=c);var d=Object.getOwnPropertyDescriptor(s,c);(!d||("get"in d?!s.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return s[c]}}),Object.defineProperty(a,p,d)}:function(a,s,c,p){p===void 0&&(p=c),a[p]=s[c]}),DMr=Vg&&Vg.__setModuleDefault||(Object.create?function(a,s){Object.defineProperty(a,"default",{enumerable:!0,value:s})}:function(a,s){a.default=s}),jFe=Vg&&Vg.__importStar||function(a){if(a&&a.__esModule)return a;var s={};if(a!=null)for(var c in a)c!=="default"&&Object.prototype.hasOwnProperty.call(a,c)&&xMr(s,a,c);return DMr(s,a),s},bMr=Vg&&Vg.__awaiter||function(a,s,c,p){function d(_){return _ instanceof c?_:new c(function(h){h(_)})}return new(c||(c=Promise))(function(_,h){function y(C){try{x(p.next(C))}catch(T){h(T)}}function v(C){try{x(p.throw(C))}catch(T){h(T)}}function x(C){C.done?_(C.value):d(C.value).then(y,v)}x((p=p.apply(a,s||[])).next())})},the=Vg&&Vg.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(Vg,"__esModule",{value:!0});Vg.compileFromFile=Vg.json2Mongoose=void 0;var EMr=jFe(require("util")),LFe=jFe(require("fs")),CMr=the(IFe()),ehe=the(Z_e()),AMr=the(Y_e());function RFe(a){switch(a.toLocaleLowerCase()){case"unix":case"unixtime":case"unix-time":return"new Date().getTime()";case"date":return"new Date().toISOString().slice(0, 10)";case"time":return"new Date().toISOString().slice(11, 19)";case"datetime":case"date-time":return"new Date().toISOString()";default:return a}}function MFe(a,s){var c,p;let d={onCreate:{},onUpdate:{}},_=s.type==="object"?s.properties:((c=s.items)===null||c===void 0?void 0:c.type)==="object"?s.items.properties:s;return s.type==="object"||((p=s.items)===null||p===void 0?void 0:p.type)==="object"?Object.keys(_).forEach(h=>{let y=_[h],v=MFe(h,y);Object.keys(v.onCreate).forEach(x=>{let C=[a,x].filter(T=>T).join(".");d.onCreate[C]=v.onCreate[x]}),Object.keys(v.onUpdate).forEach(x=>{let C=[a,x].filter(T=>T).join(".");d.onUpdate[C]=v.onUpdate[x]})}):a&&(s["x-onCreateValue"]&&(d.onCreate[a]=RFe(s["x-onCreateValue"])),s["x-onUpdateValue"]&&(d.onUpdate[a]=RFe(s["x-onUpdateValue"]))),d}function qFe(a,s){var c;let p={},d=a.required||[],_=a.index||[];for(let h in a.properties){let y=a.properties[h];if(!s.use_id&&h==="_id"||typeof y.type!="string")continue;let v=C=>{switch(C.toLowerCase()){case"string":return"{{String}}";case"integer":case"float":case"number":return"{{Number}}";case"boolean":return"{{Boolean}}";case"null":return"{{null}}";default:throw new Error(`Unsupported type [${C}]`)}},x=(C,T,N)=>{let F={type:"String",index:N.index||!!N["x-foreignKey"]||_.includes(h)||!1,required:N.required||d.includes(h)||!1};switch(T.toLowerCase()){case"string":if(N["x-foreignKey"]){let P=N["x-format"]=="ObjectId"?"Schema.Types.ObjectId":"String";F.type=`{{${P}}}`}else F.type="{{String}}";break;case"integer":case"float":case"number":F.type="{{Number}}";break;case"boolean":F.type="{{Boolean}}";break;case"null":F.type="{{null}}";break;case"array":if(N.items)if(N.items.type=="object"){if(!N.items.properties)throw new Error(`"${C}" Array items as object must have properties defined !`);F.type=[x(C,N.items.type,N.items)]}else if(N.items["x-foreignKey"]){let P=N.items["x-format"]=="ObjectId"?"Schema.Types.ObjectId":"String";F.type=[`{{${P}}}`]}else F.type=[v(N.items.type)];break;case"object":F=qFe(N,s);break;default:throw new Error(`Unsupported type [${N.type}]`)}return F};p[h]=x(h,y.type,y),y.default&&(p[h].default=y.default),(y["x-foreignKey"]||!((c=y.items)===null||c===void 0)&&c["x-foreignKey"])&&(p[h].ref=y["x-foreignKey"]||y.items["x-foreignKey"])}return p}function $Fe(a,s,c){if(!a["x-documentConfig"])throw new Error("( jsonSchema.x-documentConfig : object ) is required");let d=a["x-documentConfig"].documentName,_=qFe(a,c||ehe.default.defaultCompilerOptions),y=EMr.inspect(_,{depth:null}).replace(/'{{/g,"").replace(/}}'/g,"").replace(/"{{/g,"").replace(/}}"/g,""),v=MFe(void 0,a);return CMr.default.modelsTemplate(s,d,y,v,c||ehe.default.defaultCompilerOptions)}Vg.json2Mongoose=$Fe;function SMr(a,s,c,p){return bMr(this,void 0,void 0,function*(){try{AMr.default.process(`Model : ${a} > ${c}`);let d=LFe.readFileSync(a),_=JSON.parse(d.toString()),h=$Fe(_,s,p||ehe.default.defaultCompilerOptions);return LFe.writeFileSync(c,h),h}catch(d){throw new Error(`Processing File [${a}] :
|
|
980
980
|
${d.message||d}`)}})}Vg.compileFromFile=SMr});var zFe=vs(z7=>{"use strict";var wMr=z7&&z7.__createBinding||(Object.create?function(a,s,c,p){p===void 0&&(p=c);var d=Object.getOwnPropertyDescriptor(s,c);(!d||("get"in d?!s.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return s[c]}}),Object.defineProperty(a,p,d)}:function(a,s,c,p){p===void 0&&(p=c),a[p]=s[c]}),TMr=z7&&z7.__setModuleDefault||(Object.create?function(a,s){Object.defineProperty(a,"default",{enumerable:!0,value:s})}:function(a,s){a.default=s}),rhe=z7&&z7.__importStar||function(a){if(a&&a.__esModule)return a;var s={};if(a!=null)for(var c in a)c!=="default"&&Object.prototype.hasOwnProperty.call(a,c)&&wMr(s,a,c);return TMr(s,a),s},KFe=z7&&z7.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(z7,"__esModule",{value:!0});z7.genarate=void 0;var CT=rhe(require("fs")),JFe=rhe(OFe()),HFe=rhe(UFe()),kMr=KFe(require("path")),VFe=KFe(Z_e()),FMr=(a,s)=>kMr.default.relative(a,s).replace(/\\/g,"/");function GFe(a,s,c,p){CT.readdir(a,(d,_)=>{if(d){console.log(d);return}CT.existsSync(s)&&CT.rmSync(s,{recursive:!0}),CT.mkdirSync(s),CT.existsSync(c)&&CT.rmSync(c,{recursive:!0}),CT.mkdirSync(c),_.forEach(h=>{var y;try{if(!h.endsWith(".json"))return;let v=CT.readFileSync(`${a}/${h}`),C=(y=JSON.parse(v.toString())["x-documentConfig"])===null||y===void 0?void 0:y.documentName;if(!C)throw new Error(`invalid "x-documentConfig.documentName" in ${a}/${h}`);JFe.compileFromFile(`${a}/${h}`,`${c}/${C}.ts`,p||VFe.default.defaultCompilerOptions),HFe.compileFromFile(`${a}/${h}`,`${FMr(s,c)}/${C}`,`${s}/${C}Model.ts`,p||VFe.default.defaultCompilerOptions)}catch(v){console.error("\x1B[31m%s\x1B[0m",`Processing File : ${a}/${h}
|
|
981
|
-
`,v)}})})}z7.genarate=GFe;z7.default={genarate:GFe,typesGen:JFe,modelsGen:HFe}});var KO=nd(require("fs")),m9e=nd(require("child_process")),g9e=nd(l3e());var w3=nd(require("fs")),Y_=nd(require("path"));var Qd=nd(require("fs")),KE=nd(require("path"));function lCr(a,...s){console.log("\x1B[34m%s\x1B[0m","[PROCESSING]",a,s.length>0?s:"")}function pCr(a,...s){console.log("\x1B[32m%s\x1B[0m","[WRITING]",a,s.length>0?s:"")}function fCr(a,...s){console.log("\x1B[36m%s\x1B[0m","[INFO]",a,s.length>0?s:"")}function dCr(a,...s){console.log("\x1B[33m%s\x1B[0m","[WARN]",a,s.length>0?s:"")}function _Cr(a,...s){console.log("\x1B[41m%s\x1B[0m","[ERROR]",a,s.length>0?s:""),process.exit(1)}var A0={process:lCr,writing:pCr,info:fCr,warn:dCr,error:_Cr};var Z5={name:"very-express",version:"0.
|
|
981
|
+
`,v)}})})}z7.genarate=GFe;z7.default={genarate:GFe,typesGen:JFe,modelsGen:HFe}});var KO=nd(require("fs")),m9e=nd(require("child_process")),g9e=nd(l3e());var w3=nd(require("fs")),Y_=nd(require("path"));var Qd=nd(require("fs")),KE=nd(require("path"));function lCr(a,...s){console.log("\x1B[34m%s\x1B[0m","[PROCESSING]",a,s.length>0?s:"")}function pCr(a,...s){console.log("\x1B[32m%s\x1B[0m","[WRITING]",a,s.length>0?s:"")}function fCr(a,...s){console.log("\x1B[36m%s\x1B[0m","[INFO]",a,s.length>0?s:"")}function dCr(a,...s){console.log("\x1B[33m%s\x1B[0m","[WARN]",a,s.length>0?s:"")}function _Cr(a,...s){console.log("\x1B[41m%s\x1B[0m","[ERROR]",a,s.length>0?s:""),process.exit(1)}var A0={process:lCr,writing:pCr,info:fCr,warn:dCr,error:_Cr};var Z5={name:"very-express",version:"0.9.0",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",postversion:"npm run build && git push && git push --tags",test:"npm run compile && vitest run","test:watch":"vitest","test:update":"npm run compile && UPDATE_GOLDEN=1 vitest run","test:e2e":"npm run compile && VEX_E2E=1 vitest run test/e2e"},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.19.39","@types/passport":"^1.0.16","@types/pg":"^8.20.0","@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",knex:"^3.2.9",minimist:"^1.2.8",mongoose:"^8.7.1",mysql2:"^3.22.0",objection:"^3.1.5",pg:"^8.20.0","ts-node":"^10.9.2",typescript:"^5.3.3",vitest:"^2.1.9"}};function Fpe(a){return`/**
|
|
982
982
|
* Generated by veryExpress@${a}
|
|
983
983
|
* https://github.com/Justin26l/VeryExpress
|
|
984
984
|
*/
|
|
@@ -989,7 +989,7 @@ export const {{documentName}}Model: Model<{{documentName}}Document> = model<{{do
|
|
|
989
989
|
`}function gCr(){return`// Generated by veryExpress@${Z5.version}`}function yCr(){return"// Generated by veryExpress"}function eT(a){return Object.keys(a.auth.oauthProviders).filter(s=>a.auth.oauthProviders[s]===!0)}function mY(a){return a.auth.localAuth||eT(a).length>0||a.auth.firebase===!0}function gY(a){return mY(a)&&a.auth.firebase===!0}function yY(a){var s;return mY(a)&&((s=a.auth.deleteAccount)!=null?s:!0)}function Ppe(a){var c,p;let s=(p=(c=a.app)==null?void 0:c.showSoftDeleted)!=null?p:!1;return s&&A0.warn("app.showSoftDeleted is ON \u2014 soft-deleted rows are visible to every query, are writable again through the ordinary CRUD path, and the account-state guard in Authentication.middleware will keep rejecting tombstones. Unset app.showSoftDeleted to restore the default (hidden)."),s}function bO(a){var c;let s=(c=a.useRBAC)==null?void 0:c.roles;return Array.isArray(s)&&s.length>0}var Ope={rootDir:".",srcDir:"./src",sysDir:"./src/system",jsonSchemaDir:"./jsonSchema",openapiDir:"./openapi",generator:{commitBeforeGenerate:!1},app:{enableSwagger:!0,useUserSchema:!0,useStatefulRedisAuth:!1,allowApiCreateUpdate_id:!1,showSoftDeleted:!1},useRBAC:{roles:["user"],default:"user"},auth:{localAuth:!0,useHttpOnlyCookieToken:!1,deleteAccount:!0,firebase:!1,oauthProviders:{google:!1,microsoft:!1,apple:!1,github:!1}},_:{writtedDir:[]},dbType:"sql"},p3e={defaultCompilerOptions:Ope,getDefaultHeaderComment:Fpe,getStaticHeaderComment:mCr,getSimpleHeaderComment:gCr,getSimpleStaticHeaderComment:yCr,OAuthProviders:eT,isAuthEnabled:mY,isFirebaseAuthEnabled:gY,isRbacEnabled:bO,isAccountDeletionEnabled:yY,isShowSoftDeleted:Ppe};var vY=[],E3=Ope,tT={files:{}};function vCr(){vY.length=0}function d3e(){return KE.default.posix.join((E3==null?void 0:E3.rootDir)||".",".vex","meta.json")}function xCr(a){let s={};for(let[c,p]of Object.entries(a)){let d=c.split("/"),_=s;for(let h=0;h<d.length-1;h++)_[d[h]]=_[d[h]]||{},_=_[d[h]];_[d[d.length-1]]=p}return s}function _3e(a,s=""){let c={};for(let[p,d]of Object.entries(a)){let _=s?`${s}/${p}`:p;d&&typeof d=="object"&&!("lastWriteVersion"in d)?Object.assign(c,_3e(d,_)):c[_]=d}return c}function h3e(){try{let a=d3e(),s=KE.default.posix.dirname(a);Qd.default.existsSync(s)||Qd.default.mkdirSync(s,{recursive:!0});let c={lastGeneratedVersion:tT.lastGeneratedVersion,files:xCr(tT.files)};Qd.default.writeFileSync(a,JSON.stringify(c,null,2),"utf8")}catch(a){A0.warn(`flushVexMeta error: ${a.message}`)}}function DCr(){let a=d3e();try{if(Qd.default.existsSync(a)){let s=JSON.parse(Qd.default.readFileSync(a,"utf8")||"{}");tT={lastGeneratedVersion:s.lastGeneratedVersion,files:_3e(s.files||{})}}else tT={files:{}}}catch(s){tT={files:{}}}}var bCr=Fpe(Z5.version);function f3e(a){return a.replace(/\r\n/g,`
|
|
990
990
|
`).replace(/[ \t]+$/gm,"").trim()}function ECr(a){return a.replace(/(^\w|_\w)/g,s=>s.replace(/_/,"").toUpperCase())}function CCr(a){return a.replace(/(^\w|_\w)/g,s=>s.replace(/_/,"").toLowerCase())}var ACr=(a,s)=>KE.default.relative(a,s).replace(/\\/g,"/");function SCr(a,s){let c=Qd.default.existsSync(a);if(!c&&s)return s();if(!c)A0.error(`FILE : ${a} not found`);else try{let p=JSON.parse(Qd.default.readFileSync(a,"utf8"));if(!p)A0.error(`FILE JSON : Read Error ${a}`);else return p}catch(p){A0.error(`FILE : ${a}
|
|
991
991
|
`,p.message)}}function m3e(a,s,c){var x;let p=KE.default.dirname(s);Qd.default.existsSync(p)||Qd.default.mkdirSync(p,{recursive:!0});let d=Qd.default.existsSync(s)?Qd.default.readFileSync(s,"utf8"):"",_=/\/\*\*\r?\n \* Generated by veryExpress@[\s\S]*?\*\/\s*/g,h=f3e(d.replace(_,"")),y=/^.*({{headerComment}}|\/\/ {{headerComment}}).*$(\r?\n)?/gm,v=f3e(c.replace(y,""));if(h===v)return A0.info(`${a} : "${s}" No changes`),vY.push(s),!1;{let C=E3,T=C&&C.rootDir?KE.default.relative(C.rootDir,s).replace(/\\/g,"/"):s,N=(x=tT.files[T])==null?void 0:x.allowOverwrite,F=N!==void 0?N:!0;return!F&&Qd.default.existsSync(s)?(A0.info(`${a} : "${s}" Skip (allowOverwrite=false)`),vY.push(s),!1):(A0.writing(`${a} : "${s}"`),vY.push(s),c=c.replace(/\/\/ {{headerComment}}|{{headerComment}}/g,bCr||"// generated files by very-express"),Qd.default.writeFileSync(s,c),tT.files[T]={lastWriteVersion:Z5.version,allowOverwrite:F},h3e(),!0)}}function wCr(){E3!=null&&E3.rootDir&&(tT.lastGeneratedVersion=Z5.version,h3e())}function g3e(a,s,c,p){Qd.default.existsSync(s)||Qd.default.mkdirSync(s);let d=Qd.default.readdirSync(a);for(let _=0;_<d.length;_++){let h=d[_],y=h=="index.ts"||h.endsWith(".gen.ts")?h:h.replace(".ts",".gen.ts"),v=KE.default.posix.join(a,h),x=KE.default.posix.join(s,y);if(Qd.default.lstatSync(v).isDirectory())g3e(v,x,c,p);else if(!p&&Qd.default.existsSync(x))A0.info(`FILE : AVOID OVERWRITE, skip "${x}"`);else{let C=Qd.default.readFileSync(v,"utf8");m3e(`FILE : ${x}`,x,C)}}}function y3e(a){let s=[];if(!Qd.default.existsSync(a))return s;for(let c of Qd.default.readdirSync(a)){let p=KE.default.posix.join(a,c);Qd.default.lstatSync(p).isDirectory()?s.push(...y3e(p)):s.push(p)}return s}function TCr(){let a=E3==null?void 0:E3.sysDir;if(!a||!Qd.default.existsSync(a))return;let s=new Set(vY.map(p=>KE.default.resolve(p))),c=y3e(a);for(let p of c)s.has(KE.default.resolve(p))||(A0.info(`CLEANUP : remove stale file "${p}"`),Qd.default.rmSync(p,{force:!0}))}function kCr(a){E3=a,DCr()}function FCr(){return E3}var v3e={pascalCase:ECr,camelCase:CCr,relativePath:ACr,copyDir:g3e,loadJson:SCr,writeFile:m3e,setCompilerOptions:kCr,getCompilerOptions:FCr,saveVexMeta:wCr,resetWrittedFiles:vCr,cleanupStaleFiles:TCr};function PCr(a){return a.replace(/'FUNC{{([\s\S]*?)}}'/g,"$1")}var x3e={format:PCr};var Bpe=nd(require("fs"));var kq=(p=>(p.Role="role",p.UserId="userId",p.SoftDelete="softDelete",p))(kq||{});var Npe=(h=>(h.OnCreateTimestamp="onCreateTimestamp",h.OnCreateUnixTimestamp="onCreateUnixTimestamp",h.OnUpdateTimestamp="onUpdateTimestamp",h.OnUpdateUnixTimestamp="onUpdateUnixTimestamp",h.OnCreateUserId="onCreateUserId",h.OnUpdateUserId="onUpdateUserId",h))(Npe||{}),Ipe=["get","getList","post","put","patch","delete"],D3e=["get","post","put","patch","delete"];function OCr(a){if(!Bpe.default.existsSync(a))return A0.error(`loadJsonSchema : File Not Found ${a}`);try{return JSON.parse(Bpe.default.readFileSync(a,"utf8"))}catch(s){return A0.error(`Error Load JsonSchema :
|
|
992
|
-
`,s.message||s,a)}}function b3e(a,s){let c=JSON.parse(JSON.stringify(a)),p=Array.isArray(s),d=p?s:[],_=p?{}:s;for(let h in c)h.startsWith("x-")||p&&d.includes(h)||!p&&typeof _[h]!="undefined"&&_[h]==typeof c[h]?delete c[h]:typeof c[h]=="object"&&(c[h]=b3e(c[h],s));return c}function NCr(a,s){if(a=="getList")return"post";if(D3e.includes(a))return a;A0.error(`httpMethod : invalid method "${a}" in "${s}".`),process.exit(1)}var E3e={cleanXcustomValue:b3e,httpMethod:NCr,loadJsonSchema:OCr};function ICr(a,s){if(a!==void 0&&typeof a!="boolean")throw new Error(`vex.config.${s} must be true or false, got ${JSON.stringify(a)}`)}function BCr(a){var s;if(!a)throw new Error("vex.config is undefined");if(!a.srcDir)throw new Error("vex.config.srcDir is undefined");if(!a.sysDir)throw new Error("vex.config.sysDir is undefined");if(!a.openapiDir)throw new Error("vex.config.openapiDir is undefined");if(!a.jsonSchemaDir)throw new Error("vex.config.jsonSchemaDir is undefined");ICr((s=a.auth)==null?void 0:s.firebase,"auth.firebase")}var C3e={checkConfigValid:BCr};var qu={common:v3e,generator:p3e,template:x3e,jsonSchema:E3e,logger:A0,configChecker:C3e};function A3e(a){let s={};a.forEach(c=>{c.schema.parentSchemas={},s[c.config.documentName]=c.schema}),a.forEach(c=>{s=jCr(s,c.schema)}),a.forEach(c=>{if(c.config.restApi.joinWhitelist==null){let p=RCr(c.schema);c.config.restApi.joinWhitelist=p,c.schema["x-documentConfig"].restApi.joinWhitelist=p,LCr(c.path,p)}})}function LCr(a,s){try{let c=qu.jsonSchema.loadJsonSchema(a);c["x-documentConfig"].restApi.joinWhitelist=s,qu.common.writeFile("Json Schema restApi.joinWhitelist",a,JSON.stringify(c,null,4))}catch(c){console.warn(`[warn] Failed to write restApi.joinWhitelist to ${a}:`,c)}}function RCr(a){var c,p,d;let s=new Set;for(let _ of Object.values((c=a.properties)!=null?c:{})){let h=_["x-foreignKey"];h&&s.add(qu.common.camelCase(h.schemaName))}for(let _ of(d=(p=a.interface)==null?void 0:p.fkProps)!=null?d:[])s.add(qu.common.camelCase(_.propName));return Array.from(s)}function jCr(a,s){return Object.keys(s.properties).forEach(c=>{var _,h;let d=s.properties[c]["x-foreignKey"];if(d){let y=qu.common.pascalCase(s["x-documentConfig"].documentName),v=qu.common.camelCase(s["x-documentConfig"].documentName);(_=a[d.schemaName])!=null&&_.interface||(a[d.schemaName].interface={fkProps:[]}),(h=a[d.schemaName].interface)==null||h.fkProps.push({propName:v,interfaceName:y,relationType:d.relationType==="many-to-one"?"one-to-many":"one-to-one",imports:[]})}}),a}var w3e=nd(require("fs")),T3e=nd(require("path"));function k3e(a,s){let c=qu.jsonSchema.loadJsonSchema(a);return typeof c.properties!="object"&&A0.error(`"properties" format is invalid in ${a}`),MCr(c,a),qCr(c,a),$Cr(c,a),UCr(c,a),c.required=Rpe(c,a),s.dbType==="sql"&&VCr(c,a,s),qu.common.writeFile("Json Schema Formatting",a,JSON.stringify(c,null,4)),c}function MCr(a,s){a.type!=="object"&&a.type!=="array"&&A0.error(`Json Schema Formatting: "${s}" root type must be "object" or "array".`)}function qCr(a,s){var p,d;let c=((p=s.split("/").pop())==null?void 0:p.split(".")[0])||"Unknown_File_Name";a["x-documentConfig"]||A0.error(`Json Schema Formatting: "${s}" x-documentConfig not found.`),a["x-documentConfig"].documentName||(A0.warn(`Json Schema Formatting: "${s}" x-documentConfig.documentName added.`),a["x-documentConfig"].documentName=c),a["x-documentConfig"].restApi||(A0.warn(`Json Schema Formatting: "${s}" x-documentConfig.restApi not found, supported restApi.methods added.`),a["x-documentConfig"].restApi={methods:Object.assign([],Ipe)}),(d=a["x-documentConfig"].restApi)!=null&&d.methods||(A0.warn(`Json Schema Formatting: "${s}" x-documentConfig.restApi.methods not found, supported restApi.methods added.`),a["x-documentConfig"].restApi.methods=Object.assign([],Ipe)),a["x-documentConfig"].documentName!=c&&A0.error(`Json Schema Formatting: "${s}" x-documentConfig.documentName is not consistant with file name.`)}function $Cr(a,s){let c=["one-to-one","many-to-one"],p=d=>d&&typeof d=="object"&&typeof d.schemaName=="string"&&typeof d.fieldName=="string"&&c.includes(d.relationType);for(let d in a.properties){let _=a.properties[d]["x-foreignKey"];_&&(_.relationType==="many-to-many"&&A0.error(`Json Schema Formatting: "${s}" property "${d}" has foreignKey with relationType "many-to-many" is invalid. make a join table instead.`),_.relationType==="one-to-many"?A0.error(`Json Schema Formatting: "${s}" property "${d}" has foreignKey with relationType "one-to-many" is not allowed. Define "many-to-one" on the owning side instead; the inverse "one-to-many" is auto-generated.`):p(_)||A0.error(`Json Schema Formatting: "${s}" x-foreignKey config is invalid on property "${d}".`))}return!0}var S3e={Primary:["string"],PrimaryUUID:["string"],UUID:["string"],ObjectId:["string"],UnixTimestamp:["integer"],Timestamp:["string"]};function UCr(a,s){let c=(p,d)=>{var _;for(let h of Object.keys(p)){let y=p[h],v=y["x-format"];if(v&&S3e[v]){let x=S3e[v];x.includes(y.type)||A0.error(`Json Schema Formatting: "${s}" property "${d}${h}" has x-format "${v}" but type is "${y.type}" \u2014 expected: ${x.join(" | ")}.`)}y.type==="object"&&y.properties?c(y.properties,`${d}${h}.`):y.type==="array"&&((_=y.items)==null?void 0:_.type)==="object"&&y.items.properties&&c(y.items.properties,`${d}${h}[].`)}};a.properties&&c(a.properties,"")}function F3e(a){if(!qu.generator.isRbacEnabled(a.compilerOptions)||a.compilerOptions.dbType!=="sql")return;let s=a.compilerOptions.useRBAC.roles,c=T3e.default.posix.join(a.compilerOptions.jsonSchemaDir,"UserRole.json");if(!w3e.default.existsSync(c)){A0.warn(`Json Schema Formatting: UserRole.json not found at ${c}, skipping role enum sync.`);return}let p=qu.common.loadJson(c);for(let d in p.properties){let _=p.properties[d];if(_["x-vexData"]==="role"&&_.enum!==s){_.type="string",_.enum=s,A0.process(`Json Schema Formatting: update role definitions UserRole.${d} enum -> [${s.join(", ")}]`);break}}qu.common.writeFile("Role Schema Formatting",c,JSON.stringify(p,null,4))}function Rpe(a,s){let c,p=[],d=_=>!!(_.type=="array"&&_.items&&_.items.type=="object");if(d(a))c=a.items.properties,p=typeof a.items.required=="object"?a.items.required:[];else if(a.type=="object")c=a.properties,p=typeof a.required=="object"?a.required:[];else return;return c==null?A0.error(`formatJsonSchema > formatRequired : invalid "schema.properties" in ${s}`,a):Object.keys(c).forEach(_=>{let h=c==null?void 0:c[_],y=!p.includes(_);h&&h.type!=="object"&&h.required===!0&&y?p.push(_):h&&h.items&&d(h)?h.items.required=Rpe(h.items,s):h&&h.type=="object"&&(h.required=Rpe(h,s),h.required&&h.required.length>0&&y&&p.push(_))}),p}function VCr(a,s,c){let p=v=>{if(v)if(v.type==="object"&&v.properties){let x=v.properties;for(let C of Object.keys(x)){let T=x[C];if(T){if(T["x-format"]==="ObjectId"){let N=C==="_id";T["x-format"]=N?"Primary":void 0,T.type="string",A0.warn("[JsonSchema]",`SQL target: ${N?"converted":"removed"} x-format ObjectId ${N?"-> Primary":""} for property "${C}" in ${s}`)}T&&(T.type==="object"||T.type==="array"&&T.items)&&p(T)}}}else v.type==="array"&&v.items&&p(v.items)};c.dbType==="sql"&&p(a);let d=[],_=v=>v?!!(v.index||v["x-foreignKey"]||v["x-vexData"]||v["x-vex-data"]):!1,h=(v,x,C,T=!1)=>{_(C)&&d.push(T?`${v}[].${x}`:`${v}.${x}`)},y=(v,x)=>{if(v)if(v.type==="object"&&v.properties)for(let C of Object.keys(v.properties)){let T=v.properties[C],N=x?`${x}.${C}`:C;if(T.type==="object"){if(T.properties)for(let F of Object.keys(T.properties))h(N,F,T.properties[F],!1);y(T,N)}else if(T.type==="array"&&T.items&&T.items.type==="object"){if(T.items.properties)for(let F of Object.keys(T.items.properties))h(N,F,T.items.properties[F],!0);y(T.items,N+"[]")}else y(T,N)}else v.type==="array"&&v.items&&y(v.items,x+"[]")};y(a,""),d.length>0&&d.forEach(v=>{A0.warn(`SQL target: ${s} nested object/array contains unsupported index/x-foreignKey/x-vex-data -> ${v}. Consider modelling as separate document/table.`)})}var KCr=Object.values(Npe),P3e={Primary:"uuid",PrimaryUUID:"uuid",UUID:"uuid",UnixTimestamp:"bigint",Timestamp:"timestamptz"};function jne(a){return typeof a=="string"&&KCr.includes(a)}function O3e(a){return(a==null?void 0:a["x-vexData"])==="userId"}function N3e(a){return a["x-format"]==="Primary"||a["x-format"]==="PrimaryUUID"}function Mpe(a){let s=a["x-format"];return typeof s=="string"&&P3e[s]?P3e[s]:a.format==="uuid"?"uuid":Array.isArray(a.enum)?"enum":a.type==="integer"?"bigint":"other"}function JE(a){var c;let s=[];for(let[p,d]of Object.entries((c=a.properties)!=null?c:{}))jne(d==null?void 0:d.default)&&s.push({field:p,type:d.default});return s}function I3e(a){var c;let s=JSON.parse(JSON.stringify(a));for(let p of Object.values((c=s.properties)!=null?c:{}))jne(p==null?void 0:p.default)&&delete p.default;return s}function B3e(a){return JE(a).length>0}function Mne(a,s){var p,d;let c=JE(a).map(_=>_.field);for(let[_,h]of Object.entries((p=a.properties)!=null?p:{}))(h==null?void 0:h["x-vexData"])==="softDelete"&&!c.includes(_)&&c.push(_);if(!s)for(let[_,h]of Object.entries((d=a.properties)!=null?d:{}))h&&N3e(h)&&!c.includes(_)&&c.push(_);return c}function AO(a){var c,p,d;let s=[];for(let _ of a){let h=(p=(c=_.schema["x-documentConfig"])==null?void 0:c.documentName)!=null?p:_.path;for(let[y,v]of Object.entries((d=_.schema.properties)!=null?d:{}))O3e(v)&&s.push({documentName:h,schemaPath:_.path,field:y,prop:v})}return s[0]}function CO(a,s,c){return`${s}.${c} (${a})`}function JCr(a,s){var d,_;let c=(_=(d=s.schema["x-documentConfig"])==null?void 0:d.documentName)!=null?_:s.path,p=Array.isArray(s.schema.required)?s.schema.required:[];for(let h of JE(s.schema)){let y=s.schema.properties[h.field],v=CO(s.path,c,h.field);(p.includes(h.field)||y.required===!0)&&a.problems.push(`"${v}" is declared with default "${h.type}" but is marked required. Auto-written fields are filled by the server and must not be required from the client.`)}}function HCr(a,s){var p,d;let c=(d=(p=s.schema["x-documentConfig"])==null?void 0:p.documentName)!=null?d:s.path;for(let _ of JE(s.schema)){let h=s.schema.properties[_.field],y=CO(s.path,c,_.field);_.type==="onCreateTimestamp"||_.type==="onUpdateTimestamp"?(h.type!=="string"||h["x-format"]!=="Timestamp")&&a.problems.push(`"${y}" is declared with default "${_.type}" \u2014 expected { "type": "string", "x-format": "Timestamp" }.`):(_.type==="onCreateUnixTimestamp"||_.type==="onUpdateUnixTimestamp")&&(h.type!=="integer"||h["x-format"]!=="UnixTimestamp")&&a.problems.push(`"${y}" is declared with default "${_.type}" \u2014 expected { "type": "integer", "x-format": "UnixTimestamp" }.`)}}function GCr(a,s){var h,y;let c=a.identity;if(!c)return;let p=(y=(h=s.schema["x-documentConfig"])==null?void 0:h.documentName)!=null?y:s.path,d=Mpe(c.prop),_=CO(c.schemaPath,c.documentName,c.field);for(let v of JE(s.schema)){if(!(v.type==="onCreateUserId"||v.type==="onUpdateUserId"))continue;let C=s.schema.properties[v.field],T=CO(s.path,p,v.field);Mpe(C)!==d&&a.problems.push(`"${T}" is declared with default "${v.type}" but resolves to a "${Mpe(C)}" column, while the x-vexData "userId" field resolves to "${d}" \u2014 identity source: "${_}". Both sides must use the same column type.`)}}function zCr(a,s){var d,_,h;let c=(_=(d=s.schema["x-documentConfig"])==null?void 0:d.documentName)!=null?_:s.path,p=Object.values(kq);for(let[y,v]of Object.entries((h=s.schema.properties)!=null?h:{})){let x=v==null?void 0:v["x-vexData"];x!==void 0&&(typeof x!="string"||!p.includes(x))&&a.problems.push(`"${CO(s.path,c,y)}" has x-vexData "${String(x)}" \u2014 expected one of: ${p.join(" | ")}.`)}}function WCr(a){let s=a.identity;if(!s)return;let c=CO(s.schemaPath,s.documentName,s.field),p=Array.isArray(s.prop.required)?s.prop.required:[];s.prop.type!=="string"&&a.problems.push(`"${c}" is tagged x-vexData "userId" but type is "${s.prop.type}" \u2014 expected "string".`),s.prop.index!==!0&&!N3e(s.prop)&&!p.includes(s.field)&&a.problems.push(`"${c}" is tagged x-vexData "userId" but is not indexed \u2014 add "index": true; it is used as the lookup key by the token refresh flow.`)}function YCr(a,s){a.documents.some(p=>JE(p.schema).some(d=>d.type==="onCreateUserId"))&&(mY(s)||a.problems.push('Schema declares "onCreateUserId" but the app enables no authentication (auth.localAuth is false and no oauth provider is on) \u2014 no request can ever carry an identity, so every create of that entity would fail. Enable an auth method or remove the keyword.'))}function L3e(a,s){var _,h,y;let c=[];for(let v of a){let x=(h=(_=v.schema["x-documentConfig"])==null?void 0:_.documentName)!=null?h:v.path;for(let[C,T]of Object.entries((y=v.schema.properties)!=null?y:{}))O3e(T)&&c.push({documentName:x,schemaPath:v.path,field:C,prop:T})}let p={documents:a,identity:c[0],problems:[]};if(c.length>1){let v=c.map(x=>CO(x.schemaPath,x.documentName,x.field));p.problems.push(`x-vexData "userId" is declared on ${c.length} fields [${v.join(", ")}] \u2014 exactly one identity source is allowed.`)}a.some(v=>JE(v.schema).some(x=>x.type==="onCreateUserId"||x.type==="onUpdateUserId"))&&!p.identity&&p.problems.push('Schema declares "onCreateUserId" / "onUpdateUserId" defaults but no field is tagged x-vexData "userId" \u2014 the framework has no identity source to read from.'),WCr(p),YCr(p,s);for(let v of a)zCr(p,v),JCr(p,v),HCr(p,v),GCr(p,v);return p.problems.length>0&&A0.error(`Audit field definition error:
|
|
992
|
+
`,s.message||s,a)}}function b3e(a,s){let c=JSON.parse(JSON.stringify(a)),p=Array.isArray(s),d=p?s:[],_=p?{}:s;for(let h in c)h.startsWith("x-")||p&&d.includes(h)||!p&&typeof _[h]!="undefined"&&_[h]==typeof c[h]?delete c[h]:typeof c[h]=="object"&&(c[h]=b3e(c[h],s));return c}function NCr(a,s){if(a=="getList")return"post";if(D3e.includes(a))return a;A0.error(`httpMethod : invalid method "${a}" in "${s}".`),process.exit(1)}var E3e={cleanXcustomValue:b3e,httpMethod:NCr,loadJsonSchema:OCr};function ICr(a,s){if(a!==void 0&&typeof a!="boolean")throw new Error(`vex.config.${s} must be true or false, got ${JSON.stringify(a)}`)}function BCr(a){var s;if(!a)throw new Error("vex.config is undefined");if(!a.srcDir)throw new Error("vex.config.srcDir is undefined");if(!a.sysDir)throw new Error("vex.config.sysDir is undefined");if(!a.openapiDir)throw new Error("vex.config.openapiDir is undefined");if(!a.jsonSchemaDir)throw new Error("vex.config.jsonSchemaDir is undefined");ICr((s=a.auth)==null?void 0:s.firebase,"auth.firebase")}var C3e={checkConfigValid:BCr};var qu={common:v3e,generator:p3e,template:x3e,jsonSchema:E3e,logger:A0,configChecker:C3e};function A3e(a){let s={};a.forEach(c=>{c.schema.parentSchemas={},s[c.config.documentName]=c.schema}),a.forEach(c=>{s=jCr(s,c.schema)}),a.forEach(c=>{if(c.config.restApi.joinWhitelist==null){let p=RCr(c.schema);c.config.restApi.joinWhitelist=p,c.schema["x-documentConfig"].restApi.joinWhitelist=p,LCr(c.path,p)}})}function LCr(a,s){try{let c=qu.jsonSchema.loadJsonSchema(a);c["x-documentConfig"].restApi.joinWhitelist=s,qu.common.writeFile("Json Schema restApi.joinWhitelist",a,JSON.stringify(c,null,4))}catch(c){console.warn(`[warn] Failed to write restApi.joinWhitelist to ${a}:`,c)}}function RCr(a){var c,p,d;let s=new Set;for(let _ of Object.values((c=a.properties)!=null?c:{})){let h=_["x-foreignKey"];h&&s.add(qu.common.camelCase(h.schemaName))}for(let _ of(d=(p=a.interface)==null?void 0:p.fkProps)!=null?d:[])s.add(qu.common.camelCase(_.propName));return Array.from(s)}function jCr(a,s){return Object.keys(s.properties).forEach(c=>{var _,h;let d=s.properties[c]["x-foreignKey"];if(d){let y=qu.common.pascalCase(s["x-documentConfig"].documentName),v=qu.common.camelCase(s["x-documentConfig"].documentName);(_=a[d.schemaName])!=null&&_.interface||(a[d.schemaName].interface={fkProps:[]}),(h=a[d.schemaName].interface)==null||h.fkProps.push({propName:v,interfaceName:y,relationType:d.relationType==="many-to-one"?"one-to-many":"one-to-one",imports:[]})}}),a}var w3e=nd(require("fs")),T3e=nd(require("path"));function k3e(a,s){let c=qu.jsonSchema.loadJsonSchema(a);return typeof c.properties!="object"&&A0.error(`"properties" format is invalid in ${a}`),MCr(c,a),qCr(c,a),$Cr(c,a),UCr(c,a),c.required=Rpe(c,a),s.dbType==="sql"&&VCr(c,a,s),qu.common.writeFile("Json Schema Formatting",a,JSON.stringify(c,null,4)),c}function MCr(a,s){a.type!=="object"&&a.type!=="array"&&A0.error(`Json Schema Formatting: "${s}" root type must be "object" or "array".`)}function qCr(a,s){var p,d;let c=((p=s.split("/").pop())==null?void 0:p.split(".")[0])||"Unknown_File_Name";a["x-documentConfig"]||A0.error(`Json Schema Formatting: "${s}" x-documentConfig not found.`),a["x-documentConfig"].documentName||(A0.warn(`Json Schema Formatting: "${s}" x-documentConfig.documentName added.`),a["x-documentConfig"].documentName=c),a["x-documentConfig"].restApi||(A0.warn(`Json Schema Formatting: "${s}" x-documentConfig.restApi not found, supported restApi.methods added.`),a["x-documentConfig"].restApi={methods:Object.assign([],Ipe)}),(d=a["x-documentConfig"].restApi)!=null&&d.methods||(A0.warn(`Json Schema Formatting: "${s}" x-documentConfig.restApi.methods not found, supported restApi.methods added.`),a["x-documentConfig"].restApi.methods=Object.assign([],Ipe)),a["x-documentConfig"].documentName!=c&&A0.error(`Json Schema Formatting: "${s}" x-documentConfig.documentName is not consistant with file name.`)}function $Cr(a,s){let c=["one-to-one","many-to-one"],p=d=>d&&typeof d=="object"&&typeof d.schemaName=="string"&&typeof d.fieldName=="string"&&c.includes(d.relationType);for(let d in a.properties){let _=a.properties[d]["x-foreignKey"];_&&(_.relationType==="many-to-many"&&A0.error(`Json Schema Formatting: "${s}" property "${d}" has foreignKey with relationType "many-to-many" is invalid. make a join table instead.`),_.relationType==="one-to-many"?A0.error(`Json Schema Formatting: "${s}" property "${d}" has foreignKey with relationType "one-to-many" is not allowed. Define "many-to-one" on the owning side instead; the inverse "one-to-many" is auto-generated.`):p(_)||A0.error(`Json Schema Formatting: "${s}" x-foreignKey config is invalid on property "${d}".`))}return!0}var S3e={Primary:["string"],PrimaryUUID:["string"],UUID:["string"],ObjectId:["string"],UnixTimestamp:["integer"],Timestamp:["string"],Binary:["string"]};function UCr(a,s){let c=(p,d)=>{var _;for(let h of Object.keys(p)){let y=p[h],v=y["x-format"];if(v&&S3e[v]){let x=S3e[v];x.includes(y.type)||A0.error(`Json Schema Formatting: "${s}" property "${d}${h}" has x-format "${v}" but type is "${y.type}" \u2014 expected: ${x.join(" | ")}.`)}y.type==="object"&&y.properties?c(y.properties,`${d}${h}.`):y.type==="array"&&((_=y.items)==null?void 0:_.type)==="object"&&y.items.properties&&c(y.items.properties,`${d}${h}[].`)}};a.properties&&c(a.properties,"")}function F3e(a){if(!qu.generator.isRbacEnabled(a.compilerOptions)||a.compilerOptions.dbType!=="sql")return;let s=a.compilerOptions.useRBAC.roles,c=T3e.default.posix.join(a.compilerOptions.jsonSchemaDir,"UserRole.json");if(!w3e.default.existsSync(c)){A0.warn(`Json Schema Formatting: UserRole.json not found at ${c}, skipping role enum sync.`);return}let p=qu.common.loadJson(c);for(let d in p.properties){let _=p.properties[d];if(_["x-vexData"]==="role"&&_.enum!==s){_.type="string",_.enum=s,A0.process(`Json Schema Formatting: update role definitions UserRole.${d} enum -> [${s.join(", ")}]`);break}}qu.common.writeFile("Role Schema Formatting",c,JSON.stringify(p,null,4))}function Rpe(a,s){let c,p=[],d=_=>!!(_.type=="array"&&_.items&&_.items.type=="object");if(d(a))c=a.items.properties,p=typeof a.items.required=="object"?a.items.required:[];else if(a.type=="object")c=a.properties,p=typeof a.required=="object"?a.required:[];else return;return c==null?A0.error(`formatJsonSchema > formatRequired : invalid "schema.properties" in ${s}`,a):Object.keys(c).forEach(_=>{let h=c==null?void 0:c[_],y=!p.includes(_);h&&h.type!=="object"&&h.required===!0&&y?p.push(_):h&&h.items&&d(h)?h.items.required=Rpe(h.items,s):h&&h.type=="object"&&(h.required=Rpe(h,s),h.required&&h.required.length>0&&y&&p.push(_))}),p}function VCr(a,s,c){let p=v=>{if(v)if(v.type==="object"&&v.properties){let x=v.properties;for(let C of Object.keys(x)){let T=x[C];if(T){if(T["x-format"]==="ObjectId"){let N=C==="_id";T["x-format"]=N?"Primary":void 0,T.type="string",A0.warn("[JsonSchema]",`SQL target: ${N?"converted":"removed"} x-format ObjectId ${N?"-> Primary":""} for property "${C}" in ${s}`)}T&&(T.type==="object"||T.type==="array"&&T.items)&&p(T)}}}else v.type==="array"&&v.items&&p(v.items)};c.dbType==="sql"&&p(a);let d=[],_=v=>v?!!(v.index||v["x-foreignKey"]||v["x-vexData"]||v["x-vex-data"]):!1,h=(v,x,C,T=!1)=>{_(C)&&d.push(T?`${v}[].${x}`:`${v}.${x}`)},y=(v,x)=>{if(v)if(v.type==="object"&&v.properties)for(let C of Object.keys(v.properties)){let T=v.properties[C],N=x?`${x}.${C}`:C;if(T.type==="object"){if(T.properties)for(let F of Object.keys(T.properties))h(N,F,T.properties[F],!1);y(T,N)}else if(T.type==="array"&&T.items&&T.items.type==="object"){if(T.items.properties)for(let F of Object.keys(T.items.properties))h(N,F,T.items.properties[F],!0);y(T.items,N+"[]")}else y(T,N)}else v.type==="array"&&v.items&&y(v.items,x+"[]")};y(a,""),d.length>0&&d.forEach(v=>{A0.warn(`SQL target: ${s} nested object/array contains unsupported index/x-foreignKey/x-vex-data -> ${v}. Consider modelling as separate document/table.`)})}var KCr=Object.values(Npe),P3e={Primary:"uuid",PrimaryUUID:"uuid",UUID:"uuid",UnixTimestamp:"bigint",Timestamp:"timestamptz"};function jne(a){return typeof a=="string"&&KCr.includes(a)}function O3e(a){return(a==null?void 0:a["x-vexData"])==="userId"}function N3e(a){return a["x-format"]==="Primary"||a["x-format"]==="PrimaryUUID"}function Mpe(a){let s=a["x-format"];return typeof s=="string"&&P3e[s]?P3e[s]:a.format==="uuid"?"uuid":Array.isArray(a.enum)?"enum":a.type==="integer"?"bigint":"other"}function JE(a){var c;let s=[];for(let[p,d]of Object.entries((c=a.properties)!=null?c:{}))jne(d==null?void 0:d.default)&&s.push({field:p,type:d.default});return s}function I3e(a){var c;let s=JSON.parse(JSON.stringify(a));for(let p of Object.values((c=s.properties)!=null?c:{}))jne(p==null?void 0:p.default)&&delete p.default;return s}function B3e(a){return JE(a).length>0}function Mne(a,s){var p,d;let c=JE(a).map(_=>_.field);for(let[_,h]of Object.entries((p=a.properties)!=null?p:{}))(h==null?void 0:h["x-vexData"])==="softDelete"&&!c.includes(_)&&c.push(_);if(!s)for(let[_,h]of Object.entries((d=a.properties)!=null?d:{}))h&&N3e(h)&&!c.includes(_)&&c.push(_);return c}function AO(a){var c,p,d;let s=[];for(let _ of a){let h=(p=(c=_.schema["x-documentConfig"])==null?void 0:c.documentName)!=null?p:_.path;for(let[y,v]of Object.entries((d=_.schema.properties)!=null?d:{}))O3e(v)&&s.push({documentName:h,schemaPath:_.path,field:y,prop:v})}return s[0]}function CO(a,s,c){return`${s}.${c} (${a})`}function JCr(a,s){var d,_;let c=(_=(d=s.schema["x-documentConfig"])==null?void 0:d.documentName)!=null?_:s.path,p=Array.isArray(s.schema.required)?s.schema.required:[];for(let h of JE(s.schema)){let y=s.schema.properties[h.field],v=CO(s.path,c,h.field);(p.includes(h.field)||y.required===!0)&&a.problems.push(`"${v}" is declared with default "${h.type}" but is marked required. Auto-written fields are filled by the server and must not be required from the client.`)}}function HCr(a,s){var p,d;let c=(d=(p=s.schema["x-documentConfig"])==null?void 0:p.documentName)!=null?d:s.path;for(let _ of JE(s.schema)){let h=s.schema.properties[_.field],y=CO(s.path,c,_.field);_.type==="onCreateTimestamp"||_.type==="onUpdateTimestamp"?(h.type!=="string"||h["x-format"]!=="Timestamp")&&a.problems.push(`"${y}" is declared with default "${_.type}" \u2014 expected { "type": "string", "x-format": "Timestamp" }.`):(_.type==="onCreateUnixTimestamp"||_.type==="onUpdateUnixTimestamp")&&(h.type!=="integer"||h["x-format"]!=="UnixTimestamp")&&a.problems.push(`"${y}" is declared with default "${_.type}" \u2014 expected { "type": "integer", "x-format": "UnixTimestamp" }.`)}}function GCr(a,s){var h,y;let c=a.identity;if(!c)return;let p=(y=(h=s.schema["x-documentConfig"])==null?void 0:h.documentName)!=null?y:s.path,d=Mpe(c.prop),_=CO(c.schemaPath,c.documentName,c.field);for(let v of JE(s.schema)){if(!(v.type==="onCreateUserId"||v.type==="onUpdateUserId"))continue;let C=s.schema.properties[v.field],T=CO(s.path,p,v.field);Mpe(C)!==d&&a.problems.push(`"${T}" is declared with default "${v.type}" but resolves to a "${Mpe(C)}" column, while the x-vexData "userId" field resolves to "${d}" \u2014 identity source: "${_}". Both sides must use the same column type.`)}}function zCr(a,s){var d,_,h;let c=(_=(d=s.schema["x-documentConfig"])==null?void 0:d.documentName)!=null?_:s.path,p=Object.values(kq);for(let[y,v]of Object.entries((h=s.schema.properties)!=null?h:{})){let x=v==null?void 0:v["x-vexData"];x!==void 0&&(typeof x!="string"||!p.includes(x))&&a.problems.push(`"${CO(s.path,c,y)}" has x-vexData "${String(x)}" \u2014 expected one of: ${p.join(" | ")}.`)}}function WCr(a){let s=a.identity;if(!s)return;let c=CO(s.schemaPath,s.documentName,s.field),p=Array.isArray(s.prop.required)?s.prop.required:[];s.prop.type!=="string"&&a.problems.push(`"${c}" is tagged x-vexData "userId" but type is "${s.prop.type}" \u2014 expected "string".`),s.prop.index!==!0&&!N3e(s.prop)&&!p.includes(s.field)&&a.problems.push(`"${c}" is tagged x-vexData "userId" but is not indexed \u2014 add "index": true; it is used as the lookup key by the token refresh flow.`)}function YCr(a,s){a.documents.some(p=>JE(p.schema).some(d=>d.type==="onCreateUserId"))&&(mY(s)||a.problems.push('Schema declares "onCreateUserId" but the app enables no authentication (auth.localAuth is false and no oauth provider is on) \u2014 no request can ever carry an identity, so every create of that entity would fail. Enable an auth method or remove the keyword.'))}function L3e(a,s){var _,h,y;let c=[];for(let v of a){let x=(h=(_=v.schema["x-documentConfig"])==null?void 0:_.documentName)!=null?h:v.path;for(let[C,T]of Object.entries((y=v.schema.properties)!=null?y:{}))O3e(T)&&c.push({documentName:x,schemaPath:v.path,field:C,prop:T})}let p={documents:a,identity:c[0],problems:[]};if(c.length>1){let v=c.map(x=>CO(x.schemaPath,x.documentName,x.field));p.problems.push(`x-vexData "userId" is declared on ${c.length} fields [${v.join(", ")}] \u2014 exactly one identity source is allowed.`)}a.some(v=>JE(v.schema).some(x=>x.type==="onCreateUserId"||x.type==="onUpdateUserId"))&&!p.identity&&p.problems.push('Schema declares "onCreateUserId" / "onUpdateUserId" defaults but no field is tagged x-vexData "userId" \u2014 the framework has no identity source to read from.'),WCr(p),YCr(p,s);for(let v of a)zCr(p,v),JCr(p,v),HCr(p,v),GCr(p,v);return p.problems.length>0&&A0.error(`Audit field definition error:
|
|
993
993
|
`+p.problems.map(v=>` - ${v}`).join(`
|
|
994
994
|
`)),p.identity}function qne(a){var s;for(let[c,p]of Object.entries((s=a.properties)!=null?s:{}))if((p==null?void 0:p["x-vexData"])==="softDelete")return{field:c,prop:p}}function $ne(a){var c,p;let s=[];for(let d of a){let _=qne(d.schema);_&&s.push({documentName:(p=(c=d.schema["x-documentConfig"])==null?void 0:c.documentName)!=null?p:d.path,schemaPath:d.path,field:_.field})}return s}function XCr(a,s,c){return`${s}.${c} (${a})`}function QCr(a,s,c){var h,y;let p=(y=(h=s.schema["x-documentConfig"])==null?void 0:h.documentName)!=null?y:s.path,d=XCr(s.path,p,c.field),_=Array.isArray(s.schema.required)?s.schema.required:[];c.prop.type!=="boolean"&&a.push(`"${d}" is tagged x-vexData "softDelete" but type is "${c.prop.type}" \u2014 expected "boolean".`),c.prop.default!==!1&&a.push(`"${d}" is tagged x-vexData "softDelete" but does not declare "default": false \u2014 existing rows must default to "not deleted".`),!_.includes(c.field)&&c.prop.required!==!0&&a.push(`"${d}" is tagged x-vexData "softDelete" but is not required. The generated column must be NOT NULL DEFAULT false \u2014 a nullable marker makes the hide-filter (marker IS NOT TRUE) drop every live row written before the column existed.`)}function ZCr(a,s){var d,_,h;let c=(_=(d=s.schema["x-documentConfig"])==null?void 0:d.documentName)!=null?_:s.path,p=[];for(let[y,v]of Object.entries((h=s.schema.properties)!=null?h:{}))(v==null?void 0:v["x-vexData"])==="softDelete"&&p.push(y);p.length>1&&a.push(`x-vexData "softDelete" is declared on ${p.length} fields of "${c}" [${p.join(", ")}] (${s.path}) \u2014 at most one is allowed.`)}function R3e(a){let s=[];for(let c of a){ZCr(s,c);let p=qne(c.schema);p&&QCr(s,c,p)}s.length>0&&A0.error(`Soft delete definition error:
|
|
995
995
|
`+s.map(c=>` - ${c}`).join(`
|
|
@@ -1031,7 +1031,6 @@ class RoleBaseAccessControl {
|
|
|
1031
1031
|
|
|
1032
1032
|
public middleware(collection: string) {
|
|
1033
1033
|
return (req: Request, res: Response, next: NextFunction) => {
|
|
1034
|
-
// log.info("RBAC.middleware", req.method, req.path, req.user);
|
|
1035
1034
|
if ( !req.user ) {
|
|
1036
1035
|
throw new VexResErr(401);
|
|
1037
1036
|
}
|
|
@@ -1424,7 +1423,7 @@ async function main(): Promise<void> {
|
|
|
1424
1423
|
// Routes
|
|
1425
1424
|
{{AppRouter}}
|
|
1426
1425
|
|
|
1427
|
-
//
|
|
1426
|
+
// health check
|
|
1428
1427
|
app.get("/hello", (req, res) => {
|
|
1429
1428
|
res.send("Hello");
|
|
1430
1429
|
});
|
|
@@ -1441,7 +1440,7 @@ main();
|
|
|
1441
1440
|
`)),s=s.replace(/{{Config}}/g,_.join(`
|
|
1442
1441
|
`)),s=s.replace(/{{AppUse}}/g,h.join(`
|
|
1443
1442
|
`)),s=s.replace(/{{AppRouter}}/g,y.join(`
|
|
1444
|
-
`)),s}function sEe(a){return vl(this,null,function*(){let s=aEe.default.posix.join(a.srcDir,"server.ts");qu.common.writeFile("Server",s,zpe({compilerOptions:a}))})}function FAr(a,s){let c=Object.entries(a).filter(([,d])=>d!=null).map(([d,_])=>`${d}: ${JSON.stringify(_)}`),p=Object.entries(s!=null?s:{}).map(([d,_])=>`${d}: ${_}`);return`{${[...c,...p].join(", ")}}`}function PAr(a){let s={type:a.dbType,nullable:a.nullable,unique:a.isUnique||void 0,comment:a.comment,length:["varchar","char"].includes(a.dbType)?a.length:void 0,precision:a.precision,scale:a.scale,enum:a.enumValues,enumName:a.enumName,array:a.isArray||void 0,unsigned:a.unsigned||void 0,default:a.defaultValue},c=[];a.needsBigintTransformer&&c.push("{ to: (v: number) => v, from: (v: string) => Number(v) }"),a.needsTimestampTransformer&&c.push("{ to: (v: string) => v, from: (v: Date) => (v instanceof Date ? v.toISOString() : v) }");let p=c.length>0?{transformer:c.length===1?c[0]:`[${c.join(", ")}]`}:void 0;return FAr(s,p)}function Wpe(a){var B,G,se,Ee,ie;let s=a.documentName,c=a.tableName,p=(B=a.manyToOneRelations)!=null?B:[],d=(G=a.oneToManyRelations)!=null?G:[],_=(se=a.oneToOneRelations)!=null?se:[],h=p.length>0||d.length>0||_.length>0,y=["Entity","Column","PrimaryGeneratedColumn"],v=a.uniqueIndexes&&a.uniqueIndexes.length>0,x=a.columns.some(ue=>ue.isIndex&&!ue.isNested);v&&y.push("Unique"),x&&y.push("Index"),h&&y.push("Relation","JoinColumn"),p.length>0&&y.push("ManyToOne"),d.length>0&&y.push("OneToMany"),_.length>0&&y.push("OneToOne");let C=[...p.map(ue=>`import { ${ue.targetEntity}, ${ue.targetType} } from "${ue.importPath}";`),...d.map(ue=>`import { ${ue.targetEntity}, ${ue.targetType} } from "${ue.importPath}";`),..._.map(ue=>`import { ${ue.targetEntity}, ${ue.targetType} } from "${ue.importPath}";`)].filter((ue,pe,ge)=>ge.indexOf(ue)===pe),T=(ie=(Ee=a.uniqueIndexes)==null?void 0:Ee.map(ue=>{let pe=`unique_${ue.join("_")}`,ge=ue.map(le=>`'${le}'`).join(", ");return`@Unique('${pe}', [${ge}])`}))!=null?ie:[],N=[`@Entity("${c}")`,...T].join(`
|
|
1443
|
+
`)),s}function sEe(a){return vl(this,null,function*(){let s=aEe.default.posix.join(a.srcDir,"server.ts");qu.common.writeFile("Server",s,zpe({compilerOptions:a}))})}function FAr(a,s){let c=Object.entries(a).filter(([,d])=>d!=null).map(([d,_])=>`${d}: ${JSON.stringify(_)}`),p=Object.entries(s!=null?s:{}).map(([d,_])=>`${d}: ${_}`);return`{${[...c,...p].join(", ")}}`}function PAr(a){let s={type:a.dbType,nullable:a.nullable,unique:a.isUnique||void 0,comment:a.comment,length:["varchar","char"].includes(a.dbType)?a.length:void 0,precision:a.precision,scale:a.scale,enum:a.enumValues,enumName:a.enumName,array:a.isArray||void 0,unsigned:a.unsigned||void 0,default:a.defaultValue},c=[];a.needsBigintTransformer&&c.push("{ to: (v: number) => v, from: (v: string) => Number(v) }"),a.needsTimestampTransformer&&c.push("{ to: (v: string) => v, from: (v: Date) => (v instanceof Date ? v.toISOString() : v) }"),a.needsBase64Transformer&&c.push('{ to: (v: string | null) => (v == null ? v : Buffer.from(v, "base64")), from: (v: Buffer | null) => (v == null ? v : v.toString("base64")) }');let p=c.length>0?{transformer:c.length===1?c[0]:`[${c.join(", ")}]`}:void 0;return FAr(s,p)}function Wpe(a){var B,G,se,Ee,ie;let s=a.documentName,c=a.tableName,p=(B=a.manyToOneRelations)!=null?B:[],d=(G=a.oneToManyRelations)!=null?G:[],_=(se=a.oneToOneRelations)!=null?se:[],h=p.length>0||d.length>0||_.length>0,y=["Entity","Column","PrimaryGeneratedColumn"],v=a.uniqueIndexes&&a.uniqueIndexes.length>0,x=a.columns.some(ue=>ue.isIndex&&!ue.isNested);v&&y.push("Unique"),x&&y.push("Index"),h&&y.push("Relation","JoinColumn"),p.length>0&&y.push("ManyToOne"),d.length>0&&y.push("OneToMany"),_.length>0&&y.push("OneToOne");let C=[...p.map(ue=>`import { ${ue.targetEntity}, ${ue.targetType} } from "${ue.importPath}";`),...d.map(ue=>`import { ${ue.targetEntity}, ${ue.targetType} } from "${ue.importPath}";`),..._.map(ue=>`import { ${ue.targetEntity}, ${ue.targetType} } from "${ue.importPath}";`)].filter((ue,pe,ge)=>ge.indexOf(ue)===pe),T=(ie=(Ee=a.uniqueIndexes)==null?void 0:Ee.map(ue=>{let pe=`unique_${ue.join("_")}`,ge=ue.map(le=>`'${le}'`).join(", ");return`@Unique('${pe}', [${ge}])`}))!=null?ie:[],N=[`@Entity("${c}")`,...T].join(`
|
|
1445
1444
|
`),F=a.columns.filter(ue=>ue.enumValues).map(ue=>ue.tsType),P=a.columns.map(ue=>{let pe=[];return ue.isPrimary?(pe.push(` @PrimaryGeneratedColumn("${ue.dbType=="uuid"?"uuid":"increment"}")`),pe.push(` ${ue.name}!: ${ue.tsType};`)):(ue.isIndex&&!ue.isNested&&pe.push(" @Index()"),pe.push(` @Column(${PAr(ue)})`),pe.push(` ${ue.name}${ue.nullable?"?":"!"}: ${ue.tsType};`)),pe.join(`
|
|
1446
1445
|
`)}).join(`
|
|
1447
1446
|
|
|
@@ -1470,7 +1469,7 @@ ${P}${U?`
|
|
|
1470
1469
|
|
|
1471
1470
|
`+U:""}
|
|
1472
1471
|
}
|
|
1473
|
-
`}function cEe(a){return a.enum!==void 0&&Array.isArray(a.enum)&&a.enum.every(s=>typeof s=="string")}function OAr(a){var s;switch(a.type){case"integer":case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";case"array":switch((s=a.items)==null?void 0:s.type){case"integer":case"number":return"number[]";case"boolean":return"boolean[]";default:return"string[]"}default:return"string"}}var oEe={Primary:"uuid",PrimaryUUID:"uuid",UUID:"uuid",ObjectId:"varchar",UnixTimestamp:"bigint",Timestamp:"timestamptz"},uEe={date:"date","date-time":"timestamp",time:"time",email:"varchar",uri:"text",uuid:"uuid"};function NAr(a){return a.format&&uEe[a.format]?uEe[a.format]:a.maxLength?"varchar":"text"}function IAr(a){if(cEe(a))return"enum";let s=a["x-format"];if(s&&oEe[s])return oEe[s];switch(a.type){case"string":return NAr(a);case"integer":return"int";case"number":case"float":return a.precision?"decimal":"double precision";case"boolean":return"boolean";case"array":return"text";case"object":return"jsonb";default:return"varchar"}}function BAr(a,s){if(["varchar","char"].includes(s)){if(a.maxLength)return a.maxLength;if(a.format==="email")return 254;if(a["x-format"]==="ObjectId")return 24}}var LAr=new Set(["int","double precision","decimal","bigint"]);function RAr(a){return LAr.has(a)}function jAr(a,s,c,p){let d=s["x-format"]==="Primary"||s["x-format"]==="PrimaryUUID",_=cEe(s),h=!c.includes(a)&&!d,y=IAr(s),v=RAr(y);return{name:a,tsType:d?"string":_?qu.common.pascalCase(a)+"Enum":OAr(s),dbType:y,isPrimary:d,isGenerated:d||!!(s["x-format"]&&["UUID","UnixTimestamp"].includes(s["x-format"])),isIndex:s.index===!0,isUnique:p.has(a),isNested:s.type==="object"||s.type==="array",isArray:s.type==="array",needsBigintTransformer:y==="bigint",needsTimestampTransformer:y==="timestamptz",unsigned:v&&s.minimum!==void 0&&s.minimum>=0?!0:void 0,nullable:h,comment:s.description,length:BAr(s,y),precision:s.precision,scale:s.scale,enumValues:_?s.enum:void 0,enumName:_?qu.common.pascalCase(a)+"Enum":void 0,defaultValue:jne(s.default)?void 0:s.default}}function MAr(a){return Object.keys(a).filter(s=>!!a[s]["x-foreignKey"]).map(s=>{let c=a[s]["x-foreignKey"];return{propertyName:qu.common.camelCase(c.schemaName),targetType:c.schemaName,targetEntity:`${c.schemaName}Entity`,importPath:`./${c.schemaName}Model.gen`,joinColumnName:s,relationType:c.relationType}})}function qAr(a,s){var p;let c=[];for(let d of s){let _=d["x-documentConfig"].documentName;if(_===a)continue;let h=d.properties||{};for(let y of Object.keys(h)){let v=h[y];if(((p=v["x-foreignKey"])==null?void 0:p.schemaName)===a){let x=v["x-foreignKey"],C=x.relationType==="many-to-one"?"one-to-many":"one-to-one";c.push({propertyName:`${qu.common.camelCase(_)}`,targetType:_,targetEntity:`${_}Entity`,importPath:`./${_}Model.gen`,inversePropertyName:qu.common.camelCase(x.schemaName),relationType:C})}}}return c}function lEe(a){return vl(this,null,function*(){let s=a.jsonSchema,c=s["x-documentConfig"].documentName,p=c.toLowerCase(),d=s["x-documentConfig"].uniqueIndex||[],_=Array.isArray(s.required)?s.required:[];A0.process(`TypeORM Entity : ${c}`);let h=s.properties||{},y=new Set(d.filter(M=>M.length===1).map(M=>M[0])),v=Object.keys(h).map(M=>jAr(M,h[M],_,y));v.find(M=>M.isPrimary)||v.unshift({name:"_id",tsType:"string",dbType:"uuid",isPrimary:!0,isGenerated:!0,nullable:!1,isIndex:!1,isNested:!1,isArray:!1});let x=MAr(h),C=qAr(c,a.allSchemas),T=x.filter(M=>M.relationType==="many-to-one"),N=C.filter(M=>M.relationType==="one-to-many"),F=[...x.filter(M=>M.relationType==="one-to-one"),...C.filter(M=>M.relationType==="one-to-one").map(M=>({propertyName:M.propertyName,targetEntity:M.targetEntity,targetType:M.targetType,importPath:M.importPath,inversePropertyName:M.inversePropertyName,relationType:M.relationType}))],P=`${a.outDir}/${c}Model.gen.ts`;qu.common.writeFile("TypeORM Entity",P,Wpe({documentName:c,tableName:p,uniqueIndexes:d,columns:v,oneToOneRelations:F,manyToOneRelations:T,oneToManyRelations:N,compilerOptions:a.compilerOptions}))})}var WFe=nd(require("path")),YFe=nd(zFe());var{modelsGen:PMr}=YFe.default;function XFe(a){return vl(this,null,function*(){let s=a.jsonSchema["x-documentConfig"].documentName;A0.process(`Mongoose Model : ${s}`);let c=WFe.default.relative(a.outDir,a.typeDir).replace(/\\/g,"/"),p=`${a.outDir}/${s}Model.gen.ts`,d=B3e(a.jsonSchema)?I3e(a.jsonSchema):a.jsonSchema,h=PMr.json2Mongoose(d,`${c}/${s}.gen`,{use_id:!0}).replace(/export const \w+Model\b/g,`export const ${s}Entity`).replace(/mongoose\.model<\w+Document>\("\w+"/g,`mongoose.model<${s}Document>("${s}"`);qu.common.writeFile("Mongoose Model (patch)",p,h)})}var QFe=nd(qie());function ZFe(a,s,c){return vl(this,null,function*(){var h,y,v;let p=String((h=s.split("/").pop())==null?void 0:h.split(".")[0]);A0.process(`Type : ${p} > ${s}`);let d=Mne(a,(v=(y=c==null?void 0:c.app)==null?void 0:y.allowApiCreateUpdate_id)!=null?v:!1),_=yield QFe.compile(a,p,{$refOptions:{},additionalProperties:!1,bannerComment:"",declareExternallyReferenced:!0,enableConstEnums:!0,format:!0,ignoreMinAndMaxItems:!0,strictIndexSignatures:!1,style:{bracketSpacing:!1,printWidth:120,semi:!0,singleQuote:!1,tabWidth:4,trailingComma:"none",useTabs:!1},unreachableDefinitions:!1,unknownAny:!0}).then(x=>IMr(x,a)).then(x=>BMr(x,a)).then(x=>NMr(x,a,d));qu.common.writeFile(p,s,`// {{headerComment}}
|
|
1472
|
+
`}function cEe(a){return a.enum!==void 0&&Array.isArray(a.enum)&&a.enum.every(s=>typeof s=="string")}function OAr(a){var s;switch(a.type){case"integer":case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";case"array":switch((s=a.items)==null?void 0:s.type){case"integer":case"number":return"number[]";case"boolean":return"boolean[]";default:return"string[]"}default:return"string"}}var oEe={Primary:"uuid",PrimaryUUID:"uuid",UUID:"uuid",ObjectId:"varchar",UnixTimestamp:"bigint",Timestamp:"timestamptz",Binary:"bytea"},uEe={date:"date","date-time":"timestamp",time:"time",email:"varchar",uri:"text",uuid:"uuid"};function NAr(a){return a.format&&uEe[a.format]?uEe[a.format]:a.maxLength?"varchar":"text"}function IAr(a){if(cEe(a))return"enum";let s=a["x-format"];if(s&&oEe[s])return oEe[s];switch(a.type){case"string":return NAr(a);case"integer":return"int";case"number":case"float":return a.precision?"decimal":"double precision";case"boolean":return"boolean";case"array":return"text";case"object":return"jsonb";default:return"varchar"}}function BAr(a,s){if(["varchar","char"].includes(s)){if(a.maxLength)return a.maxLength;if(a.format==="email")return 254;if(a["x-format"]==="ObjectId")return 24}}var LAr=new Set(["int","double precision","decimal","bigint"]);function RAr(a){return LAr.has(a)}function jAr(a,s,c,p){let d=s["x-format"]==="Primary"||s["x-format"]==="PrimaryUUID",_=cEe(s),h=!c.includes(a)&&!d,y=IAr(s),v=RAr(y);return{name:a,tsType:d?"string":_?qu.common.pascalCase(a)+"Enum":OAr(s),dbType:y,isPrimary:d,isGenerated:d||!!(s["x-format"]&&["UUID","UnixTimestamp"].includes(s["x-format"])),isIndex:s.index===!0,isUnique:p.has(a),isNested:s.type==="object"||s.type==="array",isArray:s.type==="array",needsBigintTransformer:y==="bigint",needsTimestampTransformer:y==="timestamptz",needsBase64Transformer:y==="bytea",unsigned:v&&s.minimum!==void 0&&s.minimum>=0?!0:void 0,nullable:h,comment:s.description,length:BAr(s,y),precision:s.precision,scale:s.scale,enumValues:_?s.enum:void 0,enumName:_?qu.common.pascalCase(a)+"Enum":void 0,defaultValue:jne(s.default)?void 0:s.default}}function MAr(a){return Object.keys(a).filter(s=>!!a[s]["x-foreignKey"]).map(s=>{let c=a[s]["x-foreignKey"];return{propertyName:qu.common.camelCase(c.schemaName),targetType:c.schemaName,targetEntity:`${c.schemaName}Entity`,importPath:`./${c.schemaName}Model.gen`,joinColumnName:s,relationType:c.relationType}})}function qAr(a,s){var p;let c=[];for(let d of s){let _=d["x-documentConfig"].documentName;if(_===a)continue;let h=d.properties||{};for(let y of Object.keys(h)){let v=h[y];if(((p=v["x-foreignKey"])==null?void 0:p.schemaName)===a){let x=v["x-foreignKey"],C=x.relationType==="many-to-one"?"one-to-many":"one-to-one";c.push({propertyName:`${qu.common.camelCase(_)}`,targetType:_,targetEntity:`${_}Entity`,importPath:`./${_}Model.gen`,inversePropertyName:qu.common.camelCase(x.schemaName),relationType:C})}}}return c}function lEe(a){return vl(this,null,function*(){let s=a.jsonSchema,c=s["x-documentConfig"].documentName,p=c.toLowerCase(),d=s["x-documentConfig"].uniqueIndex||[],_=Array.isArray(s.required)?s.required:[];A0.process(`TypeORM Entity : ${c}`);let h=s.properties||{},y=new Set(d.filter(M=>M.length===1).map(M=>M[0])),v=Object.keys(h).map(M=>jAr(M,h[M],_,y));v.find(M=>M.isPrimary)||v.unshift({name:"_id",tsType:"string",dbType:"uuid",isPrimary:!0,isGenerated:!0,nullable:!1,isIndex:!1,isNested:!1,isArray:!1});let x=MAr(h),C=qAr(c,a.allSchemas),T=x.filter(M=>M.relationType==="many-to-one"),N=C.filter(M=>M.relationType==="one-to-many"),F=[...x.filter(M=>M.relationType==="one-to-one"),...C.filter(M=>M.relationType==="one-to-one").map(M=>({propertyName:M.propertyName,targetEntity:M.targetEntity,targetType:M.targetType,importPath:M.importPath,inversePropertyName:M.inversePropertyName,relationType:M.relationType}))],P=`${a.outDir}/${c}Model.gen.ts`;qu.common.writeFile("TypeORM Entity",P,Wpe({documentName:c,tableName:p,uniqueIndexes:d,columns:v,oneToOneRelations:F,manyToOneRelations:T,oneToManyRelations:N,compilerOptions:a.compilerOptions}))})}var WFe=nd(require("path")),YFe=nd(zFe());var{modelsGen:PMr}=YFe.default;function XFe(a){return vl(this,null,function*(){let s=a.jsonSchema["x-documentConfig"].documentName;A0.process(`Mongoose Model : ${s}`);let c=WFe.default.relative(a.outDir,a.typeDir).replace(/\\/g,"/"),p=`${a.outDir}/${s}Model.gen.ts`,d=B3e(a.jsonSchema)?I3e(a.jsonSchema):a.jsonSchema,h=PMr.json2Mongoose(d,`${c}/${s}.gen`,{use_id:!0}).replace(/export const \w+Model\b/g,`export const ${s}Entity`).replace(/mongoose\.model<\w+Document>\("\w+"/g,`mongoose.model<${s}Document>("${s}"`);qu.common.writeFile("Mongoose Model (patch)",p,h)})}var QFe=nd(qie());function ZFe(a,s,c){return vl(this,null,function*(){var h,y,v;let p=String((h=s.split("/").pop())==null?void 0:h.split(".")[0]);A0.process(`Type : ${p} > ${s}`);let d=Mne(a,(v=(y=c==null?void 0:c.app)==null?void 0:y.allowApiCreateUpdate_id)!=null?v:!1),_=yield QFe.compile(a,p,{$refOptions:{},additionalProperties:!1,bannerComment:"",declareExternallyReferenced:!0,enableConstEnums:!0,format:!0,ignoreMinAndMaxItems:!0,strictIndexSignatures:!1,style:{bracketSpacing:!1,printWidth:120,semi:!0,singleQuote:!1,tabWidth:4,trailingComma:"none",useTabs:!1},unreachableDefinitions:!1,unknownAny:!0}).then(x=>IMr(x,a)).then(x=>BMr(x,a)).then(x=>NMr(x,a,d));qu.common.writeFile(p,s,`// {{headerComment}}
|
|
1474
1473
|
`+_)})}function NMr(a,s,c){var _;if(c.length===0)return a;let p=(_=a.match(/export interface (\w+)/))==null?void 0:_[1];if(!p)return a;let d=c.map(h=>`"${h}"`).join(" | ");return a.replace(/\s+$/,"")+`
|
|
1475
1474
|
|
|
1476
1475
|
/** Request body for create / put / patch \u2014 server-managed fields are not accepted from the client */
|
|
@@ -25,8 +25,6 @@ class Authentication {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
private async handle(req: Request, next: NextFunction): Promise<void> {
|
|
28
|
-
// gate keeper
|
|
29
|
-
// log.info("Authentication.middleware", req.headers["x-auth-index"], req.headers.authorization);
|
|
30
28
|
const token = req.headers.authorization?.split(" ")[1];
|
|
31
29
|
const accessTokenIndex = req.headers["x-auth-index"]?.toString();
|
|
32
30
|
|
|
@@ -38,7 +36,6 @@ class Authentication {
|
|
|
38
36
|
throw 401;
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
// verify token
|
|
42
39
|
const tokenData = this.JWTService.verifyToken(token, accessTokenIndex);
|
|
43
40
|
|
|
44
41
|
// The signature only proves the token was issued; it says nothing about the account still
|
|
@@ -87,7 +87,6 @@ export class TypeOrmRepositoryAdapter<T extends ObjectLiteral> implements VexRep
|
|
|
87
87
|
Object.assign(data, values);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
/** Build ownership filter from current request context, or null. */
|
|
91
90
|
private getOwnershipFilter(): Record<string, unknown> | null {
|
|
92
91
|
const userId = UserContext.userId;
|
|
93
92
|
if (!userId) return null;
|
|
@@ -133,7 +132,6 @@ export class TypeOrmRepositoryAdapter<T extends ObjectLiteral> implements VexRep
|
|
|
133
132
|
|
|
134
133
|
private mapOperators(filter: Filter<T>): Record<string, unknown> | Array<Record<string, unknown>> {
|
|
135
134
|
if (!filter || typeof filter !== "object") return {};
|
|
136
|
-
// if (Array.isArray(filter)) return filter.map(f => this.mapOperators(f));
|
|
137
135
|
|
|
138
136
|
let out: Record<string, unknown> | Array<Record<string, unknown>> = {};
|
|
139
137
|
|
|
@@ -177,10 +175,6 @@ export class TypeOrmRepositoryAdapter<T extends ObjectLiteral> implements VexRep
|
|
|
177
175
|
out[key] = Like(oval.$like as string);
|
|
178
176
|
continue;
|
|
179
177
|
}
|
|
180
|
-
// if (val?.$raw) {
|
|
181
|
-
// out[key] = Raw(val.$raw as string);
|
|
182
|
-
// continue;
|
|
183
|
-
// }
|
|
184
178
|
} else {
|
|
185
179
|
out[key] = val;
|
|
186
180
|
}
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
import { Request, Response, NextFunction } from "express";
|
|
3
3
|
import { DataSource, EntityTarget, ObjectLiteral } from "typeorm";
|
|
4
4
|
import mongoose from "mongoose";
|
|
5
|
-
// import { Document } from "mongoose";
|
|
6
|
-
// import { sqlMigrations } from "../_models/sqlMigration.gen";
|
|
7
5
|
import { VexRepository } from "../_types/vex";
|
|
8
6
|
import { TypeOrmRepositoryAdapter } from "./TypeOrmRepositoryAdapter.gen";
|
|
9
|
-
// import { MongooseRepositoryAdapter } from "./MongooseRepositoryAdapter.gen";
|
|
10
7
|
import utils from "./../_utils";
|
|
11
8
|
|
|
12
9
|
export class VexDbConnector {
|
|
@@ -73,7 +70,6 @@ export class VexDbConnector {
|
|
|
73
70
|
.then(() => {
|
|
74
71
|
this.dataSource = ds;
|
|
75
72
|
utils.log.infoSql("TypeORM DataSource initialized");
|
|
76
|
-
// this.runSqlMigrations(ds);
|
|
77
73
|
})
|
|
78
74
|
.catch((err) => {
|
|
79
75
|
utils.log.errorSql(`Failed to initialize TypeORM, retrying in ${retryTime}s`, err);
|
|
@@ -84,23 +80,6 @@ export class VexDbConnector {
|
|
|
84
80
|
connectWithRetry(10);
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
// private async runSqlMigrations(ds: DataSource): Promise<void> {
|
|
88
|
-
// if (!sqlMigrations.length) return;
|
|
89
|
-
// const runner = ds.createQueryRunner();
|
|
90
|
-
// await runner.connect();
|
|
91
|
-
// try {
|
|
92
|
-
// for (const sql of sqlMigrations) {
|
|
93
|
-
// utils.log.infoSql(`Applying migration: ${sql}`);
|
|
94
|
-
// await runner.query(sql);
|
|
95
|
-
// }
|
|
96
|
-
// utils.log.infoSql(`${sqlMigrations.length} migrations applied`);
|
|
97
|
-
// } catch (err) {
|
|
98
|
-
// utils.log.errorSql("SQL migration failed", err);
|
|
99
|
-
// } finally {
|
|
100
|
-
// await runner.release();
|
|
101
|
-
// }
|
|
102
|
-
// }
|
|
103
|
-
|
|
104
83
|
closeSql(): void {
|
|
105
84
|
if (this.dataSource?.isInitialized) {
|
|
106
85
|
this.dataSource.destroy()
|
|
@@ -109,7 +88,7 @@ export class VexDbConnector {
|
|
|
109
88
|
}
|
|
110
89
|
}
|
|
111
90
|
|
|
112
|
-
// TODO: complete mongoose support
|
|
91
|
+
// TODO: complete mongoose support
|
|
113
92
|
connectMongo(): void {
|
|
114
93
|
console.warn("VeryExpress unified db adapter (MongooseRepositoryAdapter) for Mongodb are under development, use with caution. Contribute to \"https://github.com/Justin26l/VeryExpress\"");
|
|
115
94
|
utils.log.infoMongo("Connecting to MongoDB (Driver: Mongoose)...");
|
|
@@ -124,7 +103,6 @@ export class VexDbConnector {
|
|
|
124
103
|
connectWithRetry(10);
|
|
125
104
|
}
|
|
126
105
|
|
|
127
|
-
// TODO: complete mongoose support, handle join and select
|
|
128
106
|
closeMongo(): void {
|
|
129
107
|
console.warn("VeryExpress unified db adapter (MongooseRepositoryAdapter) for Mongodb are under development, use with caution. Contribute to \"https://github.com/Justin26l/VeryExpress\"");
|
|
130
108
|
mongoose.disconnect()
|
|
@@ -132,13 +110,10 @@ export class VexDbConnector {
|
|
|
132
110
|
.catch((err) => utils.log.errorMongo("Error disconnecting Mongoose", err));
|
|
133
111
|
}
|
|
134
112
|
|
|
135
|
-
// getRepository<T extends Document>(target: { schema: unknown; modelName: string }): VexRepository<T>;
|
|
136
113
|
getRepository<T extends ObjectLiteral>(target: EntityTarget<T>): VexRepository<T>;
|
|
137
114
|
getRepository<T>(target: EntityTarget<ObjectLiteral> | any): VexRepository<T> {
|
|
138
|
-
// TODO: complete mongoose support, handle join and select
|
|
139
115
|
if (target?.schema && target?.modelName) {
|
|
140
116
|
console.warn("VeryExpress unified db adapter (MongooseRepositoryAdapter) for Mongodb are under development, use with caution. Contribute to \"https://github.com/Justin26l/VeryExpress\"");
|
|
141
|
-
// return new MongooseRepositoryAdapter<T & Document>(target);
|
|
142
117
|
}
|
|
143
118
|
if (!this.dataSource) throw new Error("SQL DataSource not initialized");
|
|
144
119
|
return new TypeOrmRepositoryAdapter<T & ObjectLiteral>(this.dataSource.getRepository(target));
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import jwt from "jsonwebtoken";
|
|
3
3
|
import ms from "ms";
|
|
4
4
|
import path from "path";
|
|
5
|
-
// import express, { CookieOptions } from "express";
|
|
6
5
|
|
|
7
6
|
import JWTKeyStore from "./JWTKeyStore.gen";
|
|
8
7
|
|
|
@@ -36,13 +35,6 @@ export default class JWTService {
|
|
|
36
35
|
|
|
37
36
|
constructor() {}
|
|
38
37
|
|
|
39
|
-
/**
|
|
40
|
-
* Verifies a JSON Web Token (JWT) using the provided token and key index.
|
|
41
|
-
*
|
|
42
|
-
* @param {string} token - The JSON Web Token to be verified.
|
|
43
|
-
* @param {number} index - The index of the key used to verify the token.
|
|
44
|
-
* @return {jwt.JwtPayload } The decoded token payload, an error message, or false if verification fails.
|
|
45
|
-
*/
|
|
46
38
|
public verifyToken(token: string, index?: number | string): jwt.JwtPayload {
|
|
47
39
|
|
|
48
40
|
if (token.startsWith("Bearer ")) {
|
|
@@ -67,9 +59,6 @@ export default class JWTService {
|
|
|
67
59
|
}
|
|
68
60
|
}
|
|
69
61
|
|
|
70
|
-
/**
|
|
71
|
-
* Process of login user, assign tokens and create session.
|
|
72
|
-
*/
|
|
73
62
|
public async assignTokens(user: UserWithRelations, provider: string): Promise<string> {
|
|
74
63
|
if(!user._id) {
|
|
75
64
|
throw new VexResErr(500, null, "User Data Error, User._id missing.");
|
|
@@ -77,7 +66,6 @@ export default class JWTService {
|
|
|
77
66
|
|
|
78
67
|
const sessionCode = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
79
68
|
|
|
80
|
-
// insert new unique session for user
|
|
81
69
|
await this.sessionRepo.deleteWhere({ userId: user._id });
|
|
82
70
|
await this.sessionRepo.create({
|
|
83
71
|
sessionCode,
|
|
@@ -86,7 +74,6 @@ export default class JWTService {
|
|
|
86
74
|
expired: Date.now() + 5000,
|
|
87
75
|
});
|
|
88
76
|
|
|
89
|
-
// return appAuthCode to client
|
|
90
77
|
const redirectPath = `${path.posix.join("/", process.env.LOGIN_SUCCESS_REDIRECT_PATH || "/logincallback")}?code=${sessionCode}`;
|
|
91
78
|
|
|
92
79
|
return redirectPath;
|
|
@@ -106,8 +93,6 @@ export default class JWTService {
|
|
|
106
93
|
};
|
|
107
94
|
}
|
|
108
95
|
|
|
109
|
-
/** utils */
|
|
110
|
-
|
|
111
96
|
/**
|
|
112
97
|
* Identity value of a user record: the field tagged `x-vexData: "userId"` in the schemas,
|
|
113
98
|
* with `_id` as the fallback. This is what every audit field (createdBy / updatedBy) stores.
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
// {{headerComment}}
|
|
2
2
|
import crypto from "crypto";
|
|
3
|
-
// import log from "~/utils/logger";
|
|
4
3
|
import { UserWithRelations } from "../_types/User.gen";
|
|
5
4
|
|
|
6
|
-
/**
|
|
7
|
-
* Hashes a password with a salt (e.g., user email).
|
|
8
|
-
* @param plainPassword The plain text password to hash.
|
|
9
|
-
* @param salt The salt to use (e.g., user email).
|
|
10
|
-
* @param algorithm The hash algorithm (default: 'sha256').
|
|
11
|
-
* @returns The hashed password (hex encoded).
|
|
12
|
-
*/
|
|
13
5
|
export function hashPassword(
|
|
14
6
|
plainPassword: string,
|
|
15
7
|
salt: string,
|
|
@@ -18,24 +10,16 @@ export function hashPassword(
|
|
|
18
10
|
return crypto.createHash(algorithm).update(plainPassword + salt).digest("hex");
|
|
19
11
|
}
|
|
20
12
|
|
|
21
|
-
/**
|
|
22
|
-
* Verifies if a plain password (with salt) matches a given hashed password.
|
|
23
|
-
* @param user The user object containing email and userAuthProfiles.
|
|
24
|
-
* @param plainPassword The plain text password to verify.
|
|
25
|
-
* @returns True if the password matches, false otherwise.
|
|
26
|
-
*/
|
|
27
13
|
export function verifyPassword(
|
|
28
14
|
user: UserWithRelations,
|
|
29
15
|
plainPassword: string,
|
|
30
16
|
): boolean {
|
|
31
17
|
if(!user.email || !user.userAuthProfiles) {
|
|
32
|
-
// log.error(`User "${user._id}" email or userAuthProfiles missing for local auth's password verification.`);
|
|
33
18
|
return false;
|
|
34
19
|
}
|
|
35
20
|
|
|
36
21
|
const hashedPassword = user.userAuthProfiles.find((profile:any) => profile.provider === "local")?.password;
|
|
37
22
|
if(!hashedPassword) {
|
|
38
|
-
// log.error(`User "${user._id}" Local auth profile or password missing.`);
|
|
39
23
|
return false;
|
|
40
24
|
}
|
|
41
25
|
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
| `"mongo"` | `src/generators/db/mongooseModel.generator.ts` |
|
|
10
10
|
| `"sql"` | `src/generators/db/typeormEntity.generator.ts` |
|
|
11
11
|
|
|
12
|
-
The generated app's DB target is fixed at generation time.
|
|
12
|
+
The generated app's DB target is fixed at generation time. `"sql"` means PostgreSQL: the connector
|
|
13
|
+
pins `type: "postgres"` and the app depends on `pg` only, so column types in the entity generator
|
|
14
|
+
(`uuid`, `timestamptz`, `bytea`, `jsonb`) must be PostgreSQL types.
|
|
13
15
|
|
|
14
16
|
### SQL schema creation
|
|
15
17
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# v0.9.0
|
|
2
|
+
|
|
3
|
+
## Binary fields: `x-format: "Binary"`
|
|
4
|
+
|
|
5
|
+
A property can now carry a binary payload. Declare it as a string with the `Binary` format:
|
|
6
|
+
|
|
7
|
+
```jsonc
|
|
8
|
+
"data": { "type": "string", "x-format": "Binary", "description": "base64-encoded bytes" }
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
| Layer | Value |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| SQL column | `bytea` |
|
|
14
|
+
| Entity property | `string` |
|
|
15
|
+
| API request / response | base64 string |
|
|
16
|
+
|
|
17
|
+
A TypeORM transformer converts `string → Buffer` on write and `Buffer → base64 string` on read, so
|
|
18
|
+
clients never see a `Buffer` and every generated type stays JSON-safe:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
@Column({type: "bytea", nullable: false,
|
|
22
|
+
transformer: {
|
|
23
|
+
to: (v: string | null) => (v == null ? v : Buffer.from(v, "base64")),
|
|
24
|
+
from: (v: Buffer | null) => (v == null ? v : v.toString("base64"))
|
|
25
|
+
}})
|
|
26
|
+
data!: string;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`type` must be `string`; any other type fails generation. In mongo mode the column is a plain
|
|
30
|
+
`String` holding the same base64 text. The transformer does not validate base64 — `Buffer.from`
|
|
31
|
+
ignores invalid characters — and `maxLength` has no effect on a binary column.
|
|
32
|
+
|
|
33
|
+
Re-run the generator, then migrate the table. `SQL_SYNCHRONIZE=true` covers development; otherwise:
|
|
34
|
+
|
|
35
|
+
```sql
|
|
36
|
+
ALTER TABLE "asset" ADD COLUMN "data" bytea;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## SQL target is PostgreSQL
|
|
40
|
+
|
|
41
|
+
The generated SQL app connects with a fixed `postgres` driver and depends on `pg` only. There is no
|
|
42
|
+
MySQL or SQLite path, so binary columns are always `bytea`. A MySQL target would need a dialect layer
|
|
43
|
+
between the schema and the entity generator; `blob` is not emitted today.
|
package/docs/vexJsonSchema.md
CHANGED
|
@@ -69,8 +69,25 @@ Each `.json` file defines one REST resource. Filename must match `x-documentConf
|
|
|
69
69
|
| `ObjectId` | MongoDB ObjectId (mongo mode) |
|
|
70
70
|
| `UnixTimestamp` | Integer epoch **seconds** (SQL: `bigint`) |
|
|
71
71
|
| `Timestamp` | ISO-8601 datetime (SQL: `timestamptz`, mapped back to an ISO string) |
|
|
72
|
+
| `Binary` | Binary payload (SQL: `bytea`). The API reads and writes a **base64 string**. |
|
|
72
73
|
| `enum` | Enum field — pair with `enum` array |
|
|
73
74
|
|
|
75
|
+
#### Binary fields (`x-format: "Binary"`)
|
|
76
|
+
|
|
77
|
+
```jsonc
|
|
78
|
+
"data": { "type": "string", "x-format": "Binary", "description": "base64-encoded payload" }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The column is `bytea`; the entity property and the generated API types stay `string`. A TypeORM
|
|
82
|
+
transformer converts `string → Buffer` on write and `Buffer → base64 string` on read, so JSON
|
|
83
|
+
responses and request bodies always carry base64 text. Requirements:
|
|
84
|
+
|
|
85
|
+
- `type` must be `string` — any other type is rejected at generation time.
|
|
86
|
+
- The transformer does not validate the text, and the generator emits no `pattern` check; `Buffer.from(v, "base64")` ignores invalid characters. Validate base64 in the client, or in a hand-written check.
|
|
87
|
+
- `maxLength` has no effect on a binary column — the delivered size is checked by the app, not the generator.
|
|
88
|
+
- Set `express.json({ limit })` in the app when uploads exceed the 100 kB body-parser default.
|
|
89
|
+
- In mongo mode the field is a plain `String` column holding the same base64 text.
|
|
90
|
+
|
|
74
91
|
### `x-vexData` values
|
|
75
92
|
|
|
76
93
|
| Value | Description |
|