REC_ItemManager
Stracture
Welcome to REC_ItemManager documentation.
- Added
- Updated
config/sv_config.lua
---[[
--- REC_ItemManager server config
--- What each setting does, and why the defaults are what they are:
--- https://docs.re-cord.dev/en/resources/rec_itemmanager
---]]
---@type REC_Library.Server.Class.Web.WebConfig
local webConfig = require "@REC_Library.server.class.web.sv_webConfig"
---@type REC_Library.Server.Class.Web.WebConfigStore
local WebConfigStore = require "@REC_Library.server.class.web.sv_webConfigStore"
---@type REC_Library.Server.Class.Staff.StaffConfig
local staffConfig = require "@REC_Library.server.class.staff.sv_staffConfig"
---[[
--- Settings the admin panel owns
--- They are declared in server/sv_settings.lua (value, range and description) and
--- changed from the panel, so they are not repeated here.
---]]
---@type REC_ItemManager.Server.Settings
local settings = require "@REC_ItemManager.server.sv_settings"
---@class REC_ItemManager.Server.Config
local config = {}
---[[
--- Debug Mode
---]]
---@type boolean
config.debugMode = true
---[[
--- Change log webhook
--- The retention and page size belong to the admin panel. The url stays here,
--- because a read only token can see that page and a webhook url is a credential.
--- set REC_ItemManager:logWebhook "https://discord.com/api/webhooks/..."
---]]
config.log = {
---@type string
webhook = GetConvar(GetCurrentResourceName() .. ":logWebhook", ""),
---@type string
webhookName = "REC_ItemManager",
}
---[[
--- Shop price sync
--- The toggle belongs to the admin panel. Only the currency list stays here: it
--- decides what counts as a store price at all, which is not a runtime knob.
---]]
config.shopSync = {
---[[
--- Currencies treated as a store price
--- A slot paid for in black_money is an illegal market rate, not a store
--- price, so it is left alone unless you add it here.
---]]
---@type table<string, boolean>
currencies = {
["money"] = true,
-- ["black_money"] = true,
},
}
---[[
--- Characters left out of the circulation count entirely
--- Their inventories, stashes and vehicle storage are skipped by the walk, so an
--- admin holding a crate of anything never moves the market price.
---
--- The shared list lives in REC_Library server/sv_config.lua and covers every
--- REC_* resource at once. A convar does the same without touching a file:
--- set REC:staffCitizenIds "ABCDEFGH, K3PQ81ZR"
--- set REC_ItemManager:staffCitizenIds "ABCDEFGH" # this panel alone
---]]
config.staff = staffConfig:build({
---[[
--- Added on top of the shared list, never replacing it
--- An empty one changes nothing, so the shared list still applies.
---]]
---@type string[]
-- citizenIds = {
-- "ABCDEFGH",
-- },
-- false counts staff like anyone else, so the circulation covers every character
-- enabled = false,
-- false drops the shared list, leaving only the citizenIds above
-- useSharedList = false,
-- replaces { "admin" }, and is only read where a source is known but the
-- character is not. The item walk is all citizenIds, so it changes nothing here
-- aceGroups = {
-- "admin",
-- "moderator",
-- },
})
---[[
--- Admin UI
--- The in-game UI (/itemmanager) is always available and is gated by aceGroups.
--- http below only affects the browser route.
---
--- Tokens, dist dir and the address allowlist are shared defaults from
--- REC_Library. One convar covers every REC_* panel, so set these once:
--- set REC:adminToken "xxxxx"
--- set REC:supportToken "yyyyy"
--- set REC:allowedAddresses "192.168.1.0/24" # opens the LAN everywhere
---
--- Naming this resource narrows one of them to this panel alone:
--- set REC_ItemManager:supportToken "zzzzz"
---]]
config.web = webConfig:build(config.debugMode, {
---[[
--- Permission areas this resource understands, as "<area>:read" / "<area>:write"
---]]
---@type string[]
areas = {
"items", -- the item table and its holders (write edits cost / markup)
"market", -- the market revision status
"logs", -- the change log and the price history
"watchlist", -- the watched characters and what they gained (write edits the list)
"settings", -- the runtime config overrides (write changes them)
},
---[[
--- Who opens the in-game panel, and what they may do once inside
--- Added on top of the shared list in REC_Library (admin, full access), so
--- naming one narrow grant here can never drop the row that lets an admin in.
--- Every entry that matches contributes its scopes, and a player holding two
--- of them gets the union. There is no deny form: to take something away,
--- stop granting it. Naming both an ace and a job means the player needs both.
---]]
---@type REC_Library.Server.Class.Web.WebConfig.Grant[]
grants = {
-- a read only admin used to be "in aceGroups but not editorAceGroups"
-- { ace = "moderator", scopes = { "read", }, },
},
-- false leaves the shared list out, so only the grants above count here
-- useSharedGrants = false,
http = {
---@type boolean
enabled = true, -- RELEASE:false
-- where the built panel lives, relative to this resource
-- distDir = "web/build",
-- replaces the convar built admin/support pair entirely, which puts a literal
-- token in this file: reach for customTokens below instead
-- tokens = {
-- ["a-literal-token"] = { label = "audit", scopes = { "read" }, },
-- },
---[[
--- Resource and directory the item images come from
--- Left empty the inventory adapter answers instead (ox_inventory ->
--- ox_inventory/web/images), so only override this when the sprites live
--- somewhere the adapter does not know about.
---]]
images = {
---@type string
resource = "",
---@type string
dir = "",
},
-- named tokens beyond admin/support, each scoped on its own: https://docs.re-cord.dev/en/resources/rec_library/web-config
-- customTokens = {
-- { name = "itemsOnly", scopes = { "items" }, },
-- { name = "fullAccess", scopes = { "*" }, },
-- },
-- replaces the convar-built address list entirely, keep loopback in it
-- allowedAddresses = {
-- "127.0.0.0/8",
-- "192.168.1.0/24",
-- },
-- trustedProxies = {
-- "10.0.0.5",
-- },
},
}) --[[@as REC_ItemManager.Server.Config.Web]]
-- put the panel owned defaults in place before anything reads them
WebConfigStore.seed(config, settings.list)
return config
---@class REC_ItemManager.Server.Config.Web: REC_Library.Server.Class.Web.WebConfig.Result
---@class REC_ItemManager.Server.Config
---@field staff REC_Library.Server.Class.Staff.Staff
