@smplkit/sdk 1.5.1 → 1.5.3
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/README.md +10 -0
- package/dist/index.cjs +191 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +191 -111
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3979,11 +3979,11 @@ var require_stream_readable = __commonJS({
|
|
|
3979
3979
|
return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
3980
3980
|
}
|
|
3981
3981
|
var debugUtil = require("util");
|
|
3982
|
-
var
|
|
3982
|
+
var debug2;
|
|
3983
3983
|
if (debugUtil && debugUtil.debuglog) {
|
|
3984
|
-
|
|
3984
|
+
debug2 = debugUtil.debuglog("stream");
|
|
3985
3985
|
} else {
|
|
3986
|
-
|
|
3986
|
+
debug2 = function debug3() {
|
|
3987
3987
|
};
|
|
3988
3988
|
}
|
|
3989
3989
|
var BufferList = require_buffer_list();
|
|
@@ -4098,7 +4098,7 @@ var require_stream_readable = __commonJS({
|
|
|
4098
4098
|
return readableAddChunk(this, chunk, null, true, false);
|
|
4099
4099
|
};
|
|
4100
4100
|
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
4101
|
-
|
|
4101
|
+
debug2("readableAddChunk", chunk);
|
|
4102
4102
|
var state = stream._readableState;
|
|
4103
4103
|
if (chunk === null) {
|
|
4104
4104
|
state.reading = false;
|
|
@@ -4205,13 +4205,13 @@ var require_stream_readable = __commonJS({
|
|
|
4205
4205
|
return state.length;
|
|
4206
4206
|
}
|
|
4207
4207
|
Readable.prototype.read = function(n) {
|
|
4208
|
-
|
|
4208
|
+
debug2("read", n);
|
|
4209
4209
|
n = parseInt(n, 10);
|
|
4210
4210
|
var state = this._readableState;
|
|
4211
4211
|
var nOrig = n;
|
|
4212
4212
|
if (n !== 0) state.emittedReadable = false;
|
|
4213
4213
|
if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
|
|
4214
|
-
|
|
4214
|
+
debug2("read: emitReadable", state.length, state.ended);
|
|
4215
4215
|
if (state.length === 0 && state.ended) endReadable(this);
|
|
4216
4216
|
else emitReadable(this);
|
|
4217
4217
|
return null;
|
|
@@ -4222,16 +4222,16 @@ var require_stream_readable = __commonJS({
|
|
|
4222
4222
|
return null;
|
|
4223
4223
|
}
|
|
4224
4224
|
var doRead = state.needReadable;
|
|
4225
|
-
|
|
4225
|
+
debug2("need readable", doRead);
|
|
4226
4226
|
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
4227
4227
|
doRead = true;
|
|
4228
|
-
|
|
4228
|
+
debug2("length less than watermark", doRead);
|
|
4229
4229
|
}
|
|
4230
4230
|
if (state.ended || state.reading) {
|
|
4231
4231
|
doRead = false;
|
|
4232
|
-
|
|
4232
|
+
debug2("reading or ended", doRead);
|
|
4233
4233
|
} else if (doRead) {
|
|
4234
|
-
|
|
4234
|
+
debug2("do read");
|
|
4235
4235
|
state.reading = true;
|
|
4236
4236
|
state.sync = true;
|
|
4237
4237
|
if (state.length === 0) state.needReadable = true;
|
|
@@ -4257,7 +4257,7 @@ var require_stream_readable = __commonJS({
|
|
|
4257
4257
|
return ret;
|
|
4258
4258
|
};
|
|
4259
4259
|
function onEofChunk(stream, state) {
|
|
4260
|
-
|
|
4260
|
+
debug2("onEofChunk");
|
|
4261
4261
|
if (state.ended) return;
|
|
4262
4262
|
if (state.decoder) {
|
|
4263
4263
|
var chunk = state.decoder.end();
|
|
@@ -4279,17 +4279,17 @@ var require_stream_readable = __commonJS({
|
|
|
4279
4279
|
}
|
|
4280
4280
|
function emitReadable(stream) {
|
|
4281
4281
|
var state = stream._readableState;
|
|
4282
|
-
|
|
4282
|
+
debug2("emitReadable", state.needReadable, state.emittedReadable);
|
|
4283
4283
|
state.needReadable = false;
|
|
4284
4284
|
if (!state.emittedReadable) {
|
|
4285
|
-
|
|
4285
|
+
debug2("emitReadable", state.flowing);
|
|
4286
4286
|
state.emittedReadable = true;
|
|
4287
4287
|
process.nextTick(emitReadable_, stream);
|
|
4288
4288
|
}
|
|
4289
4289
|
}
|
|
4290
4290
|
function emitReadable_(stream) {
|
|
4291
4291
|
var state = stream._readableState;
|
|
4292
|
-
|
|
4292
|
+
debug2("emitReadable_", state.destroyed, state.length, state.ended);
|
|
4293
4293
|
if (!state.destroyed && (state.length || state.ended)) {
|
|
4294
4294
|
stream.emit("readable");
|
|
4295
4295
|
state.emittedReadable = false;
|
|
@@ -4306,7 +4306,7 @@ var require_stream_readable = __commonJS({
|
|
|
4306
4306
|
function maybeReadMore_(stream, state) {
|
|
4307
4307
|
while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
|
|
4308
4308
|
var len = state.length;
|
|
4309
|
-
|
|
4309
|
+
debug2("maybeReadMore read 0");
|
|
4310
4310
|
stream.read(0);
|
|
4311
4311
|
if (len === state.length)
|
|
4312
4312
|
break;
|
|
@@ -4331,14 +4331,14 @@ var require_stream_readable = __commonJS({
|
|
|
4331
4331
|
break;
|
|
4332
4332
|
}
|
|
4333
4333
|
state.pipesCount += 1;
|
|
4334
|
-
|
|
4334
|
+
debug2("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
|
|
4335
4335
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
4336
4336
|
var endFn = doEnd ? onend : unpipe;
|
|
4337
4337
|
if (state.endEmitted) process.nextTick(endFn);
|
|
4338
4338
|
else src.once("end", endFn);
|
|
4339
4339
|
dest.on("unpipe", onunpipe);
|
|
4340
4340
|
function onunpipe(readable, unpipeInfo) {
|
|
4341
|
-
|
|
4341
|
+
debug2("onunpipe");
|
|
4342
4342
|
if (readable === src) {
|
|
4343
4343
|
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
4344
4344
|
unpipeInfo.hasUnpiped = true;
|
|
@@ -4347,14 +4347,14 @@ var require_stream_readable = __commonJS({
|
|
|
4347
4347
|
}
|
|
4348
4348
|
}
|
|
4349
4349
|
function onend() {
|
|
4350
|
-
|
|
4350
|
+
debug2("onend");
|
|
4351
4351
|
dest.end();
|
|
4352
4352
|
}
|
|
4353
4353
|
var ondrain = pipeOnDrain(src);
|
|
4354
4354
|
dest.on("drain", ondrain);
|
|
4355
4355
|
var cleanedUp = false;
|
|
4356
4356
|
function cleanup() {
|
|
4357
|
-
|
|
4357
|
+
debug2("cleanup");
|
|
4358
4358
|
dest.removeListener("close", onclose);
|
|
4359
4359
|
dest.removeListener("finish", onfinish);
|
|
4360
4360
|
dest.removeListener("drain", ondrain);
|
|
@@ -4368,19 +4368,19 @@ var require_stream_readable = __commonJS({
|
|
|
4368
4368
|
}
|
|
4369
4369
|
src.on("data", ondata);
|
|
4370
4370
|
function ondata(chunk) {
|
|
4371
|
-
|
|
4371
|
+
debug2("ondata");
|
|
4372
4372
|
var ret = dest.write(chunk);
|
|
4373
|
-
|
|
4373
|
+
debug2("dest.write", ret);
|
|
4374
4374
|
if (ret === false) {
|
|
4375
4375
|
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
4376
|
-
|
|
4376
|
+
debug2("false write response, pause", state.awaitDrain);
|
|
4377
4377
|
state.awaitDrain++;
|
|
4378
4378
|
}
|
|
4379
4379
|
src.pause();
|
|
4380
4380
|
}
|
|
4381
4381
|
}
|
|
4382
4382
|
function onerror(er) {
|
|
4383
|
-
|
|
4383
|
+
debug2("onerror", er);
|
|
4384
4384
|
unpipe();
|
|
4385
4385
|
dest.removeListener("error", onerror);
|
|
4386
4386
|
if (EElistenerCount(dest, "error") === 0) errorOrDestroy(dest, er);
|
|
@@ -4392,18 +4392,18 @@ var require_stream_readable = __commonJS({
|
|
|
4392
4392
|
}
|
|
4393
4393
|
dest.once("close", onclose);
|
|
4394
4394
|
function onfinish() {
|
|
4395
|
-
|
|
4395
|
+
debug2("onfinish");
|
|
4396
4396
|
dest.removeListener("close", onclose);
|
|
4397
4397
|
unpipe();
|
|
4398
4398
|
}
|
|
4399
4399
|
dest.once("finish", onfinish);
|
|
4400
4400
|
function unpipe() {
|
|
4401
|
-
|
|
4401
|
+
debug2("unpipe");
|
|
4402
4402
|
src.unpipe(dest);
|
|
4403
4403
|
}
|
|
4404
4404
|
dest.emit("pipe", src);
|
|
4405
4405
|
if (!state.flowing) {
|
|
4406
|
-
|
|
4406
|
+
debug2("pipe resume");
|
|
4407
4407
|
src.resume();
|
|
4408
4408
|
}
|
|
4409
4409
|
return dest;
|
|
@@ -4411,7 +4411,7 @@ var require_stream_readable = __commonJS({
|
|
|
4411
4411
|
function pipeOnDrain(src) {
|
|
4412
4412
|
return function pipeOnDrainFunctionResult() {
|
|
4413
4413
|
var state = src._readableState;
|
|
4414
|
-
|
|
4414
|
+
debug2("pipeOnDrain", state.awaitDrain);
|
|
4415
4415
|
if (state.awaitDrain) state.awaitDrain--;
|
|
4416
4416
|
if (state.awaitDrain === 0 && EElistenerCount(src, "data")) {
|
|
4417
4417
|
state.flowing = true;
|
|
@@ -4464,7 +4464,7 @@ var require_stream_readable = __commonJS({
|
|
|
4464
4464
|
state.readableListening = state.needReadable = true;
|
|
4465
4465
|
state.flowing = false;
|
|
4466
4466
|
state.emittedReadable = false;
|
|
4467
|
-
|
|
4467
|
+
debug2("on readable", state.length, state.reading);
|
|
4468
4468
|
if (state.length) {
|
|
4469
4469
|
emitReadable(this);
|
|
4470
4470
|
} else if (!state.reading) {
|
|
@@ -4499,13 +4499,13 @@ var require_stream_readable = __commonJS({
|
|
|
4499
4499
|
}
|
|
4500
4500
|
}
|
|
4501
4501
|
function nReadingNextTick(self2) {
|
|
4502
|
-
|
|
4502
|
+
debug2("readable nexttick read 0");
|
|
4503
4503
|
self2.read(0);
|
|
4504
4504
|
}
|
|
4505
4505
|
Readable.prototype.resume = function() {
|
|
4506
4506
|
var state = this._readableState;
|
|
4507
4507
|
if (!state.flowing) {
|
|
4508
|
-
|
|
4508
|
+
debug2("resume");
|
|
4509
4509
|
state.flowing = !state.readableListening;
|
|
4510
4510
|
resume(this, state);
|
|
4511
4511
|
}
|
|
@@ -4519,7 +4519,7 @@ var require_stream_readable = __commonJS({
|
|
|
4519
4519
|
}
|
|
4520
4520
|
}
|
|
4521
4521
|
function resume_(stream, state) {
|
|
4522
|
-
|
|
4522
|
+
debug2("resume", state.reading);
|
|
4523
4523
|
if (!state.reading) {
|
|
4524
4524
|
stream.read(0);
|
|
4525
4525
|
}
|
|
@@ -4529,9 +4529,9 @@ var require_stream_readable = __commonJS({
|
|
|
4529
4529
|
if (state.flowing && !state.reading) stream.read(0);
|
|
4530
4530
|
}
|
|
4531
4531
|
Readable.prototype.pause = function() {
|
|
4532
|
-
|
|
4532
|
+
debug2("call pause flowing=%j", this._readableState.flowing);
|
|
4533
4533
|
if (this._readableState.flowing !== false) {
|
|
4534
|
-
|
|
4534
|
+
debug2("pause");
|
|
4535
4535
|
this._readableState.flowing = false;
|
|
4536
4536
|
this.emit("pause");
|
|
4537
4537
|
}
|
|
@@ -4540,7 +4540,7 @@ var require_stream_readable = __commonJS({
|
|
|
4540
4540
|
};
|
|
4541
4541
|
function flow(stream) {
|
|
4542
4542
|
var state = stream._readableState;
|
|
4543
|
-
|
|
4543
|
+
debug2("flow", state.flowing);
|
|
4544
4544
|
while (state.flowing && stream.read() !== null) ;
|
|
4545
4545
|
}
|
|
4546
4546
|
Readable.prototype.wrap = function(stream) {
|
|
@@ -4548,7 +4548,7 @@ var require_stream_readable = __commonJS({
|
|
|
4548
4548
|
var state = this._readableState;
|
|
4549
4549
|
var paused = false;
|
|
4550
4550
|
stream.on("end", function() {
|
|
4551
|
-
|
|
4551
|
+
debug2("wrapped end");
|
|
4552
4552
|
if (state.decoder && !state.ended) {
|
|
4553
4553
|
var chunk = state.decoder.end();
|
|
4554
4554
|
if (chunk && chunk.length) _this.push(chunk);
|
|
@@ -4556,7 +4556,7 @@ var require_stream_readable = __commonJS({
|
|
|
4556
4556
|
_this.push(null);
|
|
4557
4557
|
});
|
|
4558
4558
|
stream.on("data", function(chunk) {
|
|
4559
|
-
|
|
4559
|
+
debug2("wrapped data");
|
|
4560
4560
|
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
4561
4561
|
if (state.objectMode && (chunk === null || chunk === void 0)) return;
|
|
4562
4562
|
else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
@@ -4579,7 +4579,7 @@ var require_stream_readable = __commonJS({
|
|
|
4579
4579
|
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
4580
4580
|
}
|
|
4581
4581
|
this._read = function(n2) {
|
|
4582
|
-
|
|
4582
|
+
debug2("wrapped _read", n2);
|
|
4583
4583
|
if (paused) {
|
|
4584
4584
|
paused = false;
|
|
4585
4585
|
stream.resume();
|
|
@@ -4653,14 +4653,14 @@ var require_stream_readable = __commonJS({
|
|
|
4653
4653
|
}
|
|
4654
4654
|
function endReadable(stream) {
|
|
4655
4655
|
var state = stream._readableState;
|
|
4656
|
-
|
|
4656
|
+
debug2("endReadable", state.endEmitted);
|
|
4657
4657
|
if (!state.endEmitted) {
|
|
4658
4658
|
state.ended = true;
|
|
4659
4659
|
process.nextTick(endReadableNT, state, stream);
|
|
4660
4660
|
}
|
|
4661
4661
|
}
|
|
4662
4662
|
function endReadableNT(state, stream) {
|
|
4663
|
-
|
|
4663
|
+
debug2("endReadableNT", state.endEmitted, state.length);
|
|
4664
4664
|
if (!state.endEmitted && state.length === 0) {
|
|
4665
4665
|
state.endEmitted = true;
|
|
4666
4666
|
stream.readable = false;
|
|
@@ -7525,11 +7525,11 @@ var require_stream_readable2 = __commonJS({
|
|
|
7525
7525
|
return Buffer2.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
7526
7526
|
}
|
|
7527
7527
|
var debugUtil = require("util");
|
|
7528
|
-
var
|
|
7528
|
+
var debug2;
|
|
7529
7529
|
if (debugUtil && debugUtil.debuglog) {
|
|
7530
|
-
|
|
7530
|
+
debug2 = debugUtil.debuglog("stream");
|
|
7531
7531
|
} else {
|
|
7532
|
-
|
|
7532
|
+
debug2 = function debug3() {
|
|
7533
7533
|
};
|
|
7534
7534
|
}
|
|
7535
7535
|
var BufferList = require_buffer_list2();
|
|
@@ -7644,7 +7644,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
7644
7644
|
return readableAddChunk(this, chunk, null, true, false);
|
|
7645
7645
|
};
|
|
7646
7646
|
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
7647
|
-
|
|
7647
|
+
debug2("readableAddChunk", chunk);
|
|
7648
7648
|
var state = stream._readableState;
|
|
7649
7649
|
if (chunk === null) {
|
|
7650
7650
|
state.reading = false;
|
|
@@ -7751,13 +7751,13 @@ var require_stream_readable2 = __commonJS({
|
|
|
7751
7751
|
return state.length;
|
|
7752
7752
|
}
|
|
7753
7753
|
Readable.prototype.read = function(n) {
|
|
7754
|
-
|
|
7754
|
+
debug2("read", n);
|
|
7755
7755
|
n = parseInt(n, 10);
|
|
7756
7756
|
var state = this._readableState;
|
|
7757
7757
|
var nOrig = n;
|
|
7758
7758
|
if (n !== 0) state.emittedReadable = false;
|
|
7759
7759
|
if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) {
|
|
7760
|
-
|
|
7760
|
+
debug2("read: emitReadable", state.length, state.ended);
|
|
7761
7761
|
if (state.length === 0 && state.ended) endReadable(this);
|
|
7762
7762
|
else emitReadable(this);
|
|
7763
7763
|
return null;
|
|
@@ -7768,16 +7768,16 @@ var require_stream_readable2 = __commonJS({
|
|
|
7768
7768
|
return null;
|
|
7769
7769
|
}
|
|
7770
7770
|
var doRead = state.needReadable;
|
|
7771
|
-
|
|
7771
|
+
debug2("need readable", doRead);
|
|
7772
7772
|
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
7773
7773
|
doRead = true;
|
|
7774
|
-
|
|
7774
|
+
debug2("length less than watermark", doRead);
|
|
7775
7775
|
}
|
|
7776
7776
|
if (state.ended || state.reading) {
|
|
7777
7777
|
doRead = false;
|
|
7778
|
-
|
|
7778
|
+
debug2("reading or ended", doRead);
|
|
7779
7779
|
} else if (doRead) {
|
|
7780
|
-
|
|
7780
|
+
debug2("do read");
|
|
7781
7781
|
state.reading = true;
|
|
7782
7782
|
state.sync = true;
|
|
7783
7783
|
if (state.length === 0) state.needReadable = true;
|
|
@@ -7803,7 +7803,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
7803
7803
|
return ret;
|
|
7804
7804
|
};
|
|
7805
7805
|
function onEofChunk(stream, state) {
|
|
7806
|
-
|
|
7806
|
+
debug2("onEofChunk");
|
|
7807
7807
|
if (state.ended) return;
|
|
7808
7808
|
if (state.decoder) {
|
|
7809
7809
|
var chunk = state.decoder.end();
|
|
@@ -7825,17 +7825,17 @@ var require_stream_readable2 = __commonJS({
|
|
|
7825
7825
|
}
|
|
7826
7826
|
function emitReadable(stream) {
|
|
7827
7827
|
var state = stream._readableState;
|
|
7828
|
-
|
|
7828
|
+
debug2("emitReadable", state.needReadable, state.emittedReadable);
|
|
7829
7829
|
state.needReadable = false;
|
|
7830
7830
|
if (!state.emittedReadable) {
|
|
7831
|
-
|
|
7831
|
+
debug2("emitReadable", state.flowing);
|
|
7832
7832
|
state.emittedReadable = true;
|
|
7833
7833
|
process.nextTick(emitReadable_, stream);
|
|
7834
7834
|
}
|
|
7835
7835
|
}
|
|
7836
7836
|
function emitReadable_(stream) {
|
|
7837
7837
|
var state = stream._readableState;
|
|
7838
|
-
|
|
7838
|
+
debug2("emitReadable_", state.destroyed, state.length, state.ended);
|
|
7839
7839
|
if (!state.destroyed && (state.length || state.ended)) {
|
|
7840
7840
|
stream.emit("readable");
|
|
7841
7841
|
state.emittedReadable = false;
|
|
@@ -7852,7 +7852,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
7852
7852
|
function maybeReadMore_(stream, state) {
|
|
7853
7853
|
while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) {
|
|
7854
7854
|
var len = state.length;
|
|
7855
|
-
|
|
7855
|
+
debug2("maybeReadMore read 0");
|
|
7856
7856
|
stream.read(0);
|
|
7857
7857
|
if (len === state.length)
|
|
7858
7858
|
break;
|
|
@@ -7877,14 +7877,14 @@ var require_stream_readable2 = __commonJS({
|
|
|
7877
7877
|
break;
|
|
7878
7878
|
}
|
|
7879
7879
|
state.pipesCount += 1;
|
|
7880
|
-
|
|
7880
|
+
debug2("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
|
|
7881
7881
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
7882
7882
|
var endFn = doEnd ? onend : unpipe;
|
|
7883
7883
|
if (state.endEmitted) process.nextTick(endFn);
|
|
7884
7884
|
else src.once("end", endFn);
|
|
7885
7885
|
dest.on("unpipe", onunpipe);
|
|
7886
7886
|
function onunpipe(readable, unpipeInfo) {
|
|
7887
|
-
|
|
7887
|
+
debug2("onunpipe");
|
|
7888
7888
|
if (readable === src) {
|
|
7889
7889
|
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
7890
7890
|
unpipeInfo.hasUnpiped = true;
|
|
@@ -7893,14 +7893,14 @@ var require_stream_readable2 = __commonJS({
|
|
|
7893
7893
|
}
|
|
7894
7894
|
}
|
|
7895
7895
|
function onend() {
|
|
7896
|
-
|
|
7896
|
+
debug2("onend");
|
|
7897
7897
|
dest.end();
|
|
7898
7898
|
}
|
|
7899
7899
|
var ondrain = pipeOnDrain(src);
|
|
7900
7900
|
dest.on("drain", ondrain);
|
|
7901
7901
|
var cleanedUp = false;
|
|
7902
7902
|
function cleanup() {
|
|
7903
|
-
|
|
7903
|
+
debug2("cleanup");
|
|
7904
7904
|
dest.removeListener("close", onclose);
|
|
7905
7905
|
dest.removeListener("finish", onfinish);
|
|
7906
7906
|
dest.removeListener("drain", ondrain);
|
|
@@ -7914,19 +7914,19 @@ var require_stream_readable2 = __commonJS({
|
|
|
7914
7914
|
}
|
|
7915
7915
|
src.on("data", ondata);
|
|
7916
7916
|
function ondata(chunk) {
|
|
7917
|
-
|
|
7917
|
+
debug2("ondata");
|
|
7918
7918
|
var ret = dest.write(chunk);
|
|
7919
|
-
|
|
7919
|
+
debug2("dest.write", ret);
|
|
7920
7920
|
if (ret === false) {
|
|
7921
7921
|
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
7922
|
-
|
|
7922
|
+
debug2("false write response, pause", state.awaitDrain);
|
|
7923
7923
|
state.awaitDrain++;
|
|
7924
7924
|
}
|
|
7925
7925
|
src.pause();
|
|
7926
7926
|
}
|
|
7927
7927
|
}
|
|
7928
7928
|
function onerror(er) {
|
|
7929
|
-
|
|
7929
|
+
debug2("onerror", er);
|
|
7930
7930
|
unpipe();
|
|
7931
7931
|
dest.removeListener("error", onerror);
|
|
7932
7932
|
if (EElistenerCount(dest, "error") === 0) errorOrDestroy(dest, er);
|
|
@@ -7938,18 +7938,18 @@ var require_stream_readable2 = __commonJS({
|
|
|
7938
7938
|
}
|
|
7939
7939
|
dest.once("close", onclose);
|
|
7940
7940
|
function onfinish() {
|
|
7941
|
-
|
|
7941
|
+
debug2("onfinish");
|
|
7942
7942
|
dest.removeListener("close", onclose);
|
|
7943
7943
|
unpipe();
|
|
7944
7944
|
}
|
|
7945
7945
|
dest.once("finish", onfinish);
|
|
7946
7946
|
function unpipe() {
|
|
7947
|
-
|
|
7947
|
+
debug2("unpipe");
|
|
7948
7948
|
src.unpipe(dest);
|
|
7949
7949
|
}
|
|
7950
7950
|
dest.emit("pipe", src);
|
|
7951
7951
|
if (!state.flowing) {
|
|
7952
|
-
|
|
7952
|
+
debug2("pipe resume");
|
|
7953
7953
|
src.resume();
|
|
7954
7954
|
}
|
|
7955
7955
|
return dest;
|
|
@@ -7957,7 +7957,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
7957
7957
|
function pipeOnDrain(src) {
|
|
7958
7958
|
return function pipeOnDrainFunctionResult() {
|
|
7959
7959
|
var state = src._readableState;
|
|
7960
|
-
|
|
7960
|
+
debug2("pipeOnDrain", state.awaitDrain);
|
|
7961
7961
|
if (state.awaitDrain) state.awaitDrain--;
|
|
7962
7962
|
if (state.awaitDrain === 0 && EElistenerCount(src, "data")) {
|
|
7963
7963
|
state.flowing = true;
|
|
@@ -8010,7 +8010,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8010
8010
|
state.readableListening = state.needReadable = true;
|
|
8011
8011
|
state.flowing = false;
|
|
8012
8012
|
state.emittedReadable = false;
|
|
8013
|
-
|
|
8013
|
+
debug2("on readable", state.length, state.reading);
|
|
8014
8014
|
if (state.length) {
|
|
8015
8015
|
emitReadable(this);
|
|
8016
8016
|
} else if (!state.reading) {
|
|
@@ -8045,13 +8045,13 @@ var require_stream_readable2 = __commonJS({
|
|
|
8045
8045
|
}
|
|
8046
8046
|
}
|
|
8047
8047
|
function nReadingNextTick(self2) {
|
|
8048
|
-
|
|
8048
|
+
debug2("readable nexttick read 0");
|
|
8049
8049
|
self2.read(0);
|
|
8050
8050
|
}
|
|
8051
8051
|
Readable.prototype.resume = function() {
|
|
8052
8052
|
var state = this._readableState;
|
|
8053
8053
|
if (!state.flowing) {
|
|
8054
|
-
|
|
8054
|
+
debug2("resume");
|
|
8055
8055
|
state.flowing = !state.readableListening;
|
|
8056
8056
|
resume(this, state);
|
|
8057
8057
|
}
|
|
@@ -8065,7 +8065,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8065
8065
|
}
|
|
8066
8066
|
}
|
|
8067
8067
|
function resume_(stream, state) {
|
|
8068
|
-
|
|
8068
|
+
debug2("resume", state.reading);
|
|
8069
8069
|
if (!state.reading) {
|
|
8070
8070
|
stream.read(0);
|
|
8071
8071
|
}
|
|
@@ -8075,9 +8075,9 @@ var require_stream_readable2 = __commonJS({
|
|
|
8075
8075
|
if (state.flowing && !state.reading) stream.read(0);
|
|
8076
8076
|
}
|
|
8077
8077
|
Readable.prototype.pause = function() {
|
|
8078
|
-
|
|
8078
|
+
debug2("call pause flowing=%j", this._readableState.flowing);
|
|
8079
8079
|
if (this._readableState.flowing !== false) {
|
|
8080
|
-
|
|
8080
|
+
debug2("pause");
|
|
8081
8081
|
this._readableState.flowing = false;
|
|
8082
8082
|
this.emit("pause");
|
|
8083
8083
|
}
|
|
@@ -8086,7 +8086,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8086
8086
|
};
|
|
8087
8087
|
function flow(stream) {
|
|
8088
8088
|
var state = stream._readableState;
|
|
8089
|
-
|
|
8089
|
+
debug2("flow", state.flowing);
|
|
8090
8090
|
while (state.flowing && stream.read() !== null) ;
|
|
8091
8091
|
}
|
|
8092
8092
|
Readable.prototype.wrap = function(stream) {
|
|
@@ -8094,7 +8094,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8094
8094
|
var state = this._readableState;
|
|
8095
8095
|
var paused = false;
|
|
8096
8096
|
stream.on("end", function() {
|
|
8097
|
-
|
|
8097
|
+
debug2("wrapped end");
|
|
8098
8098
|
if (state.decoder && !state.ended) {
|
|
8099
8099
|
var chunk = state.decoder.end();
|
|
8100
8100
|
if (chunk && chunk.length) _this.push(chunk);
|
|
@@ -8102,7 +8102,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8102
8102
|
_this.push(null);
|
|
8103
8103
|
});
|
|
8104
8104
|
stream.on("data", function(chunk) {
|
|
8105
|
-
|
|
8105
|
+
debug2("wrapped data");
|
|
8106
8106
|
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
8107
8107
|
if (state.objectMode && (chunk === null || chunk === void 0)) return;
|
|
8108
8108
|
else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
@@ -8125,7 +8125,7 @@ var require_stream_readable2 = __commonJS({
|
|
|
8125
8125
|
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
8126
8126
|
}
|
|
8127
8127
|
this._read = function(n2) {
|
|
8128
|
-
|
|
8128
|
+
debug2("wrapped _read", n2);
|
|
8129
8129
|
if (paused) {
|
|
8130
8130
|
paused = false;
|
|
8131
8131
|
stream.resume();
|
|
@@ -8199,14 +8199,14 @@ var require_stream_readable2 = __commonJS({
|
|
|
8199
8199
|
}
|
|
8200
8200
|
function endReadable(stream) {
|
|
8201
8201
|
var state = stream._readableState;
|
|
8202
|
-
|
|
8202
|
+
debug2("endReadable", state.endEmitted);
|
|
8203
8203
|
if (!state.endEmitted) {
|
|
8204
8204
|
state.ended = true;
|
|
8205
8205
|
process.nextTick(endReadableNT, state, stream);
|
|
8206
8206
|
}
|
|
8207
8207
|
}
|
|
8208
8208
|
function endReadableNT(state, stream) {
|
|
8209
|
-
|
|
8209
|
+
debug2("endReadableNT", state.endEmitted, state.length);
|
|
8210
8210
|
if (!state.endEmitted && state.length === 0) {
|
|
8211
8211
|
state.endEmitted = true;
|
|
8212
8212
|
stream.readable = false;
|
|
@@ -10422,7 +10422,7 @@ var require_file = __commonJS({
|
|
|
10422
10422
|
var { MESSAGE } = require_triple_beam();
|
|
10423
10423
|
var { Stream, PassThrough } = require_readable();
|
|
10424
10424
|
var TransportStream = require_winston_transport();
|
|
10425
|
-
var
|
|
10425
|
+
var debug2 = require_node2()("winston:file");
|
|
10426
10426
|
var os = require("os");
|
|
10427
10427
|
var tailFile = require_tail_file();
|
|
10428
10428
|
module2.exports = class File extends TransportStream {
|
|
@@ -10566,7 +10566,7 @@ var require_file = __commonJS({
|
|
|
10566
10566
|
function logged() {
|
|
10567
10567
|
this._size += bytes;
|
|
10568
10568
|
this._pendingSize -= bytes;
|
|
10569
|
-
|
|
10569
|
+
debug2("logged %s %s", this._size, output);
|
|
10570
10570
|
this.emit("logged", info);
|
|
10571
10571
|
if (this._rotate) {
|
|
10572
10572
|
return;
|
|
@@ -10600,7 +10600,7 @@ var require_file = __commonJS({
|
|
|
10600
10600
|
} else {
|
|
10601
10601
|
callback();
|
|
10602
10602
|
}
|
|
10603
|
-
|
|
10603
|
+
debug2("written", written, this._drain);
|
|
10604
10604
|
this.finishIfEnding();
|
|
10605
10605
|
return written;
|
|
10606
10606
|
}
|
|
@@ -10753,7 +10753,7 @@ var require_file = __commonJS({
|
|
|
10753
10753
|
if (err) {
|
|
10754
10754
|
return this.emit("error", err);
|
|
10755
10755
|
}
|
|
10756
|
-
|
|
10756
|
+
debug2("stat done: %s { size: %s }", this.filename, size);
|
|
10757
10757
|
this._size = size;
|
|
10758
10758
|
this._dest = this._createStream(this._stream);
|
|
10759
10759
|
this._opening = false;
|
|
@@ -10774,12 +10774,12 @@ var require_file = __commonJS({
|
|
|
10774
10774
|
const fullpath = path.join(this.dirname, target);
|
|
10775
10775
|
fs.stat(fullpath, (err, stat) => {
|
|
10776
10776
|
if (err && err.code === "ENOENT") {
|
|
10777
|
-
|
|
10777
|
+
debug2("ENOENT\xA0ok", fullpath);
|
|
10778
10778
|
this.filename = target;
|
|
10779
10779
|
return callback(null, 0);
|
|
10780
10780
|
}
|
|
10781
10781
|
if (err) {
|
|
10782
|
-
|
|
10782
|
+
debug2(`err ${err.code} ${fullpath}`);
|
|
10783
10783
|
return callback(err);
|
|
10784
10784
|
}
|
|
10785
10785
|
if (!stat || this._needsNewFile(stat.size)) {
|
|
@@ -10876,9 +10876,9 @@ var require_file = __commonJS({
|
|
|
10876
10876
|
*/
|
|
10877
10877
|
_createStream(source) {
|
|
10878
10878
|
const fullpath = path.join(this.dirname, this.filename);
|
|
10879
|
-
|
|
10880
|
-
const dest = fs.createWriteStream(fullpath, this.options).on("error", (err) =>
|
|
10881
|
-
|
|
10879
|
+
debug2("create stream start", fullpath, this.options);
|
|
10880
|
+
const dest = fs.createWriteStream(fullpath, this.options).on("error", (err) => debug2(err)).on("close", () => debug2("close", dest.path, dest.bytesWritten)).on("open", () => {
|
|
10881
|
+
debug2("file open ok", fullpath);
|
|
10882
10882
|
this.emit("open", fullpath);
|
|
10883
10883
|
source.pipe(dest);
|
|
10884
10884
|
if (this.rotatedWhileOpening) {
|
|
@@ -10890,7 +10890,7 @@ var require_file = __commonJS({
|
|
|
10890
10890
|
source.end();
|
|
10891
10891
|
}
|
|
10892
10892
|
});
|
|
10893
|
-
|
|
10893
|
+
debug2("create stream ok", fullpath);
|
|
10894
10894
|
return dest;
|
|
10895
10895
|
}
|
|
10896
10896
|
/**
|
|
@@ -10899,7 +10899,7 @@ var require_file = __commonJS({
|
|
|
10899
10899
|
* @returns {undefined}
|
|
10900
10900
|
*/
|
|
10901
10901
|
_incFile(callback) {
|
|
10902
|
-
|
|
10902
|
+
debug2("_incFile", this.filename);
|
|
10903
10903
|
const ext = path.extname(this._basename);
|
|
10904
10904
|
const basename = path.basename(this._basename, ext);
|
|
10905
10905
|
const tasks = [];
|
|
@@ -11666,7 +11666,7 @@ var require_exception_handler = __commonJS({
|
|
|
11666
11666
|
"use strict";
|
|
11667
11667
|
var os = require("os");
|
|
11668
11668
|
var asyncForEach = require_forEach();
|
|
11669
|
-
var
|
|
11669
|
+
var debug2 = require_node2()("winston:exception");
|
|
11670
11670
|
var once = require_one_time();
|
|
11671
11671
|
var stackTrace = require_stack_trace();
|
|
11672
11672
|
var ExceptionStream = require_exception_stream();
|
|
@@ -11812,8 +11812,8 @@ var require_exception_handler = __commonJS({
|
|
|
11812
11812
|
doExit = false;
|
|
11813
11813
|
}
|
|
11814
11814
|
function gracefulExit() {
|
|
11815
|
-
|
|
11816
|
-
|
|
11815
|
+
debug2("doExit", doExit);
|
|
11816
|
+
debug2("process._exiting", process._exiting);
|
|
11817
11817
|
if (doExit && !process._exiting) {
|
|
11818
11818
|
if (timeout) {
|
|
11819
11819
|
clearTimeout(timeout);
|
|
@@ -11829,7 +11829,7 @@ var require_exception_handler = __commonJS({
|
|
|
11829
11829
|
const transport = handler.transport || handler;
|
|
11830
11830
|
function onDone(event) {
|
|
11831
11831
|
return () => {
|
|
11832
|
-
|
|
11832
|
+
debug2(event);
|
|
11833
11833
|
done();
|
|
11834
11834
|
};
|
|
11835
11835
|
}
|
|
@@ -11904,7 +11904,7 @@ var require_rejection_handler = __commonJS({
|
|
|
11904
11904
|
"use strict";
|
|
11905
11905
|
var os = require("os");
|
|
11906
11906
|
var asyncForEach = require_forEach();
|
|
11907
|
-
var
|
|
11907
|
+
var debug2 = require_node2()("winston:rejection");
|
|
11908
11908
|
var once = require_one_time();
|
|
11909
11909
|
var stackTrace = require_stack_trace();
|
|
11910
11910
|
var RejectionStream = require_rejection_stream();
|
|
@@ -12052,8 +12052,8 @@ var require_rejection_handler = __commonJS({
|
|
|
12052
12052
|
doExit = false;
|
|
12053
12053
|
}
|
|
12054
12054
|
function gracefulExit() {
|
|
12055
|
-
|
|
12056
|
-
|
|
12055
|
+
debug2("doExit", doExit);
|
|
12056
|
+
debug2("process._exiting", process._exiting);
|
|
12057
12057
|
if (doExit && !process._exiting) {
|
|
12058
12058
|
if (timeout) {
|
|
12059
12059
|
clearTimeout(timeout);
|
|
@@ -12071,7 +12071,7 @@ var require_rejection_handler = __commonJS({
|
|
|
12071
12071
|
const transport = handler.transport || handler;
|
|
12072
12072
|
function onDone(event) {
|
|
12073
12073
|
return () => {
|
|
12074
|
-
|
|
12074
|
+
debug2(event);
|
|
12075
12075
|
done();
|
|
12076
12076
|
};
|
|
12077
12077
|
}
|
|
@@ -12689,7 +12689,7 @@ var require_create_logger = __commonJS({
|
|
|
12689
12689
|
var { LEVEL } = require_triple_beam();
|
|
12690
12690
|
var config = require_config2();
|
|
12691
12691
|
var Logger2 = require_logger();
|
|
12692
|
-
var
|
|
12692
|
+
var debug2 = require_node2()("winston:create-logger");
|
|
12693
12693
|
function isLevelEnabledFunctionName(level) {
|
|
12694
12694
|
return "is" + level.charAt(0).toUpperCase() + level.slice(1) + "Enabled";
|
|
12695
12695
|
}
|
|
@@ -12708,7 +12708,7 @@ var require_create_logger = __commonJS({
|
|
|
12708
12708
|
}
|
|
12709
12709
|
const logger = new DerivedLogger(opts);
|
|
12710
12710
|
Object.keys(opts.levels).forEach(function(level) {
|
|
12711
|
-
|
|
12711
|
+
debug2('Define prototype method for "%s"', level);
|
|
12712
12712
|
if (level === "log") {
|
|
12713
12713
|
console.warn('Level "log" not defined: conflicts with the method "log". Use a different level name.');
|
|
12714
12714
|
return;
|
|
@@ -16943,6 +16943,19 @@ function keyToDisplayName(key) {
|
|
|
16943
16943
|
return key.replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
16944
16944
|
}
|
|
16945
16945
|
|
|
16946
|
+
// src/_debug.ts
|
|
16947
|
+
function _parseDebugEnv(value) {
|
|
16948
|
+
const v = value.trim().toLowerCase();
|
|
16949
|
+
return v === "1" || v === "true" || v === "yes";
|
|
16950
|
+
}
|
|
16951
|
+
var _DEBUG_ENABLED = _parseDebugEnv(process.env.SMPLKIT_DEBUG ?? "");
|
|
16952
|
+
function debug(subsystem, message) {
|
|
16953
|
+
if (!_DEBUG_ENABLED) return;
|
|
16954
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
16955
|
+
process.stderr.write(`[smplkit:${subsystem}] ${ts} ${message}
|
|
16956
|
+
`);
|
|
16957
|
+
}
|
|
16958
|
+
|
|
16946
16959
|
// src/config/client.ts
|
|
16947
16960
|
var BASE_URL = "https://config.smplkit.com";
|
|
16948
16961
|
function extractItemValues(items) {
|
|
@@ -17329,6 +17342,7 @@ var ConfigClient = class {
|
|
|
17329
17342
|
if (this._getSharedWs) {
|
|
17330
17343
|
const ws = this._getSharedWs();
|
|
17331
17344
|
ws.on("config_changed", this._handleConfigChanged);
|
|
17345
|
+
ws.on("config_deleted", this._handleConfigChanged);
|
|
17332
17346
|
}
|
|
17333
17347
|
}
|
|
17334
17348
|
/** @internal — called by SmplClient for backward compat. */
|
|
@@ -17350,7 +17364,8 @@ var ConfigClient = class {
|
|
|
17350
17364
|
// ------------------------------------------------------------------
|
|
17351
17365
|
// Internal: WebSocket handler
|
|
17352
17366
|
// ------------------------------------------------------------------
|
|
17353
|
-
_handleConfigChanged = (
|
|
17367
|
+
_handleConfigChanged = (data) => {
|
|
17368
|
+
debug("websocket", `config event received: ${JSON.stringify(data)}`);
|
|
17354
17369
|
void this.refresh().catch(() => {
|
|
17355
17370
|
});
|
|
17356
17371
|
};
|
|
@@ -18068,6 +18083,7 @@ var FlagsClient = class {
|
|
|
18068
18083
|
*/
|
|
18069
18084
|
async initialize() {
|
|
18070
18085
|
if (this._initialized) return;
|
|
18086
|
+
debug("lifecycle", "FlagsClient.initialize() called");
|
|
18071
18087
|
this._environment = this._parent?._environment ?? null;
|
|
18072
18088
|
await this._fetchAllFlags();
|
|
18073
18089
|
this._initialized = true;
|
|
@@ -18245,6 +18261,7 @@ var FlagsClient = class {
|
|
|
18245
18261
|
// Internal: event handlers (called by SharedWebSocket)
|
|
18246
18262
|
// ------------------------------------------------------------------
|
|
18247
18263
|
_handleFlagChanged = (data) => {
|
|
18264
|
+
debug("websocket", `flag event received: ${JSON.stringify(data)}`);
|
|
18248
18265
|
const flagId = data.id;
|
|
18249
18266
|
void this._fetchAllFlags().then(() => {
|
|
18250
18267
|
this._cache.clear();
|
|
@@ -18252,6 +18269,7 @@ var FlagsClient = class {
|
|
|
18252
18269
|
});
|
|
18253
18270
|
};
|
|
18254
18271
|
_handleFlagDeleted = (data) => {
|
|
18272
|
+
debug("websocket", `flag deleted event received: ${JSON.stringify(data)}`);
|
|
18255
18273
|
const flagId = data.id;
|
|
18256
18274
|
void this._fetchAllFlags().then(() => {
|
|
18257
18275
|
this._cache.clear();
|
|
@@ -18270,6 +18288,7 @@ var FlagsClient = class {
|
|
|
18270
18288
|
this._flagStore = store;
|
|
18271
18289
|
}
|
|
18272
18290
|
async _fetchFlagsList() {
|
|
18291
|
+
debug("api", "GET /api/v1/flags");
|
|
18273
18292
|
let data;
|
|
18274
18293
|
try {
|
|
18275
18294
|
const result = await this._http.GET("/api/v1/flags", {});
|
|
@@ -18279,7 +18298,9 @@ var FlagsClient = class {
|
|
|
18279
18298
|
wrapFetchError2(err);
|
|
18280
18299
|
}
|
|
18281
18300
|
if (!data) return [];
|
|
18282
|
-
|
|
18301
|
+
const flags = data.data.map((r) => this._resourceToPlainDict(r));
|
|
18302
|
+
debug("api", `GET /api/v1/flags -> ${flags.length} flag(s)`);
|
|
18303
|
+
return flags;
|
|
18283
18304
|
}
|
|
18284
18305
|
// ------------------------------------------------------------------
|
|
18285
18306
|
// Internal: change listeners
|
|
@@ -18844,6 +18865,7 @@ var LoggingClient = class {
|
|
|
18844
18865
|
*/
|
|
18845
18866
|
async start() {
|
|
18846
18867
|
if (this._started) return;
|
|
18868
|
+
debug("lifecycle", "LoggingClient.start() called");
|
|
18847
18869
|
if (!this._explicitAdapters) {
|
|
18848
18870
|
this._adapters = this._autoLoadAdapters();
|
|
18849
18871
|
}
|
|
@@ -18855,11 +18877,13 @@ var LoggingClient = class {
|
|
|
18855
18877
|
} catch {
|
|
18856
18878
|
}
|
|
18857
18879
|
}
|
|
18880
|
+
debug("discovery", `discovered ${discovered.length} logger(s) from adapters`);
|
|
18858
18881
|
for (const adapter of this._adapters) {
|
|
18859
18882
|
try {
|
|
18860
18883
|
adapter.installHook((name, level) => {
|
|
18861
18884
|
this._onAdapterNewLogger(name, level);
|
|
18862
18885
|
});
|
|
18886
|
+
debug("discovery", `hook installed on adapter`);
|
|
18863
18887
|
} catch {
|
|
18864
18888
|
}
|
|
18865
18889
|
}
|
|
@@ -18882,28 +18906,38 @@ var LoggingClient = class {
|
|
|
18882
18906
|
environment: environment ?? void 0
|
|
18883
18907
|
})
|
|
18884
18908
|
);
|
|
18909
|
+
debug("registration", `flushing ${loggers.length} logger(s) to bulk-register endpoint`);
|
|
18885
18910
|
try {
|
|
18886
18911
|
const result = await this._http.POST("/api/v1/loggers/bulk", {
|
|
18887
18912
|
body: { loggers }
|
|
18888
18913
|
});
|
|
18889
18914
|
if (result.error !== void 0)
|
|
18890
18915
|
await checkError3(result.response, "Failed to bulk-register loggers");
|
|
18916
|
+
debug("registration", `bulk-register complete (${loggers.length} logger(s))`);
|
|
18891
18917
|
} catch (err) {
|
|
18892
18918
|
console.warn(
|
|
18893
18919
|
`[smplkit] Failed to bulk-register loggers: ${err instanceof Error ? err.message : String(err)}`
|
|
18894
18920
|
);
|
|
18895
18921
|
}
|
|
18896
18922
|
}
|
|
18923
|
+
debug("resolution", `starting resolution pass (trigger: start())`);
|
|
18897
18924
|
try {
|
|
18898
|
-
const [serverLoggers] = await Promise.all([
|
|
18925
|
+
const [serverLoggers, serverGroups] = await Promise.all([
|
|
18899
18926
|
this.management.list(),
|
|
18900
18927
|
this.management.listGroups()
|
|
18901
18928
|
]);
|
|
18929
|
+
debug(
|
|
18930
|
+
"api",
|
|
18931
|
+
`fetched ${serverLoggers.length} logger(s) and ${serverGroups.length} group(s) from server`
|
|
18932
|
+
);
|
|
18902
18933
|
this._applyLevels(serverLoggers);
|
|
18903
18934
|
} catch {
|
|
18904
18935
|
}
|
|
18905
18936
|
this._wsManager = this._ensureWs();
|
|
18906
18937
|
this._wsManager.on("logger_changed", this._handleLoggerChanged);
|
|
18938
|
+
this._wsManager.on("logger_deleted", this._handleLoggerChanged);
|
|
18939
|
+
this._wsManager.on("group_changed", this._handleGroupChanged);
|
|
18940
|
+
this._wsManager.on("group_deleted", this._handleGroupChanged);
|
|
18907
18941
|
this._started = true;
|
|
18908
18942
|
}
|
|
18909
18943
|
// ------------------------------------------------------------------
|
|
@@ -18934,14 +18968,19 @@ var LoggingClient = class {
|
|
|
18934
18968
|
// ------------------------------------------------------------------
|
|
18935
18969
|
/** @internal */
|
|
18936
18970
|
_close() {
|
|
18971
|
+
debug("lifecycle", "LoggingClient._close() called");
|
|
18937
18972
|
for (const adapter of this._adapters) {
|
|
18938
18973
|
try {
|
|
18939
18974
|
adapter.uninstallHook();
|
|
18975
|
+
debug("adapter", "applying-guard OFF \u2014 adapter hook uninstalled");
|
|
18940
18976
|
} catch {
|
|
18941
18977
|
}
|
|
18942
18978
|
}
|
|
18943
18979
|
if (this._wsManager !== null) {
|
|
18944
18980
|
this._wsManager.off("logger_changed", this._handleLoggerChanged);
|
|
18981
|
+
this._wsManager.off("logger_deleted", this._handleLoggerChanged);
|
|
18982
|
+
this._wsManager.off("group_changed", this._handleGroupChanged);
|
|
18983
|
+
this._wsManager.off("group_deleted", this._handleGroupChanged);
|
|
18945
18984
|
this._wsManager = null;
|
|
18946
18985
|
}
|
|
18947
18986
|
this._started = false;
|
|
@@ -18983,12 +19022,14 @@ var LoggingClient = class {
|
|
|
18983
19022
|
effectiveLevel = envOverride.level;
|
|
18984
19023
|
}
|
|
18985
19024
|
}
|
|
19025
|
+
debug("resolution", `${logger.id} -> ${effectiveLevel}`);
|
|
18986
19026
|
const metrics = this._parent?._metrics;
|
|
18987
19027
|
if (metrics) {
|
|
18988
19028
|
metrics.record("logging.level_changes", 1, "changes", { logger: logger.id });
|
|
18989
19029
|
}
|
|
18990
19030
|
for (const adapter of this._adapters) {
|
|
18991
19031
|
try {
|
|
19032
|
+
debug("adapter", `setLevel(${logger.id}, ${effectiveLevel})`);
|
|
18992
19033
|
adapter.applyLevel(logger.id, effectiveLevel);
|
|
18993
19034
|
} catch {
|
|
18994
19035
|
}
|
|
@@ -18997,6 +19038,7 @@ var LoggingClient = class {
|
|
|
18997
19038
|
}
|
|
18998
19039
|
/** Called by adapter hooks when a new logger is created in the framework. */
|
|
18999
19040
|
_onAdapterNewLogger(_name, _level) {
|
|
19041
|
+
debug("discovery", `new logger intercepted at runtime: ${_name}`);
|
|
19000
19042
|
const logger = this.management.new(_name, { managed: true });
|
|
19001
19043
|
logger.setLevel(_level);
|
|
19002
19044
|
logger.save().catch(() => {
|
|
@@ -19006,6 +19048,7 @@ var LoggingClient = class {
|
|
|
19006
19048
|
// Internal: WebSocket handler
|
|
19007
19049
|
// ------------------------------------------------------------------
|
|
19008
19050
|
_handleLoggerChanged = (data) => {
|
|
19051
|
+
debug("websocket", `logger event received: ${JSON.stringify(data)}`);
|
|
19009
19052
|
const id = data.id;
|
|
19010
19053
|
if (id) {
|
|
19011
19054
|
const level = data.level ?? null;
|
|
@@ -19014,6 +19057,11 @@ var LoggingClient = class {
|
|
|
19014
19057
|
level,
|
|
19015
19058
|
source: "websocket"
|
|
19016
19059
|
};
|
|
19060
|
+
void Promise.all([this.management.list(), this.management.listGroups()]).then(([serverLoggers]) => {
|
|
19061
|
+
debug("resolution", `resolution pass (trigger: websocket event for logger ${id})`);
|
|
19062
|
+
this._applyLevels(serverLoggers);
|
|
19063
|
+
}).catch(() => {
|
|
19064
|
+
});
|
|
19017
19065
|
for (const cb of this._globalListeners) {
|
|
19018
19066
|
try {
|
|
19019
19067
|
cb(event);
|
|
@@ -19031,6 +19079,14 @@ var LoggingClient = class {
|
|
|
19031
19079
|
}
|
|
19032
19080
|
}
|
|
19033
19081
|
};
|
|
19082
|
+
_handleGroupChanged = (data) => {
|
|
19083
|
+
debug("websocket", `group event received: ${JSON.stringify(data)}`);
|
|
19084
|
+
void Promise.all([this.management.list(), this.management.listGroups()]).then(([serverLoggers]) => {
|
|
19085
|
+
debug("resolution", `resolution pass (trigger: group websocket event)`);
|
|
19086
|
+
this._applyLevels(serverLoggers);
|
|
19087
|
+
}).catch(() => {
|
|
19088
|
+
});
|
|
19089
|
+
};
|
|
19034
19090
|
// ------------------------------------------------------------------
|
|
19035
19091
|
// Internal: model conversion
|
|
19036
19092
|
// ------------------------------------------------------------------
|
|
@@ -19102,12 +19158,15 @@ var SharedWebSocket = class {
|
|
|
19102
19158
|
}
|
|
19103
19159
|
_dispatch(eventName, data) {
|
|
19104
19160
|
const callbacks = this._listeners.get(eventName);
|
|
19105
|
-
if (callbacks) {
|
|
19106
|
-
|
|
19107
|
-
|
|
19108
|
-
|
|
19109
|
-
|
|
19110
|
-
|
|
19161
|
+
if (!callbacks || callbacks.length === 0) {
|
|
19162
|
+
debug("websocket", `no handler registered for event: "${eventName}"`);
|
|
19163
|
+
return;
|
|
19164
|
+
}
|
|
19165
|
+
debug("websocket", `routing "${eventName}" to ${callbacks.length} handler(s)`);
|
|
19166
|
+
for (const cb of [...callbacks]) {
|
|
19167
|
+
try {
|
|
19168
|
+
cb(data);
|
|
19169
|
+
} catch {
|
|
19111
19170
|
}
|
|
19112
19171
|
}
|
|
19113
19172
|
}
|
|
@@ -19122,11 +19181,13 @@ var SharedWebSocket = class {
|
|
|
19122
19181
|
// ------------------------------------------------------------------
|
|
19123
19182
|
/** Start the WebSocket connection. */
|
|
19124
19183
|
start() {
|
|
19184
|
+
debug("websocket", "starting WebSocket connection");
|
|
19125
19185
|
this._closed = false;
|
|
19126
19186
|
this._connect();
|
|
19127
19187
|
}
|
|
19128
19188
|
/** Stop the WebSocket connection. */
|
|
19129
19189
|
stop() {
|
|
19190
|
+
debug("websocket", "stopping WebSocket connection");
|
|
19130
19191
|
this._closed = true;
|
|
19131
19192
|
this._connectionStatus = "disconnected";
|
|
19132
19193
|
if (this._reconnectTimer !== null) {
|
|
@@ -19157,6 +19218,8 @@ var SharedWebSocket = class {
|
|
|
19157
19218
|
if (this._closed) return;
|
|
19158
19219
|
this._connectionStatus = "connecting";
|
|
19159
19220
|
const wsUrl = this._buildWsUrl();
|
|
19221
|
+
const safeUrl = wsUrl.split("?")[0];
|
|
19222
|
+
debug("websocket", `connecting to ${safeUrl}`);
|
|
19160
19223
|
try {
|
|
19161
19224
|
const ws = new import_ws.default(wsUrl);
|
|
19162
19225
|
this._ws = ws;
|
|
@@ -19170,19 +19233,23 @@ var SharedWebSocket = class {
|
|
|
19170
19233
|
try {
|
|
19171
19234
|
const raw = String(data);
|
|
19172
19235
|
if (raw === "ping") {
|
|
19236
|
+
debug("websocket", "ping received, sending pong");
|
|
19173
19237
|
ws.send("pong");
|
|
19174
19238
|
return;
|
|
19175
19239
|
}
|
|
19240
|
+
debug("websocket", `event received: ${raw}`);
|
|
19176
19241
|
const msg = JSON.parse(raw);
|
|
19177
19242
|
if (msg.type === "connected") {
|
|
19178
19243
|
this._backoffIndex = 0;
|
|
19179
19244
|
this._connectionStatus = "connected";
|
|
19245
|
+
debug("websocket", `connected to ${safeUrl}`);
|
|
19180
19246
|
if (this._metrics) {
|
|
19181
19247
|
this._metrics.recordGauge("platform.websocket_connections", 1, "connections");
|
|
19182
19248
|
}
|
|
19183
19249
|
return;
|
|
19184
19250
|
}
|
|
19185
19251
|
if (msg.type === "error") {
|
|
19252
|
+
debug("websocket", `connection error from server: ${JSON.stringify(msg.message)}`);
|
|
19186
19253
|
return;
|
|
19187
19254
|
}
|
|
19188
19255
|
const eventName = msg.event;
|
|
@@ -19192,7 +19259,8 @@ var SharedWebSocket = class {
|
|
|
19192
19259
|
} catch {
|
|
19193
19260
|
}
|
|
19194
19261
|
});
|
|
19195
|
-
ws.on("close", () => {
|
|
19262
|
+
ws.on("close", (code) => {
|
|
19263
|
+
debug("websocket", `connection closed (code=${code})`);
|
|
19196
19264
|
if (this._metrics) {
|
|
19197
19265
|
this._metrics.recordGauge("platform.websocket_connections", 0, "connections");
|
|
19198
19266
|
}
|
|
@@ -19201,9 +19269,14 @@ var SharedWebSocket = class {
|
|
|
19201
19269
|
this._scheduleReconnect();
|
|
19202
19270
|
}
|
|
19203
19271
|
});
|
|
19204
|
-
ws.on("error", () => {
|
|
19272
|
+
ws.on("error", (err) => {
|
|
19273
|
+
debug("websocket", `WebSocket error: ${err.message}`);
|
|
19205
19274
|
});
|
|
19206
|
-
} catch {
|
|
19275
|
+
} catch (err) {
|
|
19276
|
+
debug(
|
|
19277
|
+
"websocket",
|
|
19278
|
+
`failed to create WebSocket: ${err instanceof Error ? err.message : String(err)}`
|
|
19279
|
+
);
|
|
19207
19280
|
if (!this._closed) {
|
|
19208
19281
|
this._scheduleReconnect();
|
|
19209
19282
|
}
|
|
@@ -19214,6 +19287,7 @@ var SharedWebSocket = class {
|
|
|
19214
19287
|
const delay = BACKOFF_MS[Math.min(this._backoffIndex, BACKOFF_MS.length - 1)];
|
|
19215
19288
|
this._backoffIndex++;
|
|
19216
19289
|
this._connectionStatus = "connecting";
|
|
19290
|
+
debug("websocket", `reconnecting in ${delay}ms (attempt ${this._backoffIndex})`);
|
|
19217
19291
|
this._reconnectTimer = setTimeout(() => {
|
|
19218
19292
|
this._reconnectTimer = null;
|
|
19219
19293
|
this._connect();
|
|
@@ -19448,6 +19522,11 @@ var SmplClient = class {
|
|
|
19448
19522
|
const apiKey = resolveApiKey(options.apiKey, environment);
|
|
19449
19523
|
this._apiKey = apiKey;
|
|
19450
19524
|
this._timeout = options.timeout ?? 3e4;
|
|
19525
|
+
const maskedKey = apiKey.length > 14 ? apiKey.slice(0, 10) + "..." + apiKey.slice(-4) : apiKey.slice(0, Math.min(4, apiKey.length)) + "...";
|
|
19526
|
+
debug(
|
|
19527
|
+
"lifecycle",
|
|
19528
|
+
`SmplClient created (api_key=${maskedKey}, environment=${environment}, service=${service})`
|
|
19529
|
+
);
|
|
19451
19530
|
this._appHttp = (0, import_openapi_fetch4.default)({
|
|
19452
19531
|
baseUrl: APP_BASE_URL3,
|
|
19453
19532
|
headers: {
|
|
@@ -19502,6 +19581,7 @@ var SmplClient = class {
|
|
|
19502
19581
|
}
|
|
19503
19582
|
/** Close the shared WebSocket and release resources. */
|
|
19504
19583
|
close() {
|
|
19584
|
+
debug("lifecycle", "SmplClient.close() called");
|
|
19505
19585
|
if (this._metrics !== null) {
|
|
19506
19586
|
this._metrics.close();
|
|
19507
19587
|
}
|