feat(guides): organize schemas and export teams
CI / Verify (push) Successful in 1m6s
CI / Build immutable images and deploy (push) Successful in 2m19s

This commit is contained in:
2026-08-29 18:52:01 +00:00 Unverified
parent ac9a733370
commit 17214a3625
13 changed files with 3751 additions and 46 deletions
+11 -1
View File
@@ -1,6 +1,10 @@
import { describe, expect, it } from "vitest";
import { cleanLunarisText, constellationSnapshot } from "@/lib/catalog/lunaris";
import {
characterDetailSchema,
cleanLunarisText,
constellationSnapshot,
} from "@/lib/catalog/lunaris";
describe("Lunaris character data", () => {
it("removes display markup from constellation text", () => {
@@ -20,4 +24,10 @@ describe("Lunaris character data", () => {
iconKey: "catalog/1/constellations/UI_Talent_Test_01.webp",
}]);
});
it("accepts characters that do not have constellations", () => {
const detail = characterDetailSchema.parse({ constellations: null });
expect(constellationSnapshot(detail, (icon) => icon)).toEqual([]);
});
});
+2 -2
View File
@@ -14,7 +14,7 @@ const constellationSchema = z.object({
});
export const characterDetailSchema = z.object({
constellations: z.record(z.string(), constellationSchema),
constellations: z.record(z.string(), constellationSchema).nullish(),
});
export function cleanLunarisText(value: string): string {
@@ -32,7 +32,7 @@ export function constellationSnapshot(
const result: CatalogConstellation[] = [];
for (const index of Array.from({ length: 6 }, (_, itemIndex) => itemIndex)) {
const level = index + 1;
const item = value.constellations[`const${level}`];
const item = value.constellations?.[`const${level}`];
if (!item) continue;
result.push({
level,
+40
View File
@@ -125,4 +125,44 @@ export async function getLatestCatalogSyncJob() {
return job ?? null;
}
export async function getPublicTeamExport(teamId: string) {
const [row] = await getDb()
.select({ team: teamCompositions, guide: guides })
.from(teamCompositions)
.innerJoin(guides, eq(guides.id, teamCompositions.guideId))
.innerJoin(
guideSections,
and(
eq(guideSections.guideId, guides.id),
eq(guideSections.slug, "team"),
eq(guideSections.enabled, true),
),
)
.where(and(eq(teamCompositions.id, teamId), isNull(guides.trashedAt)))
.limit(1);
if (!row) return null;
const members = await getDb()
.select({ member: teamMembers, character: catalogCharacters })
.from(teamMembers)
.innerJoin(
catalogCharacters,
and(
eq(catalogCharacters.version, teamMembers.catalogVersion),
eq(catalogCharacters.key, teamMembers.characterKey),
),
)
.where(eq(teamMembers.teamId, teamId))
.orderBy(asc(teamMembers.position));
return {
...row.team,
guideName: row.guide.name,
members: members.map(({ member, character }) => ({
...member,
character: catalogCharacterWithUrls(character),
})),
};
}
export type PublicGuide = NonNullable<Awaited<ReturnType<typeof getPublicGuide>>>;