Liking cljdoc? Tell your friends :D

synthigy.client.http

clj

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.
cljs

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.
raw docstring

authedclj/s≠

(authed method url opts)
clj

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.
cljs

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.
source (clj)source (cljs)raw docstring

base-urlclj/s≠

(base-url)
clj

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`.
cljs

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`.
source (clj)source (cljs)raw docstring

flush-subs!clj/s≠

(flush-subs!)
clj

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).
cljs

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.
source (clj)source (cljs)raw docstring

get-jsonclj/s≠

clj
(get-json url opts)

Authenticated GET returning parsed JSON.

Authenticated GET returning parsed JSON.
cljs
(get-json url {:keys [query-params headers]})

Authenticated GET returning parsed JSON (promise).

Authenticated GET returning parsed JSON (promise).
source (clj)source (cljs)raw docstring

onboardclj/s≠

(onboard body)
clj

Authenticated POST to /oauth/onboard, returning parsed JSON.

Authenticated POST to /oauth/onboard, returning parsed JSON.
cljs

Authenticated POST to /oauth/onboard, returning parsed JSON (promise).

Authenticated POST to /oauth/onboard, returning parsed JSON (promise).
source (clj)source (cljs)raw docstring

onboard-completeclj/s≠

(onboard-complete body)
clj

Authenticated POST to /oauth/onboard/complete, returning parsed JSON.

Authenticated POST to /oauth/onboard/complete, returning parsed JSON.
cljs

Authenticated POST to /oauth/onboard/complete, returning parsed JSON (promise).

Authenticated POST to /oauth/onboard/complete, returning parsed JSON (promise).
source (clj)source (cljs)raw docstring

post-jsonclj/s≠

(post-json url body)
clj

Authenticated POST with JSON body, returning parsed JSON.

Authenticated POST with JSON body, returning parsed JSON.
cljs

Authenticated POST with JSON body, returning parsed JSON (promise).

Authenticated POST with JSON body, returning parsed JSON (promise).
source (clj)source (cljs)raw docstring

requestclj/s≠

(request body)
clj

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.
cljs

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.
source (clj)source (cljs)raw docstring

sse-listenclj

(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*.
sourceraw docstring

tokenclj/s≠

(token)
(token audience)
clj

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).
cljs

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]`.
source (clj)source (cljs)raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close