The one settings resolver for the package: per-call opts first,
then context variables, then defaults. Per-call values are never
written to context, so parallel flows and tenants in one run don't
see each other's keys.
| opts key | Context variable | Default |
|---|---|---|
api-key | opensanctions.api-key | none |
base-url | opensanctions.base-url | https://api.opensanctions.org |
dataset | opensanctions.dataset | "default" |
Per-call credentials. An api-key in opts is masked in call
records. Present but blank or null, it is an error, never a fallback
to context. The context key is never sent to a per-call base-url: a
self-hosted yente that needs no key gets none.
Context Vars
opensanctions.api-keyopensanctions.base-urlopensanctions.dataset
Values
DEFAULT_DATASET
DEFAULT_DATASET: Str "default"
DEFAULT_OPENSANCTIONS_URL
DEFAULT_OPENSANCTIONS_URL: Str "https://api.opensanctions.org"
Functions
require-api-key
fn (cfg: Map): Str?
The resolved OpenSanctions API key. The hosted API needs one, so its absence there is an Err naming where to set it; a self-hosted yente may need none, which gives null.
Example
::opensanctions::config/require-api-key({api-key: null, base-url: "https://yente.internal"}) // null
is-err(::opensanctions::config/require-api-key({api-key: null, base-url: "https://api.opensanctions.org"})) // true
resolve
fn (opts: Map): Map
Resolve settings for one call: {api-key, base-url, dataset}. An
api-key in opts replaces the context key for that call only and
comes back unchanged; api-key is null when neither is set, and when
opts has a base-url without one. An Err when api-key is in
opts but blank or null.
Example
cfg ::opensanctions::config/resolve({api-key: ::hot::ctx/get("tenant.opensanctions-key"), dataset: "sanctions"})