Pure core of the Synthigy client — everything that is genuinely
platform-free: the client map (construction + the connected *client*),
wire operation builders, result unpacking, tree composition, and the
subscription wire shapes. No transport here; synthigy.client (.clj /
.cljs) owns the verbs.
Pure core of the Synthigy client — everything that is genuinely platform-free: the client map (construction + the connected `*client*`), wire operation builders, result unpacking, tree composition, and the subscription wire shapes. No transport here; `synthigy.client` (.clj / .cljs) owns the verbs.
The connected client — set once via synthigy.client/connect!; every API
fn uses it. Rebind with binding for a scoped alternate client (tests, a
second endpoint) — SDK consumers talk to ONE Synthigy, so it is not a
parameter.
The connected client — set once via `synthigy.client/connect!`; every API fn uses it. Rebind with `binding` for a scoped alternate client (tests, a second endpoint) — SDK consumers talk to ONE Synthigy, so it is not a parameter.
(all-ok? vs)Returns true if all values are successful (no exceptions).
Returns true if all values are successful (no exceptions).
(compose-forest records {:keys [on children-key] :or {children-key :children}})Compose a flat list into a forest — vector of trees, each rooted at a record whose parent isn't present in the set. Useful for search-tree results where multiple independent ancestor chains come back.
Compose a flat list into a forest — vector of trees, each rooted at a record whose parent isn't present in the set. Useful for search-tree results where multiple independent ancestor chains come back.
(compose-tree records
{:keys [on root-id children-key] :or {children-key :children}})Compose a flat list of records into a single nested tree rooted at
root-id. Requires each record to carry its parent FK (include the
relation in your selection).
(compose-tree records {:on :father :root-id howard-xid}) ;; => {:xid :first_name :children [{:xid :first_name :children [...]}]}
Options: :on — relation name (keyword or string) used to walk the tree :root-id — root record's id; defaults to first record's id :children-key — nesting key for children (default :children)
Compose a flat list of records into a single nested tree rooted at
`root-id`. Requires each record to carry its parent FK (include the
relation in your selection).
(compose-tree records {:on :father :root-id howard-xid})
;; => {:xid :first_name :children [{:xid :first_name :children [...]}]}
Options:
:on — relation name (keyword or string) used to walk the tree
:root-id — root record's id; defaults to first record's id
:children-key — nesting key for children (default :children)(create-client {:keys [endpoint key-format request-timeout token-fn
invalidate-fn token client-id client-secret token-url
token-buffer audience on-request on-response on-error]
:or {request-timeout 30000 key-format "kebab"}
:as opts})Create a Synthigy client.
The client is just a plain map. Auth is supplied via a provider — a map
{:token-fn f :invalidate-fn g} — with three ways to supply it:
Explicit provider: (create-client (merge {:endpoint "..."} (auth/oauth {:token-url ... :client-id ...})))
Direct fn handles (full control, bring your own storage): (create-client {:endpoint "..." :token-fn #(@my-cache) :invalidate-fn #(reset! my-cache nil)})
Convenience shortcuts (CLJ only — SDK builds the provider for you): :token "eyJ..." → auth/static :client-id + :client-secret → auth/oauth
Options:
:endpoint — Server URL (e.g. "http://localhost:7887")
:token-fn — 0-arg fn returning a bearer token. Optional 1-arg
variant (f audience) for IdP federation.
:invalidate-fn — Optional 0/1-arg fn clearing the provider's cache.
Used by the SDK to retry once on HTTP 401.
:token — (convenience) static bearer token
:client-id — (convenience) OAuth client id
:client-secret — (convenience) OAuth client secret
— JVM only: with none of the above, falls back to
SYNTHIGY_SUPERVISED=1 stdio (the pipe beats the env
var — it can refresh mid-run), then SYNTHIGY_TOKEN env
(docs/plans/PLAN-EXEC-IDENTITY.md step 3); else throws
{:code "NO_TOKEN"}. CLJS always requires a source.
:audience — (convenience) default audience bound to every
client_credentials mint. The platform's audience model
is opt-in: a mint naming none resolves to the
identity-only OIDC audience that /data rejects. The
server publishes its /data audience at
/.well-known/synthigy as auth.oidc.audience. JVM
default: $SYNTHIGY_AUDIENCE.
:token-url — (convenience) OAuth token URL — defaults to
"<endpoint>/oauth/token"
:token-buffer — (convenience) seconds before expiry to refresh (default 30)
:key-format — response key format. Default "kebab" — Clojure devs
write :published-on, so responses match. Pass nil for
the raw wire snake_case, or "camel".
:request-timeout — HTTP timeout in ms for /data and /schema requests
(default 30000). SSE streams ignore this.
:on-request — (fn [req]) before each HTTP attempt.
req: {:method :url :headers :body}
:on-response — (fn [req resp]) after each HTTP attempt.
resp: {:status :headers :body :elapsed-ms}
:on-error — (fn [req ^Throwable]) when a request throws.
Hooks fire per attempt — a 401 retry fires them twice.
Hook exceptions are caught + logged to *err*, never
bubble into the caller.
Create a Synthigy client.
The client is just a plain map. Auth is supplied via a provider — a map
`{:token-fn f :invalidate-fn g}` — with three ways to supply it:
1. Explicit provider:
(create-client (merge {:endpoint "..."}
(auth/oauth {:token-url ... :client-id ...})))
2. Direct fn handles (full control, bring your own storage):
(create-client {:endpoint "..."
:token-fn #(@my-cache)
:invalidate-fn #(reset! my-cache nil)})
3. Convenience shortcuts (CLJ only — SDK builds the provider for you):
:token "eyJ..." → auth/static
:client-id + :client-secret → auth/oauth
Options:
:endpoint — Server URL (e.g. "http://localhost:7887")
:token-fn — 0-arg fn returning a bearer token. Optional 1-arg
variant `(f audience)` for IdP federation.
:invalidate-fn — Optional 0/1-arg fn clearing the provider's cache.
Used by the SDK to retry once on HTTP 401.
:token — (convenience) static bearer token
:client-id — (convenience) OAuth client id
:client-secret — (convenience) OAuth client secret
— JVM only: with none of the above, falls back to
SYNTHIGY_SUPERVISED=1 stdio (the pipe beats the env
var — it can refresh mid-run), then SYNTHIGY_TOKEN env
(docs/plans/PLAN-EXEC-IDENTITY.md step 3); else throws
{:code "NO_TOKEN"}. CLJS always requires a source.
:audience — (convenience) default audience bound to every
client_credentials mint. The platform's audience model
is opt-in: a mint naming none resolves to the
identity-only OIDC audience that /data rejects. The
server publishes its /data audience at
/.well-known/synthigy as auth.oidc.audience. JVM
default: $SYNTHIGY_AUDIENCE.
:token-url — (convenience) OAuth token URL — defaults to
"<endpoint>/oauth/token"
:token-buffer — (convenience) seconds before expiry to refresh (default 30)
:key-format — response key format. Default "kebab" — Clojure devs
write :published-on, so responses match. Pass nil for
the raw wire snake_case, or "camel".
:request-timeout — HTTP timeout in ms for /data and /schema requests
(default 30000). SSE streams ignore this.
:on-request — (fn [req]) before each HTTP attempt.
req: {:method :url :headers :body}
:on-response — (fn [req resp]) after each HTTP attempt.
resp: {:status :headers :body :elapsed-ms}
:on-error — (fn [req ^Throwable]) when a request throws.
Hooks fire per attempt — a 401 retry fires them twice.
Hook exceptions are caught + logged to *err*, never
bubble into the caller.(errors vs)Filter exceptions from a data vector.
Filter exceptions from a data vector.
(new-xid)A fresh 22-char Base58 xid — client-minted identity for sync/stack, the same derivation the server uses (id/uuid->nanoid: UUID bytes -> base58, left-padded with '1'). Verified byte-for-byte against the server's algorithm across 2000 random UUIDs.
Mint one before a write to know a record's id up front, or to make a
retried write idempotent — the server accepts a caller-supplied id
as-is, and the alternative (returning: true) costs the full echo on
every write. See docs/plans/PLAN-SYNC-RETURNING-FLAG.md.
A fresh 22-char Base58 xid — client-minted identity for sync/stack, the same derivation the server uses (id/uuid->nanoid: UUID bytes -> base58, left-padded with '1'). Verified byte-for-byte against the server's algorithm across 2000 random UUIDs. Mint one before a write to know a record's id up front, or to make a retried write idempotent — the server accepts a caller-supplied id as-is, and the alternative (`returning: true`) costs the full echo on every write. See docs/plans/PLAN-SYNC-RETURNING-FLAG.md.
(ok? v)Returns true if a value is not an error.
Returns true if a value is not an error.
(op-delete entity data)Build a delete operation for batch use.
Build a delete operation for batch use.
(op-deployed-model)Build a deployed-model operation (raw ERD model as deployed).
Build a deployed-model operation (raw ERD model as deployed).
(op-get entity args selection)Build a get operation for batch use.
Build a get operation for batch use.
(op-get-tree entity root on selection)Build a get-tree operation (from root, return root + descendants via :on).
Build a get-tree operation (from root, return root + descendants via :on).
(op-purge entity args selection)Build a purge operation for batch use.
Build a purge operation for batch use.
(op-runtime-model)Build a runtime-model operation (deployed model + identity/audit/ref augmentation).
Build a runtime-model operation (deployed model + identity/audit/ref augmentation).
(op-search entity args selection)Build a search operation for batch use.
Build a search operation for batch use.
(op-search-tree entity on args selection)Build a search-tree operation (walk :on relation UP to ancestors).
Build a search-tree operation (walk :on relation UP to ancestors).
(op-slice entity args selection)Build a slice operation for batch use. The selection names link-sets
to cut; the server ignores :_join on slice targeting.
Build a slice operation for batch use. The selection names link-sets to cut; the server ignores `:_join` on slice targeting.
(op-sql-template template params & {:keys [cached] :or {cached true}})Build a SQL template operation (ERD-aware analytics) for batch use.
Build a SQL template operation (ERD-aware analytics) for batch use.
(op-stack entity data)(op-stack entity data returning)Build a stack operation for batch use. Same returning contract as
op-sync.
Build a stack operation for batch use. Same `returning` contract as op-sync.
(op-sync entity data)(op-sync entity data returning)Build a sync (upsert) operation for batch use. The server answers
{:count n}; pass returning true for the written records. Mint ids with
new-xid when you need them up front — that is the cheap way to know
what you wrote. See docs/plans/PLAN-SYNC-RETURNING-FLAG.md.
Build a sync (upsert) operation for batch use. The server answers
{:count n}; pass `returning` true for the written records. Mint ids with
`new-xid` when you need them up front — that is the cheap way to know
what you wrote. See docs/plans/PLAN-SYNC-RETURNING-FLAG.md.(results->data results)(results->data results operations)Extract data from batch results as a vector for destructuring. Successful operations return their data, failed operations return ExceptionInfo carrying the error and original operation.
(let [[synced users roles] (results->data results ops)] (when (all-ok? [synced users roles]) (println synced users roles)))
Extract data from batch results as a vector for destructuring.
Successful operations return their data, failed operations return
ExceptionInfo carrying the error and original operation.
(let [[synced users roles] (results->data results ops)]
(when (all-ok? [synced users roles])
(println synced users roles)))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 |