Initial commit: page-manager Next.js app with Coolify deploy support

Replace Vercel-specific infra (Cron, Blob) with self-hosted equivalents
for deployment to Coolify: in-container cron scheduler
(scripts/cron-runner.mjs) and disk-based upload storage served via
/api/uploads/[...path]. Add Dockerfile, .dockerignore, and /api/health
for container health checks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
chaloemphong
2026-11-22 11:52:17 +07:00
commit 9d32552457
155 changed files with 22174 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
import type { PageRole } from "@prisma/client";
// Client-safe: no Prisma runtime import, only types.
const RANK: Record<PageRole, number> = { VIEWER: 0, EDITOR: 1, APPROVER: 2, MANAGER: 3 };
export function roleAtLeast(role: PageRole | null | undefined, min: PageRole): boolean {
if (!role) return false;
return RANK[role] >= RANK[min];
}
export const PAGE_ROLE_LABEL: Record<PageRole, string> = {
VIEWER: "ดูอย่างเดียว",
EDITOR: "ผู้เขียน",
APPROVER: "ผู้อนุมัติ",
MANAGER: "ผู้จัดการเพจ",
};
export const PAGE_ROLES: PageRole[] = ["VIEWER", "EDITOR", "APPROVER", "MANAGER"];
/** Minimum page role per action — the single source of truth for the permission table in docs/ARCHITECTURE.md. */
export const ACTION_MIN_ROLE = {
view: "VIEWER",
editPost: "EDITOR",
replyInbox: "EDITOR",
approvePost: "APPROVER",
publishPost: "APPROVER",
editRules: "APPROVER",
editProfile: "APPROVER",
manageMembers: "MANAGER",
analyzePage: "MANAGER",
} as const satisfies Record<string, PageRole>;
export type PageAction = keyof typeof ACTION_MIN_ROLE;
export const ACTION_DENIED_MESSAGE: Record<PageAction, string> = {
view: "คุณไม่มีสิทธิ์เข้าถึงเพจนี้",
editPost: "ต้องเป็นผู้เขียนขึ้นไปถึงจะแก้โพสต์ได้",
replyInbox: "ต้องเป็นผู้เขียนขึ้นไปถึงจะตอบข้อความได้",
approvePost: "ต้องเป็นผู้อนุมัติขึ้นไปถึงจะอนุมัติได้",
publishPost: "ต้องเป็นผู้อนุมัติขึ้นไปถึงจะเผยแพร่ได้",
editRules: "ต้องเป็นผู้อนุมัติขึ้นไปถึงจะแก้ auto-reply ได้",
editProfile: "ต้องเป็นผู้อนุมัติขึ้นไปถึงจะแก้โปรไฟล์ร้านได้",
manageMembers: "ต้องเป็นผู้จัดการเพจถึงจะจัดการสมาชิกได้",
analyzePage: "ต้องเป็นผู้จัดการเพจถึงจะเริ่มวิเคราะห์และวางงบได้",
};