@simitgroup/simpleapp-generator 2.0.0-x-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.
- package/ReleaseNote.md +10 -0
- package/dist/buildinschemas/autoincreament.js +1 -1
- package/dist/buildinschemas/docnoformat.js +1 -1
- package/dist/buildinschemas/docnoformat.js.map +1 -1
- package/dist/buildinschemas/documentevent.js +1 -1
- package/dist/buildinschemas/message.d.ts +3 -0
- package/dist/buildinschemas/message.d.ts.map +1 -0
- package/dist/buildinschemas/message.js +34 -0
- package/dist/buildinschemas/message.js.map +1 -0
- package/dist/buildinschemas/webhookhistory.d.ts +3 -0
- package/dist/buildinschemas/webhookhistory.d.ts.map +1 -0
- package/dist/buildinschemas/webhookhistory.js +44 -0
- package/dist/buildinschemas/webhookhistory.js.map +1 -0
- package/dist/createproject.js +138 -0
- package/dist/createproject.js.map +1 -0
- package/dist/generate-allow-changebackend.js +305 -0
- package/dist/generate-allow-changebackend.js.map +1 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/index2.js +118 -0
- package/dist/index2.js.map +1 -0
- package/dist/installdependency.js +20 -0
- package/dist/installdependency.js.map +1 -0
- package/dist/installnest.js +2 -0
- package/dist/installnest.js.map +1 -0
- package/dist/installnuxt.js +2 -0
- package/dist/installnuxt.js.map +1 -0
- package/dist/processors/groupsbuilder.js +2 -0
- package/dist/processors/groupsbuilder.js.map +1 -0
- package/dist/schematype/baseschema.js +25 -0
- package/dist/schematype/baseschema.js.map +1 -0
- package/dist/schematype/default.js +2 -0
- package/dist/schematype/default.js.map +1 -0
- package/dist/schematype/index.js +12 -0
- package/dist/schematype/index.js.map +1 -0
- package/dist/schematype/primarymasterdata.js +38 -0
- package/dist/schematype/primarymasterdata.js.map +1 -0
- package/dist/schematype/simple.js +24 -0
- package/dist/schematype/simple.js.map +1 -0
- package/dist/schematype/simplemasterdata.js +31 -0
- package/dist/schematype/simplemasterdata.js.map +1 -0
- package/dist/schematype/transaction.js +74 -0
- package/dist/schematype/transaction.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +4 -2
- package/templates/basic/nuxt/simpleapp.generate.client.ts.eta +11 -10
- package/templates/nest/src/simple-app/_core/features/auth/role-guard/roles.enum.ts.eta +4 -1
- package/templates/nest/src/simple-app/_core/features/cron/base/cron.base.ts.eta +11 -11
- package/templates/nest/src/simple-app/_core/features/maintenance/maintenance.controller.ts.eta +26 -7
- package/templates/nest/src/simple-app/_core/features/maintenance/maintenance.service.ts.eta +25 -12
- package/templates/nest/src/simple-app/_core/features/maintenance/schemas/environment.ts.eta +37 -20
- package/templates/nest/src/simple-app/_core/features/mini-app/mini-app-manager/mini-app-manager-policy.service.ts.eta +3 -3
- package/templates/nest/src/simple-app/_core/features/policy/policy.service.ts.eta +5 -8
- package/templates/nest/src/simple-app/_core/features/queue/queue-base/queue-base.consumer.ts.eta +5 -5
- package/templates/nest/src/simple-app/_core/features/queue/queue-user-context/queue-user-context.service.ts.eta +4 -4
- package/templates/nest/src/simple-app/_core/features/user-context/robot-user.service.ts.eta +17 -11
- package/templates/nest/src/simple-app/_core/features/user-context/user-context.module.ts.eta +2 -1
- package/templates/nest/src/simple-app/_core/features/user-context/user.context.ts.eta +28 -5
- package/templates/nest/src/simple-app/_core/framework/base/simple-app.service.ts.eta +56 -56
- package/templates/nest/src/simple-app/_core/framework/simple-app.middleware.ts.eta +1 -1
- package/templates/nuxt/composables/getUserStore.generate.ts.eta +19 -23
- package/templates/nuxt/middleware/30.acl.global.ts._eta +139 -0
- package/templates/nuxt/pages/[xorg]/profile.vue.eta +5 -2
- package/templates/nuxt/plugins/20.simpleapp-userstore.ts.eta +11 -15
- package/templates/nuxt/simpleapp/generate/clients/SimpleAppClient.ts.eta +47 -1
- package/templates/nuxt/simpleapp/generate/features/customField/services/CustomFieldService.ts.eta +59 -33
- package/templates/nest/src/simple-app/_core/features/mini-app/developer-portal/dto/developer-portal-create-app.dto.ts.eta +0 -22
- package/templates/nest/src/simple-app/_core/features/mini-app/developer-portal/dto/developer-portal-publish-app.dto.ts.eta +0 -0
- package/templates/nuxt/middleware/30.acl.global.ts.eta +0 -48
|
@@ -12,6 +12,10 @@ export const getUserStore = () => {
|
|
|
12
12
|
const { $userstore } = useNuxtApp();
|
|
13
13
|
return $userstore;
|
|
14
14
|
};
|
|
15
|
+
export const reloadUserStoreFromMiddleware = async (xorg:string) => {
|
|
16
|
+
const { $userstore } = useNuxtApp();
|
|
17
|
+
await $userstore.loadRemoteUserFromXorg(xorg)
|
|
18
|
+
};
|
|
15
19
|
export const reloadUserStore = async () => {
|
|
16
20
|
const { $userstore } = useNuxtApp();
|
|
17
21
|
await $userstore.loadRemoteUserInfo();
|
|
@@ -25,17 +29,15 @@ export const isGuideComplete = (guidename: string): boolean => {
|
|
|
25
29
|
} else return false;
|
|
26
30
|
};
|
|
27
31
|
export const setGuideComplete = async (guidename: string) => {
|
|
28
|
-
const userstore = useNuxtApp().$userstore;
|
|
29
|
-
await getProfileApi().runTourComplete(guidename);
|
|
30
|
-
if (getUserProfile() !== undefined) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
export const getCurrentXorg = () => {
|
|
37
|
-
return useRoute().params.xorg ? String(useRoute().params.xorg) : undefined;
|
|
32
|
+
// const userstore = useNuxtApp().$userstore;
|
|
33
|
+
// await getProfileApi().runTourComplete(guidename);
|
|
34
|
+
// if (getUserProfile() !== undefined) {
|
|
35
|
+
// if (!Array.isArray(getUserProfile()?.moreProps.completedTours))
|
|
36
|
+
// userstore.moreProps.completedTours = [guidename];
|
|
37
|
+
// else userstore.moreProps.completedTours.push(guidename);
|
|
38
|
+
// }
|
|
38
39
|
};
|
|
40
|
+
export const getCurrentXorg = () => getUserStore().xOrg ?? ''
|
|
39
41
|
export const getPageBaseUrl = (resourcename: string) => {
|
|
40
42
|
return `/${getCurrentXorg()}/${resourcename}`;
|
|
41
43
|
};
|
|
@@ -60,19 +62,13 @@ export const getProfileEmail = () => getUserProfile()?.email;
|
|
|
60
62
|
export const getProfileUid = () => getUserProfile()?.uid;
|
|
61
63
|
export const getProfileFullName = () => getUserProfile()?.fullName;
|
|
62
64
|
|
|
63
|
-
export const refreshOrgLogo = async () => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
export const getOrgLogo = () => orgLogo;
|
|
68
|
-
export const setOrgLogo = (str: string) => (orgLogo = str);
|
|
69
|
-
export const getCurrentBranch = () =>
|
|
70
|
-
const branchId = getUserStore().branchId;
|
|
71
|
-
const branchinfo = getUserStore().branches.find(
|
|
72
|
-
(item) => item.branch.branchId == branchId,
|
|
73
|
-
);
|
|
74
|
-
return branchinfo;
|
|
75
|
-
};
|
|
65
|
+
// export const refreshOrgLogo = async () => {
|
|
66
|
+
// const logodata = await useNuxtApp().$OrganizationDoc().getApi().runGetlogo();
|
|
67
|
+
// orgLogo = logodata.data;
|
|
68
|
+
// };
|
|
69
|
+
// export const getOrgLogo = () => orgLogo;
|
|
70
|
+
// export const setOrgLogo = (str: string) => (orgLogo = str);
|
|
71
|
+
export const getCurrentBranch = () => getUserProfile().branchInfo;
|
|
76
72
|
|
|
77
73
|
export const getMySimpleAppUserPicker = () => {
|
|
78
74
|
return {
|
|
@@ -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
|
+
}
|
|
@@ -53,12 +53,9 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
53
53
|
}),
|
|
54
54
|
|
|
55
55
|
actions: {
|
|
56
|
-
async
|
|
57
|
-
// console.log('loadRemoteUserInfo')
|
|
58
|
-
|
|
56
|
+
async loadRemoteUserFromXorg(xorg:string) {
|
|
59
57
|
const { $axios, $miniAppStore, $customFieldStore } = useNuxtApp();
|
|
60
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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();
|
|
@@ -20,6 +20,7 @@ import { WatchHandle } from "vue";
|
|
|
20
20
|
import { CustomFieldService } from "../features/customField/services/CustomFieldService";
|
|
21
21
|
import { CustomFieldDataMode } from "../features/customField/types/common";
|
|
22
22
|
import { CustomFieldDataModeEnum } from "../features/customField/enums/common";
|
|
23
|
+
import { cloneDeep, isEmpty } from "lodash";
|
|
23
24
|
|
|
24
25
|
// import { useToast, } from 'primevue/usetoast';
|
|
25
26
|
// import type { ToastMessageOptions } from 'primevue/toast';
|
|
@@ -68,7 +69,8 @@ export class SimpleAppClient<
|
|
|
68
69
|
getDocType = () => this.doctype;
|
|
69
70
|
getDocName = (capFirst: boolean = false) =>
|
|
70
71
|
capFirst ? upperFirst(this.docname) : this.docname;
|
|
71
|
-
getResourceName = ()=>
|
|
72
|
+
getResourceName = () =>
|
|
73
|
+
upperFirst(this.schema["x-simpleapp-config"]?.resourceName ?? "");
|
|
72
74
|
setNew = () => {};
|
|
73
75
|
isNew = () => this.data.value?.created == "";
|
|
74
76
|
setSchema = (schema: SchemaType) => (this.schema = schema);
|
|
@@ -85,7 +87,51 @@ export class SimpleAppClient<
|
|
|
85
87
|
Object.assign(this.data.value, data);
|
|
86
88
|
};
|
|
87
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Adjust built in standard field validation rules
|
|
92
|
+
*/
|
|
93
|
+
private prepareSchemaPatches() {
|
|
94
|
+
const patches = this._customFieldService.prepareSchemaPatches(this.docname);
|
|
95
|
+
if (patches && !isEmpty(patches)) {
|
|
96
|
+
const schema = this.applySchemaPatch(patches);
|
|
97
|
+
this.schema = schema;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private applySchemaPatch(patches: { [key: string]: string | number }) {
|
|
102
|
+
const allowedPatchAttributes = ["required", "minLength", "maxLength"];
|
|
103
|
+
const schema = cloneDeep(this.schema);
|
|
104
|
+
for (const [path, value] of Object.entries(patches)) {
|
|
105
|
+
const keys = path.split(".");
|
|
106
|
+
let target: any = schema;
|
|
107
|
+
|
|
108
|
+
// Traverse into nested path (e.g. properties.studentGroup.properties._id)
|
|
109
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
110
|
+
const key = keys[i];
|
|
111
|
+
if (!(key in target)) target[key] = {};
|
|
112
|
+
target = target[key];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const attributeName = keys[keys.length - 1];
|
|
116
|
+
if (allowedPatchAttributes.includes(attributeName)) {
|
|
117
|
+
if (attributeName === "required" && Array.isArray(value)) {
|
|
118
|
+
target.required = Array.from(
|
|
119
|
+
new Set([...(target.required ?? []), ...value]),
|
|
120
|
+
);
|
|
121
|
+
} else {
|
|
122
|
+
target[attributeName] = value;
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
console.error("Found invalid schema patch: ", path, value);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return schema;
|
|
130
|
+
}
|
|
131
|
+
|
|
88
132
|
prepareCustomFieldJsonSchema() {
|
|
133
|
+
this.prepareSchemaPatches();
|
|
134
|
+
|
|
89
135
|
const resp = this._customFieldService.prepareCustomFieldJsonSchema(
|
|
90
136
|
this.docname,
|
|
91
137
|
);
|
package/templates/nuxt/simpleapp/generate/features/customField/services/CustomFieldService.ts.eta
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import _ from
|
|
1
|
+
import _ from "lodash";
|
|
2
2
|
import {
|
|
3
3
|
CustomFieldDataMode,
|
|
4
4
|
CustomFieldMoreSchema,
|
|
5
|
-
CustomFieldMoreSchemaGroup
|
|
6
|
-
} from
|
|
7
|
-
import { CustomFieldDataModeEnum } from
|
|
8
|
-
import { DynamicObject, SimpleAppJSONSchema7Definition } from
|
|
5
|
+
CustomFieldMoreSchemaGroup,
|
|
6
|
+
} from "../types/common";
|
|
7
|
+
import { CustomFieldDataModeEnum } from "../enums/common";
|
|
8
|
+
import { DynamicObject, SimpleAppJSONSchema7Definition } from "~/types";
|
|
9
9
|
|
|
10
10
|
export class CustomFieldService {
|
|
11
11
|
// =============================== Prepare Schema Function ===============================
|
|
@@ -18,16 +18,20 @@ export class CustomFieldService {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const schema: CustomFieldMoreSchema = {
|
|
21
|
-
type:
|
|
21
|
+
type: "object",
|
|
22
22
|
properties: {
|
|
23
23
|
...customFieldFromDB,
|
|
24
|
-
...customFieldFromMiniApp
|
|
25
|
-
}
|
|
24
|
+
...customFieldFromMiniApp,
|
|
25
|
+
},
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
return schema;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
prepareSchemaPatches(collectionName: string) {
|
|
32
|
+
return this.findSchemaPatchFromMiniApp(collectionName);
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
private findCustomFieldSchemaFromDB(collectionName: string) {
|
|
32
36
|
const { $customFieldStore } = useNuxtApp();
|
|
33
37
|
if (!$customFieldStore.data || _.isEmpty($customFieldStore.data)) {
|
|
@@ -48,9 +52,9 @@ export class CustomFieldService {
|
|
|
48
52
|
|
|
49
53
|
const schema: CustomFieldMoreSchemaGroup = {
|
|
50
54
|
default: {
|
|
51
|
-
title:
|
|
52
|
-
...customField.form.jsonSchema
|
|
53
|
-
}
|
|
55
|
+
title: "Custom Field",
|
|
56
|
+
...customField.form.jsonSchema,
|
|
57
|
+
},
|
|
54
58
|
};
|
|
55
59
|
|
|
56
60
|
return schema;
|
|
@@ -76,12 +80,32 @@ export class CustomFieldService {
|
|
|
76
80
|
return schema;
|
|
77
81
|
}
|
|
78
82
|
|
|
83
|
+
private findSchemaPatchFromMiniApp(collectionName: string) {
|
|
84
|
+
const { $miniAppStore } = useNuxtApp();
|
|
85
|
+
|
|
86
|
+
const miniAppForms = $miniAppStore.getForm(collectionName);
|
|
87
|
+
if (!miniAppForms || miniAppForms.length <= 0) {
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
for (let i = 0; i < miniAppForms.length; i++) {
|
|
92
|
+
const miniAppItem = miniAppForms[i];
|
|
93
|
+
const { patches } = miniAppItem;
|
|
94
|
+
|
|
95
|
+
if (patches && !_.isEmpty(patches)) {
|
|
96
|
+
return patches;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
|
|
79
103
|
// ================================ Prepare Data Function ================================
|
|
80
104
|
prepareCustomFieldData<T extends DynamicObject>(
|
|
81
105
|
collectionName: string,
|
|
82
106
|
mode: CustomFieldDataMode,
|
|
83
107
|
customSchema: CustomFieldMoreSchema | undefined,
|
|
84
|
-
resourceData: T | undefined
|
|
108
|
+
resourceData: T | undefined,
|
|
85
109
|
): T | undefined {
|
|
86
110
|
if (
|
|
87
111
|
!customSchema ||
|
|
@@ -103,18 +127,18 @@ export class CustomFieldService {
|
|
|
103
127
|
|
|
104
128
|
return this.prepareCustomFieldWithExistingData(
|
|
105
129
|
customSchema,
|
|
106
|
-
resourceData
|
|
130
|
+
resourceData,
|
|
107
131
|
);
|
|
108
132
|
break;
|
|
109
133
|
}
|
|
110
134
|
}
|
|
111
135
|
|
|
112
136
|
private prepareCustomFieldWithDefaultData<T extends DynamicObject>(
|
|
113
|
-
customSchema: CustomFieldMoreSchema
|
|
137
|
+
customSchema: CustomFieldMoreSchema,
|
|
114
138
|
) {
|
|
115
139
|
const data: DynamicObject = {};
|
|
116
140
|
for (const [groupName, groupItem] of Object.entries(
|
|
117
|
-
customSchema.properties
|
|
141
|
+
customSchema.properties,
|
|
118
142
|
)) {
|
|
119
143
|
const defaultData = this.generateDefaultData(groupItem);
|
|
120
144
|
|
|
@@ -126,16 +150,16 @@ export class CustomFieldService {
|
|
|
126
150
|
|
|
127
151
|
private prepareCustomFieldWithExistingData<T extends DynamicObject>(
|
|
128
152
|
customSchema: CustomFieldMoreSchema,
|
|
129
|
-
resourceData: T
|
|
153
|
+
resourceData: T,
|
|
130
154
|
) {
|
|
131
155
|
const data: DynamicObject = {};
|
|
132
156
|
for (const [groupName, groupItem] of Object.entries(
|
|
133
|
-
customSchema.properties
|
|
157
|
+
customSchema.properties,
|
|
134
158
|
)) {
|
|
135
159
|
const defaultData = this.generateDefaultData(groupItem);
|
|
136
160
|
const mergedData = this.mergeWithDefault(
|
|
137
161
|
defaultData,
|
|
138
|
-
resourceData?.[groupName]
|
|
162
|
+
resourceData?.[groupName],
|
|
139
163
|
);
|
|
140
164
|
|
|
141
165
|
data[groupName] = mergedData;
|
|
@@ -146,13 +170,13 @@ export class CustomFieldService {
|
|
|
146
170
|
|
|
147
171
|
private generateDefaultData(schema: SimpleAppJSONSchema7Definition): any {
|
|
148
172
|
if (!_.isObject(schema)) {
|
|
149
|
-
return
|
|
173
|
+
return "";
|
|
150
174
|
}
|
|
151
175
|
|
|
152
|
-
if (schema.type ===
|
|
176
|
+
if (schema.type === "object") {
|
|
153
177
|
const result: any = {};
|
|
154
178
|
|
|
155
|
-
if (schema?.[
|
|
179
|
+
if (schema?.["x-foreignkey"]) {
|
|
156
180
|
return undefined;
|
|
157
181
|
}
|
|
158
182
|
|
|
@@ -163,31 +187,33 @@ export class CustomFieldService {
|
|
|
163
187
|
return result;
|
|
164
188
|
}
|
|
165
189
|
|
|
166
|
-
if (schema.type ===
|
|
190
|
+
if (schema.type === "array") {
|
|
167
191
|
const itemSchema = schema.items;
|
|
168
192
|
const minItems = schema.minItems || 0;
|
|
169
193
|
const arr = [];
|
|
170
194
|
const itemsCount = minItems > 0 ? 1 : 0;
|
|
171
195
|
for (let i = 0; i < itemsCount; i++) {
|
|
172
196
|
arr.push(
|
|
173
|
-
this.generateDefaultData(
|
|
197
|
+
this.generateDefaultData(
|
|
198
|
+
itemSchema as SimpleAppJSONSchema7Definition,
|
|
199
|
+
),
|
|
174
200
|
);
|
|
175
201
|
}
|
|
176
202
|
return arr;
|
|
177
203
|
}
|
|
178
204
|
|
|
179
|
-
if (typeof schema.default !==
|
|
205
|
+
if (typeof schema.default !== "undefined") {
|
|
180
206
|
return schema.default;
|
|
181
207
|
}
|
|
182
208
|
|
|
183
209
|
// handle primitive types fallback
|
|
184
210
|
switch (schema.type) {
|
|
185
|
-
case
|
|
186
|
-
return
|
|
187
|
-
case
|
|
188
|
-
case
|
|
211
|
+
case "string":
|
|
212
|
+
return "";
|
|
213
|
+
case "number":
|
|
214
|
+
case "integer":
|
|
189
215
|
return 0;
|
|
190
|
-
case
|
|
216
|
+
case "boolean":
|
|
191
217
|
return false;
|
|
192
218
|
default:
|
|
193
219
|
return null;
|
|
@@ -196,7 +222,7 @@ export class CustomFieldService {
|
|
|
196
222
|
|
|
197
223
|
private mergeWithDefault<T extends DynamicObject>(
|
|
198
224
|
defaultData: T,
|
|
199
|
-
collectionData: T | undefined
|
|
225
|
+
collectionData: T | undefined,
|
|
200
226
|
) {
|
|
201
227
|
if (Array.isArray(defaultData)) {
|
|
202
228
|
if (Array.isArray(collectionData)) {
|
|
@@ -213,17 +239,17 @@ export class CustomFieldService {
|
|
|
213
239
|
// return defaultData;
|
|
214
240
|
return [];
|
|
215
241
|
}
|
|
216
|
-
} else if (typeof defaultData ===
|
|
242
|
+
} else if (typeof defaultData === "object" && defaultData !== null) {
|
|
217
243
|
const result: any = {};
|
|
218
244
|
for (const key of Object.keys(defaultData)) {
|
|
219
245
|
result[key] = this.mergeWithDefault(
|
|
220
246
|
defaultData[key],
|
|
221
|
-
collectionData?.[key]
|
|
247
|
+
collectionData?.[key],
|
|
222
248
|
);
|
|
223
249
|
}
|
|
224
250
|
return result;
|
|
225
251
|
} else {
|
|
226
|
-
return typeof collectionData !==
|
|
252
|
+
return typeof collectionData !== "undefined"
|
|
227
253
|
? collectionData
|
|
228
254
|
: defaultData;
|
|
229
255
|
}
|
|
@@ -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
|
-
}
|
|
File without changes
|
|
@@ -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
|
-
})
|