73 lines
No EOL
2.2 KiB
TypeScript
73 lines
No EOL
2.2 KiB
TypeScript
import { CollectionConfig } from "payload";
|
|
|
|
/**
|
|
* Supply crates synced from the Arma bridge mod (`box.*` event family).
|
|
*
|
|
* Rows are written only by the crate-sync handler (`src/lib/arma-bridge/crates.ts`)
|
|
* via `overrideAccess`; the admin panel and REST API are read-only for logged-in
|
|
* users. `box.deleted` never hard-deletes: it marks the row `status: deleted`
|
|
* and a later `box.register`/`box.sync` reactivates it. Every row links to the
|
|
* raw `arma-sync-events` row that produced its current state (`sourceEvent`).
|
|
*/
|
|
export const SupplyBoxes: CollectionConfig = {
|
|
slug: "supply-boxes",
|
|
admin: {
|
|
group: "Server",
|
|
useAsTitle: "boxId",
|
|
defaultColumns: ["boxId", "boxClass", "status", "server", "lastSyncedAt"],
|
|
},
|
|
access: {
|
|
read: ({ req }) => !!req.user,
|
|
create: () => false,
|
|
update: () => false,
|
|
delete: () => false,
|
|
},
|
|
fields: [
|
|
{ name: "boxId", type: "text", required: true, unique: true, index: true },
|
|
{
|
|
name: "sessionId",
|
|
type: "text",
|
|
required: true,
|
|
index: true,
|
|
admin: {
|
|
description:
|
|
"Bridge session generation id (worldName + systemTime) extracted from the boxId; used to detect stale generations after a mission restart.",
|
|
},
|
|
},
|
|
{
|
|
name: "server",
|
|
type: "relationship",
|
|
relationTo: "game-servers",
|
|
required: true,
|
|
index: true,
|
|
admin: {
|
|
description:
|
|
"Owning game server, resolved from the authenticated ingestion event. Never populated from payload content.",
|
|
},
|
|
},
|
|
{ name: "boxClass", type: "text" },
|
|
{ name: "displayName", type: "text" },
|
|
{ name: "location", type: "json" },
|
|
{ name: "contents", type: "json" },
|
|
{ name: "lastSyncedAt", type: "date", required: true },
|
|
{
|
|
name: "status",
|
|
type: "select",
|
|
required: true,
|
|
defaultValue: "active",
|
|
options: ["active", "deleted"],
|
|
index: true,
|
|
},
|
|
{
|
|
name: "sourceEvent",
|
|
type: "relationship",
|
|
relationTo: "arma-sync-events",
|
|
required: true,
|
|
index: true,
|
|
admin: {
|
|
description:
|
|
"Raw arma-sync-events row that produced the current state; provenance back to the exact mod event.",
|
|
},
|
|
},
|
|
],
|
|
}; |