Server functions

luastra/server

Calls declared versioned operations implemented by a trusted backend and decodes bounded success and validation-error envelopes. Generated schema-v2 clients add nested records, arrays, enums, optional fields, explicit null values, and field errors without exposing provider objects to Luau.

Use generated operation functions and Api.decodeError for schema-v2 work; use Server.call and Server.decode for schema-v1 low-level string maps.

A successful transport response still requires the matching generated decoder before domain data is used.

Complete example

local Server = require("luastra/server")

local requestId = Server.call(
    "records.list.v1",
    { cursor = "" },
    { deadlineMs = 3000, retry = true }
)
pending[requestId] = "list-records"

-- In app.resolve, decode a successful payload first.
local decoded = Server.decode(payload)
if decoded.success then
    consumeRecordFields(decoded.fields)
end

Detail pages

Server.RequestIdServer.OptionsServer.V2LimitsServer.DecodeSuccessServer.DecodeFailureServer.DecodeResultServer.NullableServer.ErrorServer.callServer.callV2Server.decodeServer.decodeV2Server.decodeErrorServer.nullValueServer.value