A store record is a name and a catalog

Both extras go. `config` was added this morning on the idea that the registry should
say how each store behaves; that was wrong. The configuration is fixed per installed
client — the client carries its own store engine and knows its own machine — so a copy
here was a second authority over decisions the client had already made correctly,
including which directories it may delete from. Keeping two stores on one machine apart
is a subfolder, and the client derives that itself.

`store_repository_url` goes with it. The store engines it pointed at no longer exist, and
a URL nobody follows is a URL that goes stale.

The public stores page loses its desktop card for the same reason: it advertised a
`curl … | sh` for a repository that is gone, and an ordinary computer is served by the
app in the section above it. `/desktop` now lands on that app rather than on a device
tab, so the old URL still means what someone typing it wants.

Unrelated but in the way: the dead `engines` list in that page has been failing
`vue-tsc` on master, so the frontend could not be built to check any of this. Removed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-19 07:19:52 +02:00
co-authored by Claude Opus 5
parent 9255a11254
commit 021f2b9b07
14 changed files with 51 additions and 245 deletions
+5 -33
View File
@@ -1,5 +1,5 @@
ActiveAdmin.register Store do
permit_params :name, :catalog_url, :store_repository_url, :config_json
permit_params :name, :catalog_url
menu priority: 5, label: "🛒 Stores"
@@ -10,19 +10,12 @@ ActiveAdmin.register Store do
column :catalog_url do |store|
link_to store.catalog_url, store.catalog_url, target: "_blank", rel: "noopener"
end
column :store_repository_url do |store|
link_to store.store_repository_url, store.store_repository_url, target: "_blank", rel: "noopener"
end
column :config do |store|
store.config.blank? ? status_tag("engine defaults") : status_tag("configured", class: "ok")
end
column :updated_at
actions
end
filter :name
filter :catalog_url
filter :store_repository_url
show do
attributes_table do
@@ -31,25 +24,14 @@ ActiveAdmin.register Store do
row :catalog_url do |store|
link_to store.catalog_url, store.catalog_url, target: "_blank", rel: "noopener"
end
row :store_repository_url do |store|
link_to store.store_repository_url, store.store_repository_url, target: "_blank", rel: "noopener"
end
row :config do |store|
if store.config.blank?
"— the client uses the store engine's defaults"
else
pre JSON.pretty_generate(store.config)
end
end
row :created_at
row :updated_at
end
para do
"Listed by GET /api/stores, which the desktop client reads on first run. The " \
"config above is what the client applies, pointed at the catalog above; leave " \
"it empty and the client uses the store engine's defaults, which need nothing " \
"but the name and the catalog. The client always takes the name, the catalog " \
"and the store's slug from this record, whatever the config says."
"Listed by GET /api/stores, which the graphical client reads on first run. A name " \
"and a catalog are the whole record: the client carries its own store engine " \
"and configures itself from this much, deriving the store's slug from the " \
"catalog host."
end
end
@@ -57,16 +39,6 @@ ActiveAdmin.register Store do
f.inputs do
f.input :name, hint: "What the client shows in its store picker"
f.input :catalog_url, hint: "Base URL of the WarpEngine catalog, e.g. https://teletypegames.org"
f.input :store_repository_url,
hint: "Optional, and only a pointer for a person now: where this store's " \
"own repository is, if it has one. Clients from before the config " \
"field below still fetch a config.json from it"
f.input :config_json, as: :text, input_html: { rows: 20, style: "font-family: monospace" },
label: "Config (JSON)",
hint: "Optional. The store's own configuration — platforms, release " \
"statuses, where games land — in the shape a store's config.json " \
"had. Leave it empty and the client uses the store engine's " \
"defaults. Invalid JSON is refused with the text kept"
end
f.actions
end
@@ -6,26 +6,16 @@ class Api::StoresController < ApiController
api :GET, "/api/stores", "List the stores a client can install from"
desc <<~DESC
The registry the graphical desktop client reads on first run: which catalogs
exist, and how each store behaves. Public on purpose: a client has nobody to log
in as.
exist. Public on purpose: a client has nobody to log in as.
A record needs a name and a catalog URL. Both other fields are optional and answer
`null` when unset. `config` is the store's own configuration, in the shape a
store's `config.json` had a client applies it and takes the name, the catalog and
the store's slug from this record regardless. With no `config` a client uses the
store engine's built-in defaults, so neither a config nor a repository has to exist
for a store to be installable.
`storeRepositoryUrl` is a pointer to the store's own repository where it has one.
Clients released before `config` existed fetch a `config.json` from it instead.
A name and a catalog URL are the whole record. How a store behaves is fixed per
installed client it carries its own store engine and knows its own machine so
the registry says what a store *is* and nothing about how it works.
DESC
returns code: 200, desc: "Array of stores" do
property :name, String, desc: "Display name of the store"
property :catalogUrl, String, desc: "Base URL of the WarpEngine catalog it serves"
property :storeRepositoryUrl, [String, nil],
desc: "The store's own repository, or null when it has none"
property :config, [Hash, nil],
desc: "The store's configuration, or null when it uses the engine's defaults"
end
def index
render json: StoreService.new.index
+10 -58
View File
@@ -1,73 +1,25 @@
# A store a client can install from: a WarpEngine catalog, and — optionally — the
# configuration that says how that store behaves.
# A store a client can install from: a name and a WarpEngine catalog.
#
# This is deliberately not part of WarpEngine. The engine serves one catalog and
# has no business knowing which stores exist for it; the registry is a property of
# this site, which is what the graphical client asks.
# That is the whole record, and deliberately so. A client takes identity from it — the
# name, the catalog, and a slug derived from the catalog host — and everything else from
# the store engine it carries. How a store behaves is fixed per installed client, which
# knows its own machine; a copy of it here would be a second authority over decisions
# the client has already made, including which directories it may delete from.
#
# Both extras are optional, because a store needs neither. A client takes identity
# from this record — the name, the catalog and a slug derived from it — and everything
# else from the store engine's built-in defaults.
#
# `config` is that store's own configuration: which platforms it offers, which release
# statuses it shows, where its games land. It used to be a `config.json` in a
# repository the client fetched; carrying it here makes this record the one source of
# truth and removes a second thing that had to exist and stay reachable.
#
# `store_repository_url` is now only a pointer for a person — where the store's own
# repository is, when it has one. A client that predates `config` still reads a
# `config.json` from it, which is why it stays.
# This is deliberately not part of WarpEngine. The engine serves one catalog and has no
# business knowing which stores exist for it; the registry is a property of this site,
# which is what the graphical client asks.
class Store < ApplicationRecord
URL = %r{\Ahttps?://\S+\z}
validates :name, presence: true
validates :catalog_url, presence: true, format: { with: URL, message: "must be an http(s) URL" }
validates :store_repository_url, format: { with: URL, message: "must be an http(s) URL" },
allow_blank: true
validate :config_must_be_an_object
validate :config_json_must_parse
default_scope { where(deleted_at: nil) }
scope :ordered, -> { order(:name) }
def self.ransackable_attributes(auth_object = nil)
%w[id name catalog_url store_repository_url created_at updated_at]
end
# The config as JSON text, which is the only form an admin form can edit. The column
# still holds real JSON — this is a view of it, not a second copy.
def config_json
return @config_json if defined?(@config_json) && !@config_json.nil?
config.blank? ? "" : JSON.pretty_generate(config)
end
def config_json=(text)
@config_json = text
@config_json_error = nil
if text.blank?
self.config = nil
return
end
self.config = JSON.parse(text)
rescue JSON::ParserError => e
# Kept rather than raised: the form has to come back with the text the person
# typed and a message, not a 500.
@config_json_error = e.message
end
private
def config_must_be_an_object
return if config.nil? || config.is_a?(Hash)
errors.add(:config, "must be a JSON object")
end
def config_json_must_parse
return if @config_json_error.blank?
errors.add(:config, "is not valid JSON: #{@config_json_error}")
%w[id name catalog_url created_at updated_at]
end
end
@@ -5,11 +5,4 @@ class StoreSerializer < Blueprinter::Base
# camelCase, as the catalog's own payloads use — one convention for a client
# that reads both.
field(:catalogUrl) { |store| store.catalog_url }
# Null rather than an empty string when there is no repository: the client
# branches on its absence, and "" is not an absence a JSON reader can trust.
field(:storeRepositoryUrl) { |store| store.store_repository_url.presence }
# The store's own configuration, in the shape a store's `config.json` had — the
# client applies it exactly as it applied that file. Null when the store configures
# nothing, and then the client uses the engine's defaults.
field(:config) { |store| store.config.presence }
end