import { Days, FreeTrialPackage, PaddlePlanId, PaidPackage, PaidPerpetualPackage, SubscriptionPackage, FreeUploadPlanId } from "@upload-io/upload-shared-iso-lite"; /** * Packages vs Plans: * * Packages are what we advertise on the website and are ultimately what users can buy. A package may include one or * many plans. For example, a package may include a free trial premium plan, and then downgrade to a basic plan. The * dashboard shows the user which _plan_ they're on rather than which _package_, since the plan may expire and * transition into a new plan. */ function makeFreeTrial(paidPlan: PaidPerpetualPackage, uploadPlanId: FreeUploadPlanId): FreeTrialPackage { const quotas = paidPlan.plans.base.quotas.base; return { uploadPackageId: uploadPlanId, // Currently they exactly match, so just reuse it (structured typing ftw!) isFreeTrailFor: paidPlan.uploadPackageId, paddlePlanId: undefined, priceUsd: 0, plans: { base: undefined, trials: [ { validity: Days(14), plan: { uploadPlanId, features: { base: paidPlan.plans.base.features.base }, quotas: { base: parseInt(quotas) > 100 ? "50" : quotas // We reduce the limit for free trials. } } } ] } }; } const gb10: PaidPerpetualPackage = { uploadPackageId: "gb10", paddlePlanId: PaddlePlanId(741915), priceUsd: 7, plans: { base: { uploadPlanId: "gb10", features: { base: "basic" }, quotas: { base: "10" } }, trials: [] } }; const gb50: PaidPerpetualPackage = { uploadPackageId: "gb50", paddlePlanId: PaddlePlanId(741914), priceUsd: 35, plans: { base: { uploadPlanId: "gb50", features: { base: "pro" }, quotas: { base: "50" } }, trials: [] } }; const gb300: PaidPerpetualPackage = { uploadPackageId: "gb300", paddlePlanId: PaddlePlanId(741916), priceUsd: 195, plans: { base: { uploadPlanId: "gb300", features: { base: "business" }, quotas: { base: "300" } }, trials: [] } }; const gb10Trial: FreeTrialPackage = makeFreeTrial(gb10, "gb10Trial"); const gb50Trial: FreeTrialPackage = makeFreeTrial(gb50, "gb50Trial"); const gb300Trial: FreeTrialPackage = makeFreeTrial(gb300, "gb300Trial"); export const packageCatalog = { gb10, gb50, gb300, gb10Trial, gb50Trial, gb300Trial }; export const packageList: SubscriptionPackage[] = Object.values(packageCatalog); // Subscription plans that we allow all new users to freely enter into on signing up. // IMPORTANT: these lists must be in order from worst-to-best, as we rely on the order when suggesting plan upgrades in the UI. export const freeTrialPackages: FreeTrialPackage[] = [gb10Trial, gb50Trial, gb300Trial]; export const paidPackages: PaidPackage[] = [gb10, gb50, gb300]; // There may be a slight delay in the webhook from Paddle, so we put them onto the lowest tier. Worse-case is someone // creates their account by signing straight up to a higher tier, and then notices they're on the wrong (a lower) tier. // This is still better than them paying money and they being told they can't sign in! export const defaultPackageUntilWebhookReceived = gb10Trial;