feat : update
This commit is contained in:
@@ -2,7 +2,7 @@ import * as z from "zod";
|
||||
|
||||
import { targetStatOptions } from "@/lib/guides/stats";
|
||||
import { parseYouTubeUrl } from "@/lib/guides/youtube";
|
||||
import { extraSheetSchema } from "@/lib/guides/extra-sheet";
|
||||
import { extraSheetSchema, normalizeExtraSheetRichText } from "@/lib/guides/extra-sheet";
|
||||
import { normalizeExtraRichText } from "@/lib/rich-text";
|
||||
|
||||
export const guideSectionKinds = ["weapon", "artifact", "constellations", "team"] as const;
|
||||
@@ -10,6 +10,11 @@ export type GuideSectionKind = (typeof guideSectionKinds)[number];
|
||||
|
||||
const percent = z.coerce.number().finite().min(-9999).max(9999);
|
||||
const catalogKey = z.string().trim().min(1).max(64);
|
||||
export const weaponRefinementSchema = z.union([
|
||||
z.number().int().min(1).max(5).transform(String),
|
||||
z.enum(["1", "2", "3", "4", "5", "1-5"]),
|
||||
]);
|
||||
export type WeaponRefinement = z.output<typeof weaponRefinementSchema>;
|
||||
|
||||
export const createGuideSchema = z.strictObject({
|
||||
characterKey: catalogKey,
|
||||
@@ -40,7 +45,7 @@ export const weaponSectionSchema = z.strictObject({
|
||||
note: z.string().trim().max(2_000).nullable(),
|
||||
rows: z.array(z.strictObject({
|
||||
weaponKey: catalogKey,
|
||||
refinement: z.number().int().min(1).max(5),
|
||||
refinement: weaponRefinementSchema,
|
||||
overallPercent: percent.nullable(),
|
||||
personalPercent: percent.nullable(),
|
||||
note: z.string().trim().max(2_000).nullable(),
|
||||
@@ -159,6 +164,7 @@ const extraRowSchema = z.strictObject({
|
||||
}).transform((row) => ({
|
||||
...row,
|
||||
body: normalizeExtraRichText(row.body, row.highlights),
|
||||
sheet: row.sheet ? normalizeExtraSheetRichText(row.sheet) : null,
|
||||
highlights: [],
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user