@smplkit/sdk 1.3.21 → 1.3.23
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 +16960 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +136 -34
- package/dist/index.d.ts +136 -34
- package/dist/index.js +16970 -19
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -53,7 +53,7 @@ declare class SharedWebSocket {
|
|
|
53
53
|
* A configuration resource managed by the smplkit platform.
|
|
54
54
|
*
|
|
55
55
|
* Management: mutate properties directly and call `save()` to persist.
|
|
56
|
-
*
|
|
56
|
+
* Creates if new, updates if existing.
|
|
57
57
|
*/
|
|
58
58
|
declare class Config {
|
|
59
59
|
/** UUID of the config, or `null` if unsaved. */
|
|
@@ -70,8 +70,7 @@ declare class Config {
|
|
|
70
70
|
items: Record<string, unknown>;
|
|
71
71
|
/**
|
|
72
72
|
* Per-environment overrides.
|
|
73
|
-
*
|
|
74
|
-
* unwrapped from the server's `{ value: raw }` wrapper.
|
|
73
|
+
* Structured as `{ env_name: { values: { key: value } } }`.
|
|
75
74
|
*/
|
|
76
75
|
environments: Record<string, unknown>;
|
|
77
76
|
/** When the config was created, or null if unavailable. */
|
|
@@ -95,7 +94,7 @@ declare class Config {
|
|
|
95
94
|
/**
|
|
96
95
|
* Persist this config to the server.
|
|
97
96
|
*
|
|
98
|
-
*
|
|
97
|
+
* Creates if new, updates if existing.
|
|
99
98
|
* Updates this instance in-place with the server response.
|
|
100
99
|
*/
|
|
101
100
|
save(): Promise<void>;
|
|
@@ -118,17 +117,17 @@ declare class Config {
|
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
/**
|
|
121
|
-
* LiveConfigProxy —
|
|
120
|
+
* LiveConfigProxy — live configuration access.
|
|
122
121
|
*
|
|
123
|
-
* Property reads
|
|
124
|
-
*
|
|
125
|
-
*
|
|
122
|
+
* Property reads always return the latest resolved values. When the
|
|
123
|
+
* underlying config changes, subsequent reads automatically reflect
|
|
124
|
+
* the new values.
|
|
126
125
|
*/
|
|
127
126
|
|
|
128
127
|
/**
|
|
129
128
|
* A live proxy that auto-updates when the underlying config changes.
|
|
130
129
|
*
|
|
131
|
-
* Access properties directly — each read
|
|
130
|
+
* Access properties directly — each read returns the latest resolved value.
|
|
132
131
|
*
|
|
133
132
|
* @example
|
|
134
133
|
* ```typescript
|
|
@@ -208,8 +207,8 @@ declare class ConfigClient {
|
|
|
208
207
|
/**
|
|
209
208
|
* Resolve a config's values for the current environment.
|
|
210
209
|
*
|
|
211
|
-
* Returns a flat dict of resolved key-value pairs
|
|
212
|
-
*
|
|
210
|
+
* Returns a flat dict of resolved key-value pairs with inherited
|
|
211
|
+
* values and environment overrides applied.
|
|
213
212
|
*
|
|
214
213
|
* Optionally pass a model class to map the resolved values.
|
|
215
214
|
*/
|
|
@@ -230,7 +229,7 @@ declare class ConfigClient {
|
|
|
230
229
|
*/
|
|
231
230
|
onChange(callbackOrConfigKey: string | ((event: ConfigChangeEvent) => void), callbackOrItemKey?: string | ((event: ConfigChangeEvent) => void), callback?: (event: ConfigChangeEvent) => void): void;
|
|
232
231
|
/**
|
|
233
|
-
* Re-fetch all configs
|
|
232
|
+
* Re-fetch all configs and re-resolve values.
|
|
234
233
|
* Fires change listeners for any values that differ.
|
|
235
234
|
*/
|
|
236
235
|
refresh(): Promise<void>;
|
|
@@ -529,8 +528,8 @@ declare class Rule {
|
|
|
529
528
|
/**
|
|
530
529
|
* A flag resource that doubles as a runtime handle.
|
|
531
530
|
*
|
|
532
|
-
* Management: call `save()` to persist (
|
|
533
|
-
* Runtime: call `get()`
|
|
531
|
+
* Management: call `save()` to persist (creates if new, updates if existing).
|
|
532
|
+
* Runtime: call `get()` to evaluate the flag locally.
|
|
534
533
|
*/
|
|
535
534
|
declare class Flag {
|
|
536
535
|
/** UUID of the flag, or `null` if unsaved. */
|
|
@@ -577,7 +576,7 @@ declare class Flag {
|
|
|
577
576
|
/**
|
|
578
577
|
* Persist this flag to the server.
|
|
579
578
|
*
|
|
580
|
-
*
|
|
579
|
+
* Creates if new, updates if existing.
|
|
581
580
|
* Updates this instance in-place with the server response.
|
|
582
581
|
*/
|
|
583
582
|
save(): Promise<void>;
|
|
@@ -597,7 +596,7 @@ declare class Flag {
|
|
|
597
596
|
/** Clear all rules for a specific environment (sync local mutation). */
|
|
598
597
|
clearRules(envKey: string): void;
|
|
599
598
|
/**
|
|
600
|
-
* Evaluate the flag locally
|
|
599
|
+
* Evaluate the flag locally.
|
|
601
600
|
*
|
|
602
601
|
* Requires `initialize()` to have been called.
|
|
603
602
|
*/
|
|
@@ -635,10 +634,6 @@ declare class JsonFlag extends Flag {
|
|
|
635
634
|
|
|
636
635
|
/**
|
|
637
636
|
* FlagsClient — management + prescriptive runtime for Smpl Flags.
|
|
638
|
-
*
|
|
639
|
-
* Uses the generated OpenAPI types (`src/generated/flags.d.ts`) via
|
|
640
|
-
* `openapi-fetch` for all flag HTTP calls. Context registration uses
|
|
641
|
-
* the generated app service types (`src/generated/app.d.ts`).
|
|
642
637
|
*/
|
|
643
638
|
|
|
644
639
|
type FlagResource = components["schemas"]["FlagResource"];
|
|
@@ -773,16 +768,18 @@ declare class FlagsClient {
|
|
|
773
768
|
*/
|
|
774
769
|
onChange(callbackOrKey: string | ((event: FlagChangeEvent) => void), callback?: (event: FlagChangeEvent) => void): void;
|
|
775
770
|
/**
|
|
776
|
-
*
|
|
771
|
+
* Register context(s) with the server.
|
|
777
772
|
*
|
|
778
|
-
* Accepts a single Context or an array.
|
|
779
|
-
* blocks. Works before `initialize()` is called.
|
|
773
|
+
* Accepts a single Context or an array. Registration is asynchronous
|
|
774
|
+
* and never blocks. Works before `initialize()` is called.
|
|
780
775
|
*/
|
|
781
776
|
register(context: Context | Context[]): void;
|
|
782
777
|
/** Flush pending context registrations to the server. */
|
|
783
778
|
flushContexts(): Promise<void>;
|
|
784
779
|
/**
|
|
785
|
-
*
|
|
780
|
+
* Evaluate a flag with an explicit environment and context.
|
|
781
|
+
*
|
|
782
|
+
* Stateless — does not use the context provider or cached results.
|
|
786
783
|
*/
|
|
787
784
|
evaluate(key: string, options: {
|
|
788
785
|
environment: string;
|
|
@@ -877,7 +874,7 @@ declare class Logger {
|
|
|
877
874
|
/**
|
|
878
875
|
* Persist this logger to the server.
|
|
879
876
|
*
|
|
880
|
-
*
|
|
877
|
+
* Creates if new, updates if existing.
|
|
881
878
|
*/
|
|
882
879
|
save(): Promise<void>;
|
|
883
880
|
/** Set the base log level (sync local mutation). */
|
|
@@ -932,7 +929,7 @@ declare class LogGroup {
|
|
|
932
929
|
/**
|
|
933
930
|
* Persist this log group to the server.
|
|
934
931
|
*
|
|
935
|
-
*
|
|
932
|
+
* Creates if new, updates if existing.
|
|
936
933
|
*/
|
|
937
934
|
save(): Promise<void>;
|
|
938
935
|
/** Set the base log level (sync local mutation). */
|
|
@@ -951,10 +948,40 @@ declare class LogGroup {
|
|
|
951
948
|
}
|
|
952
949
|
|
|
953
950
|
/**
|
|
954
|
-
*
|
|
951
|
+
* Contract for pluggable logging framework integration.
|
|
955
952
|
*
|
|
956
|
-
*
|
|
957
|
-
*
|
|
953
|
+
* Adapters bridge the smplkit logging runtime to a specific logging
|
|
954
|
+
* framework (e.g., Winston, Pino).
|
|
955
|
+
*/
|
|
956
|
+
interface LoggingAdapter {
|
|
957
|
+
/** Human-readable adapter name for diagnostics (e.g., 'winston'). */
|
|
958
|
+
readonly name: string;
|
|
959
|
+
/**
|
|
960
|
+
* Scan the runtime for existing loggers.
|
|
961
|
+
* Returns an array of { name, level } where level is a smplkit level string.
|
|
962
|
+
*/
|
|
963
|
+
discover(): Array<{
|
|
964
|
+
name: string;
|
|
965
|
+
level: string;
|
|
966
|
+
}>;
|
|
967
|
+
/**
|
|
968
|
+
* Set the level on a specific logger.
|
|
969
|
+
* @param loggerName - The original (non-normalized) logger name.
|
|
970
|
+
* @param level - smplkit level string (e.g., 'DEBUG', 'INFO', 'WARN').
|
|
971
|
+
*/
|
|
972
|
+
applyLevel(loggerName: string, level: string): void;
|
|
973
|
+
/**
|
|
974
|
+
* Install continuous discovery hook.
|
|
975
|
+
* The callback receives (original_name, smplkit_level_string) whenever
|
|
976
|
+
* a new logger is created in the framework.
|
|
977
|
+
*/
|
|
978
|
+
installHook(onNewLogger: (name: string, level: string) => void): void;
|
|
979
|
+
/** Remove the hook installed by installHook(). Called on client close(). */
|
|
980
|
+
uninstallHook(): void;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* LoggingClient — management plane + scaffolded runtime for Smpl Logging.
|
|
958
985
|
*/
|
|
959
986
|
|
|
960
987
|
/**
|
|
@@ -979,8 +1006,17 @@ declare class LoggingClient {
|
|
|
979
1006
|
private _started;
|
|
980
1007
|
private _globalListeners;
|
|
981
1008
|
private _keyListeners;
|
|
1009
|
+
private _adapters;
|
|
1010
|
+
private _explicitAdapters;
|
|
982
1011
|
/** @internal */
|
|
983
1012
|
constructor(apiKey: string, ensureWs: () => SharedWebSocket, timeout?: number);
|
|
1013
|
+
/**
|
|
1014
|
+
* Register a logging framework adapter.
|
|
1015
|
+
*
|
|
1016
|
+
* Must be called before `start()`. Disables auto-loading of built-in
|
|
1017
|
+
* adapters — only explicitly registered adapters will be used.
|
|
1018
|
+
*/
|
|
1019
|
+
registerAdapter(adapter: LoggingAdapter): void;
|
|
984
1020
|
/** Create an unsaved logger. Call `.save()` to persist. */
|
|
985
1021
|
new(key: string, options?: {
|
|
986
1022
|
name?: string;
|
|
@@ -1010,11 +1046,12 @@ declare class LoggingClient {
|
|
|
1010
1046
|
/**
|
|
1011
1047
|
* Start the logging runtime.
|
|
1012
1048
|
*
|
|
1013
|
-
*
|
|
1014
|
-
*
|
|
1049
|
+
* Discovers loggers from registered adapters, syncs them with the
|
|
1050
|
+
* server, applies server-side log levels, and subscribes to live
|
|
1051
|
+
* level updates.
|
|
1015
1052
|
*
|
|
1016
|
-
*
|
|
1017
|
-
*
|
|
1053
|
+
* Idempotent — safe to call multiple times.
|
|
1054
|
+
* Management methods work without start().
|
|
1018
1055
|
*/
|
|
1019
1056
|
start(): Promise<void>;
|
|
1020
1057
|
/**
|
|
@@ -1026,6 +1063,12 @@ declare class LoggingClient {
|
|
|
1026
1063
|
onChange(callbackOrKey: string | ((event: LoggerChangeEvent) => void), callback?: (event: LoggerChangeEvent) => void): void;
|
|
1027
1064
|
/** @internal */
|
|
1028
1065
|
_close(): void;
|
|
1066
|
+
/** Auto-load built-in adapters by attempting to require each framework. */
|
|
1067
|
+
private _autoLoadAdapters;
|
|
1068
|
+
/** Apply resolved levels from server loggers to all adapters. */
|
|
1069
|
+
private _applyLevels;
|
|
1070
|
+
/** Called by adapter hooks when a new logger is created in the framework. */
|
|
1071
|
+
private _onAdapterNewLogger;
|
|
1029
1072
|
private _handleLoggerChanged;
|
|
1030
1073
|
private _loggerToModel;
|
|
1031
1074
|
private _groupToModel;
|
|
@@ -1109,6 +1152,65 @@ declare class SmplClient {
|
|
|
1109
1152
|
close(): void;
|
|
1110
1153
|
}
|
|
1111
1154
|
|
|
1155
|
+
/**
|
|
1156
|
+
* Winston logging framework adapter.
|
|
1157
|
+
*
|
|
1158
|
+
* Integrates the smplkit logging runtime with Winston. Discovers
|
|
1159
|
+
* existing loggers, tracks new logger creation, and applies
|
|
1160
|
+
* server-managed log levels.
|
|
1161
|
+
*/
|
|
1162
|
+
|
|
1163
|
+
interface WinstonAdapterConfig {
|
|
1164
|
+
/** Whether to include the default logger in discovery (default: true). */
|
|
1165
|
+
discoverDefault?: boolean;
|
|
1166
|
+
/** @internal — inject a winston module for testing. */
|
|
1167
|
+
_winston?: unknown;
|
|
1168
|
+
}
|
|
1169
|
+
declare class WinstonAdapter implements LoggingAdapter {
|
|
1170
|
+
readonly name = "winston";
|
|
1171
|
+
private readonly _discoverDefault;
|
|
1172
|
+
private _winston;
|
|
1173
|
+
private _originalAdd;
|
|
1174
|
+
constructor(config?: WinstonAdapterConfig);
|
|
1175
|
+
discover(): Array<{
|
|
1176
|
+
name: string;
|
|
1177
|
+
level: string;
|
|
1178
|
+
}>;
|
|
1179
|
+
applyLevel(loggerName: string, level: string): void;
|
|
1180
|
+
installHook(onNewLogger: (name: string, level: string) => void): void;
|
|
1181
|
+
uninstallHook(): void;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* Pino logging framework adapter.
|
|
1186
|
+
*
|
|
1187
|
+
* Integrates the smplkit logging runtime with Pino. Tracks logger
|
|
1188
|
+
* instances (including child loggers) for discovery and level control.
|
|
1189
|
+
*/
|
|
1190
|
+
|
|
1191
|
+
interface PinoAdapterConfig {
|
|
1192
|
+
/** Which binding field to use as the logger name (default: 'name'). */
|
|
1193
|
+
nameField?: string;
|
|
1194
|
+
/** @internal — inject a pino module for testing. */
|
|
1195
|
+
_pino?: unknown;
|
|
1196
|
+
}
|
|
1197
|
+
declare class PinoAdapter implements LoggingAdapter {
|
|
1198
|
+
readonly name = "pino";
|
|
1199
|
+
private readonly _nameField;
|
|
1200
|
+
private _pino;
|
|
1201
|
+
private _registry;
|
|
1202
|
+
private _originalPino;
|
|
1203
|
+
private _pinoModule;
|
|
1204
|
+
constructor(config?: PinoAdapterConfig);
|
|
1205
|
+
discover(): Array<{
|
|
1206
|
+
name: string;
|
|
1207
|
+
level: string;
|
|
1208
|
+
}>;
|
|
1209
|
+
applyLevel(loggerName: string, level: string): void;
|
|
1210
|
+
installHook(onNewLogger: (name: string, level: string) => void): void;
|
|
1211
|
+
uninstallHook(): void;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1112
1214
|
/**
|
|
1113
1215
|
* Structured SDK error types.
|
|
1114
1216
|
*
|
|
@@ -1155,4 +1257,4 @@ declare class SmplValidationError extends SmplError {
|
|
|
1155
1257
|
constructor(message: string, statusCode?: number, responseBody?: string, errors?: ApiErrorObject[]);
|
|
1156
1258
|
}
|
|
1157
1259
|
|
|
1158
|
-
export { type ApiErrorObject, BooleanFlag, Config, type ConfigChangeEvent, ConfigClient, Context, Flag, FlagChangeEvent, FlagStats, FlagsClient, JsonFlag, LiveConfigProxy, LogGroup, LogLevel, Logger, type LoggerChangeEvent, LoggingClient, NumberFlag, Rule, SharedWebSocket, SmplClient, type SmplClientOptions, SmplConflictError, SmplConnectionError, SmplError, SmplNotFoundError, SmplTimeoutError, SmplValidationError, StringFlag };
|
|
1260
|
+
export { type ApiErrorObject, BooleanFlag, Config, type ConfigChangeEvent, ConfigClient, Context, Flag, FlagChangeEvent, FlagStats, FlagsClient, JsonFlag, LiveConfigProxy, LogGroup, LogLevel, Logger, type LoggerChangeEvent, type LoggingAdapter, LoggingClient, NumberFlag, PinoAdapter, type PinoAdapterConfig, Rule, SharedWebSocket, SmplClient, type SmplClientOptions, SmplConflictError, SmplConnectionError, SmplError, SmplNotFoundError, SmplTimeoutError, SmplValidationError, StringFlag, WinstonAdapter, type WinstonAdapterConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ declare class SharedWebSocket {
|
|
|
53
53
|
* A configuration resource managed by the smplkit platform.
|
|
54
54
|
*
|
|
55
55
|
* Management: mutate properties directly and call `save()` to persist.
|
|
56
|
-
*
|
|
56
|
+
* Creates if new, updates if existing.
|
|
57
57
|
*/
|
|
58
58
|
declare class Config {
|
|
59
59
|
/** UUID of the config, or `null` if unsaved. */
|
|
@@ -70,8 +70,7 @@ declare class Config {
|
|
|
70
70
|
items: Record<string, unknown>;
|
|
71
71
|
/**
|
|
72
72
|
* Per-environment overrides.
|
|
73
|
-
*
|
|
74
|
-
* unwrapped from the server's `{ value: raw }` wrapper.
|
|
73
|
+
* Structured as `{ env_name: { values: { key: value } } }`.
|
|
75
74
|
*/
|
|
76
75
|
environments: Record<string, unknown>;
|
|
77
76
|
/** When the config was created, or null if unavailable. */
|
|
@@ -95,7 +94,7 @@ declare class Config {
|
|
|
95
94
|
/**
|
|
96
95
|
* Persist this config to the server.
|
|
97
96
|
*
|
|
98
|
-
*
|
|
97
|
+
* Creates if new, updates if existing.
|
|
99
98
|
* Updates this instance in-place with the server response.
|
|
100
99
|
*/
|
|
101
100
|
save(): Promise<void>;
|
|
@@ -118,17 +117,17 @@ declare class Config {
|
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
/**
|
|
121
|
-
* LiveConfigProxy —
|
|
120
|
+
* LiveConfigProxy — live configuration access.
|
|
122
121
|
*
|
|
123
|
-
* Property reads
|
|
124
|
-
*
|
|
125
|
-
*
|
|
122
|
+
* Property reads always return the latest resolved values. When the
|
|
123
|
+
* underlying config changes, subsequent reads automatically reflect
|
|
124
|
+
* the new values.
|
|
126
125
|
*/
|
|
127
126
|
|
|
128
127
|
/**
|
|
129
128
|
* A live proxy that auto-updates when the underlying config changes.
|
|
130
129
|
*
|
|
131
|
-
* Access properties directly — each read
|
|
130
|
+
* Access properties directly — each read returns the latest resolved value.
|
|
132
131
|
*
|
|
133
132
|
* @example
|
|
134
133
|
* ```typescript
|
|
@@ -208,8 +207,8 @@ declare class ConfigClient {
|
|
|
208
207
|
/**
|
|
209
208
|
* Resolve a config's values for the current environment.
|
|
210
209
|
*
|
|
211
|
-
* Returns a flat dict of resolved key-value pairs
|
|
212
|
-
*
|
|
210
|
+
* Returns a flat dict of resolved key-value pairs with inherited
|
|
211
|
+
* values and environment overrides applied.
|
|
213
212
|
*
|
|
214
213
|
* Optionally pass a model class to map the resolved values.
|
|
215
214
|
*/
|
|
@@ -230,7 +229,7 @@ declare class ConfigClient {
|
|
|
230
229
|
*/
|
|
231
230
|
onChange(callbackOrConfigKey: string | ((event: ConfigChangeEvent) => void), callbackOrItemKey?: string | ((event: ConfigChangeEvent) => void), callback?: (event: ConfigChangeEvent) => void): void;
|
|
232
231
|
/**
|
|
233
|
-
* Re-fetch all configs
|
|
232
|
+
* Re-fetch all configs and re-resolve values.
|
|
234
233
|
* Fires change listeners for any values that differ.
|
|
235
234
|
*/
|
|
236
235
|
refresh(): Promise<void>;
|
|
@@ -529,8 +528,8 @@ declare class Rule {
|
|
|
529
528
|
/**
|
|
530
529
|
* A flag resource that doubles as a runtime handle.
|
|
531
530
|
*
|
|
532
|
-
* Management: call `save()` to persist (
|
|
533
|
-
* Runtime: call `get()`
|
|
531
|
+
* Management: call `save()` to persist (creates if new, updates if existing).
|
|
532
|
+
* Runtime: call `get()` to evaluate the flag locally.
|
|
534
533
|
*/
|
|
535
534
|
declare class Flag {
|
|
536
535
|
/** UUID of the flag, or `null` if unsaved. */
|
|
@@ -577,7 +576,7 @@ declare class Flag {
|
|
|
577
576
|
/**
|
|
578
577
|
* Persist this flag to the server.
|
|
579
578
|
*
|
|
580
|
-
*
|
|
579
|
+
* Creates if new, updates if existing.
|
|
581
580
|
* Updates this instance in-place with the server response.
|
|
582
581
|
*/
|
|
583
582
|
save(): Promise<void>;
|
|
@@ -597,7 +596,7 @@ declare class Flag {
|
|
|
597
596
|
/** Clear all rules for a specific environment (sync local mutation). */
|
|
598
597
|
clearRules(envKey: string): void;
|
|
599
598
|
/**
|
|
600
|
-
* Evaluate the flag locally
|
|
599
|
+
* Evaluate the flag locally.
|
|
601
600
|
*
|
|
602
601
|
* Requires `initialize()` to have been called.
|
|
603
602
|
*/
|
|
@@ -635,10 +634,6 @@ declare class JsonFlag extends Flag {
|
|
|
635
634
|
|
|
636
635
|
/**
|
|
637
636
|
* FlagsClient — management + prescriptive runtime for Smpl Flags.
|
|
638
|
-
*
|
|
639
|
-
* Uses the generated OpenAPI types (`src/generated/flags.d.ts`) via
|
|
640
|
-
* `openapi-fetch` for all flag HTTP calls. Context registration uses
|
|
641
|
-
* the generated app service types (`src/generated/app.d.ts`).
|
|
642
637
|
*/
|
|
643
638
|
|
|
644
639
|
type FlagResource = components["schemas"]["FlagResource"];
|
|
@@ -773,16 +768,18 @@ declare class FlagsClient {
|
|
|
773
768
|
*/
|
|
774
769
|
onChange(callbackOrKey: string | ((event: FlagChangeEvent) => void), callback?: (event: FlagChangeEvent) => void): void;
|
|
775
770
|
/**
|
|
776
|
-
*
|
|
771
|
+
* Register context(s) with the server.
|
|
777
772
|
*
|
|
778
|
-
* Accepts a single Context or an array.
|
|
779
|
-
* blocks. Works before `initialize()` is called.
|
|
773
|
+
* Accepts a single Context or an array. Registration is asynchronous
|
|
774
|
+
* and never blocks. Works before `initialize()` is called.
|
|
780
775
|
*/
|
|
781
776
|
register(context: Context | Context[]): void;
|
|
782
777
|
/** Flush pending context registrations to the server. */
|
|
783
778
|
flushContexts(): Promise<void>;
|
|
784
779
|
/**
|
|
785
|
-
*
|
|
780
|
+
* Evaluate a flag with an explicit environment and context.
|
|
781
|
+
*
|
|
782
|
+
* Stateless — does not use the context provider or cached results.
|
|
786
783
|
*/
|
|
787
784
|
evaluate(key: string, options: {
|
|
788
785
|
environment: string;
|
|
@@ -877,7 +874,7 @@ declare class Logger {
|
|
|
877
874
|
/**
|
|
878
875
|
* Persist this logger to the server.
|
|
879
876
|
*
|
|
880
|
-
*
|
|
877
|
+
* Creates if new, updates if existing.
|
|
881
878
|
*/
|
|
882
879
|
save(): Promise<void>;
|
|
883
880
|
/** Set the base log level (sync local mutation). */
|
|
@@ -932,7 +929,7 @@ declare class LogGroup {
|
|
|
932
929
|
/**
|
|
933
930
|
* Persist this log group to the server.
|
|
934
931
|
*
|
|
935
|
-
*
|
|
932
|
+
* Creates if new, updates if existing.
|
|
936
933
|
*/
|
|
937
934
|
save(): Promise<void>;
|
|
938
935
|
/** Set the base log level (sync local mutation). */
|
|
@@ -951,10 +948,40 @@ declare class LogGroup {
|
|
|
951
948
|
}
|
|
952
949
|
|
|
953
950
|
/**
|
|
954
|
-
*
|
|
951
|
+
* Contract for pluggable logging framework integration.
|
|
955
952
|
*
|
|
956
|
-
*
|
|
957
|
-
*
|
|
953
|
+
* Adapters bridge the smplkit logging runtime to a specific logging
|
|
954
|
+
* framework (e.g., Winston, Pino).
|
|
955
|
+
*/
|
|
956
|
+
interface LoggingAdapter {
|
|
957
|
+
/** Human-readable adapter name for diagnostics (e.g., 'winston'). */
|
|
958
|
+
readonly name: string;
|
|
959
|
+
/**
|
|
960
|
+
* Scan the runtime for existing loggers.
|
|
961
|
+
* Returns an array of { name, level } where level is a smplkit level string.
|
|
962
|
+
*/
|
|
963
|
+
discover(): Array<{
|
|
964
|
+
name: string;
|
|
965
|
+
level: string;
|
|
966
|
+
}>;
|
|
967
|
+
/**
|
|
968
|
+
* Set the level on a specific logger.
|
|
969
|
+
* @param loggerName - The original (non-normalized) logger name.
|
|
970
|
+
* @param level - smplkit level string (e.g., 'DEBUG', 'INFO', 'WARN').
|
|
971
|
+
*/
|
|
972
|
+
applyLevel(loggerName: string, level: string): void;
|
|
973
|
+
/**
|
|
974
|
+
* Install continuous discovery hook.
|
|
975
|
+
* The callback receives (original_name, smplkit_level_string) whenever
|
|
976
|
+
* a new logger is created in the framework.
|
|
977
|
+
*/
|
|
978
|
+
installHook(onNewLogger: (name: string, level: string) => void): void;
|
|
979
|
+
/** Remove the hook installed by installHook(). Called on client close(). */
|
|
980
|
+
uninstallHook(): void;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* LoggingClient — management plane + scaffolded runtime for Smpl Logging.
|
|
958
985
|
*/
|
|
959
986
|
|
|
960
987
|
/**
|
|
@@ -979,8 +1006,17 @@ declare class LoggingClient {
|
|
|
979
1006
|
private _started;
|
|
980
1007
|
private _globalListeners;
|
|
981
1008
|
private _keyListeners;
|
|
1009
|
+
private _adapters;
|
|
1010
|
+
private _explicitAdapters;
|
|
982
1011
|
/** @internal */
|
|
983
1012
|
constructor(apiKey: string, ensureWs: () => SharedWebSocket, timeout?: number);
|
|
1013
|
+
/**
|
|
1014
|
+
* Register a logging framework adapter.
|
|
1015
|
+
*
|
|
1016
|
+
* Must be called before `start()`. Disables auto-loading of built-in
|
|
1017
|
+
* adapters — only explicitly registered adapters will be used.
|
|
1018
|
+
*/
|
|
1019
|
+
registerAdapter(adapter: LoggingAdapter): void;
|
|
984
1020
|
/** Create an unsaved logger. Call `.save()` to persist. */
|
|
985
1021
|
new(key: string, options?: {
|
|
986
1022
|
name?: string;
|
|
@@ -1010,11 +1046,12 @@ declare class LoggingClient {
|
|
|
1010
1046
|
/**
|
|
1011
1047
|
* Start the logging runtime.
|
|
1012
1048
|
*
|
|
1013
|
-
*
|
|
1014
|
-
*
|
|
1049
|
+
* Discovers loggers from registered adapters, syncs them with the
|
|
1050
|
+
* server, applies server-side log levels, and subscribes to live
|
|
1051
|
+
* level updates.
|
|
1015
1052
|
*
|
|
1016
|
-
*
|
|
1017
|
-
*
|
|
1053
|
+
* Idempotent — safe to call multiple times.
|
|
1054
|
+
* Management methods work without start().
|
|
1018
1055
|
*/
|
|
1019
1056
|
start(): Promise<void>;
|
|
1020
1057
|
/**
|
|
@@ -1026,6 +1063,12 @@ declare class LoggingClient {
|
|
|
1026
1063
|
onChange(callbackOrKey: string | ((event: LoggerChangeEvent) => void), callback?: (event: LoggerChangeEvent) => void): void;
|
|
1027
1064
|
/** @internal */
|
|
1028
1065
|
_close(): void;
|
|
1066
|
+
/** Auto-load built-in adapters by attempting to require each framework. */
|
|
1067
|
+
private _autoLoadAdapters;
|
|
1068
|
+
/** Apply resolved levels from server loggers to all adapters. */
|
|
1069
|
+
private _applyLevels;
|
|
1070
|
+
/** Called by adapter hooks when a new logger is created in the framework. */
|
|
1071
|
+
private _onAdapterNewLogger;
|
|
1029
1072
|
private _handleLoggerChanged;
|
|
1030
1073
|
private _loggerToModel;
|
|
1031
1074
|
private _groupToModel;
|
|
@@ -1109,6 +1152,65 @@ declare class SmplClient {
|
|
|
1109
1152
|
close(): void;
|
|
1110
1153
|
}
|
|
1111
1154
|
|
|
1155
|
+
/**
|
|
1156
|
+
* Winston logging framework adapter.
|
|
1157
|
+
*
|
|
1158
|
+
* Integrates the smplkit logging runtime with Winston. Discovers
|
|
1159
|
+
* existing loggers, tracks new logger creation, and applies
|
|
1160
|
+
* server-managed log levels.
|
|
1161
|
+
*/
|
|
1162
|
+
|
|
1163
|
+
interface WinstonAdapterConfig {
|
|
1164
|
+
/** Whether to include the default logger in discovery (default: true). */
|
|
1165
|
+
discoverDefault?: boolean;
|
|
1166
|
+
/** @internal — inject a winston module for testing. */
|
|
1167
|
+
_winston?: unknown;
|
|
1168
|
+
}
|
|
1169
|
+
declare class WinstonAdapter implements LoggingAdapter {
|
|
1170
|
+
readonly name = "winston";
|
|
1171
|
+
private readonly _discoverDefault;
|
|
1172
|
+
private _winston;
|
|
1173
|
+
private _originalAdd;
|
|
1174
|
+
constructor(config?: WinstonAdapterConfig);
|
|
1175
|
+
discover(): Array<{
|
|
1176
|
+
name: string;
|
|
1177
|
+
level: string;
|
|
1178
|
+
}>;
|
|
1179
|
+
applyLevel(loggerName: string, level: string): void;
|
|
1180
|
+
installHook(onNewLogger: (name: string, level: string) => void): void;
|
|
1181
|
+
uninstallHook(): void;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/**
|
|
1185
|
+
* Pino logging framework adapter.
|
|
1186
|
+
*
|
|
1187
|
+
* Integrates the smplkit logging runtime with Pino. Tracks logger
|
|
1188
|
+
* instances (including child loggers) for discovery and level control.
|
|
1189
|
+
*/
|
|
1190
|
+
|
|
1191
|
+
interface PinoAdapterConfig {
|
|
1192
|
+
/** Which binding field to use as the logger name (default: 'name'). */
|
|
1193
|
+
nameField?: string;
|
|
1194
|
+
/** @internal — inject a pino module for testing. */
|
|
1195
|
+
_pino?: unknown;
|
|
1196
|
+
}
|
|
1197
|
+
declare class PinoAdapter implements LoggingAdapter {
|
|
1198
|
+
readonly name = "pino";
|
|
1199
|
+
private readonly _nameField;
|
|
1200
|
+
private _pino;
|
|
1201
|
+
private _registry;
|
|
1202
|
+
private _originalPino;
|
|
1203
|
+
private _pinoModule;
|
|
1204
|
+
constructor(config?: PinoAdapterConfig);
|
|
1205
|
+
discover(): Array<{
|
|
1206
|
+
name: string;
|
|
1207
|
+
level: string;
|
|
1208
|
+
}>;
|
|
1209
|
+
applyLevel(loggerName: string, level: string): void;
|
|
1210
|
+
installHook(onNewLogger: (name: string, level: string) => void): void;
|
|
1211
|
+
uninstallHook(): void;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1112
1214
|
/**
|
|
1113
1215
|
* Structured SDK error types.
|
|
1114
1216
|
*
|
|
@@ -1155,4 +1257,4 @@ declare class SmplValidationError extends SmplError {
|
|
|
1155
1257
|
constructor(message: string, statusCode?: number, responseBody?: string, errors?: ApiErrorObject[]);
|
|
1156
1258
|
}
|
|
1157
1259
|
|
|
1158
|
-
export { type ApiErrorObject, BooleanFlag, Config, type ConfigChangeEvent, ConfigClient, Context, Flag, FlagChangeEvent, FlagStats, FlagsClient, JsonFlag, LiveConfigProxy, LogGroup, LogLevel, Logger, type LoggerChangeEvent, LoggingClient, NumberFlag, Rule, SharedWebSocket, SmplClient, type SmplClientOptions, SmplConflictError, SmplConnectionError, SmplError, SmplNotFoundError, SmplTimeoutError, SmplValidationError, StringFlag };
|
|
1260
|
+
export { type ApiErrorObject, BooleanFlag, Config, type ConfigChangeEvent, ConfigClient, Context, Flag, FlagChangeEvent, FlagStats, FlagsClient, JsonFlag, LiveConfigProxy, LogGroup, LogLevel, Logger, type LoggerChangeEvent, type LoggingAdapter, LoggingClient, NumberFlag, PinoAdapter, type PinoAdapterConfig, Rule, SharedWebSocket, SmplClient, type SmplClientOptions, SmplConflictError, SmplConnectionError, SmplError, SmplNotFoundError, SmplTimeoutError, SmplValidationError, StringFlag, WinstonAdapter, type WinstonAdapterConfig };
|