@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.d.cts
CHANGED
|
@@ -106,27 +106,54 @@ interface HttpHeader {
|
|
|
106
106
|
* {@link FORWARDER_TYPES} for callers that need to iterate.
|
|
107
107
|
*/
|
|
108
108
|
type ForwarderType = "HTTP" | "DATADOG" | "SPLUNK_HEC" | "SUMO_LOGIC" | "NEW_RELIC" | "HONEYCOMB" | "ELASTIC";
|
|
109
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Transport-specific delivery configuration. Today every destination
|
|
111
|
+
* type uses HTTP; future transports (FTP, SQS, ...) will join this as
|
|
112
|
+
* members of a discriminated union under {@link Forwarder.configuration}.
|
|
113
|
+
*/
|
|
114
|
+
interface HttpConfiguration {
|
|
115
|
+
/** HTTP method: GET, POST, PUT, PATCH, or DELETE. */
|
|
110
116
|
method: string;
|
|
117
|
+
/** Destination URL. */
|
|
111
118
|
url: string;
|
|
119
|
+
/** HTTP headers attached to each delivery request. */
|
|
112
120
|
headers: HttpHeader[];
|
|
113
|
-
body: string | null;
|
|
114
121
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
122
|
+
* Either an exact HTTP code (e.g. `"200"`, `"204"`) or a status class
|
|
123
|
+
* (`"1xx"`, `"2xx"`, `"3xx"`, `"4xx"`, `"5xx"`).
|
|
117
124
|
*/
|
|
118
125
|
successStatus: string;
|
|
119
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Engine used to evaluate {@link Forwarder.transform}. Must be set
|
|
129
|
+
* whenever `transform` is set. Today only `JSONATA` is supported.
|
|
130
|
+
*/
|
|
131
|
+
type TransformType = "JSONATA";
|
|
120
132
|
interface Forwarder {
|
|
133
|
+
/** UUID assigned by the server at creation time. */
|
|
121
134
|
id: string;
|
|
122
135
|
name: string;
|
|
123
|
-
|
|
136
|
+
/** Free-text description for the forwarder. */
|
|
137
|
+
description: string | null;
|
|
124
138
|
forwarderType: ForwarderType;
|
|
125
139
|
enabled: boolean;
|
|
126
140
|
filter: Record<string, unknown> | null;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Engine used to evaluate {@link transform}. Paired 1:1 with
|
|
143
|
+
* `transform` — both set, or both `null`.
|
|
144
|
+
*/
|
|
145
|
+
transformType: TransformType | null;
|
|
146
|
+
/**
|
|
147
|
+
* Template applied to each event before delivery. Shape depends on
|
|
148
|
+
* {@link transformType}; for `JSONATA`, a string containing a JSONata
|
|
149
|
+
* expression. `null` when no transform is configured.
|
|
150
|
+
*/
|
|
151
|
+
transform: unknown | null;
|
|
152
|
+
/**
|
|
153
|
+
* Transport-specific delivery configuration. Header values are
|
|
154
|
+
* returned redacted on reads.
|
|
155
|
+
*/
|
|
156
|
+
configuration: HttpConfiguration;
|
|
130
157
|
createdAt: string | null;
|
|
131
158
|
updatedAt: string | null;
|
|
132
159
|
deletedAt: string | null;
|
|
@@ -135,10 +162,13 @@ interface Forwarder {
|
|
|
135
162
|
interface CreateForwarderInput {
|
|
136
163
|
name: string;
|
|
137
164
|
forwarderType: ForwarderType;
|
|
138
|
-
|
|
165
|
+
configuration: HttpConfiguration;
|
|
139
166
|
enabled?: boolean;
|
|
167
|
+
description?: string;
|
|
140
168
|
filter?: Record<string, unknown>;
|
|
141
|
-
transform
|
|
169
|
+
/** Required when {@link transform} is set; today must be `"JSONATA"`. */
|
|
170
|
+
transformType?: TransformType;
|
|
171
|
+
transform?: unknown;
|
|
142
172
|
}
|
|
143
173
|
interface UpdateForwarderInput extends CreateForwarderInput {
|
|
144
174
|
}
|
|
@@ -2632,22 +2662,20 @@ declare enum LogLevel {
|
|
|
2632
2662
|
SILENT = "SILENT"
|
|
2633
2663
|
}
|
|
2634
2664
|
/**
|
|
2635
|
-
* Describes a logger
|
|
2665
|
+
* Describes a logger effective-level change. Frozen — fields cannot be
|
|
2636
2666
|
* mutated after construction so a listener cannot affect later listeners.
|
|
2637
2667
|
*
|
|
2638
|
-
*
|
|
2639
|
-
*
|
|
2668
|
+
* One instance per logger whose effective level moved; emitted in lockstep
|
|
2669
|
+
* with the matching `adapter.applyLevel(...)` call.
|
|
2640
2670
|
*/
|
|
2641
2671
|
declare class LoggerChangeEvent {
|
|
2642
2672
|
readonly id: string;
|
|
2643
2673
|
readonly source: string;
|
|
2644
|
-
readonly level
|
|
2645
|
-
readonly deleted?: true;
|
|
2674
|
+
readonly level: LogLevel;
|
|
2646
2675
|
constructor(fields: {
|
|
2647
2676
|
id: string;
|
|
2648
2677
|
source: string;
|
|
2649
|
-
level
|
|
2650
|
-
deleted?: true;
|
|
2678
|
+
level: LogLevel;
|
|
2651
2679
|
});
|
|
2652
2680
|
}
|
|
2653
2681
|
/**
|
|
@@ -3446,15 +3474,17 @@ declare class LoggingClient {
|
|
|
3446
3474
|
/**
|
|
3447
3475
|
* Refresh resolved levels and apply them to adapter-known loggers.
|
|
3448
3476
|
*
|
|
3449
|
-
*
|
|
3450
|
-
*
|
|
3451
|
-
*
|
|
3452
|
-
*
|
|
3477
|
+
* Walks every adapter-known logger name through {@link resolveLevel}
|
|
3478
|
+
* (env override → base → group chain → dot-notation ancestry → fallback)
|
|
3479
|
+
* and pushes the result to every registered adapter. Loggers whose own
|
|
3480
|
+
* `level` is `null` are still applied — that's the whole point of group
|
|
3481
|
+
* inheritance and dot-notation ancestry.
|
|
3453
3482
|
*
|
|
3454
|
-
* The
|
|
3455
|
-
*
|
|
3456
|
-
*
|
|
3457
|
-
*
|
|
3483
|
+
* The resolved-level snapshot lives in `_resolvedLevelStore` so callers
|
|
3484
|
+
* can diff pre-vs-post and fire change listeners on actual effective-
|
|
3485
|
+
* level deltas. The store is scoped to adapter-known names: listener
|
|
3486
|
+
* fanout pairs 1:1 with `adapter.applyLevel` calls, so a logger that
|
|
3487
|
+
* the adapter doesn't know about has no apply and no listener fire.
|
|
3458
3488
|
* @internal
|
|
3459
3489
|
*/
|
|
3460
3490
|
private _applyLevels;
|
|
@@ -3475,19 +3505,25 @@ declare class LoggingClient {
|
|
|
3475
3505
|
private _handleGroupChanged;
|
|
3476
3506
|
private _handleGroupDeleted;
|
|
3477
3507
|
/**
|
|
3478
|
-
* @internal Fire change listeners for every logger whose
|
|
3479
|
-
* changed between `pre` and `post`.
|
|
3480
|
-
*
|
|
3481
|
-
*
|
|
3508
|
+
* @internal Fire change listeners for every logger whose effective level
|
|
3509
|
+
* changed between `pre` and `post`.
|
|
3510
|
+
*
|
|
3511
|
+
* Contract:
|
|
3512
|
+
* - Iterates loggers present in `post` (the post-apply resolved store).
|
|
3513
|
+
* A key in `pre` but not in `post` is a cache eviction — that key
|
|
3514
|
+
* itself fires nothing. Dependents that re-resolved to a new value
|
|
3515
|
+
* are still in `post` and fire normally.
|
|
3516
|
+
* - For every changed logger, fires every global listener once with
|
|
3517
|
+
* that logger's own payload (no "summary" event), then fires every
|
|
3518
|
+
* key-scoped listener registered for that id.
|
|
3519
|
+
* - One adapter.applyLevel call ↔ one listener notification per
|
|
3520
|
+
* subscriber. A trigger that moves N loggers fires the global
|
|
3521
|
+
* listener N times, not once.
|
|
3522
|
+
* - `suppressIds` is the deletion-event escape hatch: a deleted id
|
|
3523
|
+
* fires nothing for itself even when its adapter-known resolved
|
|
3524
|
+
* level moved (e.g. fell back to INFO).
|
|
3482
3525
|
*/
|
|
3483
3526
|
private _fireDeltas;
|
|
3484
|
-
/**
|
|
3485
|
-
* @internal Always emit a deleted event for `id` on global and per-key
|
|
3486
|
-
* listeners. Used by `logger_deleted` / `group_deleted` handlers to
|
|
3487
|
-
* preserve the explicit notification contract even when nothing in the
|
|
3488
|
-
* resolved-level store changed (e.g. server removed an unknown logger).
|
|
3489
|
-
*/
|
|
3490
|
-
private _emitDeletedEvent;
|
|
3491
3527
|
private _handleLoggersChanged;
|
|
3492
3528
|
/**
|
|
3493
3529
|
* Full refetch of loggers + log_groups, rebuild the caches, re-resolve
|
package/dist/index.d.ts
CHANGED
|
@@ -106,27 +106,54 @@ interface HttpHeader {
|
|
|
106
106
|
* {@link FORWARDER_TYPES} for callers that need to iterate.
|
|
107
107
|
*/
|
|
108
108
|
type ForwarderType = "HTTP" | "DATADOG" | "SPLUNK_HEC" | "SUMO_LOGIC" | "NEW_RELIC" | "HONEYCOMB" | "ELASTIC";
|
|
109
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Transport-specific delivery configuration. Today every destination
|
|
111
|
+
* type uses HTTP; future transports (FTP, SQS, ...) will join this as
|
|
112
|
+
* members of a discriminated union under {@link Forwarder.configuration}.
|
|
113
|
+
*/
|
|
114
|
+
interface HttpConfiguration {
|
|
115
|
+
/** HTTP method: GET, POST, PUT, PATCH, or DELETE. */
|
|
110
116
|
method: string;
|
|
117
|
+
/** Destination URL. */
|
|
111
118
|
url: string;
|
|
119
|
+
/** HTTP headers attached to each delivery request. */
|
|
112
120
|
headers: HttpHeader[];
|
|
113
|
-
body: string | null;
|
|
114
121
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
122
|
+
* Either an exact HTTP code (e.g. `"200"`, `"204"`) or a status class
|
|
123
|
+
* (`"1xx"`, `"2xx"`, `"3xx"`, `"4xx"`, `"5xx"`).
|
|
117
124
|
*/
|
|
118
125
|
successStatus: string;
|
|
119
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Engine used to evaluate {@link Forwarder.transform}. Must be set
|
|
129
|
+
* whenever `transform` is set. Today only `JSONATA` is supported.
|
|
130
|
+
*/
|
|
131
|
+
type TransformType = "JSONATA";
|
|
120
132
|
interface Forwarder {
|
|
133
|
+
/** UUID assigned by the server at creation time. */
|
|
121
134
|
id: string;
|
|
122
135
|
name: string;
|
|
123
|
-
|
|
136
|
+
/** Free-text description for the forwarder. */
|
|
137
|
+
description: string | null;
|
|
124
138
|
forwarderType: ForwarderType;
|
|
125
139
|
enabled: boolean;
|
|
126
140
|
filter: Record<string, unknown> | null;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Engine used to evaluate {@link transform}. Paired 1:1 with
|
|
143
|
+
* `transform` — both set, or both `null`.
|
|
144
|
+
*/
|
|
145
|
+
transformType: TransformType | null;
|
|
146
|
+
/**
|
|
147
|
+
* Template applied to each event before delivery. Shape depends on
|
|
148
|
+
* {@link transformType}; for `JSONATA`, a string containing a JSONata
|
|
149
|
+
* expression. `null` when no transform is configured.
|
|
150
|
+
*/
|
|
151
|
+
transform: unknown | null;
|
|
152
|
+
/**
|
|
153
|
+
* Transport-specific delivery configuration. Header values are
|
|
154
|
+
* returned redacted on reads.
|
|
155
|
+
*/
|
|
156
|
+
configuration: HttpConfiguration;
|
|
130
157
|
createdAt: string | null;
|
|
131
158
|
updatedAt: string | null;
|
|
132
159
|
deletedAt: string | null;
|
|
@@ -135,10 +162,13 @@ interface Forwarder {
|
|
|
135
162
|
interface CreateForwarderInput {
|
|
136
163
|
name: string;
|
|
137
164
|
forwarderType: ForwarderType;
|
|
138
|
-
|
|
165
|
+
configuration: HttpConfiguration;
|
|
139
166
|
enabled?: boolean;
|
|
167
|
+
description?: string;
|
|
140
168
|
filter?: Record<string, unknown>;
|
|
141
|
-
transform
|
|
169
|
+
/** Required when {@link transform} is set; today must be `"JSONATA"`. */
|
|
170
|
+
transformType?: TransformType;
|
|
171
|
+
transform?: unknown;
|
|
142
172
|
}
|
|
143
173
|
interface UpdateForwarderInput extends CreateForwarderInput {
|
|
144
174
|
}
|
|
@@ -2632,22 +2662,20 @@ declare enum LogLevel {
|
|
|
2632
2662
|
SILENT = "SILENT"
|
|
2633
2663
|
}
|
|
2634
2664
|
/**
|
|
2635
|
-
* Describes a logger
|
|
2665
|
+
* Describes a logger effective-level change. Frozen — fields cannot be
|
|
2636
2666
|
* mutated after construction so a listener cannot affect later listeners.
|
|
2637
2667
|
*
|
|
2638
|
-
*
|
|
2639
|
-
*
|
|
2668
|
+
* One instance per logger whose effective level moved; emitted in lockstep
|
|
2669
|
+
* with the matching `adapter.applyLevel(...)` call.
|
|
2640
2670
|
*/
|
|
2641
2671
|
declare class LoggerChangeEvent {
|
|
2642
2672
|
readonly id: string;
|
|
2643
2673
|
readonly source: string;
|
|
2644
|
-
readonly level
|
|
2645
|
-
readonly deleted?: true;
|
|
2674
|
+
readonly level: LogLevel;
|
|
2646
2675
|
constructor(fields: {
|
|
2647
2676
|
id: string;
|
|
2648
2677
|
source: string;
|
|
2649
|
-
level
|
|
2650
|
-
deleted?: true;
|
|
2678
|
+
level: LogLevel;
|
|
2651
2679
|
});
|
|
2652
2680
|
}
|
|
2653
2681
|
/**
|
|
@@ -3446,15 +3474,17 @@ declare class LoggingClient {
|
|
|
3446
3474
|
/**
|
|
3447
3475
|
* Refresh resolved levels and apply them to adapter-known loggers.
|
|
3448
3476
|
*
|
|
3449
|
-
*
|
|
3450
|
-
*
|
|
3451
|
-
*
|
|
3452
|
-
*
|
|
3477
|
+
* Walks every adapter-known logger name through {@link resolveLevel}
|
|
3478
|
+
* (env override → base → group chain → dot-notation ancestry → fallback)
|
|
3479
|
+
* and pushes the result to every registered adapter. Loggers whose own
|
|
3480
|
+
* `level` is `null` are still applied — that's the whole point of group
|
|
3481
|
+
* inheritance and dot-notation ancestry.
|
|
3453
3482
|
*
|
|
3454
|
-
* The
|
|
3455
|
-
*
|
|
3456
|
-
*
|
|
3457
|
-
*
|
|
3483
|
+
* The resolved-level snapshot lives in `_resolvedLevelStore` so callers
|
|
3484
|
+
* can diff pre-vs-post and fire change listeners on actual effective-
|
|
3485
|
+
* level deltas. The store is scoped to adapter-known names: listener
|
|
3486
|
+
* fanout pairs 1:1 with `adapter.applyLevel` calls, so a logger that
|
|
3487
|
+
* the adapter doesn't know about has no apply and no listener fire.
|
|
3458
3488
|
* @internal
|
|
3459
3489
|
*/
|
|
3460
3490
|
private _applyLevels;
|
|
@@ -3475,19 +3505,25 @@ declare class LoggingClient {
|
|
|
3475
3505
|
private _handleGroupChanged;
|
|
3476
3506
|
private _handleGroupDeleted;
|
|
3477
3507
|
/**
|
|
3478
|
-
* @internal Fire change listeners for every logger whose
|
|
3479
|
-
* changed between `pre` and `post`.
|
|
3480
|
-
*
|
|
3481
|
-
*
|
|
3508
|
+
* @internal Fire change listeners for every logger whose effective level
|
|
3509
|
+
* changed between `pre` and `post`.
|
|
3510
|
+
*
|
|
3511
|
+
* Contract:
|
|
3512
|
+
* - Iterates loggers present in `post` (the post-apply resolved store).
|
|
3513
|
+
* A key in `pre` but not in `post` is a cache eviction — that key
|
|
3514
|
+
* itself fires nothing. Dependents that re-resolved to a new value
|
|
3515
|
+
* are still in `post` and fire normally.
|
|
3516
|
+
* - For every changed logger, fires every global listener once with
|
|
3517
|
+
* that logger's own payload (no "summary" event), then fires every
|
|
3518
|
+
* key-scoped listener registered for that id.
|
|
3519
|
+
* - One adapter.applyLevel call ↔ one listener notification per
|
|
3520
|
+
* subscriber. A trigger that moves N loggers fires the global
|
|
3521
|
+
* listener N times, not once.
|
|
3522
|
+
* - `suppressIds` is the deletion-event escape hatch: a deleted id
|
|
3523
|
+
* fires nothing for itself even when its adapter-known resolved
|
|
3524
|
+
* level moved (e.g. fell back to INFO).
|
|
3482
3525
|
*/
|
|
3483
3526
|
private _fireDeltas;
|
|
3484
|
-
/**
|
|
3485
|
-
* @internal Always emit a deleted event for `id` on global and per-key
|
|
3486
|
-
* listeners. Used by `logger_deleted` / `group_deleted` handlers to
|
|
3487
|
-
* preserve the explicit notification contract even when nothing in the
|
|
3488
|
-
* resolved-level store changed (e.g. server removed an unknown logger).
|
|
3489
|
-
*/
|
|
3490
|
-
private _emitDeletedEvent;
|
|
3491
3527
|
private _handleLoggersChanged;
|
|
3492
3528
|
/**
|
|
3493
3529
|
* Full refetch of loggers + log_groups, rebuild the caches, re-resolve
|
package/dist/index.js
CHANGED
|
@@ -19221,12 +19221,10 @@ var LoggerChangeEvent = class {
|
|
|
19221
19221
|
id;
|
|
19222
19222
|
source;
|
|
19223
19223
|
level;
|
|
19224
|
-
deleted;
|
|
19225
19224
|
constructor(fields) {
|
|
19226
19225
|
this.id = fields.id;
|
|
19227
19226
|
this.source = fields.source;
|
|
19228
|
-
|
|
19229
|
-
if (fields.deleted) this.deleted = fields.deleted;
|
|
19227
|
+
this.level = fields.level;
|
|
19230
19228
|
Object.freeze(this);
|
|
19231
19229
|
}
|
|
19232
19230
|
};
|
|
@@ -19868,16 +19866,15 @@ function _paginationFromBody2(body) {
|
|
|
19868
19866
|
}
|
|
19869
19867
|
return out;
|
|
19870
19868
|
}
|
|
19871
|
-
function
|
|
19869
|
+
function _configurationToWire(config) {
|
|
19872
19870
|
return {
|
|
19873
|
-
method:
|
|
19874
|
-
url:
|
|
19875
|
-
headers:
|
|
19876
|
-
|
|
19877
|
-
success_status: http.successStatus
|
|
19871
|
+
method: config.method,
|
|
19872
|
+
url: config.url,
|
|
19873
|
+
headers: config.headers.map((h) => ({ name: h.name, value: h.value })),
|
|
19874
|
+
success_status: config.successStatus
|
|
19878
19875
|
};
|
|
19879
19876
|
}
|
|
19880
|
-
function
|
|
19877
|
+
function _configurationFromWire(raw) {
|
|
19881
19878
|
const r = raw ?? {};
|
|
19882
19879
|
const headers = (r.headers ?? []).map((h) => ({
|
|
19883
19880
|
name: String(h.name ?? ""),
|
|
@@ -19887,7 +19884,6 @@ function _httpFromWire(raw) {
|
|
|
19887
19884
|
method: String(r.method ?? "POST"),
|
|
19888
19885
|
url: String(r.url ?? ""),
|
|
19889
19886
|
headers,
|
|
19890
|
-
body: r.body ?? null,
|
|
19891
19887
|
successStatus: String(r.success_status ?? "2xx")
|
|
19892
19888
|
};
|
|
19893
19889
|
}
|
|
@@ -19896,11 +19892,13 @@ function _forwarderAttributes(input) {
|
|
|
19896
19892
|
name: input.name,
|
|
19897
19893
|
forwarder_type: input.forwarderType,
|
|
19898
19894
|
enabled: input.enabled ?? true,
|
|
19899
|
-
|
|
19895
|
+
configuration: _configurationToWire(input.configuration)
|
|
19900
19896
|
};
|
|
19897
|
+
if (input.description !== void 0) attrs.description = input.description;
|
|
19901
19898
|
if (input.filter !== void 0) {
|
|
19902
19899
|
attrs.filter = input.filter;
|
|
19903
19900
|
}
|
|
19901
|
+
if (input.transformType !== void 0) attrs.transform_type = input.transformType;
|
|
19904
19902
|
if (input.transform !== void 0) attrs.transform = input.transform;
|
|
19905
19903
|
return attrs;
|
|
19906
19904
|
}
|
|
@@ -19909,12 +19907,13 @@ function _forwarderFromResource(resource) {
|
|
|
19909
19907
|
return {
|
|
19910
19908
|
id: resource.id,
|
|
19911
19909
|
name: String(a.name ?? ""),
|
|
19912
|
-
|
|
19910
|
+
description: a.description ?? null,
|
|
19913
19911
|
forwarderType: a.forwarder_type,
|
|
19914
19912
|
enabled: Boolean(a.enabled ?? true),
|
|
19915
19913
|
filter: a.filter ?? null,
|
|
19914
|
+
transformType: a.transform_type ?? null,
|
|
19916
19915
|
transform: a.transform ?? null,
|
|
19917
|
-
|
|
19916
|
+
configuration: _configurationFromWire(a.configuration),
|
|
19918
19917
|
createdAt: a.created_at ?? null,
|
|
19919
19918
|
updatedAt: a.updated_at ?? null,
|
|
19920
19919
|
deletedAt: a.deleted_at ?? null,
|
|
@@ -22150,27 +22149,24 @@ var LoggingClient = class {
|
|
|
22150
22149
|
/**
|
|
22151
22150
|
* Refresh resolved levels and apply them to adapter-known loggers.
|
|
22152
22151
|
*
|
|
22153
|
-
*
|
|
22154
|
-
*
|
|
22155
|
-
*
|
|
22156
|
-
*
|
|
22152
|
+
* Walks every adapter-known logger name through {@link resolveLevel}
|
|
22153
|
+
* (env override → base → group chain → dot-notation ancestry → fallback)
|
|
22154
|
+
* and pushes the result to every registered adapter. Loggers whose own
|
|
22155
|
+
* `level` is `null` are still applied — that's the whole point of group
|
|
22156
|
+
* inheritance and dot-notation ancestry.
|
|
22157
22157
|
*
|
|
22158
|
-
* The
|
|
22159
|
-
*
|
|
22160
|
-
*
|
|
22161
|
-
*
|
|
22158
|
+
* The resolved-level snapshot lives in `_resolvedLevelStore` so callers
|
|
22159
|
+
* can diff pre-vs-post and fire change listeners on actual effective-
|
|
22160
|
+
* level deltas. The store is scoped to adapter-known names: listener
|
|
22161
|
+
* fanout pairs 1:1 with `adapter.applyLevel` calls, so a logger that
|
|
22162
|
+
* the adapter doesn't know about has no apply and no listener fire.
|
|
22162
22163
|
* @internal
|
|
22163
22164
|
*/
|
|
22164
22165
|
_applyLevels() {
|
|
22165
22166
|
const environment = this._parent?._environment ?? "";
|
|
22166
22167
|
const newResolved = {};
|
|
22167
|
-
for (const id of Object.keys(this._loggersCache)) {
|
|
22168
|
-
newResolved[id] = resolveLevel(id, environment, this._loggersCache, this._groupsCache);
|
|
22169
|
-
}
|
|
22170
22168
|
for (const name of this._knownLoggerNames) {
|
|
22171
|
-
|
|
22172
|
-
newResolved[name] = resolveLevel(name, environment, this._loggersCache, this._groupsCache);
|
|
22173
|
-
}
|
|
22169
|
+
newResolved[name] = resolveLevel(name, environment, this._loggersCache, this._groupsCache);
|
|
22174
22170
|
}
|
|
22175
22171
|
this._resolvedLevelStore = newResolved;
|
|
22176
22172
|
for (const name of this._knownLoggerNames) {
|
|
@@ -22303,7 +22299,6 @@ var LoggingClient = class {
|
|
|
22303
22299
|
delete this._loggersCache[id];
|
|
22304
22300
|
const preResolved = { ...this._resolvedLevelStore };
|
|
22305
22301
|
this._applyLevels();
|
|
22306
|
-
this._emitDeletedEvent(id, "websocket");
|
|
22307
22302
|
this._fireDeltas(preResolved, this._resolvedLevelStore, "websocket", /* @__PURE__ */ new Set([id]));
|
|
22308
22303
|
};
|
|
22309
22304
|
_handleGroupChanged = (data) => {
|
|
@@ -22333,45 +22328,41 @@ var LoggingClient = class {
|
|
|
22333
22328
|
delete this._groupsCache[id];
|
|
22334
22329
|
const preResolved = { ...this._resolvedLevelStore };
|
|
22335
22330
|
this._applyLevels();
|
|
22336
|
-
this._emitDeletedEvent(id, "websocket");
|
|
22337
22331
|
this._fireDeltas(preResolved, this._resolvedLevelStore, "websocket", /* @__PURE__ */ new Set([id]));
|
|
22338
22332
|
};
|
|
22339
22333
|
/**
|
|
22340
|
-
* @internal Fire change listeners for every logger whose
|
|
22341
|
-
* changed between `pre` and `post`.
|
|
22342
|
-
*
|
|
22343
|
-
*
|
|
22334
|
+
* @internal Fire change listeners for every logger whose effective level
|
|
22335
|
+
* changed between `pre` and `post`.
|
|
22336
|
+
*
|
|
22337
|
+
* Contract:
|
|
22338
|
+
* - Iterates loggers present in `post` (the post-apply resolved store).
|
|
22339
|
+
* A key in `pre` but not in `post` is a cache eviction — that key
|
|
22340
|
+
* itself fires nothing. Dependents that re-resolved to a new value
|
|
22341
|
+
* are still in `post` and fire normally.
|
|
22342
|
+
* - For every changed logger, fires every global listener once with
|
|
22343
|
+
* that logger's own payload (no "summary" event), then fires every
|
|
22344
|
+
* key-scoped listener registered for that id.
|
|
22345
|
+
* - One adapter.applyLevel call ↔ one listener notification per
|
|
22346
|
+
* subscriber. A trigger that moves N loggers fires the global
|
|
22347
|
+
* listener N times, not once.
|
|
22348
|
+
* - `suppressIds` is the deletion-event escape hatch: a deleted id
|
|
22349
|
+
* fires nothing for itself even when its adapter-known resolved
|
|
22350
|
+
* level moved (e.g. fell back to INFO).
|
|
22344
22351
|
*/
|
|
22345
|
-
_fireDeltas(pre, post, source,
|
|
22346
|
-
const
|
|
22347
|
-
|
|
22348
|
-
|
|
22349
|
-
if (
|
|
22350
|
-
|
|
22351
|
-
|
|
22352
|
-
|
|
22353
|
-
|
|
22354
|
-
|
|
22355
|
-
|
|
22356
|
-
id,
|
|
22357
|
-
source,
|
|
22358
|
-
level: post[id] ?? null
|
|
22359
|
-
};
|
|
22360
|
-
if (isDeletion) fields.deleted = true;
|
|
22361
|
-
return new LoggerChangeEvent(fields);
|
|
22362
|
-
};
|
|
22363
|
-
const firstKey = changed[0];
|
|
22364
|
-
const globalEvent = buildEvent(firstKey);
|
|
22365
|
-
for (const cb of this._globalListeners) {
|
|
22366
|
-
try {
|
|
22367
|
-
cb(globalEvent);
|
|
22368
|
-
} catch {
|
|
22352
|
+
_fireDeltas(pre, post, source, suppressIds) {
|
|
22353
|
+
for (const id of Object.keys(post)) {
|
|
22354
|
+
if (suppressIds?.has(id)) continue;
|
|
22355
|
+
const next = post[id];
|
|
22356
|
+
if (pre[id] === next) continue;
|
|
22357
|
+
const event = new LoggerChangeEvent({ id, source, level: next });
|
|
22358
|
+
for (const cb of this._globalListeners) {
|
|
22359
|
+
try {
|
|
22360
|
+
cb(event);
|
|
22361
|
+
} catch {
|
|
22362
|
+
}
|
|
22369
22363
|
}
|
|
22370
|
-
|
|
22371
|
-
for (const k of changed) {
|
|
22372
|
-
const keyCallbacks = this._keyListeners.get(k);
|
|
22364
|
+
const keyCallbacks = this._keyListeners.get(id);
|
|
22373
22365
|
if (keyCallbacks) {
|
|
22374
|
-
const event = buildEvent(k);
|
|
22375
22366
|
for (const cb of keyCallbacks) {
|
|
22376
22367
|
try {
|
|
22377
22368
|
cb(event);
|
|
@@ -22381,43 +22372,6 @@ var LoggingClient = class {
|
|
|
22381
22372
|
}
|
|
22382
22373
|
}
|
|
22383
22374
|
}
|
|
22384
|
-
/**
|
|
22385
|
-
* @internal Always emit a deleted event for `id` on global and per-key
|
|
22386
|
-
* listeners. Used by `logger_deleted` / `group_deleted` handlers to
|
|
22387
|
-
* preserve the explicit notification contract even when nothing in the
|
|
22388
|
-
* resolved-level store changed (e.g. server removed an unknown logger).
|
|
22389
|
-
*/
|
|
22390
|
-
_emitDeletedEvent(id, source) {
|
|
22391
|
-
const event = new LoggerChangeEvent({
|
|
22392
|
-
id,
|
|
22393
|
-
level: null,
|
|
22394
|
-
source,
|
|
22395
|
-
deleted: true
|
|
22396
|
-
});
|
|
22397
|
-
for (const cb of this._globalListeners) {
|
|
22398
|
-
try {
|
|
22399
|
-
cb(event);
|
|
22400
|
-
} catch (err) {
|
|
22401
|
-
debug(
|
|
22402
|
-
"websocket",
|
|
22403
|
-
`deleted listener error: ${err instanceof Error ? err.message : String(err)}`
|
|
22404
|
-
);
|
|
22405
|
-
}
|
|
22406
|
-
}
|
|
22407
|
-
const idCallbacks = this._keyListeners.get(id);
|
|
22408
|
-
if (idCallbacks) {
|
|
22409
|
-
for (const cb of idCallbacks) {
|
|
22410
|
-
try {
|
|
22411
|
-
cb(event);
|
|
22412
|
-
} catch (err) {
|
|
22413
|
-
debug(
|
|
22414
|
-
"websocket",
|
|
22415
|
-
`deleted key listener error: ${err instanceof Error ? err.message : String(err)}`
|
|
22416
|
-
);
|
|
22417
|
-
}
|
|
22418
|
-
}
|
|
22419
|
-
}
|
|
22420
|
-
}
|
|
22421
22375
|
_handleLoggersChanged = (_data) => {
|
|
22422
22376
|
debug("websocket", `loggers_changed event received`);
|
|
22423
22377
|
void this._resolveAndFire("websocket").catch(() => {
|