@simitgroup/simpleapp-generator 2.0.2-o-alpha → 2.0.2-p-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 +4 -0
- package/package.json +1 -1
- package/templates/basic/nest/controller.ts.eta +5 -4
- package/templates/basic/nest/default.ts.eta +2 -2
- package/templates/basic/nest/service.ts.eta +3 -2
- package/templates/nuxt/app.vue.eta +4 -4
- package/templates/nuxt/server/api/auth/[...].ts.eta +18 -5
package/ReleaseNote.md
CHANGED
package/package.json
CHANGED
|
@@ -99,7 +99,7 @@ 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) {
|
|
102
|
+
async search(@AppUser() appuser: UserContext,@Body() data: schemas.SearchBody, @Res({ passthrough: true }) res: Response): Promise<schemas.<%= it.typename %>[]> {
|
|
103
103
|
return await this._search(appuser,data, res)
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -169,7 +169,7 @@ 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
|
-
) {
|
|
172
|
+
): Promise<schemas.<%= it.typename %>AutoComplete[]> {
|
|
173
173
|
return this._autocomplete(appuser, keyword,data);
|
|
174
174
|
}
|
|
175
175
|
|
|
@@ -220,7 +220,8 @@ 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%>>
|
|
223
|
+
async patchMany(@AppUser() appuser: UserContext, @Body() patchManyData: schemas.PatchManyRequest<schemas.<%= it.typename%>>
|
|
224
|
+
): Promise<schemas.UpdateManyResponse> {
|
|
224
225
|
return await this._patchMany(appuser, patchManyData);
|
|
225
226
|
}
|
|
226
227
|
|
|
@@ -258,7 +259,7 @@ 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
|
+
async delete(@AppUser() appuser: UserContext,@Param('id') id: string): Promise<schemas.<%= it.typename %>> {
|
|
262
263
|
return this._delete(appuser,id);
|
|
263
264
|
}
|
|
264
265
|
|
|
@@ -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: <%= toTypeName(it.resourceName ,modelname) %> | undefined
|
|
15
15
|
<%} else{%>
|
|
16
16
|
|
|
17
17
|
const data = {
|
|
@@ -88,8 +88,9 @@ export class <%= it.typename %>Service extends SimpleAppService<schema.<%= it.ty
|
|
|
88
88
|
// <%~ JSON.stringify(fml) %>
|
|
89
89
|
//const tmp = jsonpath.query(vdata,fieldpath).filter((item:string)=>item!='')
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
jsonpath.apply($data, '<%~ fml.jsonPath %>', function ($item: schema.<%= it.typename %>) {
|
|
92
|
+
return <%~fml.formula %>
|
|
93
|
+
})
|
|
93
94
|
<%}) %>
|
|
94
95
|
<%} %>
|
|
95
96
|
|
|
@@ -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 }) {
|