@otonoma/paranet-client 2.18.2 → 2.19.0-rc.14
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/cjs/graphql.d.ts.map +1 -1
- package/dist/cjs/{index-AtS3JMf_.cjs → index-eBiJ1Egw.cjs} +161 -295
- package/dist/cjs/index-eBiJ1Egw.cjs.map +1 -0
- package/dist/cjs/index.cjs +110 -246
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/pncp.d.ts +0 -10
- package/dist/cjs/pncp.d.ts.map +1 -1
- package/dist/cjs/proto/broker.grpc.client.d.ts +29 -31
- package/dist/cjs/proto/broker.grpc.client.d.ts.map +1 -1
- package/dist/cjs/proto/broker_api.d.ts +32 -25
- package/dist/cjs/proto/broker_api.d.ts.map +1 -1
- package/dist/cjs/proto/google/protobuf/descriptor.d.ts +177 -177
- package/dist/cjs/proto/google/protobuf/descriptor.d.ts.map +1 -1
- package/dist/cjs/proto/google/protobuf/timestamp.d.ts +2 -2
- package/dist/cjs/proto/grpc/health/v1/health.client.d.ts +4 -4
- package/dist/cjs/proto/grpc/health/v1/health.d.ts +2 -2
- package/dist/cjs/proto/identifiers.d.ts +4 -4
- package/dist/cjs/proto/observation.d.ts +27 -27
- package/dist/cjs/proto/otonoma/common/value.d.ts +10 -10
- package/dist/cjs/proto/pncp.d.ts +74 -100
- package/dist/cjs/proto/pncp.d.ts.map +1 -1
- package/dist/cjs/schema/paranet.d.ts +4 -32
- package/dist/cjs/schema/paranet.d.ts.map +1 -1
- package/dist/esm/graphql.d.ts.map +1 -1
- package/dist/esm/{index-HCY5Ez1I.mjs → index-PztyZob7.mjs} +161 -295
- package/dist/esm/index-PztyZob7.mjs.map +1 -0
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.mjs +111 -245
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/pncp.d.ts +0 -10
- package/dist/esm/pncp.d.ts.map +1 -1
- package/dist/esm/proto/broker.grpc.client.d.ts +29 -31
- package/dist/esm/proto/broker.grpc.client.d.ts.map +1 -1
- package/dist/esm/proto/broker_api.d.ts +32 -25
- package/dist/esm/proto/broker_api.d.ts.map +1 -1
- package/dist/esm/proto/google/protobuf/descriptor.d.ts +177 -177
- package/dist/esm/proto/google/protobuf/descriptor.d.ts.map +1 -1
- package/dist/esm/proto/google/protobuf/timestamp.d.ts +2 -2
- package/dist/esm/proto/grpc/health/v1/health.client.d.ts +4 -4
- package/dist/esm/proto/grpc/health/v1/health.d.ts +2 -2
- package/dist/esm/proto/identifiers.d.ts +4 -4
- package/dist/esm/proto/observation.d.ts +27 -27
- package/dist/esm/proto/otonoma/common/value.d.ts +10 -10
- package/dist/esm/proto/pncp.d.ts +74 -100
- package/dist/esm/proto/pncp.d.ts.map +1 -1
- package/dist/esm/schema/paranet.d.ts +4 -32
- package/dist/esm/schema/paranet.d.ts.map +1 -1
- package/dist/graphql.d.ts.map +1 -1
- package/dist/graphql.js +0 -2
- package/dist/index.d.cts +206 -319
- package/dist/index.d.mts +206 -319
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/pncp.d.ts +0 -10
- package/dist/pncp.d.ts.map +1 -1
- package/dist/pncp.js +0 -3
- package/dist/proto/broker.grpc.client.d.ts +29 -31
- package/dist/proto/broker.grpc.client.d.ts.map +1 -1
- package/dist/proto/broker.grpc.client.js +22 -23
- package/dist/proto/broker.grpc.js +4 -4
- package/dist/proto/broker_api.d.ts +32 -25
- package/dist/proto/broker_api.d.ts.map +1 -1
- package/dist/proto/broker_api.js +22 -2
- package/dist/proto/google/protobuf/descriptor.d.ts +177 -177
- package/dist/proto/google/protobuf/descriptor.d.ts.map +1 -1
- package/dist/proto/google/protobuf/descriptor.js +136 -110
- package/dist/proto/google/protobuf/timestamp.d.ts +2 -2
- package/dist/proto/google/protobuf/timestamp.js +1 -1
- package/dist/proto/grpc/health/v1/health.client.d.ts +4 -4
- package/dist/proto/grpc/health/v1/health.client.js +2 -2
- package/dist/proto/grpc/health/v1/health.d.ts +2 -2
- package/dist/proto/grpc/health/v1/health.js +1 -1
- package/dist/proto/identifiers.d.ts +4 -4
- package/dist/proto/observation.d.ts +27 -27
- package/dist/proto/observation.js +1 -1
- package/dist/proto/otonoma/common/value.d.ts +10 -10
- package/dist/proto/otonoma/common/value.js +2 -2
- package/dist/proto/pncp.d.ts +74 -100
- package/dist/proto/pncp.d.ts.map +1 -1
- package/dist/proto/pncp.js +55 -89
- package/dist/schema/paranet.d.ts +4 -32
- package/dist/schema/paranet.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/index-AtS3JMf_.cjs.map +0 -1
- package/dist/cjs/proto/mediums.d.ts +0 -71
- package/dist/cjs/proto/mediums.d.ts.map +0 -1
- package/dist/esm/index-HCY5Ez1I.mjs.map +0 -1
- package/dist/esm/proto/mediums.d.ts +0 -71
- package/dist/esm/proto/mediums.d.ts.map +0 -1
- package/dist/proto/mediums.d.ts +0 -71
- package/dist/proto/mediums.d.ts.map +0 -1
- package/dist/proto/mediums.js +0 -120
|
@@ -8947,7 +8947,7 @@ async function connectH1$1 (client, socket) {
|
|
|
8947
8947
|
|
|
8948
8948
|
function clearIdleSocketValidation (socket) {
|
|
8949
8949
|
if (socket[kIdleSocketValidationTimeout]) {
|
|
8950
|
-
|
|
8950
|
+
clearTimeout(socket[kIdleSocketValidationTimeout]);
|
|
8951
8951
|
socket[kIdleSocketValidationTimeout] = null;
|
|
8952
8952
|
}
|
|
8953
8953
|
|
|
@@ -8956,23 +8956,15 @@ function clearIdleSocketValidation (socket) {
|
|
|
8956
8956
|
|
|
8957
8957
|
function scheduleIdleSocketValidation (client, socket) {
|
|
8958
8958
|
socket[kIdleSocketValidation] = 1;
|
|
8959
|
-
|
|
8960
|
-
// already pending on this idle keep-alive socket are processed before the
|
|
8961
|
-
// next request is written (GHSA-35p6-xmwp-9g52).
|
|
8962
|
-
//
|
|
8963
|
-
// setTimeout(0) pays Node's ~1ms timer floor on every sequential reuse
|
|
8964
|
-
// (#5493). setImmediate avoids that, but an *unref'd* Immediate lets poll
|
|
8965
|
-
// block for ~500ms when the event loop is otherwise idle (#5600 / #5606).
|
|
8966
|
-
// A ref'd Immediate both keeps the pending request alive and makes poll
|
|
8967
|
-
// return immediately — the hybrid those issues asked for.
|
|
8968
|
-
socket[kIdleSocketValidationTimeout] = setImmediate(() => {
|
|
8959
|
+
socket[kIdleSocketValidationTimeout] = setTimeout(() => {
|
|
8969
8960
|
socket[kIdleSocketValidationTimeout] = null;
|
|
8970
8961
|
socket[kIdleSocketValidation] = 2;
|
|
8971
8962
|
|
|
8972
8963
|
if (client[kSocket$1] === socket && !socket.destroyed) {
|
|
8973
8964
|
client[kResume$3]();
|
|
8974
8965
|
}
|
|
8975
|
-
});
|
|
8966
|
+
}, 0);
|
|
8967
|
+
socket[kIdleSocketValidationTimeout].unref?.();
|
|
8976
8968
|
}
|
|
8977
8969
|
|
|
8978
8970
|
/**
|
|
@@ -12477,7 +12469,6 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12477
12469
|
this.end = null;
|
|
12478
12470
|
this.etag = null;
|
|
12479
12471
|
this.resume = null;
|
|
12480
|
-
this.headersSent = false;
|
|
12481
12472
|
|
|
12482
12473
|
// Handle possible onConnect duplication
|
|
12483
12474
|
this.handler.onConnect(reason => {
|
|
@@ -12490,20 +12481,6 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12490
12481
|
});
|
|
12491
12482
|
}
|
|
12492
12483
|
|
|
12493
|
-
checkpointResponseEnd (headers, resume) {
|
|
12494
|
-
if (this.end == null && this.opts.method !== 'HEAD') {
|
|
12495
|
-
const contentLength = headers['content-length'];
|
|
12496
|
-
this.end = contentLength != null ? Number(contentLength) - 1 : null;
|
|
12497
|
-
|
|
12498
|
-
assert$7(
|
|
12499
|
-
this.end == null || Number.isFinite(this.end),
|
|
12500
|
-
'invalid content-length'
|
|
12501
|
-
);
|
|
12502
|
-
}
|
|
12503
|
-
|
|
12504
|
-
this.resume = this.end != null ? resume : null;
|
|
12505
|
-
}
|
|
12506
|
-
|
|
12507
12484
|
onRequestSent () {
|
|
12508
12485
|
if (this.handler.onRequestSent) {
|
|
12509
12486
|
this.handler.onRequestSent();
|
|
@@ -12593,8 +12570,6 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12593
12570
|
|
|
12594
12571
|
if (statusCode >= 300) {
|
|
12595
12572
|
if (this.retryOpts.statusCodes.includes(statusCode) === false) {
|
|
12596
|
-
this.headersSent = true;
|
|
12597
|
-
this.checkpointResponseEnd(headers, resume);
|
|
12598
12573
|
return this.handler.onHeaders(
|
|
12599
12574
|
statusCode,
|
|
12600
12575
|
rawHeaders,
|
|
@@ -12663,15 +12638,8 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12663
12638
|
|
|
12664
12639
|
const { start, size, end = size - 1 } = contentRange;
|
|
12665
12640
|
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
new RequestRetryError('Content-Range mismatch', statusCode, {
|
|
12669
|
-
headers,
|
|
12670
|
-
data: { count: this.retryCount }
|
|
12671
|
-
})
|
|
12672
|
-
);
|
|
12673
|
-
return false
|
|
12674
|
-
}
|
|
12641
|
+
assert$7(this.start === start, 'content-range mismatch');
|
|
12642
|
+
assert$7(this.end == null || this.end === end, 'content-range mismatch');
|
|
12675
12643
|
|
|
12676
12644
|
this.resume = resume;
|
|
12677
12645
|
return true
|
|
@@ -12683,7 +12651,6 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12683
12651
|
const range = parseRangeHeader(headers['content-range']);
|
|
12684
12652
|
|
|
12685
12653
|
if (range == null) {
|
|
12686
|
-
this.headersSent = true;
|
|
12687
12654
|
return this.handler.onHeaders(
|
|
12688
12655
|
statusCode,
|
|
12689
12656
|
rawHeaders,
|
|
@@ -12722,7 +12689,6 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12722
12689
|
);
|
|
12723
12690
|
|
|
12724
12691
|
this.resume = resume;
|
|
12725
|
-
this.headersSent = true;
|
|
12726
12692
|
this.etag = headers.etag != null ? headers.etag : null;
|
|
12727
12693
|
|
|
12728
12694
|
// Weak etags are not useful for comparison nor cache
|
|
@@ -12762,7 +12728,7 @@ let RetryHandler$3 = class RetryHandler {
|
|
|
12762
12728
|
}
|
|
12763
12729
|
|
|
12764
12730
|
onError (err) {
|
|
12765
|
-
if (this.aborted || isDisturbed(this.opts.body)
|
|
12731
|
+
if (this.aborted || isDisturbed(this.opts.body)) {
|
|
12766
12732
|
return this.handler.onError(err)
|
|
12767
12733
|
}
|
|
12768
12734
|
|
|
@@ -24671,7 +24637,7 @@ function requireConnection () {
|
|
|
24671
24637
|
// is specified, the server needs to include the same field and one of
|
|
24672
24638
|
// the selected subprotocol values in its response for the connection to
|
|
24673
24639
|
// be established.
|
|
24674
|
-
if (
|
|
24640
|
+
if (!requestProtocols.includes(secProtocol)) {
|
|
24675
24641
|
failWebsocketConnection(ws, 'Protocol was not set in the opening handshake.');
|
|
24676
24642
|
return
|
|
24677
24643
|
}
|
|
@@ -24918,12 +24884,7 @@ function requirePermessageDeflate () {
|
|
|
24918
24884
|
|
|
24919
24885
|
if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
|
|
24920
24886
|
callback(new MessageSizeExceededError());
|
|
24921
|
-
// The inflater may still hold buffered input that can emit a late
|
|
24922
|
-
// zlib error. Remove the data listener, then deterministically stop
|
|
24923
|
-
// the stream so a subsequent 'error' cannot fire without a listener
|
|
24924
|
-
// (which would terminate the process as an unhandled error event).
|
|
24925
24887
|
this.#inflate.removeAllListeners();
|
|
24926
|
-
this.#inflate.destroy();
|
|
24927
24888
|
this.#inflate = null;
|
|
24928
24889
|
return
|
|
24929
24890
|
}
|
|
@@ -26272,49 +26233,6 @@ function requireEventsourceStream () {
|
|
|
26272
26233
|
*/
|
|
26273
26234
|
const SPACE = 0x20;
|
|
26274
26235
|
|
|
26275
|
-
const DATA = Buffer.from('data');
|
|
26276
|
-
const EVENT = Buffer.from('event');
|
|
26277
|
-
const ID = Buffer.from('id');
|
|
26278
|
-
const RETRY = Buffer.from('retry');
|
|
26279
|
-
|
|
26280
|
-
function isASCIINumberBytes (buffer, start) {
|
|
26281
|
-
if (start >= buffer.length) {
|
|
26282
|
-
return false
|
|
26283
|
-
}
|
|
26284
|
-
|
|
26285
|
-
for (let i = start; i < buffer.length; i++) {
|
|
26286
|
-
if (buffer[i] < 0x30 || buffer[i] > 0x39) {
|
|
26287
|
-
return false
|
|
26288
|
-
}
|
|
26289
|
-
}
|
|
26290
|
-
|
|
26291
|
-
return true
|
|
26292
|
-
}
|
|
26293
|
-
|
|
26294
|
-
function isValidLastEventIdBytes (buffer, start) {
|
|
26295
|
-
for (let i = start; i < buffer.length; i++) {
|
|
26296
|
-
if (buffer[i] === 0x00) {
|
|
26297
|
-
return false
|
|
26298
|
-
}
|
|
26299
|
-
}
|
|
26300
|
-
|
|
26301
|
-
return true
|
|
26302
|
-
}
|
|
26303
|
-
|
|
26304
|
-
function isFieldName (line, length, field) {
|
|
26305
|
-
if (length !== field.length) {
|
|
26306
|
-
return false
|
|
26307
|
-
}
|
|
26308
|
-
|
|
26309
|
-
for (let i = 0; i < length; i++) {
|
|
26310
|
-
if (line[i] !== field[i]) {
|
|
26311
|
-
return false
|
|
26312
|
-
}
|
|
26313
|
-
}
|
|
26314
|
-
|
|
26315
|
-
return true
|
|
26316
|
-
}
|
|
26317
|
-
|
|
26318
26236
|
/**
|
|
26319
26237
|
* @typedef {object} EventSourceStreamEvent
|
|
26320
26238
|
* @type {object}
|
|
@@ -26355,14 +26273,11 @@ function requireEventsourceStream () {
|
|
|
26355
26273
|
eventEndCheck = false
|
|
26356
26274
|
|
|
26357
26275
|
/**
|
|
26358
|
-
* @type {Buffer
|
|
26276
|
+
* @type {Buffer}
|
|
26359
26277
|
*/
|
|
26360
|
-
|
|
26278
|
+
buffer = null
|
|
26361
26279
|
|
|
26362
|
-
chunkIndex = 0
|
|
26363
26280
|
pos = 0
|
|
26364
|
-
lineChunkIndex = 0
|
|
26365
|
-
linePos = 0
|
|
26366
26281
|
|
|
26367
26282
|
event = {
|
|
26368
26283
|
data: undefined,
|
|
@@ -26401,20 +26316,92 @@ function requireEventsourceStream () {
|
|
|
26401
26316
|
return
|
|
26402
26317
|
}
|
|
26403
26318
|
|
|
26404
|
-
|
|
26319
|
+
// Cache the chunk in the buffer, as the data might not be complete while
|
|
26320
|
+
// processing it
|
|
26321
|
+
// TODO: Investigate if there is a more performant way to handle
|
|
26322
|
+
// incoming chunks
|
|
26323
|
+
// see: https://github.com/nodejs/undici/issues/2630
|
|
26324
|
+
if (this.buffer) {
|
|
26325
|
+
this.buffer = Buffer.concat([this.buffer, chunk]);
|
|
26326
|
+
} else {
|
|
26327
|
+
this.buffer = chunk;
|
|
26328
|
+
}
|
|
26405
26329
|
|
|
26406
26330
|
// Strip leading byte-order-mark if we opened the stream and started
|
|
26407
26331
|
// the processing of the incoming data
|
|
26408
26332
|
if (this.checkBOM) {
|
|
26409
|
-
|
|
26410
|
-
|
|
26411
|
-
|
|
26333
|
+
switch (this.buffer.length) {
|
|
26334
|
+
case 1:
|
|
26335
|
+
// Check if the first byte is the same as the first byte of the BOM
|
|
26336
|
+
if (this.buffer[0] === BOM[0]) {
|
|
26337
|
+
// If it is, we need to wait for more data
|
|
26338
|
+
callback();
|
|
26339
|
+
return
|
|
26340
|
+
}
|
|
26341
|
+
// Set the checkBOM flag to false as we don't need to check for the
|
|
26342
|
+
// BOM anymore
|
|
26343
|
+
this.checkBOM = false;
|
|
26344
|
+
|
|
26345
|
+
// The buffer only contains one byte so we need to wait for more data
|
|
26346
|
+
callback();
|
|
26347
|
+
return
|
|
26348
|
+
case 2:
|
|
26349
|
+
// Check if the first two bytes are the same as the first two bytes
|
|
26350
|
+
// of the BOM
|
|
26351
|
+
if (
|
|
26352
|
+
this.buffer[0] === BOM[0] &&
|
|
26353
|
+
this.buffer[1] === BOM[1]
|
|
26354
|
+
) {
|
|
26355
|
+
// If it is, we need to wait for more data, because the third byte
|
|
26356
|
+
// is needed to determine if it is the BOM or not
|
|
26357
|
+
callback();
|
|
26358
|
+
return
|
|
26359
|
+
}
|
|
26360
|
+
|
|
26361
|
+
// Set the checkBOM flag to false as we don't need to check for the
|
|
26362
|
+
// BOM anymore
|
|
26363
|
+
this.checkBOM = false;
|
|
26364
|
+
break
|
|
26365
|
+
case 3:
|
|
26366
|
+
// Check if the first three bytes are the same as the first three
|
|
26367
|
+
// bytes of the BOM
|
|
26368
|
+
if (
|
|
26369
|
+
this.buffer[0] === BOM[0] &&
|
|
26370
|
+
this.buffer[1] === BOM[1] &&
|
|
26371
|
+
this.buffer[2] === BOM[2]
|
|
26372
|
+
) {
|
|
26373
|
+
// If it is, we can drop the buffered data, as it is only the BOM
|
|
26374
|
+
this.buffer = Buffer.alloc(0);
|
|
26375
|
+
// Set the checkBOM flag to false as we don't need to check for the
|
|
26376
|
+
// BOM anymore
|
|
26377
|
+
this.checkBOM = false;
|
|
26378
|
+
|
|
26379
|
+
// Await more data
|
|
26380
|
+
callback();
|
|
26381
|
+
return
|
|
26382
|
+
}
|
|
26383
|
+
// If it is not the BOM, we can start processing the data
|
|
26384
|
+
this.checkBOM = false;
|
|
26385
|
+
break
|
|
26386
|
+
default:
|
|
26387
|
+
// The buffer is longer than 3 bytes, so we can drop the BOM if it is
|
|
26388
|
+
// present
|
|
26389
|
+
if (
|
|
26390
|
+
this.buffer[0] === BOM[0] &&
|
|
26391
|
+
this.buffer[1] === BOM[1] &&
|
|
26392
|
+
this.buffer[2] === BOM[2]
|
|
26393
|
+
) {
|
|
26394
|
+
// Remove the BOM from the buffer
|
|
26395
|
+
this.buffer = this.buffer.subarray(3);
|
|
26396
|
+
}
|
|
26397
|
+
|
|
26398
|
+
// Set the checkBOM flag to false as we don't need to check for the
|
|
26399
|
+
this.checkBOM = false;
|
|
26400
|
+
break
|
|
26412
26401
|
}
|
|
26413
26402
|
}
|
|
26414
26403
|
|
|
26415
|
-
while (this.
|
|
26416
|
-
const byte = this.currentByte();
|
|
26417
|
-
|
|
26404
|
+
while (this.pos < this.buffer.length) {
|
|
26418
26405
|
// If the previous line ended with an end-of-line, we need to check
|
|
26419
26406
|
// if the next character is also an end-of-line.
|
|
26420
26407
|
if (this.eventEndCheck) {
|
|
@@ -26427,9 +26414,10 @@ function requireEventsourceStream () {
|
|
|
26427
26414
|
if (this.crlfCheck) {
|
|
26428
26415
|
// If the current character is a line feed, we can remove it
|
|
26429
26416
|
// from the buffer and reset the crlfCheck flag
|
|
26430
|
-
if (
|
|
26417
|
+
if (this.buffer[this.pos] === LF) {
|
|
26418
|
+
this.buffer = this.buffer.subarray(this.pos + 1);
|
|
26419
|
+
this.pos = 0;
|
|
26431
26420
|
this.crlfCheck = false;
|
|
26432
|
-
this.consumeCurrentByte();
|
|
26433
26421
|
|
|
26434
26422
|
// It is possible that the line feed is not the end of the
|
|
26435
26423
|
// event. We need to check if the next character is an
|
|
@@ -26445,17 +26433,19 @@ function requireEventsourceStream () {
|
|
|
26445
26433
|
this.crlfCheck = false;
|
|
26446
26434
|
}
|
|
26447
26435
|
|
|
26448
|
-
if (
|
|
26436
|
+
if (this.buffer[this.pos] === LF || this.buffer[this.pos] === CR) {
|
|
26449
26437
|
// If the current character is a carriage return, we need to
|
|
26450
26438
|
// set the crlfCheck flag to true, as we need to check if the
|
|
26451
26439
|
// next character is a line feed so we can remove it from the
|
|
26452
26440
|
// buffer
|
|
26453
|
-
if (
|
|
26441
|
+
if (this.buffer[this.pos] === CR) {
|
|
26454
26442
|
this.crlfCheck = true;
|
|
26455
26443
|
}
|
|
26456
26444
|
|
|
26457
|
-
this.
|
|
26458
|
-
|
|
26445
|
+
this.buffer = this.buffer.subarray(this.pos + 1);
|
|
26446
|
+
this.pos = 0;
|
|
26447
|
+
if (
|
|
26448
|
+
this.event.data !== undefined || this.event.event || this.event.id || this.event.retry) {
|
|
26459
26449
|
this.processEvent(this.event);
|
|
26460
26450
|
}
|
|
26461
26451
|
this.clearEvent();
|
|
@@ -26469,18 +26459,22 @@ function requireEventsourceStream () {
|
|
|
26469
26459
|
|
|
26470
26460
|
// If the current character is an end-of-line, we can process the
|
|
26471
26461
|
// line
|
|
26472
|
-
if (
|
|
26462
|
+
if (this.buffer[this.pos] === LF || this.buffer[this.pos] === CR) {
|
|
26473
26463
|
// If the current character is a carriage return, we need to
|
|
26474
26464
|
// set the crlfCheck flag to true, as we need to check if the
|
|
26475
26465
|
// next character is a line feed
|
|
26476
|
-
if (
|
|
26466
|
+
if (this.buffer[this.pos] === CR) {
|
|
26477
26467
|
this.crlfCheck = true;
|
|
26478
26468
|
}
|
|
26479
26469
|
|
|
26480
26470
|
// In any case, we can process the line as we reached an
|
|
26481
26471
|
// end-of-line character
|
|
26482
|
-
this.parseLine(this.
|
|
26483
|
-
|
|
26472
|
+
this.parseLine(this.buffer.subarray(0, this.pos), this.event);
|
|
26473
|
+
|
|
26474
|
+
// Remove the processed line from the buffer
|
|
26475
|
+
this.buffer = this.buffer.subarray(this.pos + 1);
|
|
26476
|
+
// Reset the position as we removed the processed line from the buffer
|
|
26477
|
+
this.pos = 0;
|
|
26484
26478
|
// A line was processed and this could be the end of the event. We need
|
|
26485
26479
|
// to check if the next line is empty to determine if the event is
|
|
26486
26480
|
// finished.
|
|
@@ -26488,7 +26482,7 @@ function requireEventsourceStream () {
|
|
|
26488
26482
|
continue
|
|
26489
26483
|
}
|
|
26490
26484
|
|
|
26491
|
-
this.
|
|
26485
|
+
this.pos++;
|
|
26492
26486
|
}
|
|
26493
26487
|
|
|
26494
26488
|
callback();
|
|
@@ -26513,53 +26507,64 @@ function requireEventsourceStream () {
|
|
|
26513
26507
|
return
|
|
26514
26508
|
}
|
|
26515
26509
|
|
|
26516
|
-
let
|
|
26517
|
-
let
|
|
26510
|
+
let field = '';
|
|
26511
|
+
let value = '';
|
|
26518
26512
|
|
|
26519
26513
|
// If the line contains a U+003A COLON character (:)
|
|
26520
26514
|
if (colonPosition !== -1) {
|
|
26521
|
-
|
|
26515
|
+
// Collect the characters on the line before the first U+003A COLON
|
|
26516
|
+
// character (:), and let field be that string.
|
|
26517
|
+
// TODO: Investigate if there is a more performant way to extract the
|
|
26518
|
+
// field
|
|
26519
|
+
// see: https://github.com/nodejs/undici/issues/2630
|
|
26520
|
+
field = line.subarray(0, colonPosition).toString('utf8');
|
|
26522
26521
|
|
|
26523
26522
|
// Collect the characters on the line after the first U+003A COLON
|
|
26524
26523
|
// character (:), and let value be that string.
|
|
26525
26524
|
// If value starts with a U+0020 SPACE character, remove it from value.
|
|
26526
|
-
valueStart = colonPosition + 1;
|
|
26525
|
+
let valueStart = colonPosition + 1;
|
|
26527
26526
|
if (line[valueStart] === SPACE) {
|
|
26528
26527
|
++valueStart;
|
|
26529
26528
|
}
|
|
26530
|
-
|
|
26531
|
-
|
|
26532
|
-
|
|
26533
|
-
|
|
26534
|
-
|
|
26535
|
-
if (event.data === undefined) {
|
|
26536
|
-
event.data = value;
|
|
26537
|
-
} else {
|
|
26538
|
-
event.data += `\n${value}`;
|
|
26539
|
-
}
|
|
26540
|
-
return
|
|
26541
|
-
}
|
|
26542
|
-
|
|
26543
|
-
if (isFieldName(line, fieldLength, RETRY)) {
|
|
26544
|
-
if (isASCIINumberBytes(line, valueStart)) {
|
|
26545
|
-
event.retry = line.toString('utf8', valueStart);
|
|
26546
|
-
}
|
|
26547
|
-
return
|
|
26548
|
-
}
|
|
26549
|
-
|
|
26550
|
-
if (isFieldName(line, fieldLength, ID)) {
|
|
26551
|
-
if (isValidLastEventIdBytes(line, valueStart)) {
|
|
26552
|
-
event.id = line.toString('utf8', valueStart);
|
|
26553
|
-
}
|
|
26554
|
-
return
|
|
26555
|
-
}
|
|
26529
|
+
// TODO: Investigate if there is a more performant way to extract the
|
|
26530
|
+
// value
|
|
26531
|
+
// see: https://github.com/nodejs/undici/issues/2630
|
|
26532
|
+
value = line.subarray(valueStart).toString('utf8');
|
|
26556
26533
|
|
|
26557
|
-
|
|
26558
|
-
|
|
26559
|
-
|
|
26560
|
-
|
|
26561
|
-
|
|
26562
|
-
|
|
26534
|
+
// Otherwise, the string is not empty but does not contain a U+003A COLON
|
|
26535
|
+
// character (:)
|
|
26536
|
+
} else {
|
|
26537
|
+
// Process the field using the steps described below, using the whole
|
|
26538
|
+
// line as the field name, and the empty string as the field value.
|
|
26539
|
+
field = line.toString('utf8');
|
|
26540
|
+
value = '';
|
|
26541
|
+
}
|
|
26542
|
+
|
|
26543
|
+
// Modify the event with the field name and value. The value is also
|
|
26544
|
+
// decoded as UTF-8
|
|
26545
|
+
switch (field) {
|
|
26546
|
+
case 'data':
|
|
26547
|
+
if (event[field] === undefined) {
|
|
26548
|
+
event[field] = value;
|
|
26549
|
+
} else {
|
|
26550
|
+
event[field] += `\n${value}`;
|
|
26551
|
+
}
|
|
26552
|
+
break
|
|
26553
|
+
case 'retry':
|
|
26554
|
+
if (isASCIINumber(value)) {
|
|
26555
|
+
event[field] = value;
|
|
26556
|
+
}
|
|
26557
|
+
break
|
|
26558
|
+
case 'id':
|
|
26559
|
+
if (isValidLastEventId(value)) {
|
|
26560
|
+
event[field] = value;
|
|
26561
|
+
}
|
|
26562
|
+
break
|
|
26563
|
+
case 'event':
|
|
26564
|
+
if (value.length > 0) {
|
|
26565
|
+
event[field] = value;
|
|
26566
|
+
}
|
|
26567
|
+
break
|
|
26563
26568
|
}
|
|
26564
26569
|
}
|
|
26565
26570
|
|
|
@@ -26589,151 +26594,12 @@ function requireEventsourceStream () {
|
|
|
26589
26594
|
}
|
|
26590
26595
|
|
|
26591
26596
|
clearEvent () {
|
|
26592
|
-
this.event
|
|
26593
|
-
|
|
26594
|
-
|
|
26595
|
-
|
|
26596
|
-
|
|
26597
|
-
|
|
26598
|
-
hasPendingEvent () {
|
|
26599
|
-
return this.event.data !== undefined ||
|
|
26600
|
-
this.event.event !== undefined ||
|
|
26601
|
-
this.event.id !== undefined ||
|
|
26602
|
-
this.event.retry !== undefined
|
|
26603
|
-
}
|
|
26604
|
-
|
|
26605
|
-
hasCurrentByte () {
|
|
26606
|
-
return this.chunkIndex < this.chunks.length &&
|
|
26607
|
-
this.pos < this.chunks[this.chunkIndex].length
|
|
26608
|
-
}
|
|
26609
|
-
|
|
26610
|
-
currentByte () {
|
|
26611
|
-
return this.chunks[this.chunkIndex][this.pos]
|
|
26612
|
-
}
|
|
26613
|
-
|
|
26614
|
-
consumeCurrentByte () {
|
|
26615
|
-
this.advanceCursor();
|
|
26616
|
-
this.syncLineStartToCursor();
|
|
26617
|
-
}
|
|
26618
|
-
|
|
26619
|
-
advanceCursor () {
|
|
26620
|
-
this.pos++;
|
|
26621
|
-
|
|
26622
|
-
while (this.chunkIndex < this.chunks.length && this.pos >= this.chunks[this.chunkIndex].length) {
|
|
26623
|
-
this.chunkIndex++;
|
|
26624
|
-
this.pos = 0;
|
|
26625
|
-
}
|
|
26626
|
-
}
|
|
26627
|
-
|
|
26628
|
-
syncLineStartToCursor () {
|
|
26629
|
-
this.lineChunkIndex = this.chunkIndex;
|
|
26630
|
-
this.linePos = this.pos;
|
|
26631
|
-
this.dropConsumedChunks();
|
|
26632
|
-
}
|
|
26633
|
-
|
|
26634
|
-
dropConsumedChunks () {
|
|
26635
|
-
while (this.lineChunkIndex > 0) {
|
|
26636
|
-
this.chunks.shift();
|
|
26637
|
-
this.lineChunkIndex--;
|
|
26638
|
-
this.chunkIndex--;
|
|
26639
|
-
}
|
|
26640
|
-
|
|
26641
|
-
if (this.chunkIndex === this.chunks.length) {
|
|
26642
|
-
this.chunks.length = 0;
|
|
26643
|
-
this.chunkIndex = 0;
|
|
26644
|
-
this.pos = 0;
|
|
26645
|
-
this.lineChunkIndex = 0;
|
|
26646
|
-
this.linePos = 0;
|
|
26647
|
-
}
|
|
26648
|
-
}
|
|
26649
|
-
|
|
26650
|
-
readLine () {
|
|
26651
|
-
if (this.lineChunkIndex === this.chunkIndex) {
|
|
26652
|
-
return this.chunks[this.chunkIndex].subarray(this.linePos, this.pos)
|
|
26653
|
-
}
|
|
26654
|
-
|
|
26655
|
-
const chunks = [];
|
|
26656
|
-
let length = 0;
|
|
26657
|
-
|
|
26658
|
-
for (let i = this.lineChunkIndex; i <= this.chunkIndex; i++) {
|
|
26659
|
-
const chunk = this.chunks[i];
|
|
26660
|
-
const start = i === this.lineChunkIndex ? this.linePos : 0;
|
|
26661
|
-
const end = i === this.chunkIndex ? this.pos : chunk.length;
|
|
26662
|
-
const slice = chunk.subarray(start, end);
|
|
26663
|
-
length += slice.length;
|
|
26664
|
-
chunks.push(slice);
|
|
26665
|
-
}
|
|
26666
|
-
|
|
26667
|
-
return Buffer.concat(chunks, length)
|
|
26668
|
-
}
|
|
26669
|
-
|
|
26670
|
-
peekBufferedByte (offset) {
|
|
26671
|
-
let chunkIndex = this.lineChunkIndex;
|
|
26672
|
-
let pos = this.linePos;
|
|
26673
|
-
|
|
26674
|
-
while (chunkIndex < this.chunks.length) {
|
|
26675
|
-
const chunk = this.chunks[chunkIndex];
|
|
26676
|
-
const remaining = chunk.length - pos;
|
|
26677
|
-
|
|
26678
|
-
if (offset < remaining) {
|
|
26679
|
-
return chunk[pos + offset]
|
|
26680
|
-
}
|
|
26681
|
-
|
|
26682
|
-
offset -= remaining;
|
|
26683
|
-
chunkIndex++;
|
|
26684
|
-
pos = 0;
|
|
26685
|
-
}
|
|
26686
|
-
}
|
|
26687
|
-
|
|
26688
|
-
discardLeadingBytes (count) {
|
|
26689
|
-
while (count > 0 && this.lineChunkIndex < this.chunks.length) {
|
|
26690
|
-
const chunk = this.chunks[this.lineChunkIndex];
|
|
26691
|
-
const remaining = chunk.length - this.linePos;
|
|
26692
|
-
|
|
26693
|
-
if (count < remaining) {
|
|
26694
|
-
this.linePos += count;
|
|
26695
|
-
count = 0;
|
|
26696
|
-
} else {
|
|
26697
|
-
count -= remaining;
|
|
26698
|
-
this.lineChunkIndex++;
|
|
26699
|
-
this.linePos = 0;
|
|
26700
|
-
}
|
|
26701
|
-
}
|
|
26702
|
-
|
|
26703
|
-
this.chunkIndex = this.lineChunkIndex;
|
|
26704
|
-
this.pos = this.linePos;
|
|
26705
|
-
this.dropConsumedChunks();
|
|
26706
|
-
}
|
|
26707
|
-
|
|
26708
|
-
handleBOM () {
|
|
26709
|
-
const first = this.peekBufferedByte(0);
|
|
26710
|
-
const second = this.peekBufferedByte(1);
|
|
26711
|
-
const third = this.peekBufferedByte(2);
|
|
26712
|
-
|
|
26713
|
-
if (second === undefined) {
|
|
26714
|
-
if (first === BOM[0]) {
|
|
26715
|
-
return true
|
|
26716
|
-
}
|
|
26717
|
-
|
|
26718
|
-
this.checkBOM = false;
|
|
26719
|
-
return true
|
|
26720
|
-
}
|
|
26721
|
-
|
|
26722
|
-
if (third === undefined) {
|
|
26723
|
-
if (first === BOM[0] && second === BOM[1]) {
|
|
26724
|
-
return true
|
|
26725
|
-
}
|
|
26726
|
-
|
|
26727
|
-
this.checkBOM = false;
|
|
26728
|
-
return false
|
|
26729
|
-
}
|
|
26730
|
-
|
|
26731
|
-
if (first === BOM[0] && second === BOM[1] && third === BOM[2]) {
|
|
26732
|
-
this.discardLeadingBytes(3);
|
|
26733
|
-
}
|
|
26734
|
-
|
|
26735
|
-
this.checkBOM = false;
|
|
26736
|
-
return !this.hasCurrentByte()
|
|
26597
|
+
this.event = {
|
|
26598
|
+
data: undefined,
|
|
26599
|
+
event: undefined,
|
|
26600
|
+
id: undefined,
|
|
26601
|
+
retry: undefined
|
|
26602
|
+
};
|
|
26737
26603
|
}
|
|
26738
26604
|
}
|
|
26739
26605
|
|
|
@@ -27453,4 +27319,4 @@ var index = /*#__PURE__*/_mergeNamespaces({
|
|
|
27453
27319
|
}, [undici]);
|
|
27454
27320
|
|
|
27455
27321
|
export { index as i };
|
|
27456
|
-
//# sourceMappingURL=index-
|
|
27322
|
+
//# sourceMappingURL=index-PztyZob7.mjs.map
|