rename: "Team" billing tier to "Family"
All literal "team" tier-value references renamed to "family" across API routes, admin UI, OpenAPI schemas, and lib/tiers.ts. The DB enum value itself is renamed in place via ALTER TYPE ... RENAME VALUE (migration 0044) rather than drizzle-kit's auto-generated drop-and-recreate-the-enum migration, which would have failed against any existing row still holding 'team' — RENAME VALUE preserves existing data with no cast/backfill needed. Also adds STRIPE_PLAN.md — a full Stripe billing integration plan (Checkout+Portal, tier→Price mapping, admin billing dashboard, and a multi-user Family-group design since Family is meant to cover several accounts under one subscription, not one payer). Planning only, no Stripe code yet. v0.47.0
This commit is contained in:
@@ -41,7 +41,7 @@ export default async function AdminStoragePage() {
|
||||
|
||||
const freePhotos = Number(photosByTier.find((r) => r.tier === "free")?.photoCount ?? 0);
|
||||
const proPhotos = Number(photosByTier.find((r) => r.tier === "pro")?.photoCount ?? 0);
|
||||
const teamPhotos = Number(photosByTier.find((r) => r.tier === "team")?.photoCount ?? 0);
|
||||
const familyPhotos = Number(photosByTier.find((r) => r.tier === "family")?.photoCount ?? 0);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -86,11 +86,11 @@ export default async function AdminStoragePage() {
|
||||
|
||||
<Card>
|
||||
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||
<CardTitle className="text-sm font-medium text-muted-foreground">Team Tier Photos</CardTitle>
|
||||
<CardTitle className="text-sm font-medium text-muted-foreground">Family Tier Photos</CardTitle>
|
||||
<HardDrive className="h-4 w-4 text-muted-foreground" />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="text-2xl font-bold">{teamPhotos.toLocaleString()}</div>
|
||||
<div className="text-2xl font-bold">{familyPhotos.toLocaleString()}</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@@ -25,7 +25,7 @@ const ROLE_COLORS = {
|
||||
const TIER_COLORS = {
|
||||
free: "secondary",
|
||||
pro: "default",
|
||||
team: "default",
|
||||
family: "default",
|
||||
} as const;
|
||||
|
||||
export default async function AdminUserDetailPage({ params }: PageProps) {
|
||||
|
||||
@@ -24,7 +24,7 @@ const ROLE_COLORS = {
|
||||
const TIER_COLORS = {
|
||||
free: "secondary",
|
||||
pro: "default",
|
||||
team: "default",
|
||||
family: "default",
|
||||
} as const;
|
||||
|
||||
export default async function AdminUsersPage({ searchParams }: PageProps) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { createInvite, listInvites } from "@/lib/invites";
|
||||
import { randomUUID } from "crypto";
|
||||
|
||||
const VALID_ROLES = ["user", "moderator", "admin"] as const;
|
||||
const VALID_TIERS = ["free", "pro", "team"] as const;
|
||||
const VALID_TIERS = ["free", "pro", "family"] as const;
|
||||
|
||||
export async function GET() {
|
||||
const { response } = await requireAdmin();
|
||||
|
||||
@@ -16,7 +16,7 @@ export async function PATCH(req: NextRequest, { params }: RouteContext) {
|
||||
if (response) return response;
|
||||
|
||||
const { tier } = await params;
|
||||
if (tier !== "free" && tier !== "pro" && tier !== "team") {
|
||||
if (tier !== "free" && tier !== "pro" && tier !== "family") {
|
||||
return NextResponse.json({ error: "Invalid tier" }, { status: 400 });
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export async function PATCH(req: NextRequest, { params }: RouteContext) {
|
||||
const { role, tier } = body;
|
||||
|
||||
const validRoles = ["user", "moderator", "admin"] as const;
|
||||
const validTiers = ["free", "pro", "team"] as const;
|
||||
const validTiers = ["free", "pro", "family"] as const;
|
||||
|
||||
if (role !== undefined && !validRoles.includes(role as typeof validRoles[number])) {
|
||||
return NextResponse.json({ error: "Invalid role" }, { status: 400 });
|
||||
@@ -25,11 +25,11 @@ export async function PATCH(req: NextRequest, { params }: RouteContext) {
|
||||
return NextResponse.json({ error: "Invalid tier" }, { status: 400 });
|
||||
}
|
||||
|
||||
const updateData: Partial<{ role: "user" | "moderator" | "admin"; tier: "free" | "pro" | "team"; updatedAt: Date }> = {
|
||||
const updateData: Partial<{ role: "user" | "moderator" | "admin"; tier: "free" | "pro" | "family"; updatedAt: Date }> = {
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
if (role) updateData.role = role as "user" | "moderator" | "admin";
|
||||
if (tier) updateData.tier = tier as "free" | "pro" | "team";
|
||||
if (tier) updateData.tier = tier as "free" | "pro" | "family";
|
||||
|
||||
const [updated] = await db
|
||||
.update(users)
|
||||
|
||||
@@ -7,7 +7,7 @@ import { randomBytes, randomUUID } from "crypto";
|
||||
import { APIError } from "better-auth";
|
||||
|
||||
const VALID_ROLES = ["user", "moderator", "admin"] as const;
|
||||
const VALID_TIERS = ["free", "pro", "team"] as const;
|
||||
const VALID_TIERS = ["free", "pro", "family"] as const;
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
const { session, response } = await requireAdmin();
|
||||
|
||||
@@ -52,7 +52,7 @@ export async function POST(req: NextRequest, { params }: Params) {
|
||||
if (!configResult.ok) return configResult.response;
|
||||
const aiConfig = configResult.data;
|
||||
|
||||
const result = await withAiQuota(userId, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(userId, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
adaptRecipe(
|
||||
{
|
||||
title: recipe.title,
|
||||
@@ -80,7 +80,7 @@ export async function POST(req: NextRequest, { params }: Params) {
|
||||
}
|
||||
|
||||
try {
|
||||
await checkAndIncrementTierLimit(userId, session!.user.tier as "free" | "pro" | "team", "recipe");
|
||||
await checkAndIncrementTierLimit(userId, session!.user.tier as "free" | "pro" | "family", "recipe");
|
||||
} catch (err) {
|
||||
if (err instanceof TierLimitError) {
|
||||
return NextResponse.json({ error: "Recipe limit reached for your tier" }, { status: 403 });
|
||||
|
||||
@@ -43,7 +43,7 @@ export async function POST(req: NextRequest) {
|
||||
if (!configResult.ok) return configResult.response;
|
||||
const config = configResult.data;
|
||||
|
||||
const result = await withAiQuota(userId, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(userId, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
generateBatchCook(
|
||||
{
|
||||
dinners: parsed.data.dinners,
|
||||
|
||||
@@ -42,7 +42,7 @@ export async function POST(req: NextRequest) {
|
||||
const locale = (session!.user as { locale?: string }).locale ?? "en";
|
||||
const lang = LANG[locale] ?? "English";
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
generateText({
|
||||
model,
|
||||
system: `You are Epicure, a helpful culinary assistant answering general cooking questions — not tied to any specific recipe (techniques, substitutions, timing, equipment, food safety, etc). If asked who you are or what model/AI you're built on, say you're Epicure — never name the underlying model or provider. If a question has nothing to do with cooking or food, politely redirect. Keep answers under 200 words. Respond in ${lang}.\n\nYou have two tools. Using one only drafts something for the user to review — it never saves by itself.\n- createRecipe: the user is asking you to create, save, or write down a recipe (e.g. "make me a recipe for X", "give me a recipe for Y", "write that down"). This includes any request for a full recipe, not only ones that say the word "create" or "save".\n- addToShoppingList: the user is asking to add ingredients/items to a shopping list.\n\nIMPORTANT: when the user's request matches createRecipe, you MUST call that tool instead of writing the recipe's ingredients or steps directly in your text reply. Never output a full ingredient list or numbered steps as plain text — that content belongs in the tool call, not the message. Your text reply in that case should just be a short line like "Here's a draft — check it below and confirm if it looks right." Only skip the tool if the user is asking a general question (no specific recipe requested) or explicitly wants prose, not a structured recipe.${bioContext}`,
|
||||
|
||||
@@ -43,7 +43,7 @@ export async function POST(req: NextRequest, { params }: Params) {
|
||||
if (!configResult.ok) return configResult.response;
|
||||
const aiConfig = configResult.data;
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
suggestDrinks(
|
||||
{
|
||||
title: recipe.title,
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function POST(req: NextRequest) {
|
||||
if (!configResult.ok) return configResult.response;
|
||||
const aiConfig = configResult.data;
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
generateRecipe(parsed.data.title, {
|
||||
...aiConfig,
|
||||
userContext: privateBio ?? undefined,
|
||||
|
||||
@@ -36,7 +36,7 @@ export async function POST(req: NextRequest) {
|
||||
if (!configResult.ok) return configResult.response;
|
||||
const aiConfig = configResult.data;
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
generateRecipe(parsed.data.prompt, {
|
||||
...aiConfig,
|
||||
language: parsed.data.language,
|
||||
|
||||
@@ -42,7 +42,7 @@ export async function POST(req: NextRequest) {
|
||||
if (!textConfigResult.ok) return textConfigResult.response;
|
||||
const textConfig = textConfigResult.data;
|
||||
|
||||
const result = await withAiQuota(userId, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(userId, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
importFromPhoto(parsed.data.imageBase64, parsed.data.mimeType, visionConfig, textConfig, locale),
|
||||
{ skipQuota: visionConfig.isByok && textConfig.isByok }
|
||||
);
|
||||
|
||||
@@ -37,7 +37,7 @@ export async function POST(req: NextRequest) {
|
||||
if (!configResult.ok) return configResult.response;
|
||||
const aiConfig = configResult.data;
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
importFromUrl(parsed.data.url, aiConfig), { skipQuota: aiConfig.isByok }
|
||||
);
|
||||
if (!result.ok) return result.response;
|
||||
|
||||
@@ -75,7 +75,7 @@ export async function POST(req: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
const result = await withAiQuota(userId, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(userId, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
generateMealPlan(
|
||||
{
|
||||
dietaryPrefs: parsed.data.dietaryPrefs,
|
||||
@@ -99,7 +99,7 @@ export async function POST(req: NextRequest) {
|
||||
let chargedRecipes = 0;
|
||||
try {
|
||||
for (let i = 0; i < plan.entries.length; i++) {
|
||||
await checkAndIncrementTierLimit(userId, session!.user.tier as "free" | "pro" | "team", "recipe");
|
||||
await checkAndIncrementTierLimit(userId, session!.user.tier as "free" | "pro" | "family", "recipe");
|
||||
chargedRecipes++;
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
@@ -44,7 +44,7 @@ export async function POST(req: NextRequest, { params }: Params) {
|
||||
if (!configResult.ok) return configResult.response;
|
||||
const aiConfig = configResult.data;
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
suggestPairings(
|
||||
{
|
||||
title: recipe.title,
|
||||
|
||||
@@ -74,7 +74,7 @@ ${stepList || "None listed"}
|
||||
const locale = (session!.user as { locale?: string }).locale ?? "en";
|
||||
const lang = LANG[locale] ?? "English";
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
generateText({
|
||||
model,
|
||||
system: `You are Epicure, a helpful culinary assistant. Answer questions about the following recipe concisely and accurately. If asked who you are or what model/AI you're built on, say you're Epicure — never name the underlying model or provider. If a question is not related to the recipe or cooking, politely redirect. Keep answers under 200 words. Respond in ${lang}.
|
||||
|
||||
@@ -57,7 +57,7 @@ export async function POST(req: NextRequest) {
|
||||
? `${userContext}Generate 6 diverse recipe ideas based on: "${parsed.data.prompt}". Include a mix of difficulty levels.`
|
||||
: `${userContext}Generate 6 diverse, creative recipe ideas. Include different cuisines, difficulty levels, and meal types.`;
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
generateObject({
|
||||
model,
|
||||
schema: IdeasSchema,
|
||||
|
||||
@@ -47,7 +47,7 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
const { instruction, language, ...current } = parsed.data;
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
regenerateRecipe(current, instruction, { ...aiConfig, language }), { skipQuota: aiConfig.isByok }
|
||||
);
|
||||
if (!result.ok) return result.response;
|
||||
|
||||
@@ -44,7 +44,7 @@ export async function POST(req: NextRequest) {
|
||||
if (!configResult.ok) return configResult.response;
|
||||
const aiConfig = configResult.data;
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
scaleRecipe(
|
||||
{
|
||||
title: recipe.title,
|
||||
|
||||
@@ -40,7 +40,7 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
const locale = (session!.user as { locale?: string }).locale ?? "en";
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
substituteIngredient(parsed.data.ingredient, context, aiConfig, locale),
|
||||
{ skipQuota: aiConfig.isByok }
|
||||
);
|
||||
|
||||
@@ -42,7 +42,7 @@ export async function POST(req: NextRequest, { params }: Params) {
|
||||
if (!configResult.ok) return configResult.response;
|
||||
const aiConfig = configResult.data;
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
translateRecipe(
|
||||
{
|
||||
title: recipe.title,
|
||||
|
||||
@@ -47,7 +47,7 @@ export async function POST(req: NextRequest, { params }: Params) {
|
||||
if (!configResult.ok) return configResult.response;
|
||||
const aiConfig = configResult.data;
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
suggestVariations(
|
||||
{
|
||||
title: recipe.title,
|
||||
|
||||
@@ -36,7 +36,7 @@ export async function POST(req: NextRequest) {
|
||||
else if (aiConfig.provider === "anthropic") aiConfig.model = "claude-sonnet-4-6";
|
||||
}
|
||||
|
||||
const result = await withAiQuota(userId, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(userId, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
scanPantryPhoto(parsed.data.imageBase64, parsed.data.mimeType, aiConfig)
|
||||
);
|
||||
if (!result.ok) return result.response;
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function POST(req: NextRequest, { params }: Params) {
|
||||
if (!source) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
||||
|
||||
try {
|
||||
await checkAndIncrementTierLimit(session!.user.id, session!.user.tier as "free" | "pro" | "team", "recipe");
|
||||
await checkAndIncrementTierLimit(session!.user.id, session!.user.tier as "free" | "pro" | "family", "recipe");
|
||||
} catch (err) {
|
||||
if (err instanceof TierLimitError) {
|
||||
return NextResponse.json({ error: "Recipe limit reached for your tier" }, { status: 403 });
|
||||
|
||||
@@ -46,7 +46,7 @@ export async function POST(req: NextRequest, { params }: Params) {
|
||||
|
||||
if (!recipe) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
||||
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "team", () =>
|
||||
const result = await withAiQuota(session!.user.id, session!.user.tier as "free" | "pro" | "family", () =>
|
||||
estimateNutrition({
|
||||
title: recipe.title,
|
||||
baseServings: recipe.baseServings,
|
||||
|
||||
@@ -117,7 +117,7 @@ export async function POST(req: NextRequest) {
|
||||
}
|
||||
|
||||
try {
|
||||
await checkAndIncrementTierLimit(session!.user.id, session!.user.tier as "free" | "pro" | "team", "recipe");
|
||||
await checkAndIncrementTierLimit(session!.user.id, session!.user.tier as "free" | "pro" | "family", "recipe");
|
||||
} catch (err) {
|
||||
if (err instanceof TierLimitError) {
|
||||
return NextResponse.json({ error: "Recipe limit reached for your tier" }, { status: 403 });
|
||||
|
||||
@@ -29,7 +29,7 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
try {
|
||||
const sizeMb = Math.ceil(fileSize / (1024 * 1024));
|
||||
await checkAndIncrementTierLimit(session!.user.id, session!.user.tier as "free" | "pro" | "team", "storage", sizeMb);
|
||||
await checkAndIncrementTierLimit(session!.user.id, session!.user.tier as "free" | "pro" | "family", "storage", sizeMb);
|
||||
} catch (err) {
|
||||
if (err instanceof TierLimitError) {
|
||||
return NextResponse.json({ error: "Storage limit reached for your tier" }, { status: 403 });
|
||||
|
||||
@@ -42,7 +42,7 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
try {
|
||||
const sizeMb = Math.ceil(fileSize / (1024 * 1024));
|
||||
await checkAndIncrementTierLimit(session!.user.id, session!.user.tier as "free" | "pro" | "team", "storage", sizeMb);
|
||||
await checkAndIncrementTierLimit(session!.user.id, session!.user.tier as "free" | "pro" | "family", "storage", sizeMb);
|
||||
} catch (err) {
|
||||
if (err instanceof TierLimitError) {
|
||||
return NextResponse.json({ error: "Storage limit reached for your tier" }, { status: 403 });
|
||||
|
||||
@@ -16,7 +16,7 @@ export function CreateUserDialog() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [name, setName] = useState("");
|
||||
const [role, setRole] = useState<"user" | "moderator" | "admin">("user");
|
||||
const [tier, setTier] = useState<"free" | "pro" | "team">("free");
|
||||
const [tier, setTier] = useState<"free" | "pro" | "family">("free");
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
async function handleCreate() {
|
||||
@@ -85,7 +85,7 @@ export function CreateUserDialog() {
|
||||
<SelectContent>
|
||||
<SelectItem value="free">Free</SelectItem>
|
||||
<SelectItem value="pro">Pro</SelectItem>
|
||||
<SelectItem value="team">Team</SelectItem>
|
||||
<SelectItem value="family">Family</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
@@ -24,7 +24,7 @@ type Invite = {
|
||||
token: string;
|
||||
email: string | null;
|
||||
role: "user" | "moderator" | "admin";
|
||||
tier: "free" | "pro" | "team";
|
||||
tier: "free" | "pro" | "family";
|
||||
createdAt: string;
|
||||
expiresAt: string | null;
|
||||
};
|
||||
@@ -33,7 +33,7 @@ export function InvitesManager({ invites, appUrl }: { invites: Invite[]; appUrl:
|
||||
const router = useRouter();
|
||||
const [email, setEmail] = useState("");
|
||||
const [role, setRole] = useState<"user" | "moderator" | "admin">("user");
|
||||
const [tier, setTier] = useState<"free" | "pro" | "team">("free");
|
||||
const [tier, setTier] = useState<"free" | "pro" | "family">("free");
|
||||
const [creating, setCreating] = useState(false);
|
||||
const [revokeId, setRevokeId] = useState<string | null>(null);
|
||||
|
||||
@@ -106,7 +106,7 @@ export function InvitesManager({ invites, appUrl }: { invites: Invite[]; appUrl:
|
||||
<SelectContent>
|
||||
<SelectItem value="free">Free</SelectItem>
|
||||
<SelectItem value="pro">Pro</SelectItem>
|
||||
<SelectItem value="team">Team</SelectItem>
|
||||
<SelectItem value="family">Family</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
@@ -15,12 +15,12 @@ import { Label } from "@/components/ui/label";
|
||||
interface UserEditorProps {
|
||||
userId: string;
|
||||
currentRole: "user" | "moderator" | "admin";
|
||||
currentTier: "free" | "pro" | "team";
|
||||
currentTier: "free" | "pro" | "family";
|
||||
}
|
||||
|
||||
export function UserEditor({ userId, currentRole, currentTier }: UserEditorProps) {
|
||||
const [role, setRole] = useState<"user" | "moderator" | "admin">(currentRole);
|
||||
const [tier, setTier] = useState<"free" | "pro" | "team">(currentTier);
|
||||
const [tier, setTier] = useState<"free" | "pro" | "family">(currentTier);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
async function handleSave() {
|
||||
@@ -68,7 +68,7 @@ export function UserEditor({ userId, currentRole, currentTier }: UserEditorProps
|
||||
<SelectContent>
|
||||
<SelectItem value="free">Free</SelectItem>
|
||||
<SelectItem value="pro">Pro</SelectItem>
|
||||
<SelectItem value="team">Team</SelectItem>
|
||||
<SelectItem value="family">Family</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
@@ -54,7 +54,7 @@ type QuotaResult<T> = { ok: true; data: T } | { ok: false; response: NextRespons
|
||||
*/
|
||||
export async function withAiQuota<T>(
|
||||
userId: string,
|
||||
tier: "free" | "pro" | "team",
|
||||
tier: "free" | "pro" | "family",
|
||||
fn: () => Promise<T>,
|
||||
opts?: { skipQuota?: boolean }
|
||||
): Promise<QuotaResult<T>> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Mirrors CHANGELOG.md at the repo root — update both together.
|
||||
export const APP_VERSION = "0.46.2";
|
||||
export const APP_VERSION = "0.47.0";
|
||||
|
||||
export type ChangelogEntry = {
|
||||
version: string;
|
||||
@@ -11,6 +11,11 @@ export type ChangelogEntry = {
|
||||
};
|
||||
|
||||
export const CHANGELOG: ChangelogEntry[] = [
|
||||
{
|
||||
version: "0.47.0",
|
||||
date: "2026-07-18 00:30",
|
||||
notes: "Renamed the \"Team\" billing tier to \"Family\" (free/pro/family) — same limits, same admin editing, just the name. Existing Team users keep their tier/limits unaffected; the DB enum value itself was renamed in place (no data migration needed).",
|
||||
},
|
||||
{
|
||||
version: "0.46.2",
|
||||
date: "2026-07-17 19:20",
|
||||
|
||||
@@ -27,7 +27,7 @@ export async function createInvite(opts: {
|
||||
createdById: string;
|
||||
email?: string | null;
|
||||
role?: "user" | "moderator" | "admin";
|
||||
tier?: "free" | "pro" | "team";
|
||||
tier?: "free" | "pro" | "family";
|
||||
expiresInDays?: number | null;
|
||||
}) {
|
||||
const [invite] = await db
|
||||
|
||||
@@ -696,14 +696,14 @@ export function generateOpenApiSpec(): object {
|
||||
|
||||
const InviteRef = registry.register("Invite", z.object({
|
||||
id: z.string(), token: z.string(), email: z.string().nullable(),
|
||||
role: z.enum(["user", "moderator", "admin"]), tier: z.enum(["free", "pro", "team"]),
|
||||
role: z.enum(["user", "moderator", "admin"]), tier: z.enum(["free", "pro", "family"]),
|
||||
createdById: z.string(), createdAt: z.string().datetime(),
|
||||
expiresAt: z.string().datetime().nullable(), usedAt: z.string().datetime().nullable(),
|
||||
usedById: z.string().nullable(),
|
||||
}));
|
||||
const CreateInviteRef = registry.register("CreateInvite", z.object({
|
||||
email: z.string().optional(), role: z.enum(["user", "moderator", "admin"]).default("user"),
|
||||
tier: z.enum(["free", "pro", "team"]).default("free"), expiresInDays: z.number().default(7),
|
||||
tier: z.enum(["free", "pro", "family"]).default("free"), expiresInDays: z.number().default(7),
|
||||
}));
|
||||
|
||||
const AdminReportRef = registry.register("AdminReport", z.object({
|
||||
@@ -745,20 +745,20 @@ export function generateOpenApiSpec(): object {
|
||||
storageMb: z.number().int().optional(), maxPublicRecipes: z.number().int().optional(),
|
||||
}).describe("Each field must be a non-negative integer, or -1 for unlimited."));
|
||||
const TierDefinitionRef = registry.register("TierDefinition", z.object({
|
||||
tier: z.enum(["free", "pro", "team"]), maxRecipes: z.number().int(), aiCallsPerMonth: z.number().int(),
|
||||
tier: z.enum(["free", "pro", "family"]), maxRecipes: z.number().int(), aiCallsPerMonth: z.number().int(),
|
||||
storageMb: z.number().int(), maxPublicRecipes: z.number().int(),
|
||||
}));
|
||||
|
||||
const AdminCreateUserBodyRef = registry.register("AdminCreateUserBody", z.object({
|
||||
email: z.string(), name: z.string(), role: z.enum(["user", "moderator", "admin"]).default("user"),
|
||||
tier: z.enum(["free", "pro", "team"]).default("free"),
|
||||
tier: z.enum(["free", "pro", "family"]).default("free"),
|
||||
}));
|
||||
const AdminCreatedUserRef = registry.register("AdminCreatedUser", z.object({
|
||||
user: z.object({ id: z.string(), email: z.string(), name: z.string(), role: z.string(), tier: z.string() }),
|
||||
}));
|
||||
|
||||
const AdminUpdateUserBodyRef = registry.register("AdminUpdateUserBody", z.object({
|
||||
role: z.enum(["user", "moderator", "admin"]).optional(), tier: z.enum(["free", "pro", "team"]).optional(),
|
||||
role: z.enum(["user", "moderator", "admin"]).optional(), tier: z.enum(["free", "pro", "family"]).optional(),
|
||||
}));
|
||||
const AdminUpdatedUserRef = registry.register("AdminUpdatedUser", z.object({
|
||||
user: z.object({ id: z.string(), role: z.string(), tier: z.string() }),
|
||||
@@ -769,7 +769,7 @@ export function generateOpenApiSpec(): object {
|
||||
aiCallsUsed: z.number().int(), recipeCount: z.number().int(), storageUsedMb: z.number().int(),
|
||||
}));
|
||||
|
||||
const tierParam = z.object({ tier: z.enum(["free", "pro", "team"]) });
|
||||
const tierParam = z.object({ tier: z.enum(["free", "pro", "family"]) });
|
||||
|
||||
registry.registerPath({ method: "get", path: "/api/v1/admin/invites", summary: "List invites", description: "Admin only.", security: adminSecurity, responses: { 200: { description: "Invites", content: { "application/json": { schema: z.object({ invites: z.array(InviteRef) }) } } }, 403: { description: "Forbidden", content: { "application/json": { schema: ApiErrorRef } } } } });
|
||||
registry.registerPath({ method: "post", path: "/api/v1/admin/invites", summary: "Create an invite", description: "Admin only.", security: adminSecurity, request: { body: { content: { "application/json": { schema: CreateInviteRef } }, required: true } }, responses: { 200: { description: "Created", content: { "application/json": { schema: z.object({ invite: InviteRef }) } } }, 400: { description: "Invalid role or tier", content: { "application/json": { schema: ApiErrorRef } } }, 403: { description: "Forbidden", content: { "application/json": { schema: ApiErrorRef } } } } });
|
||||
|
||||
@@ -35,12 +35,12 @@ export class TierLimitError extends Error {
|
||||
*/
|
||||
export async function checkAndIncrementTierLimit(
|
||||
userId: string,
|
||||
fallbackTier: "free" | "pro" | "team",
|
||||
fallbackTier: "free" | "pro" | "family",
|
||||
key: "recipe" | "aiCall" | "storage",
|
||||
amount = 1
|
||||
): Promise<void> {
|
||||
const [dbUser] = await db.select({ tier: users.tier }).from(users).where(eq(users.id, userId));
|
||||
const userTier = (dbUser?.tier as "free" | "pro" | "team" | undefined) ?? fallbackTier;
|
||||
const userTier = (dbUser?.tier as "free" | "pro" | "family" | undefined) ?? fallbackTier;
|
||||
|
||||
const [tierDef] = await db
|
||||
.select()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@epicure/web",
|
||||
"version": "0.46.2",
|
||||
"version": "0.47.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
Reference in New Issue
Block a user