Skip to content

Commit

Permalink
[license] Prepare renaming of argument names
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Aug 25, 2024
1 parent bdd0686 commit 2e9f2d0
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions packages/x-license/src/generateLicense/generateLicense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,36 @@ const licenseVersion = '2';
export interface LicenseDetails {
orderNumber: string;
expiryDate: Date;
scope: LicenseScope;
licensingModel: LicensingModel;
scope?: LicenseScope;
planScope?: LicenseScope; // TODO deprecate
licenseModel?: LicensingModel;
licensingModel?: LicensingModel; // TODO deprecate
planVersion: PlanVersion;
}

function getClearLicenseString(details: LicenseDetails) {
if (details.scope && !LICENSE_SCOPES.includes(details.scope)) {
// TODO remove
if (details.licensingModel) {
details.licenseModel = details.licensingModel;
}
// TODO remove
if (details.scope) {
details.planScope = details.scope;
}

if (details.planScope && !LICENSE_SCOPES.includes(details.planScope)) {
throw new Error('MUI X: Invalid scope');
}

if (details.licensingModel && !LICENSING_MODELS.includes(details.licensingModel)) {
if (details.licenseModel && !LICENSING_MODELS.includes(details.licenseModel)) {
throw new Error('MUI X: Invalid licensing model');
}

const keyParts = [
`O=${details.orderNumber}`,
`E=${details.expiryDate.getTime()}`,
`S=${details.scope}`,
`LM=${details.licensingModel}`,
`S=${details.planScope}`,
`LM=${details.licenseModel}`,
`PV=${details.planVersion}`,
`KV=${licenseVersion}`,
];
Expand Down

0 comments on commit 2e9f2d0

Please sign in to comment.