-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Entitlements + license services (#4593)
* first pass at two new modules for TemplatesManager, TemplateDefault * added templates manager to space; removed the SpaceDefaults entity (module still present until move all data to be via defaults * added templatesManager to platform * moved creating of default innovatin flow input to space defaults * back out space type on Template; tidy up Template module to use switch statements * created template applier module * tidy up naming * updated set of default template types * fixed circular dependency; moved logic for creating collaboration input to space defaults * removed loading of defaults from files for collaboration content * removed code based addition of callouts, innovation flow states * tidy up naming * added loading of default templates at platform level in to bootstrap * removed option to create new innovation flow template * added in migration: * loading in templates on bootstrap * added field for collaboration templates on templatesSet; added lookup for templatesManager * added mutation to create template from collaboration; added logic to prevent template used as default to be deleted; fixed removal of template set on template manager * initial creation of license + entitlements modules * add license into account * updated account to have license service + use that in mutations checking limits, removing notion of soft limits * ensure data is loaded properly on account for license checking * added mutation to reset the license calculations on account, including new auth privilege to be able to do so * renamed Licensing module to LicensingFramework module; trigger license reset on Account after assigning / removing license * removed usage of LicenseEngine outside of license services on space or account * renamed entitlement to licenseEntitlement as entity; first pass at migration * fixed issues in migration * fixed issues related to auth reset; tidied up loader creator imports * fixed auth cascade for templates of type post * license reset running * reset licenses on space after adding / removing license plans * removed need for license check in community; added entitlement check in roleset when adding a VC * remove auth reset when assigning / removing license plans * added License to RoleSet * added license to collaboration * tidied up retrieval of license for whiteboard; added license to collaboration in migration * fix typo; fix space spec file * fix additional tests * moved tempaltesManager to last migration in the list * fixed retrieval of template when creating collaboration * added logging * fixed bootstrap setting of templates * refactored inputCreator to do the data loading closer to usage; fixed picking up of templates; fixed bootstrap usage of templates * added ability to retrieve limits on entitlements + current usage * updated field names on entitlements * updated field names on entitlements * fixed account mutaiton logic bug * ensure that licenses are reset when assigning beta tester or vc campaign role to a user * added reset all account licenses mutation * fixed bug on space entitlements; refactored code to reduce duplication * fixed url generation for templates inside of TempaltesManager * fixed bootstrap order to create forum earlier * ensure collaboration creation on template provides some defaults for callouts * fix deletion of templates of type post * ensure more data is defaulted inside of template service for collaboration; add setting of isTemplate field on Collaboration, and also on contained Callouts * ensure isTempalte is passed to Collaboration entity * fixed groups in bootstrap space template; updated signature for creating callout from collaboration * fixed missing field * fixed type on mutation to create from collaboration * fixed typo * fixed groups in bootstrap space template; updated signature for creating callout from collaboration * fixed missing field * fixed type on mutation to create from collaboration * fixed typo * reworked applying collaboraiton template to collaboration * improved error message in wrong type of ID passed in * fixed build * made migration last in the list * rename migration to be last * removed read check when looking up collaboration * track free / plus / premium space entitlements separately * updated migration order * removed duplicate migration * moved auth reset to mutation for applying the template to another collaboration * extend lookup of entitlement usage to cover new types * updaed license policy to reflect new entitlements; made license engine work with entitlements, not license privileges; removed license privilege (no longer relevant) * updated migration to not drop indexes already removed * fix for license reset on space * added license policy rule for free space credential * ensure license entitlements are reset as part of the bootstrap * fixed typo * extended reset all to include resetting licenses on accounts + AI server; moved migration to be last * Address pr comment * Address PR feedback * Address PR comment * Address PR comments * Address PR comments * Address PR comment Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Improved types & naming * Address PR comments * Fixed switch-case logic in entitlements * Converge entitlements schema * Remove unused AuthorizationPrivilege --------- Co-authored-by: Carlos Cano <[email protected]> Co-authored-by: Valentin Yanakiev <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ee016b1
commit c3a8314
Showing
126 changed files
with
3,342 additions
and
776 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { registerEnumType } from '@nestjs/graphql'; | ||
|
||
export enum LicenseEntitlementDataType { | ||
LIMIT = 'limit', | ||
FLAG = 'flag', | ||
} | ||
|
||
registerEnumType(LicenseEntitlementDataType, { | ||
name: 'LicenseEntitlementDataType', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { registerEnumType } from '@nestjs/graphql'; | ||
|
||
export 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', | ||
} | ||
|
||
registerEnumType(LicenseEntitlementType, { | ||
name: 'LicenseEntitlementType', | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { registerEnumType } from '@nestjs/graphql'; | ||
|
||
export enum LicenseType { | ||
ACCOUNT = 'account', | ||
SPACE = 'space', | ||
WHITEBOARD = 'whiteboard', | ||
ROLESET = 'roleset', | ||
COLLABORATION = 'collaboration', | ||
} | ||
|
||
registerEnumType(LicenseType, { | ||
name: 'LicenseType', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/common/exceptions/license.entitlement.not.available.exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { LogContext, AlkemioErrorStatus } from '@common/enums'; | ||
import { BaseException } from './base.exception'; | ||
|
||
export class LicenseEntitlementNotAvailableException extends BaseException { | ||
constructor(error: string, context: LogContext, code?: AlkemioErrorStatus) { | ||
super( | ||
error, | ||
context, | ||
code ?? AlkemioErrorStatus.LICENSE_ENTITLEMENT_NOT_AVAILABLE | ||
); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/common/exceptions/license.entitlement.not.supported.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { LogContext, AlkemioErrorStatus } from '@common/enums'; | ||
import { BaseException } from './base.exception'; | ||
|
||
export class LicenseEntitlementNotSupportedException extends BaseException { | ||
constructor(error: string, context: LogContext, code?: AlkemioErrorStatus) { | ||
super( | ||
error, | ||
context, | ||
code ?? AlkemioErrorStatus.LICENSE_ENTITLEMENT_NOT_SUPPORTED | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/core/dataloader/creators/loader.creators/license.loader.creator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { EntityManager } from 'typeorm'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectEntityManager } from '@nestjs/typeorm'; | ||
import { DataLoaderInitError } from '@common/exceptions/data-loader'; | ||
import { createTypedRelationDataLoader } from '../../utils'; | ||
import { DataLoaderCreator, DataLoaderCreatorOptions } from '../base'; | ||
import { ILicense } from '@domain/common/license/license.interface'; | ||
import { License } from '@domain/common/license/license.entity'; | ||
|
||
@Injectable() | ||
export class LicenseLoaderCreator implements DataLoaderCreator<ILicense> { | ||
constructor(@InjectEntityManager() private manager: EntityManager) {} | ||
|
||
create( | ||
options?: DataLoaderCreatorOptions< | ||
ILicense, | ||
{ id: string; license?: License } | ||
> | ||
) { | ||
if (!options?.parentClassRef) { | ||
throw new DataLoaderInitError( | ||
`${this.constructor.name} requires the 'parentClassRef' to be provided.` | ||
); | ||
} | ||
|
||
return createTypedRelationDataLoader( | ||
this.manager, | ||
options.parentClassRef, | ||
{ | ||
license: true, | ||
}, | ||
this.constructor.name, | ||
options | ||
); | ||
} | ||
} |
Oops, something went wrong.