@smplkit/sdk 3.0.83 → 3.0.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +250 -214
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +89 -79
- package/dist/index.d.ts +89 -79
- package/dist/index.js +250 -214
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -579,19 +579,18 @@ declare class SharedWebSocket {
|
|
|
579
579
|
}
|
|
580
580
|
|
|
581
581
|
/**
|
|
582
|
-
* LiveConfigProxy — live, dict-like, read-only
|
|
582
|
+
* LiveConfigProxy — live, dict-like, read-only view of a config's resolved values.
|
|
583
|
+
*
|
|
584
|
+
* Returned by {@link ConfigClient.get} when called with a single argument.
|
|
585
|
+
* For typed access via an object literal or class instance, use
|
|
586
|
+
* {@link ConfigClient.bind} instead — bound objects stay live on the same
|
|
587
|
+
* WebSocket-driven cache, with no proxy indirection.
|
|
583
588
|
*/
|
|
584
589
|
|
|
585
590
|
/**
|
|
586
|
-
* A live, dict-like, read-only view of
|
|
587
|
-
*
|
|
588
|
-
* Returned by {@link ConfigClient.get}. Always reflects the latest
|
|
589
|
-
* server-pushed state — every read sees current values.
|
|
591
|
+
* A live, dict-like, read-only view of a config's resolved values.
|
|
590
592
|
*
|
|
591
|
-
*
|
|
592
|
-
* key. If a *model* class was provided, the model is reconstructed from
|
|
593
|
-
* the latest values on each access (so attribute access type-checks
|
|
594
|
-
* against the model).
|
|
593
|
+
* Always reflects the latest server-pushed state — every read sees current values.
|
|
595
594
|
*
|
|
596
595
|
* Dict-like API: `proxy["key"]`, `key in proxy`, `Object.keys(proxy)`,
|
|
597
596
|
* `proxy.values()`, `proxy.items()`, `proxy.get(key, default)`,
|
|
@@ -606,7 +605,7 @@ declare class SharedWebSocket {
|
|
|
606
605
|
* @example
|
|
607
606
|
* ```typescript
|
|
608
607
|
* const cfg = await client.config.get("user-service");
|
|
609
|
-
* console.log(cfg.database
|
|
608
|
+
* console.log(cfg.database); // resolved value
|
|
610
609
|
* console.log(cfg["max_retries"]); // subscript also works
|
|
611
610
|
* for (const key of Object.keys(cfg)) console.log(key);
|
|
612
611
|
*
|
|
@@ -614,14 +613,12 @@ declare class SharedWebSocket {
|
|
|
614
613
|
* cfg.onChange("max_retries", (event) => console.log("retries changed"));
|
|
615
614
|
* ```
|
|
616
615
|
*/
|
|
617
|
-
declare class LiveConfigProxy
|
|
616
|
+
declare class LiveConfigProxy {
|
|
618
617
|
/** @internal */
|
|
619
618
|
private readonly _client;
|
|
620
619
|
/** @internal */
|
|
621
620
|
private readonly _key;
|
|
622
|
-
|
|
623
|
-
private readonly _model?;
|
|
624
|
-
constructor(client: ConfigClient, key: string, model?: new (data: any) => T);
|
|
621
|
+
constructor(client: ConfigClient, key: string);
|
|
625
622
|
/** @internal */
|
|
626
623
|
_currentValues(): Record<string, unknown>;
|
|
627
624
|
/** Dict method: list of resolved item keys. */
|
|
@@ -632,32 +629,10 @@ declare class LiveConfigProxy<T = Record<string, unknown>> {
|
|
|
632
629
|
items(): Array<[string, unknown]>;
|
|
633
630
|
/** Dict method: get a value by key, returning `defaultValue` if absent. */
|
|
634
631
|
get<V = unknown>(key: string, defaultValue?: V): V | unknown;
|
|
635
|
-
/** @internal */
|
|
636
|
-
private _registerItem;
|
|
637
|
-
/** Read a BOOLEAN item, registering the declaration on first call. */
|
|
638
|
-
getBool(key: string, defaultValue: boolean, options?: {
|
|
639
|
-
description?: string;
|
|
640
|
-
}): boolean;
|
|
641
|
-
/** Read a NUMBER item as int, registering the declaration on first call. */
|
|
642
|
-
getInt(key: string, defaultValue: number, options?: {
|
|
643
|
-
description?: string;
|
|
644
|
-
}): number;
|
|
645
|
-
/** Read a NUMBER item as float, registering the declaration on first call. */
|
|
646
|
-
getFloat(key: string, defaultValue: number, options?: {
|
|
647
|
-
description?: string;
|
|
648
|
-
}): number;
|
|
649
|
-
/** Read a STRING item, registering the declaration on first call. */
|
|
650
|
-
getString(key: string, defaultValue: string, options?: {
|
|
651
|
-
description?: string;
|
|
652
|
-
}): string;
|
|
653
|
-
/** Read a JSON item, registering the declaration on first call. */
|
|
654
|
-
getJson<V = unknown>(key: string, defaultValue: V, options?: {
|
|
655
|
-
description?: string;
|
|
656
|
-
}): V;
|
|
657
632
|
/**
|
|
658
633
|
* Register a change listener scoped to this config.
|
|
659
634
|
*
|
|
660
|
-
*
|
|
635
|
+
* Two forms:
|
|
661
636
|
* - `proxy.onChange(callback)` — fires on any change to this config.
|
|
662
637
|
* - `proxy.onChange("itemKey", callback)` — fires only when `itemKey` changes.
|
|
663
638
|
*
|
|
@@ -2008,7 +1983,7 @@ declare class Environment {
|
|
|
2008
1983
|
* environment. Unmanaged environments are view-only — existing values
|
|
2009
1984
|
* render for comparison but no new values can be set. Managed
|
|
2010
1985
|
* environments count toward the account's `platform.managed_environments`
|
|
2011
|
-
* quota.
|
|
1986
|
+
* quota. `production` is always managed and cannot be demoted.
|
|
2012
1987
|
*/
|
|
2013
1988
|
managed: boolean;
|
|
2014
1989
|
/** When the environment was created. */
|
|
@@ -3605,9 +3580,10 @@ declare class ConfigChangeEvent {
|
|
|
3605
3580
|
/**
|
|
3606
3581
|
* Runtime client for the smplkit Config service.
|
|
3607
3582
|
*
|
|
3608
|
-
* Obtained via `SmplClient.config`. Provides
|
|
3609
|
-
* listeners, and lazy initialization.
|
|
3610
|
-
* `SmplClient.manage.config` (or use a standalone
|
|
3583
|
+
* Obtained via `SmplClient.config`. Provides {@link bind} (the declarative
|
|
3584
|
+
* path), {@link get} (lookup), change listeners, and lazy initialization.
|
|
3585
|
+
* Management/CRUD lives on `SmplClient.manage.config` (or use a standalone
|
|
3586
|
+
* {@link SmplManagementClient}).
|
|
3611
3587
|
*/
|
|
3612
3588
|
declare class ConfigClient {
|
|
3613
3589
|
/** @internal */
|
|
@@ -3633,55 +3609,84 @@ declare class ConfigClient {
|
|
|
3633
3609
|
* without a full re-list. Mirrors Python's `_raw_config_cache`. */
|
|
3634
3610
|
private _configStore;
|
|
3635
3611
|
/** Cache of LiveConfigProxy instances by config id — ensures repeat
|
|
3636
|
-
* `
|
|
3637
|
-
* handle so callers can reference it as a parent via direct ref.
|
|
3638
|
-
* Mirrors Python's `_proxies`. */
|
|
3612
|
+
* `get(id)` calls return the same handle. */
|
|
3639
3613
|
private _proxies;
|
|
3614
|
+
/** Bound targets (plain objects or class instances) keyed by config
|
|
3615
|
+
* id. WebSocket dispatch mutates these in place when values change. */
|
|
3616
|
+
private _bindings;
|
|
3640
3617
|
private _initialized;
|
|
3641
3618
|
private _listeners;
|
|
3642
3619
|
/** @internal */
|
|
3643
3620
|
constructor(apiKey: string, timeout?: number, baseUrl?: string, extraHeaders?: Record<string, string>);
|
|
3644
3621
|
/**
|
|
3645
|
-
*
|
|
3622
|
+
* Bind an object to a config id; return the same object back, live.
|
|
3623
|
+
*
|
|
3624
|
+
* Declarative, code-first API. The object's keys are the schema; its
|
|
3625
|
+
* values are the in-code defaults. On first boot:
|
|
3646
3626
|
*
|
|
3647
|
-
*
|
|
3648
|
-
*
|
|
3649
|
-
*
|
|
3650
|
-
*
|
|
3627
|
+
* 1. Every leaf (recursively, through nested plain objects) is
|
|
3628
|
+
* registered with the server as a config item, with its value as
|
|
3629
|
+
* the in-code default and a type inferred from `typeof value`.
|
|
3630
|
+
* 2. After the SDK's cache is populated, any server-side overrides for
|
|
3631
|
+
* this config are applied to the bound object in place.
|
|
3651
3632
|
*
|
|
3652
|
-
*
|
|
3653
|
-
*
|
|
3654
|
-
*
|
|
3655
|
-
* in
|
|
3633
|
+
* On every WebSocket-delivered change thereafter the bound object is
|
|
3634
|
+
* mutated in place — readers of `obj.foo` and `obj["foo"]` always see
|
|
3635
|
+
* the current resolved value. The returned object is the same one you
|
|
3636
|
+
* passed in (referential identity preserved).
|
|
3656
3637
|
*
|
|
3657
|
-
*
|
|
3658
|
-
*
|
|
3638
|
+
* Idempotent. Repeated calls with the same id return the originally-
|
|
3639
|
+
* bound object; the new `config` argument is ignored.
|
|
3640
|
+
*
|
|
3641
|
+
* **Plain object literals vs. class instances.** Plain object literals
|
|
3642
|
+
* (e.g., `{ a: 1, b: { c: 2 } }`) are the recommended input shape —
|
|
3643
|
+
* their keys are the explicit override set, and omitted keys inherit
|
|
3644
|
+
* from `parent`. Class instances are also accepted, but every
|
|
3645
|
+
* enumerable property is registered as an explicit override (there is
|
|
3646
|
+
* no JS equivalent of Python's `model_fields_set`); to get omit-to-
|
|
3647
|
+
* inherit semantics, use a plain object literal.
|
|
3648
|
+
*
|
|
3649
|
+
* @param id - The config id to register under.
|
|
3650
|
+
* @param config - A plain object literal (recommended) or class
|
|
3651
|
+
* instance carrying the in-code defaults.
|
|
3652
|
+
* @param options - Optional `parent`: another object previously
|
|
3653
|
+
* returned from a {@link bind} call. Activates parent-chain
|
|
3654
|
+
* inheritance for keys the caller omitted.
|
|
3655
|
+
* @returns The same `config` object, registered and live.
|
|
3656
|
+
* @throws TypeError if `config` is not an object.
|
|
3657
|
+
* @throws Error if `parent` was not previously bound via {@link bind}.
|
|
3659
3658
|
*/
|
|
3660
|
-
|
|
3659
|
+
bind<T extends object>(id: string, config: T, options?: {
|
|
3660
|
+
parent?: object | null;
|
|
3661
|
+
}): Promise<T>;
|
|
3661
3662
|
/**
|
|
3662
|
-
*
|
|
3663
|
+
* Read a config (full) or a single value within a config.
|
|
3663
3664
|
*
|
|
3664
|
-
*
|
|
3665
|
-
* {@link LiveConfigProxy} instance. The first call queues a discovery
|
|
3666
|
-
* payload (the config and any items declared via typed getters on the
|
|
3667
|
-
* returned handle) for upload to `POST /api/v1/configs/bulk` on next
|
|
3668
|
-
* flush. If the config already exists server-side, `managed=true`
|
|
3669
|
-
* configs are left untouched; `managed=false` configs receive the
|
|
3670
|
-
* SDK's items via source-row upsert per ADR-024 §2.9.
|
|
3665
|
+
* Three forms dispatched by argument count:
|
|
3671
3666
|
*
|
|
3672
|
-
*
|
|
3673
|
-
*
|
|
3667
|
+
* - `get(id)` — returns a {@link LiveConfigProxy}, a live dict-like
|
|
3668
|
+
* view. Throws {@link SmplkitNotFoundError} if the config is missing.
|
|
3669
|
+
* No registration.
|
|
3670
|
+
* - `get(id, key)` — returns the resolved value of `key` within `id`.
|
|
3671
|
+
* Throws {@link SmplkitNotFoundError} if either the config or the key
|
|
3672
|
+
* is missing. No registration.
|
|
3673
|
+
* - `get(id, key, defaultValue)` — returns the resolved value, falling
|
|
3674
|
+
* back to `defaultValue` if either is missing. Never throws. Also
|
|
3675
|
+
* **registers** the config (if new) and the key (with `defaultValue`
|
|
3676
|
+
* as its default value) for code-first console observability.
|
|
3674
3677
|
*
|
|
3675
|
-
*
|
|
3678
|
+
* For typed access via a Pydantic-style declarative API, use
|
|
3679
|
+
* {@link bind} instead.
|
|
3676
3680
|
*/
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3681
|
+
get(id: string): Promise<LiveConfigProxy>;
|
|
3682
|
+
get(id: string, key: string): Promise<unknown>;
|
|
3683
|
+
get<V>(id: string, key: string, defaultValue: V): Promise<V | unknown>;
|
|
3684
|
+
/** @internal — return the config_id this object was bound under, or null. */
|
|
3685
|
+
private _configIdFor;
|
|
3686
|
+
/** @internal — apply current cached values to a freshly-bound target. */
|
|
3687
|
+
private _syncTargetFromCache;
|
|
3683
3688
|
/** @internal — return (and cache) the canonical proxy for a config id. */
|
|
3684
|
-
_cachedProxy
|
|
3689
|
+
_cachedProxy(id: string): LiveConfigProxy;
|
|
3685
3690
|
/** @internal — queue a config declaration with the management buffer. */
|
|
3686
3691
|
_observeConfigDeclaration(configId: string, parent: string | null, name: string | null, description: string | null): void;
|
|
3687
3692
|
/** @internal — queue a config item declaration with the management buffer. */
|
|
@@ -3704,17 +3709,14 @@ declare class ConfigClient {
|
|
|
3704
3709
|
* (set via `_resolveManagement`) so runtime + management share one HTTP
|
|
3705
3710
|
* client; falls back to a direct GET when running without `SmplClient`
|
|
3706
3711
|
* bootstrap (e.g. unit tests that construct `ConfigClient` directly).
|
|
3707
|
-
*
|
|
3708
|
-
* Pages through the server until a short page (less than the requested
|
|
3709
|
-
* size) is returned — accounts with more than 1000 configs would
|
|
3710
|
-
* otherwise silently lose everything past page one.
|
|
3711
3712
|
*/
|
|
3712
3713
|
private _listConfigs;
|
|
3713
3714
|
/**
|
|
3714
3715
|
* Eagerly initialize the config subclient — fetch all configs, resolve
|
|
3715
3716
|
* environment-scoped values into the local cache, and subscribe to the
|
|
3716
3717
|
* shared WebSocket for live updates. Idempotent. Called automatically
|
|
3717
|
-
* on first `client.config.get(...)` if not
|
|
3718
|
+
* on first `client.config.get(...)` / `client.config.bind(...)` if not
|
|
3719
|
+
* invoked manually.
|
|
3718
3720
|
*/
|
|
3719
3721
|
start(): Promise<void>;
|
|
3720
3722
|
/** @internal */
|
|
@@ -4161,9 +4163,17 @@ declare class PinoAdapter implements LoggingAdapter {
|
|
|
4161
4163
|
/** A single error object from a JSON:API error response. */
|
|
4162
4164
|
interface ApiErrorDetail {
|
|
4163
4165
|
status?: string;
|
|
4166
|
+
/**
|
|
4167
|
+
* Application-specific machine-readable error code (e.g.
|
|
4168
|
+
* ``environment_unmanaged``). Per JSON:API §7 and ADR-014, the server
|
|
4169
|
+
* sets this on every error so callers can branch without string-matching.
|
|
4170
|
+
*/
|
|
4171
|
+
code?: string;
|
|
4164
4172
|
title?: string;
|
|
4165
4173
|
detail?: string;
|
|
4166
4174
|
source?: Record<string, unknown>;
|
|
4175
|
+
/** Additional structured context (e.g. ``{environment: "staging"}``). */
|
|
4176
|
+
meta?: Record<string, unknown>;
|
|
4167
4177
|
}
|
|
4168
4178
|
/** Base exception for all smplkit SDK errors. */
|
|
4169
4179
|
declare class SmplError extends Error {
|
package/dist/index.d.ts
CHANGED
|
@@ -579,19 +579,18 @@ declare class SharedWebSocket {
|
|
|
579
579
|
}
|
|
580
580
|
|
|
581
581
|
/**
|
|
582
|
-
* LiveConfigProxy — live, dict-like, read-only
|
|
582
|
+
* LiveConfigProxy — live, dict-like, read-only view of a config's resolved values.
|
|
583
|
+
*
|
|
584
|
+
* Returned by {@link ConfigClient.get} when called with a single argument.
|
|
585
|
+
* For typed access via an object literal or class instance, use
|
|
586
|
+
* {@link ConfigClient.bind} instead — bound objects stay live on the same
|
|
587
|
+
* WebSocket-driven cache, with no proxy indirection.
|
|
583
588
|
*/
|
|
584
589
|
|
|
585
590
|
/**
|
|
586
|
-
* A live, dict-like, read-only view of
|
|
587
|
-
*
|
|
588
|
-
* Returned by {@link ConfigClient.get}. Always reflects the latest
|
|
589
|
-
* server-pushed state — every read sees current values.
|
|
591
|
+
* A live, dict-like, read-only view of a config's resolved values.
|
|
590
592
|
*
|
|
591
|
-
*
|
|
592
|
-
* key. If a *model* class was provided, the model is reconstructed from
|
|
593
|
-
* the latest values on each access (so attribute access type-checks
|
|
594
|
-
* against the model).
|
|
593
|
+
* Always reflects the latest server-pushed state — every read sees current values.
|
|
595
594
|
*
|
|
596
595
|
* Dict-like API: `proxy["key"]`, `key in proxy`, `Object.keys(proxy)`,
|
|
597
596
|
* `proxy.values()`, `proxy.items()`, `proxy.get(key, default)`,
|
|
@@ -606,7 +605,7 @@ declare class SharedWebSocket {
|
|
|
606
605
|
* @example
|
|
607
606
|
* ```typescript
|
|
608
607
|
* const cfg = await client.config.get("user-service");
|
|
609
|
-
* console.log(cfg.database
|
|
608
|
+
* console.log(cfg.database); // resolved value
|
|
610
609
|
* console.log(cfg["max_retries"]); // subscript also works
|
|
611
610
|
* for (const key of Object.keys(cfg)) console.log(key);
|
|
612
611
|
*
|
|
@@ -614,14 +613,12 @@ declare class SharedWebSocket {
|
|
|
614
613
|
* cfg.onChange("max_retries", (event) => console.log("retries changed"));
|
|
615
614
|
* ```
|
|
616
615
|
*/
|
|
617
|
-
declare class LiveConfigProxy
|
|
616
|
+
declare class LiveConfigProxy {
|
|
618
617
|
/** @internal */
|
|
619
618
|
private readonly _client;
|
|
620
619
|
/** @internal */
|
|
621
620
|
private readonly _key;
|
|
622
|
-
|
|
623
|
-
private readonly _model?;
|
|
624
|
-
constructor(client: ConfigClient, key: string, model?: new (data: any) => T);
|
|
621
|
+
constructor(client: ConfigClient, key: string);
|
|
625
622
|
/** @internal */
|
|
626
623
|
_currentValues(): Record<string, unknown>;
|
|
627
624
|
/** Dict method: list of resolved item keys. */
|
|
@@ -632,32 +629,10 @@ declare class LiveConfigProxy<T = Record<string, unknown>> {
|
|
|
632
629
|
items(): Array<[string, unknown]>;
|
|
633
630
|
/** Dict method: get a value by key, returning `defaultValue` if absent. */
|
|
634
631
|
get<V = unknown>(key: string, defaultValue?: V): V | unknown;
|
|
635
|
-
/** @internal */
|
|
636
|
-
private _registerItem;
|
|
637
|
-
/** Read a BOOLEAN item, registering the declaration on first call. */
|
|
638
|
-
getBool(key: string, defaultValue: boolean, options?: {
|
|
639
|
-
description?: string;
|
|
640
|
-
}): boolean;
|
|
641
|
-
/** Read a NUMBER item as int, registering the declaration on first call. */
|
|
642
|
-
getInt(key: string, defaultValue: number, options?: {
|
|
643
|
-
description?: string;
|
|
644
|
-
}): number;
|
|
645
|
-
/** Read a NUMBER item as float, registering the declaration on first call. */
|
|
646
|
-
getFloat(key: string, defaultValue: number, options?: {
|
|
647
|
-
description?: string;
|
|
648
|
-
}): number;
|
|
649
|
-
/** Read a STRING item, registering the declaration on first call. */
|
|
650
|
-
getString(key: string, defaultValue: string, options?: {
|
|
651
|
-
description?: string;
|
|
652
|
-
}): string;
|
|
653
|
-
/** Read a JSON item, registering the declaration on first call. */
|
|
654
|
-
getJson<V = unknown>(key: string, defaultValue: V, options?: {
|
|
655
|
-
description?: string;
|
|
656
|
-
}): V;
|
|
657
632
|
/**
|
|
658
633
|
* Register a change listener scoped to this config.
|
|
659
634
|
*
|
|
660
|
-
*
|
|
635
|
+
* Two forms:
|
|
661
636
|
* - `proxy.onChange(callback)` — fires on any change to this config.
|
|
662
637
|
* - `proxy.onChange("itemKey", callback)` — fires only when `itemKey` changes.
|
|
663
638
|
*
|
|
@@ -2008,7 +1983,7 @@ declare class Environment {
|
|
|
2008
1983
|
* environment. Unmanaged environments are view-only — existing values
|
|
2009
1984
|
* render for comparison but no new values can be set. Managed
|
|
2010
1985
|
* environments count toward the account's `platform.managed_environments`
|
|
2011
|
-
* quota.
|
|
1986
|
+
* quota. `production` is always managed and cannot be demoted.
|
|
2012
1987
|
*/
|
|
2013
1988
|
managed: boolean;
|
|
2014
1989
|
/** When the environment was created. */
|
|
@@ -3605,9 +3580,10 @@ declare class ConfigChangeEvent {
|
|
|
3605
3580
|
/**
|
|
3606
3581
|
* Runtime client for the smplkit Config service.
|
|
3607
3582
|
*
|
|
3608
|
-
* Obtained via `SmplClient.config`. Provides
|
|
3609
|
-
* listeners, and lazy initialization.
|
|
3610
|
-
* `SmplClient.manage.config` (or use a standalone
|
|
3583
|
+
* Obtained via `SmplClient.config`. Provides {@link bind} (the declarative
|
|
3584
|
+
* path), {@link get} (lookup), change listeners, and lazy initialization.
|
|
3585
|
+
* Management/CRUD lives on `SmplClient.manage.config` (or use a standalone
|
|
3586
|
+
* {@link SmplManagementClient}).
|
|
3611
3587
|
*/
|
|
3612
3588
|
declare class ConfigClient {
|
|
3613
3589
|
/** @internal */
|
|
@@ -3633,55 +3609,84 @@ declare class ConfigClient {
|
|
|
3633
3609
|
* without a full re-list. Mirrors Python's `_raw_config_cache`. */
|
|
3634
3610
|
private _configStore;
|
|
3635
3611
|
/** Cache of LiveConfigProxy instances by config id — ensures repeat
|
|
3636
|
-
* `
|
|
3637
|
-
* handle so callers can reference it as a parent via direct ref.
|
|
3638
|
-
* Mirrors Python's `_proxies`. */
|
|
3612
|
+
* `get(id)` calls return the same handle. */
|
|
3639
3613
|
private _proxies;
|
|
3614
|
+
/** Bound targets (plain objects or class instances) keyed by config
|
|
3615
|
+
* id. WebSocket dispatch mutates these in place when values change. */
|
|
3616
|
+
private _bindings;
|
|
3640
3617
|
private _initialized;
|
|
3641
3618
|
private _listeners;
|
|
3642
3619
|
/** @internal */
|
|
3643
3620
|
constructor(apiKey: string, timeout?: number, baseUrl?: string, extraHeaders?: Record<string, string>);
|
|
3644
3621
|
/**
|
|
3645
|
-
*
|
|
3622
|
+
* Bind an object to a config id; return the same object back, live.
|
|
3623
|
+
*
|
|
3624
|
+
* Declarative, code-first API. The object's keys are the schema; its
|
|
3625
|
+
* values are the in-code defaults. On first boot:
|
|
3646
3626
|
*
|
|
3647
|
-
*
|
|
3648
|
-
*
|
|
3649
|
-
*
|
|
3650
|
-
*
|
|
3627
|
+
* 1. Every leaf (recursively, through nested plain objects) is
|
|
3628
|
+
* registered with the server as a config item, with its value as
|
|
3629
|
+
* the in-code default and a type inferred from `typeof value`.
|
|
3630
|
+
* 2. After the SDK's cache is populated, any server-side overrides for
|
|
3631
|
+
* this config are applied to the bound object in place.
|
|
3651
3632
|
*
|
|
3652
|
-
*
|
|
3653
|
-
*
|
|
3654
|
-
*
|
|
3655
|
-
* in
|
|
3633
|
+
* On every WebSocket-delivered change thereafter the bound object is
|
|
3634
|
+
* mutated in place — readers of `obj.foo` and `obj["foo"]` always see
|
|
3635
|
+
* the current resolved value. The returned object is the same one you
|
|
3636
|
+
* passed in (referential identity preserved).
|
|
3656
3637
|
*
|
|
3657
|
-
*
|
|
3658
|
-
*
|
|
3638
|
+
* Idempotent. Repeated calls with the same id return the originally-
|
|
3639
|
+
* bound object; the new `config` argument is ignored.
|
|
3640
|
+
*
|
|
3641
|
+
* **Plain object literals vs. class instances.** Plain object literals
|
|
3642
|
+
* (e.g., `{ a: 1, b: { c: 2 } }`) are the recommended input shape —
|
|
3643
|
+
* their keys are the explicit override set, and omitted keys inherit
|
|
3644
|
+
* from `parent`. Class instances are also accepted, but every
|
|
3645
|
+
* enumerable property is registered as an explicit override (there is
|
|
3646
|
+
* no JS equivalent of Python's `model_fields_set`); to get omit-to-
|
|
3647
|
+
* inherit semantics, use a plain object literal.
|
|
3648
|
+
*
|
|
3649
|
+
* @param id - The config id to register under.
|
|
3650
|
+
* @param config - A plain object literal (recommended) or class
|
|
3651
|
+
* instance carrying the in-code defaults.
|
|
3652
|
+
* @param options - Optional `parent`: another object previously
|
|
3653
|
+
* returned from a {@link bind} call. Activates parent-chain
|
|
3654
|
+
* inheritance for keys the caller omitted.
|
|
3655
|
+
* @returns The same `config` object, registered and live.
|
|
3656
|
+
* @throws TypeError if `config` is not an object.
|
|
3657
|
+
* @throws Error if `parent` was not previously bound via {@link bind}.
|
|
3659
3658
|
*/
|
|
3660
|
-
|
|
3659
|
+
bind<T extends object>(id: string, config: T, options?: {
|
|
3660
|
+
parent?: object | null;
|
|
3661
|
+
}): Promise<T>;
|
|
3661
3662
|
/**
|
|
3662
|
-
*
|
|
3663
|
+
* Read a config (full) or a single value within a config.
|
|
3663
3664
|
*
|
|
3664
|
-
*
|
|
3665
|
-
* {@link LiveConfigProxy} instance. The first call queues a discovery
|
|
3666
|
-
* payload (the config and any items declared via typed getters on the
|
|
3667
|
-
* returned handle) for upload to `POST /api/v1/configs/bulk` on next
|
|
3668
|
-
* flush. If the config already exists server-side, `managed=true`
|
|
3669
|
-
* configs are left untouched; `managed=false` configs receive the
|
|
3670
|
-
* SDK's items via source-row upsert per ADR-024 §2.9.
|
|
3665
|
+
* Three forms dispatched by argument count:
|
|
3671
3666
|
*
|
|
3672
|
-
*
|
|
3673
|
-
*
|
|
3667
|
+
* - `get(id)` — returns a {@link LiveConfigProxy}, a live dict-like
|
|
3668
|
+
* view. Throws {@link SmplkitNotFoundError} if the config is missing.
|
|
3669
|
+
* No registration.
|
|
3670
|
+
* - `get(id, key)` — returns the resolved value of `key` within `id`.
|
|
3671
|
+
* Throws {@link SmplkitNotFoundError} if either the config or the key
|
|
3672
|
+
* is missing. No registration.
|
|
3673
|
+
* - `get(id, key, defaultValue)` — returns the resolved value, falling
|
|
3674
|
+
* back to `defaultValue` if either is missing. Never throws. Also
|
|
3675
|
+
* **registers** the config (if new) and the key (with `defaultValue`
|
|
3676
|
+
* as its default value) for code-first console observability.
|
|
3674
3677
|
*
|
|
3675
|
-
*
|
|
3678
|
+
* For typed access via a Pydantic-style declarative API, use
|
|
3679
|
+
* {@link bind} instead.
|
|
3676
3680
|
*/
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3681
|
+
get(id: string): Promise<LiveConfigProxy>;
|
|
3682
|
+
get(id: string, key: string): Promise<unknown>;
|
|
3683
|
+
get<V>(id: string, key: string, defaultValue: V): Promise<V | unknown>;
|
|
3684
|
+
/** @internal — return the config_id this object was bound under, or null. */
|
|
3685
|
+
private _configIdFor;
|
|
3686
|
+
/** @internal — apply current cached values to a freshly-bound target. */
|
|
3687
|
+
private _syncTargetFromCache;
|
|
3683
3688
|
/** @internal — return (and cache) the canonical proxy for a config id. */
|
|
3684
|
-
_cachedProxy
|
|
3689
|
+
_cachedProxy(id: string): LiveConfigProxy;
|
|
3685
3690
|
/** @internal — queue a config declaration with the management buffer. */
|
|
3686
3691
|
_observeConfigDeclaration(configId: string, parent: string | null, name: string | null, description: string | null): void;
|
|
3687
3692
|
/** @internal — queue a config item declaration with the management buffer. */
|
|
@@ -3704,17 +3709,14 @@ declare class ConfigClient {
|
|
|
3704
3709
|
* (set via `_resolveManagement`) so runtime + management share one HTTP
|
|
3705
3710
|
* client; falls back to a direct GET when running without `SmplClient`
|
|
3706
3711
|
* bootstrap (e.g. unit tests that construct `ConfigClient` directly).
|
|
3707
|
-
*
|
|
3708
|
-
* Pages through the server until a short page (less than the requested
|
|
3709
|
-
* size) is returned — accounts with more than 1000 configs would
|
|
3710
|
-
* otherwise silently lose everything past page one.
|
|
3711
3712
|
*/
|
|
3712
3713
|
private _listConfigs;
|
|
3713
3714
|
/**
|
|
3714
3715
|
* Eagerly initialize the config subclient — fetch all configs, resolve
|
|
3715
3716
|
* environment-scoped values into the local cache, and subscribe to the
|
|
3716
3717
|
* shared WebSocket for live updates. Idempotent. Called automatically
|
|
3717
|
-
* on first `client.config.get(...)` if not
|
|
3718
|
+
* on first `client.config.get(...)` / `client.config.bind(...)` if not
|
|
3719
|
+
* invoked manually.
|
|
3718
3720
|
*/
|
|
3719
3721
|
start(): Promise<void>;
|
|
3720
3722
|
/** @internal */
|
|
@@ -4161,9 +4163,17 @@ declare class PinoAdapter implements LoggingAdapter {
|
|
|
4161
4163
|
/** A single error object from a JSON:API error response. */
|
|
4162
4164
|
interface ApiErrorDetail {
|
|
4163
4165
|
status?: string;
|
|
4166
|
+
/**
|
|
4167
|
+
* Application-specific machine-readable error code (e.g.
|
|
4168
|
+
* ``environment_unmanaged``). Per JSON:API §7 and ADR-014, the server
|
|
4169
|
+
* sets this on every error so callers can branch without string-matching.
|
|
4170
|
+
*/
|
|
4171
|
+
code?: string;
|
|
4164
4172
|
title?: string;
|
|
4165
4173
|
detail?: string;
|
|
4166
4174
|
source?: Record<string, unknown>;
|
|
4175
|
+
/** Additional structured context (e.g. ``{environment: "staging"}``). */
|
|
4176
|
+
meta?: Record<string, unknown>;
|
|
4167
4177
|
}
|
|
4168
4178
|
/** Base exception for all smplkit SDK errors. */
|
|
4169
4179
|
declare class SmplError extends Error {
|