Fix guest demo UX and enforce guest limits

This commit is contained in:
Codex Agent
2026-01-21 21:35:40 +01:00
parent a01a7ec399
commit 80dd12bb92
28 changed files with 812 additions and 118 deletions

View File

@@ -63,6 +63,20 @@ function collectFeatures(pkg: Package | null): Set<string> {
return new Set(getEnabledPackageFeatures(pkg));
}
const FEATURE_COMPATIBILITY: Record<string, string[]> = {
limited_sharing: ['limited_sharing', 'unlimited_sharing'],
watermark_base: ['watermark_base', 'watermark_custom', 'no_watermark'],
};
function featureSatisfied(feature: string, candidateFeatures: Set<string>): boolean {
const compatible = FEATURE_COMPATIBILITY[feature];
if (compatible) {
return compatible.some((value) => candidateFeatures.has(value));
}
return candidateFeatures.has(feature);
}
function compareLimit(candidate: number | null, active: number | null): number {
if (active === null) {
return candidate === null ? 0 : -1;
@@ -89,8 +103,8 @@ export function classifyPackageChange(pkg: Package, active: Package | null): Pac
const activeFeatures = collectFeatures(active);
const candidateFeatures = collectFeatures(pkg);
const hasFeatureUpgrade = Array.from(candidateFeatures).some((feature) => !activeFeatures.has(feature));
const hasFeatureDowngrade = Array.from(activeFeatures).some((feature) => !candidateFeatures.has(feature));
const hasFeatureUpgrade = Array.from(candidateFeatures).some((feature) => !featureSatisfied(feature, activeFeatures));
const hasFeatureDowngrade = Array.from(activeFeatures).some((feature) => !featureSatisfied(feature, candidateFeatures));
const limitKeys: Array<keyof Package> = ['max_photos', 'max_guests', 'gallery_days'];
let hasLimitUpgrade = false;