diff --git a/src/domain/space/account/account.module.ts b/src/domain/space/account/account.module.ts index 29ba9b4b5..484e680b3 100644 --- a/src/domain/space/account/account.module.ts +++ b/src/domain/space/account/account.module.ts @@ -26,6 +26,7 @@ import { TemporaryStorageModule } from '@services/infrastructure/temporary-stora import { LicenseModule } from '@domain/common/license/license.module'; import { AccountLicenseService } from './account.service.license'; import { LicensingFrameworkModule } from '@platform/licensing/credential-based/licensing-framework/licensing.framework.module'; +import { LicensingWingbackSubscriptionModule } from '@platform/licensing/wingback-subscription/licensing.wingback.subscription.module'; @Module({ imports: [ @@ -40,6 +41,7 @@ import { LicensingFrameworkModule } from '@platform/licensing/credential-based/l LicensingFrameworkModule, LicenseIssuerModule, LicensingCredentialBasedModule, + LicensingWingbackSubscriptionModule, LicenseModule, SpaceModule, InnovationHubModule, diff --git a/src/domain/space/account/account.service.license.ts b/src/domain/space/account/account.service.license.ts index d008d4f0d..9ba51b080 100644 --- a/src/domain/space/account/account.service.license.ts +++ b/src/domain/space/account/account.service.license.ts @@ -9,18 +9,20 @@ import { IAgent } from '@domain/agent/agent/agent.interface'; import { LicenseService } from '@domain/common/license/license.service'; import { ILicense } from '@domain/common/license/license.interface'; import { LicensingCredentialBasedService } from '@platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.service'; -import { LicenseEntitlementType } from '@common/enums/license.entitlement.type'; import { IAccount } from './account.interface'; import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston'; import { SpaceLicenseService } from '../space/space.service.license'; +import { LicensingWingbackSubscriptionService } from '@platform/licensing/wingback-subscription/licensing.wingback.subscription.service'; +import { ILicenseEntitlement } from '@domain/common/license-entitlement/license.entitlement.interface'; @Injectable() export class AccountLicenseService { constructor( private licenseService: LicenseService, private accountService: AccountService, - private licenseEngineService: LicensingCredentialBasedService, private spaceLicenseService: SpaceLicenseService, + private licensingCredentialBasedService: LicensingCredentialBasedService, + private licensingWingbackSubscriptionService: LicensingWingbackSubscriptionService, @Inject(WINSTON_MODULE_NEST_PROVIDER) private readonly logger: LoggerService ) {} @@ -81,90 +83,50 @@ export class AccountLicenseService { LogContext.LICENSE ); } + + // First check the credential based licensing based on the Agent held credentials for (const entitlement of license.entitlements) { - switch (entitlement.type) { - case LicenseEntitlementType.ACCOUNT_SPACE_FREE: - const createSpace = - await this.licenseEngineService.isEntitlementGranted( - LicenseEntitlementType.ACCOUNT_SPACE_FREE, - accountAgent - ); - if (createSpace) { - entitlement.limit = 3; - entitlement.enabled = true; - } - break; - case LicenseEntitlementType.ACCOUNT_SPACE_PLUS: - const createSpacePLus = - await this.licenseEngineService.isEntitlementGranted( - LicenseEntitlementType.ACCOUNT_SPACE_PLUS, - accountAgent - ); - if (createSpacePLus) { - entitlement.limit = 0; - entitlement.enabled = true; - } - break; - case LicenseEntitlementType.ACCOUNT_SPACE_PREMIUM: - const createSpacePremium = - await this.licenseEngineService.isEntitlementGranted( - LicenseEntitlementType.ACCOUNT_SPACE_PREMIUM, - accountAgent - ); - if (createSpacePremium) { - entitlement.limit = 0; - entitlement.enabled = true; - } - break; - case LicenseEntitlementType.ACCOUNT_VIRTUAL_CONTRIBUTOR: - const createVirtualContributor = - await this.licenseEngineService.isEntitlementGranted( - LicenseEntitlementType.ACCOUNT_VIRTUAL_CONTRIBUTOR, - accountAgent - ); - if (createVirtualContributor) { - entitlement.limit = 3; - entitlement.enabled = true; - } - break; - case LicenseEntitlementType.ACCOUNT_INNOVATION_HUB: - const createInnovationHub = - await this.licenseEngineService.isEntitlementGranted( - LicenseEntitlementType.ACCOUNT_INNOVATION_HUB, - accountAgent - ); - if (createInnovationHub) { - entitlement.limit = 1; - entitlement.enabled = true; - } - break; - case LicenseEntitlementType.ACCOUNT_INNOVATION_PACK: - const createInnovationPack = - await this.licenseEngineService.isEntitlementGranted( - LicenseEntitlementType.ACCOUNT_INNOVATION_PACK, - accountAgent - ); - if (createInnovationPack) { - entitlement.limit = 3; - entitlement.enabled = true; - } - break; - default: - throw new EntityNotInitializedException( - `Unknown entitlement type for license: ${entitlement.type}`, - LogContext.LICENSE - ); - } + await this.checkAndAssignGrantedEntitlement(entitlement, accountAgent); } + // Then check the Wingback subscription service for any granted entitlements if (account.externalSubscriptionID) { - // TODO: get subscription details from the WingBack api + set the entitlements accordingly + const wingbackGrantedLicenseEntitlements = + await this.licensingWingbackSubscriptionService.getEntitlements( + account.externalSubscriptionID + ); this.logger.verbose?.( - `Invoking external subscription service for account ${account.id}`, + `Invoking external subscription service for account ${account.id}, entitlements ${wingbackGrantedLicenseEntitlements}`, LogContext.ACCOUNT ); + for (const entitlement of license.entitlements) { + const wingbackGrantedEntitlement = + wingbackGrantedLicenseEntitlements.find( + e => e.type === entitlement.type + ); + // Note: for now overwrite the credential based entitlements with the Wingback entitlements + if (wingbackGrantedEntitlement) { + entitlement.limit = wingbackGrantedEntitlement.limit; + entitlement.enabled = true; + } + } } return license; } + + private async checkAndAssignGrantedEntitlement( + entitlement: ILicenseEntitlement, + accountAgent: IAgent + ): Promise { + const grantedEntitlement = + await this.licensingCredentialBasedService.getEntitlementIfGranted( + entitlement.type, + accountAgent + ); + if (grantedEntitlement) { + entitlement.limit = grantedEntitlement.limit; + entitlement.enabled = true; + } + } } diff --git a/src/migrations/1731500015640-licenseEntitlements.ts b/src/migrations/1731500015640-licenseEntitlements.ts index 39567afcb..73996d47b 100644 --- a/src/migrations/1731500015640-licenseEntitlements.ts +++ b/src/migrations/1731500015640-licenseEntitlements.ts @@ -610,7 +610,7 @@ const licenseCredentialRules = [ { credentialType: 'space-feature-save-as-template', grantedEntitlements: [LicenseEntitlementType.SPACE_FLAG_SAVE_AS_TEMPLATE], - name: 'Space Save As Templatet', + name: 'Space Save As Template', }, { credentialType: 'space-license-free', diff --git a/src/migrations/1734708463555-licensePolicyLimits.ts b/src/migrations/1734708463555-licensePolicyLimits.ts new file mode 100644 index 000000000..35e0055c0 --- /dev/null +++ b/src/migrations/1734708463555-licensePolicyLimits.ts @@ -0,0 +1,155 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class LicensePolicyLimits1734708463555 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const [licensePolicy]: { + id: string; + }[] = await queryRunner.query(`SELECT id FROM license_policy`); + await queryRunner.query( + `UPDATE license_policy SET credentialRulesStr = ? WHERE id = ?`, + [`${JSON.stringify(licenseCredentialRules)}`, licensePolicy.id] + ); + } + + public async down(queryRunner: QueryRunner): Promise { + console.log('No down migration needed'); + } +} + +type CredentialRule = { + credentialType: LicenseCredential; + grantedEntitlements: GrantedEntitlement[]; + name: string; +}; + +type GrantedEntitlement = { + type: LicenseEntitlementType; + limit: number; +}; + +enum LicenseCredential { + SPACE_LICENSE_FREE = 'space-license-free', + SPACE_LICENSE_PLUS = 'space-license-plus', + SPACE_LICENSE_PREMIUM = 'space-license-premium', + SPACE_LICENSE_ENTERPRISE = 'space-license-enterprise', // todo: remove for space + SPACE_FEATURE_SAVE_AS_TEMPLATE = 'space-feature-save-as-template', + SPACE_FEATURE_VIRTUAL_CONTRIBUTORS = 'space-feature-virtual-contributors', + SPACE_FEATURE_WHITEBOARD_MULTI_USER = 'space-feature-whiteboard-multi-user', + ACCOUNT_LICENSE_PLUS = 'account-license-plus', +} + +enum LicenseEntitlementType { + ACCOUNT_SPACE_FREE = 'account-space-free', + ACCOUNT_SPACE_PLUS = 'account-space-plus', + ACCOUNT_SPACE_PREMIUM = 'account-space-premium', + ACCOUNT_VIRTUAL_CONTRIBUTOR = 'account-virtual-contributor', + ACCOUNT_INNOVATION_PACK = 'account-innovation-pack', + ACCOUNT_INNOVATION_HUB = 'account-innovation-hub', + SPACE_FREE = 'space-free', + SPACE_PLUS = 'space-plus', + SPACE_PREMIUM = 'space-premium', + SPACE_FLAG_SAVE_AS_TEMPLATE = 'space-flag-save-as-template', + SPACE_FLAG_VIRTUAL_CONTRIBUTOR_ACCESS = 'space-flag-virtual-contributor-access', + SPACE_FLAG_WHITEBOARD_MULTI_USER = 'space-flag-whiteboard-multi-user', +} + +const licenseCredentialRules: CredentialRule[] = [ + { + credentialType: LicenseCredential.SPACE_FEATURE_VIRTUAL_CONTRIBUTORS, + grantedEntitlements: [ + { + type: LicenseEntitlementType.SPACE_FLAG_VIRTUAL_CONTRIBUTOR_ACCESS, + limit: 1, + }, + ], + name: 'Space Virtual Contributors', + }, + { + credentialType: LicenseCredential.SPACE_FEATURE_WHITEBOARD_MULTI_USER, + grantedEntitlements: [ + { + type: LicenseEntitlementType.SPACE_FLAG_WHITEBOARD_MULTI_USER, + limit: 1, + }, + ], + name: 'Space Multi-user whiteboards', + }, + { + credentialType: LicenseCredential.SPACE_FEATURE_SAVE_AS_TEMPLATE, + grantedEntitlements: [ + { + type: LicenseEntitlementType.SPACE_FLAG_SAVE_AS_TEMPLATE, + limit: 1, + }, + ], + name: 'Space Save As Template', + }, + { + credentialType: LicenseCredential.SPACE_LICENSE_FREE, + grantedEntitlements: [ + { + type: LicenseEntitlementType.SPACE_FREE, + limit: 1, + }, + ], + name: 'Space License Free', + }, + { + credentialType: LicenseCredential.SPACE_LICENSE_PLUS, + grantedEntitlements: [ + { + type: LicenseEntitlementType.SPACE_PLUS, + limit: 1, + }, + { + type: LicenseEntitlementType.SPACE_FLAG_WHITEBOARD_MULTI_USER, + limit: 1, + }, + { + type: LicenseEntitlementType.SPACE_FLAG_SAVE_AS_TEMPLATE, + limit: 1, + }, + ], + name: 'Space License Plus', + }, + { + credentialType: LicenseCredential.SPACE_LICENSE_PREMIUM, + grantedEntitlements: [ + { + type: LicenseEntitlementType.SPACE_PREMIUM, + limit: 1, + }, + { + type: LicenseEntitlementType.SPACE_FLAG_WHITEBOARD_MULTI_USER, + limit: 1, + }, + { + type: LicenseEntitlementType.SPACE_FLAG_SAVE_AS_TEMPLATE, + limit: 1, + }, + ], + name: 'Space License Premium', + }, + { + credentialType: LicenseCredential.ACCOUNT_LICENSE_PLUS, + grantedEntitlements: [ + { + type: LicenseEntitlementType.ACCOUNT_SPACE_FREE, + limit: 3, + }, + { + type: LicenseEntitlementType.ACCOUNT_VIRTUAL_CONTRIBUTOR, + limit: 3, + }, + { + type: LicenseEntitlementType.ACCOUNT_INNOVATION_HUB, + limit: 1, + }, + { + type: LicenseEntitlementType.ACCOUNT_INNOVATION_PACK, + limit: 3, + }, + ], + name: 'Account License Plus', + }, +]; diff --git a/src/platform/licensing/credential-based/license-policy/license.policy.service.ts b/src/platform/licensing/credential-based/license-policy/license.policy.service.ts index 758b12fb2..613175a59 100644 --- a/src/platform/licensing/credential-based/license-policy/license.policy.service.ts +++ b/src/platform/licensing/credential-based/license-policy/license.policy.service.ts @@ -9,7 +9,7 @@ import { LicensingCredentialBasedService } from '@platform/licensing/credential- import { LogContext } from '@common/enums/logging.context'; import { ILicensingCredentialBasedPolicyCredentialRule } from '@platform/licensing/credential-based/licensing-credential-based-entitlements-engine'; import { LicensingCredentialBasedCredentialType } from '@common/enums/licensing.credential.based.credential.type'; -import { LicenseEntitlementType } from '@common/enums/license.entitlement.type'; +import { LicensingGrantedEntitlement } from '@platform/licensing/dto/licensing.dto.granted.entitlement'; @Injectable() export class LicensePolicyService { @@ -22,7 +22,7 @@ export class LicensePolicyService { ) {} createCredentialRule( - grantedEntitlements: LicenseEntitlementType[], + grantedEntitlements: LicensingGrantedEntitlement[], credentialType: LicensingCredentialBasedCredentialType, name: string ): ILicensingCredentialBasedPolicyCredentialRule { diff --git a/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/index.ts b/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/index.ts index b3500d3fa..3417226b1 100644 --- a/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/index.ts +++ b/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/index.ts @@ -1 +1 @@ -export * from './licensing.credential.based.policy.rule.credential.interface'; +export * from './licensing.credential.based.policy.credential.rule.interface'; diff --git a/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.rule.credential.interface.ts b/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.credential.rule.interface.ts similarity index 69% rename from src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.rule.credential.interface.ts rename to src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.credential.rule.interface.ts index 0d9dd160f..51564d75f 100644 --- a/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.rule.credential.interface.ts +++ b/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.credential.rule.interface.ts @@ -1,14 +1,14 @@ import { LicensingCredentialBasedCredentialType } from '@common/enums/licensing.credential.based.credential.type'; -import { LicenseEntitlementType } from '@common/enums/license.entitlement.type'; import { Field, ObjectType } from '@nestjs/graphql'; +import { LicensingGrantedEntitlement } from '@platform/licensing/dto/licensing.dto.granted.entitlement'; @ObjectType('LicensingCredentialBasedPolicyCredentialRule') export abstract class ILicensingCredentialBasedPolicyCredentialRule { @Field(() => LicensingCredentialBasedCredentialType) credentialType!: LicensingCredentialBasedCredentialType; - @Field(() => [LicenseEntitlementType]) - grantedEntitlements!: LicenseEntitlementType[]; + @Field(() => [LicensingGrantedEntitlement]) + grantedEntitlements!: LicensingGrantedEntitlement[]; @Field(() => String, { nullable: true }) name?: string; diff --git a/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.rule.credential.ts b/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.credential.rule.ts similarity index 68% rename from src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.rule.credential.ts rename to src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.credential.rule.ts index 199883e03..5e10b616a 100644 --- a/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.rule.credential.ts +++ b/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.policy.credential.rule.ts @@ -1,16 +1,16 @@ import { LicensingCredentialBasedCredentialType } from '@common/enums/licensing.credential.based.credential.type'; -import { ILicensingCredentialBasedPolicyCredentialRule } from './licensing.credential.based.policy.rule.credential.interface'; -import { LicenseEntitlementType } from '@common/enums/license.entitlement.type'; +import { ILicensingCredentialBasedPolicyCredentialRule } from './licensing.credential.based.policy.credential.rule.interface'; +import { LicensingGrantedEntitlement } from '@platform/licensing/dto/licensing.dto.granted.entitlement'; export class LicensingCredentialBasedPolicyCredentialRule implements ILicensingCredentialBasedPolicyCredentialRule { credentialType: LicensingCredentialBasedCredentialType; - grantedEntitlements: LicenseEntitlementType[]; + grantedEntitlements: LicensingGrantedEntitlement[]; name: string; constructor( - grantedEntitlements: LicenseEntitlementType[], + grantedEntitlements: LicensingGrantedEntitlement[], credentialType: LicensingCredentialBasedCredentialType, name: string ) { diff --git a/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.service.ts b/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.service.ts index 073c30bba..065ae3521 100644 --- a/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.service.ts +++ b/src/platform/licensing/credential-based/licensing-credential-based-entitlements-engine/licensing.credential.based.service.ts @@ -11,8 +11,9 @@ import { EntityManager } from 'typeorm'; import { InjectEntityManager } from '@nestjs/typeorm'; import { LicensePolicy } from '@platform/licensing/credential-based/license-policy'; import { IAgent, ICredential } from '@domain/agent'; -import { ILicensingCredentialBasedPolicyCredentialRule } from './licensing.credential.based.policy.rule.credential.interface'; +import { ILicensingCredentialBasedPolicyCredentialRule } from './licensing.credential.based.policy.credential.rule.interface'; import { LicenseEntitlementType } from '@common/enums/license.entitlement.type'; +import { LicensingGrantedEntitlement } from '@platform/licensing/dto/licensing.dto.granted.entitlement'; @Injectable() export class LicensingCredentialBasedService { @@ -61,9 +62,10 @@ export class LicensingCredentialBasedService { for (const credentialRule of credentialRules) { for (const credential of credentials) { if (credential.type === credentialRule.credentialType) { - if ( - credentialRule.grantedEntitlements.includes(entitlementRequired) - ) { + const grantedEntitlement = credentialRule.grantedEntitlements.find( + ge => ge.type === entitlementRequired + ); + if (grantedEntitlement) { this.logger.verbose?.( `[CredentialRule] Granted privilege '${entitlementRequired}' using rule '${credentialRule.name}'`, LogContext.LICENSE @@ -76,6 +78,37 @@ export class LicensingCredentialBasedService { return false; } + public async getEntitlementIfGranted( + entitlementRequired: LicenseEntitlementType, + agent: IAgent, + licensePolicy?: ILicensePolicy | undefined + ): Promise { + const policy = + await this.getLicensingCredentialBasedPolicyOrFail(licensePolicy); + const credentials = await this.getCredentialsFromAgent(agent); + + const credentialRules = this.convertCredentialRulesStr( + policy.credentialRulesStr + ); + for (const credentialRule of credentialRules) { + for (const credential of credentials) { + if (credential.type === credentialRule.credentialType) { + const grantedEntitlement = credentialRule.grantedEntitlements.find( + ge => ge.type === entitlementRequired + ); + if (grantedEntitlement) { + this.logger.verbose?.( + `[CredentialRule] Granted privilege '${entitlementRequired}' using rule '${credentialRule.name}'`, + LogContext.LICENSE + ); + return grantedEntitlement; + } + } + } + } + return undefined; + } + private async getCredentialsFromAgent(agent: IAgent): Promise { const credentials = agent.credentials; if (!credentials) { @@ -114,7 +147,9 @@ export class LicensingCredentialBasedService { for (const credential of credentials) { if (rule.credentialType === credential.type) { for (const entitlement of rule.grantedEntitlements) { - grantedEntitlements.push(entitlement); + if (entitlement.limit > 0) { + grantedEntitlements.push(entitlement.type); + } } } } diff --git a/src/platform/licensing/dto/licensing.dto.granted.entitlement.ts b/src/platform/licensing/dto/licensing.dto.granted.entitlement.ts new file mode 100644 index 000000000..ed406bbf9 --- /dev/null +++ b/src/platform/licensing/dto/licensing.dto.granted.entitlement.ts @@ -0,0 +1,13 @@ +import { LicenseEntitlementType } from '@common/enums/license.entitlement.type'; +import { Field, ObjectType } from '@nestjs/graphql'; + +@ObjectType('LicensingGrantedEntitlement') +export class LicensingGrantedEntitlement { + @Field(() => LicenseEntitlementType, { + description: 'The entitlement that is granted.', + }) + type!: LicenseEntitlementType; + + @Field(() => Number, { nullable: false }) + limit!: number; +} diff --git a/src/platform/licensing/wingback-subscription/licensing.wingback.subscription.service.spec.ts b/src/platform/licensing/wingback-subscription/licensing.wingback.subscription.service.spec.ts index 67e136d19..eeab0caf1 100644 --- a/src/platform/licensing/wingback-subscription/licensing.wingback.subscription.service.spec.ts +++ b/src/platform/licensing/wingback-subscription/licensing.wingback.subscription.service.spec.ts @@ -1,6 +1,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { LicensingWingbackSubscriptionService } from './licensing.wingback.subscription.service'; import { WingbackManager } from '@services/external/wingback'; +import { MockWinstonProvider } from '@test/mocks/winston.provider.mock'; describe('LicensingWingbackSubscriptionService', () => { let service: LicensingWingbackSubscriptionService; @@ -9,6 +10,7 @@ describe('LicensingWingbackSubscriptionService', () => { const module: TestingModule = await Test.createTestingModule({ providers: [ LicensingWingbackSubscriptionService, + MockWinstonProvider, { provide: WingbackManager, useValue: { diff --git a/src/platform/licensing/wingback-subscription/licensing.wingback.subscription.service.ts b/src/platform/licensing/wingback-subscription/licensing.wingback.subscription.service.ts index 8e798e0b7..e65e6dac8 100644 --- a/src/platform/licensing/wingback-subscription/licensing.wingback.subscription.service.ts +++ b/src/platform/licensing/wingback-subscription/licensing.wingback.subscription.service.ts @@ -1,10 +1,17 @@ -import { Injectable } from '@nestjs/common'; +import { Inject, Injectable, LoggerService } from '@nestjs/common'; import { CreateCustomer } from '../../../services/external/wingback/types/wingback.type.create.customer'; import { WingbackManager } from '@services/external/wingback/wingback.manager'; +import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston'; +import { LogContext } from '@common/enums'; +import { LicensingGrantedEntitlement } from '../dto/licensing.dto.granted.entitlement'; @Injectable() export class LicensingWingbackSubscriptionService { - constructor(private readonly wingbackManager: WingbackManager) {} + constructor( + private readonly wingbackManager: WingbackManager, + @Inject(WINSTON_MODULE_NEST_PROVIDER) + private readonly logger: LoggerService + ) {} /** * Create a new customer @@ -15,9 +22,17 @@ export class LicensingWingbackSubscriptionService { return this.wingbackManager.createCustomer(data); } - public getEntitlements( + public async getEntitlements( customerId: string - ): Promise[]> { - return this.wingbackManager.getEntitlements(customerId); + ): Promise { + const entitlements: LicensingGrantedEntitlement[] = []; + const wingbackEntitlements = + await this.wingbackManager.getEntitlements(customerId); + // Todo: map the wingback entitlements to the entitlements that are understood within Alkemio Licensing + this.logger.verbose?.( + `Wingback entitlements: ${JSON.stringify(wingbackEntitlements)}`, + LogContext.LICENSE + ); + return entitlements; } }