@simitgroup/simpleapp-generator 2.0.2-o-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 +8 -0
- package/package.json +1 -1
- package/templates/basic/nest/controller.ts.eta +9 -8
- package/templates/basic/nest/default.ts.eta +2 -2
- package/templates/basic/nest/service.ts.eta +9 -2
- package/templates/nuxt/app.vue.eta +4 -4
- package/templates/nuxt/server/api/auth/[...].ts.eta +18 -5
package/ReleaseNote.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
[2.0.2q-alpha]
|
|
2
|
+
|
|
3
|
+
1. Added 'schema' on the TypeScript type
|
|
4
|
+
|
|
5
|
+
[2.0.2p-alpha]
|
|
6
|
+
|
|
7
|
+
1. Added explicit return types in generated controller endpoints to improve TypeScript type safety and resolve ESLint `no-unsafe-return` warnings
|
|
8
|
+
|
|
1
9
|
[2.0.2o-alpha]
|
|
2
10
|
|
|
3
11
|
1. Revert date.generate.ts for universal use
|
package/package.json
CHANGED
|
@@ -99,8 +99,8 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
99
99
|
@ApiBody({ description: 'Data', type: schemas.SearchBody })
|
|
100
100
|
@ApiOperation({ operationId: 'runSearch' })
|
|
101
101
|
<%~ drawMiniAppScope('list') %>
|
|
102
|
-
async search(@AppUser() appuser: UserContext,@Body() data: schemas.SearchBody, @Res({ passthrough: true }) res: Response) {
|
|
103
|
-
return await this._search(appuser,data, res)
|
|
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)) as schemas.<%= it.typename %>[];
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
<% if(simpleappconfig.search !==undefined){%>
|
|
@@ -169,8 +169,8 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
169
169
|
async autoComplete(@AppUser() appuser: UserContext,
|
|
170
170
|
@Query('keyword') keyword:string,
|
|
171
171
|
@Body() data: schemas.<%=it.typename%>,
|
|
172
|
-
) {
|
|
173
|
-
return this._autocomplete(appuser, keyword,data);
|
|
172
|
+
): Promise<schemas.<%= it.typename %>AutoComplete[]> {
|
|
173
|
+
return (await this._autocomplete(appuser, keyword, data)) as schemas.<%= it.typename %>AutoComplete[];
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
@Post()
|
|
@@ -220,8 +220,9 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
220
220
|
@ApiBody({ description: 'Data', type: schemas.PatchManyRequest<schemas.<%= it.typename%>> })
|
|
221
221
|
@ApiOperation({ operationId: 'runPatchMany' })
|
|
222
222
|
<%~ drawMiniAppScope('patchMany') %>
|
|
223
|
-
async patchMany(@AppUser() appuser: UserContext, @Body() patchManyData: schemas.PatchManyRequest<schemas.<%= it.typename%>>
|
|
224
|
-
|
|
223
|
+
async patchMany(@AppUser() appuser: UserContext, @Body() patchManyData: schemas.PatchManyRequest<schemas.<%= it.typename%>>
|
|
224
|
+
): Promise<schemas.UpdateManyResponse> {
|
|
225
|
+
return (await this._patchMany(appuser, patchManyData)) as schemas.UpdateManyResponse;
|
|
225
226
|
}
|
|
226
227
|
|
|
227
228
|
@Patch(':id')
|
|
@@ -258,8 +259,8 @@ export class <%= it.typename %>Controller extends SimpleAppController<
|
|
|
258
259
|
@ApiResponse({ status: 500, description: 'Internal error' })
|
|
259
260
|
@ApiOperation({ operationId: 'runDelete' })
|
|
260
261
|
<%~ drawMiniAppScope('delete') %>
|
|
261
|
-
async delete(@AppUser() appuser: UserContext,@Param('id') id: string) {
|
|
262
|
-
return this._delete(appuser,id)
|
|
262
|
+
async delete(@AppUser() appuser: UserContext,@Param('id') id: string): Promise<schemas.<%= it.typename %>> {
|
|
263
|
+
return (await this._delete(appuser, id)) as schemas.<%= it.typename %>;
|
|
263
264
|
}
|
|
264
265
|
|
|
265
266
|
/***************************** start status control api definitions *****************************************/
|
|
@@ -8,10 +8,10 @@ import * as schema from './<%= camelToKebab(it.resourceName) %>.schema'
|
|
|
8
8
|
|
|
9
9
|
<%Object.keys(it.models).forEach(function(modelname) { %>
|
|
10
10
|
|
|
11
|
-
export const Default<%= toTypeName(it.resourceName ,modelname) %> = (uuid:string)=>{
|
|
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
|
-
|
|
14
|
+
let data: schema.<%= toTypeName(it.resourceName ,modelname) %> | undefined
|
|
15
15
|
<%} else{%>
|
|
16
16
|
|
|
17
17
|
const data = {
|
|
@@ -87,9 +87,16 @@ 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
|
-
|
|
92
|
-
|
|
97
|
+
jsonpath.apply($data, '<%~ fml.jsonPath %>', function ($item: <%= itemType %>) {
|
|
98
|
+
return <%~ fml.formula %>
|
|
99
|
+
})
|
|
93
100
|
<%}) %>
|
|
94
101
|
<%} %>
|
|
95
102
|
|
|
@@ -31,9 +31,9 @@ watch(()=>useRoute().fullPath,async (newval,oldvalue)=>{
|
|
|
31
31
|
if(getPathPara('xorg','')!=''){
|
|
32
32
|
|
|
33
33
|
if(getCurrentXorg()===''){
|
|
34
|
-
|
|
34
|
+
navigateTo('/picktenant')
|
|
35
35
|
}else if(!getUserProfile()?.currentGroup){
|
|
36
|
-
|
|
36
|
+
goTo('pickgroup')
|
|
37
37
|
}
|
|
38
38
|
setGraphqlServer()
|
|
39
39
|
}
|
|
@@ -56,9 +56,9 @@ onMounted(async()=>{
|
|
|
56
56
|
const currentgroup = useCookie('currentGroup').value
|
|
57
57
|
//if no xorg, no enforce pick group
|
|
58
58
|
if(getCurrentXorg()===''){
|
|
59
|
-
|
|
59
|
+
navigateTo('/picktenant')
|
|
60
60
|
}else if(!currentgroup){
|
|
61
|
-
|
|
61
|
+
goTo('/pickgroup')
|
|
62
62
|
}
|
|
63
63
|
setGraphqlServer()
|
|
64
64
|
}else{
|
|
@@ -72,10 +72,18 @@ export default NuxtAuthHandler({
|
|
|
72
72
|
token.accessToken = account.access_token;
|
|
73
73
|
token.refreshToken = account.refresh_token;
|
|
74
74
|
token.expiresAt = account.expires_at;
|
|
75
|
-
} else if (Date.now() < (<number>token.expiresAt) * 1000) {
|
|
76
75
|
return token;
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const buffer = 60;
|
|
79
|
+
|
|
80
|
+
if (Date.now() < (<number>token.expiresAt - buffer) * 1000) {
|
|
81
|
+
return token;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!token.refreshToken) {
|
|
85
|
+
return token;
|
|
86
|
+
}
|
|
79
87
|
// try refresh token
|
|
80
88
|
const response = await fetch(`${process.env.OAUTH2_CONFIGURL}/protocol/openid-connect/token`, {
|
|
81
89
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
@@ -92,7 +100,12 @@ export default NuxtAuthHandler({
|
|
|
92
100
|
|
|
93
101
|
if(!response.ok) {
|
|
94
102
|
/** @todo handle refresh token failed */
|
|
95
|
-
return
|
|
103
|
+
return {
|
|
104
|
+
...token,
|
|
105
|
+
accessToken: null,
|
|
106
|
+
expiresAt: 0,
|
|
107
|
+
error: "RefreshAccessTokenError"
|
|
108
|
+
};
|
|
96
109
|
}
|
|
97
110
|
|
|
98
111
|
return {
|
|
@@ -102,7 +115,7 @@ export default NuxtAuthHandler({
|
|
|
102
115
|
expiresAt: Math.floor(Date.now() / 1000 + newToken.expires_in),
|
|
103
116
|
// Fall back to old refresh token, but note that
|
|
104
117
|
// many providers may only allow using a refresh token once.
|
|
105
|
-
refreshToken: newToken.refresh_token ?? token.
|
|
118
|
+
refreshToken: newToken.refresh_token ?? token.refreshToken
|
|
106
119
|
}
|
|
107
120
|
},
|
|
108
121
|
async session({ session, token, user }) {
|