11import { Connection , Messages } from '@salesforce/core' ;
22import { Logger } from '../utils/logger' ;
33import { OmnistudioOrgDetails } from './orgUtils' ;
4+ import { isStandardDataModel } from './dataModelService' ;
45
56export class ValidatorService {
6- private readonly connection : Connection ;
77 private readonly messages : Messages ;
88 private readonly orgs : OmnistudioOrgDetails ;
9-
10- public constructor ( orgs : OmnistudioOrgDetails , connection : Connection , messages : Messages ) {
9+ private readonly connection : Connection ;
10+ public constructor ( orgs : OmnistudioOrgDetails , messages : Messages , connection : Connection ) {
1111 this . orgs = orgs ;
12- this . connection = connection ;
1312 this . messages = messages ;
13+ this . connection = connection ;
1414 }
1515
1616 public async validate ( ) : Promise < boolean > {
17- return (
18- this . validateNamespace ( ) &&
19- this . validatePackageInstalled ( ) &&
20- this . validateOmniStudioOrgPermissionEnabled ( ) &&
21- ( await this . validateOmniStudioLicenses ( ) )
22- ) ;
17+ const basicValidation = this . validateNamespace ( ) && this . validatePackageInstalled ( ) ;
18+ if ( ! basicValidation ) {
19+ return false ;
20+ }
21+
22+ // If data model is standard no need to check for the licences
23+ // TODO: Add metadata toggle validation
24+ const isStandard = isStandardDataModel ( ) ;
25+ if ( isStandard ) {
26+ return true ;
27+ }
28+
29+ // For custom data model, validate if licenses are valid
30+ const isLicensesValid = await this . validateOmniStudioLicenses ( ) ;
31+ return isLicensesValid ;
2332 }
2433
2534 public validatePackageInstalled ( ) : boolean {
@@ -31,15 +40,6 @@ export class ValidatorService {
3140 return true ;
3241 }
3342
34- public validateOmniStudioOrgPermissionEnabled ( ) : boolean {
35- const { omniStudioOrgPermissionEnabled } = this . orgs ;
36- if ( omniStudioOrgPermissionEnabled ) {
37- Logger . error ( this . messages . getMessage ( 'alreadyStandardModel' ) ) ;
38- return false ;
39- }
40- return true ;
41- }
42-
4343 public validateNamespace ( ) : boolean {
4444 const { hasValidNamespace } = this . orgs ;
4545 if ( ! hasValidNamespace ) {
0 commit comments