Reward users for helping build the app: wiki pages, mission planning markers (queued until the mission completes), surveys, and manual awards. Contribution XP folds into the existing virtual profile total, so it flows into the level ladder, sidebar XP display, dashboard, and profile. - contribution-entries ledger collection + profile progression.contributions.xpEarned bucket - src/lib/contributions service (record/grant/expire/revoke, caps, idempotency, leaderboard) with a pure rules module - per-mission planning-map delegation (missions:update grants) and a completed/cancelled map lock - wiki, survey, and marker action/hook integration - contribution:* event types, muteable notifications, permissions group, event targets - profile Contributions section and /contributions leaderboard - migration, reconcile tool, and integration tests
6.1 KiB
6.1 KiB
AGENTS.md — Payload Collections
Parent:
../../AGENTS.md— commands, RBAC basics, Payload CMS config.
Overview
55 files (~54 collections) across 15 domain groups. Access control defined in src/permissions/index.ts (~880 lines, permission registry across groups). RBAC check: hasPermission(payload, user, "collection:action").
Structure
collections/
Media.ts # Image uploads (public read; used by wiki image upload)
Shims.ts # Global: audience-targeted content (admin-only)
Announcements.ts # Banner/modal/dialog/toast announcements (admin-authored, client-evaluated)
users/ 12 files # Users (auth), Ranks, Profiles (incl. minigame stats), Awards,
# Qualifications, Assignments, AssignmentTransfers, Experience,
# Evaluations, Roles (dynamic RBAC), UserNotifications,
# ContributionEntries (crowdsourced XP ledger)
intelligence/ 5 files # Missions, MissionAttendances, MissionRoleSignups,
# MissionMapMarkers (planning-map markers), Campaigns, Factions, Technologies
logistics/ 5 files # Structures (staffing defaults), Resources, Assets, Vehicles, Shipments
banking/ 3 files # BankAccounts, BankTransactions, LedgerEntries
market/ 3 files # MarketListings, MarketNegotiations, MarketState (supply/demand ledger, one doc per tradeable resource/asset)
locker/ 2 files # LockerStorages, Loadouts
game/ 9 files # GameRules (global, currency + staffing flags), GameStructures,
# GameVehicles, GameNpcs, GameHardResources, GameEventLogs,
# NpcStaffing, LaborClassifications (+ shared staffingFields.ts factory)
server/ 5 files # MissionFiles, ModLists, GameServers, ArmaCommands, ArmaSyncEvents
world/ 5 files # Maps (basemap config), MapRoads/MapZones/ResourceNodes (map features), NarrativeEvents
projects/ 4 files # Projects, Labels, Releases, Sprints (Jira-like)
tickets/ 2 files # Tickets (Lexical rich text; `archived` hides from all front-ends, admin panel only), TicketVotes
wiki/ 3 files # WikiPages, WikiRevisions, WikiTemplates
story/ 3 files # StoryBeats (Chronicle chapters), StoryBeatStates (read markers/reactions),
# Voiceovers (audio narration uploads for the Chronicle, attached to beats)
Key relationships
Users ──┬── Profiles ──┬── Qualifications
│ ├── Awards
│ ├── Assignments ── Ranks
│ ├── AssignmentTransfers
│ └── Experience
├── UserNotifications
├── Evaluations
└── BankAccounts ── BankTransactions ── LedgerEntries
GameStructures ── Structures (template) ── Resources/Assets/Vehicles
GameStructures ── NpcStaffing ── LaborClassifications
GameVehicles ── Vehicles (template)
GameNpcs ── MarketListings ── MarketNegotiations
MissionAttendances ── Missions ── Campaigns
MissionMapMarkers ── Missions (removed by Missions beforeDelete)
Access control pattern
Collections define access at field + document level using helpers from src/utils/access-control/:
isRole(role)— single role checkhasRoles(roles[])— any-of role checkhasPermission(payload, user, "collection:action")— full RBAC (cached 30s)hasLogisticsQualification()/hasIntelligenceQualification()— queries Profiles- Legacy role enum on Users:
guest,user,admin,developer. Full RBAC lives insrc/permissions/index.ts+ the dynamicRolescollection.
Admin group access: developer only for destructive operations, admin for read/write.
Permission tiers and panel gates:
system:admin-access("Superuser Tier" label) = functional superuser tier: final approval states (approvalStatusFieldAccess), Users admin page, read-all notifications. Only built-inadmin+ superuser roles hold it; NEVER grant to division roles.- Admin panel ENTRY: Users collection
access.adminusescanAccessAdminPanel(superuser OR anyadmin:<slug>:manage). Per-page sidebar visibility:requireAdminPageAccess(<slug>:read+admin:<slug>:manage). Two gates, do not collapse them. - Payload 3 field-level
accessreturningfalseon update silently drops the field (no 403, success toast); the document saves with the previous value. Loud rejection or hidden options require abeforeChangehook or custom admin field component.
Hooks with side effects
StructuresbeforeChange: emitsstructure:resize; blueprint "Staffing Defaults" group viastaffingFields.tsGameStructuresafterChange: emits storage edit events;beforeChangecopies blueprint staffing defaults on createUsersafterChange: maintains profile syncBankTransactionsbeforeValidate: auto-generatestransactionNumberMarketNegotiations: patience meter enforcement
Where to look
| Task | Path |
|---|---|
| Add a new collection | Create <Name>.ts here, register in src/payload.config.ts |
| Add RBAC permission | src/permissions/index.ts (add to group + add check) |
| Modify collection access | <collection>/access.ts or inline in collection file |
| Add field hook | Inline in collection definition (beforeChange/afterChange) |
| Relationship graph | See key relationships above; Payload manages FK constraints |
Anti-patterns
- NEVER edit
src/payload-types.tsorsrc/payload-generated-schema.ts— runbun run generate:typesinstead - NEVER add
accessfunctions that callpayload.auth()without handling the null user case - NEVER use
payload.createinafterChangehooks without checking for infinite loops - NEVER mix
overrideAccess: truewithout a permission check — always gate behind RBAC first