@smplkit/sdk 1.1.3 → 1.1.5
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/{chunk-GLOLTIGH.js → chunk-RF6LYU4V.js} +6 -6
- package/dist/{chunk-GLOLTIGH.js.map → chunk-RF6LYU4V.js.map} +1 -1
- package/dist/index.cjs +84 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.js +81 -26
- package/dist/index.js.map +1 -1
- package/dist/runtime-FT745HBO.js +7 -0
- package/package.json +1 -1
- package/dist/runtime-GALKHNKF.js +0 -7
- /package/dist/{runtime-GALKHNKF.js.map → runtime-FT745HBO.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConfigRuntime
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RF6LYU4V.js";
|
|
4
4
|
|
|
5
5
|
// src/config/client.ts
|
|
6
6
|
import createClient from "openapi-fetch";
|
|
@@ -67,12 +67,12 @@ var Config = class {
|
|
|
67
67
|
description;
|
|
68
68
|
/** Parent config UUID, or null if this is a root config. */
|
|
69
69
|
parent;
|
|
70
|
-
/** Base key-value pairs. */
|
|
71
|
-
|
|
70
|
+
/** Base key-value pairs (unwrapped from typed item definitions). */
|
|
71
|
+
items;
|
|
72
72
|
/**
|
|
73
73
|
* Per-environment overrides.
|
|
74
|
-
* Stored as `{ env_name: { values: { key: value } } }`
|
|
75
|
-
* server's
|
|
74
|
+
* Stored as `{ env_name: { values: { key: value } } }` — values are
|
|
75
|
+
* unwrapped from the server's `{ value: raw }` wrapper.
|
|
76
76
|
*/
|
|
77
77
|
environments;
|
|
78
78
|
/** When the config was created, or null if unavailable. */
|
|
@@ -92,7 +92,7 @@ var Config = class {
|
|
|
92
92
|
this.name = fields.name;
|
|
93
93
|
this.description = fields.description;
|
|
94
94
|
this.parent = fields.parent;
|
|
95
|
-
this.
|
|
95
|
+
this.items = fields.items;
|
|
96
96
|
this.environments = fields.environments;
|
|
97
97
|
this.createdAt = fields.createdAt;
|
|
98
98
|
this.updatedAt = fields.updatedAt;
|
|
@@ -105,7 +105,7 @@ var Config = class {
|
|
|
105
105
|
*
|
|
106
106
|
* @param options.name - New display name.
|
|
107
107
|
* @param options.description - New description (pass empty string to clear).
|
|
108
|
-
* @param options.
|
|
108
|
+
* @param options.items - New base values (replaces entirely).
|
|
109
109
|
* @param options.environments - New environments dict (replaces entirely).
|
|
110
110
|
*/
|
|
111
111
|
async update(options) {
|
|
@@ -115,12 +115,12 @@ var Config = class {
|
|
|
115
115
|
key: this.key,
|
|
116
116
|
description: options.description !== void 0 ? options.description : this.description,
|
|
117
117
|
parent: this.parent,
|
|
118
|
-
|
|
118
|
+
items: options.items ?? this.items,
|
|
119
119
|
environments: options.environments ?? this.environments
|
|
120
120
|
});
|
|
121
121
|
this.name = updated.name;
|
|
122
122
|
this.description = updated.description;
|
|
123
|
-
this.
|
|
123
|
+
this.items = updated.items;
|
|
124
124
|
this.environments = updated.environments;
|
|
125
125
|
this.updatedAt = updated.updatedAt;
|
|
126
126
|
}
|
|
@@ -129,19 +129,19 @@ var Config = class {
|
|
|
129
129
|
*
|
|
130
130
|
* When `environment` is provided, replaces that environment's `values`
|
|
131
131
|
* sub-dict (other environments are preserved). When omitted, replaces
|
|
132
|
-
* the base `
|
|
132
|
+
* the base `items`.
|
|
133
133
|
*
|
|
134
134
|
* @param values - The complete set of values to set.
|
|
135
135
|
* @param environment - Target environment, or omit for base values.
|
|
136
136
|
*/
|
|
137
137
|
async setValues(values, environment) {
|
|
138
|
-
let
|
|
138
|
+
let newItems;
|
|
139
139
|
let newEnvs;
|
|
140
140
|
if (environment === void 0) {
|
|
141
|
-
|
|
141
|
+
newItems = values;
|
|
142
142
|
newEnvs = this.environments;
|
|
143
143
|
} else {
|
|
144
|
-
|
|
144
|
+
newItems = this.items;
|
|
145
145
|
const existingEntry = typeof this.environments[environment] === "object" && this.environments[environment] !== null ? { ...this.environments[environment] } : {};
|
|
146
146
|
existingEntry.values = values;
|
|
147
147
|
newEnvs = { ...this.environments, [environment]: existingEntry };
|
|
@@ -152,10 +152,10 @@ var Config = class {
|
|
|
152
152
|
key: this.key,
|
|
153
153
|
description: this.description,
|
|
154
154
|
parent: this.parent,
|
|
155
|
-
|
|
155
|
+
items: newItems,
|
|
156
156
|
environments: newEnvs
|
|
157
157
|
});
|
|
158
|
-
this.
|
|
158
|
+
this.items = updated.items;
|
|
159
159
|
this.environments = updated.environments;
|
|
160
160
|
this.updatedAt = updated.updatedAt;
|
|
161
161
|
}
|
|
@@ -170,7 +170,7 @@ var Config = class {
|
|
|
170
170
|
*/
|
|
171
171
|
async setValue(key, value, environment) {
|
|
172
172
|
if (environment === void 0) {
|
|
173
|
-
const merged = { ...this.
|
|
173
|
+
const merged = { ...this.items, [key]: value };
|
|
174
174
|
await this.setValues(merged);
|
|
175
175
|
} else {
|
|
176
176
|
const envEntry = typeof this.environments[environment] === "object" && this.environments[environment] !== null ? this.environments[environment] : {};
|
|
@@ -207,7 +207,7 @@ var Config = class {
|
|
|
207
207
|
* @param options.timeout - Milliseconds to wait for the initial fetch.
|
|
208
208
|
*/
|
|
209
209
|
async connect(environment, options) {
|
|
210
|
-
const { ConfigRuntime: ConfigRuntime2 } = await import("./runtime-
|
|
210
|
+
const { ConfigRuntime: ConfigRuntime2 } = await import("./runtime-FT745HBO.js");
|
|
211
211
|
const timeout = options?.timeout ?? 3e4;
|
|
212
212
|
const chain = await this._buildChain(timeout);
|
|
213
213
|
return new ConfigRuntime2({
|
|
@@ -225,13 +225,13 @@ var Config = class {
|
|
|
225
225
|
* @internal
|
|
226
226
|
*/
|
|
227
227
|
async _buildChain(_timeout) {
|
|
228
|
-
const chain = [{ id: this.id,
|
|
228
|
+
const chain = [{ id: this.id, items: this.items, environments: this.environments }];
|
|
229
229
|
let parentId = this.parent;
|
|
230
230
|
while (parentId !== null) {
|
|
231
231
|
const parentConfig = await this._client.get({ id: parentId });
|
|
232
232
|
chain.push({
|
|
233
233
|
id: parentConfig.id,
|
|
234
|
-
|
|
234
|
+
items: parentConfig.items,
|
|
235
235
|
environments: parentConfig.environments
|
|
236
236
|
});
|
|
237
237
|
parentId = parentConfig.parent;
|
|
@@ -245,6 +245,30 @@ var Config = class {
|
|
|
245
245
|
|
|
246
246
|
// src/config/client.ts
|
|
247
247
|
var BASE_URL = "https://config.smplkit.com";
|
|
248
|
+
function extractItemValues(items) {
|
|
249
|
+
if (!items) return {};
|
|
250
|
+
const result = {};
|
|
251
|
+
for (const [key, item] of Object.entries(items)) {
|
|
252
|
+
result[key] = item && typeof item === "object" && "value" in item ? item.value : item;
|
|
253
|
+
}
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
function extractEnvironments(environments) {
|
|
257
|
+
if (!environments) return {};
|
|
258
|
+
const result = {};
|
|
259
|
+
for (const [envName, envEntry] of Object.entries(environments)) {
|
|
260
|
+
if (envEntry && typeof envEntry === "object" && envEntry.values) {
|
|
261
|
+
const unwrapped = {};
|
|
262
|
+
for (const [key, item] of Object.entries(envEntry.values)) {
|
|
263
|
+
unwrapped[key] = item && typeof item === "object" && "value" in item ? item.value : item;
|
|
264
|
+
}
|
|
265
|
+
result[envName] = { values: unwrapped };
|
|
266
|
+
} else {
|
|
267
|
+
result[envName] = envEntry;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
248
272
|
function resourceToConfig(resource, client) {
|
|
249
273
|
const attrs = resource.attributes;
|
|
250
274
|
return new Config(client, {
|
|
@@ -253,8 +277,10 @@ function resourceToConfig(resource, client) {
|
|
|
253
277
|
name: attrs.name,
|
|
254
278
|
description: attrs.description ?? null,
|
|
255
279
|
parent: attrs.parent ?? null,
|
|
256
|
-
|
|
257
|
-
environments:
|
|
280
|
+
items: extractItemValues(attrs.items),
|
|
281
|
+
environments: extractEnvironments(
|
|
282
|
+
attrs.environments
|
|
283
|
+
),
|
|
258
284
|
createdAt: attrs.created_at ? new Date(attrs.created_at) : null,
|
|
259
285
|
updatedAt: attrs.updated_at ? new Date(attrs.updated_at) : null
|
|
260
286
|
});
|
|
@@ -283,6 +309,35 @@ function wrapFetchError(err) {
|
|
|
283
309
|
`Request failed: ${err instanceof Error ? err.message : String(err)}`
|
|
284
310
|
);
|
|
285
311
|
}
|
|
312
|
+
function wrapItemValues(values) {
|
|
313
|
+
if (!values) return null;
|
|
314
|
+
const result = {};
|
|
315
|
+
for (const [key, val] of Object.entries(values)) {
|
|
316
|
+
result[key] = { value: val };
|
|
317
|
+
}
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
function wrapEnvironments(environments) {
|
|
321
|
+
if (!environments) return null;
|
|
322
|
+
const result = {};
|
|
323
|
+
for (const [envName, envEntry] of Object.entries(environments)) {
|
|
324
|
+
if (envEntry && typeof envEntry === "object" && !Array.isArray(envEntry)) {
|
|
325
|
+
const entry = envEntry;
|
|
326
|
+
if (entry.values && typeof entry.values === "object" && !Array.isArray(entry.values)) {
|
|
327
|
+
const wrapped = {};
|
|
328
|
+
for (const [key, val] of Object.entries(entry.values)) {
|
|
329
|
+
wrapped[key] = { value: val };
|
|
330
|
+
}
|
|
331
|
+
result[envName] = { ...entry, values: wrapped };
|
|
332
|
+
} else {
|
|
333
|
+
result[envName] = envEntry;
|
|
334
|
+
}
|
|
335
|
+
} else {
|
|
336
|
+
result[envName] = envEntry;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return result;
|
|
340
|
+
}
|
|
286
341
|
function buildRequestBody(options) {
|
|
287
342
|
const attrs = {
|
|
288
343
|
name: options.name
|
|
@@ -290,10 +345,10 @@ function buildRequestBody(options) {
|
|
|
290
345
|
if (options.key !== void 0) attrs.key = options.key;
|
|
291
346
|
if (options.description !== void 0) attrs.description = options.description;
|
|
292
347
|
if (options.parent !== void 0) attrs.parent = options.parent;
|
|
293
|
-
if (options.
|
|
294
|
-
attrs.
|
|
348
|
+
if (options.items !== void 0)
|
|
349
|
+
attrs.items = wrapItemValues(options.items);
|
|
295
350
|
if (options.environments !== void 0)
|
|
296
|
-
attrs.environments = options.environments;
|
|
351
|
+
attrs.environments = wrapEnvironments(options.environments);
|
|
297
352
|
return {
|
|
298
353
|
data: {
|
|
299
354
|
id: options.id ?? null,
|
|
@@ -376,7 +431,7 @@ var ConfigClient = class {
|
|
|
376
431
|
key: options.key,
|
|
377
432
|
description: options.description,
|
|
378
433
|
parent: options.parent,
|
|
379
|
-
|
|
434
|
+
items: options.items
|
|
380
435
|
});
|
|
381
436
|
let data;
|
|
382
437
|
try {
|
|
@@ -419,7 +474,7 @@ var ConfigClient = class {
|
|
|
419
474
|
key: payload.key,
|
|
420
475
|
description: payload.description,
|
|
421
476
|
parent: payload.parent,
|
|
422
|
-
|
|
477
|
+
items: payload.items,
|
|
423
478
|
environments: payload.environments
|
|
424
479
|
});
|
|
425
480
|
let data;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config/client.ts","../src/errors.ts","../src/config/types.ts","../src/resolve.ts","../src/client.ts"],"sourcesContent":["/**\n * ConfigClient — management-plane operations for configs.\n *\n * Uses the generated OpenAPI types (`src/generated/config.d.ts`) via\n * `openapi-fetch` for all HTTP calls, keeping the client layer fully\n * type-safe without hand-coded request/response shapes.\n */\n\nimport createClient from \"openapi-fetch\";\nimport type { components, operations } from \"../generated/config.d.ts\";\nimport {\n SmplConflictError,\n SmplNotFoundError,\n SmplValidationError,\n SmplError,\n SmplConnectionError,\n SmplTimeoutError,\n} from \"../errors.js\";\nimport { Config } from \"./types.js\";\nimport type { ConfigUpdatePayload, CreateConfigOptions, GetConfigOptions } from \"./types.js\";\n\nconst BASE_URL = \"https://config.smplkit.com\";\n\ntype ApiConfig = components[\"schemas\"][\"Config\"];\ntype ConfigResource = components[\"schemas\"][\"ConfigResource\"];\n\n/** @internal */\nfunction resourceToConfig(resource: ConfigResource, client: ConfigClient): Config {\n const attrs: ApiConfig = resource.attributes;\n return new Config(client, {\n id: resource.id ?? \"\",\n key: attrs.key ?? \"\",\n name: attrs.name,\n description: attrs.description ?? null,\n parent: attrs.parent ?? null,\n values: (attrs.values ?? {}) as Record<string, unknown>,\n environments: (attrs.environments ?? {}) as Record<string, unknown>,\n createdAt: attrs.created_at ? new Date(attrs.created_at) : null,\n updatedAt: attrs.updated_at ? new Date(attrs.updated_at) : null,\n });\n}\n\n/**\n * Map fetch or HTTP errors to typed SDK exceptions.\n * @internal\n */\nasync function checkError(response: Response, context: string): Promise<never> {\n const body = await response.text().catch(() => \"\");\n switch (response.status) {\n case 404:\n throw new SmplNotFoundError(body || context, 404, body);\n case 409:\n throw new SmplConflictError(body || context, 409, body);\n case 422:\n throw new SmplValidationError(body || context, 422, body);\n default:\n throw new SmplError(`HTTP ${response.status}: ${body}`, response.status, body);\n }\n}\n\n/**\n * Re-raise fetch-level errors (network, timeout) as typed SDK exceptions.\n * @internal\n */\nfunction wrapFetchError(err: unknown): never {\n if (\n err instanceof SmplNotFoundError ||\n err instanceof SmplConflictError ||\n err instanceof SmplValidationError ||\n err instanceof SmplError\n ) {\n throw err;\n }\n if (err instanceof TypeError) {\n throw new SmplConnectionError(`Network error: ${err.message}`);\n }\n throw new SmplConnectionError(\n `Request failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n}\n\n/**\n * Build a JSON:API request body for create/update operations.\n * @internal\n */\nfunction buildRequestBody(options: {\n id?: string | null;\n name: string;\n key?: string | null;\n description?: string | null;\n parent?: string | null;\n values?: Record<string, unknown> | null;\n environments?: Record<string, unknown> | null;\n}): operations[\"create_config\"][\"requestBody\"][\"content\"][\"application/json\"] {\n const attrs: ApiConfig = {\n name: options.name,\n };\n if (options.key !== undefined) attrs.key = options.key;\n if (options.description !== undefined) attrs.description = options.description;\n if (options.parent !== undefined) attrs.parent = options.parent;\n if (options.values !== undefined)\n attrs.values = options.values as { [key: string]: unknown } | null;\n if (options.environments !== undefined)\n attrs.environments = options.environments as { [key: string]: unknown } | null;\n\n return {\n data: {\n id: options.id ?? null,\n type: \"config\",\n attributes: attrs,\n },\n };\n}\n\n/**\n * Client for the smplkit Config API (management plane).\n *\n * All methods are async and return `Promise<T>`. Network and server\n * errors are mapped to typed SDK exceptions.\n *\n * Obtained via `SmplClient.config`.\n */\nexport class ConfigClient {\n /** @internal — used by Config instances for reconnecting and WebSocket auth. */\n readonly _apiKey: string;\n\n /** @internal */\n readonly _baseUrl: string = BASE_URL;\n\n /** @internal */\n private readonly _http: ReturnType<typeof createClient<import(\"../generated/config.d.ts\").paths>>;\n\n /** @internal */\n constructor(apiKey: string, timeout?: number) {\n this._apiKey = apiKey;\n const ms = timeout ?? 30_000;\n this._http = createClient<import(\"../generated/config.d.ts\").paths>({\n baseUrl: BASE_URL,\n headers: {\n Authorization: `Bearer ${apiKey}`,\n Accept: \"application/json\",\n },\n // openapi-fetch custom fetch receives a pre-built Request object\n fetch: async (request: Request): Promise<Response> => {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), ms);\n try {\n return await fetch(new Request(request, { signal: controller.signal }));\n } catch (err) {\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw new SmplTimeoutError(`Request timed out after ${ms}ms`);\n }\n throw err;\n } finally {\n clearTimeout(timer);\n }\n },\n });\n }\n\n /**\n * Fetch a single config by key or UUID.\n *\n * Exactly one of `key` or `id` must be provided.\n *\n * @throws {SmplNotFoundError} If no matching config exists.\n */\n async get(options: GetConfigOptions): Promise<Config> {\n const { key, id } = options;\n if ((key === undefined) === (id === undefined)) {\n throw new Error(\"Exactly one of 'key' or 'id' must be provided.\");\n }\n return id !== undefined ? this._getById(id) : this._getByKey(key!);\n }\n\n /**\n * List all configs for the account.\n */\n async list(): Promise<Config[]> {\n let data: components[\"schemas\"][\"ConfigListResponse\"] | undefined;\n try {\n const result = await this._http.GET(\"/api/v1/configs\", {});\n if (result.error !== undefined) await checkError(result.response, \"Failed to list configs\");\n data = result.data;\n } catch (err) {\n wrapFetchError(err);\n }\n if (!data) return [];\n return data.data.map((r) => resourceToConfig(r, this));\n }\n\n /**\n * Create a new config.\n *\n * @throws {SmplValidationError} If the server rejects the request.\n */\n async create(options: CreateConfigOptions): Promise<Config> {\n const body = buildRequestBody({\n name: options.name,\n key: options.key,\n description: options.description,\n parent: options.parent,\n values: options.values,\n });\n\n let data: components[\"schemas\"][\"ConfigResponse\"] | undefined;\n try {\n const result = await this._http.POST(\"/api/v1/configs\", { body });\n if (result.error !== undefined) await checkError(result.response, \"Failed to create config\");\n data = result.data;\n } catch (err) {\n wrapFetchError(err);\n }\n if (!data || !data.data) throw new SmplValidationError(\"Failed to create config\");\n return resourceToConfig(data.data, this);\n }\n\n /**\n * Delete a config by UUID.\n *\n * @throws {SmplNotFoundError} If the config does not exist.\n * @throws {SmplConflictError} If the config has child configs.\n */\n async delete(configId: string): Promise<void> {\n try {\n const result = await this._http.DELETE(\"/api/v1/configs/{id}\", {\n params: { path: { id: configId } },\n });\n if (result.error !== undefined && result.response.status !== 204)\n await checkError(result.response, `Failed to delete config ${configId}`);\n } catch (err) {\n wrapFetchError(err);\n }\n }\n\n /**\n * Internal: PUT a full config update and return the updated model.\n *\n * Called by {@link Config} instance methods.\n * @internal\n */\n async _updateConfig(payload: ConfigUpdatePayload): Promise<Config> {\n const body = buildRequestBody({\n id: payload.configId,\n name: payload.name,\n key: payload.key,\n description: payload.description,\n parent: payload.parent,\n values: payload.values,\n environments: payload.environments,\n });\n\n let data: components[\"schemas\"][\"ConfigResponse\"] | undefined;\n try {\n const result = await this._http.PUT(\"/api/v1/configs/{id}\", {\n params: { path: { id: payload.configId } },\n body,\n });\n if (result.error !== undefined)\n await checkError(result.response, `Failed to update config ${payload.configId}`);\n data = result.data;\n } catch (err) {\n wrapFetchError(err);\n }\n if (!data || !data.data)\n throw new SmplValidationError(`Failed to update config ${payload.configId}`);\n return resourceToConfig(data.data, this);\n }\n\n // ---- Private helpers ----\n\n private async _getById(configId: string): Promise<Config> {\n let data: components[\"schemas\"][\"ConfigResponse\"] | undefined;\n try {\n const result = await this._http.GET(\"/api/v1/configs/{id}\", {\n params: { path: { id: configId } },\n });\n if (result.error !== undefined)\n await checkError(result.response, `Config ${configId} not found`);\n data = result.data;\n } catch (err) {\n wrapFetchError(err);\n }\n if (!data || !data.data) throw new SmplNotFoundError(`Config ${configId} not found`);\n return resourceToConfig(data.data, this);\n }\n\n private async _getByKey(key: string): Promise<Config> {\n let data: components[\"schemas\"][\"ConfigListResponse\"] | undefined;\n try {\n const result = await this._http.GET(\"/api/v1/configs\", {\n params: { query: { \"filter[key]\": key } },\n });\n if (result.error !== undefined)\n await checkError(result.response, `Config with key '${key}' not found`);\n data = result.data;\n } catch (err) {\n wrapFetchError(err);\n }\n if (!data || !data.data || data.data.length === 0) {\n throw new SmplNotFoundError(`Config with key '${key}' not found`);\n }\n return resourceToConfig(data.data[0], this);\n }\n}\n","/**\n * Structured SDK error types.\n *\n * All smplkit errors extend {@link SmplError}, allowing callers to catch\n * the base class for generic handling or specific subclasses for\n * fine-grained control.\n */\n\n/** Base exception for all smplkit SDK errors. */\nexport class SmplError extends Error {\n /** The HTTP status code, if the error originated from an HTTP response. */\n public readonly statusCode?: number;\n\n /** The raw response body, if available. */\n public readonly responseBody?: string;\n\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message);\n this.name = \"SmplError\";\n this.statusCode = statusCode;\n this.responseBody = responseBody;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Raised when a network request fails (e.g., DNS resolution, connection refused). */\nexport class SmplConnectionError extends SmplError {\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message, statusCode, responseBody);\n this.name = \"SmplConnectionError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Raised when an operation exceeds its timeout. */\nexport class SmplTimeoutError extends SmplError {\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message, statusCode, responseBody);\n this.name = \"SmplTimeoutError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Raised when a requested resource does not exist (HTTP 404). */\nexport class SmplNotFoundError extends SmplError {\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message, statusCode ?? 404, responseBody);\n this.name = \"SmplNotFoundError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Raised when an operation conflicts with current state (HTTP 409). */\nexport class SmplConflictError extends SmplError {\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message, statusCode ?? 409, responseBody);\n this.name = \"SmplConflictError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Raised when the server rejects a request due to validation errors (HTTP 422). */\nexport class SmplValidationError extends SmplError {\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message, statusCode ?? 422, responseBody);\n this.name = \"SmplValidationError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * Config resource — management-plane model with runtime connect support.\n *\n * Instances are returned by {@link ConfigClient} methods and provide\n * management-plane operations (`update`, `setValues`, `setValue`) as well\n * as the {@link connect} entry point for runtime value resolution.\n */\n\nimport type { ConfigRuntime } from \"./runtime.js\";\nimport type { ConnectOptions } from \"./runtime-types.js\";\n\n/**\n * Internal type used by {@link ConfigClient}. Not part of the public API.\n * @internal\n */\nexport interface ConfigUpdatePayload {\n configId: string;\n name: string;\n key: string | null;\n description: string | null;\n parent: string | null;\n values: Record<string, unknown>;\n environments: Record<string, unknown>;\n}\n\n/**\n * A configuration resource fetched from the smplkit Config service.\n *\n * Instances are returned by {@link ConfigClient} methods and provide\n * management-plane operations as well as the {@link connect} entry point\n * for runtime value resolution.\n */\nexport class Config {\n /** UUID of the config. */\n id: string;\n\n /** Human-readable key (e.g. `\"user_service\"`). */\n key: string;\n\n /** Display name. */\n name: string;\n\n /** Optional description. */\n description: string | null;\n\n /** Parent config UUID, or null if this is a root config. */\n parent: string | null;\n\n /** Base key-value pairs. */\n values: Record<string, unknown>;\n\n /**\n * Per-environment overrides.\n * Stored as `{ env_name: { values: { key: value } } }` to match the\n * server's format.\n */\n environments: Record<string, unknown>;\n\n /** When the config was created, or null if unavailable. */\n createdAt: Date | null;\n\n /** When the config was last updated, or null if unavailable. */\n updatedAt: Date | null;\n\n /**\n * Internal reference to the parent client.\n * @internal\n */\n private readonly _client: {\n _updateConfig(payload: ConfigUpdatePayload): Promise<Config>;\n get(options: { id: string }): Promise<Config>;\n readonly _apiKey: string;\n readonly _baseUrl: string;\n };\n\n /** @internal */\n constructor(\n client: {\n _updateConfig(payload: ConfigUpdatePayload): Promise<Config>;\n get(options: { id: string }): Promise<Config>;\n readonly _apiKey: string;\n readonly _baseUrl: string;\n },\n fields: {\n id: string;\n key: string;\n name: string;\n description: string | null;\n parent: string | null;\n values: Record<string, unknown>;\n environments: Record<string, unknown>;\n createdAt: Date | null;\n updatedAt: Date | null;\n },\n ) {\n this._client = client;\n this.id = fields.id;\n this.key = fields.key;\n this.name = fields.name;\n this.description = fields.description;\n this.parent = fields.parent;\n this.values = fields.values;\n this.environments = fields.environments;\n this.createdAt = fields.createdAt;\n this.updatedAt = fields.updatedAt;\n }\n\n /**\n * Update this config's attributes on the server.\n *\n * Builds the request from current attribute values, overriding with any\n * provided options. Updates local attributes in place on success.\n *\n * @param options.name - New display name.\n * @param options.description - New description (pass empty string to clear).\n * @param options.values - New base values (replaces entirely).\n * @param options.environments - New environments dict (replaces entirely).\n */\n async update(options: {\n name?: string;\n description?: string;\n values?: Record<string, unknown>;\n environments?: Record<string, unknown>;\n }): Promise<void> {\n const updated = await this._client._updateConfig({\n configId: this.id,\n name: options.name ?? this.name,\n key: this.key,\n description: options.description !== undefined ? options.description : this.description,\n parent: this.parent,\n values: options.values ?? this.values,\n environments: options.environments ?? this.environments,\n });\n this.name = updated.name;\n this.description = updated.description;\n this.values = updated.values;\n this.environments = updated.environments;\n this.updatedAt = updated.updatedAt;\n }\n\n /**\n * Replace base or environment-specific values.\n *\n * When `environment` is provided, replaces that environment's `values`\n * sub-dict (other environments are preserved). When omitted, replaces\n * the base `values`.\n *\n * @param values - The complete set of values to set.\n * @param environment - Target environment, or omit for base values.\n */\n async setValues(values: Record<string, unknown>, environment?: string): Promise<void> {\n let newValues: Record<string, unknown>;\n let newEnvs: Record<string, unknown>;\n\n if (environment === undefined) {\n newValues = values;\n newEnvs = this.environments;\n } else {\n newValues = this.values;\n // Preserve any extra metadata on the environment entry (like other sub-keys),\n // but replace the `values` sub-dict entirely.\n const existingEntry =\n typeof this.environments[environment] === \"object\" &&\n this.environments[environment] !== null\n ? { ...(this.environments[environment] as Record<string, unknown>) }\n : {};\n existingEntry.values = values;\n newEnvs = { ...this.environments, [environment]: existingEntry };\n }\n\n const updated = await this._client._updateConfig({\n configId: this.id,\n name: this.name,\n key: this.key,\n description: this.description,\n parent: this.parent,\n values: newValues,\n environments: newEnvs,\n });\n this.values = updated.values;\n this.environments = updated.environments;\n this.updatedAt = updated.updatedAt;\n }\n\n /**\n * Set a single key within base or environment-specific values.\n *\n * Merges the key into existing values rather than replacing all values.\n *\n * @param key - The config key to set.\n * @param value - The value to assign.\n * @param environment - Target environment, or omit for base values.\n */\n async setValue(key: string, value: unknown, environment?: string): Promise<void> {\n if (environment === undefined) {\n const merged = { ...this.values, [key]: value };\n await this.setValues(merged);\n } else {\n const envEntry =\n typeof this.environments[environment] === \"object\" &&\n this.environments[environment] !== null\n ? (this.environments[environment] as Record<string, unknown>)\n : {};\n const existing = {\n ...(typeof envEntry.values === \"object\" && envEntry.values !== null\n ? (envEntry.values as Record<string, unknown>)\n : {}),\n };\n existing[key] = value;\n await this.setValues(existing, environment);\n }\n }\n\n /**\n * Connect to this config for runtime value resolution.\n *\n * Eagerly fetches this config and its full parent chain, resolves values\n * for the given environment via deep merge, and returns a\n * {@link ConfigRuntime} with a fully populated local cache.\n *\n * A background WebSocket connection is started for real-time updates.\n * If the WebSocket fails to connect, the runtime operates in cache-only\n * mode and reconnects automatically.\n *\n * Supports both `await` and `await using` (TypeScript 5.2+)::\n *\n * ```typescript\n * // Simple await\n * const runtime = await config.connect(\"production\");\n * try { ... } finally { await runtime.close(); }\n *\n * // await using (auto-close)\n * await using runtime = await config.connect(\"production\");\n * ```\n *\n * @param environment - The environment to resolve for (e.g. `\"production\"`).\n * @param options.timeout - Milliseconds to wait for the initial fetch.\n */\n async connect(environment: string, options?: ConnectOptions): Promise<ConfigRuntime> {\n // Lazy import to avoid loading ws at module-init time\n const { ConfigRuntime } = await import(\"./runtime.js\");\n\n const timeout = options?.timeout ?? 30_000;\n const chain = await this._buildChain(timeout);\n\n return new ConfigRuntime({\n configKey: this.key,\n configId: this.id,\n environment,\n chain,\n apiKey: this._client._apiKey,\n baseUrl: this._client._baseUrl,\n fetchChain: () => this._buildChain(timeout),\n });\n }\n\n /**\n * Walk the parent chain and return config data objects, child-to-root.\n * @internal\n */\n private async _buildChain(\n _timeout: number,\n ): Promise<\n Array<{ id: string; values: Record<string, unknown>; environments: Record<string, unknown> }>\n > {\n const chain: Array<{\n id: string;\n values: Record<string, unknown>;\n environments: Record<string, unknown>;\n }> = [{ id: this.id, values: this.values, environments: this.environments }];\n\n let parentId = this.parent;\n while (parentId !== null) {\n const parentConfig = await this._client.get({ id: parentId });\n chain.push({\n id: parentConfig.id,\n values: parentConfig.values,\n environments: parentConfig.environments,\n });\n parentId = parentConfig.parent;\n }\n\n return chain;\n }\n\n toString(): string {\n return `Config(id=${this.id}, key=${this.key}, name=${this.name})`;\n }\n}\n\n/** Options for creating a new config. */\nexport interface CreateConfigOptions {\n /** Display name for the config. */\n name: string;\n /** Human-readable key. Auto-generated by the server if omitted. */\n key?: string;\n /** Optional description. */\n description?: string;\n /** Parent config UUID. Defaults to the account's `common` config if omitted. */\n parent?: string;\n /** Initial base values. */\n values?: Record<string, unknown>;\n}\n\n/** Options for fetching a single config. Exactly one of `key` or `id` must be provided. */\nexport interface GetConfigOptions {\n /** Fetch by human-readable key. */\n key?: string;\n /** Fetch by UUID. */\n id?: string;\n}\n","/**\n * API key resolution chain: explicit → env var → config file.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { SmplError } from \"./errors.js\";\n\nconst NO_API_KEY_MESSAGE =\n \"No API key provided. Set one of:\\n\" +\n \" 1. Pass apiKey to the constructor\\n\" +\n \" 2. Set the SMPLKIT_API_KEY environment variable\\n\" +\n \" 3. Add api_key to [default] in ~/.smplkit\";\n\nexport function resolveApiKey(explicit?: string): string {\n if (explicit) return explicit;\n\n const envVal = process.env.SMPLKIT_API_KEY;\n if (envVal) return envVal;\n\n const configPath = join(homedir(), \".smplkit\");\n try {\n const content = readFileSync(configPath, \"utf-8\");\n const match = content.match(/\\[default\\]\\s*[\\s\\S]*?api_key\\s*=\\s*\"([^\"]+)\"/);\n if (match?.[1]) return match[1];\n } catch {\n // File doesn't exist or isn't readable — skip\n }\n\n throw new SmplError(NO_API_KEY_MESSAGE);\n}\n","/**\n * Top-level SDK client — SmplClient.\n *\n * The main entry point for the smplkit TypeScript SDK. Provides access\n * to sub-clients for each API domain (config, flags, logging, etc.).\n */\n\nimport { ConfigClient } from \"./config/client.js\";\nimport { resolveApiKey } from \"./resolve.js\";\n\n/** Configuration options for the {@link SmplClient}. */\nexport interface SmplClientOptions {\n /**\n * API key for authenticating with the smplkit platform.\n * When omitted, the SDK resolves it from the `SMPLKIT_API_KEY`\n * environment variable or the `~/.smplkit` configuration file.\n */\n apiKey?: string;\n\n /**\n * Request timeout in milliseconds.\n * @default 30000\n */\n timeout?: number;\n}\n\n/**\n * Entry point for the smplkit TypeScript SDK.\n *\n * @example\n * ```typescript\n * import { SmplClient } from \"@smplkit/sdk\";\n *\n * const client = new SmplClient({ apiKey: \"sk_api_...\" });\n * const cfg = await client.config.get({ key: \"common\" });\n * ```\n */\nexport class SmplClient {\n /** Client for config management-plane operations. */\n readonly config: ConfigClient;\n\n constructor(options: SmplClientOptions = {}) {\n const apiKey = resolveApiKey(options.apiK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|
+
{"version":3,"sources":["../src/config/client.ts","../src/errors.ts","../src/config/types.ts","../src/resolve.ts","../src/client.ts"],"sourcesContent":["/**\n * ConfigClient — management-plane operations for configs.\n *\n * Uses the generated OpenAPI types (`src/generated/config.d.ts`) via\n * `openapi-fetch` for all HTTP calls, keeping the client layer fully\n * type-safe without hand-coded request/response shapes.\n */\n\nimport createClient from \"openapi-fetch\";\nimport type { components, operations } from \"../generated/config.d.ts\";\nimport {\n SmplConflictError,\n SmplNotFoundError,\n SmplValidationError,\n SmplError,\n SmplConnectionError,\n SmplTimeoutError,\n} from \"../errors.js\";\nimport { Config } from \"./types.js\";\nimport type { ConfigUpdatePayload, CreateConfigOptions, GetConfigOptions } from \"./types.js\";\n\nconst BASE_URL = \"https://config.smplkit.com\";\n\ntype ApiConfig = components[\"schemas\"][\"Config-Input\"];\ntype ApiConfigOutput = components[\"schemas\"][\"Config-Output\"];\ntype ConfigResource = components[\"schemas\"][\"ConfigResource\"];\n\n/**\n * Extract raw values from typed items: `{key: {value, type?, description?}}` -> `{key: rawValue}`.\n * @internal\n */\nfunction extractItemValues(\n items: Record<string, { value: unknown }> | null | undefined,\n): Record<string, unknown> {\n if (!items) return {};\n const result: Record<string, unknown> = {};\n for (const [key, item] of Object.entries(items)) {\n result[key] = item && typeof item === \"object\" && \"value\" in item ? item.value : item;\n }\n return result;\n}\n\n/**\n * Extract raw values from environment overrides.\n * Wire format: `{ env: { values: { key: { value: raw } } } }`\n * SDK format: `{ env: { values: { key: raw } } }`\n * @internal\n */\nfunction extractEnvironments(\n environments:\n | Record<string, { values?: Record<string, { value: unknown }> | null }>\n | null\n | undefined,\n): Record<string, unknown> {\n if (!environments) return {};\n const result: Record<string, unknown> = {};\n for (const [envName, envEntry] of Object.entries(environments)) {\n if (envEntry && typeof envEntry === \"object\" && envEntry.values) {\n const unwrapped: Record<string, unknown> = {};\n for (const [key, item] of Object.entries(envEntry.values)) {\n unwrapped[key] = item && typeof item === \"object\" && \"value\" in item ? item.value : item;\n }\n result[envName] = { values: unwrapped };\n } else {\n result[envName] = envEntry;\n }\n }\n return result;\n}\n\n/** @internal */\nfunction resourceToConfig(resource: ConfigResource, client: ConfigClient): Config {\n const attrs: ApiConfigOutput = resource.attributes;\n return new Config(client, {\n id: resource.id ?? \"\",\n key: attrs.key ?? \"\",\n name: attrs.name,\n description: attrs.description ?? null,\n parent: attrs.parent ?? null,\n items: extractItemValues(attrs.items as Record<string, { value: unknown }> | null | undefined),\n environments: extractEnvironments(\n attrs.environments as\n | Record<string, { values?: Record<string, { value: unknown }> | null }>\n | null\n | undefined,\n ),\n createdAt: attrs.created_at ? new Date(attrs.created_at) : null,\n updatedAt: attrs.updated_at ? new Date(attrs.updated_at) : null,\n });\n}\n\n/**\n * Map fetch or HTTP errors to typed SDK exceptions.\n * @internal\n */\nasync function checkError(response: Response, context: string): Promise<never> {\n const body = await response.text().catch(() => \"\");\n switch (response.status) {\n case 404:\n throw new SmplNotFoundError(body || context, 404, body);\n case 409:\n throw new SmplConflictError(body || context, 409, body);\n case 422:\n throw new SmplValidationError(body || context, 422, body);\n default:\n throw new SmplError(`HTTP ${response.status}: ${body}`, response.status, body);\n }\n}\n\n/**\n * Re-raise fetch-level errors (network, timeout) as typed SDK exceptions.\n * @internal\n */\nfunction wrapFetchError(err: unknown): never {\n if (\n err instanceof SmplNotFoundError ||\n err instanceof SmplConflictError ||\n err instanceof SmplValidationError ||\n err instanceof SmplError\n ) {\n throw err;\n }\n if (err instanceof TypeError) {\n throw new SmplConnectionError(`Network error: ${err.message}`);\n }\n throw new SmplConnectionError(\n `Request failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n}\n\n/**\n * Wrap plain values into typed item format for the API.\n * `{key: rawValue}` -> `{key: {value: rawValue}}`\n * @internal\n */\nfunction wrapItemValues(\n values: Record<string, unknown> | null | undefined,\n): Record<string, { value: unknown }> | null {\n if (!values) return null;\n const result: Record<string, { value: unknown }> = {};\n for (const [key, val] of Object.entries(values)) {\n result[key] = { value: val };\n }\n return result;\n}\n\n/**\n * Wrap plain environment values into the API wire format.\n * SDK format: `{ env: { values: { key: raw } } }`\n * Wire format: `{ env: { values: { key: { value: raw } } } }`\n * @internal\n */\nfunction wrapEnvironments(\n environments: Record<string, unknown> | null | undefined,\n): Record<string, unknown> | null {\n if (!environments) return null;\n const result: Record<string, unknown> = {};\n for (const [envName, envEntry] of Object.entries(environments)) {\n if (envEntry && typeof envEntry === \"object\" && !Array.isArray(envEntry)) {\n const entry = envEntry as Record<string, unknown>;\n if (entry.values && typeof entry.values === \"object\" && !Array.isArray(entry.values)) {\n const wrapped: Record<string, { value: unknown }> = {};\n for (const [key, val] of Object.entries(entry.values as Record<string, unknown>)) {\n wrapped[key] = { value: val };\n }\n result[envName] = { ...entry, values: wrapped };\n } else {\n result[envName] = envEntry;\n }\n } else {\n result[envName] = envEntry;\n }\n }\n return result;\n}\n\n/**\n * Build a JSON:API request body for create/update operations.\n * @internal\n */\nfunction buildRequestBody(options: {\n id?: string | null;\n name: string;\n key?: string | null;\n description?: string | null;\n parent?: string | null;\n items?: Record<string, unknown> | null;\n environments?: Record<string, unknown> | null;\n}): operations[\"create_config\"][\"requestBody\"][\"content\"][\"application/json\"] {\n const attrs: ApiConfig = {\n name: options.name,\n };\n if (options.key !== undefined) attrs.key = options.key;\n if (options.description !== undefined) attrs.description = options.description;\n if (options.parent !== undefined) attrs.parent = options.parent;\n if (options.items !== undefined)\n attrs.items = wrapItemValues(options.items) as ApiConfig[\"items\"];\n if (options.environments !== undefined)\n attrs.environments = wrapEnvironments(options.environments) as ApiConfig[\"environments\"];\n\n return {\n data: {\n id: options.id ?? null,\n type: \"config\",\n attributes: attrs,\n },\n };\n}\n\n/**\n * Client for the smplkit Config API (management plane).\n *\n * All methods are async and return `Promise<T>`. Network and server\n * errors are mapped to typed SDK exceptions.\n *\n * Obtained via `SmplClient.config`.\n */\nexport class ConfigClient {\n /** @internal — used by Config instances for reconnecting and WebSocket auth. */\n readonly _apiKey: string;\n\n /** @internal */\n readonly _baseUrl: string = BASE_URL;\n\n /** @internal */\n private readonly _http: ReturnType<typeof createClient<import(\"../generated/config.d.ts\").paths>>;\n\n /** @internal */\n constructor(apiKey: string, timeout?: number) {\n this._apiKey = apiKey;\n const ms = timeout ?? 30_000;\n this._http = createClient<import(\"../generated/config.d.ts\").paths>({\n baseUrl: BASE_URL,\n headers: {\n Authorization: `Bearer ${apiKey}`,\n Accept: \"application/json\",\n },\n // openapi-fetch custom fetch receives a pre-built Request object\n fetch: async (request: Request): Promise<Response> => {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), ms);\n try {\n return await fetch(new Request(request, { signal: controller.signal }));\n } catch (err) {\n if (err instanceof DOMException && err.name === \"AbortError\") {\n throw new SmplTimeoutError(`Request timed out after ${ms}ms`);\n }\n throw err;\n } finally {\n clearTimeout(timer);\n }\n },\n });\n }\n\n /**\n * Fetch a single config by key or UUID.\n *\n * Exactly one of `key` or `id` must be provided.\n *\n * @throws {SmplNotFoundError} If no matching config exists.\n */\n async get(options: GetConfigOptions): Promise<Config> {\n const { key, id } = options;\n if ((key === undefined) === (id === undefined)) {\n throw new Error(\"Exactly one of 'key' or 'id' must be provided.\");\n }\n return id !== undefined ? this._getById(id) : this._getByKey(key!);\n }\n\n /**\n * List all configs for the account.\n */\n async list(): Promise<Config[]> {\n let data: components[\"schemas\"][\"ConfigListResponse\"] | undefined;\n try {\n const result = await this._http.GET(\"/api/v1/configs\", {});\n if (result.error !== undefined) await checkError(result.response, \"Failed to list configs\");\n data = result.data;\n } catch (err) {\n wrapFetchError(err);\n }\n if (!data) return [];\n return data.data.map((r) => resourceToConfig(r, this));\n }\n\n /**\n * Create a new config.\n *\n * @throws {SmplValidationError} If the server rejects the request.\n */\n async create(options: CreateConfigOptions): Promise<Config> {\n const body = buildRequestBody({\n name: options.name,\n key: options.key,\n description: options.description,\n parent: options.parent,\n items: options.items,\n });\n\n let data: components[\"schemas\"][\"ConfigResponse\"] | undefined;\n try {\n const result = await this._http.POST(\"/api/v1/configs\", { body });\n if (result.error !== undefined) await checkError(result.response, \"Failed to create config\");\n data = result.data;\n } catch (err) {\n wrapFetchError(err);\n }\n if (!data || !data.data) throw new SmplValidationError(\"Failed to create config\");\n return resourceToConfig(data.data, this);\n }\n\n /**\n * Delete a config by UUID.\n *\n * @throws {SmplNotFoundError} If the config does not exist.\n * @throws {SmplConflictError} If the config has child configs.\n */\n async delete(configId: string): Promise<void> {\n try {\n const result = await this._http.DELETE(\"/api/v1/configs/{id}\", {\n params: { path: { id: configId } },\n });\n if (result.error !== undefined && result.response.status !== 204)\n await checkError(result.response, `Failed to delete config ${configId}`);\n } catch (err) {\n wrapFetchError(err);\n }\n }\n\n /**\n * Internal: PUT a full config update and return the updated model.\n *\n * Called by {@link Config} instance methods.\n * @internal\n */\n async _updateConfig(payload: ConfigUpdatePayload): Promise<Config> {\n const body = buildRequestBody({\n id: payload.configId,\n name: payload.name,\n key: payload.key,\n description: payload.description,\n parent: payload.parent,\n items: payload.items,\n environments: payload.environments,\n });\n\n let data: components[\"schemas\"][\"ConfigResponse\"] | undefined;\n try {\n const result = await this._http.PUT(\"/api/v1/configs/{id}\", {\n params: { path: { id: payload.configId } },\n body,\n });\n if (result.error !== undefined)\n await checkError(result.response, `Failed to update config ${payload.configId}`);\n data = result.data;\n } catch (err) {\n wrapFetchError(err);\n }\n if (!data || !data.data)\n throw new SmplValidationError(`Failed to update config ${payload.configId}`);\n return resourceToConfig(data.data, this);\n }\n\n // ---- Private helpers ----\n\n private async _getById(configId: string): Promise<Config> {\n let data: components[\"schemas\"][\"ConfigResponse\"] | undefined;\n try {\n const result = await this._http.GET(\"/api/v1/configs/{id}\", {\n params: { path: { id: configId } },\n });\n if (result.error !== undefined)\n await checkError(result.response, `Config ${configId} not found`);\n data = result.data;\n } catch (err) {\n wrapFetchError(err);\n }\n if (!data || !data.data) throw new SmplNotFoundError(`Config ${configId} not found`);\n return resourceToConfig(data.data, this);\n }\n\n private async _getByKey(key: string): Promise<Config> {\n let data: components[\"schemas\"][\"ConfigListResponse\"] | undefined;\n try {\n const result = await this._http.GET(\"/api/v1/configs\", {\n params: { query: { \"filter[key]\": key } },\n });\n if (result.error !== undefined)\n await checkError(result.response, `Config with key '${key}' not found`);\n data = result.data;\n } catch (err) {\n wrapFetchError(err);\n }\n if (!data || !data.data || data.data.length === 0) {\n throw new SmplNotFoundError(`Config with key '${key}' not found`);\n }\n return resourceToConfig(data.data[0], this);\n }\n}\n","/**\n * Structured SDK error types.\n *\n * All smplkit errors extend {@link SmplError}, allowing callers to catch\n * the base class for generic handling or specific subclasses for\n * fine-grained control.\n */\n\n/** Base exception for all smplkit SDK errors. */\nexport class SmplError extends Error {\n /** The HTTP status code, if the error originated from an HTTP response. */\n public readonly statusCode?: number;\n\n /** The raw response body, if available. */\n public readonly responseBody?: string;\n\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message);\n this.name = \"SmplError\";\n this.statusCode = statusCode;\n this.responseBody = responseBody;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Raised when a network request fails (e.g., DNS resolution, connection refused). */\nexport class SmplConnectionError extends SmplError {\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message, statusCode, responseBody);\n this.name = \"SmplConnectionError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Raised when an operation exceeds its timeout. */\nexport class SmplTimeoutError extends SmplError {\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message, statusCode, responseBody);\n this.name = \"SmplTimeoutError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Raised when a requested resource does not exist (HTTP 404). */\nexport class SmplNotFoundError extends SmplError {\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message, statusCode ?? 404, responseBody);\n this.name = \"SmplNotFoundError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Raised when an operation conflicts with current state (HTTP 409). */\nexport class SmplConflictError extends SmplError {\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message, statusCode ?? 409, responseBody);\n this.name = \"SmplConflictError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Raised when the server rejects a request due to validation errors (HTTP 422). */\nexport class SmplValidationError extends SmplError {\n constructor(message: string, statusCode?: number, responseBody?: string) {\n super(message, statusCode ?? 422, responseBody);\n this.name = \"SmplValidationError\";\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","/**\n * Config resource — management-plane model with runtime connect support.\n *\n * Instances are returned by {@link ConfigClient} methods and provide\n * management-plane operations (`update`, `setValues`, `setValue`) as well\n * as the {@link connect} entry point for runtime value resolution.\n */\n\nimport type { ConfigRuntime } from \"./runtime.js\";\nimport type { ConnectOptions } from \"./runtime-types.js\";\n\n/**\n * Internal type used by {@link ConfigClient}. Not part of the public API.\n * @internal\n */\nexport interface ConfigUpdatePayload {\n configId: string;\n name: string;\n key: string | null;\n description: string | null;\n parent: string | null;\n items: Record<string, unknown>;\n environments: Record<string, unknown>;\n}\n\n/**\n * A configuration resource fetched from the smplkit Config service.\n *\n * Instances are returned by {@link ConfigClient} methods and provide\n * management-plane operations as well as the {@link connect} entry point\n * for runtime value resolution.\n */\nexport class Config {\n /** UUID of the config. */\n id: string;\n\n /** Human-readable key (e.g. `\"user_service\"`). */\n key: string;\n\n /** Display name. */\n name: string;\n\n /** Optional description. */\n description: string | null;\n\n /** Parent config UUID, or null if this is a root config. */\n parent: string | null;\n\n /** Base key-value pairs (unwrapped from typed item definitions). */\n items: Record<string, unknown>;\n\n /**\n * Per-environment overrides.\n * Stored as `{ env_name: { values: { key: value } } }` — values are\n * unwrapped from the server's `{ value: raw }` wrapper.\n */\n environments: Record<string, unknown>;\n\n /** When the config was created, or null if unavailable. */\n createdAt: Date | null;\n\n /** When the config was last updated, or null if unavailable. */\n updatedAt: Date | null;\n\n /**\n * Internal reference to the parent client.\n * @internal\n */\n private readonly _client: {\n _updateConfig(payload: ConfigUpdatePayload): Promise<Config>;\n get(options: { id: string }): Promise<Config>;\n readonly _apiKey: string;\n readonly _baseUrl: string;\n };\n\n /** @internal */\n constructor(\n client: {\n _updateConfig(payload: ConfigUpdatePayload): Promise<Config>;\n get(options: { id: string }): Promise<Config>;\n readonly _apiKey: string;\n readonly _baseUrl: string;\n },\n fields: {\n id: string;\n key: string;\n name: string;\n description: string | null;\n parent: string | null;\n items: Record<string, unknown>;\n environments: Record<string, unknown>;\n createdAt: Date | null;\n updatedAt: Date | null;\n },\n ) {\n this._client = client;\n this.id = fields.id;\n this.key = fields.key;\n this.name = fields.name;\n this.description = fields.description;\n this.parent = fields.parent;\n this.items = fields.items;\n this.environments = fields.environments;\n this.createdAt = fields.createdAt;\n this.updatedAt = fields.updatedAt;\n }\n\n /**\n * Update this config's attributes on the server.\n *\n * Builds the request from current attribute values, overriding with any\n * provided options. Updates local attributes in place on success.\n *\n * @param options.name - New display name.\n * @param options.description - New description (pass empty string to clear).\n * @param options.items - New base values (replaces entirely).\n * @param options.environments - New environments dict (replaces entirely).\n */\n async update(options: {\n name?: string;\n description?: string;\n items?: Record<string, unknown>;\n environments?: Record<string, unknown>;\n }): Promise<void> {\n const updated = await this._client._updateConfig({\n configId: this.id,\n name: options.name ?? this.name,\n key: this.key,\n description: options.description !== undefined ? options.description : this.description,\n parent: this.parent,\n items: options.items ?? this.items,\n environments: options.environments ?? this.environments,\n });\n this.name = updated.name;\n this.description = updated.description;\n this.items = updated.items;\n this.environments = updated.environments;\n this.updatedAt = updated.updatedAt;\n }\n\n /**\n * Replace base or environment-specific values.\n *\n * When `environment` is provided, replaces that environment's `values`\n * sub-dict (other environments are preserved). When omitted, replaces\n * the base `items`.\n *\n * @param values - The complete set of values to set.\n * @param environment - Target environment, or omit for base values.\n */\n async setValues(values: Record<string, unknown>, environment?: string): Promise<void> {\n let newItems: Record<string, unknown>;\n let newEnvs: Record<string, unknown>;\n\n if (environment === undefined) {\n newItems = values;\n newEnvs = this.environments;\n } else {\n newItems = this.items;\n // Preserve any extra metadata on the environment entry (like other sub-keys),\n // but replace the `values` sub-dict entirely.\n const existingEntry =\n typeof this.environments[environment] === \"object\" &&\n this.environments[environment] !== null\n ? { ...(this.environments[environment] as Record<string, unknown>) }\n : {};\n existingEntry.values = values;\n newEnvs = { ...this.environments, [environment]: existingEntry };\n }\n\n const updated = await this._client._updateConfig({\n configId: this.id,\n name: this.name,\n key: this.key,\n description: this.description,\n parent: this.parent,\n items: newItems,\n environments: newEnvs,\n });\n this.items = updated.items;\n this.environments = updated.environments;\n this.updatedAt = updated.updatedAt;\n }\n\n /**\n * Set a single key within base or environment-specific values.\n *\n * Merges the key into existing values rather than replacing all values.\n *\n * @param key - The config key to set.\n * @param value - The value to assign.\n * @param environment - Target environment, or omit for base values.\n */\n async setValue(key: string, value: unknown, environment?: string): Promise<void> {\n if (environment === undefined) {\n const merged = { ...this.items, [key]: value };\n await this.setValues(merged);\n } else {\n const envEntry =\n typeof this.environments[environment] === \"object\" &&\n this.environments[environment] !== null\n ? (this.environments[environment] as Record<string, unknown>)\n : {};\n const existing = {\n ...(typeof envEntry.values === \"object\" && envEntry.values !== null\n ? (envEntry.values as Record<string, unknown>)\n : {}),\n };\n existing[key] = value;\n await this.setValues(existing, environment);\n }\n }\n\n /**\n * Connect to this config for runtime value resolution.\n *\n * Eagerly fetches this config and its full parent chain, resolves values\n * for the given environment via deep merge, and returns a\n * {@link ConfigRuntime} with a fully populated local cache.\n *\n * A background WebSocket connection is started for real-time updates.\n * If the WebSocket fails to connect, the runtime operates in cache-only\n * mode and reconnects automatically.\n *\n * Supports both `await` and `await using` (TypeScript 5.2+)::\n *\n * ```typescript\n * // Simple await\n * const runtime = await config.connect(\"production\");\n * try { ... } finally { await runtime.close(); }\n *\n * // await using (auto-close)\n * await using runtime = await config.connect(\"production\");\n * ```\n *\n * @param environment - The environment to resolve for (e.g. `\"production\"`).\n * @param options.timeout - Milliseconds to wait for the initial fetch.\n */\n async connect(environment: string, options?: ConnectOptions): Promise<ConfigRuntime> {\n // Lazy import to avoid loading ws at module-init time\n const { ConfigRuntime } = await import(\"./runtime.js\");\n\n const timeout = options?.timeout ?? 30_000;\n const chain = await this._buildChain(timeout);\n\n return new ConfigRuntime({\n configKey: this.key,\n configId: this.id,\n environment,\n chain,\n apiKey: this._client._apiKey,\n baseUrl: this._client._baseUrl,\n fetchChain: () => this._buildChain(timeout),\n });\n }\n\n /**\n * Walk the parent chain and return config data objects, child-to-root.\n * @internal\n */\n private async _buildChain(\n _timeout: number,\n ): Promise<\n Array<{ id: string; items: Record<string, unknown>; environments: Record<string, unknown> }>\n > {\n const chain: Array<{\n id: string;\n items: Record<string, unknown>;\n environments: Record<string, unknown>;\n }> = [{ id: this.id, items: this.items, environments: this.environments }];\n\n let parentId = this.parent;\n while (parentId !== null) {\n const parentConfig = await this._client.get({ id: parentId });\n chain.push({\n id: parentConfig.id,\n items: parentConfig.items,\n environments: parentConfig.environments,\n });\n parentId = parentConfig.parent;\n }\n\n return chain;\n }\n\n toString(): string {\n return `Config(id=${this.id}, key=${this.key}, name=${this.name})`;\n }\n}\n\n/** Options for creating a new config. */\nexport interface CreateConfigOptions {\n /** Display name for the config. */\n name: string;\n /** Human-readable key. Auto-generated by the server if omitted. */\n key?: string;\n /** Optional description. */\n description?: string;\n /** Parent config UUID. Defaults to the account's `common` config if omitted. */\n parent?: string;\n /** Initial base values. */\n items?: Record<string, unknown>;\n}\n\n/** Options for fetching a single config. Exactly one of `key` or `id` must be provided. */\nexport interface GetConfigOptions {\n /** Fetch by human-readable key. */\n key?: string;\n /** Fetch by UUID. */\n id?: string;\n}\n","/**\n * API key resolution chain: explicit → env var → config file.\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { SmplError } from \"./errors.js\";\n\nconst NO_API_KEY_MESSAGE =\n \"No API key provided. Set one of:\\n\" +\n \" 1. Pass apiKey to the constructor\\n\" +\n \" 2. Set the SMPLKIT_API_KEY environment variable\\n\" +\n \" 3. Add api_key to [default] in ~/.smplkit\";\n\nexport function resolveApiKey(explicit?: string): string {\n if (explicit) return explicit;\n\n const envVal = process.env.SMPLKIT_API_KEY;\n if (envVal) return envVal;\n\n const configPath = join(homedir(), \".smplkit\");\n try {\n const content = readFileSync(configPath, \"utf-8\");\n const match = content.match(/\\[default\\]\\s*[\\s\\S]*?api_key\\s*=\\s*\"([^\"]+)\"/);\n if (match?.[1]) return match[1];\n } catch {\n // File doesn't exist or isn't readable — skip\n }\n\n throw new SmplError(NO_API_KEY_MESSAGE);\n}\n","/**\n * Top-level SDK client — SmplClient.\n *\n * The main entry point for the smplkit TypeScript SDK. Provides access\n * to sub-clients for each API domain (config, flags, logging, etc.).\n */\n\nimport { ConfigClient } from \"./config/client.js\";\nimport { resolveApiKey } from \"./resolve.js\";\n\n/** Configuration options for the {@link SmplClient}. */\nexport interface SmplClientOptions {\n /**\n * API key for authenticating with the smplkit platform.\n * When omitted, the SDK resolves it from the `SMPLKIT_API_KEY`\n * environment variable or the `~/.smplkit` configuration file.\n */\n apiKey?: string;\n\n /**\n * Request timeout in milliseconds.\n * @default 30000\n */\n timeout?: number;\n}\n\n/**\n * Entry point for the smplkit TypeScript SDK.\n *\n * @example\n * ```typescript\n * import { SmplClient } from \"@smplkit/sdk\";\n *\n * const client = new SmplClient({ apiKey: \"sk_api_...\" });\n * const cfg = await client.config.get({ key: \"common\" });\n * ```\n */\nexport class SmplClient {\n /** Client for config management-plane operations. */\n readonly config: ConfigClient;\n\n constructor(options: SmplClientOptions = {}) {\n const apiKey = resolveApiKey(options.apiKey);\n this.config = new ConfigClient(apiKey, options.timeout);\n }\n}\n"],"mappings":";;;;;AAQA,OAAO,kBAAkB;;;ACClB,IAAM,YAAN,cAAwB,MAAM;AAAA;AAAA,EAEnB;AAAA;AAAA,EAGA;AAAA,EAEhB,YAAY,SAAiB,YAAqB,cAAuB;AACvE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,eAAe;AACpB,WAAO,eAAe,M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