@simitgroup/simpleapp-generator 2.0.0-y-alpha → 2.0.0-z-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 (66) hide show
  1. package/ReleaseNote.md +7 -1
  2. package/dist/buildinschemas/autoincreament.js +1 -1
  3. package/dist/buildinschemas/docnoformat.js +1 -1
  4. package/dist/buildinschemas/docnoformat.js.map +1 -1
  5. package/dist/buildinschemas/documentevent.js +1 -1
  6. package/dist/buildinschemas/message.d.ts +3 -0
  7. package/dist/buildinschemas/message.d.ts.map +1 -0
  8. package/dist/buildinschemas/message.js +34 -0
  9. package/dist/buildinschemas/message.js.map +1 -0
  10. package/dist/buildinschemas/webhookhistory.d.ts +3 -0
  11. package/dist/buildinschemas/webhookhistory.d.ts.map +1 -0
  12. package/dist/buildinschemas/webhookhistory.js +44 -0
  13. package/dist/buildinschemas/webhookhistory.js.map +1 -0
  14. package/dist/createproject.js +138 -0
  15. package/dist/createproject.js.map +1 -0
  16. package/dist/generate-allow-changebackend.js +305 -0
  17. package/dist/generate-allow-changebackend.js.map +1 -0
  18. package/dist/index.js +4 -2
  19. package/dist/index.js.map +1 -1
  20. package/dist/index2.js +118 -0
  21. package/dist/index2.js.map +1 -0
  22. package/dist/installdependency.js +20 -0
  23. package/dist/installdependency.js.map +1 -0
  24. package/dist/installnest.js +2 -0
  25. package/dist/installnest.js.map +1 -0
  26. package/dist/installnuxt.js +2 -0
  27. package/dist/installnuxt.js.map +1 -0
  28. package/dist/processors/groupsbuilder.js +2 -0
  29. package/dist/processors/groupsbuilder.js.map +1 -0
  30. package/dist/schematype/baseschema.js +25 -0
  31. package/dist/schematype/baseschema.js.map +1 -0
  32. package/dist/schematype/default.js +2 -0
  33. package/dist/schematype/default.js.map +1 -0
  34. package/dist/schematype/index.js +12 -0
  35. package/dist/schematype/index.js.map +1 -0
  36. package/dist/schematype/primarymasterdata.js +38 -0
  37. package/dist/schematype/primarymasterdata.js.map +1 -0
  38. package/dist/schematype/simple.js +24 -0
  39. package/dist/schematype/simple.js.map +1 -0
  40. package/dist/schematype/simplemasterdata.js +31 -0
  41. package/dist/schematype/simplemasterdata.js.map +1 -0
  42. package/dist/schematype/transaction.js +74 -0
  43. package/dist/schematype/transaction.js.map +1 -0
  44. package/package.json +1 -1
  45. package/src/index.ts +4 -2
  46. package/templates/nest/src/simple-app/_core/features/auth/role-guard/roles.enum.ts.eta +4 -1
  47. package/templates/nest/src/simple-app/_core/features/cron/base/cron.base.ts.eta +11 -11
  48. package/templates/nest/src/simple-app/_core/features/maintenance/maintenance.controller.ts.eta +26 -7
  49. package/templates/nest/src/simple-app/_core/features/maintenance/maintenance.service.ts.eta +25 -12
  50. package/templates/nest/src/simple-app/_core/features/maintenance/schemas/environment.ts.eta +37 -20
  51. package/templates/nest/src/simple-app/_core/features/mini-app/mini-app-manager/mini-app-manager-policy.service.ts.eta +3 -3
  52. package/templates/nest/src/simple-app/_core/features/policy/policy.service.ts.eta +5 -8
  53. package/templates/nest/src/simple-app/_core/features/queue/queue-base/queue-base.consumer.ts.eta +5 -5
  54. package/templates/nest/src/simple-app/_core/features/queue/queue-user-context/queue-user-context.service.ts.eta +4 -4
  55. package/templates/nest/src/simple-app/_core/features/user-context/robot-user.service.ts.eta +17 -11
  56. package/templates/nest/src/simple-app/_core/features/user-context/user-context.module.ts.eta +2 -1
  57. package/templates/nest/src/simple-app/_core/features/user-context/user.context.ts.eta +28 -5
  58. package/templates/nest/src/simple-app/_core/framework/base/simple-app.service.ts.eta +56 -56
  59. package/templates/nest/src/simple-app/_core/framework/simple-app.middleware.ts.eta +1 -1
  60. package/templates/nuxt/composables/getUserStore.generate.ts.eta +19 -23
  61. package/templates/nuxt/middleware/30.acl.global.ts._eta +139 -0
  62. package/templates/nuxt/pages/[xorg]/profile.vue.eta +5 -2
  63. package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +11 -15
  64. package/templates/nest/src/simple-app/_core/features/mini-app/developer-portal/dto/developer-portal-create-app.dto.ts.eta +0 -22
  65. package/templates/nest/src/simple-app/_core/features/mini-app/developer-portal/dto/developer-portal-publish-app.dto.ts.eta +0 -0
  66. package/templates/nuxt/middleware/30.acl.global.ts.eta +0 -48
