bridgething
Surfaces ↓

Config

client.config

Daemon -> webapp config replies and events. Get / List reply to the matching requests. Changed broadcasts whenever the gateway writes or deletes a value for the active webapp.

Requests

you ask, the daemon answers; await the tagged result and check .ok

get(ConfigGet): Promise<TypedRequestResult<ConfigGetReply, never>>

push form: onGet (subscribe instead of awaiting)

Webapp request: read one config value for the currently active webapp, as most recently set by the gateway. This surface is read-only; only the gateway can write config.

const res = await client.config.get({ key: '...' });
if (res.ok) {
  console.log(res.response.key);
}

list(): Promise<TypedRequestResult<ConfigListReply, never>>

push form: onList (subscribe instead of awaiting)

Marker request: webapp asks for every config entry the gateway has set for the currently active webapp.

const res = await client.config.list();
if (res.ok) {
  console.log(res.response.entries);
}

Events

the daemon pushes these unprompted; subscribing returns an unsubscribe function

onChanged(handler: (ConfigChanged) => void): () => void

const off = client.config.onChanged((configChanged) => {
  console.log(configChanged.key);
});
// call off() to unsubscribe

Types

shapes referenced above, as the SDK types them

Broadcast when the gateway writes a new value for the active webapp. value: None means the entry was deleted; consumers should fall back to whatever default they declared.

type ConfigChanged = {
  key: string;
  value?: string;
};

Webapp request: read one config value for the currently active webapp, as most recently set by the gateway. This surface is read-only; only the gateway can write config.

type ConfigGet = {
  key: string;
};

Reply to ConfigGet.

type ConfigGetReply = {
  key: string;
  value?: string; // `None` when the gateway has never set this key, as opposed to an empty string.
};

Reply to ConfigList.

type ConfigListReply = {
  entries: ConfigEntry[];
};

One key/value pair as exposed by config read APIs. value is always a string; consumers parse per the field's declared kind (number -> parseFloat, boolean -> "true"/"false", string/enum/secret -> as-is).

type ConfigEntry = {
  key: string;
  value: string;
};