Skip to content

Commit

Permalink
Refactor addon type and start event preparations
Browse files Browse the repository at this point in the history
  • Loading branch information
d-gubert committed Sep 30, 2024
1 parent af53e49 commit 838b8a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
6 changes: 5 additions & 1 deletion ee/packages/license/src/events/listeners.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LicenseLimitKind, LicenseModule, BehaviorWithContext, LicenseBehavior } from '@rocket.chat/core-typings';
import type { LicenseLimitKind, LicenseModule, BehaviorWithContext, LicenseBehavior, LicenseAddon } from '@rocket.chat/core-typings';

import type { LicenseManager } from '../license';
import { hasModule } from '../modules';
Expand Down Expand Up @@ -87,6 +87,10 @@ export function onModule(this: LicenseManager, cb: (data: { module: LicenseModul
this.on('module', cb);
}

export function onAddon(this: LicenseManager, cb: (data: { addon: LicenseAddon }) => void) {
this.on('addon', cb);
}

export function onValidateLicense(this: LicenseManager, cb: () => void) {
this.on('validate', cb);
}
Expand Down
16 changes: 9 additions & 7 deletions packages/core-typings/src/license/ILicenseV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ export interface ILicenseV3 {
monthlyActiveContacts?: LicenseLimit[];
};
cloudMeta?: Record<string, any>;
addOns?: {
id: string;
limits?: {
maxUsers: number;
};
expiresAt?: Timestamp;
}[];
addOns?: LicenseAddon[];
}

export type LicenseAddon = {
id: string;
limits?: {
maxUsers: number;
};
expiresAt?: Timestamp;
};

export type LicenseLimitKind = keyof ILicenseV3['limits'];
3 changes: 2 additions & 1 deletion packages/core-typings/src/license/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LicenseLimitKind } from './ILicenseV3';
import type { LicenseAddon, LicenseLimitKind } from './ILicenseV3';
import type { BehaviorWithContext, LicenseBehavior } from './LicenseBehavior';
import type { LicenseModule } from './LicenseModule';

Expand All @@ -20,5 +20,6 @@ export type LicenseEvents = ModuleValidation &
validate: undefined;
invalidate: undefined;
module: { module: LicenseModule; valid: boolean };
addon: { addon: LicenseAddon };
sync: undefined;
};

0 comments on commit 838b8a0

Please sign in to comment.