@simitgroup/simpleapp-generator 2.0.2-p-alpha → 2.0.2-q-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.
package/ReleaseNote.md CHANGED
@@ -1,3 +1,7 @@
1
+ [2.0.2q-alpha]
2
+
3
+ 1. Added 'schema' on the TypeScript type
4
+
1
5
  [2.0.2p-alpha]
2
6
 
3
7
  1. Added explicit return types in generated controller endpoints to improve TypeScript type safety and resolve ESLint `no-unsafe-return` warnings
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "2.0.2p-alpha",
3
+ "version": "2.0.2q-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -100,7 +100,7 @@ export class <%= it.typename %>Controller extends SimpleAppController<
100
100
  @ApiOperation({ operationId: 'runSearch' })
101
101
  <%~ drawMiniAppScope('list') %>
102
102
  async search(@AppUser() appuser: UserContext,@Body() data: schemas.SearchBody, @Res({ passthrough: true }) res: Response): Promise<schemas.<%= it.typename %>[]> {
103
- return await this._search(appuser,data, res)
103
+ return (await this._search(appuser, data, res)) as schemas.<%= it.typename %>[];
104
104
  }
105
105
 
106
106
  <% if(simpleappconfig.search !==undefined){%>
@@ -170,7 +170,7 @@ export class <%= it.typename %>Controller extends SimpleAppController<
170
170
  @Query('keyword') keyword:string,
171
171
  @Body() data: schemas.<%=it.typename%>,
172
172
  ): Promise<schemas.<%= it.typename %>AutoComplete[]> {
173
- return this._autocomplete(appuser, keyword,data);
173
+ return (await this._autocomplete(appuser, keyword, data)) as schemas.<%= it.typename %>AutoComplete[];
174
174
  }
175
175
 
176
176
  @Post()
@@ -222,7 +222,7 @@ export class <%= it.typename %>Controller extends SimpleAppController<
222
222
  <%~ drawMiniAppScope('patchMany') %>
223
223
  async patchMany(@AppUser() appuser: UserContext, @Body() patchManyData: schemas.PatchManyRequest<schemas.<%= it.typename%>>
224
224
  ): Promise<schemas.UpdateManyResponse> {
225
- return await this._patchMany(appuser, patchManyData);
225
+ return (await this._patchMany(appuser, patchManyData)) as schemas.UpdateManyResponse;
226
226
  }
227
227
 
228
228
  @Patch(':id')
@@ -260,7 +260,7 @@ export class <%= it.typename %>Controller extends SimpleAppController<
260
260
  @ApiOperation({ operationId: 'runDelete' })
261
261
  <%~ drawMiniAppScope('delete') %>
262
262
  async delete(@AppUser() appuser: UserContext,@Param('id') id: string): Promise<schemas.<%= it.typename %>> {
263
- return this._delete(appuser,id);
263
+ return (await this._delete(appuser, id)) as schemas.<%= it.typename %>;
264
264
  }
265
265
 
266
266
  /***************************** start status control api definitions *****************************************/
@@ -11,7 +11,7 @@ import * as schema from './<%= camelToKebab(it.resourceName) %>.schema'
11
11
  export const Default<%= toTypeName(it.resourceName ,modelname) %> = (uuid:string) : <%= toTypeName(it.resourceName ,modelname) %> | undefined =>{
12
12
  <% let model = it.models[modelname].model%>
13
13
  <% if(model['_id'] && model['code'] && model['label']){%>
14
- let data: <%= toTypeName(it.resourceName ,modelname) %> | undefined
14
+ let data: schema.<%= toTypeName(it.resourceName ,modelname) %> | undefined
15
15
  <%} else{%>
16
16
 
17
17
  const data = {
@@ -87,9 +87,15 @@ export class <%= it.typename %>Service extends SimpleAppService<schema.<%= it.ty
87
87
  <% let fml = it.jsonschema['x-simpleapp-config']['formulas'][index] %>
88
88
  // <%~ JSON.stringify(fml) %>
89
89
  //const tmp = jsonpath.query(vdata,fieldpath).filter((item:string)=>item!='')
90
+ <%
91
+ const m = String(fml.jsonPath || '').match(/^\$\.(\w+)\[\*\]/);
92
+ const prop = m ? m[1] : '';
93
+ const pascalProp = prop ? (prop[0].toUpperCase() + prop.slice(1)) : '';
94
+ const itemType = m ? `schema.${it.typename}${pascalProp}` : 'unknown';
95
+ %>
90
96
 
91
- jsonpath.apply($data, '<%~ fml.jsonPath %>', function ($item: schema.<%= it.typename %>) {
92
- return <%~fml.formula %>
97
+ jsonpath.apply($data, '<%~ fml.jsonPath %>', function ($item: <%= itemType %>) {
98
+ return <%~ fml.formula %>
93
99
  })
94
100
  <%}) %>
95
101
  <%} %>