@simitgroup/simpleapp-generator 2.0.0-g-alpha → 2.0.0-h-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 +3 -0
- package/package.json +1 -1
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager-policy.service.ts.eta +7 -8
- package/templates/nest/src/simple-app/.core/features/mini-app/mini-app-manager/mini-app-manager.service.ts.eta +3 -6
- package/templates/nest/src/simple-app/.core/features/policy/policy.service.ts.eta +7 -7
- package/templates/nest/src/simple-app/config/license-types/index.ts._eta +1 -0
package/ReleaseNote.md
CHANGED
package/package.json
CHANGED
|
@@ -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 * as
|
|
8
|
+
import * as licenseTypes from 'src/simple-app/config/license-types';
|
|
9
9
|
@Injectable()
|
|
10
10
|
export class MiniAppManagerPolicyService {
|
|
11
11
|
readonly _RELEASED_STATUSES = [MiniAppStatusEnum.PUBLISHED];
|
|
@@ -29,15 +29,14 @@ export class MiniAppManagerPolicyService {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
hasRequiredPlan(appUser: UserContext, miniApp: MiniApp) {
|
|
32
|
-
const
|
|
32
|
+
const currentLicense = appUser.tenantInfo?.license ?? 'free';
|
|
33
33
|
// const requiredPlans = miniApp.access.requiredPlans ?? [];
|
|
34
|
-
|
|
35
|
-
if(plans[currentPlan]){
|
|
36
|
-
const plansetting = plans[currentPlan]()
|
|
37
|
-
return plansetting?.features?.advance?.features?.miniApp ?? false
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
if (licenseTypes[currentLicense]) {
|
|
36
|
+
const licenseSetting = licenseTypes[currentLicense]();
|
|
37
|
+
return licenseSetting?.features?.advance?.features?.miniApp ?? false;
|
|
38
|
+
} else {
|
|
39
|
+
return false;
|
|
41
40
|
}
|
|
42
41
|
// if (_.isEmpty(requiredPlans)) return true;
|
|
43
42
|
|
|
@@ -9,7 +9,7 @@ import { MiniAppInstallationService } from 'src/simple-app/.core/resources/mini-
|
|
|
9
9
|
import _ from 'lodash';
|
|
10
10
|
import { MiniAppManagerPolicyService } from './mini-app-manager-policy.service';
|
|
11
11
|
import { MiniAppError } from './mini-app-manager.error';
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
@Injectable()
|
|
14
14
|
export class MiniAppManagerService {
|
|
15
15
|
constructor(
|
|
@@ -82,7 +82,7 @@ export class MiniAppManagerService {
|
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
const permissions = this.getMiniAppActionAccess(appUser);
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
const installedMiniApps = miniAppInstallations.map((installation) => {
|
|
87
87
|
const miniApp = miniApps.find((miniApp) => miniApp._id === installation.miniApp._id);
|
|
88
88
|
if (!miniApp) {
|
|
@@ -175,10 +175,7 @@ export class MiniAppManagerService {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
private getMiniAppActionAccess(appUser: UserContext) {
|
|
179
|
-
const currentPlan = appUser.tenantInfo.package;
|
|
180
|
-
const planSetting = plans[currentPlan]()
|
|
181
|
-
|
|
178
|
+
private getMiniAppActionAccess(appUser: UserContext) {
|
|
182
179
|
return {
|
|
183
180
|
hasMiniAppFeature: this.policyService.hasFeature(appUser),
|
|
184
181
|
canInstall: this.policyService.canInstall(appUser),
|
|
@@ -1,7 +1,7 @@
|
|
|
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 * as
|
|
4
|
+
import * as licenseTypes from 'src/simple-app/config/license-types';
|
|
5
5
|
@Injectable()
|
|
6
6
|
export class PolicyService {
|
|
7
7
|
private readonly _HIGH_PRIVILEGE_ROLES = [Role.SuperAdmin, Role.SuperUser, Role.TenantOwner];
|
|
@@ -27,12 +27,12 @@ export class PolicyService {
|
|
|
27
27
|
* - plans/pro.ts
|
|
28
28
|
* - plans/enterprise.ts
|
|
29
29
|
*/
|
|
30
|
-
hasFeature(appUser: UserContext, feature: keyof typeof this._FEATURES): boolean {
|
|
31
|
-
const
|
|
32
|
-
const allowedPlans = this._FEATURES[feature];
|
|
33
|
-
const
|
|
34
|
-
const allowed =
|
|
35
|
-
return allowed
|
|
30
|
+
hasFeature(appUser: UserContext, feature: keyof typeof this._FEATURES): boolean {
|
|
31
|
+
const appLicense = appUser.tenantInfo?.license ?? 'free';
|
|
32
|
+
// const allowedPlans = this._FEATURES[feature];
|
|
33
|
+
const licenseSetting = licenseTypes[appLicense]();
|
|
34
|
+
const allowed = licenseSetting.features?.advance?.features[feature] ?? false;
|
|
35
|
+
return allowed;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
can(appUser: UserContext, role: Role) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const license1 = {id:"app"}
|