chore: make ai feature available for self hosting (#4543)

This commit is contained in:
Dhruwang Jariwala
2024-12-31 14:31:08 +05:30
committed by GitHub
parent 93e9ec867c
commit e194a2feb8
2 changed files with 16 additions and 8 deletions

View File

@@ -89,6 +89,7 @@ const fetchLicenseForE2ETesting = async (): Promise<{
projects: 3,
whitelabel: true,
removeBranding: true,
ai: true,
},
lastChecked: currentTime,
};
@@ -154,6 +155,7 @@ export const getEnterpriseLicense = async (): Promise<{
whitelabel: false,
removeBranding: false,
contacts: false,
ai: false,
},
lastChecked: new Date(),
};
@@ -350,18 +352,23 @@ export const getIsSSOEnabled = async (): Promise<boolean> => {
};
export const getIsOrganizationAIReady = async (billingPlan: TOrganizationBillingPlan) => {
// TODO: We'll remove the IS_FORMBRICKS_CLOUD check once we have the AI feature available for self-hosted customers
if (!IS_AI_CONFIGURED) return false;
if (E2E_TESTING) {
const previousResult = await fetchLicenseForE2ETesting();
return previousResult && previousResult.features ? previousResult.features.ai : false;
}
const license = await getEnterpriseLicense();
if (IS_FORMBRICKS_CLOUD) {
return (
IS_AI_CONFIGURED &&
(await getEnterpriseLicense()).active &&
(billingPlan === PROJECT_FEATURE_KEYS.STARTUP ||
billingPlan === PROJECT_FEATURE_KEYS.SCALE ||
billingPlan === PROJECT_FEATURE_KEYS.ENTERPRISE)
return Boolean(
license.features?.ai &&
(billingPlan === PROJECT_FEATURE_KEYS.STARTUP ||
billingPlan === PROJECT_FEATURE_KEYS.SCALE ||
billingPlan === PROJECT_FEATURE_KEYS.ENTERPRISE)
);
}
return false;
return Boolean(license.features?.ai);
};
export const getIsAIEnabled = async (organization: TOrganization) => {

View File

@@ -12,6 +12,7 @@ const ZEnterpriseLicenseFeatures = z.object({
removeBranding: z.boolean(),
twoFactorAuth: z.boolean(),
sso: z.boolean(),
ai: z.boolean(),
});
export type TEnterpriseLicenseFeatures = z.infer<typeof ZEnterpriseLicenseFeatures>;