Files
outline/shared/utils/PlanHelper.ts
T
Tom Moor 95f31d361f fix: Owner selection and membership edge cases
- Remove document owners from the legacy plan
- Selecting yourself in the share picker only suggests other users that can
  be owners, and you are not suggested next to groups or guests
- Users that make themselves an owner through the API get the manage
  permission, so they are listed in the share panel
2026-11-20 11:55:16 -05:00

70 lines
2.2 KiB
TypeScript

import { Plan, PlanFeature } from "../types";
/**
* Describes the features that are included in each plan.
*
* IMPORTANT NOTICE: Bypassing or modifying license controls is a breach of
* the license agreement, and will automatically terminate your rights under
* the license for the current and all other versions.
*/
export class PlanHelper {
/** Plans that can be chosen, ordered from lowest to highest. */
public static readonly plans: Plan[] = [
Plan.Community,
Plan.Standard,
Plan.Business,
Plan.Enterprise,
];
/** The plan that a team gets when no other plan applies. */
public static readonly defaultPlan = Plan.Community;
/** The features that are included in each plan. */
public static readonly features: Record<Plan, PlanFeature[]> = {
[Plan.Community]: [PlanFeature.DocumentOwners],
[Plan.Standard]: [PlanFeature.DocumentOwners, PlanFeature.Guests],
[Plan.Business]: Object.values(PlanFeature),
[Plan.Enterprise]: Object.values(PlanFeature),
[Plan.Legacy]: [
PlanFeature.AuditLog,
PlanFeature.AdvancedSecurity,
PlanFeature.Guests,
PlanFeature.ApiKeyManagement,
PlanFeature.ContentManagement,
PlanFeature.AIAnswers,
PlanFeature.CustomDomain,
],
};
/**
* Get the features that are included in a plan.
*
* @param plan the plan to get the features for.
* @returns the features included in the plan.
*/
public static getFeatures(plan: Plan): PlanFeature[] {
return this.features[plan] ?? [];
}
/**
* Check if a plan includes a feature.
*
* @param plan the plan to check.
* @param feature the feature to check for.
* @returns true if the plan includes the feature.
*/
public static hasFeature(plan: Plan, feature: PlanFeature): boolean {
return this.getFeatures(plan).includes(feature);
}
/**
* Get the lowest plan that can be chosen and includes a feature, for example to show in an upgrade prompt.
*
* @param feature the feature to find a plan for.
* @returns the lowest plan that includes the feature, or undefined if no plan does.
*/
public static getMinimumPlan(feature: PlanFeature): Plan | undefined {
return this.plans.find((plan) => this.hasFeature(plan, feature));
}
}