feat(admin) : persist drafts and add constellation conditions
CI / Verify (push) Successful in 59s
CI / Build immutable images and deploy (push) Successful in 1m58s

This commit is contained in:
2026-09-02 12:40:13 +07:00 Unverified
parent 5a2e2e4829
commit 7708a2df31
17 changed files with 3738 additions and 100 deletions
+8 -1
View File
@@ -16,6 +16,7 @@ import { builtInTemplates } from "@/lib/templates";
import { persistTemplateApplication } from "@/lib/templates/persist";
import {
createGuide,
GuideVersionConflictError,
permanentlyDeleteGuide,
restoreGuide,
runCatalogSync,
@@ -204,13 +205,19 @@ export async function applyEditorTemplate(input: unknown): Promise<
type GuideActionResult =
| { status: "saved"; version?: number; location?: string }
| { status: "conflict"; currentVersion: number; message: string }
| { status: "error"; message: string };
type CreateGuideActionResult = Exclude<GuideActionResult, { status: "conflict" }>;
async function runGuideAction(action: () => Promise<{ version?: number }>): Promise<GuideActionResult> {
try {
const result = await action();
return { status: "saved", version: result.version };
} catch (cause) {
if (cause instanceof GuideVersionConflictError) {
return { status: "conflict", currentVersion: cause.currentVersion, message: cause.message };
}
if (cause instanceof z.ZodError) {
return { status: "error", message: cause.issues.map((issue) => issue.message).join(" • ") };
}
@@ -218,7 +225,7 @@ async function runGuideAction(action: () => Promise<{ version?: number }>): Prom
}
}
export async function createStructuredGuide(input: unknown): Promise<GuideActionResult> {
export async function createStructuredGuide(input: unknown): Promise<CreateGuideActionResult> {
await requireAdmin();
try {
const guide = await createGuide(input);