@@ -0,0 +1,139 @@
1
+ import { RouteLocationNormalizedGeneric } from 'vue-router';
2
+ import { getUserProfile } from './../composables/getUserStore.generate';
3
+
4
+ export default defineNuxtRouteMiddleware(async (to, from) => {
5
+ console.log(to.path)
6
+ const userProfile = getUserProfile()
7
+ const xorg = <string>to.params['xorg'] ?? 'MC0wLTA'
8
+ useNuxtApp().$userstore.xOrg=xorg
9
+ if(!userProfile?._id){
10
+ // console.error("middleware detect no user id, reload under xorg",xorg)
11
+ await reloadUserStoreFromMiddleware(xorg)
12
+ // console.log("after reload",userProfile)
13
+ }else if(userProfile.branchId===0 && xorg !='MC0wLTA'){
14
+ // console.error("middleware detect wrong xorg reload profile for",xorg)
15
+ await reloadUserStoreFromMiddleware(xorg)
16
+ // console.log("after reload",userProfile)
17
+ }else{
18
+ // console.log("use exists, use back the user store")
19
+ }
20
+
21
+
22
+
23
+ const currentgroup = useCookie('currentGroup').value
24
+ if(currentgroup && userProfile.groups.includes(currentgroup)){
25
+ //use back ground
26
+ }else if(userProfile.groups.length>0){
27
+ goTo('pickgroup')
28
+ }
29
+ // if (!currentgroup)goTo('pickgroup')
30
+
31
+ // console.log("userProfile1",userProfile)
32
+ // console.log(xorg)
33
+
34
+ const { status } = useAuth();
35
+ const metas = Object.keys(to.meta)
36
+
37
+ if(status.value=='unauthenticated'){
38
+ if(to.meta.auth===false){
39
+ return true
40
+ }else{
41
+ navigateTo('/login')
42
+ }
43
+ }
44
+
45
+ const license = useLicense().getLicense()
46
+ console.log("metas check",metas)
47
+ if(metas.length == 0){
48
+ throw createError({
49
+ statusCode: 404,
50
+ statusMessage: 'pageDoesNotExists',
51
+ message: 'pageDoesNotExistsMsg',
52
+ fatal: true,
53
+ });
54
+ }
55
+ if(to.meta['licenseWeight'] === undefined){
56
+ throw createError({
57
+ statusCode: 403,
58
+ statusMessage: 'undefinePageMetaLicenseWeight',
59
+ message: 'undefinePageMetaLicenseWeightMsg',
60
+ fatal: true,
61
+ });
62
+ }
63
+
64
+ if(to.meta['requiredGroups']===undefined || !Array.isArray(to.meta['requiredGroups'])){
65
+ throw createError({
66
+ statusCode: 403,
67
+ statusMessage: 'undefinePageMetaRequiredGroups',
68
+ message: 'undefinePageMetaRequiredGroupsMsg',
69
+ fatal: true,
70
+ });
71
+ }
72
+
73
+ if(to.meta['licenseWeight'] && <number>to.meta['licenseWeight']> license.licenseWeight){
74
+ throw createError({
75
+ statusCode: 403,
76
+ statusMessage: 'upgradeSoftwareLicenseRequired',
77
+ message: 'upgradeSoftwareLicenseRequiredMsg',
78
+ fatal: true,
79
+ });
80
+ }
81
+
82
+
83
+ if(to.meta['requiredGroups']){
84
+
85
+ const requiredGroups:string[] = to.meta['requiredGroups']
86
+ const userGroups = userProfile.groups
87
+ let allowAccess = false
88
+ if(['','/'].includes(to.path)) allowAccess= true
89
+
90
+ for(const g of requiredGroups){
91
+
92
+ if(userGroups.includes(g)){
93
+ allowAccess = true
94
+ }
95
+ if(userProfile.roles.includes(g)){
96
+ allowAccess = true
97
+ }
98
+
99
+ }
100
+ if(!allowAccess){
101
+ throw createError({
102
+ statusCode: 403,
103
+ statusMessage: 'insufficientPriviledge',
104
+ message: 'insufficientPriviledgeMsg',
105
+ fatal: true,
106
+ });
107
+ }
108
+ }
109
+ console.log("middleware check isexpired",useLicense().isExpired())
110
+ if(!useLicense().isExpired()) {
111
+ return true
112
+ }else if(allowAccessExpired(to)){
113
+ return true
114
+ }else{
115
+ throw createError({
116
+ statusCode: 402,
117
+ statusMessage: 'systemExpired',
118
+ message:'systemExpiredMsg',
119
+ fatal: true,
120
+ });
121
+ }
122
+ })
123
+
124
+
125
+ const allowAccessExpired = (to:RouteLocationNormalizedGeneric)=>{
126
+ const userProfile = getUserProfile()
127
+ let allowPass = false
128
+ const isSuperAdmin = userProfile.groups.includes('superadmin')
129
+ if(isSuperAdmin){
130
+ allowPass=true
131
+ }
132
+ const allowedPath = ['/billing','/pickgroup']
133
+ for(const p of allowedPath){
134
+ console.log("to.path.includes",to.path,p)
135
+ if(to.path.includes(p))allowPass = true
136
+ }
137
+
138
+ return allowPass
139
+ }
@@ -10,6 +10,9 @@
10
10
  */
