The Chronicle collections were auto-labeled from their slugs ("Story
Beats"). Give them explicit Chronicle labels and adopt the word
Chronicle in the surrounding titles, descriptions, and event text.
- StoryBeats: labels Chronicle Entry/Entries, admin group Story ->
Chronicle, descriptions updated
- Voiceovers / StoryBeatStates: Chronicle labels, group, descriptions
(including the "beat" field label)
- GameEventLogs: event-log target labels -> Chronicle Entries / States
- lib/story: event message text -> "chronicle entry" (internal
event-type strings left intact so existing logs stay valid)
- regenerate payload-types.ts
Slugs are unchanged, so no migration is required.
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import path from "path";
|
|
import type { CollectionConfig } from "payload";
|
|
import hasRoles from "@/utils/access-control/hasRoles";
|
|
|
|
function isStoryAuthor(user: Parameters<typeof hasRoles>[1]): boolean {
|
|
return hasRoles(["admin", "developer"], user);
|
|
}
|
|
|
|
export const Voiceovers: CollectionConfig = {
|
|
slug: "story-voiceovers",
|
|
labels: {
|
|
singular: "Chronicle Voiceover",
|
|
plural: "Chronicle Voiceovers",
|
|
},
|
|
admin: {
|
|
group: "Chronicle",
|
|
useAsTitle: "filename",
|
|
defaultColumns: ["filename", "mimeType", "updatedAt"],
|
|
description:
|
|
"Audio narrations for Chronicle entries. Attach to an entry via its Voiceover field.",
|
|
},
|
|
access: {
|
|
read: ({ req }) => Boolean(req.user),
|
|
create: ({ req }) => isStoryAuthor(req.user),
|
|
update: ({ req }) => isStoryAuthor(req.user),
|
|
delete: ({ req }) => isStoryAuthor(req.user),
|
|
},
|
|
// staticDir must be set explicitly: Payload defaults an upload collection's
|
|
// staticDir to its slug resolved from cwd (dist/collections/config/sanitize.js),
|
|
// which would write files to <cwd>/story-voiceovers and miss the persistent
|
|
// /app/media volume in production. media/ is gitignored.
|
|
upload: {
|
|
staticDir: path.resolve(process.cwd(), "media", "story-voiceovers"),
|
|
mimeTypes: ["audio/*"],
|
|
},
|
|
fields: [
|
|
{
|
|
name: "aiGenerated",
|
|
type: "checkbox",
|
|
label: "AI-generated",
|
|
defaultValue: false,
|
|
admin: {
|
|
description:
|
|
"Tick if this narration was generated by AI (text-to-speech) rather than recorded by a person. Adds a note under the player on /story.",
|
|
},
|
|
},
|
|
],
|
|
};
|