@smplkit/sdk 3.0.50 → 3.0.52
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 +53 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -36
- package/dist/index.d.ts +72 -36
- package/dist/index.js +53 -99
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -19291,12 +19291,10 @@ var LoggerChangeEvent = class {
|
|
|
19291
19291
|
id;
|
|
19292
19292
|
source;
|
|
19293
19293
|
level;
|
|
19294
|
-
deleted;
|
|
19295
19294
|
constructor(fields) {
|
|
19296
19295
|
this.id = fields.id;
|
|
19297
19296
|
this.source = fields.source;
|
|
19298
|
-
|
|
19299
|
-
if (fields.deleted) this.deleted = fields.deleted;
|
|
19297
|
+
this.level = fields.level;
|
|
19300
19298
|
Object.freeze(this);
|
|
19301
19299
|
}
|
|
19302
19300
|
};
|
|
@@ -19938,16 +19936,15 @@ function _paginationFromBody2(body) {
|
|
|
19938
19936
|
}
|
|
19939
19937
|
return out;
|
|
19940
19938
|
}
|
|
19941
|
-
function
|
|
19939
|
+
function _configurationToWire(config) {
|
|
19942
19940
|
return {
|
|
19943
|
-
method:
|
|
19944
|
-
url:
|
|
19945
|
-
headers:
|
|
19946
|
-
|
|
19947
|
-
success_status: http.successStatus
|
|
19941
|
+
method: config.method,
|
|
19942
|
+
url: config.url,
|
|
19943
|
+
headers: config.headers.map((h) => ({ name: h.name, value: h.value })),
|
|
19944
|
+
success_status: config.successStatus
|
|
19948
19945
|
};
|
|
19949
19946
|
}
|
|
19950
|
-
function
|
|
19947
|
+
function _configurationFromWire(raw) {
|
|
19951
19948
|
const r = raw ?? {};
|
|
19952
19949
|
const headers = (r.headers ?? []).map((h) => ({
|
|
19953
19950
|
name: String(h.name ?? ""),
|
|
@@ -19957,7 +19954,6 @@ function _httpFromWire(raw) {
|
|
|
19957
19954
|
method: String(r.method ?? "POST"),
|
|
19958
19955
|
url: String(r.url ?? ""),
|
|
19959
19956
|
headers,
|
|
19960
|
-
body: r.body ?? null,
|
|
19961
19957
|
successStatus: String(r.success_status ?? "2xx")
|
|
19962
19958
|
};
|
|
19963
19959
|
}
|
|
@@ -19966,11 +19962,13 @@ function _forwarderAttributes(input) {
|
|
|
19966
19962
|
name: input.name,
|
|
19967
19963
|
forwarder_type: input.forwarderType,
|
|
19968
19964
|
enabled: input.enabled ?? true,
|
|
19969
|
-
|
|
19965
|
+
configuration: _configurationToWire(input.configuration)
|
|
19970
19966
|
};
|
|
19967
|
+
if (input.description !== void 0) attrs.description = input.description;
|
|
19971
19968
|
if (input.filter !== void 0) {
|
|
19972
19969
|
attrs.filter = input.filter;
|
|
19973
19970
|
}
|
|
19971
|
+
if (input.transformType !== void 0) attrs.transform_type = input.transformType;
|
|
19974
19972
|
if (input.transform !== void 0) attrs.transform = input.transform;
|
|
19975
19973
|
return attrs;
|
|
19976
19974
|
}
|
|
@@ -19979,12 +19977,13 @@ function _forwarderFromResource(resource) {
|
|
|
19979
19977
|
return {
|
|
19980
19978
|
id: resource.id,
|
|
19981
19979
|
name: String(a.name ?? ""),
|
|
19982
|
-
|
|
19980
|
+
description: a.description ?? null,
|
|
19983
19981
|
forwarderType: a.forwarder_type,
|
|
19984
19982
|
enabled: Boolean(a.enabled ?? true),
|
|
19985
19983
|
filter: a.filter ?? null,
|
|
19984
|
+
transformType: a.transform_type ?? null,
|
|
19986
19985
|
transform: a.transform ?? null,
|
|
19987
|
-
|
|
19986
|
+
configuration: _configurationFromWire(a.configuration),
|
|
19988
19987
|
createdAt: a.created_at ?? null,
|
|
19989
19988
|
updatedAt: a.updated_at ?? null,
|
|
19990
19989
|
deletedAt: a.deleted_at ?? null,
|
|
@@ -22220,27 +22219,24 @@ var LoggingClient = class {
|
|
|
22220
22219
|
/**
|
|
22221
22220
|
* Refresh resolved levels and apply them to adapter-known loggers.
|
|
22222
22221
|
*
|
|
22223
|
-
*
|
|
22224
|
-
*
|
|
22225
|
-
*
|
|
22226
|
-
*
|
|
22222
|
+
* Walks every adapter-known logger name through {@link resolveLevel}
|
|
22223
|
+
* (env override → base → group chain → dot-notation ancestry → fallback)
|
|
22224
|
+
* and pushes the result to every registered adapter. Loggers whose own
|
|
22225
|
+
* `level` is `null` are still applied — that's the whole point of group
|
|
22226
|
+
* inheritance and dot-notation ancestry.
|
|
22227
22227
|
*
|
|
22228
|
-
* The
|
|
22229
|
-
*
|
|
22230
|
-
*
|
|
22231
|
-
*
|
|
22228
|
+
* The resolved-level snapshot lives in `_resolvedLevelStore` so callers
|
|
22229
|
+
* can diff pre-vs-post and fire change listeners on actual effective-
|
|
22230
|
+
* level deltas. The store is scoped to adapter-known names: listener
|
|
22231
|
+
* fanout pairs 1:1 with `adapter.applyLevel` calls, so a logger that
|
|
22232
|
+
* the adapter doesn't know about has no apply and no listener fire.
|
|
22232
22233
|
* @internal
|
|
22233
22234
|
*/
|
|
22234
22235
|
_applyLevels() {
|
|
22235
22236
|
const environment = this._parent?._environment ?? "";
|
|
22236
22237
|
const newResolved = {};
|
|
22237
|
-
for (const id of Object.keys(this._loggersCache)) {
|
|
22238
|
-
newResolved[id] = resolveLevel(id, environment, this._loggersCache, this._groupsCache);
|
|
22239
|
-
}
|
|
22240
22238
|
for (const name of this._knownLoggerNames) {
|
|
22241
|
-
|
|
22242
|
-
newResolved[name] = resolveLevel(name, environment, this._loggersCache, this._groupsCache);
|
|
22243
|
-
}
|
|
22239
|
+
newResolved[name] = resolveLevel(name, environment, this._loggersCache, this._groupsCache);
|
|
22244
22240
|
}
|
|
22245
22241
|
this._resolvedLevelStore = newResolved;
|
|
22246
22242
|
for (const name of this._knownLoggerNames) {
|
|
@@ -22373,7 +22369,6 @@ var LoggingClient = class {
|
|
|
22373
22369
|
delete this._loggersCache[id];
|
|
22374
22370
|
const preResolved = { ...this._resolvedLevelStore };
|
|
22375
22371
|
this._applyLevels();
|
|
22376
|
-
this._emitDeletedEvent(id, "websocket");
|
|
22377
22372
|
this._fireDeltas(preResolved, this._resolvedLevelStore, "websocket", /* @__PURE__ */ new Set([id]));
|
|
22378
22373
|
};
|
|
22379
22374
|
_handleGroupChanged = (data) => {
|
|
@@ -22403,45 +22398,41 @@ var LoggingClient = class {
|
|
|
22403
22398
|
delete this._groupsCache[id];
|
|
22404
22399
|
const preResolved = { ...this._resolvedLevelStore };
|
|
22405
22400
|
this._applyLevels();
|
|
22406
|
-
this._emitDeletedEvent(id, "websocket");
|
|
22407
22401
|
this._fireDeltas(preResolved, this._resolvedLevelStore, "websocket", /* @__PURE__ */ new Set([id]));
|
|
22408
22402
|
};
|
|
22409
22403
|
/**
|
|
22410
|
-
* @internal Fire change listeners for every logger whose
|
|
22411
|
-
* changed between `pre` and `post`.
|
|
22412
|
-
*
|
|
22413
|
-
*
|
|
22404
|
+
* @internal Fire change listeners for every logger whose effective level
|
|
22405
|
+
* changed between `pre` and `post`.
|
|
22406
|
+
*
|
|
22407
|
+
* Contract:
|
|
22408
|
+
* - Iterates loggers present in `post` (the post-apply resolved store).
|
|
22409
|
+
* A key in `pre` but not in `post` is a cache eviction — that key
|
|
22410
|
+
* itself fires nothing. Dependents that re-resolved to a new value
|
|
22411
|
+
* are still in `post` and fire normally.
|
|
22412
|
+
* - For every changed logger, fires every global listener once with
|
|
22413
|
+
* that logger's own payload (no "summary" event), then fires every
|
|
22414
|
+
* key-scoped listener registered for that id.
|
|
22415
|
+
* - One adapter.applyLevel call ↔ one listener notification per
|
|
22416
|
+
* subscriber. A trigger that moves N loggers fires the global
|
|
22417
|
+
* listener N times, not once.
|
|
22418
|
+
* - `suppressIds` is the deletion-event escape hatch: a deleted id
|
|
22419
|
+
* fires nothing for itself even when its adapter-known resolved
|
|
22420
|
+
* level moved (e.g. fell back to INFO).
|
|
22414
22421
|
*/
|
|
22415
|
-
_fireDeltas(pre, post, source,
|
|
22416
|
-
const
|
|
22417
|
-
|
|
22418
|
-
|
|
22419
|
-
if (
|
|
22420
|
-
|
|
22421
|
-
|
|
22422
|
-
|
|
22423
|
-
|
|
22424
|
-
|
|
22425
|
-
|
|
22426
|
-
id,
|
|
22427
|
-
source,
|
|
22428
|
-
level: post[id] ?? null
|
|
22429
|
-
};
|
|
22430
|
-
if (isDeletion) fields.deleted = true;
|
|
22431
|
-
return new LoggerChangeEvent(fields);
|
|
22432
|
-
};
|
|
22433
|
-
const firstKey = changed[0];
|
|
22434
|
-
const globalEvent = buildEvent(firstKey);
|
|
22435
|
-
for (const cb of this._globalListeners) {
|
|
22436
|
-
try {
|
|
22437
|
-
cb(globalEvent);
|
|
22438
|
-
} catch {
|
|
22422
|
+
_fireDeltas(pre, post, source, suppressIds) {
|
|
22423
|
+
for (const id of Object.keys(post)) {
|
|
22424
|
+
if (suppressIds?.has(id)) continue;
|
|
22425
|
+
const next = post[id];
|
|
22426
|
+
if (pre[id] === next) continue;
|
|
22427
|
+
const event = new LoggerChangeEvent({ id, source, level: next });
|
|
22428
|
+
for (const cb of this._globalListeners) {
|
|
22429
|
+
try {
|
|
22430
|
+
cb(event);
|
|
22431
|
+
} catch {
|
|
22432
|
+
}
|
|
22439
22433
|
}
|
|
22440
|
-
|
|
22441
|
-
for (const k of changed) {
|
|
22442
|
-
const keyCallbacks = this._keyListeners.get(k);
|
|
22434
|
+
const keyCallbacks = this._keyListeners.get(id);
|
|
22443
22435
|
if (keyCallbacks) {
|
|
22444
|
-
const event = buildEvent(k);
|
|
22445
22436
|
for (const cb of keyCallbacks) {
|
|
22446
22437
|
try {
|
|
22447
22438
|
cb(event);
|
|
@@ -22451,43 +22442,6 @@ var LoggingClient = class {
|
|
|
22451
22442
|
}
|
|
22452
22443
|
}
|
|
22453
22444
|
}
|
|
22454
|
-
/**
|
|
22455
|
-
* @internal Always emit a deleted event for `id` on global and per-key
|
|
22456
|
-
* listeners. Used by `logger_deleted` / `group_deleted` handlers to
|
|
22457
|
-
* preserve the explicit notification contract even when nothing in the
|
|
22458
|
-
* resolved-level store changed (e.g. server removed an unknown logger).
|
|
22459
|
-
*/
|
|
22460
|
-
_emitDeletedEvent(id, source) {
|
|
22461
|
-
const event = new LoggerChangeEvent({
|
|
22462
|
-
id,
|
|
22463
|
-
level: null,
|
|
22464
|
-
source,
|
|
22465
|
-
deleted: true
|
|
22466
|
-
});
|
|
22467
|
-
for (const cb of this._globalListeners) {
|
|
22468
|
-
try {
|
|
22469
|
-
cb(event);
|
|
22470
|
-
} catch (err) {
|
|
22471
|
-
debug(
|
|
22472
|
-
"websocket",
|
|
22473
|
-
`deleted listener error: ${err instanceof Error ? err.message : String(err)}`
|
|
22474
|
-
);
|
|
22475
|
-
}
|
|
22476
|
-
}
|
|
22477
|
-
const idCallbacks = this._keyListeners.get(id);
|
|
22478
|
-
if (idCallbacks) {
|
|
22479
|
-
for (const cb of idCallbacks) {
|
|
22480
|
-
try {
|
|
22481
|
-
cb(event);
|
|
22482
|
-
} catch (err) {
|
|
22483
|
-
debug(
|
|
22484
|
-
"websocket",
|
|
22485
|
-
`deleted key listener error: ${err instanceof Error ? err.message : String(err)}`
|
|
22486
|
-
);
|
|
22487
|
-
}
|
|
22488
|
-
}
|
|
22489
|
-
}
|
|
22490
|
-
}
|
|
22491
22445
|
_handleLoggersChanged = (_data) => {
|
|
22492
22446
|
debug("websocket", `loggers_changed event received`);
|
|
22493
22447
|
void this._resolveAndFire("websocket").catch(() => {
|