1
0
Fork 0
polaris-task-force/src/collections/world/NarrativeEvents.ts
Z8MB1E 653caa8064 feat(rbac): migrate collection access controls to RBAC permissions
Replace legacy isDeveloper/isAdmin/hasRoles checks with
hasPermission/requirePermission across all collections. Add roleDocs
relationship to Users, enlistmentDate to Profiles, and field-level
intel_excerpt permission gate on Profiles. Auto-generated payload-types
updated to reflect the new Roles collection and roleDocs field.
2026-08-19 19:47:51 -04:00

89 lines
2.4 KiB
TypeScript

import { CollectionConfig } from "payload";
import { requirePermission } from "@/utils/access-control/hasPermission";
export const NarrativeEvents: CollectionConfig = {
slug: "narrative-events",
admin: {
group: "World",
useAsTitle: "name",
},
access: {
create: requirePermission("narrative-events:create"),
update: requirePermission("narrative-events:update"),
delete: requirePermission("narrative-events:delete"),
read: requirePermission("narrative-events:read"),
},
fields: [
{
name: "name",
type: "text",
required: true,
admin: {
description: "The title of this narrative event chain.",
},
},
{
name: "summary",
type: "textarea",
required: true,
admin: {
description: "A brief summary of what this event is about.",
},
},
{
type: "tabs",
tabs: [
{
label: "Flow Editor",
description: "Build the narrative flowchart by adding beats, choices, and outcomes.",
fields: [
{
name: "flowData",
type: "json",
required: true,
defaultValue: () => ({
nodes: [],
edges: [],
}),
admin: {
components: {
Field: "@/components/admin/narrative-flow/NarrativeFlowEditor",
},
},
},
],
},
{
label: "Event Configuration",
description: "Configure trigger conditions and other metadata.",
fields: [
{
name: "triggers",
type: "group",
fields: [
{
name: "type",
type: "select",
options: [
{ label: "Manual", value: "manual" },
{ label: "On Mission Complete", value: "mission_complete" },
{ label: "On Timer", value: "timer" },
{ label: "On Condition", value: "condition" },
],
defaultValue: "manual",
},
{
name: "condition",
type: "json",
admin: {
description: "Optional JSON conditions for when this event can fire.",
},
},
],
},
],
},
],
},
],
};