mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
43 lines
925 B
TypeScript
43 lines
925 B
TypeScript
type FeatureEarlyAccessPreview = {
|
|
whitelist: RegExp[];
|
|
};
|
|
|
|
type FeatureStorageLimit = {
|
|
storageQuota: number;
|
|
};
|
|
|
|
type UserFeatureGate = {
|
|
earlyAccessPreview: FeatureEarlyAccessPreview;
|
|
freeUser: FeatureStorageLimit;
|
|
proUser: FeatureStorageLimit;
|
|
};
|
|
|
|
const UserLevel = {
|
|
freeUser: {
|
|
storageQuota: 10 * 1024 * 1024 * 1024,
|
|
},
|
|
proUser: {
|
|
storageQuota: 100 * 1024 * 1024 * 1024,
|
|
},
|
|
} satisfies Pick<UserFeatureGate, 'freeUser' | 'proUser'>;
|
|
|
|
export function getStorageQuota(features: string[]) {
|
|
for (const feature of features) {
|
|
if (feature in UserLevel) {
|
|
return UserLevel[feature as keyof typeof UserLevel].storageQuota;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
const UserType = {
|
|
earlyAccessPreview: {
|
|
whitelist: [/@toeverything\.info$/],
|
|
},
|
|
} satisfies Pick<UserFeatureGate, 'earlyAccessPreview'>;
|
|
|
|
export const FeatureGates = {
|
|
...UserType,
|
|
...UserLevel,
|
|
} satisfies UserFeatureGate;
|