@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.cjs +45 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -135
- package/dist/index.d.ts +70 -135
- package/dist/index.js +45 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -16804,12 +16804,11 @@ var Config = class {
|
|
|
16804
16804
|
description;
|
|
16805
16805
|
/** Parent config UUID, or null if this is a root config. */
|
|
16806
16806
|
parent;
|
|
16807
|
-
/** Base key-value pairs
|
|
16807
|
+
/** Base key-value pairs. */
|
|
16808
16808
|
items;
|
|
16809
16809
|
/**
|
|
16810
16810
|
* Per-environment overrides.
|
|
16811
|
-
*
|
|
16812
|
-
* unwrapped from the server's `{ value: raw }` wrapper.
|
|
16811
|
+
* Structured as `{ env_name: { values: { key: value } } }`.
|
|
16813
16812
|
*/
|
|
16814
16813
|
environments;
|
|
16815
16814
|
/** When the config was created, or null if unavailable. */
|
|
@@ -16834,7 +16833,7 @@ var Config = class {
|
|
|
16834
16833
|
/**
|
|
16835
16834
|
* Persist this config to the server.
|
|
16836
16835
|
*
|
|
16837
|
-
*
|
|
16836
|
+
* Creates if new, updates if existing.
|
|
16838
16837
|
* Updates this instance in-place with the server response.
|
|
16839
16838
|
*/
|
|
16840
16839
|
async save() {
|
|
@@ -17212,9 +17211,7 @@ var ConfigClient = class {
|
|
|
17212
17211
|
/**
|
|
17213
17212
|
* Resolve a config's values for the current environment.
|
|
17214
17213
|
*
|
|
17215
|
-
* Returns
|
|
17216
|
-
* parent chain and applying environment overrides.
|
|
17217
|
-
*
|
|
17214
|
+
* Returns the resolved key-value pairs for the given config.
|
|
17218
17215
|
* Optionally pass a model class to map the resolved values.
|
|
17219
17216
|
*/
|
|
17220
17217
|
async resolve(key, model) {
|
|
@@ -17229,8 +17226,8 @@ var ConfigClient = class {
|
|
|
17229
17226
|
return values;
|
|
17230
17227
|
}
|
|
17231
17228
|
/**
|
|
17232
|
-
* Subscribe to a config's values
|
|
17233
|
-
*
|
|
17229
|
+
* Subscribe to a config's values. Returns a proxy whose properties
|
|
17230
|
+
* always reflect the latest resolved values.
|
|
17234
17231
|
*
|
|
17235
17232
|
* Optionally pass a model class to map the resolved values.
|
|
17236
17233
|
*/
|
|
@@ -17276,8 +17273,8 @@ var ConfigClient = class {
|
|
|
17276
17273
|
// Runtime: refresh
|
|
17277
17274
|
// ------------------------------------------------------------------
|
|
17278
17275
|
/**
|
|
17279
|
-
*
|
|
17280
|
-
* Fires change listeners for any values that
|
|
17276
|
+
* Refresh all config values from the server.
|
|
17277
|
+
* Fires change listeners for any values that changed.
|
|
17281
17278
|
*/
|
|
17282
17279
|
async refresh() {
|
|
17283
17280
|
if (!this._initialized) {
|
|
@@ -17442,7 +17439,7 @@ var Flag = class {
|
|
|
17442
17439
|
/**
|
|
17443
17440
|
* Persist this flag to the server.
|
|
17444
17441
|
*
|
|
17445
|
-
*
|
|
17442
|
+
* Creates if new, updates if existing.
|
|
17446
17443
|
* Updates this instance in-place with the server response.
|
|
17447
17444
|
*/
|
|
17448
17445
|
async save() {
|
|
@@ -17455,10 +17452,10 @@ var Flag = class {
|
|
|
17455
17452
|
}
|
|
17456
17453
|
}
|
|
17457
17454
|
/**
|
|
17458
|
-
* Add a rule to a specific environment
|
|
17455
|
+
* Add a rule to a specific environment.
|
|
17459
17456
|
*
|
|
17460
17457
|
* The built rule must include an `environment` key (set via
|
|
17461
|
-
* `Rule(...).environment("env_key")`).
|
|
17458
|
+
* `Rule(...).environment("env_key")`). Call `save()` to persist.
|
|
17462
17459
|
*
|
|
17463
17460
|
* @returns `this` for chaining.
|
|
17464
17461
|
*/
|
|
@@ -17479,7 +17476,7 @@ var Flag = class {
|
|
|
17479
17476
|
this.environments = envs;
|
|
17480
17477
|
return this;
|
|
17481
17478
|
}
|
|
17482
|
-
/** Enable or disable a flag in a specific environment (
|
|
17479
|
+
/** Enable or disable a flag in a specific environment. Call `save()` to persist. */
|
|
17483
17480
|
setEnvironmentEnabled(envKey, enabled) {
|
|
17484
17481
|
const envs = { ...this.environments };
|
|
17485
17482
|
const envData = { ...envs[envKey] ?? { enabled: false, rules: [] } };
|
|
@@ -17487,7 +17484,7 @@ var Flag = class {
|
|
|
17487
17484
|
envs[envKey] = envData;
|
|
17488
17485
|
this.environments = envs;
|
|
17489
17486
|
}
|
|
17490
|
-
/** Set the default value for a specific environment (
|
|
17487
|
+
/** Set the default value for a specific environment. Call `save()` to persist. */
|
|
17491
17488
|
setEnvironmentDefault(envKey, defaultValue) {
|
|
17492
17489
|
const envs = { ...this.environments };
|
|
17493
17490
|
const envData = { ...envs[envKey] ?? { enabled: false, rules: [] } };
|
|
@@ -17495,7 +17492,7 @@ var Flag = class {
|
|
|
17495
17492
|
envs[envKey] = envData;
|
|
17496
17493
|
this.environments = envs;
|
|
17497
17494
|
}
|
|
17498
|
-
/** Clear all rules for a specific environment (
|
|
17495
|
+
/** Clear all rules for a specific environment. Call `save()` to persist. */
|
|
17499
17496
|
clearRules(envKey) {
|
|
17500
17497
|
const envs = { ...this.environments };
|
|
17501
17498
|
const envData = envs[envKey];
|
|
@@ -17505,9 +17502,9 @@ var Flag = class {
|
|
|
17505
17502
|
}
|
|
17506
17503
|
}
|
|
17507
17504
|
/**
|
|
17508
|
-
* Evaluate the flag
|
|
17505
|
+
* Evaluate the flag and return its current value.
|
|
17509
17506
|
*
|
|
17510
|
-
* Requires `initialize()` to have been called.
|
|
17507
|
+
* Requires `initialize()` to have been called on the flags client.
|
|
17511
17508
|
*/
|
|
17512
17509
|
get(options) {
|
|
17513
17510
|
return this._client._evaluateHandle(this.key, this.default, options?.context ?? null);
|
|
@@ -18049,7 +18046,7 @@ var FlagsClient = class {
|
|
|
18049
18046
|
// Runtime: initialize / disconnect / refresh
|
|
18050
18047
|
// ------------------------------------------------------------------
|
|
18051
18048
|
/**
|
|
18052
|
-
* Initialize the flags runtime
|
|
18049
|
+
* Initialize the flags runtime.
|
|
18053
18050
|
*
|
|
18054
18051
|
* Idempotent — safe to call multiple times. Must be called (and awaited)
|
|
18055
18052
|
* before using `.get()` on flag handles.
|
|
@@ -18064,7 +18061,7 @@ var FlagsClient = class {
|
|
|
18064
18061
|
this._wsManager.on("flag_changed", this._handleFlagChanged);
|
|
18065
18062
|
this._wsManager.on("flag_deleted", this._handleFlagDeleted);
|
|
18066
18063
|
}
|
|
18067
|
-
/** Disconnect
|
|
18064
|
+
/** Disconnect the flags runtime and release resources. */
|
|
18068
18065
|
async disconnect() {
|
|
18069
18066
|
if (this._wsManager !== null) {
|
|
18070
18067
|
this._wsManager.off("flag_changed", this._handleFlagChanged);
|
|
@@ -18077,30 +18074,30 @@ var FlagsClient = class {
|
|
|
18077
18074
|
this._initialized = false;
|
|
18078
18075
|
this._environment = null;
|
|
18079
18076
|
}
|
|
18080
|
-
/**
|
|
18077
|
+
/** Refresh all flag definitions from the server. */
|
|
18081
18078
|
async refresh() {
|
|
18082
18079
|
await this._fetchAllFlags();
|
|
18083
18080
|
this._cache.clear();
|
|
18084
18081
|
this._fireChangeListenersAll("manual");
|
|
18085
18082
|
}
|
|
18086
|
-
/** Return the current
|
|
18083
|
+
/** Return the current real-time connection status. */
|
|
18087
18084
|
connectionStatus() {
|
|
18088
18085
|
if (this._wsManager !== null) {
|
|
18089
18086
|
return this._wsManager.connectionStatus;
|
|
18090
18087
|
}
|
|
18091
18088
|
return "disconnected";
|
|
18092
18089
|
}
|
|
18093
|
-
/** Return
|
|
18090
|
+
/** Return evaluation statistics. */
|
|
18094
18091
|
stats() {
|
|
18095
18092
|
return new FlagStats(this._cache.cacheHits, this._cache.cacheMisses);
|
|
18096
18093
|
}
|
|
18097
18094
|
// ------------------------------------------------------------------
|
|
18098
|
-
// Runtime: change listeners
|
|
18095
|
+
// Runtime: change listeners
|
|
18099
18096
|
// ------------------------------------------------------------------
|
|
18100
18097
|
/**
|
|
18101
18098
|
* Register a change listener.
|
|
18102
18099
|
*
|
|
18103
|
-
* - `onChange(callback)` — fires for any flag change
|
|
18100
|
+
* - `onChange(callback)` — fires for any flag change.
|
|
18104
18101
|
* - `onChange(key, callback)` — fires only for the specified flag key.
|
|
18105
18102
|
*/
|
|
18106
18103
|
onChange(callbackOrKey, callback) {
|
|
@@ -18121,10 +18118,9 @@ var FlagsClient = class {
|
|
|
18121
18118
|
// Runtime: context registration
|
|
18122
18119
|
// ------------------------------------------------------------------
|
|
18123
18120
|
/**
|
|
18124
|
-
*
|
|
18121
|
+
* Register context(s) with the server.
|
|
18125
18122
|
*
|
|
18126
|
-
* Accepts a single Context or an array.
|
|
18127
|
-
* blocks. Works before `initialize()` is called.
|
|
18123
|
+
* Accepts a single Context or an array. Works before `initialize()` is called.
|
|
18128
18124
|
*/
|
|
18129
18125
|
register(context) {
|
|
18130
18126
|
if (Array.isArray(context)) {
|
|
@@ -18141,7 +18137,7 @@ var FlagsClient = class {
|
|
|
18141
18137
|
// Runtime: Tier 1 evaluate
|
|
18142
18138
|
// ------------------------------------------------------------------
|
|
18143
18139
|
/**
|
|
18144
|
-
*
|
|
18140
|
+
* Evaluate a flag with an explicit environment and context.
|
|
18145
18141
|
*/
|
|
18146
18142
|
async evaluate(key, options) {
|
|
18147
18143
|
const evalDict = contextsToEvalDict(options.context);
|
|
@@ -18384,27 +18380,27 @@ var Logger = class {
|
|
|
18384
18380
|
/**
|
|
18385
18381
|
* Persist this logger to the server.
|
|
18386
18382
|
*
|
|
18387
|
-
*
|
|
18383
|
+
* Creates if new, updates if existing.
|
|
18388
18384
|
*/
|
|
18389
18385
|
async save() {
|
|
18390
18386
|
const saved = await this._client._saveLogger(this);
|
|
18391
18387
|
this._apply(saved);
|
|
18392
18388
|
}
|
|
18393
|
-
/** Set the base log level (
|
|
18389
|
+
/** Set the base log level. Call `save()` to persist. */
|
|
18394
18390
|
setLevel(level) {
|
|
18395
18391
|
this.level = level;
|
|
18396
18392
|
}
|
|
18397
|
-
/** Clear the base log level (
|
|
18393
|
+
/** Clear the base log level. Call `save()` to persist. */
|
|
18398
18394
|
clearLevel() {
|
|
18399
18395
|
this.level = null;
|
|
18400
18396
|
}
|
|
18401
|
-
/** Set an environment-specific log level (
|
|
18397
|
+
/** Set an environment-specific log level. Call `save()` to persist. */
|
|
18402
18398
|
setEnvironmentLevel(env, level) {
|
|
18403
18399
|
const envs = { ...this.environments };
|
|
18404
18400
|
envs[env] = { ...envs[env] ?? {}, level };
|
|
18405
18401
|
this.environments = envs;
|
|
18406
18402
|
}
|
|
18407
|
-
/** Clear an environment-specific log level (
|
|
18403
|
+
/** Clear an environment-specific log level. Call `save()` to persist. */
|
|
18408
18404
|
clearEnvironmentLevel(env) {
|
|
18409
18405
|
const envs = { ...this.environments };
|
|
18410
18406
|
if (envs[env]) {
|
|
@@ -18414,7 +18410,7 @@ var Logger = class {
|
|
|
18414
18410
|
this.environments = envs;
|
|
18415
18411
|
}
|
|
18416
18412
|
}
|
|
18417
|
-
/** Clear all environment-specific log levels (
|
|
18413
|
+
/** Clear all environment-specific log levels. Call `save()` to persist. */
|
|
18418
18414
|
clearAllEnvironmentLevels() {
|
|
18419
18415
|
this.environments = {};
|
|
18420
18416
|
}
|
|
@@ -18469,27 +18465,27 @@ var LogGroup = class {
|
|
|
18469
18465
|
/**
|
|
18470
18466
|
* Persist this log group to the server.
|
|
18471
18467
|
*
|
|
18472
|
-
*
|
|
18468
|
+
* Creates if new, updates if existing.
|
|
18473
18469
|
*/
|
|
18474
18470
|
async save() {
|
|
18475
18471
|
const saved = await this._client._saveLogGroup(this);
|
|
18476
18472
|
this._apply(saved);
|
|
18477
18473
|
}
|
|
18478
|
-
/** Set the base log level (
|
|
18474
|
+
/** Set the base log level. Call `save()` to persist. */
|
|
18479
18475
|
setLevel(level) {
|
|
18480
18476
|
this.level = level;
|
|
18481
18477
|
}
|
|
18482
|
-
/** Clear the base log level (
|
|
18478
|
+
/** Clear the base log level. Call `save()` to persist. */
|
|
18483
18479
|
clearLevel() {
|
|
18484
18480
|
this.level = null;
|
|
18485
18481
|
}
|
|
18486
|
-
/** Set an environment-specific log level (
|
|
18482
|
+
/** Set an environment-specific log level. Call `save()` to persist. */
|
|
18487
18483
|
setEnvironmentLevel(env, level) {
|
|
18488
18484
|
const envs = { ...this.environments };
|
|
18489
18485
|
envs[env] = { ...envs[env] ?? {}, level };
|
|
18490
18486
|
this.environments = envs;
|
|
18491
18487
|
}
|
|
18492
|
-
/** Clear an environment-specific log level (
|
|
18488
|
+
/** Clear an environment-specific log level. Call `save()` to persist. */
|
|
18493
18489
|
clearEnvironmentLevel(env) {
|
|
18494
18490
|
const envs = { ...this.environments };
|
|
18495
18491
|
if (envs[env]) {
|
|
@@ -18499,7 +18495,7 @@ var LogGroup = class {
|
|
|
18499
18495
|
this.environments = envs;
|
|
18500
18496
|
}
|
|
18501
18497
|
}
|
|
18502
|
-
/** Clear all environment-specific log levels (
|
|
18498
|
+
/** Clear all environment-specific log levels. Call `save()` to persist. */
|
|
18503
18499
|
clearAllEnvironmentLevels() {
|
|
18504
18500
|
this.environments = {};
|
|
18505
18501
|
}
|
|
@@ -18585,8 +18581,8 @@ var LoggingClient = class {
|
|
|
18585
18581
|
/**
|
|
18586
18582
|
* Register a logging framework adapter.
|
|
18587
18583
|
*
|
|
18588
|
-
* Must be called before `start()`.
|
|
18589
|
-
*
|
|
18584
|
+
* Must be called before `start()`. When called, only explicitly
|
|
18585
|
+
* registered adapters will be used.
|
|
18590
18586
|
*/
|
|
18591
18587
|
registerAdapter(adapter) {
|
|
18592
18588
|
if (this._started) {
|
|
@@ -18813,17 +18809,9 @@ var LoggingClient = class {
|
|
|
18813
18809
|
/**
|
|
18814
18810
|
* Start the logging runtime.
|
|
18815
18811
|
*
|
|
18816
|
-
*
|
|
18817
|
-
*
|
|
18818
|
-
*
|
|
18819
|
-
* 3. Install hooks on each adapter for new logger creation
|
|
18820
|
-
* 4. Bulk-register discovered loggers with the server
|
|
18821
|
-
* 5. Fetch all loggers and groups from the server
|
|
18822
|
-
* 6. Resolve levels and apply to adapters
|
|
18823
|
-
* 7. Wire WebSocket for live updates
|
|
18824
|
-
*
|
|
18825
|
-
* Idempotent — safe to call multiple times.
|
|
18826
|
-
* Management methods work without start().
|
|
18812
|
+
* Synchronizes loggers with the server and subscribes to live level
|
|
18813
|
+
* updates. Idempotent — safe to call multiple times.
|
|
18814
|
+
* Management methods work without calling `start()`.
|
|
18827
18815
|
*/
|
|
18828
18816
|
async start() {
|
|
18829
18817
|
if (this._started) return;
|
|
@@ -18864,12 +18852,12 @@ var LoggingClient = class {
|
|
|
18864
18852
|
this._started = true;
|
|
18865
18853
|
}
|
|
18866
18854
|
// ------------------------------------------------------------------
|
|
18867
|
-
// Runtime: change listeners
|
|
18855
|
+
// Runtime: change listeners
|
|
18868
18856
|
// ------------------------------------------------------------------
|
|
18869
18857
|
/**
|
|
18870
18858
|
* Register a change listener.
|
|
18871
18859
|
*
|
|
18872
|
-
* - `onChange(callback)` — fires for any logger change
|
|
18860
|
+
* - `onChange(callback)` — fires for any logger change.
|
|
18873
18861
|
* - `onChange(key, callback)` — fires only for the specified logger key.
|
|
18874
18862
|
*/
|
|
18875
18863
|
onChange(callbackOrKey, callback) {
|