From e75865865fb37d03651af2577390501a4b12ceb3 Mon Sep 17 00:00:00 2001 From: chenhang Date: Tue, 30 Jun 2026 17:37:53 +0800 Subject: [PATCH] chore(architecture): enforce app data boundaries --- eslint.config.mjs | 31 +++++++++++++++++++++++++++ src/app/subscription/success/page.tsx | 4 ++-- src/lib/payment/payment_status.ts | 11 ++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/lib/payment/payment_status.ts diff --git a/eslint.config.mjs b/eslint.config.mjs index 05e726d1..6217fd56 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -5,6 +5,37 @@ import nextTs from "eslint-config-next/typescript"; const eslintConfig = defineConfig([ ...nextVitals, ...nextTs, + { + files: ["src/app/**/*.{ts,tsx}"], + ignores: ["src/app/api/**", "src/app/**/route.ts"], + rules: { + "no-restricted-imports": [ + "error", + { + patterns: [ + { + group: [ + "@/data/repositories", + "@/data/repositories/*", + "@/data/repositories/**", + ], + message: + "App UI should depend on stores or lib use-case helpers instead of repositories.", + }, + { + group: [ + "@/data/storage", + "@/data/storage/*", + "@/data/storage/**", + ], + message: + "App UI should not access storage directly; move persistence behind lib or stores.", + }, + ], + }, + ], + }, + }, // Override default ignores of eslint-config-next. globalIgnores([ // Default ignores of eslint-config-next: diff --git a/src/app/subscription/success/page.tsx b/src/app/subscription/success/page.tsx index fa234f13..47b8c737 100644 --- a/src/app/subscription/success/page.tsx +++ b/src/app/subscription/success/page.tsx @@ -16,7 +16,7 @@ import Link from "next/link"; import { useRouter } from "next/navigation"; import { MobileShell } from "@/app/_components/core/mobile-shell"; -import { getPaymentRepository } from "@/data/repositories/payment_repository"; +import { getCurrentVipPaymentStatus } from "@/lib/payment/payment_status"; import { ROUTES } from "@/router/routes"; export default function SubscriptionSuccessPage() { @@ -33,7 +33,7 @@ export default function SubscriptionSuccessPage() { let cancelled = false; const tryRefresh = async (attemptsLeft: number) => { if (cancelled) return; - const r = await getPaymentRepository().getVipStatus(); + const r = await getCurrentVipPaymentStatus(); if (cancelled) return; if (r.success) { if (r.data.isVip) { diff --git a/src/lib/payment/payment_status.ts b/src/lib/payment/payment_status.ts new file mode 100644 index 00000000..09501349 --- /dev/null +++ b/src/lib/payment/payment_status.ts @@ -0,0 +1,11 @@ +"use client"; + +import type { PaymentVipStatusResponse } from "@/data/dto/payment"; +import { getPaymentRepository } from "@/data/repositories/payment_repository"; +import type { Result } from "@/utils"; + +export function getCurrentVipPaymentStatus(): Promise< + Result +> { + return getPaymentRepository().getVipStatus(); +}