@junando/webhook 0.14.0 → 0.15.1
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/{checksum-Conn-Zv6.cjs → event-streams-BNpVWorN.cjs} +1005 -32
- package/dist/handler.cjs +8453 -1144
- package/package.json +3 -3
- package/dist/dist-DV15lRHH.cjs +0 -1463
- package/dist/event-streams-D4zq5a68.cjs +0 -978
|
@@ -5639,7 +5639,7 @@ var init_evaluateRules = require_rolldown_runtime.__esmMin((() => {
|
|
|
5639
5639
|
|
|
5640
5640
|
//#endregion
|
|
5641
5641
|
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/utils/index.js
|
|
5642
|
-
var init_utils = require_rolldown_runtime.__esmMin((() => {
|
|
5642
|
+
var init_utils$1 = require_rolldown_runtime.__esmMin((() => {
|
|
5643
5643
|
init_customEndpointFunctions();
|
|
5644
5644
|
init_evaluateRules();
|
|
5645
5645
|
}));
|
|
@@ -5651,7 +5651,7 @@ var init_resolveEndpoint = require_rolldown_runtime.__esmMin((() => {
|
|
|
5651
5651
|
init_transport();
|
|
5652
5652
|
init_debug();
|
|
5653
5653
|
init_types();
|
|
5654
|
-
init_utils();
|
|
5654
|
+
init_utils$1();
|
|
5655
5655
|
resolveEndpoint = (ruleSetObject, options) => {
|
|
5656
5656
|
const { endpointParams, logger } = options;
|
|
5657
5657
|
const { parameters, rules } = ruleSetObject;
|
|
@@ -7428,6 +7428,997 @@ var init_checksum = require_rolldown_runtime.__esmMin((() => {
|
|
|
7428
7428
|
init_chunked_blob_reader();
|
|
7429
7429
|
}));
|
|
7430
7430
|
|
|
7431
|
+
//#endregion
|
|
7432
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/Int64.js
|
|
7433
|
+
function negate(bytes) {
|
|
7434
|
+
for (let i = 0; i < 8; i++) {
|
|
7435
|
+
bytes[i] ^= 255;
|
|
7436
|
+
}
|
|
7437
|
+
for (let i = 7; i > -1; i--) {
|
|
7438
|
+
bytes[i]++;
|
|
7439
|
+
if (bytes[i] !== 0) break;
|
|
7440
|
+
}
|
|
7441
|
+
}
|
|
7442
|
+
var Int64;
|
|
7443
|
+
var init_Int64 = require_rolldown_runtime.__esmMin((() => {
|
|
7444
|
+
init_serde();
|
|
7445
|
+
Int64 = class Int64 {
|
|
7446
|
+
bytes;
|
|
7447
|
+
constructor(bytes) {
|
|
7448
|
+
this.bytes = bytes;
|
|
7449
|
+
if (bytes.byteLength !== 8) {
|
|
7450
|
+
throw new Error("Int64 buffers must be exactly 8 bytes");
|
|
7451
|
+
}
|
|
7452
|
+
}
|
|
7453
|
+
static fromNumber(number) {
|
|
7454
|
+
if (number > 0x8000000000000000 || number < -0x8000000000000000) {
|
|
7455
|
+
throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
|
|
7456
|
+
}
|
|
7457
|
+
const bytes = new Uint8Array(8);
|
|
7458
|
+
for (let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {
|
|
7459
|
+
bytes[i] = remaining;
|
|
7460
|
+
}
|
|
7461
|
+
if (number < 0) {
|
|
7462
|
+
negate(bytes);
|
|
7463
|
+
}
|
|
7464
|
+
return new Int64(bytes);
|
|
7465
|
+
}
|
|
7466
|
+
valueOf() {
|
|
7467
|
+
const bytes = this.bytes.slice(0);
|
|
7468
|
+
const negative = bytes[0] & 128;
|
|
7469
|
+
if (negative) {
|
|
7470
|
+
negate(bytes);
|
|
7471
|
+
}
|
|
7472
|
+
return parseInt(toHex(bytes), 16) * (negative ? -1 : 1);
|
|
7473
|
+
}
|
|
7474
|
+
toString() {
|
|
7475
|
+
return String(this.valueOf());
|
|
7476
|
+
}
|
|
7477
|
+
};
|
|
7478
|
+
}));
|
|
7479
|
+
|
|
7480
|
+
//#endregion
|
|
7481
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js
|
|
7482
|
+
var HeaderMarshaller, HEADER_VALUE_TYPE, BOOLEAN_TAG, BYTE_TAG, SHORT_TAG, INT_TAG, LONG_TAG, BINARY_TAG, STRING_TAG, TIMESTAMP_TAG, UUID_TAG, UUID_PATTERN;
|
|
7483
|
+
var init_HeaderMarshaller = require_rolldown_runtime.__esmMin((() => {
|
|
7484
|
+
init_transport();
|
|
7485
|
+
init_serde();
|
|
7486
|
+
init_Int64();
|
|
7487
|
+
HeaderMarshaller = class {
|
|
7488
|
+
toUtf8;
|
|
7489
|
+
fromUtf8;
|
|
7490
|
+
constructor(toUtf8, fromUtf8) {
|
|
7491
|
+
this.toUtf8 = toUtf8;
|
|
7492
|
+
this.fromUtf8 = fromUtf8;
|
|
7493
|
+
}
|
|
7494
|
+
format(headers) {
|
|
7495
|
+
const chunks = [];
|
|
7496
|
+
for (const headerName in headers) {
|
|
7497
|
+
if (!hasOwn(headers, headerName)) continue;
|
|
7498
|
+
const bytes = this.fromUtf8(headerName);
|
|
7499
|
+
chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
|
|
7500
|
+
}
|
|
7501
|
+
const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
|
|
7502
|
+
let position = 0;
|
|
7503
|
+
for (const chunk of chunks) {
|
|
7504
|
+
out.set(chunk, position);
|
|
7505
|
+
position += chunk.byteLength;
|
|
7506
|
+
}
|
|
7507
|
+
return out;
|
|
7508
|
+
}
|
|
7509
|
+
formatHeaderValue(header) {
|
|
7510
|
+
switch (header.type) {
|
|
7511
|
+
case "boolean": return Uint8Array.from([header.value ? 0 : 1]);
|
|
7512
|
+
case "byte": return Uint8Array.from([2, header.value]);
|
|
7513
|
+
case "short":
|
|
7514
|
+
const shortView = new DataView(new ArrayBuffer(3));
|
|
7515
|
+
shortView.setUint8(0, 3);
|
|
7516
|
+
shortView.setInt16(1, header.value, false);
|
|
7517
|
+
return new Uint8Array(shortView.buffer);
|
|
7518
|
+
case "integer":
|
|
7519
|
+
const intView = new DataView(new ArrayBuffer(5));
|
|
7520
|
+
intView.setUint8(0, 4);
|
|
7521
|
+
intView.setInt32(1, header.value, false);
|
|
7522
|
+
return new Uint8Array(intView.buffer);
|
|
7523
|
+
case "long":
|
|
7524
|
+
const longBytes = new Uint8Array(9);
|
|
7525
|
+
longBytes[0] = 5;
|
|
7526
|
+
longBytes.set(header.value.bytes, 1);
|
|
7527
|
+
return longBytes;
|
|
7528
|
+
case "binary":
|
|
7529
|
+
const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
|
|
7530
|
+
binView.setUint8(0, 6);
|
|
7531
|
+
binView.setUint16(1, header.value.byteLength, false);
|
|
7532
|
+
const binBytes = new Uint8Array(binView.buffer);
|
|
7533
|
+
binBytes.set(header.value, 3);
|
|
7534
|
+
return binBytes;
|
|
7535
|
+
case "string":
|
|
7536
|
+
const utf8Bytes = this.fromUtf8(header.value);
|
|
7537
|
+
const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
|
|
7538
|
+
strView.setUint8(0, 7);
|
|
7539
|
+
strView.setUint16(1, utf8Bytes.byteLength, false);
|
|
7540
|
+
const strBytes = new Uint8Array(strView.buffer);
|
|
7541
|
+
strBytes.set(utf8Bytes, 3);
|
|
7542
|
+
return strBytes;
|
|
7543
|
+
case "timestamp":
|
|
7544
|
+
const tsBytes = new Uint8Array(9);
|
|
7545
|
+
tsBytes[0] = 8;
|
|
7546
|
+
tsBytes.set(Int64.fromNumber(header.value.valueOf()).bytes, 1);
|
|
7547
|
+
return tsBytes;
|
|
7548
|
+
case "uuid":
|
|
7549
|
+
if (!UUID_PATTERN.test(header.value)) {
|
|
7550
|
+
throw new Error(`Invalid UUID received: ${header.value}`);
|
|
7551
|
+
}
|
|
7552
|
+
const uuidBytes = new Uint8Array(17);
|
|
7553
|
+
uuidBytes[0] = 9;
|
|
7554
|
+
uuidBytes.set(fromHex(header.value.replace(/-/g, "")), 1);
|
|
7555
|
+
return uuidBytes;
|
|
7556
|
+
}
|
|
7557
|
+
}
|
|
7558
|
+
parse(headers) {
|
|
7559
|
+
const out = {};
|
|
7560
|
+
let position = 0;
|
|
7561
|
+
while (position < headers.byteLength) {
|
|
7562
|
+
const nameLength = headers.getUint8(position++);
|
|
7563
|
+
const name = this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, nameLength));
|
|
7564
|
+
position += nameLength;
|
|
7565
|
+
switch (headers.getUint8(position++)) {
|
|
7566
|
+
case 0:
|
|
7567
|
+
out[name] = {
|
|
7568
|
+
type: BOOLEAN_TAG,
|
|
7569
|
+
value: true
|
|
7570
|
+
};
|
|
7571
|
+
break;
|
|
7572
|
+
case 1:
|
|
7573
|
+
out[name] = {
|
|
7574
|
+
type: BOOLEAN_TAG,
|
|
7575
|
+
value: false
|
|
7576
|
+
};
|
|
7577
|
+
break;
|
|
7578
|
+
case 2:
|
|
7579
|
+
out[name] = {
|
|
7580
|
+
type: BYTE_TAG,
|
|
7581
|
+
value: headers.getInt8(position++)
|
|
7582
|
+
};
|
|
7583
|
+
break;
|
|
7584
|
+
case 3:
|
|
7585
|
+
out[name] = {
|
|
7586
|
+
type: SHORT_TAG,
|
|
7587
|
+
value: headers.getInt16(position, false)
|
|
7588
|
+
};
|
|
7589
|
+
position += 2;
|
|
7590
|
+
break;
|
|
7591
|
+
case 4:
|
|
7592
|
+
out[name] = {
|
|
7593
|
+
type: INT_TAG,
|
|
7594
|
+
value: headers.getInt32(position, false)
|
|
7595
|
+
};
|
|
7596
|
+
position += 4;
|
|
7597
|
+
break;
|
|
7598
|
+
case 5:
|
|
7599
|
+
out[name] = {
|
|
7600
|
+
type: LONG_TAG,
|
|
7601
|
+
value: new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8))
|
|
7602
|
+
};
|
|
7603
|
+
position += 8;
|
|
7604
|
+
break;
|
|
7605
|
+
case 6:
|
|
7606
|
+
const binaryLength = headers.getUint16(position, false);
|
|
7607
|
+
position += 2;
|
|
7608
|
+
out[name] = {
|
|
7609
|
+
type: BINARY_TAG,
|
|
7610
|
+
value: new Uint8Array(headers.buffer, headers.byteOffset + position, binaryLength)
|
|
7611
|
+
};
|
|
7612
|
+
position += binaryLength;
|
|
7613
|
+
break;
|
|
7614
|
+
case 7:
|
|
7615
|
+
const stringLength = headers.getUint16(position, false);
|
|
7616
|
+
position += 2;
|
|
7617
|
+
out[name] = {
|
|
7618
|
+
type: STRING_TAG,
|
|
7619
|
+
value: this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, stringLength))
|
|
7620
|
+
};
|
|
7621
|
+
position += stringLength;
|
|
7622
|
+
break;
|
|
7623
|
+
case 8:
|
|
7624
|
+
out[name] = {
|
|
7625
|
+
type: TIMESTAMP_TAG,
|
|
7626
|
+
value: new Date(new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8)).valueOf())
|
|
7627
|
+
};
|
|
7628
|
+
position += 8;
|
|
7629
|
+
break;
|
|
7630
|
+
case 9:
|
|
7631
|
+
const uuidBytes = new Uint8Array(headers.buffer, headers.byteOffset + position, 16);
|
|
7632
|
+
position += 16;
|
|
7633
|
+
out[name] = {
|
|
7634
|
+
type: UUID_TAG,
|
|
7635
|
+
value: `${toHex(uuidBytes.subarray(0, 4))}-${toHex(uuidBytes.subarray(4, 6))}-${toHex(uuidBytes.subarray(6, 8))}-${toHex(uuidBytes.subarray(8, 10))}-${toHex(uuidBytes.subarray(10))}`
|
|
7636
|
+
};
|
|
7637
|
+
break;
|
|
7638
|
+
default: throw new Error(`Unrecognized header type tag`);
|
|
7639
|
+
}
|
|
7640
|
+
}
|
|
7641
|
+
return out;
|
|
7642
|
+
}
|
|
7643
|
+
};
|
|
7644
|
+
;
|
|
7645
|
+
(function(HEADER_VALUE_TYPE) {
|
|
7646
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["boolTrue"] = 0] = "boolTrue";
|
|
7647
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["boolFalse"] = 1] = "boolFalse";
|
|
7648
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["byte"] = 2] = "byte";
|
|
7649
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["short"] = 3] = "short";
|
|
7650
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["integer"] = 4] = "integer";
|
|
7651
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["long"] = 5] = "long";
|
|
7652
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["byteArray"] = 6] = "byteArray";
|
|
7653
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["string"] = 7] = "string";
|
|
7654
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["timestamp"] = 8] = "timestamp";
|
|
7655
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["uuid"] = 9] = "uuid";
|
|
7656
|
+
})(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
|
|
7657
|
+
BOOLEAN_TAG = "boolean";
|
|
7658
|
+
BYTE_TAG = "byte";
|
|
7659
|
+
SHORT_TAG = "short";
|
|
7660
|
+
INT_TAG = "integer";
|
|
7661
|
+
LONG_TAG = "long";
|
|
7662
|
+
BINARY_TAG = "binary";
|
|
7663
|
+
STRING_TAG = "string";
|
|
7664
|
+
TIMESTAMP_TAG = "timestamp";
|
|
7665
|
+
UUID_TAG = "uuid";
|
|
7666
|
+
UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
7667
|
+
}));
|
|
7668
|
+
|
|
7669
|
+
//#endregion
|
|
7670
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js
|
|
7671
|
+
function splitMessage({ byteLength, byteOffset, buffer }) {
|
|
7672
|
+
if (byteLength < MINIMUM_MESSAGE_LENGTH) {
|
|
7673
|
+
throw new Error("Provided message too short to accommodate event stream message overhead");
|
|
7674
|
+
}
|
|
7675
|
+
const view = new DataView(buffer, byteOffset, byteLength);
|
|
7676
|
+
const messageLength = view.getUint32(0, false);
|
|
7677
|
+
if (byteLength !== messageLength) {
|
|
7678
|
+
throw new Error("Reported message length does not match received message length");
|
|
7679
|
+
}
|
|
7680
|
+
const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);
|
|
7681
|
+
const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
|
|
7682
|
+
const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);
|
|
7683
|
+
const checksummer = new Crc32Node();
|
|
7684
|
+
checksummer.update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
|
|
7685
|
+
if (expectedPreludeChecksum !== checksummer.digestSync()) {
|
|
7686
|
+
throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digestSync()})`);
|
|
7687
|
+
}
|
|
7688
|
+
checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH)));
|
|
7689
|
+
if (expectedMessageChecksum !== checksummer.digestSync()) {
|
|
7690
|
+
throw new Error(`The message checksum (${checksummer.digestSync()}) did not match the expected value of ${expectedMessageChecksum}`);
|
|
7691
|
+
}
|
|
7692
|
+
return {
|
|
7693
|
+
headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),
|
|
7694
|
+
body: new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH + headerLength, messageLength - headerLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH + CHECKSUM_LENGTH))
|
|
7695
|
+
};
|
|
7696
|
+
}
|
|
7697
|
+
var PRELUDE_MEMBER_LENGTH, PRELUDE_LENGTH, CHECKSUM_LENGTH, MINIMUM_MESSAGE_LENGTH;
|
|
7698
|
+
var init_splitMessage = require_rolldown_runtime.__esmMin((() => {
|
|
7699
|
+
init_checksum();
|
|
7700
|
+
PRELUDE_MEMBER_LENGTH = 4;
|
|
7701
|
+
PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
|
|
7702
|
+
CHECKSUM_LENGTH = 4;
|
|
7703
|
+
MINIMUM_MESSAGE_LENGTH = PRELUDE_LENGTH + CHECKSUM_LENGTH * 2;
|
|
7704
|
+
}));
|
|
7705
|
+
|
|
7706
|
+
//#endregion
|
|
7707
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js
|
|
7708
|
+
var EventStreamCodec;
|
|
7709
|
+
var init_EventStreamCodec = require_rolldown_runtime.__esmMin((() => {
|
|
7710
|
+
init_checksum();
|
|
7711
|
+
init_HeaderMarshaller();
|
|
7712
|
+
init_splitMessage();
|
|
7713
|
+
EventStreamCodec = class {
|
|
7714
|
+
headerMarshaller;
|
|
7715
|
+
messageBuffer;
|
|
7716
|
+
isEndOfStream;
|
|
7717
|
+
constructor(toUtf8, fromUtf8) {
|
|
7718
|
+
this.headerMarshaller = new HeaderMarshaller(toUtf8, fromUtf8);
|
|
7719
|
+
this.messageBuffer = [];
|
|
7720
|
+
this.isEndOfStream = false;
|
|
7721
|
+
}
|
|
7722
|
+
feed(message) {
|
|
7723
|
+
this.messageBuffer.push(this.decode(message));
|
|
7724
|
+
}
|
|
7725
|
+
endOfStream() {
|
|
7726
|
+
this.isEndOfStream = true;
|
|
7727
|
+
}
|
|
7728
|
+
getMessage() {
|
|
7729
|
+
const message = this.messageBuffer.pop();
|
|
7730
|
+
const isEndOfStream = this.isEndOfStream;
|
|
7731
|
+
return {
|
|
7732
|
+
getMessage() {
|
|
7733
|
+
return message;
|
|
7734
|
+
},
|
|
7735
|
+
isEndOfStream() {
|
|
7736
|
+
return isEndOfStream;
|
|
7737
|
+
}
|
|
7738
|
+
};
|
|
7739
|
+
}
|
|
7740
|
+
getAvailableMessages() {
|
|
7741
|
+
const messages = this.messageBuffer;
|
|
7742
|
+
this.messageBuffer = [];
|
|
7743
|
+
const isEndOfStream = this.isEndOfStream;
|
|
7744
|
+
return {
|
|
7745
|
+
getMessages() {
|
|
7746
|
+
return messages;
|
|
7747
|
+
},
|
|
7748
|
+
isEndOfStream() {
|
|
7749
|
+
return isEndOfStream;
|
|
7750
|
+
}
|
|
7751
|
+
};
|
|
7752
|
+
}
|
|
7753
|
+
encode({ headers: rawHeaders, body }) {
|
|
7754
|
+
const headers = this.headerMarshaller.format(rawHeaders);
|
|
7755
|
+
const length = headers.byteLength + body.byteLength + 16;
|
|
7756
|
+
const out = new Uint8Array(length);
|
|
7757
|
+
const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
|
|
7758
|
+
const checksum = new Crc32Node();
|
|
7759
|
+
view.setUint32(0, length, false);
|
|
7760
|
+
view.setUint32(4, headers.byteLength, false);
|
|
7761
|
+
checksum.update(out.subarray(0, 8));
|
|
7762
|
+
view.setUint32(8, checksum.digestSync(), false);
|
|
7763
|
+
out.set(headers, 12);
|
|
7764
|
+
out.set(body, headers.byteLength + 12);
|
|
7765
|
+
checksum.update(out.subarray(8, length - 4));
|
|
7766
|
+
view.setUint32(length - 4, checksum.digestSync(), false);
|
|
7767
|
+
return out;
|
|
7768
|
+
}
|
|
7769
|
+
decode(message) {
|
|
7770
|
+
const { headers, body } = splitMessage(message);
|
|
7771
|
+
return {
|
|
7772
|
+
headers: this.headerMarshaller.parse(headers),
|
|
7773
|
+
body
|
|
7774
|
+
};
|
|
7775
|
+
}
|
|
7776
|
+
formatHeaders(rawHeaders) {
|
|
7777
|
+
return this.headerMarshaller.format(rawHeaders);
|
|
7778
|
+
}
|
|
7779
|
+
};
|
|
7780
|
+
}));
|
|
7781
|
+
|
|
7782
|
+
//#endregion
|
|
7783
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageDecoderStream.js
|
|
7784
|
+
var MessageDecoderStream;
|
|
7785
|
+
var init_MessageDecoderStream = require_rolldown_runtime.__esmMin((() => {
|
|
7786
|
+
MessageDecoderStream = class {
|
|
7787
|
+
options;
|
|
7788
|
+
constructor(options) {
|
|
7789
|
+
this.options = options;
|
|
7790
|
+
}
|
|
7791
|
+
[Symbol.asyncIterator]() {
|
|
7792
|
+
return this.asyncIterator();
|
|
7793
|
+
}
|
|
7794
|
+
async *asyncIterator() {
|
|
7795
|
+
for await (const bytes of this.options.inputStream) {
|
|
7796
|
+
const decoded = this.options.decoder.decode(bytes);
|
|
7797
|
+
yield decoded;
|
|
7798
|
+
}
|
|
7799
|
+
}
|
|
7800
|
+
};
|
|
7801
|
+
}));
|
|
7802
|
+
|
|
7803
|
+
//#endregion
|
|
7804
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageEncoderStream.js
|
|
7805
|
+
var MessageEncoderStream;
|
|
7806
|
+
var init_MessageEncoderStream = require_rolldown_runtime.__esmMin((() => {
|
|
7807
|
+
MessageEncoderStream = class {
|
|
7808
|
+
options;
|
|
7809
|
+
constructor(options) {
|
|
7810
|
+
this.options = options;
|
|
7811
|
+
}
|
|
7812
|
+
[Symbol.asyncIterator]() {
|
|
7813
|
+
return this.asyncIterator();
|
|
7814
|
+
}
|
|
7815
|
+
async *asyncIterator() {
|
|
7816
|
+
for await (const msg of this.options.messageStream) {
|
|
7817
|
+
const encoded = this.options.encoder.encode(msg);
|
|
7818
|
+
yield encoded;
|
|
7819
|
+
}
|
|
7820
|
+
if (this.options.includeEndFrame) {
|
|
7821
|
+
yield new Uint8Array(0);
|
|
7822
|
+
}
|
|
7823
|
+
}
|
|
7824
|
+
};
|
|
7825
|
+
}));
|
|
7826
|
+
|
|
7827
|
+
//#endregion
|
|
7828
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageDecoderStream.js
|
|
7829
|
+
var SmithyMessageDecoderStream;
|
|
7830
|
+
var init_SmithyMessageDecoderStream = require_rolldown_runtime.__esmMin((() => {
|
|
7831
|
+
SmithyMessageDecoderStream = class {
|
|
7832
|
+
options;
|
|
7833
|
+
constructor(options) {
|
|
7834
|
+
this.options = options;
|
|
7835
|
+
}
|
|
7836
|
+
[Symbol.asyncIterator]() {
|
|
7837
|
+
return this.asyncIterator();
|
|
7838
|
+
}
|
|
7839
|
+
async *asyncIterator() {
|
|
7840
|
+
for await (const message of this.options.messageStream) {
|
|
7841
|
+
const deserialized = await this.options.deserializer(message);
|
|
7842
|
+
if (deserialized === undefined) continue;
|
|
7843
|
+
yield deserialized;
|
|
7844
|
+
}
|
|
7845
|
+
}
|
|
7846
|
+
};
|
|
7847
|
+
}));
|
|
7848
|
+
|
|
7849
|
+
//#endregion
|
|
7850
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageEncoderStream.js
|
|
7851
|
+
var SmithyMessageEncoderStream;
|
|
7852
|
+
var init_SmithyMessageEncoderStream = require_rolldown_runtime.__esmMin((() => {
|
|
7853
|
+
SmithyMessageEncoderStream = class {
|
|
7854
|
+
options;
|
|
7855
|
+
constructor(options) {
|
|
7856
|
+
this.options = options;
|
|
7857
|
+
}
|
|
7858
|
+
[Symbol.asyncIterator]() {
|
|
7859
|
+
return this.asyncIterator();
|
|
7860
|
+
}
|
|
7861
|
+
async *asyncIterator() {
|
|
7862
|
+
for await (const chunk of this.options.inputStream) {
|
|
7863
|
+
const payloadBuf = this.options.serializer(chunk);
|
|
7864
|
+
yield payloadBuf;
|
|
7865
|
+
}
|
|
7866
|
+
}
|
|
7867
|
+
};
|
|
7868
|
+
}));
|
|
7869
|
+
|
|
7870
|
+
//#endregion
|
|
7871
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getChunkedStream.js
|
|
7872
|
+
function getChunkedStream(source) {
|
|
7873
|
+
let currentMessageTotalLength = 0;
|
|
7874
|
+
let currentMessagePendingLength = 0;
|
|
7875
|
+
let currentMessage = null;
|
|
7876
|
+
let messageLengthBuffer = null;
|
|
7877
|
+
const allocateMessage = (size) => {
|
|
7878
|
+
if (typeof size !== "number") {
|
|
7879
|
+
throw new Error("Attempted to allocate an event message where size was not a number: " + size);
|
|
7880
|
+
}
|
|
7881
|
+
currentMessageTotalLength = size;
|
|
7882
|
+
currentMessagePendingLength = 4;
|
|
7883
|
+
currentMessage = new Uint8Array(size);
|
|
7884
|
+
const currentMessageView = new DataView(currentMessage.buffer);
|
|
7885
|
+
currentMessageView.setUint32(0, size, false);
|
|
7886
|
+
};
|
|
7887
|
+
const iterator = async function* () {
|
|
7888
|
+
const sourceIterator = source[Symbol.asyncIterator]();
|
|
7889
|
+
while (true) {
|
|
7890
|
+
const { value, done } = await sourceIterator.next();
|
|
7891
|
+
if (done) {
|
|
7892
|
+
if (!currentMessageTotalLength) {
|
|
7893
|
+
return;
|
|
7894
|
+
} else if (currentMessageTotalLength === currentMessagePendingLength) {
|
|
7895
|
+
yield currentMessage;
|
|
7896
|
+
} else {
|
|
7897
|
+
throw new Error("Truncated event message received.");
|
|
7898
|
+
}
|
|
7899
|
+
return;
|
|
7900
|
+
}
|
|
7901
|
+
const chunkLength = value.length;
|
|
7902
|
+
let currentOffset = 0;
|
|
7903
|
+
while (currentOffset < chunkLength) {
|
|
7904
|
+
if (!currentMessage) {
|
|
7905
|
+
const bytesRemaining = chunkLength - currentOffset;
|
|
7906
|
+
if (!messageLengthBuffer) {
|
|
7907
|
+
messageLengthBuffer = new Uint8Array(4);
|
|
7908
|
+
}
|
|
7909
|
+
const numBytesForTotal = Math.min(4 - currentMessagePendingLength, bytesRemaining);
|
|
7910
|
+
messageLengthBuffer.set(value.slice(currentOffset, currentOffset + numBytesForTotal), currentMessagePendingLength);
|
|
7911
|
+
currentMessagePendingLength += numBytesForTotal;
|
|
7912
|
+
currentOffset += numBytesForTotal;
|
|
7913
|
+
if (currentMessagePendingLength < 4) {
|
|
7914
|
+
break;
|
|
7915
|
+
}
|
|
7916
|
+
allocateMessage(new DataView(messageLengthBuffer.buffer).getUint32(0, false));
|
|
7917
|
+
messageLengthBuffer = null;
|
|
7918
|
+
}
|
|
7919
|
+
const numBytesToWrite = Math.min(currentMessageTotalLength - currentMessagePendingLength, chunkLength - currentOffset);
|
|
7920
|
+
currentMessage.set(value.slice(currentOffset, currentOffset + numBytesToWrite), currentMessagePendingLength);
|
|
7921
|
+
currentMessagePendingLength += numBytesToWrite;
|
|
7922
|
+
currentOffset += numBytesToWrite;
|
|
7923
|
+
if (currentMessageTotalLength && currentMessageTotalLength === currentMessagePendingLength) {
|
|
7924
|
+
yield currentMessage;
|
|
7925
|
+
currentMessage = null;
|
|
7926
|
+
currentMessageTotalLength = 0;
|
|
7927
|
+
currentMessagePendingLength = 0;
|
|
7928
|
+
}
|
|
7929
|
+
}
|
|
7930
|
+
}
|
|
7931
|
+
};
|
|
7932
|
+
return { [Symbol.asyncIterator]: iterator };
|
|
7933
|
+
}
|
|
7934
|
+
var init_getChunkedStream = require_rolldown_runtime.__esmMin((() => {}));
|
|
7935
|
+
|
|
7936
|
+
//#endregion
|
|
7937
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getUnmarshalledStream.js
|
|
7938
|
+
function getUnmarshalledStream(source, options) {
|
|
7939
|
+
const messageUnmarshaller = getMessageUnmarshaller(options.deserializer, options.toUtf8);
|
|
7940
|
+
return { [Symbol.asyncIterator]: async function* () {
|
|
7941
|
+
for await (const chunk of source) {
|
|
7942
|
+
const message = options.eventStreamCodec.decode(chunk);
|
|
7943
|
+
const type = await messageUnmarshaller(message);
|
|
7944
|
+
if (type === undefined) continue;
|
|
7945
|
+
yield type;
|
|
7946
|
+
}
|
|
7947
|
+
} };
|
|
7948
|
+
}
|
|
7949
|
+
function getMessageUnmarshaller(deserializer, toUtf8) {
|
|
7950
|
+
return async function(message) {
|
|
7951
|
+
const { value: messageType } = message.headers[":message-type"];
|
|
7952
|
+
if (messageType === "error") {
|
|
7953
|
+
const unmodeledError = new Error(message.headers[":error-message"].value || "UnknownError");
|
|
7954
|
+
unmodeledError.name = message.headers[":error-code"].value;
|
|
7955
|
+
throw unmodeledError;
|
|
7956
|
+
} else if (messageType === "exception") {
|
|
7957
|
+
const code = message.headers[":exception-type"].value;
|
|
7958
|
+
const exception = { [code]: message };
|
|
7959
|
+
const deserializedException = await deserializer(exception);
|
|
7960
|
+
if (deserializedException.$unknown) {
|
|
7961
|
+
const error = new Error(toUtf8(message.body));
|
|
7962
|
+
error.name = code;
|
|
7963
|
+
throw error;
|
|
7964
|
+
}
|
|
7965
|
+
throw deserializedException[code];
|
|
7966
|
+
} else if (messageType === "event") {
|
|
7967
|
+
const event = { [message.headers[":event-type"].value]: message };
|
|
7968
|
+
const deserialized = await deserializer(event);
|
|
7969
|
+
if (deserialized.$unknown) return;
|
|
7970
|
+
return deserialized;
|
|
7971
|
+
} else {
|
|
7972
|
+
throw Error(`Unrecognizable event type: ${message.headers[":event-type"].value}`);
|
|
7973
|
+
}
|
|
7974
|
+
};
|
|
7975
|
+
}
|
|
7976
|
+
var init_getUnmarshalledStream = require_rolldown_runtime.__esmMin((() => {}));
|
|
7977
|
+
|
|
7978
|
+
//#endregion
|
|
7979
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/EventStreamMarshaller.js
|
|
7980
|
+
var EventStreamMarshaller$1, eventStreamSerdeProvider$1;
|
|
7981
|
+
var init_EventStreamMarshaller$1 = require_rolldown_runtime.__esmMin((() => {
|
|
7982
|
+
init_EventStreamCodec();
|
|
7983
|
+
init_MessageDecoderStream();
|
|
7984
|
+
init_MessageEncoderStream();
|
|
7985
|
+
init_SmithyMessageDecoderStream();
|
|
7986
|
+
init_SmithyMessageEncoderStream();
|
|
7987
|
+
init_getChunkedStream();
|
|
7988
|
+
init_getUnmarshalledStream();
|
|
7989
|
+
EventStreamMarshaller$1 = class {
|
|
7990
|
+
eventStreamCodec;
|
|
7991
|
+
utfEncoder;
|
|
7992
|
+
constructor({ utf8Encoder, utf8Decoder }) {
|
|
7993
|
+
this.eventStreamCodec = new EventStreamCodec(utf8Encoder, utf8Decoder);
|
|
7994
|
+
this.utfEncoder = utf8Encoder;
|
|
7995
|
+
}
|
|
7996
|
+
deserialize(body, deserializer) {
|
|
7997
|
+
const inputStream = getChunkedStream(body);
|
|
7998
|
+
return new SmithyMessageDecoderStream({
|
|
7999
|
+
messageStream: new MessageDecoderStream({
|
|
8000
|
+
inputStream,
|
|
8001
|
+
decoder: this.eventStreamCodec
|
|
8002
|
+
}),
|
|
8003
|
+
deserializer: getMessageUnmarshaller(deserializer, this.utfEncoder)
|
|
8004
|
+
});
|
|
8005
|
+
}
|
|
8006
|
+
serialize(inputStream, serializer) {
|
|
8007
|
+
return new MessageEncoderStream({
|
|
8008
|
+
messageStream: new SmithyMessageEncoderStream({
|
|
8009
|
+
inputStream,
|
|
8010
|
+
serializer
|
|
8011
|
+
}),
|
|
8012
|
+
encoder: this.eventStreamCodec,
|
|
8013
|
+
includeEndFrame: true
|
|
8014
|
+
});
|
|
8015
|
+
}
|
|
8016
|
+
};
|
|
8017
|
+
eventStreamSerdeProvider$1 = (options) => new EventStreamMarshaller$1(options);
|
|
8018
|
+
}));
|
|
8019
|
+
|
|
8020
|
+
//#endregion
|
|
8021
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
|
|
8022
|
+
async function* readableToIterable(readStream) {
|
|
8023
|
+
let streamEnded = false;
|
|
8024
|
+
let generationEnded = false;
|
|
8025
|
+
const records = new Array();
|
|
8026
|
+
readStream.on("error", (err) => {
|
|
8027
|
+
if (!streamEnded) {
|
|
8028
|
+
streamEnded = true;
|
|
8029
|
+
}
|
|
8030
|
+
if (err) {
|
|
8031
|
+
throw err;
|
|
8032
|
+
}
|
|
8033
|
+
});
|
|
8034
|
+
readStream.on("data", (data) => {
|
|
8035
|
+
records.push(data);
|
|
8036
|
+
});
|
|
8037
|
+
readStream.on("end", () => {
|
|
8038
|
+
streamEnded = true;
|
|
8039
|
+
});
|
|
8040
|
+
while (!generationEnded) {
|
|
8041
|
+
const value = await new Promise((resolve) => setTimeout(() => resolve(records.shift()), 0));
|
|
8042
|
+
if (value) {
|
|
8043
|
+
yield value;
|
|
8044
|
+
}
|
|
8045
|
+
generationEnded = streamEnded && records.length === 0;
|
|
8046
|
+
}
|
|
8047
|
+
}
|
|
8048
|
+
var EventStreamMarshaller, eventStreamSerdeProvider;
|
|
8049
|
+
var init_EventStreamMarshaller = require_rolldown_runtime.__esmMin((() => {
|
|
8050
|
+
init_EventStreamMarshaller$1();
|
|
8051
|
+
EventStreamMarshaller = class {
|
|
8052
|
+
universalMarshaller;
|
|
8053
|
+
constructor({ utf8Encoder, utf8Decoder }) {
|
|
8054
|
+
this.universalMarshaller = new EventStreamMarshaller$1({
|
|
8055
|
+
utf8Decoder,
|
|
8056
|
+
utf8Encoder
|
|
8057
|
+
});
|
|
8058
|
+
}
|
|
8059
|
+
deserialize(body, deserializer) {
|
|
8060
|
+
const bodyIterable = typeof body[Symbol.asyncIterator] === "function" ? body : readableToIterable(body);
|
|
8061
|
+
return this.universalMarshaller.deserialize(bodyIterable, deserializer);
|
|
8062
|
+
}
|
|
8063
|
+
serialize(input, serializer) {
|
|
8064
|
+
return node_stream.Readable.from(this.universalMarshaller.serialize(input, serializer));
|
|
8065
|
+
}
|
|
8066
|
+
};
|
|
8067
|
+
eventStreamSerdeProvider = (options) => new EventStreamMarshaller(options);
|
|
8068
|
+
}));
|
|
8069
|
+
|
|
8070
|
+
//#endregion
|
|
8071
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/utils.js
|
|
8072
|
+
var readableStreamToIterable, iterableToReadableStream;
|
|
8073
|
+
var init_utils = require_rolldown_runtime.__esmMin((() => {
|
|
8074
|
+
readableStreamToIterable = (readableStream) => ({ [Symbol.asyncIterator]: async function* () {
|
|
8075
|
+
const reader = readableStream.getReader();
|
|
8076
|
+
try {
|
|
8077
|
+
while (true) {
|
|
8078
|
+
const { done, value } = await reader.read();
|
|
8079
|
+
if (done) return;
|
|
8080
|
+
yield value;
|
|
8081
|
+
}
|
|
8082
|
+
} finally {
|
|
8083
|
+
reader.releaseLock();
|
|
8084
|
+
}
|
|
8085
|
+
} });
|
|
8086
|
+
iterableToReadableStream = (asyncIterable) => {
|
|
8087
|
+
const iterator = asyncIterable[Symbol.asyncIterator]();
|
|
8088
|
+
return new ReadableStream({ async pull(controller) {
|
|
8089
|
+
const { done, value } = await iterator.next();
|
|
8090
|
+
if (done) {
|
|
8091
|
+
return controller.close();
|
|
8092
|
+
}
|
|
8093
|
+
controller.enqueue(value);
|
|
8094
|
+
} });
|
|
8095
|
+
};
|
|
8096
|
+
}));
|
|
8097
|
+
|
|
8098
|
+
//#endregion
|
|
8099
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-config-resolver/EventStreamSerdeConfig.js
|
|
8100
|
+
var resolveEventStreamSerdeConfig;
|
|
8101
|
+
var init_EventStreamSerdeConfig = require_rolldown_runtime.__esmMin((() => {
|
|
8102
|
+
resolveEventStreamSerdeConfig = (input) => Object.assign(input, { eventStreamMarshaller: input.eventStreamSerdeProvider(input) });
|
|
8103
|
+
}));
|
|
8104
|
+
|
|
8105
|
+
//#endregion
|
|
8106
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js
|
|
8107
|
+
var EventStreamSerde;
|
|
8108
|
+
var init_EventStreamSerde = require_rolldown_runtime.__esmMin((() => {
|
|
8109
|
+
init_transport();
|
|
8110
|
+
init_schema();
|
|
8111
|
+
init_serde();
|
|
8112
|
+
EventStreamSerde = class {
|
|
8113
|
+
marshaller;
|
|
8114
|
+
serializer;
|
|
8115
|
+
deserializer;
|
|
8116
|
+
serdeContext;
|
|
8117
|
+
defaultContentType;
|
|
8118
|
+
compositeErrorRegistry;
|
|
8119
|
+
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, compositeErrorRegistry }) {
|
|
8120
|
+
this.marshaller = marshaller;
|
|
8121
|
+
this.serializer = serializer;
|
|
8122
|
+
this.deserializer = deserializer;
|
|
8123
|
+
this.serdeContext = serdeContext;
|
|
8124
|
+
this.defaultContentType = defaultContentType;
|
|
8125
|
+
this.compositeErrorRegistry = compositeErrorRegistry;
|
|
8126
|
+
}
|
|
8127
|
+
async serializeEventStream({ eventStream, requestSchema, initialRequest, initialMessageType }) {
|
|
8128
|
+
const marshaller = this.marshaller;
|
|
8129
|
+
const eventStreamMember = requestSchema.getEventStreamMember();
|
|
8130
|
+
const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
|
|
8131
|
+
const serializer = this.serializer;
|
|
8132
|
+
const defaultContentType = this.defaultContentType;
|
|
8133
|
+
const initialRequestMarker = Symbol("initialRequestMarker");
|
|
8134
|
+
const eventStreamIterable = { async *[Symbol.asyncIterator]() {
|
|
8135
|
+
if (initialRequest) {
|
|
8136
|
+
const headers = {
|
|
8137
|
+
":event-type": {
|
|
8138
|
+
type: "string",
|
|
8139
|
+
value: initialMessageType ?? "initial-request"
|
|
8140
|
+
},
|
|
8141
|
+
":message-type": {
|
|
8142
|
+
type: "string",
|
|
8143
|
+
value: "event"
|
|
8144
|
+
},
|
|
8145
|
+
":content-type": {
|
|
8146
|
+
type: "string",
|
|
8147
|
+
value: defaultContentType
|
|
8148
|
+
}
|
|
8149
|
+
};
|
|
8150
|
+
serializer.write(requestSchema, initialRequest);
|
|
8151
|
+
const body = serializer.flush();
|
|
8152
|
+
yield {
|
|
8153
|
+
[initialRequestMarker]: true,
|
|
8154
|
+
headers,
|
|
8155
|
+
body
|
|
8156
|
+
};
|
|
8157
|
+
}
|
|
8158
|
+
for await (const page of eventStream) {
|
|
8159
|
+
yield page;
|
|
8160
|
+
}
|
|
8161
|
+
} };
|
|
8162
|
+
return marshaller.serialize(eventStreamIterable, (event) => {
|
|
8163
|
+
if (event[initialRequestMarker]) {
|
|
8164
|
+
return {
|
|
8165
|
+
headers: event.headers,
|
|
8166
|
+
body: event.body
|
|
8167
|
+
};
|
|
8168
|
+
}
|
|
8169
|
+
let unionMember = "";
|
|
8170
|
+
for (const key in event) {
|
|
8171
|
+
if (!hasOwn(event, key)) continue;
|
|
8172
|
+
if (key !== "__type") {
|
|
8173
|
+
unionMember = key;
|
|
8174
|
+
break;
|
|
8175
|
+
}
|
|
8176
|
+
}
|
|
8177
|
+
const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
|
|
8178
|
+
const headers = {
|
|
8179
|
+
":event-type": {
|
|
8180
|
+
type: "string",
|
|
8181
|
+
value: eventType
|
|
8182
|
+
},
|
|
8183
|
+
":message-type": {
|
|
8184
|
+
type: "string",
|
|
8185
|
+
value: "event"
|
|
8186
|
+
},
|
|
8187
|
+
":content-type": {
|
|
8188
|
+
type: "string",
|
|
8189
|
+
value: explicitPayloadContentType ?? defaultContentType
|
|
8190
|
+
},
|
|
8191
|
+
...additionalHeaders
|
|
8192
|
+
};
|
|
8193
|
+
return {
|
|
8194
|
+
headers,
|
|
8195
|
+
body
|
|
8196
|
+
};
|
|
8197
|
+
});
|
|
8198
|
+
}
|
|
8199
|
+
async deserializeEventStream({ response, responseSchema, initialResponseContainer, initialMessageType }) {
|
|
8200
|
+
const marshaller = this.marshaller;
|
|
8201
|
+
const eventStreamMember = responseSchema.getEventStreamMember();
|
|
8202
|
+
const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
|
|
8203
|
+
const memberSchemas = unionSchema.getMemberSchemas();
|
|
8204
|
+
const initialResponseMarker = Symbol("initialResponseMarker");
|
|
8205
|
+
const asyncIterable = marshaller.deserialize(response.body, async (event) => {
|
|
8206
|
+
let unionMember = "";
|
|
8207
|
+
for (const key in event) {
|
|
8208
|
+
if (!hasOwn(event, key)) continue;
|
|
8209
|
+
if (key !== "__type") {
|
|
8210
|
+
unionMember = key;
|
|
8211
|
+
break;
|
|
8212
|
+
}
|
|
8213
|
+
}
|
|
8214
|
+
const body = event[unionMember].body;
|
|
8215
|
+
if (unionMember === (initialMessageType ?? "initial-response")) {
|
|
8216
|
+
const dataObject = await this.deserializer.read(responseSchema, body);
|
|
8217
|
+
delete dataObject[eventStreamMember];
|
|
8218
|
+
return {
|
|
8219
|
+
[initialResponseMarker]: true,
|
|
8220
|
+
...dataObject
|
|
8221
|
+
};
|
|
8222
|
+
} else if (unionMember in memberSchemas) {
|
|
8223
|
+
const eventStreamSchema = memberSchemas[unionMember];
|
|
8224
|
+
if (eventStreamSchema.isStructSchema()) {
|
|
8225
|
+
const out = {};
|
|
8226
|
+
let hasBindings = false;
|
|
8227
|
+
for (const [name, member] of eventStreamSchema.structIterator()) {
|
|
8228
|
+
const { eventHeader, eventPayload } = member.getMergedTraits();
|
|
8229
|
+
hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
|
|
8230
|
+
if (eventPayload) {
|
|
8231
|
+
if (member.isBlobSchema()) {
|
|
8232
|
+
out[name] = body;
|
|
8233
|
+
} else if (member.isStringSchema()) {
|
|
8234
|
+
out[name] = (this.serdeContext?.utf8Encoder ?? toUtf8$1)(body);
|
|
8235
|
+
} else if (member.isStructSchema()) {
|
|
8236
|
+
out[name] = await this.deserializer.read(member, body);
|
|
8237
|
+
}
|
|
8238
|
+
} else if (eventHeader) {
|
|
8239
|
+
const value = event[unionMember].headers[name]?.value;
|
|
8240
|
+
if (value != null) {
|
|
8241
|
+
if (member.isNumericSchema()) {
|
|
8242
|
+
if (value && typeof value === "object" && "bytes" in value) {
|
|
8243
|
+
out[name] = BigInt(value.toString());
|
|
8244
|
+
} else {
|
|
8245
|
+
out[name] = Number(value);
|
|
8246
|
+
}
|
|
8247
|
+
} else {
|
|
8248
|
+
out[name] = value;
|
|
8249
|
+
}
|
|
8250
|
+
}
|
|
8251
|
+
}
|
|
8252
|
+
}
|
|
8253
|
+
return { [unionMember]: await this.readEventMember(eventStreamSchema, body, hasBindings, out) };
|
|
8254
|
+
}
|
|
8255
|
+
return { [unionMember]: await this.deserializer.read(eventStreamSchema, body) };
|
|
8256
|
+
} else {
|
|
8257
|
+
return { $unknown: event };
|
|
8258
|
+
}
|
|
8259
|
+
});
|
|
8260
|
+
const asyncIterator = asyncIterable[Symbol.asyncIterator]();
|
|
8261
|
+
const firstEvent = await asyncIterator.next();
|
|
8262
|
+
if (firstEvent.done) {
|
|
8263
|
+
return asyncIterable;
|
|
8264
|
+
}
|
|
8265
|
+
if (firstEvent.value?.[initialResponseMarker]) {
|
|
8266
|
+
if (!responseSchema) {
|
|
8267
|
+
throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
|
|
8268
|
+
}
|
|
8269
|
+
for (const key in firstEvent.value) {
|
|
8270
|
+
if (!hasOwn(firstEvent.value, key)) continue;
|
|
8271
|
+
initialResponseContainer[key] = firstEvent.value[key];
|
|
8272
|
+
}
|
|
8273
|
+
}
|
|
8274
|
+
return { async *[Symbol.asyncIterator]() {
|
|
8275
|
+
if (!firstEvent?.value?.[initialResponseMarker]) {
|
|
8276
|
+
yield firstEvent.value;
|
|
8277
|
+
}
|
|
8278
|
+
while (true) {
|
|
8279
|
+
const { done, value } = await asyncIterator.next();
|
|
8280
|
+
if (done) {
|
|
8281
|
+
break;
|
|
8282
|
+
}
|
|
8283
|
+
yield value;
|
|
8284
|
+
}
|
|
8285
|
+
} };
|
|
8286
|
+
}
|
|
8287
|
+
async readEventMember(eventStreamSchema, body, hasBindings, out) {
|
|
8288
|
+
let ErrCtor;
|
|
8289
|
+
const staticStructuralSchema = eventStreamSchema.getSchema();
|
|
8290
|
+
if (Array.isArray(staticStructuralSchema) && staticStructuralSchema[0] === -3) {
|
|
8291
|
+
const namespace = staticStructuralSchema[1];
|
|
8292
|
+
const nsRegistry = TypeRegistry.for(namespace);
|
|
8293
|
+
this.compositeErrorRegistry?.copyFrom(nsRegistry);
|
|
8294
|
+
ErrCtor = (this.compositeErrorRegistry ?? nsRegistry)?.getErrorCtor(staticStructuralSchema);
|
|
8295
|
+
}
|
|
8296
|
+
const dataObject = hasBindings ? out : body.byteLength === 0 ? {} : await this.deserializer.read(eventStreamSchema, body);
|
|
8297
|
+
if (ErrCtor) {
|
|
8298
|
+
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
8299
|
+
const metadata = {};
|
|
8300
|
+
const $fault = eventStreamSchema.getMergedTraits().error;
|
|
8301
|
+
if ($fault) {
|
|
8302
|
+
metadata.$fault = $fault;
|
|
8303
|
+
}
|
|
8304
|
+
return Object.assign(new ErrCtor({}), metadata, { message }, dataObject);
|
|
8305
|
+
}
|
|
8306
|
+
return dataObject;
|
|
8307
|
+
}
|
|
8308
|
+
writeEventBody(unionMember, unionSchema, event) {
|
|
8309
|
+
const serializer = this.serializer;
|
|
8310
|
+
let eventType = unionMember;
|
|
8311
|
+
let explicitPayloadMember = null;
|
|
8312
|
+
let explicitPayloadContentType;
|
|
8313
|
+
const isKnownSchema = (() => {
|
|
8314
|
+
const struct = unionSchema.getSchema();
|
|
8315
|
+
return struct[4].includes(unionMember);
|
|
8316
|
+
})();
|
|
8317
|
+
const additionalHeaders = {};
|
|
8318
|
+
if (!isKnownSchema) {
|
|
8319
|
+
const [type, value] = event[unionMember];
|
|
8320
|
+
eventType = type;
|
|
8321
|
+
serializer.write(15, value);
|
|
8322
|
+
} else {
|
|
8323
|
+
const eventSchema = unionSchema.getMemberSchema(unionMember);
|
|
8324
|
+
if (eventSchema.isStructSchema()) {
|
|
8325
|
+
for (const [memberName, memberSchema] of eventSchema.structIterator()) {
|
|
8326
|
+
const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
|
|
8327
|
+
if (eventPayload) {
|
|
8328
|
+
explicitPayloadMember = memberName;
|
|
8329
|
+
} else if (eventHeader) {
|
|
8330
|
+
const value = event[unionMember][memberName];
|
|
8331
|
+
let type = "binary";
|
|
8332
|
+
if (memberSchema.isNumericSchema()) {
|
|
8333
|
+
if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
|
|
8334
|
+
type = "integer";
|
|
8335
|
+
} else {
|
|
8336
|
+
type = "long";
|
|
8337
|
+
}
|
|
8338
|
+
} else if (memberSchema.isTimestampSchema()) {
|
|
8339
|
+
type = "timestamp";
|
|
8340
|
+
} else if (memberSchema.isStringSchema()) {
|
|
8341
|
+
type = "string";
|
|
8342
|
+
} else if (memberSchema.isBooleanSchema()) {
|
|
8343
|
+
type = "boolean";
|
|
8344
|
+
}
|
|
8345
|
+
if (value != null) {
|
|
8346
|
+
additionalHeaders[memberName] = {
|
|
8347
|
+
type,
|
|
8348
|
+
value
|
|
8349
|
+
};
|
|
8350
|
+
delete event[unionMember][memberName];
|
|
8351
|
+
}
|
|
8352
|
+
}
|
|
8353
|
+
}
|
|
8354
|
+
if (explicitPayloadMember !== null) {
|
|
8355
|
+
const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
|
|
8356
|
+
if (payloadSchema.isBlobSchema()) {
|
|
8357
|
+
explicitPayloadContentType = "application/octet-stream";
|
|
8358
|
+
} else if (payloadSchema.isStringSchema()) {
|
|
8359
|
+
explicitPayloadContentType = "text/plain";
|
|
8360
|
+
}
|
|
8361
|
+
serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
|
|
8362
|
+
} else {
|
|
8363
|
+
serializer.write(eventSchema, event[unionMember]);
|
|
8364
|
+
}
|
|
8365
|
+
} else if (eventSchema.isUnitSchema()) {
|
|
8366
|
+
serializer.write(eventSchema, {});
|
|
8367
|
+
} else {
|
|
8368
|
+
throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
|
|
8369
|
+
}
|
|
8370
|
+
}
|
|
8371
|
+
const messageSerialization = serializer.flush() ?? new Uint8Array();
|
|
8372
|
+
const body = typeof messageSerialization === "string" ? (this.serdeContext?.utf8Decoder ?? fromUtf8$1)(messageSerialization) : messageSerialization;
|
|
8373
|
+
return {
|
|
8374
|
+
body,
|
|
8375
|
+
eventType,
|
|
8376
|
+
explicitPayloadContentType,
|
|
8377
|
+
additionalHeaders
|
|
8378
|
+
};
|
|
8379
|
+
}
|
|
8380
|
+
};
|
|
8381
|
+
}));
|
|
8382
|
+
|
|
8383
|
+
//#endregion
|
|
8384
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.33.3/node_modules/@smithy/core/dist-es/submodules/event-streams/index.js
|
|
8385
|
+
var event_streams_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
8386
|
+
EventStreamCodec: () => EventStreamCodec,
|
|
8387
|
+
EventStreamMarshaller: () => EventStreamMarshaller,
|
|
8388
|
+
EventStreamSerde: () => EventStreamSerde,
|
|
8389
|
+
HeaderMarshaller: () => HeaderMarshaller,
|
|
8390
|
+
Int64: () => Int64,
|
|
8391
|
+
MessageDecoderStream: () => MessageDecoderStream,
|
|
8392
|
+
MessageEncoderStream: () => MessageEncoderStream,
|
|
8393
|
+
SmithyMessageDecoderStream: () => SmithyMessageDecoderStream,
|
|
8394
|
+
SmithyMessageEncoderStream: () => SmithyMessageEncoderStream,
|
|
8395
|
+
UniversalEventStreamMarshaller: () => EventStreamMarshaller$1,
|
|
8396
|
+
eventStreamSerdeProvider: () => eventStreamSerdeProvider,
|
|
8397
|
+
getChunkedStream: () => getChunkedStream,
|
|
8398
|
+
getMessageUnmarshaller: () => getMessageUnmarshaller,
|
|
8399
|
+
getUnmarshalledStream: () => getUnmarshalledStream,
|
|
8400
|
+
iterableToReadableStream: () => iterableToReadableStream,
|
|
8401
|
+
readableStreamToIterable: () => readableStreamToIterable,
|
|
8402
|
+
resolveEventStreamSerdeConfig: () => resolveEventStreamSerdeConfig,
|
|
8403
|
+
universalEventStreamSerdeProvider: () => eventStreamSerdeProvider$1
|
|
8404
|
+
});
|
|
8405
|
+
var init_event_streams = require_rolldown_runtime.__esmMin((() => {
|
|
8406
|
+
init_EventStreamCodec();
|
|
8407
|
+
init_HeaderMarshaller();
|
|
8408
|
+
init_Int64();
|
|
8409
|
+
init_MessageDecoderStream();
|
|
8410
|
+
init_MessageEncoderStream();
|
|
8411
|
+
init_SmithyMessageDecoderStream();
|
|
8412
|
+
init_SmithyMessageEncoderStream();
|
|
8413
|
+
init_EventStreamMarshaller();
|
|
8414
|
+
init_utils();
|
|
8415
|
+
init_EventStreamMarshaller$1();
|
|
8416
|
+
init_getChunkedStream();
|
|
8417
|
+
init_getUnmarshalledStream();
|
|
8418
|
+
init_EventStreamSerdeConfig();
|
|
8419
|
+
init_EventStreamSerde();
|
|
8420
|
+
}));
|
|
8421
|
+
|
|
7431
8422
|
//#endregion
|
|
7432
8423
|
Object.defineProperty(exports, 'BinaryDecisionDiagram', {
|
|
7433
8424
|
enumerable: true,
|
|
@@ -7447,12 +8438,6 @@ Object.defineProperty(exports, 'Command', {
|
|
|
7447
8438
|
return Command;
|
|
7448
8439
|
}
|
|
7449
8440
|
});
|
|
7450
|
-
Object.defineProperty(exports, 'Crc32Node', {
|
|
7451
|
-
enumerable: true,
|
|
7452
|
-
get: function () {
|
|
7453
|
-
return Crc32Node;
|
|
7454
|
-
}
|
|
7455
|
-
});
|
|
7456
8441
|
Object.defineProperty(exports, 'EndpointCache', {
|
|
7457
8442
|
enumerable: true,
|
|
7458
8443
|
get: function () {
|
|
@@ -7669,22 +8654,22 @@ Object.defineProperty(exports, 'endpoints_exports', {
|
|
|
7669
8654
|
return endpoints_exports;
|
|
7670
8655
|
}
|
|
7671
8656
|
});
|
|
7672
|
-
Object.defineProperty(exports, '
|
|
8657
|
+
Object.defineProperty(exports, 'event_streams_exports', {
|
|
7673
8658
|
enumerable: true,
|
|
7674
8659
|
get: function () {
|
|
7675
|
-
return
|
|
8660
|
+
return event_streams_exports;
|
|
7676
8661
|
}
|
|
7677
8662
|
});
|
|
7678
|
-
Object.defineProperty(exports, '
|
|
8663
|
+
Object.defineProperty(exports, 'expectUnion', {
|
|
7679
8664
|
enumerable: true,
|
|
7680
8665
|
get: function () {
|
|
7681
|
-
return
|
|
8666
|
+
return expectUnion;
|
|
7682
8667
|
}
|
|
7683
8668
|
});
|
|
7684
|
-
Object.defineProperty(exports, '
|
|
8669
|
+
Object.defineProperty(exports, 'fromBase64', {
|
|
7685
8670
|
enumerable: true,
|
|
7686
8671
|
get: function () {
|
|
7687
|
-
return
|
|
8672
|
+
return fromBase64;
|
|
7688
8673
|
}
|
|
7689
8674
|
});
|
|
7690
8675
|
Object.defineProperty(exports, 'fromUtf8', {
|
|
@@ -7741,12 +8726,6 @@ Object.defineProperty(exports, 'init_BinaryDecisionDiagram', {
|
|
|
7741
8726
|
return init_BinaryDecisionDiagram;
|
|
7742
8727
|
}
|
|
7743
8728
|
});
|
|
7744
|
-
Object.defineProperty(exports, 'init_Crc32Node', {
|
|
7745
|
-
enumerable: true,
|
|
7746
|
-
get: function () {
|
|
7747
|
-
return init_Crc32Node;
|
|
7748
|
-
}
|
|
7749
|
-
});
|
|
7750
8729
|
Object.defineProperty(exports, 'init_EndpointCache', {
|
|
7751
8730
|
enumerable: true,
|
|
7752
8731
|
get: function () {
|
|
@@ -7921,6 +8900,12 @@ Object.defineProperty(exports, 'init_endpoints', {
|
|
|
7921
8900
|
return init_endpoints;
|
|
7922
8901
|
}
|
|
7923
8902
|
});
|
|
8903
|
+
Object.defineProperty(exports, 'init_event_streams', {
|
|
8904
|
+
enumerable: true,
|
|
8905
|
+
get: function () {
|
|
8906
|
+
return init_event_streams;
|
|
8907
|
+
}
|
|
8908
|
+
});
|
|
7924
8909
|
Object.defineProperty(exports, 'init_exceptions', {
|
|
7925
8910
|
enumerable: true,
|
|
7926
8911
|
get: function () {
|
|
@@ -7969,12 +8954,6 @@ Object.defineProperty(exports, 'init_hasOwn', {
|
|
|
7969
8954
|
return init_hasOwn;
|
|
7970
8955
|
}
|
|
7971
8956
|
});
|
|
7972
|
-
Object.defineProperty(exports, 'init_hex_encoding', {
|
|
7973
|
-
enumerable: true,
|
|
7974
|
-
get: function () {
|
|
7975
|
-
return init_hex_encoding;
|
|
7976
|
-
}
|
|
7977
|
-
});
|
|
7978
8957
|
Object.defineProperty(exports, 'init_httpRequest', {
|
|
7979
8958
|
enumerable: true,
|
|
7980
8959
|
get: function () {
|
|
@@ -8287,12 +9266,6 @@ Object.defineProperty(exports, 'toBase64', {
|
|
|
8287
9266
|
return toBase64$1;
|
|
8288
9267
|
}
|
|
8289
9268
|
});
|
|
8290
|
-
Object.defineProperty(exports, 'toHex', {
|
|
8291
|
-
enumerable: true,
|
|
8292
|
-
get: function () {
|
|
8293
|
-
return toHex;
|
|
8294
|
-
}
|
|
8295
|
-
});
|
|
8296
9269
|
Object.defineProperty(exports, 'toUtf8', {
|
|
8297
9270
|
enumerable: true,
|
|
8298
9271
|
get: function () {
|