shopify_draft_proxy/proxy/operation_registry
Mirrors src/proxy/operation-registry.ts.
The TS module imports config/operation-registry.json directly via
with { type: 'json' } and validates it against
operationRegistrySchema. We can’t replicate the static-import dance
portably across Gleam’s two targets, so this module exposes a
parse(json_string) that callers feed with the raw JSON. A thin
FFI/loader shim (separate concern, future pass) reads the file at
startup and hands the string in.
The registry itself is just List(RegistryEntry) — no map/dict
caching here. Lookup helpers (find_entry, list_implemented)
stream the list, which is fine for ~100 entries; if dispatch on the
hot path benefits from a map, callers can build their own.
Types
Mirrors the TS CapabilityDomain union. The list is closed and the
JSON schema enforces it, so unknown values during decode are an
error (we surface them as UnknownDomain decode errors rather than
folding them into Unknown, which is reserved for the
“no entry matched” capability fallback).
pub type CapabilityDomain {
Products
AdminPlatform
B2b
Apps
Media
BulkOperations
Customers
Orders
StoreProperties
Discounts
Events
Functions
Payments
Marketing
OnlineStore
SavedSearches
Privacy
Segments
ShippingFulfillments
GiftCards
Webhooks
Localization
Markets
Metafields
Metaobjects
Unknown
}
Constructors
-
Products -
AdminPlatform -
B2b -
Apps -
Media -
BulkOperations -
Customers -
Orders -
StoreProperties -
Discounts -
Events -
Functions -
Payments -
Marketing -
OnlineStore -
SavedSearches -
Privacy -
Segments -
ShippingFulfillments -
GiftCards -
Webhooks -
Localization -
Markets -
Metafields -
Metaobjects -
Unknown
Mirrors the TS CapabilityExecution. Passthrough only appears in
the capability fallback today — every entry in the JSON registry is
overlay-read or stage-locally — but the type carries it because
capabilities.ts returns it for the unknown branch.
pub type CapabilityExecution {
OverlayRead
StageLocally
Passthrough
}
Constructors
-
OverlayRead -
StageLocally -
Passthrough
Mirrors the TS OperationType. Subscriptions are out of scope.
pub type OperationType {
Query
Mutation
}
Constructors
-
Query -
Mutation
Mirrors OperationRegistryEntry. support_notes is optional —
defaults to None when the JSON omits it.
pub type RegistryEntry {
RegistryEntry(
name: String,
type_: OperationType,
domain: CapabilityDomain,
execution: CapabilityExecution,
implemented: Bool,
match_names: List(String),
runtime_tests: List(String),
support_notes: option.Option(String),
)
}
Constructors
-
RegistryEntry( name: String, type_: OperationType, domain: CapabilityDomain, execution: CapabilityExecution, implemented: Bool, match_names: List(String), runtime_tests: List(String), support_notes: option.Option(String), )
Values
pub fn find_entry(
registry: List(RegistryEntry),
type_: OperationType,
names: List(option.Option(String)),
) -> option.Option(RegistryEntry)
Mirrors findOperationRegistryEntry. names is searched in order,
returning the first entry whose type_ matches and whose
match_names contains the candidate. Empty / None candidates are
skipped to mirror the TS filter.
pub fn list_entries(
registry: List(RegistryEntry),
) -> List(RegistryEntry)
All entries, untouched. In the TS this is a defensive copy; in Gleam the list is immutable so we just return it.
pub fn list_implemented(
registry: List(RegistryEntry),
) -> List(RegistryEntry)
Mirrors listImplementedOperationRegistryEntries.
pub fn parse(
input: String,
) -> Result(List(RegistryEntry), json.DecodeError)
Parse a JSON string into a list of registry entries. Mirrors the
operationRegistrySchema.parse(...) pass at module load time in
operation-registry.ts.