-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
235 additions
and
215 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
export interface ILicenseTag { | ||
name: string; | ||
color: string; | ||
} | ||
export { ILicenseTag } from '@rocket.chat/core-typings'; |
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 |
---|---|---|
@@ -1,22 +1 @@ | ||
import type { ILicenseTag } from './ILicenseTag'; | ||
|
||
export interface ILicenseV2 { | ||
url: string; | ||
expiry: string; | ||
maxActiveUsers: number; | ||
modules: string[]; | ||
maxGuestUsers: number; | ||
maxRoomsPerGuest: number; | ||
tag?: ILicenseTag; | ||
meta?: { | ||
trial: boolean; | ||
trialEnd: string; | ||
workspaceId: string; | ||
}; | ||
apps?: { | ||
maxPrivateApps: number; | ||
maxMarketplaceApps: number; | ||
}; | ||
} | ||
|
||
export type LicenseAppSources = 'private' | 'marketplace'; | ||
export { ILicenseV2, LicenseAppSources } from '@rocket.chat/core-typings'; |
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 |
---|---|---|
@@ -1,65 +1 @@ | ||
import type { ILicenseTag } from './ILicenseTag'; | ||
import type { LicenseLimit } from './LicenseLimit'; | ||
import type { LicenseModule } from './LicenseModule'; | ||
import type { LicensePeriod, Timestamp } from './LicensePeriod'; | ||
|
||
export interface ILicenseV3 { | ||
version: '3.0'; | ||
information: { | ||
id?: string; | ||
autoRenew: boolean; | ||
visualExpiration?: Timestamp; | ||
notifyAdminsAt?: Timestamp; | ||
notifyUsersAt?: Timestamp; | ||
trial: boolean; | ||
cancellable?: boolean; | ||
offline: boolean; | ||
createdAt: Timestamp; | ||
grantedBy: { | ||
method: 'manual' | 'self-service' | 'sales' | 'support' | 'reseller'; | ||
seller?: string; | ||
}; | ||
grantedTo?: { | ||
name?: string; | ||
company?: string; | ||
email?: string; | ||
}; | ||
legalText?: string; | ||
notes?: string; | ||
tags?: ILicenseTag[]; | ||
}; | ||
validation: { | ||
serverUrls: { | ||
value: string; | ||
type: 'url' | 'regex' | 'hash'; | ||
}[]; | ||
serverVersions?: { | ||
value: string; | ||
}[]; | ||
serverUniqueId?: string; | ||
cloudWorkspaceId?: string; | ||
validPeriods: LicensePeriod[]; | ||
legalTextAgreement?: { | ||
type: 'required' | 'not-required' | 'accepted'; | ||
acceptedVia?: 'cloud'; | ||
}; | ||
statisticsReport: { | ||
required: boolean; | ||
allowedStaleInDays?: number; | ||
}; | ||
}; | ||
grantedModules: { | ||
module: LicenseModule; | ||
}[]; | ||
limits: { | ||
activeUsers?: LicenseLimit[]; | ||
guestUsers?: LicenseLimit[]; | ||
roomsPerGuest?: LicenseLimit<'prevent_action'>[]; | ||
privateApps?: LicenseLimit[]; | ||
marketplaceApps?: LicenseLimit[]; | ||
monthlyActiveContacts?: LicenseLimit[]; | ||
}; | ||
cloudMeta?: Record<string, any>; | ||
} | ||
|
||
export type LicenseLimitKind = keyof ILicenseV3['limits']; | ||
export { ILicenseV3, LicenseLimitKind } from '@rocket.chat/core-typings'; |
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 |
---|---|---|
@@ -1,23 +1 @@ | ||
import type { LicenseLimitKind } from './ILicenseV3'; | ||
import type { LicenseModule } from './LicenseModule'; | ||
|
||
export type LicenseBehavior = | ||
| 'invalidate_license' | ||
| 'start_fair_policy' | ||
| 'prevent_action' | ||
| 'allow_action' | ||
| 'prevent_installation' | ||
| 'disable_modules'; | ||
|
||
export type BehaviorWithContext = | ||
| { | ||
behavior: LicenseBehavior; | ||
modules?: LicenseModule[]; | ||
reason: 'limit'; | ||
limit?: LicenseLimitKind; | ||
} | ||
| { | ||
behavior: LicenseBehavior; | ||
modules?: LicenseModule[]; | ||
reason: 'period' | 'url'; | ||
}; | ||
export { LicenseBehavior, BehaviorWithContext } from '@rocket.chat/core-typings'; |
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 |
---|---|---|
@@ -1,12 +1 @@ | ||
import type { ILicenseTag } from './ILicenseTag'; | ||
import type { ILicenseV3, LicenseLimitKind } from './ILicenseV3'; | ||
import type { LicenseModule } from './LicenseModule'; | ||
|
||
export type LicenseInfo = { | ||
license?: ILicenseV3; | ||
activeModules: LicenseModule[]; | ||
preventedActions: Record<LicenseLimitKind, boolean>; | ||
limits: Record<LicenseLimitKind, { value?: number; max: number }>; | ||
tags: ILicenseTag[]; | ||
trial: boolean; | ||
}; | ||
export { LicenseInfo } from '@rocket.chat/core-typings'; |
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 |
---|---|---|
@@ -1,7 +1 @@ | ||
import type { LicenseBehavior } from './LicenseBehavior'; | ||
import type { LicenseModule } from './LicenseModule'; | ||
|
||
export type LicenseLimit<T extends LicenseBehavior = LicenseBehavior> = { | ||
max: number; | ||
behavior: T; | ||
} & (T extends 'disable_modules' ? { behavior: T; modules: LicenseModule[] } : { behavior: T }); | ||
export { LicenseLimit } from '@rocket.chat/core-typings'; |
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 |
---|---|---|
@@ -1,21 +1 @@ | ||
export type LicenseModule = | ||
| 'auditing' | ||
| 'canned-responses' | ||
| 'ldap-enterprise' | ||
| 'livechat-enterprise' | ||
| 'voip-enterprise' | ||
| 'omnichannel-mobile-enterprise' | ||
| 'engagement-dashboard' | ||
| 'push-privacy' | ||
| 'scalability' | ||
| 'teams-mention' | ||
| 'saml-enterprise' | ||
| 'oauth-enterprise' | ||
| 'device-management' | ||
| 'federation' | ||
| 'videoconference-enterprise' | ||
| 'message-read-receipt' | ||
| 'outlook-calendar' | ||
| 'hide-watermark' | ||
| 'custom-roles' | ||
| 'accessibility-certification'; | ||
export { LicenseModule } from '@rocket.chat/core-typings'; |
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 |
---|---|---|
@@ -1,13 +1 @@ | ||
import type { LicenseBehavior } from './LicenseBehavior'; | ||
import type { LicenseModule } from './LicenseModule'; | ||
|
||
export type Timestamp = string; | ||
|
||
export type LicensePeriod = { | ||
validFrom?: Timestamp; | ||
validUntil?: Timestamp; | ||
invalidBehavior: LicenseBehavior; | ||
} & ({ validFrom: Timestamp } | { validUntil: Timestamp }) & | ||
({ invalidBehavior: 'disable_modules'; modules: LicenseModule[] } | { invalidBehavior: Exclude<LicenseBehavior, 'disable_modules'> }); | ||
|
||
export type LicensePeriodBehavior = Exclude<LicenseBehavior, 'prevent_action'>; | ||
export { LicensePeriod, LicensePeriodBehavior, Timestamp } from '@rocket.chat/core-typings'; |
13 changes: 1 addition & 12 deletions
13
ee/packages/license/src/definition/LicenseValidationOptions.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 |
---|---|---|
@@ -1,12 +1 @@ | ||
import type { LicenseLimitKind } from './ILicenseV3'; | ||
import type { LicenseBehavior } from './LicenseBehavior'; | ||
import type { LimitContext } from './LimitContext'; | ||
|
||
export type LicenseValidationOptions = { | ||
behaviors?: LicenseBehavior[]; | ||
limits?: LicenseLimitKind[]; | ||
suppressLog?: boolean; | ||
isNewLicense?: boolean; | ||
context?: Partial<{ [K in LicenseLimitKind]: Partial<LimitContext<LicenseLimitKind>> }>; | ||
triggerSync?: boolean; | ||
}; | ||
export { LicenseValidationOptions } from '@rocket.chat/core-typings'; |
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 |
---|---|---|
@@ -1,7 +1 @@ | ||
import type { IUser } from '@rocket.chat/core-typings'; | ||
|
||
import type { LicenseLimitKind } from './ILicenseV3'; | ||
|
||
export type LimitContext<T extends LicenseLimitKind> = { extraCount?: number } & (T extends 'roomsPerGuest' | ||
? { userId: IUser['_id'] } | ||
: Record<string, never>); | ||
export { LimitContext } from '@rocket.chat/core-typings'; |
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 |
---|---|---|
@@ -1,24 +1 @@ | ||
import type { LicenseLimitKind } from './ILicenseV3'; | ||
import type { BehaviorWithContext, LicenseBehavior } from './LicenseBehavior'; | ||
import type { LicenseModule } from './LicenseModule'; | ||
|
||
type ModuleValidation = Record<`${'invalid' | 'valid'}:${LicenseModule}`, undefined>; | ||
type BehaviorTriggered = Record<`behavior:${LicenseBehavior}`, { reason: BehaviorWithContext['reason']; limit?: LicenseLimitKind }>; | ||
type BehaviorTriggeredToggled = Record< | ||
`behaviorToggled:${LicenseBehavior}`, | ||
{ reason: BehaviorWithContext['reason']; limit?: LicenseLimitKind } | ||
>; | ||
|
||
type LimitReached = Record<`limitReached:${LicenseLimitKind}`, undefined>; | ||
|
||
export type LicenseEvents = ModuleValidation & | ||
BehaviorTriggeredToggled & | ||
BehaviorTriggered & | ||
LimitReached & { | ||
installed: undefined; | ||
removed: undefined; | ||
validate: undefined; | ||
invalidate: undefined; | ||
module: { module: LicenseModule; valid: boolean }; | ||
sync: undefined; | ||
}; | ||
export { LicenseEvents } from '@rocket.chat/core-typings'; |
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,4 @@ | ||
export interface ILicenseTag { | ||
name: string; | ||
color: string; | ||
} |
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,22 @@ | ||
import type { ILicenseTag } from './ILicenseTag'; | ||
|
||
export interface ILicenseV2 { | ||
url: string; | ||
expiry: string; | ||
maxActiveUsers: number; | ||
modules: string[]; | ||
maxGuestUsers: number; | ||
maxRoomsPerGuest: number; | ||
tag?: ILicenseTag; | ||
meta?: { | ||
trial: boolean; | ||
trialEnd: string; | ||
workspaceId: string; | ||
}; | ||
apps?: { | ||
maxPrivateApps: number; | ||
maxMarketplaceApps: number; | ||
}; | ||
} | ||
|
||
export type LicenseAppSources = 'private' | 'marketplace'; |
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,65 @@ | ||
import type { ILicenseTag } from './ILicenseTag'; | ||
import type { LicenseLimit } from './LicenseLimit'; | ||
import type { LicenseModule } from './LicenseModule'; | ||
import type { LicensePeriod, Timestamp } from './LicensePeriod'; | ||
|
||
export interface ILicenseV3 { | ||
version: '3.0'; | ||
information: { | ||
id?: string; | ||
autoRenew: boolean; | ||
visualExpiration?: Timestamp; | ||
notifyAdminsAt?: Timestamp; | ||
notifyUsersAt?: Timestamp; | ||
trial: boolean; | ||
cancellable?: boolean; | ||
offline: boolean; | ||
createdAt: Timestamp; | ||
grantedBy: { | ||
method: 'manual' | 'self-service' | 'sales' | 'support' | 'reseller'; | ||
seller?: string; | ||
}; | ||
grantedTo?: { | ||
name?: string; | ||
company?: string; | ||
email?: string; | ||
}; | ||
legalText?: string; | ||
notes?: string; | ||
tags?: ILicenseTag[]; | ||
}; | ||
validation: { | ||
serverUrls: { | ||
value: string; | ||
type: 'url' | 'regex' | 'hash'; | ||
}[]; | ||
serverVersions?: { | ||
value: string; | ||
}[]; | ||
serverUniqueId?: string; | ||
cloudWorkspaceId?: string; | ||
validPeriods: LicensePeriod[]; | ||
legalTextAgreement?: { | ||
type: 'required' | 'not-required' | 'accepted'; | ||
acceptedVia?: 'cloud'; | ||
}; | ||
statisticsReport: { | ||
required: boolean; | ||
allowedStaleInDays?: number; | ||
}; | ||
}; | ||
grantedModules: { | ||
module: LicenseModule; | ||
}[]; | ||
limits: { | ||
activeUsers?: LicenseLimit[]; | ||
guestUsers?: LicenseLimit[]; | ||
roomsPerGuest?: LicenseLimit<'prevent_action'>[]; | ||
privateApps?: LicenseLimit[]; | ||
marketplaceApps?: LicenseLimit[]; | ||
monthlyActiveContacts?: LicenseLimit[]; | ||
}; | ||
cloudMeta?: Record<string, any>; | ||
} | ||
|
||
export type LicenseLimitKind = keyof ILicenseV3['limits']; |
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,23 @@ | ||
import type { LicenseLimitKind } from './ILicenseV3'; | ||
import type { LicenseModule } from './LicenseModule'; | ||
|
||
export type LicenseBehavior = | ||
| 'invalidate_license' | ||
| 'start_fair_policy' | ||
| 'prevent_action' | ||
| 'allow_action' | ||
| 'prevent_installation' | ||
| 'disable_modules'; | ||
|
||
export type BehaviorWithContext = | ||
| { | ||
behavior: LicenseBehavior; | ||
modules?: LicenseModule[]; | ||
reason: 'limit'; | ||
limit?: LicenseLimitKind; | ||
} | ||
| { | ||
behavior: LicenseBehavior; | ||
modules?: LicenseModule[]; | ||
reason: 'period' | 'url'; | ||
}; |
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 type { ILicenseTag } from './ILicenseTag'; | ||
import type { ILicenseV3, LicenseLimitKind } from './ILicenseV3'; | ||
import type { LicenseModule } from './LicenseModule'; | ||
|
||
export type LicenseInfo = { | ||
license?: ILicenseV3; | ||
activeModules: LicenseModule[]; | ||
preventedActions: Record<LicenseLimitKind, boolean>; | ||
limits: Record<LicenseLimitKind, { value?: number; max: number }>; | ||
tags: ILicenseTag[]; | ||
trial: boolean; | ||
}; |
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,7 @@ | ||
import type { LicenseBehavior } from './LicenseBehavior'; | ||
import type { LicenseModule } from './LicenseModule'; | ||
|
||
export type LicenseLimit<T extends LicenseBehavior = LicenseBehavior> = { | ||
max: number; | ||
behavior: T; | ||
} & (T extends 'disable_modules' ? { behavior: T; modules: LicenseModule[] } : { behavior: T }); |
Oops, something went wrong.