chore: remove MVP positioning and align plan defaults (#15)
## Summary - remove MVP wording from repository docs and guidance - rename the system plan document and update references to it - align the default subscription plan code/name with product wording - document hard subscription expiry with no grace period ## Verification - docker build -f infra/docker/web.Dockerfile . - docker build -f infra/docker/migrate.Dockerfile . Co-authored-by: sirily <sirily@git.shararam.party> Reviewed-on: #15
This commit was merged in pull request #15.
This commit is contained in:
@@ -4,7 +4,7 @@ Database package for `nproxy`.
|
||||
|
||||
## Implemented in this iteration
|
||||
- Prisma package scaffold
|
||||
- Initial Prisma schema for MVP persisted state
|
||||
- Current Prisma schema for persisted state
|
||||
- Shared schema path export for runtime tooling
|
||||
|
||||
## Current scope
|
||||
|
||||
@@ -73,7 +73,7 @@ export function createPrismaAuthStore(database: PrismaClient = defaultPrisma) {
|
||||
return database.$transaction(async (transaction) => {
|
||||
const defaultPlan = await transaction.subscriptionPlan.findFirst({
|
||||
where: {
|
||||
code: "mvp_monthly",
|
||||
code: "monthly",
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -10,8 +10,8 @@ export interface SubscriptionPlanSeedInput {
|
||||
}
|
||||
|
||||
export const defaultSubscriptionPlanSeed: SubscriptionPlanSeedInput = {
|
||||
code: "mvp_monthly",
|
||||
displayName: "MVP Monthly",
|
||||
code: "monthly",
|
||||
displayName: "Monthly",
|
||||
monthlyRequestLimit: 100,
|
||||
monthlyPriceUsd: 9.99,
|
||||
billingCurrency: "USDT",
|
||||
@@ -21,6 +21,8 @@ export async function ensureSubscriptionPlan(
|
||||
input: SubscriptionPlanSeedInput,
|
||||
database: PrismaClient = defaultPrisma,
|
||||
): Promise<void> {
|
||||
await reconcileDefaultSubscriptionPlan(input, database);
|
||||
|
||||
await database.subscriptionPlan.upsert({
|
||||
where: {
|
||||
code: input.code,
|
||||
@@ -48,3 +50,47 @@ export async function ensureDefaultSubscriptionPlan(
|
||||
): Promise<void> {
|
||||
await ensureSubscriptionPlan(defaultSubscriptionPlanSeed, database);
|
||||
}
|
||||
|
||||
async function reconcileDefaultSubscriptionPlan(
|
||||
input: SubscriptionPlanSeedInput,
|
||||
database: PrismaClient,
|
||||
): Promise<void> {
|
||||
const existing = await database.subscriptionPlan.findUnique({
|
||||
where: {
|
||||
code: input.code,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (existing) {
|
||||
return;
|
||||
}
|
||||
|
||||
const candidate = await database.subscriptionPlan.findFirst({
|
||||
where: {
|
||||
monthlyRequestLimit: input.monthlyRequestLimit,
|
||||
monthlyPriceUsd: new Prisma.Decimal(input.monthlyPriceUsd),
|
||||
billingCurrency: input.billingCurrency,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
},
|
||||
});
|
||||
|
||||
if (!candidate) {
|
||||
return;
|
||||
}
|
||||
|
||||
await database.subscriptionPlan.update({
|
||||
where: {
|
||||
id: candidate.id,
|
||||
},
|
||||
data: {
|
||||
code: input.code,
|
||||
displayName: input.displayName,
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user