From 0280d564f9b0ec1964f2896292a5f88a8089a2ce Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Mon, 27 Jul 2026 19:19:41 -0400 Subject: [PATCH] feat: add faction ownership to game-structures and relax factions read access - Allow authenticated users to read factions (was developer-only) - Add optional faction relationship field to game-structures - Regenerate payload-types.ts --- src/collections/game/GameStructures.ts | 8 ++ src/collections/intelligence/Factions.ts | 2 +- src/payload-types.ts | 133 ++++++++++++----------- 3 files changed, 78 insertions(+), 65 deletions(-) diff --git a/src/collections/game/GameStructures.ts b/src/collections/game/GameStructures.ts index 9e4789d..43c87a8 100644 --- a/src/collections/game/GameStructures.ts +++ b/src/collections/game/GameStructures.ts @@ -81,6 +81,14 @@ export const GameStructures: CollectionConfig = { description: "The type of structure this is.", }, }, + { + name: "faction", + type: "relationship", + relationTo: "factions", + admin: { + description: "The faction that owns this structure.", + }, + }, { label: "Geolocation", type: "group", diff --git a/src/collections/intelligence/Factions.ts b/src/collections/intelligence/Factions.ts index 9e719f1..49a9525 100644 --- a/src/collections/intelligence/Factions.ts +++ b/src/collections/intelligence/Factions.ts @@ -11,7 +11,7 @@ export const Factions: CollectionConfig = { create: isDeveloper, update: isDeveloper, delete: isDeveloper, - read: isDeveloper, + read: ({ req }) => !!req.user, }, fields: [ { diff --git a/src/payload-types.ts b/src/payload-types.ts index 19813e5..7f73b6d 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -226,6 +226,10 @@ export interface GameStructure { * The type of structure this is. */ type: number | Structure; + /** + * The faction that owns this structure. + */ + faction?: (number | null) | Faction; /** * @minItems 2 * @maxItems 2 @@ -850,6 +854,70 @@ export interface Vehicle { updatedAt: string; createdAt: string; } +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "factions". + */ +export interface Faction { + id: number; + name: string; + type: 'majorFaction' | 'minorFaction' | 'corporation' | 'special'; + description?: { + root: { + type: string; + children: { + type: any; + version: number; + [k: string]: unknown; + }[]; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; + indent: number; + version: number; + }; + [k: string]: unknown; + } | null; + /** + * Whether or not this faction is playable. Some factions may be specifically intended to be unplayable based on narrative requirements. + */ + playableFaction?: boolean | null; + /** + * Whether or not this faction is/was available as a starting faction at the beginning of the campaign. + */ + startingFaction?: boolean | null; + associatedCampaigns?: (number | Campaign)[] | null; + updatedAt: string; + createdAt: string; +} +/** + * This interface was referenced by `Config`'s JSON-Schema + * via the `definition` "campaigns". + */ +export interface Campaign { + id: number; + name: string; + summary: string; + status: 'concept' | 'inProgress' | 'completed'; + description?: { + root: { + type: string; + children: { + type: any; + version: number; + [k: string]: unknown; + }[]; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; + indent: number; + version: number; + }; + [k: string]: unknown; + } | null; + startDate?: string | null; + endDate?: string | null; + updatedAt: string; + createdAt: string; +} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "users". @@ -1239,35 +1307,6 @@ export interface Map { updatedAt: string; createdAt: string; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "campaigns". - */ -export interface Campaign { - id: number; - name: string; - summary: string; - status: 'concept' | 'inProgress' | 'completed'; - description?: { - root: { - type: string; - children: { - type: any; - version: number; - [k: string]: unknown; - }[]; - direction: ('ltr' | 'rtl') | null; - format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; - indent: number; - version: number; - }; - [k: string]: unknown; - } | null; - startDate?: string | null; - endDate?: string | null; - updatedAt: string; - createdAt: string; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "mission-files". @@ -1311,41 +1350,6 @@ export interface ModList { focalX?: number | null; focalY?: number | null; } -/** - * This interface was referenced by `Config`'s JSON-Schema - * via the `definition` "factions". - */ -export interface Faction { - id: number; - name: string; - type: 'majorFaction' | 'minorFaction' | 'corporation' | 'special'; - description?: { - root: { - type: string; - children: { - type: any; - version: number; - [k: string]: unknown; - }[]; - direction: ('ltr' | 'rtl') | null; - format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; - indent: number; - version: number; - }; - [k: string]: unknown; - } | null; - /** - * Whether or not this faction is playable. Some factions may be specifically intended to be unplayable based on narrative requirements. - */ - playableFaction?: boolean | null; - /** - * Whether or not this faction is/was available as a starting faction at the beginning of the campaign. - */ - startingFaction?: boolean | null; - associatedCampaigns?: (number | Campaign)[] | null; - updatedAt: string; - createdAt: string; -} /** * This interface was referenced by `Config`'s JSON-Schema * via the `definition` "narrative-events". @@ -1547,6 +1551,7 @@ export interface GameHardResourcesSelect { export interface GameStructuresSelect { name?: T; type?: T; + faction?: T; coordinates?: T; storedResources?: | T