@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 CHANGED
@@ -1,3 +1,6 @@
1
+ [2.0.0h-alpha]
2
+ 1. add software license config folder
3
+
1
4
  [2.0.0g-alpha]
2
5
  1. fix create many no await cause transaction error
3
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simitgroup/simpleapp-generator",
3
- "version": "2.0.0g-alpha",
3
+ "version": "2.0.0h-alpha",
4
4
  "description": "frontend nuxtjs and backend nests code generator using jsonschema",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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 plans from 'src/simple-app/features/subscription/license/plans'
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 currentPlan = appUser.tenantInfo.package;
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
- }else{
40
- return false
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
- import * as plans from 'src/simple-app/features/subscription/license/plans'
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 plans from 'src/simple-app/features/subscription/license/plans'
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 appPackage = appUser.tenantInfo.package;
32
- const allowedPlans = this._FEATURES[feature];
33
- const planSetting = plans[appPackage]();
34
- const allowed = planSetting.features?.advance?.features[feature] ?? false;
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"}