very-express 0.6.7-alpha → 0.6.8-alpha

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.
Files changed (2) hide show
  1. package/dist/index.js +7 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -978,7 +978,7 @@ export const {{documentName}}Model: Model<{{documentName}}Document> = model<{{do
978
978
  */
979
979
  `}s6.getGenaratorHeaderComment=D_e;s6.defaultCompilerOptions={headerComment:D_e(),use_id:!1};s6.default={getGenaratorHeaderComment:D_e,defaultCompilerOptions:s6.defaultCompilerOptions}});var W9e=vs(Ug=>{"use strict";var URr=Ug&&Ug.__createBinding||(Object.create?function(a,s,l,p){p===void 0&&(p=l);var d=Object.getOwnPropertyDescriptor(s,l);(!d||("get"in d?!s.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return s[l]}}),Object.defineProperty(a,p,d)}:function(a,s,l,p){p===void 0&&(p=l),a[p]=s[l]}),VRr=Ug&&Ug.__setModuleDefault||(Object.create?function(a,s){Object.defineProperty(a,"default",{enumerable:!0,value:s})}:function(a,s){a.default=s}),J9e=Ug&&Ug.__importStar||function(a){if(a&&a.__esModule)return a;var s={};if(a!=null)for(var l in a)l!=="default"&&Object.prototype.hasOwnProperty.call(a,l)&&URr(s,a,l);return VRr(s,a),s},KRr=Ug&&Ug.__awaiter||function(a,s,l,p){function d(_){return _ instanceof l?_:new l(function(h){h(_)})}return new(l||(l=Promise))(function(_,h){function y(A){try{x(p.next(A))}catch(k){h(k)}}function v(A){try{x(p.throw(A))}catch(k){h(k)}}function x(A){A.done?_(A.value):d(A.value).then(y,v)}x((p=p.apply(a,s||[])).next())})},C_e=Ug&&Ug.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(Ug,"__esModule",{value:!0});Ug.compileFromFile=Ug.json2Mongoose=void 0;var JRr=J9e(require("util")),V9e=J9e(require("fs")),HRr=C_e($9e()),E_e=C_e(b_e()),GRr=C_e(v_e());function K9e(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 H9e(a,s){var l,p;let d={onCreate:{},onUpdate:{}},_=s.type==="object"?s.properties:((l=s.items)===null||l===void 0?void 0:l.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=H9e(h,y);Object.keys(v.onCreate).forEach(x=>{let A=[a,x].filter(k=>k).join(".");d.onCreate[A]=v.onCreate[x]}),Object.keys(v.onUpdate).forEach(x=>{let A=[a,x].filter(k=>k).join(".");d.onUpdate[A]=v.onUpdate[x]})}):a&&(s["x-onCreateValue"]&&(d.onCreate[a]=K9e(s["x-onCreateValue"])),s["x-onUpdateValue"]&&(d.onUpdate[a]=K9e(s["x-onUpdateValue"]))),d}function G9e(a,s){var l;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=A=>{switch(A.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 [${A}]`)}},x=(A,k,N)=>{let F={type:"String",index:N.index||!!N["x-foreignKey"]||_.includes(h)||!1,required:N.required||d.includes(h)||!1};switch(k.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(`"${A}" Array items as object must have properties defined !`);F.type=[x(A,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=G9e(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"]||!((l=y.items)===null||l===void 0)&&l["x-foreignKey"])&&(p[h].ref=y["x-foreignKey"]||y.items["x-foreignKey"])}return p}function z9e(a,s,l){if(!a["x-documentConfig"])throw new Error("( jsonSchema.x-documentConfig : object ) is required");let d=a["x-documentConfig"].documentName,_=G9e(a,l||E_e.default.defaultCompilerOptions),y=JRr.inspect(_,{depth:null}).replace(/'{{/g,"").replace(/}}'/g,"").replace(/"{{/g,"").replace(/}}"/g,""),v=H9e(void 0,a);return HRr.default.modelsTemplate(s,d,y,v,l||E_e.default.defaultCompilerOptions)}Ug.json2Mongoose=z9e;function zRr(a,s,l,p){return KRr(this,void 0,void 0,function*(){try{GRr.default.process(`Model : ${a} > ${l}`);let d=V9e.readFileSync(a),_=JSON.parse(d.toString()),h=z9e(_,s,p||E_e.default.defaultCompilerOptions);return V9e.writeFileSync(l,h),h}catch(d){throw new Error(`Processing File [${a}] :
980
980
  ${d.message||d}`)}})}Ug.compileFromFile=zRr});var tke=vs(z7=>{"use strict";var WRr=z7&&z7.__createBinding||(Object.create?function(a,s,l,p){p===void 0&&(p=l);var d=Object.getOwnPropertyDescriptor(s,l);(!d||("get"in d?!s.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return s[l]}}),Object.defineProperty(a,p,d)}:function(a,s,l,p){p===void 0&&(p=l),a[p]=s[l]}),YRr=z7&&z7.__setModuleDefault||(Object.create?function(a,s){Object.defineProperty(a,"default",{enumerable:!0,value:s})}:function(a,s){a.default=s}),A_e=z7&&z7.__importStar||function(a){if(a&&a.__esModule)return a;var s={};if(a!=null)for(var l in a)l!=="default"&&Object.prototype.hasOwnProperty.call(a,l)&&WRr(s,a,l);return YRr(s,a),s},X9e=z7&&z7.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(z7,"__esModule",{value:!0});z7.genarate=void 0;var yT=A_e(require("fs")),Q9e=A_e(M9e()),Z9e=A_e(W9e()),XRr=X9e(require("path")),Y9e=X9e(b_e()),QRr=(a,s)=>XRr.default.relative(a,s).replace(/\\/g,"/");function eke(a,s,l,p){yT.readdir(a,(d,_)=>{if(d){console.log(d);return}yT.existsSync(s)&&yT.rmSync(s,{recursive:!0}),yT.mkdirSync(s),yT.existsSync(l)&&yT.rmSync(l,{recursive:!0}),yT.mkdirSync(l),_.forEach(h=>{var y;try{if(!h.endsWith(".json"))return;let v=yT.readFileSync(`${a}/${h}`),A=(y=JSON.parse(v.toString())["x-documentConfig"])===null||y===void 0?void 0:y.documentName;if(!A)throw new Error(`invalid "x-documentConfig.documentName" in ${a}/${h}`);Q9e.compileFromFile(`${a}/${h}`,`${l}/${A}.ts`,p||Y9e.default.defaultCompilerOptions),Z9e.compileFromFile(`${a}/${h}`,`${QRr(s,l)}/${A}`,`${s}/${A}Model.ts`,p||Y9e.default.defaultCompilerOptions)}catch(v){console.error("\x1B[31m%s\x1B[0m",`Processing File : ${a}/${h}
981
- `,v)}})})}z7.genarate=eke;z7.default={genarate:eke,typesGen:Q9e,modelsGen:Z9e}});var OO=f_(require("fs")),lke=f_(require("child_process")),pke=f_(Fbe());var S3=f_(require("fs")),W_=f_(require("path"));var sx=f_(require("fs")),tY=f_(require("path"));function nEr(a,...s){console.log("\x1B[34m%s\x1B[0m","[PROCESSING]",a,s.length>0?s:"")}function iEr(a,...s){console.log("\x1B[32m%s\x1B[0m","[WRITING]",a,s.length>0?s:"")}function aEr(a,...s){console.log("\x1B[36m%s\x1B[0m","[INFO]",a,s.length>0?s:"")}function sEr(a,...s){console.log("\x1B[33m%s\x1B[0m","[WARN]",a,s.length>0?s:"")}function oEr(a,...s){console.log("\x1B[41m%s\x1B[0m","[ERROR]",a,s.length>0?s:""),process.exit(1)}var yl={process:nEr,writing:iEr,info:aEr,warn:sEr,error:oEr};var gq={name:"very-express",version:"0.6.7-alpha",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",preversion:"npm run lint",postversion:"npm run compile",v:"node scripts/bump-version.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.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"}};function ipe(a){return`/**
981
+ `,v)}})})}z7.genarate=eke;z7.default={genarate:eke,typesGen:Q9e,modelsGen:Z9e}});var OO=f_(require("fs")),lke=f_(require("child_process")),pke=f_(Fbe());var S3=f_(require("fs")),W_=f_(require("path"));var sx=f_(require("fs")),tY=f_(require("path"));function nEr(a,...s){console.log("\x1B[34m%s\x1B[0m","[PROCESSING]",a,s.length>0?s:"")}function iEr(a,...s){console.log("\x1B[32m%s\x1B[0m","[WRITING]",a,s.length>0?s:"")}function aEr(a,...s){console.log("\x1B[36m%s\x1B[0m","[INFO]",a,s.length>0?s:"")}function sEr(a,...s){console.log("\x1B[33m%s\x1B[0m","[WARN]",a,s.length>0?s:"")}function oEr(a,...s){console.log("\x1B[41m%s\x1B[0m","[ERROR]",a,s.length>0?s:""),process.exit(1)}var yl={process:nEr,writing:iEr,info:aEr,warn:sEr,error:oEr};var gq={name:"very-express",version:"0.6.8-alpha",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",preversion:"npm run lint",postversion:"npm run compile",v:"node scripts/bump-version.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.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"}};function ipe(a){return`/**
982
982
  * Generated by veryExpress@${a}
983
983
  * https://github.com/Justin26l/VeryExpress
984
984
  */
@@ -1055,20 +1055,20 @@ export default class RoleBaseAccessControl {
1055
1055
  `)}
1056
1056
  ${ge} {
1057
1057
  ${Ne}
1058
- }`}let B=$(p.includes("getList"),[`@SuccessResponse(200, "Success", typeof VexResponse<${s}[]>)`,'@Post("/search")'],`public async getList${s}(@Body() body: { filter: Filter, join?: Join, select?: Select }): Promise<typeof VexResponse<${s}[]>>`,`const result = await this.repo.find(body.filter, body.join, body.select);
1059
- throw new VexResponse(200, { result });`),G=$(p.includes("get"),[`@SuccessResponse(200, "Success", typeof VexResponse<${s}>)`,'@Get("{id}")'],`public async get${s}(${V}, @Query() join?: Join, @Query() select?: Select): Promise<typeof VexResponse<${s}>>`,`const result = await this.repo.findOne({ _id: id }, join, select);
1058
+ }`}let B=$(p.includes("getList"),[`@SuccessResponse(200, "Success", typeof VexResponse<${s}[]>)`,'@Post("/search")'],`public async getList${s}(@Body() body: { filter: Filter, join?: string[], select?: string[] })`,`const result = await this.repo.find(body.filter, body.join, body.select);
1059
+ throw new VexResponse(200, { result });`),G=$(p.includes("get"),[`@SuccessResponse(200, "Success", typeof VexResponse<${s}>)`,'@Get("{id}")'],`public async get${s}(${V}, @Query() join?: string[], @Query() select?: string[])`,`const result = await this.repo.findOne({ _id: id }, join, select);
1060
1060
  if (!result) throw new VexResponseError(404);
1061
- throw new VexResponse(200, { result });`),oe=$(p.includes("post"),[`@SuccessResponse(201, "Created", typeof VexResponse<${s}>)`,"@Post()"],`public async create${s}(@Body() body: ${s}): Promise<typeof VexResponse<${s}>>`,`${k}
1061
+ throw new VexResponse(200, { result });`),oe=$(p.includes("post"),[`@SuccessResponse(201, "Created", typeof VexResponse<${s}>)`,"@Post()"],`public async create${s}(@Body() body: ${s})`,`${k}
1062
1062
  const result = await this.repo.create(body);
1063
1063
  if (!result) throw new VexResponseError(400);
1064
1064
  this.setStatus(201);
1065
- throw new VexResponse(201, { result });`),Ae=$(p.includes("put"),[`@SuccessResponse(200, "Success", typeof VexResponse<${s}>)`,'@Put("{id}")'],`public async replace${s}(${V}, @Body() body: ${s}): Promise<typeof VexResponse<${s}>>`,`${k}
1065
+ throw new VexResponse(201, { result });`),Ae=$(p.includes("put"),[`@SuccessResponse(200, "Success", typeof VexResponse<${s}>)`,'@Put("{id}")'],`public async replace${s}(${V}, @Body() body: ${s})`,`${k}
1066
1066
  const result = await this.repo.replace(id, body);
1067
1067
  if (!result) throw new VexResponseError(404);
1068
- throw new VexResponse(200, { result });`),ee=$(p.includes("patch"),[`@SuccessResponse(200, "Success", typeof VexResponse<${s}>)`,'@Patch("{id}")'],`public async update${s}(${V}, @Body() body: Partial<${s}>): Promise<typeof VexResponse<${s}>>`,`${k}
1068
+ throw new VexResponse(200, { result });`),ee=$(p.includes("patch"),[`@SuccessResponse(200, "Success", typeof VexResponse<${s}>)`,'@Patch("{id}")'],`public async update${s}(${V}, @Body() body: Partial<${s}>)`,`${k}
1069
1069
  const result = await this.repo.update(id, body);
1070
1070
  if (!result) throw new VexResponseError(404);
1071
- throw new VexResponse(200, { result });`),le=$(p.includes("delete"),['@SuccessResponse(204, "No Content")','@Delete("{id}")'],`public async delete${s}(${V}): Promise<void>`,`const existing = await this.repo.findOne({ _id: id });
1071
+ throw new VexResponse(200, { result });`),le=$(p.includes("delete"),['@SuccessResponse(204, "No Content")','@Delete("{id}")'],`public async delete${s}(${V})`,`const existing = await this.repo.findOne({ _id: id });
1072
1072
  if (!existing) throw new VexResponseError(404);
1073
1073
  await this.repo.delete(id);
1074
1074
  throw new VexResponse(204);`),pe=`{{headerComment}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "very-express",
3
- "version": "0.6.7-alpha",
3
+ "version": "0.6.8-alpha",
4
4
  "description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
5
5
  "author": "Justin26l",
6
6
  "license": "MIT",