HTTP transport for Synthigy client.
ONE PROCESS, ONE CLIENT: every fn here reads the connected client from
synthigy.client.core/*client* — nothing below the public API passes a
client around (the Clojure server-restart idiom: connect! destroys the
old client and installs the new one, so the root var is always the only
live client). Each request resolves the client ONCE and uses that
snapshot for token + retry + hooks.
Tokens come from the client's :token-fn (0-arg for default token,
1-arg for audience-scoped). On 401 the client's :invalidate-fn (if
any) is called to force a token refresh, then the request is retried
once. If that still fails with 401, UNAUTHORIZED is thrown.
HTTP transport for Synthigy client. ONE PROCESS, ONE CLIENT: every fn here reads the connected client from `synthigy.client.core/*client*` — nothing below the public API passes a client around (the Clojure server-restart idiom: `connect!` destroys the old client and installs the new one, so the root var is always the only live client). Each request resolves the client ONCE and uses that snapshot for token + retry + hooks. Tokens come from the client's `:token-fn` (0-arg for default token, 1-arg for audience-scoped). On 401 the client's `:invalidate-fn` (if any) is called to force a token refresh, then the request is retried once. If that still fails with 401, UNAUTHORIZED is thrown.
HTTP transport for the Synthigy CLJS client.
Uses js/fetch — works in every modern browser and Node 18+. Promise-
returning throughout; callers use promesa (p/let) or .then.
Tokens come from the client's :token-fn (0-arg for default token,
1-arg for audience-scoped). On 401 the client's :invalidate-fn (if
any) is called to force a token refresh, then the request is retried
once. If that still fails with 401, UNAUTHORIZED is thrown.
HTTP transport for the Synthigy CLJS client. Uses js/fetch — works in every modern browser and Node 18+. Promise- returning throughout; callers use promesa (`p/let`) or `.then`. Tokens come from the client's `:token-fn` (0-arg for default token, 1-arg for audience-scoped). On 401 the client's `:invalidate-fn` (if any) is called to force a token refresh, then the request is retried once. If that still fails with 401, UNAUTHORIZED is thrown.
(authed method url opts)Run an authenticated HTTP request against the connected client. On 401, invalidate the token cache (if the provider supports it) and retry once. A second 401 throws UNAUTHORIZED. Resolves the client ONCE — token, retry and hooks all use the same snapshot.
Run an authenticated HTTP request against the connected client. On 401, invalidate the token cache (if the provider supports it) and retry once. A second 401 throws UNAUTHORIZED. Resolves the client ONCE — token, retry and hooks all use the same snapshot.
Run an authenticated fetch. On 401, invalidate the token cache (if
supported) and retry once. A second 401 throws UNAUTHORIZED. Returns
a promise of {:status :body-text} or {:status :stream} for SSE.
Run an authenticated fetch. On 401, invalidate the token cache (if
supported) and retry once. A second 401 throws UNAUTHORIZED. Returns
a promise of `{:status :body-text}` or `{:status :stream}` for SSE.(base-url)The connected client's server base URL. Sibling paths (/schema, /lint,
/history, /oauth/onboard, /data/events, /data/subscription/set …) hang off
this; /data itself is appended by request.
The connected client's server base URL. Sibling paths (/schema, /lint, /history, /oauth/onboard, /data/events, /data/subscription/set …) hang off this; /data itself is appended by `request`.
The connected client's server base URL. Sibling paths (/schema, /lint,
/data/events, /data/subscription/set …) hang off this; /data itself is
appended by request.
The connected client's server base URL. Sibling paths (/schema, /lint, /data/events, /data/subscription/set …) hang off this; /data itself is appended by `request`.
(flush-subs!)POST the connected client's local subscription mirror as the full set (the /data/subscription/set endpoint is full-replace).
POST the connected client's local subscription mirror as the full set (the /data/subscription/set endpoint is full-replace).
POST the connected client's local subscription mirror as the full set (the /data/subscription/set endpoint is full-replace). Returns a Promise.
POST the connected client's local subscription mirror as the full set (the /data/subscription/set endpoint is full-replace). Returns a Promise.
(get-json url opts)Authenticated GET returning parsed JSON.
Authenticated GET returning parsed JSON.
(get-json url {:keys [query-params headers]})Authenticated GET returning parsed JSON (promise).
Authenticated GET returning parsed JSON (promise).
(onboard body)Authenticated POST to /oauth/onboard, returning parsed JSON.
Authenticated POST to /oauth/onboard, returning parsed JSON.
Authenticated POST to /oauth/onboard, returning parsed JSON (promise).
Authenticated POST to /oauth/onboard, returning parsed JSON (promise).
(onboard-complete body)Authenticated POST to /oauth/onboard/complete, returning parsed JSON.
Authenticated POST to /oauth/onboard/complete, returning parsed JSON.
Authenticated POST to /oauth/onboard/complete, returning parsed JSON (promise).
Authenticated POST to /oauth/onboard/complete, returning parsed JSON (promise).
(post-json url body)Authenticated POST with JSON body, returning parsed JSON.
Authenticated POST with JSON body, returning parsed JSON.
Authenticated POST with JSON body, returning parsed JSON (promise).
Authenticated POST with JSON body, returning parsed JSON (promise).
(request body)POST to /data with the given body (transit). Returns the parsed response — temporal values come back as real java.util.Date.
POST to /data with the given body (transit). Returns the parsed response — temporal values come back as real java.util.Date.
POST to /data with the given body (transit). Returns a promise of the parsed response — temporal values come back as real js/Date.
POST to /data with the given body (transit). Returns a promise of the parsed response — temporal values come back as real js/Date.
(sse-listen on-event
{:keys [stop? max-delay on-connect on-parse-error]
:or {max-delay 30000 on-parse-error default-on-parse-error}})BLOCKS the calling thread. Streams SSE events from /data/events, calling
on-event with each {:type :entity :relations :xids} notification.
Auto-reconnects with Last-Event-ID and exponential backoff (1s → max-delay). UNAUTHORIZED/FORBIDDEN propagate; other errors trigger reconnect.
Options: :stop? 0-arg predicate — truthy stops the loop between frames :max-delay cap for reconnect backoff in ms (default 30000) :on-connect 0-arg fn called after every successful (re)connect — used to re-assert server-side state (e.g. re-POST the subscription set, which may have been lost/replaced while disconnected). Exceptions are swallowed. :on-parse-error fn [Throwable raw-payload] — called when a frame's data fails JSON parsing. Default logs to err.
BLOCKS the calling thread. Streams SSE events from /data/events, calling
`on-event` with each `{:type :entity :relations :xids}` notification.
Auto-reconnects with Last-Event-ID and exponential backoff (1s → max-delay).
UNAUTHORIZED/FORBIDDEN propagate; other errors trigger reconnect.
Options:
:stop? 0-arg predicate — truthy stops the loop between frames
:max-delay cap for reconnect backoff in ms (default 30000)
:on-connect 0-arg fn called after every successful (re)connect —
used to re-assert server-side state (e.g. re-POST the
subscription set, which may have been lost/replaced
while disconnected). Exceptions are swallowed.
:on-parse-error fn [Throwable raw-payload] — called when a frame's
data fails JSON parsing. Default logs to *err*.(token)(token audience)Resolve a bearer token via the connected client's token-fn. Optional
audience requests a token for another service (IdP federation).
Resolve a bearer token via the connected client's token-fn. Optional `audience` requests a token for another service (IdP federation).
Resolve a bearer token via the connected client's token-fn. Returns a
promise (token-fn may be sync — a raw string — or async — a Promise).
js/Promise.resolve is deliberate: it FLATTENS a thenable, so an async
token-fn resolves to the token string. promesa/resolved does NOT
flatten — it would wrap the inner promise, and callers would send
Bearer [object Promise].
Resolve a bearer token via the connected client's token-fn. Returns a promise (token-fn may be sync — a raw string — or async — a Promise). `js/Promise.resolve` is deliberate: it FLATTENS a thenable, so an async token-fn resolves to the token string. `promesa/resolved` does NOT flatten — it would wrap the inner promise, and callers would send `Bearer [object Promise]`.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |