infra stuff in gleam

atproto_codegen: input encoders, envelope decoders, and params encoders are only emitted inside the client module #32

Open mokkenstorm.dev
Open opened by mokkenstorm.dev

Found while migrating at-record's Lustre web app (javascript target, rsvp transport) to the generated code.

The per-method modules (shelf/entry.gleam, catalog/list_releases.gleam, ...) only expose the leaf item record type and its decoder/encoder. Everything a non-client consumer needs to speak the procedure-level contract is generated exclusively inside client.gleam, next to the sync xrpc.Client-taking functions:

  • encode_*_input for procedure bodies (encode_shelf_add_entry_input, encode_shelf_append_event_input, encode_catalog_adopt_release_input, ...)
  • output envelope decoders (e.g. listEntries' {handle, items, viaHandles}, listReleases' {results, page, pages}, applyEditProposal's {releaseUri})
  • query params records and their query-string encoding
  • for discogs.getStatus the output type/decoder exists nowhere else: gen/discogs/get_status.gleam is not emitted at all

Because atproto_client's Client.send is synchronous, the client module is unusable on the javascript target (browser fetch is async), so a browser consumer can only reuse the leaf item codecs and must keep hand-writing every body encode, envelope decode, and URL. In the at-record migration that left ~10 call sites unmigratable.

Suggestion: emit these as pure, transport-free functions in the per-method modules (or one transport-free module) and have client.gleam wrap them.

Sign up or Sign in to add to the discussion.