11
11
  import profile from "../profile.vue";
12
12
  definePageMeta({
13
- // menuPath:'setting/profile'
14
- })
13
+ menuPath:'setting/profile',
14
+ licenseWeight: 0,
15
+ requiredGroups: ["everyone",]
16
+
17
+ });
15
18
  </script>
@@ -53,12 +53,9 @@ export default defineNuxtPlugin(async (nuxtApp) => {
53
53
  }),
54
54
 
55
55
  actions: {
56
- async loadRemoteUserInfo() {
57
- // console.log('loadRemoteUserInfo')
58
-
56
+ async loadRemoteUserFromXorg(xorg:string) {
59
57
  const { $axios, $miniAppStore, $customFieldStore } = useNuxtApp();
60
- const route = useRoute();
61
- let xorg = this.getCurrentXorg();
58
+
62
59
  let apiurl = "";
63
60
  if (!xorg) {
64
61
  apiurl = `${useRuntimeConfig().public.appUrl}/api`;
@@ -76,7 +73,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
76
73
  return;
77
74
  }
78
75
  const res = tmp.data
79
-
76
+ this.xOrg= xorg
80
77
  this._id = res._id;
81
78
  this.uName = res.uName;
82
79
  this.sessionId = res.sessionId;
@@ -103,7 +100,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
103
100
  this.groups = res.groups;
104
101
  this.roles = res.roles;
105
102
  this.time = res.time;
106
- this.xOrg = res.xOrg;
103
+
107
104
  this.invites = res.invites;
108
105
  this.moreProps = res.moreProps;
109
106
  // this.package = res.moreProps.package;
@@ -122,15 +119,14 @@ export default defineNuxtPlugin(async (nuxtApp) => {
122
119
  return Promise.reject(err);
123
120
  });
124
121
  },
122
+ async loadRemoteUserInfo() {
123
+ const route = useRoute();
124
+ let xorg = this.getCurrentXorg();
125
+ await this.loadRemoteUserFromXorg(xorg)
126
+
127
+ },
125
128
  getCurrentXorg() {
126
- const xorg = useRoute().params.xorg
127
- let result = ''
128
- if(typeof xorg == 'string'){
129
- result = xorg
130
- }else{
131
- result =''
132
- }
133
- return result
129
+ return this.xOrg
134
130
  },
135
131
  async pingSession(): Promise<string> {
136
132
  let xorg = this.getCurrentXorg();
@@ -1,22 +0,0 @@
1
- import { Field, ObjectType } from '@nestjs/graphql';
2
- import { ApiProperty } from '@nestjs/swagger';
3
- import { MiniAppAuthor } from 'src/simple-app/_core/resources/mini-app/mini-app.schema';
4
-
5
- @ObjectType()
6
- export class DeveloperPortalCreateAppDto {
7
- @Field()
8
- @ApiProperty({ type: 'string', required: true, default: '' })
9
- code: string;
10
-
11
- @Field()
12
- @ApiProperty({ type: 'string', required: true, default: '' })
13
- name: string;
14
-
15
- @Field()
16
- @ApiProperty({ type: 'string', required: true, default: '' })
17
- version: string;
18
-
19
- @Field()
20
- @ApiProperty({ type: MiniAppAuthor, required: true, default: '' })
21
- author: MiniAppAuthor;
22
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * This file was automatically generated by simpleapp generator. Every
3
- * MODIFICATION OVERRIDE BY GENERATEOR
4
- * last change 2023-10-28
5
- * Author: Ks Tan
6
- */
7
- import { getUserProfile } from './../composables/getUserStore.generate';
8
- import {MenuData} from '~/types'
9
- export default defineNuxtRouteMiddleware((to, from) => {
10
- // const userprofile = getUserProfile()
11
- //skip auto then simply allow
12
- if(!to.meta.auth){
13
- return true
14
- }else if(to.path=='/relogin'){
15
- return true
16
- }else if( getPublicResource(String(to.params['xorg'])).filter((item:MenuData)=>to.fullPath === item.url)){
17
- return true
18
- }// no permission control needed yet
19
- else if(!to.params['xorg']){
20
-
21
- return true //no permission needed
22
- }else{
23
-
24
- const resourcename = to.fullPath.split('/')[2]
25
-
26
- if(resourcename===undefined){//home page
27
-
28
- // return true //no permission needed
29
- //if(userprofile.group==''){
30
- // console.error("no access right to current xorg")
31
- // return navigateTo('/')
32
- //}else{
33
- return true
34
- //}
35
-
36
- }else{
37
- const {$userstore} = useNuxtApp()
38
- if($userstore.haveAccess(resourcename)){
39
- return true
40
- }else{
41
- // congetWorkflowApisole.error("access deny, redirect to '/'")
42
- return navigateTo('/')
43
- // abortNavigation()
44
- }
45
- }
46
- }
47
-
48
- })