@simitgroup/simpleapp-generator 2.0.0-y-alpha → 2.0.1-b-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 +16 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -2
- 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/getMenus.generate.ts.eta +86 -0
- 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 +54 -64
- package/templates/nuxt/simpleapp/generate/features/miniApp/app/components/MiniAppPageIframe.vue.eta +1 -0
- 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
package/ReleaseNote.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
[2.0.1b-alpha]
|
|
2
|
+
|
|
3
|
+
1. Update menu permission
|
|
4
|
+
|
|
5
|
+
[2.0.1a-alpha]
|
|
6
|
+
|
|
7
|
+
1. Add allow clipboard-write for mini app iframe
|
|
8
|
+
|
|
9
|
+
[2.0.0z-alpha]
|
|
10
|
+
|
|
11
|
+
1. add more roles like support, billings
|
|
12
|
+
2. environment allow add more type of users
|
|
13
|
+
3. user context can obtain environment collection value
|
|
14
|
+
4. make frontend midleware changable, and support new license, permission strategy
|
|
15
|
+
5. improve frontend userstore get xorg method
|
|
16
|
+
|
|
1
17
|
[2.0.0y-alpha]
|
|
2
18
|
|
|
3
19
|
1. Allow mini app adjust built in schema
|
package/dist/index.js
CHANGED
|
@@ -123,8 +123,9 @@ if (continueexecute) {
|
|
|
123
123
|
};
|
|
124
124
|
const reGenBackend = async () => {
|
|
125
125
|
fw.setConfiguration(configs);
|
|
126
|
-
generate.run(configs, ['nest'], () => {
|
|
127
|
-
|
|
126
|
+
await generate.run(configs, ['nest'], () => {
|
|
127
|
+
// console.log("reGenBackendreGenBackendreGenBackendreGenBackend")
|
|
128
|
+
// fw.prettyNest();
|
|
128
129
|
});
|
|
129
130
|
};
|
|
130
131
|
const runbackend = async () => {
|
|
@@ -156,6 +157,7 @@ if (continueexecute) {
|
|
|
156
157
|
break;
|
|
157
158
|
case 'updatebackend':
|
|
158
159
|
reGenBackend();
|
|
160
|
+
console.log("reGenBackend done");
|
|
159
161
|
break;
|
|
160
162
|
case 'frontend':
|
|
161
163
|
runfrontend();
|
package/dist/index.js.map
CHANGED
|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AAK,CAAC,uBAAuB,CAAC,CAAC;YACnC,MAAM;KACT;CACF"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -115,8 +115,9 @@ if (continueexecute) {
|
|
|
115
115
|
};
|
|
116
116
|
const reGenBackend = async () => {
|
|
117
117
|
fw.setConfiguration(configs);
|
|
118
|
-
generate.run(configs, ['nest'], () => {
|
|
119
|
-
|
|
118
|
+
await generate.run(configs, ['nest'], () => {
|
|
119
|
+
// console.log("reGenBackendreGenBackendreGenBackendreGenBackend")
|
|
120
|
+
// fw.prettyNest();
|
|
120
121
|
});
|
|
121
122
|
};
|
|
122
123
|
|
|
@@ -151,6 +152,7 @@ if (continueexecute) {
|
|
|
151
152
|
break;
|
|
152
153
|
case 'updatebackend':
|
|
153
154
|
reGenBackend();
|
|
155
|
+
console.log("reGenBackend done")
|
|
154
156
|
break;
|
|
155
157
|
case 'frontend':
|
|
156
158
|
runfrontend();
|
|
@@ -8,8 +8,11 @@ export enum Role {
|
|
|
8
8
|
Unknown = 'unknown', // unuse yet
|
|
9
9
|
Everyone = 'everyone', //everyone
|
|
10
10
|
SuperAdmin = 'superadmin', //reserved for developers, no control,
|
|
11
|
-
SuperUser = '
|
|
11
|
+
SuperUser = 'superpuser', //reserved, plan use by support
|
|
12
12
|
TenantOwner = 'tenantowner', //tenant owner/creator
|
|
13
|
+
Billing = 'billing',
|
|
14
|
+
DevSupport = 'devsupport',
|
|
15
|
+
DevBilling = 'devbilling',
|
|
13
16
|
User = 'user',
|
|
14
17
|
//role generated from groups
|
|
15
18
|
<% Object.getOwnPropertyNames(it.allroles).forEach((key)=>{%>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { UserContext } from
|
|
2
|
-
import { SimpleAppRobotUserService } from
|
|
3
|
-
import {BaseUserContext} from '../../user-context/user-context.type'
|
|
1
|
+
import { UserContext } from '../../user-context/user.context';
|
|
2
|
+
import { SimpleAppRobotUserService } from '../../user-context/robot-user.service';
|
|
3
|
+
import { BaseUserContext } from '../../user-context/user-context.type';
|
|
4
4
|
export abstract class SimpleAppCronBaseClass {
|
|
5
|
-
|
|
5
|
+
private robotUser: SimpleAppRobotUserService;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
7
|
+
constructor(robotUser: SimpleAppRobotUserService) {
|
|
8
|
+
this.robotUser = robotUser;
|
|
9
|
+
}
|
|
10
|
+
async getAppUser(user: BaseUserContext) {
|
|
11
|
+
return await this.robotUser.createDumyAppUser(user);
|
|
12
|
+
}
|
|
13
|
+
}
|
package/templates/nest/src/simple-app/_core/features/maintenance/maintenance.controller.ts.eta
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* last change 2025-09-01
|
|
5
5
|
* Author: Ks Tan
|
|
6
6
|
*/
|
|
7
|
-
import { Controller, Get, Post, Param, Logger, HttpCode } from '@nestjs/common';
|
|
7
|
+
import { Controller, Get, Post,Put, Param, Logger, HttpCode,Body } from '@nestjs/common';
|
|
8
8
|
import { MaintenanceService } from './maintenance.service';
|
|
9
9
|
import { ApiTags, ApiBody, ApiResponse, ApiOperation, ApiQuery } from '@nestjs/swagger';
|
|
10
10
|
import { Roles } from 'src/simple-app/_core/features/auth/role-guard/roles.decorator';
|
|
11
11
|
import { Role } from 'src/simple-app/_core/features/auth/role-guard/roles.enum';
|
|
12
|
-
import
|
|
12
|
+
import {Environment,UpgradeScript} from './schemas';
|
|
13
13
|
import { UserContext } from 'src/simple-app/_core/features/user-context/user.context';
|
|
14
14
|
import { AppUser } from 'src/simple-app/_core/features/user-context/appuser.decorator';
|
|
15
15
|
@ApiTags('maintenance')
|
|
@@ -21,12 +21,13 @@ export class MaintenanceController {
|
|
|
21
21
|
|
|
22
22
|
@Get('/get-updates')
|
|
23
23
|
@Roles(Role.SuperAdmin)
|
|
24
|
+
@ApiOperation({ operationId: 'getUpdates', description: 'get all available update scripts' })
|
|
24
25
|
@ApiResponse({
|
|
25
26
|
status: 200,
|
|
26
27
|
description: 'Sample 200 response',
|
|
27
|
-
type: [
|
|
28
|
+
type: [UpgradeScript],
|
|
28
29
|
})
|
|
29
|
-
async
|
|
30
|
+
async getUpdates(@AppUser() appuser: UserContext) {
|
|
30
31
|
const result = await this.maintenanceService.getUpdates(appuser);
|
|
31
32
|
return result;
|
|
32
33
|
}
|
|
@@ -34,6 +35,7 @@ export class MaintenanceController {
|
|
|
34
35
|
@Post('/run-updates/:id')
|
|
35
36
|
@HttpCode(200)
|
|
36
37
|
@Roles(Role.SuperAdmin)
|
|
38
|
+
@ApiOperation({ operationId: 'runUpdate', description: 'run specific update script' })
|
|
37
39
|
@ApiResponse({
|
|
38
40
|
status: 200,
|
|
39
41
|
description: 'Sample 200 response',
|
|
@@ -46,17 +48,33 @@ export class MaintenanceController {
|
|
|
46
48
|
|
|
47
49
|
@Get('/service-status')
|
|
48
50
|
@Roles(Role.SuperAdmin)
|
|
51
|
+
@ApiOperation({ operationId: 'runGetEnvironment', description: 'get system status' })
|
|
49
52
|
@ApiResponse({
|
|
50
53
|
status: 200,
|
|
51
54
|
description: 'Sample 200 response',
|
|
52
|
-
type:
|
|
55
|
+
type: Environment,
|
|
53
56
|
})
|
|
54
|
-
async
|
|
55
|
-
const result:
|
|
57
|
+
async runGetEnvironment(@AppUser() appuser: UserContext) {
|
|
58
|
+
const result: Environment = await this.maintenanceService.runGetEnvironment(appuser);
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Put('/service-status')
|
|
63
|
+
@Roles(Role.SuperAdmin)
|
|
64
|
+
@ApiOperation({ operationId: 'runUpdateEnvironment', description: 'Update system status' })
|
|
65
|
+
@ApiBody({ description: 'Data', type: Environment })
|
|
66
|
+
@ApiResponse({
|
|
67
|
+
status: 200,
|
|
68
|
+
description: 'Sample 200 response',
|
|
69
|
+
type: Environment,
|
|
70
|
+
})
|
|
71
|
+
async runUpdateEnvironment(@AppUser() appuser: UserContext,@Body() data: Environment) {
|
|
72
|
+
const result = await this.maintenanceService.runUpdateEnvironment(appuser, data);
|
|
56
73
|
return result;
|
|
57
74
|
}
|
|
58
75
|
|
|
59
76
|
@Post('/stop-service')
|
|
77
|
+
@ApiOperation({ operationId: 'runStopService', description: 'suspend backend, only superadmin can access' })
|
|
60
78
|
@HttpCode(200)
|
|
61
79
|
@Roles(Role.SuperAdmin)
|
|
62
80
|
@ApiResponse({
|
|
@@ -70,6 +88,7 @@ export class MaintenanceController {
|
|
|
70
88
|
}
|
|
71
89
|
|
|
72
90
|
@Post('/start-service')
|
|
91
|
+
@ApiOperation({ operationId: 'runStartService', description: 'start backend, system back to usual' })
|
|
73
92
|
@HttpCode(200)
|
|
74
93
|
@Roles(Role.SuperAdmin)
|
|
75
94
|
@ApiResponse({
|
|
@@ -10,11 +10,11 @@ import { InjectConnection, InjectModel } from '@nestjs/mongoose';
|
|
|
10
10
|
import { Connection, Model } from 'mongoose';
|
|
11
11
|
import { UserContext } from 'src/simple-app/_core/features/user-context/user.context';
|
|
12
12
|
import * as dbupdate from 'src/simple-app/config/db-update';
|
|
13
|
-
import
|
|
13
|
+
import { Environment, UpgradeScript } from './schemas';
|
|
14
14
|
@Injectable()
|
|
15
15
|
export class MaintenanceService {
|
|
16
16
|
constructor(
|
|
17
|
-
@InjectModel('Environment') private sysEnvdoc: Model<
|
|
17
|
+
@InjectModel('Environment') private sysEnvdoc: Model<Environment>,
|
|
18
18
|
@InjectConnection() private readonly connection: Connection,
|
|
19
19
|
) {
|
|
20
20
|
this.initEnv();
|
|
@@ -32,7 +32,7 @@ export class MaintenanceService {
|
|
|
32
32
|
|
|
33
33
|
async getUpdates(appuser: UserContext) {
|
|
34
34
|
const keys = Object.keys(dbupdate);
|
|
35
|
-
const updatescripts:
|
|
35
|
+
const updatescripts: UpgradeScript[] = [];
|
|
36
36
|
const key = keys[0];
|
|
37
37
|
// console.log(dbupdate[key]())
|
|
38
38
|
|
|
@@ -62,15 +62,28 @@ export class MaintenanceService {
|
|
|
62
62
|
throw new InternalServerErrorException(`Error db update (${versionId}): ${e.message}`);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
async
|
|
66
|
-
const res = await this.sysEnvdoc.
|
|
67
|
-
|
|
68
|
-
return res[0].systemEnable;
|
|
69
|
-
} else {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
65
|
+
async runGetEnvironment(appUser: UserContext) {
|
|
66
|
+
const res = await this.sysEnvdoc.findOne();
|
|
67
|
+
return res;
|
|
72
68
|
}
|
|
73
|
-
async
|
|
69
|
+
async runUpdateEnvironment(appUser: UserContext, data: Environment) {
|
|
70
|
+
const finalData: Environment = {
|
|
71
|
+
systemEnable: data.systemEnable === undefined ? data.systemEnable : true,
|
|
72
|
+
stopUntil: data.stopUntil ?? '',
|
|
73
|
+
maintenanceMessage: data.maintenanceMessage ?? '',
|
|
74
|
+
adminEmails: data.adminEmails.map((item) => item.replace(' ', '')) ?? [],
|
|
75
|
+
billingEmails: data.billingEmails.map((item) => item.replace(' ', '')) ?? [],
|
|
76
|
+
supportEmails: data.supportEmails.map((item) => item.replace(' ', '')) ?? [],
|
|
77
|
+
taxRate: data.taxRate ?? 0.00,
|
|
78
|
+
taxName: data.taxName?? '',
|
|
79
|
+
updated: new Date().toISOString(),
|
|
80
|
+
updatedBy: appUser.getUid(),
|
|
81
|
+
};
|
|
82
|
+
const res = await this.sysEnvdoc.updateOne({}, finalData);
|
|
83
|
+
return res;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async runStopService(appUser: UserContext) {
|
|
74
87
|
const res = await this.sysEnvdoc.find();
|
|
75
88
|
if (res.length > 0) {
|
|
76
89
|
res[0].systemEnable = false;
|
|
@@ -78,7 +91,7 @@ export class MaintenanceService {
|
|
|
78
91
|
}
|
|
79
92
|
return Promise.resolve(`status: ${res[0].systemEnable}`);
|
|
80
93
|
}
|
|
81
|
-
async runStartService(
|
|
94
|
+
async runStartService(appUser: UserContext) {
|
|
82
95
|
const res = await this.sysEnvdoc.find();
|
|
83
96
|
if (res.length > 0) {
|
|
84
97
|
res[0].systemEnable = true;
|
|
@@ -1,23 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
* This file was automatically generated by simpleapp generator. Every
|
|
3
|
-
* MODIFICATION OVERRIDE BY GENERATEOR
|
|
4
|
-
* last change 2025-08-27
|
|
5
|
-
* Author: Ks Tan
|
|
6
|
-
*/
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
7
2
|
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
8
|
-
|
|
3
|
+
@Schema()
|
|
9
4
|
export class Environment {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
@Prop()
|
|
6
|
+
@ApiProperty({ type: Boolean })
|
|
7
|
+
systemEnable: boolean;
|
|
8
|
+
@Prop()
|
|
9
|
+
@ApiProperty({ type: Number })
|
|
10
|
+
taxRate:number;
|
|
11
|
+
@Prop()
|
|
12
|
+
@ApiProperty({ type: String })
|
|
13
|
+
taxName:string;
|
|
14
|
+
@Prop()
|
|
15
|
+
@ApiProperty({ type: String })
|
|
16
|
+
stopUntil: string;
|
|
17
|
+
@Prop()
|
|
18
|
+
@ApiProperty({ type: String })
|
|
19
|
+
maintenanceMessage: string;
|
|
20
|
+
@Prop()
|
|
21
|
+
@ApiProperty({ type: [String] })
|
|
22
|
+
adminEmails: string[];
|
|
23
|
+
@Prop()
|
|
24
|
+
@ApiProperty({ type: [String] })
|
|
25
|
+
billingEmails: string[];
|
|
26
|
+
@Prop()
|
|
27
|
+
@ApiProperty({ type: [String] })
|
|
28
|
+
supportEmails: string[];
|
|
29
|
+
@Prop()
|
|
30
|
+
@ApiProperty({ type: String })
|
|
31
|
+
updated: string;
|
|
32
|
+
@ApiProperty({ type: String })
|
|
33
|
+
@Prop()
|
|
34
|
+
updatedBy: string;
|
|
35
|
+
}
|
|
17
36
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return next();
|
|
23
|
-
})
|
|
37
|
+
export const EnvironmentMongoSchema = SchemaFactory.createForClass(Environment).pre('save', function (next) {
|
|
38
|
+
this.increment();
|
|
39
|
+
return next();
|
|
40
|
+
});
|
|
@@ -5,7 +5,7 @@ import { PolicyService } from 'src/simple-app/_core/features/policy/policy.servi
|
|
|
5
5
|
import { Role } from 'src/simple-app/_core/features/auth/role-guard/roles.enum';
|
|
6
6
|
import { UserContext } from 'src/simple-app/_core/features/user-context/user.context';
|
|
7
7
|
import { MiniApp } from '../dto';
|
|
8
|
-
import
|
|
8
|
+
import licenseTypes,{BaseLicense} from 'src/simple-app/config/license-types';
|
|
9
9
|
@Injectable()
|
|
10
10
|
export class MiniAppManagerPolicyService {
|
|
11
11
|
readonly _RELEASED_STATUSES = [MiniAppStatusEnum.PUBLISHED];
|
|
@@ -33,8 +33,8 @@ export class MiniAppManagerPolicyService {
|
|
|
33
33
|
// const requiredPlans = miniApp.access.requiredPlans ?? [];
|
|
34
34
|
|
|
35
35
|
if (licenseTypes[currentLicense]) {
|
|
36
|
-
const licenseSetting = licenseTypes[currentLicense]
|
|
37
|
-
return licenseSetting?.
|
|
36
|
+
const licenseSetting:BaseLicense = licenseTypes[currentLicense]
|
|
37
|
+
return licenseSetting?.feature?.miniApp ?? false;
|
|
38
38
|
} else {
|
|
39
39
|
return false;
|
|
40
40
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { Role } from 'src/simple-app/_core/features/auth/role-guard/roles.enum';
|
|
3
3
|
import { UserContext } from 'src/simple-app/_core/features/user-context/user.context';
|
|
4
|
-
import
|
|
4
|
+
import licenseTypes,{BaseLicense} from 'src/simple-app/config/license-types';
|
|
5
|
+
import { HasType } from 'src/simple-app/config/license-types/license.type';
|
|
5
6
|
@Injectable()
|
|
6
7
|
export class PolicyService {
|
|
7
8
|
private readonly _HIGH_PRIVILEGE_ROLES = [Role.SuperAdmin, Role.SuperUser, Role.TenantOwner];
|
|
8
9
|
|
|
9
|
-
private readonly _FEATURES = {
|
|
10
|
-
miniApp: ['lite', 'pro', 'enterprise'],
|
|
11
|
-
};
|
|
12
|
-
|
|
13
10
|
hasHighPrivilege(roles: Role[]): boolean {
|
|
14
11
|
return this._HIGH_PRIVILEGE_ROLES.some((role) => roles.includes(role));
|
|
15
12
|
}
|
|
@@ -27,11 +24,11 @@ export class PolicyService {
|
|
|
27
24
|
* - plans/pro.ts
|
|
28
25
|
* - plans/enterprise.ts
|
|
29
26
|
*/
|
|
30
|
-
hasFeature(appUser: UserContext, feature:
|
|
27
|
+
hasFeature(appUser: UserContext, feature: string): boolean {
|
|
31
28
|
const appLicense = appUser.tenantInfo?.license ?? 'free';
|
|
32
29
|
// const allowedPlans = this._FEATURES[feature];
|
|
33
|
-
const licenseSetting = licenseTypes[appLicense]
|
|
34
|
-
const allowed = licenseSetting.
|
|
30
|
+
const licenseSetting:BaseLicense = licenseTypes[appLicense]
|
|
31
|
+
const allowed = licenseSetting.has(HasType.feature,feature) ?? false;
|
|
35
32
|
return allowed;
|
|
36
33
|
}
|
|
37
34
|
|
package/templates/nest/src/simple-app/_core/features/queue/queue-base/queue-base.consumer.ts.eta
CHANGED
|
@@ -24,8 +24,8 @@ export abstract class BaseQueueConsumer extends WorkerHost {
|
|
|
24
24
|
super();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
createUserContext(user) {
|
|
28
|
-
return this.queueUserContext.create(user);
|
|
27
|
+
async createUserContext(user) {
|
|
28
|
+
return await this.queueUserContext.create(user);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
async startSession(appUser: UserContext) {
|
|
@@ -37,7 +37,7 @@ export abstract class BaseQueueConsumer extends WorkerHost {
|
|
|
37
37
|
// console.log("process job", job.data)
|
|
38
38
|
const { userContext, payload } = job.data;
|
|
39
39
|
|
|
40
|
-
const appUser = this.createUserContext(userContext.user);
|
|
40
|
+
const appUser = await this.createUserContext(userContext.user);
|
|
41
41
|
await this.startSession(appUser);
|
|
42
42
|
|
|
43
43
|
try {
|
|
@@ -45,14 +45,14 @@ export abstract class BaseQueueConsumer extends WorkerHost {
|
|
|
45
45
|
// this.queueUserContext.assign(userContext);
|
|
46
46
|
|
|
47
47
|
await this.dispatch(appUser, job, payload);
|
|
48
|
-
if(appUser.getDBSession().inTransaction()) {
|
|
48
|
+
if (appUser.getDBSession().inTransaction()) {
|
|
49
49
|
await appUser.getDBSession().commitTransaction();
|
|
50
50
|
}
|
|
51
51
|
return {
|
|
52
52
|
success: true,
|
|
53
53
|
};
|
|
54
54
|
} catch (e) {
|
|
55
|
-
if(appUser.getDBSession().inTransaction()) {
|
|
55
|
+
if (appUser.getDBSession().inTransaction()) {
|
|
56
56
|
await appUser.getDBSession().abortTransaction();
|
|
57
57
|
}
|
|
58
58
|
throw e;
|
|
@@ -15,11 +15,11 @@ export class QueueUserContext {
|
|
|
15
15
|
@InjectModel('User') private userModel: Model<User>,
|
|
16
16
|
@InjectModel('Permission') private permModel: Model<Permission>,
|
|
17
17
|
@InjectModel('MiniAppInstallation') private miniAppInstallationModel: Model<MiniAppInstallation>,
|
|
18
|
-
private robotUserService: SimpleAppRobotUserService
|
|
19
|
-
) {
|
|
18
|
+
private robotUserService: SimpleAppRobotUserService,
|
|
19
|
+
) {}
|
|
20
20
|
|
|
21
|
-
create(user) {
|
|
22
|
-
return this.robotUserService.createDumyAppUser(user)
|
|
21
|
+
async create(user) {
|
|
22
|
+
return await this.robotUserService.createDumyAppUser(user);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// assign(userContext: QueuePayload.UserContext) {
|
|
@@ -6,6 +6,7 @@ import { Permission } from '../../resources/permission/permission.schema';
|
|
|
6
6
|
import { User } from '../../resources/user/user.schema';
|
|
7
7
|
import { BaseUserContext } from './user-context.type';
|
|
8
8
|
import { UserContext } from './user.context';
|
|
9
|
+
import { Environment } from '@core-features/maintenance/schemas';
|
|
9
10
|
const Base64URL = require('@darkwolf/base64url');
|
|
10
11
|
@Injectable()
|
|
11
12
|
export class SimpleAppRobotUserService {
|
|
@@ -18,12 +19,14 @@ export class SimpleAppRobotUserService {
|
|
|
18
19
|
private getToken = () => this.systemAccessToken;
|
|
19
20
|
private expired: string;
|
|
20
21
|
logger = new Logger();
|
|
21
|
-
@InjectModel('User') private readonly userModel: Model<User>;
|
|
22
|
-
@InjectModel('Permission') private readonly permModel: Model<Permission>;
|
|
23
|
-
// @InjectModel('Appintegration') private readonly appmodel: Model<Appintegration>;
|
|
24
|
-
@InjectModel('MiniAppInstallation') private readonly miniAppInstallationModel: Model<MiniAppInstallation>;
|
|
25
22
|
|
|
26
|
-
constructor(
|
|
23
|
+
constructor(
|
|
24
|
+
@InjectModel('User') private readonly userModel: Model<User>,
|
|
25
|
+
@InjectModel('Permission') private readonly permModel: Model<Permission>,
|
|
26
|
+
// @InjectModel('Appintegration') private readonly appmodel: Model<Appintegration>;
|
|
27
|
+
@InjectModel('MiniAppInstallation') private readonly miniAppInstallationModel: Model<MiniAppInstallation>,
|
|
28
|
+
@InjectModel('Environment') private envModel: Model<Environment>,
|
|
29
|
+
) {
|
|
27
30
|
this.init();
|
|
28
31
|
// console.log('init SimpleAppRobotUserService');
|
|
29
32
|
}
|
|
@@ -89,11 +92,13 @@ export class SimpleAppRobotUserService {
|
|
|
89
92
|
// }
|
|
90
93
|
}
|
|
91
94
|
|
|
92
|
-
createDumyAppUser(userContext: BaseUserContext) {
|
|
93
|
-
const
|
|
94
|
-
const user = userContext
|
|
95
|
-
const xorg = appUser.generateXOrg(user.tenantId, user.orgId, user.branchId);
|
|
95
|
+
async createDumyAppUser(userContext: BaseUserContext) {
|
|
96
|
+
const envs = await this.envModel.find();
|
|
96
97
|
|
|
98
|
+
const appUser = new UserContext(this.userModel, this.permModel, this.miniAppInstallationModel,envs[0]);
|
|
99
|
+
const user = userContext;
|
|
100
|
+
const xorg = appUser.generateXOrg(user.tenantId, user.orgId, user.branchId);
|
|
101
|
+
|
|
97
102
|
appUser.setAsStaticUser(user.uid ?? '00000000-0000-0000-0000-000000000000', user.uname ?? 'robot', user.fullName ?? 'Robot', user.email ?? 'robot@a.org', xorg);
|
|
98
103
|
appUser.setTimeZone(user.timeZone ?? this.defaultTimeZone);
|
|
99
104
|
appUser.setCountry(user.country ?? this.defaultCountry);
|
|
@@ -101,10 +106,11 @@ export class SimpleAppRobotUserService {
|
|
|
101
106
|
appUser.setOffsetMinute(user.offsetMinute ?? this.defaultOffsetMinute);
|
|
102
107
|
return appUser;
|
|
103
108
|
}
|
|
104
|
-
prepareAppUser(data: any) {
|
|
109
|
+
async prepareAppUser(data: any) {
|
|
110
|
+
const envs = await this.envModel.find();
|
|
105
111
|
// console.log('prepareAppUserprepareAppUser');
|
|
106
112
|
// this.appmodel,
|
|
107
|
-
const appuser = new UserContext(this.userModel, this.permModel, this.miniAppInstallationModel);
|
|
113
|
+
const appuser = new UserContext(this.userModel, this.permModel, this.miniAppInstallationModel,envs[0]);
|
|
108
114
|
appuser.setAsStaticUser('00000000-0000-0000-0000-000000000000', 'robot', 'Robot', 'robot@a.org', Base64URL.encodeText('0-0-0'));
|
|
109
115
|
|
|
110
116
|
const tenantId = data?.tenantId ?? 0;
|
package/templates/nest/src/simple-app/_core/features/user-context/user-context.module.ts.eta
CHANGED
|
@@ -15,8 +15,9 @@ import {TenantModule} from '../../resources/tenant/tenant.module'
|
|
|
15
15
|
import {BranchModule} from '../../resources/branch/branch.module'
|
|
16
16
|
import {OrganizationModule} from '../../resources/organization/organization.module'
|
|
17
17
|
import { MiniAppInstallationModule } from '../../resources/mini-app-installation/mini-app-installation.module';
|
|
18
|
+
import { MaintenanceModule } from '@core-features/maintenance/maintenance.module';
|
|
18
19
|
@Module({
|
|
19
|
-
imports: [UserModule,PermissionModule,MiniAppInstallationModule],
|
|
20
|
+
imports: [UserModule,PermissionModule,MiniAppInstallationModule,MaintenanceModule],
|
|
20
21
|
controllers: [],
|
|
21
22
|
providers: [SimpleAppRobotUserService],
|
|
22
23
|
exports: [SimpleAppRobotUserService],
|
|
@@ -27,6 +27,7 @@ import { Webhook } from 'src/simple-app/_core/features/webhook/schemas';
|
|
|
27
27
|
import { UserContextInfo, ProfileUserBranch, ProfileUserInvites, TenantPermission } from 'src/simple-app/_core/features/profile/profile.schema';
|
|
28
28
|
import { ModifiedRecords } from '../../framework/schemas';
|
|
29
29
|
import { Role } from '../auth/role-guard/roles.enum';
|
|
30
|
+
import { Environment } from '@core-features/maintenance/schemas';
|
|
30
31
|
import * as rolegroups from '../auth/role-guard/roles.group';
|
|
31
32
|
|
|
32
33
|
// import systemWebHooks from '../../webhooks';
|
|
@@ -136,10 +137,11 @@ export class UserContext extends UserContextInfo {
|
|
|
136
137
|
private readonly permModel: Model<Permission>,
|
|
137
138
|
// private readonly appModel: Model<Appintegration>,
|
|
138
139
|
private readonly miniAppInstallationModel: Model<MiniAppInstallation>,
|
|
140
|
+
private systemEnvironment: Environment,
|
|
139
141
|
) {
|
|
140
142
|
super();
|
|
141
143
|
}
|
|
142
|
-
|
|
144
|
+
getEnvironment = ()=> this.systemEnvironment
|
|
143
145
|
setDBSession = (dbsession: ClientSession) => {
|
|
144
146
|
this.dbsession = dbsession;
|
|
145
147
|
};
|
|
@@ -482,6 +484,7 @@ export class UserContext extends UserContextInfo {
|
|
|
482
484
|
|
|
483
485
|
setUserToken = async (tokenStr: string) => {
|
|
484
486
|
this.logger.debug(`===setUserToken===`);
|
|
487
|
+
const systemEnv = this.systemEnvironment;
|
|
485
488
|
// Define token info
|
|
486
489
|
const tokeninfo: jwt.JwtPayload = jwt.decode(tokenStr) as jwt.JwtPayload;
|
|
487
490
|
this.token = tokenStr;
|
|
@@ -493,9 +496,9 @@ export class UserContext extends UserContextInfo {
|
|
|
493
496
|
this.logger.debug(`User found ${this.uid}`);
|
|
494
497
|
|
|
495
498
|
const userProfile = await this.obtainProfileFromDB();
|
|
499
|
+
|
|
496
500
|
if (userProfile) {
|
|
497
501
|
this.logger.debug(`User ${this.uid} exists in tenant (${this.tenantId})`);
|
|
498
|
-
|
|
499
502
|
this._id = userProfile._id;
|
|
500
503
|
this.branchCode = userProfile['branchCode'] ?? '';
|
|
501
504
|
this.branchName = userProfile['branchName'] ?? '';
|
|
@@ -511,6 +514,7 @@ export class UserContext extends UserContextInfo {
|
|
|
511
514
|
this.orgRecordId = userProfile['orgRecordId'] ?? '';
|
|
512
515
|
this.branchRecordId = userProfile['branchRecordId'] ?? '';
|
|
513
516
|
this.invites = userProfile.invites;
|
|
517
|
+
|
|
514
518
|
userProfile['branches'].forEach((b) => {
|
|
515
519
|
b.xOrg = this.generateXOrg(b.tenantId, b.orgId, b.branchId);
|
|
516
520
|
});
|
|
@@ -522,9 +526,29 @@ export class UserContext extends UserContextInfo {
|
|
|
522
526
|
webhook: false,
|
|
523
527
|
support: false,
|
|
524
528
|
};
|
|
525
|
-
this.roles = userProfile['roles'] ?? [Role.Everyone, Role.User];
|
|
529
|
+
this.roles = userProfile['roles'] ?? [Role.Everyone, Role.User,Role.CustomField_search,Role.QueueJob_search];
|
|
530
|
+
|
|
531
|
+
if (this.tenantInfo?.owner?.uid === this.uid) {
|
|
532
|
+
this.roles.push(Role.TenantOwner);
|
|
533
|
+
}
|
|
534
|
+
if (this.tenantInfo?.company && this.tenantInfo.company.billUserEmail === this.email) {
|
|
535
|
+
this.roles.push(Role.Billing);
|
|
536
|
+
}
|
|
537
|
+
if (systemEnv) {
|
|
538
|
+
// console.log("systemEnv",systemEnv)
|
|
539
|
+
const emailFields = {
|
|
540
|
+
adminEmails: 'SuperAdmin',
|
|
541
|
+
billingEmails: 'DevBilling',
|
|
542
|
+
supportEmails: 'DevSupport',
|
|
543
|
+
};
|
|
544
|
+
for (const f of Object.keys(emailFields)) {
|
|
545
|
+
if (Array.isArray(systemEnv[f]) && systemEnv[f].includes(this.email) && !this.roles.includes(Role[emailFields[f]])) {
|
|
546
|
+
this.roles.push(Role[emailFields[f]]);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
526
550
|
|
|
527
|
-
// console.log(
|
|
551
|
+
// console.log('this.roles', this.roles);
|
|
528
552
|
for (const group of this.groups) {
|
|
529
553
|
const roles: Role[] = rolegroups[group]();
|
|
530
554
|
//(<() => Role[]>rolegroups[group])();
|
|
@@ -1150,7 +1174,6 @@ export class UserContext extends UserContextInfo {
|
|
|
1150
1174
|
return data;
|
|
1151
1175
|
}
|
|
1152
1176
|
|
|
1153
|
-
|
|
1154
1177
|
offsetDate(date: string): string {
|
|
1155
1178
|
const timestamp = new Date(date).getTime();
|
|
1156
1179
|
const offsets = this.getOffsetMinute() * 60000;
|