@smplkit/sdk 1.3.22 → 1.3.24

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.js CHANGED
@@ -16766,12 +16766,11 @@ var Config = class {
16766
16766
  description;
16767
16767
  /** Parent config UUID, or null if this is a root config. */
16768
16768
  parent;
16769
- /** Base key-value pairs (unwrapped from typed item definitions). */
16769
+ /** Base key-value pairs. */
16770
16770
  items;
16771
16771
  /**
16772
16772
  * Per-environment overrides.
16773
- * Stored as `{ env_name: { values: { key: value } } }` — values are
16774
- * unwrapped from the server's `{ value: raw }` wrapper.
16773
+ * Structured as `{ env_name: { values: { key: value } } }`.
16775
16774
  */
16776
16775
  environments;
16777
16776
  /** When the config was created, or null if unavailable. */
@@ -16796,7 +16795,7 @@ var Config = class {
16796
16795
  /**
16797
16796
  * Persist this config to the server.
16798
16797
  *
16799
- * POST if `id` is null (new config), PUT if `id` is set (update).
16798
+ * Creates if new, updates if existing.
16800
16799
  * Updates this instance in-place with the server response.
16801
16800
  */
16802
16801
  async save() {
@@ -17174,9 +17173,7 @@ var ConfigClient = class {
17174
17173
  /**
17175
17174
  * Resolve a config's values for the current environment.
17176
17175
  *
17177
- * Returns a flat dict of resolved key-value pairs, walking the
17178
- * parent chain and applying environment overrides.
17179
- *
17176
+ * Returns the resolved key-value pairs for the given config.
17180
17177
  * Optionally pass a model class to map the resolved values.
17181
17178
  */
17182
17179
  async resolve(key, model) {
@@ -17191,8 +17188,8 @@ var ConfigClient = class {
17191
17188
  return values;
17192
17189
  }
17193
17190
  /**
17194
- * Subscribe to a config's values returns a live proxy that
17195
- * auto-updates when the underlying config changes.
17191
+ * Subscribe to a config's values. Returns a proxy whose properties
17192
+ * always reflect the latest resolved values.
17196
17193
  *
17197
17194
  * Optionally pass a model class to map the resolved values.
17198
17195
  */
@@ -17238,8 +17235,8 @@ var ConfigClient = class {
17238
17235
  // Runtime: refresh
17239
17236
  // ------------------------------------------------------------------
17240
17237
  /**
17241
- * Re-fetch all configs, re-resolve values, and update the cache.
17242
- * Fires change listeners for any values that differ.
17238
+ * Refresh all config values from the server.
17239
+ * Fires change listeners for any values that changed.
17243
17240
  */
17244
17241
  async refresh() {
17245
17242
  if (!this._initialized) {
@@ -17404,7 +17401,7 @@ var Flag = class {
17404
17401
  /**
17405
17402
  * Persist this flag to the server.
17406
17403
  *
17407
- * POST if `id` is null (new flag), PUT if `id` is set (update).
17404
+ * Creates if new, updates if existing.
17408
17405
  * Updates this instance in-place with the server response.
17409
17406
  */
17410
17407
  async save() {
@@ -17417,10 +17414,10 @@ var Flag = class {
17417
17414
  }
17418
17415
  }
17419
17416
  /**
17420
- * Add a rule to a specific environment (sync local mutation).
17417
+ * Add a rule to a specific environment.
17421
17418
  *
17422
17419
  * The built rule must include an `environment` key (set via
17423
- * `Rule(...).environment("env_key")`). No HTTP call is made.
17420
+ * `Rule(...).environment("env_key")`). Call `save()` to persist.
17424
17421
  *
17425
17422
  * @returns `this` for chaining.
17426
17423
  */
@@ -17441,7 +17438,7 @@ var Flag = class {
17441
17438
  this.environments = envs;
17442
17439
  return this;
17443
17440
  }
17444
- /** Enable or disable a flag in a specific environment (sync local mutation). */
17441
+ /** Enable or disable a flag in a specific environment. Call `save()` to persist. */
17445
17442
  setEnvironmentEnabled(envKey, enabled) {
17446
17443
  const envs = { ...this.environments };
17447
17444
  const envData = { ...envs[envKey] ?? { enabled: false, rules: [] } };
@@ -17449,7 +17446,7 @@ var Flag = class {
17449
17446
  envs[envKey] = envData;
17450
17447
  this.environments = envs;
17451
17448
  }
17452
- /** Set the default value for a specific environment (sync local mutation). */
17449
+ /** Set the default value for a specific environment. Call `save()` to persist. */
17453
17450
  setEnvironmentDefault(envKey, defaultValue) {
17454
17451
  const envs = { ...this.environments };
17455
17452
  const envData = { ...envs[envKey] ?? { enabled: false, rules: [] } };
@@ -17457,7 +17454,7 @@ var Flag = class {
17457
17454
  envs[envKey] = envData;
17458
17455
  this.environments = envs;
17459
17456
  }
17460
- /** Clear all rules for a specific environment (sync local mutation). */
17457
+ /** Clear all rules for a specific environment. Call `save()` to persist. */
17461
17458
  clearRules(envKey) {
17462
17459
  const envs = { ...this.environments };
17463
17460
  const envData = envs[envKey];
@@ -17467,9 +17464,9 @@ var Flag = class {
17467
17464
  }
17468
17465
  }
17469
17466
  /**
17470
- * Evaluate the flag locally (sync, no HTTP).
17467
+ * Evaluate the flag and return its current value.
17471
17468
  *
17472
- * Requires `initialize()` to have been called.
17469
+ * Requires `initialize()` to have been called on the flags client.
17473
17470
  */
17474
17471
  get(options) {
17475
17472
  return this._client._evaluateHandle(this.key, this.default, options?.context ?? null);
@@ -18011,7 +18008,7 @@ var FlagsClient = class {
18011
18008
  // Runtime: initialize / disconnect / refresh
18012
18009
  // ------------------------------------------------------------------
18013
18010
  /**
18014
- * Initialize the flags runtime: fetch definitions and wire WebSocket.
18011
+ * Initialize the flags runtime.
18015
18012
  *
18016
18013
  * Idempotent — safe to call multiple times. Must be called (and awaited)
18017
18014
  * before using `.get()` on flag handles.
@@ -18026,7 +18023,7 @@ var FlagsClient = class {
18026
18023
  this._wsManager.on("flag_changed", this._handleFlagChanged);
18027
18024
  this._wsManager.on("flag_deleted", this._handleFlagDeleted);
18028
18025
  }
18029
- /** Disconnect: unregister from WebSocket, flush contexts, clear state. */
18026
+ /** Disconnect the flags runtime and release resources. */
18030
18027
  async disconnect() {
18031
18028
  if (this._wsManager !== null) {
18032
18029
  this._wsManager.off("flag_changed", this._handleFlagChanged);
@@ -18039,30 +18036,30 @@ var FlagsClient = class {
18039
18036
  this._initialized = false;
18040
18037
  this._environment = null;
18041
18038
  }
18042
- /** Re-fetch all flag definitions and clear cache. */
18039
+ /** Refresh all flag definitions from the server. */
18043
18040
  async refresh() {
18044
18041
  await this._fetchAllFlags();
18045
18042
  this._cache.clear();
18046
18043
  this._fireChangeListenersAll("manual");
18047
18044
  }
18048
- /** Return the current WebSocket connection status. */
18045
+ /** Return the current real-time connection status. */
18049
18046
  connectionStatus() {
18050
18047
  if (this._wsManager !== null) {
18051
18048
  return this._wsManager.connectionStatus;
18052
18049
  }
18053
18050
  return "disconnected";
18054
18051
  }
18055
- /** Return cache statistics. */
18052
+ /** Return evaluation statistics. */
18056
18053
  stats() {
18057
18054
  return new FlagStats(this._cache.cacheHits, this._cache.cacheMisses);
18058
18055
  }
18059
18056
  // ------------------------------------------------------------------
18060
- // Runtime: change listeners (dual-mode)
18057
+ // Runtime: change listeners
18061
18058
  // ------------------------------------------------------------------
18062
18059
  /**
18063
18060
  * Register a change listener.
18064
18061
  *
18065
- * - `onChange(callback)` — fires for any flag change (global).
18062
+ * - `onChange(callback)` — fires for any flag change.
18066
18063
  * - `onChange(key, callback)` — fires only for the specified flag key.
18067
18064
  */
18068
18065
  onChange(callbackOrKey, callback) {
@@ -18083,10 +18080,9 @@ var FlagsClient = class {
18083
18080
  // Runtime: context registration
18084
18081
  // ------------------------------------------------------------------
18085
18082
  /**
18086
- * Explicitly register context(s) for background batch registration.
18083
+ * Register context(s) with the server.
18087
18084
  *
18088
- * Accepts a single Context or an array. Fire-and-forget never
18089
- * blocks. Works before `initialize()` is called.
18085
+ * Accepts a single Context or an array. Works before `initialize()` is called.
18090
18086
  */
18091
18087
  register(context) {
18092
18088
  if (Array.isArray(context)) {
@@ -18103,7 +18099,7 @@ var FlagsClient = class {
18103
18099
  // Runtime: Tier 1 evaluate
18104
18100
  // ------------------------------------------------------------------
18105
18101
  /**
18106
- * Tier 1 explicit evaluation stateless, no provider or cache.
18102
+ * Evaluate a flag with an explicit environment and context.
18107
18103
  */
18108
18104
  async evaluate(key, options) {
18109
18105
  const evalDict = contextsToEvalDict(options.context);
@@ -18346,27 +18342,27 @@ var Logger = class {
18346
18342
  /**
18347
18343
  * Persist this logger to the server.
18348
18344
  *
18349
- * POST if `id` is null (new), PUT if `id` is set (update).
18345
+ * Creates if new, updates if existing.
18350
18346
  */
18351
18347
  async save() {
18352
18348
  const saved = await this._client._saveLogger(this);
18353
18349
  this._apply(saved);
18354
18350
  }
18355
- /** Set the base log level (sync local mutation). */
18351
+ /** Set the base log level. Call `save()` to persist. */
18356
18352
  setLevel(level) {
18357
18353
  this.level = level;
18358
18354
  }
18359
- /** Clear the base log level (sync local mutation). */
18355
+ /** Clear the base log level. Call `save()` to persist. */
18360
18356
  clearLevel() {
18361
18357
  this.level = null;
18362
18358
  }
18363
- /** Set an environment-specific log level (sync local mutation). */
18359
+ /** Set an environment-specific log level. Call `save()` to persist. */
18364
18360
  setEnvironmentLevel(env, level) {
18365
18361
  const envs = { ...this.environments };
18366
18362
  envs[env] = { ...envs[env] ?? {}, level };
18367
18363
  this.environments = envs;
18368
18364
  }
18369
- /** Clear an environment-specific log level (sync local mutation). */
18365
+ /** Clear an environment-specific log level. Call `save()` to persist. */
18370
18366
  clearEnvironmentLevel(env) {
18371
18367
  const envs = { ...this.environments };
18372
18368
  if (envs[env]) {
@@ -18376,7 +18372,7 @@ var Logger = class {
18376
18372
  this.environments = envs;
18377
18373
  }
18378
18374
  }
18379
- /** Clear all environment-specific log levels (sync local mutation). */
18375
+ /** Clear all environment-specific log levels. Call `save()` to persist. */
18380
18376
  clearAllEnvironmentLevels() {
18381
18377
  this.environments = {};
18382
18378
  }
@@ -18431,27 +18427,27 @@ var LogGroup = class {
18431
18427
  /**
18432
18428
  * Persist this log group to the server.
18433
18429
  *
18434
- * POST if `id` is null (new), PUT if `id` is set (update).
18430
+ * Creates if new, updates if existing.
18435
18431
  */
18436
18432
  async save() {
18437
18433
  const saved = await this._client._saveLogGroup(this);
18438
18434
  this._apply(saved);
18439
18435
  }
18440
- /** Set the base log level (sync local mutation). */
18436
+ /** Set the base log level. Call `save()` to persist. */
18441
18437
  setLevel(level) {
18442
18438
  this.level = level;
18443
18439
  }
18444
- /** Clear the base log level (sync local mutation). */
18440
+ /** Clear the base log level. Call `save()` to persist. */
18445
18441
  clearLevel() {
18446
18442
  this.level = null;
18447
18443
  }
18448
- /** Set an environment-specific log level (sync local mutation). */
18444
+ /** Set an environment-specific log level. Call `save()` to persist. */
18449
18445
  setEnvironmentLevel(env, level) {
18450
18446
  const envs = { ...this.environments };
18451
18447
  envs[env] = { ...envs[env] ?? {}, level };
18452
18448
  this.environments = envs;
18453
18449
  }
18454
- /** Clear an environment-specific log level (sync local mutation). */
18450
+ /** Clear an environment-specific log level. Call `save()` to persist. */
18455
18451
  clearEnvironmentLevel(env) {
18456
18452
  const envs = { ...this.environments };
18457
18453
  if (envs[env]) {
@@ -18461,7 +18457,7 @@ var LogGroup = class {
18461
18457
  this.environments = envs;
18462
18458
  }
18463
18459
  }
18464
- /** Clear all environment-specific log levels (sync local mutation). */
18460
+ /** Clear all environment-specific log levels. Call `save()` to persist. */
18465
18461
  clearAllEnvironmentLevels() {
18466
18462
  this.environments = {};
18467
18463
  }
@@ -18547,8 +18543,8 @@ var LoggingClient = class {
18547
18543
  /**
18548
18544
  * Register a logging framework adapter.
18549
18545
  *
18550
- * Must be called before `start()`. Disables auto-loading of built-in
18551
- * adapters — only explicitly registered adapters will be used.
18546
+ * Must be called before `start()`. When called, only explicitly
18547
+ * registered adapters will be used.
18552
18548
  */
18553
18549
  registerAdapter(adapter) {
18554
18550
  if (this._started) {
@@ -18775,17 +18771,9 @@ var LoggingClient = class {
18775
18771
  /**
18776
18772
  * Start the logging runtime.
18777
18773
  *
18778
- * Performs the full runtime pipeline:
18779
- * 1. Auto-load adapters (if none registered explicitly)
18780
- * 2. Discover existing loggers from each adapter
18781
- * 3. Install hooks on each adapter for new logger creation
18782
- * 4. Bulk-register discovered loggers with the server
18783
- * 5. Fetch all loggers and groups from the server
18784
- * 6. Resolve levels and apply to adapters
18785
- * 7. Wire WebSocket for live updates
18786
- *
18787
- * Idempotent — safe to call multiple times.
18788
- * Management methods work without start().
18774
+ * Synchronizes loggers with the server and subscribes to live level
18775
+ * updates. Idempotent safe to call multiple times.
18776
+ * Management methods work without calling `start()`.
18789
18777
  */
18790
18778
  async start() {
18791
18779
  if (this._started) return;
@@ -18826,12 +18814,12 @@ var LoggingClient = class {
18826
18814
  this._started = true;
18827
18815
  }
18828
18816
  // ------------------------------------------------------------------
18829
- // Runtime: change listeners (dual-mode)
18817
+ // Runtime: change listeners
18830
18818
  // ------------------------------------------------------------------
18831
18819
  /**
18832
18820
  * Register a change listener.
18833
18821
  *
18834
- * - `onChange(callback)` — fires for any logger change (global).
18822
+ * - `onChange(callback)` — fires for any logger change.
18835
18823
  * - `onChange(key, callback)` — fires only for the specified logger key.
18836
18824
  */
18837
18825
  onChange(callbackOrKey, callback) {