@junando/worker 0.10.1 → 0.11.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-B7SAT8oI.cjs +8048 -0
- package/dist/checksum-BKPTTLSe.cjs +7710 -0
- package/dist/dist-CbGq-c4z.cjs +1463 -0
- package/dist/dist-cjs-mxzJ7CE9.cjs +100 -0
- package/dist/es5-CBwA-Kuh.cjs +1731 -0
- package/dist/event-streams-B7_gEE-_.cjs +953 -0
- package/dist/event-streams-DNZOvjgj.cjs +953 -0
- package/dist/handler.cjs +83996 -65578
- package/dist/node-BzYEGMG1.cjs +1177 -0
- package/dist/rolldown-runtime-CfAboj1T.cjs +81 -0
- package/dist/sdk-BD78kZ4E.cjs +10527 -0
- package/package.json +12 -12
|
@@ -0,0 +1,953 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./rolldown-runtime-CfAboj1T.cjs');
|
|
2
|
+
const require_checksum = require('./checksum-B7SAT8oI.cjs');
|
|
3
|
+
let node_stream = require("node:stream");
|
|
4
|
+
|
|
5
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/Int64.js
|
|
6
|
+
function negate(bytes) {
|
|
7
|
+
for (let i = 0; i < 8; i++) {
|
|
8
|
+
bytes[i] ^= 255;
|
|
9
|
+
}
|
|
10
|
+
for (let i = 7; i > -1; i--) {
|
|
11
|
+
bytes[i]++;
|
|
12
|
+
if (bytes[i] !== 0) break;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
var Int64;
|
|
16
|
+
var init_Int64 = require_rolldown_runtime.__esmMin((() => {
|
|
17
|
+
require_checksum.init_serde();
|
|
18
|
+
Int64 = class Int64 {
|
|
19
|
+
bytes;
|
|
20
|
+
constructor(bytes) {
|
|
21
|
+
this.bytes = bytes;
|
|
22
|
+
if (bytes.byteLength !== 8) {
|
|
23
|
+
throw new Error("Int64 buffers must be exactly 8 bytes");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
static fromNumber(number) {
|
|
27
|
+
if (number > 0x8000000000000000 || number < -0x8000000000000000) {
|
|
28
|
+
throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
|
|
29
|
+
}
|
|
30
|
+
const bytes = new Uint8Array(8);
|
|
31
|
+
for (let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {
|
|
32
|
+
bytes[i] = remaining;
|
|
33
|
+
}
|
|
34
|
+
if (number < 0) {
|
|
35
|
+
negate(bytes);
|
|
36
|
+
}
|
|
37
|
+
return new Int64(bytes);
|
|
38
|
+
}
|
|
39
|
+
valueOf() {
|
|
40
|
+
const bytes = this.bytes.slice(0);
|
|
41
|
+
const negative = bytes[0] & 128;
|
|
42
|
+
if (negative) {
|
|
43
|
+
negate(bytes);
|
|
44
|
+
}
|
|
45
|
+
return parseInt(require_checksum.toHex(bytes), 16) * (negative ? -1 : 1);
|
|
46
|
+
}
|
|
47
|
+
toString() {
|
|
48
|
+
return String(this.valueOf());
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js
|
|
55
|
+
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;
|
|
56
|
+
var init_HeaderMarshaller = require_rolldown_runtime.__esmMin((() => {
|
|
57
|
+
require_checksum.init_serde();
|
|
58
|
+
init_Int64();
|
|
59
|
+
HeaderMarshaller = class {
|
|
60
|
+
toUtf8;
|
|
61
|
+
fromUtf8;
|
|
62
|
+
constructor(toUtf8, fromUtf8) {
|
|
63
|
+
this.toUtf8 = toUtf8;
|
|
64
|
+
this.fromUtf8 = fromUtf8;
|
|
65
|
+
}
|
|
66
|
+
format(headers) {
|
|
67
|
+
const chunks = [];
|
|
68
|
+
for (const headerName of Object.keys(headers)) {
|
|
69
|
+
const bytes = this.fromUtf8(headerName);
|
|
70
|
+
chunks.push(Uint8Array.from([bytes.byteLength]), bytes, this.formatHeaderValue(headers[headerName]));
|
|
71
|
+
}
|
|
72
|
+
const out = new Uint8Array(chunks.reduce((carry, bytes) => carry + bytes.byteLength, 0));
|
|
73
|
+
let position = 0;
|
|
74
|
+
for (const chunk of chunks) {
|
|
75
|
+
out.set(chunk, position);
|
|
76
|
+
position += chunk.byteLength;
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
formatHeaderValue(header) {
|
|
81
|
+
switch (header.type) {
|
|
82
|
+
case "boolean": return Uint8Array.from([header.value ? 0 : 1]);
|
|
83
|
+
case "byte": return Uint8Array.from([2, header.value]);
|
|
84
|
+
case "short":
|
|
85
|
+
const shortView = new DataView(new ArrayBuffer(3));
|
|
86
|
+
shortView.setUint8(0, 3);
|
|
87
|
+
shortView.setInt16(1, header.value, false);
|
|
88
|
+
return new Uint8Array(shortView.buffer);
|
|
89
|
+
case "integer":
|
|
90
|
+
const intView = new DataView(new ArrayBuffer(5));
|
|
91
|
+
intView.setUint8(0, 4);
|
|
92
|
+
intView.setInt32(1, header.value, false);
|
|
93
|
+
return new Uint8Array(intView.buffer);
|
|
94
|
+
case "long":
|
|
95
|
+
const longBytes = new Uint8Array(9);
|
|
96
|
+
longBytes[0] = 5;
|
|
97
|
+
longBytes.set(header.value.bytes, 1);
|
|
98
|
+
return longBytes;
|
|
99
|
+
case "binary":
|
|
100
|
+
const binView = new DataView(new ArrayBuffer(3 + header.value.byteLength));
|
|
101
|
+
binView.setUint8(0, 6);
|
|
102
|
+
binView.setUint16(1, header.value.byteLength, false);
|
|
103
|
+
const binBytes = new Uint8Array(binView.buffer);
|
|
104
|
+
binBytes.set(header.value, 3);
|
|
105
|
+
return binBytes;
|
|
106
|
+
case "string":
|
|
107
|
+
const utf8Bytes = this.fromUtf8(header.value);
|
|
108
|
+
const strView = new DataView(new ArrayBuffer(3 + utf8Bytes.byteLength));
|
|
109
|
+
strView.setUint8(0, 7);
|
|
110
|
+
strView.setUint16(1, utf8Bytes.byteLength, false);
|
|
111
|
+
const strBytes = new Uint8Array(strView.buffer);
|
|
112
|
+
strBytes.set(utf8Bytes, 3);
|
|
113
|
+
return strBytes;
|
|
114
|
+
case "timestamp":
|
|
115
|
+
const tsBytes = new Uint8Array(9);
|
|
116
|
+
tsBytes[0] = 8;
|
|
117
|
+
tsBytes.set(Int64.fromNumber(header.value.valueOf()).bytes, 1);
|
|
118
|
+
return tsBytes;
|
|
119
|
+
case "uuid":
|
|
120
|
+
if (!UUID_PATTERN.test(header.value)) {
|
|
121
|
+
throw new Error(`Invalid UUID received: ${header.value}`);
|
|
122
|
+
}
|
|
123
|
+
const uuidBytes = new Uint8Array(17);
|
|
124
|
+
uuidBytes[0] = 9;
|
|
125
|
+
uuidBytes.set(require_checksum.fromHex(header.value.replace(/\-/g, "")), 1);
|
|
126
|
+
return uuidBytes;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
parse(headers) {
|
|
130
|
+
const out = {};
|
|
131
|
+
let position = 0;
|
|
132
|
+
while (position < headers.byteLength) {
|
|
133
|
+
const nameLength = headers.getUint8(position++);
|
|
134
|
+
const name = this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, nameLength));
|
|
135
|
+
position += nameLength;
|
|
136
|
+
switch (headers.getUint8(position++)) {
|
|
137
|
+
case 0:
|
|
138
|
+
out[name] = {
|
|
139
|
+
type: BOOLEAN_TAG,
|
|
140
|
+
value: true
|
|
141
|
+
};
|
|
142
|
+
break;
|
|
143
|
+
case 1:
|
|
144
|
+
out[name] = {
|
|
145
|
+
type: BOOLEAN_TAG,
|
|
146
|
+
value: false
|
|
147
|
+
};
|
|
148
|
+
break;
|
|
149
|
+
case 2:
|
|
150
|
+
out[name] = {
|
|
151
|
+
type: BYTE_TAG,
|
|
152
|
+
value: headers.getInt8(position++)
|
|
153
|
+
};
|
|
154
|
+
break;
|
|
155
|
+
case 3:
|
|
156
|
+
out[name] = {
|
|
157
|
+
type: SHORT_TAG,
|
|
158
|
+
value: headers.getInt16(position, false)
|
|
159
|
+
};
|
|
160
|
+
position += 2;
|
|
161
|
+
break;
|
|
162
|
+
case 4:
|
|
163
|
+
out[name] = {
|
|
164
|
+
type: INT_TAG,
|
|
165
|
+
value: headers.getInt32(position, false)
|
|
166
|
+
};
|
|
167
|
+
position += 4;
|
|
168
|
+
break;
|
|
169
|
+
case 5:
|
|
170
|
+
out[name] = {
|
|
171
|
+
type: LONG_TAG,
|
|
172
|
+
value: new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8))
|
|
173
|
+
};
|
|
174
|
+
position += 8;
|
|
175
|
+
break;
|
|
176
|
+
case 6:
|
|
177
|
+
const binaryLength = headers.getUint16(position, false);
|
|
178
|
+
position += 2;
|
|
179
|
+
out[name] = {
|
|
180
|
+
type: BINARY_TAG,
|
|
181
|
+
value: new Uint8Array(headers.buffer, headers.byteOffset + position, binaryLength)
|
|
182
|
+
};
|
|
183
|
+
position += binaryLength;
|
|
184
|
+
break;
|
|
185
|
+
case 7:
|
|
186
|
+
const stringLength = headers.getUint16(position, false);
|
|
187
|
+
position += 2;
|
|
188
|
+
out[name] = {
|
|
189
|
+
type: STRING_TAG,
|
|
190
|
+
value: this.toUtf8(new Uint8Array(headers.buffer, headers.byteOffset + position, stringLength))
|
|
191
|
+
};
|
|
192
|
+
position += stringLength;
|
|
193
|
+
break;
|
|
194
|
+
case 8:
|
|
195
|
+
out[name] = {
|
|
196
|
+
type: TIMESTAMP_TAG,
|
|
197
|
+
value: new Date(new Int64(new Uint8Array(headers.buffer, headers.byteOffset + position, 8)).valueOf())
|
|
198
|
+
};
|
|
199
|
+
position += 8;
|
|
200
|
+
break;
|
|
201
|
+
case 9:
|
|
202
|
+
const uuidBytes = new Uint8Array(headers.buffer, headers.byteOffset + position, 16);
|
|
203
|
+
position += 16;
|
|
204
|
+
out[name] = {
|
|
205
|
+
type: UUID_TAG,
|
|
206
|
+
value: `${require_checksum.toHex(uuidBytes.subarray(0, 4))}-${require_checksum.toHex(uuidBytes.subarray(4, 6))}-${require_checksum.toHex(uuidBytes.subarray(6, 8))}-${require_checksum.toHex(uuidBytes.subarray(8, 10))}-${require_checksum.toHex(uuidBytes.subarray(10))}`
|
|
207
|
+
};
|
|
208
|
+
break;
|
|
209
|
+
default: throw new Error(`Unrecognized header type tag`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return out;
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
;
|
|
216
|
+
(function(HEADER_VALUE_TYPE) {
|
|
217
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["boolTrue"] = 0] = "boolTrue";
|
|
218
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["boolFalse"] = 1] = "boolFalse";
|
|
219
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["byte"] = 2] = "byte";
|
|
220
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["short"] = 3] = "short";
|
|
221
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["integer"] = 4] = "integer";
|
|
222
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["long"] = 5] = "long";
|
|
223
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["byteArray"] = 6] = "byteArray";
|
|
224
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["string"] = 7] = "string";
|
|
225
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["timestamp"] = 8] = "timestamp";
|
|
226
|
+
HEADER_VALUE_TYPE[HEADER_VALUE_TYPE["uuid"] = 9] = "uuid";
|
|
227
|
+
})(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
|
|
228
|
+
BOOLEAN_TAG = "boolean";
|
|
229
|
+
BYTE_TAG = "byte";
|
|
230
|
+
SHORT_TAG = "short";
|
|
231
|
+
INT_TAG = "integer";
|
|
232
|
+
LONG_TAG = "long";
|
|
233
|
+
BINARY_TAG = "binary";
|
|
234
|
+
STRING_TAG = "string";
|
|
235
|
+
TIMESTAMP_TAG = "timestamp";
|
|
236
|
+
UUID_TAG = "uuid";
|
|
237
|
+
UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
|
|
238
|
+
}));
|
|
239
|
+
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js
|
|
242
|
+
function splitMessage({ byteLength, byteOffset, buffer }) {
|
|
243
|
+
if (byteLength < MINIMUM_MESSAGE_LENGTH) {
|
|
244
|
+
throw new Error("Provided message too short to accommodate event stream message overhead");
|
|
245
|
+
}
|
|
246
|
+
const view = new DataView(buffer, byteOffset, byteLength);
|
|
247
|
+
const messageLength = view.getUint32(0, false);
|
|
248
|
+
if (byteLength !== messageLength) {
|
|
249
|
+
throw new Error("Reported message length does not match received message length");
|
|
250
|
+
}
|
|
251
|
+
const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);
|
|
252
|
+
const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
|
|
253
|
+
const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);
|
|
254
|
+
const checksummer = new require_checksum.Crc32Node();
|
|
255
|
+
checksummer.update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
|
|
256
|
+
if (expectedPreludeChecksum !== checksummer.digestSync()) {
|
|
257
|
+
throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digestSync()})`);
|
|
258
|
+
}
|
|
259
|
+
checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH)));
|
|
260
|
+
if (expectedMessageChecksum !== checksummer.digestSync()) {
|
|
261
|
+
throw new Error(`The message checksum (${checksummer.digestSync()}) did not match the expected value of ${expectedMessageChecksum}`);
|
|
262
|
+
}
|
|
263
|
+
return {
|
|
264
|
+
headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),
|
|
265
|
+
body: new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH + headerLength, messageLength - headerLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH + CHECKSUM_LENGTH))
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
var PRELUDE_MEMBER_LENGTH, PRELUDE_LENGTH, CHECKSUM_LENGTH, MINIMUM_MESSAGE_LENGTH;
|
|
269
|
+
var init_splitMessage = require_rolldown_runtime.__esmMin((() => {
|
|
270
|
+
require_checksum.init_checksum();
|
|
271
|
+
PRELUDE_MEMBER_LENGTH = 4;
|
|
272
|
+
PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
|
|
273
|
+
CHECKSUM_LENGTH = 4;
|
|
274
|
+
MINIMUM_MESSAGE_LENGTH = PRELUDE_LENGTH + CHECKSUM_LENGTH * 2;
|
|
275
|
+
}));
|
|
276
|
+
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js
|
|
279
|
+
var EventStreamCodec;
|
|
280
|
+
var init_EventStreamCodec = require_rolldown_runtime.__esmMin((() => {
|
|
281
|
+
require_checksum.init_checksum();
|
|
282
|
+
init_HeaderMarshaller();
|
|
283
|
+
init_splitMessage();
|
|
284
|
+
EventStreamCodec = class {
|
|
285
|
+
headerMarshaller;
|
|
286
|
+
messageBuffer;
|
|
287
|
+
isEndOfStream;
|
|
288
|
+
constructor(toUtf8, fromUtf8) {
|
|
289
|
+
this.headerMarshaller = new HeaderMarshaller(toUtf8, fromUtf8);
|
|
290
|
+
this.messageBuffer = [];
|
|
291
|
+
this.isEndOfStream = false;
|
|
292
|
+
}
|
|
293
|
+
feed(message) {
|
|
294
|
+
this.messageBuffer.push(this.decode(message));
|
|
295
|
+
}
|
|
296
|
+
endOfStream() {
|
|
297
|
+
this.isEndOfStream = true;
|
|
298
|
+
}
|
|
299
|
+
getMessage() {
|
|
300
|
+
const message = this.messageBuffer.pop();
|
|
301
|
+
const isEndOfStream = this.isEndOfStream;
|
|
302
|
+
return {
|
|
303
|
+
getMessage() {
|
|
304
|
+
return message;
|
|
305
|
+
},
|
|
306
|
+
isEndOfStream() {
|
|
307
|
+
return isEndOfStream;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
getAvailableMessages() {
|
|
312
|
+
const messages = this.messageBuffer;
|
|
313
|
+
this.messageBuffer = [];
|
|
314
|
+
const isEndOfStream = this.isEndOfStream;
|
|
315
|
+
return {
|
|
316
|
+
getMessages() {
|
|
317
|
+
return messages;
|
|
318
|
+
},
|
|
319
|
+
isEndOfStream() {
|
|
320
|
+
return isEndOfStream;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
encode({ headers: rawHeaders, body }) {
|
|
325
|
+
const headers = this.headerMarshaller.format(rawHeaders);
|
|
326
|
+
const length = headers.byteLength + body.byteLength + 16;
|
|
327
|
+
const out = new Uint8Array(length);
|
|
328
|
+
const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
|
|
329
|
+
const checksum = new require_checksum.Crc32Node();
|
|
330
|
+
view.setUint32(0, length, false);
|
|
331
|
+
view.setUint32(4, headers.byteLength, false);
|
|
332
|
+
checksum.update(out.subarray(0, 8));
|
|
333
|
+
view.setUint32(8, checksum.digestSync(), false);
|
|
334
|
+
out.set(headers, 12);
|
|
335
|
+
out.set(body, headers.byteLength + 12);
|
|
336
|
+
checksum.update(out.subarray(8, length - 4));
|
|
337
|
+
view.setUint32(length - 4, checksum.digestSync(), false);
|
|
338
|
+
return out;
|
|
339
|
+
}
|
|
340
|
+
decode(message) {
|
|
341
|
+
const { headers, body } = splitMessage(message);
|
|
342
|
+
return {
|
|
343
|
+
headers: this.headerMarshaller.parse(headers),
|
|
344
|
+
body
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
formatHeaders(rawHeaders) {
|
|
348
|
+
return this.headerMarshaller.format(rawHeaders);
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
}));
|
|
352
|
+
|
|
353
|
+
//#endregion
|
|
354
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageDecoderStream.js
|
|
355
|
+
var MessageDecoderStream;
|
|
356
|
+
var init_MessageDecoderStream = require_rolldown_runtime.__esmMin((() => {
|
|
357
|
+
MessageDecoderStream = class {
|
|
358
|
+
options;
|
|
359
|
+
constructor(options) {
|
|
360
|
+
this.options = options;
|
|
361
|
+
}
|
|
362
|
+
[Symbol.asyncIterator]() {
|
|
363
|
+
return this.asyncIterator();
|
|
364
|
+
}
|
|
365
|
+
async *asyncIterator() {
|
|
366
|
+
for await (const bytes of this.options.inputStream) {
|
|
367
|
+
const decoded = this.options.decoder.decode(bytes);
|
|
368
|
+
yield decoded;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
}));
|
|
373
|
+
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageEncoderStream.js
|
|
376
|
+
var MessageEncoderStream;
|
|
377
|
+
var init_MessageEncoderStream = require_rolldown_runtime.__esmMin((() => {
|
|
378
|
+
MessageEncoderStream = class {
|
|
379
|
+
options;
|
|
380
|
+
constructor(options) {
|
|
381
|
+
this.options = options;
|
|
382
|
+
}
|
|
383
|
+
[Symbol.asyncIterator]() {
|
|
384
|
+
return this.asyncIterator();
|
|
385
|
+
}
|
|
386
|
+
async *asyncIterator() {
|
|
387
|
+
for await (const msg of this.options.messageStream) {
|
|
388
|
+
const encoded = this.options.encoder.encode(msg);
|
|
389
|
+
yield encoded;
|
|
390
|
+
}
|
|
391
|
+
if (this.options.includeEndFrame) {
|
|
392
|
+
yield new Uint8Array(0);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
}));
|
|
397
|
+
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageDecoderStream.js
|
|
400
|
+
var SmithyMessageDecoderStream;
|
|
401
|
+
var init_SmithyMessageDecoderStream = require_rolldown_runtime.__esmMin((() => {
|
|
402
|
+
SmithyMessageDecoderStream = class {
|
|
403
|
+
options;
|
|
404
|
+
constructor(options) {
|
|
405
|
+
this.options = options;
|
|
406
|
+
}
|
|
407
|
+
[Symbol.asyncIterator]() {
|
|
408
|
+
return this.asyncIterator();
|
|
409
|
+
}
|
|
410
|
+
async *asyncIterator() {
|
|
411
|
+
for await (const message of this.options.messageStream) {
|
|
412
|
+
const deserialized = await this.options.deserializer(message);
|
|
413
|
+
if (deserialized === undefined) continue;
|
|
414
|
+
yield deserialized;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
}));
|
|
419
|
+
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageEncoderStream.js
|
|
422
|
+
var SmithyMessageEncoderStream;
|
|
423
|
+
var init_SmithyMessageEncoderStream = require_rolldown_runtime.__esmMin((() => {
|
|
424
|
+
SmithyMessageEncoderStream = class {
|
|
425
|
+
options;
|
|
426
|
+
constructor(options) {
|
|
427
|
+
this.options = options;
|
|
428
|
+
}
|
|
429
|
+
[Symbol.asyncIterator]() {
|
|
430
|
+
return this.asyncIterator();
|
|
431
|
+
}
|
|
432
|
+
async *asyncIterator() {
|
|
433
|
+
for await (const chunk of this.options.inputStream) {
|
|
434
|
+
const payloadBuf = this.options.serializer(chunk);
|
|
435
|
+
yield payloadBuf;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
}));
|
|
440
|
+
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getChunkedStream.js
|
|
443
|
+
function getChunkedStream(source) {
|
|
444
|
+
let currentMessageTotalLength = 0;
|
|
445
|
+
let currentMessagePendingLength = 0;
|
|
446
|
+
let currentMessage = null;
|
|
447
|
+
let messageLengthBuffer = null;
|
|
448
|
+
const allocateMessage = (size) => {
|
|
449
|
+
if (typeof size !== "number") {
|
|
450
|
+
throw new Error("Attempted to allocate an event message where size was not a number: " + size);
|
|
451
|
+
}
|
|
452
|
+
currentMessageTotalLength = size;
|
|
453
|
+
currentMessagePendingLength = 4;
|
|
454
|
+
currentMessage = new Uint8Array(size);
|
|
455
|
+
const currentMessageView = new DataView(currentMessage.buffer);
|
|
456
|
+
currentMessageView.setUint32(0, size, false);
|
|
457
|
+
};
|
|
458
|
+
const iterator = async function* () {
|
|
459
|
+
const sourceIterator = source[Symbol.asyncIterator]();
|
|
460
|
+
while (true) {
|
|
461
|
+
const { value, done } = await sourceIterator.next();
|
|
462
|
+
if (done) {
|
|
463
|
+
if (!currentMessageTotalLength) {
|
|
464
|
+
return;
|
|
465
|
+
} else if (currentMessageTotalLength === currentMessagePendingLength) {
|
|
466
|
+
yield currentMessage;
|
|
467
|
+
} else {
|
|
468
|
+
throw new Error("Truncated event message received.");
|
|
469
|
+
}
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
const chunkLength = value.length;
|
|
473
|
+
let currentOffset = 0;
|
|
474
|
+
while (currentOffset < chunkLength) {
|
|
475
|
+
if (!currentMessage) {
|
|
476
|
+
const bytesRemaining = chunkLength - currentOffset;
|
|
477
|
+
if (!messageLengthBuffer) {
|
|
478
|
+
messageLengthBuffer = new Uint8Array(4);
|
|
479
|
+
}
|
|
480
|
+
const numBytesForTotal = Math.min(4 - currentMessagePendingLength, bytesRemaining);
|
|
481
|
+
messageLengthBuffer.set(value.slice(currentOffset, currentOffset + numBytesForTotal), currentMessagePendingLength);
|
|
482
|
+
currentMessagePendingLength += numBytesForTotal;
|
|
483
|
+
currentOffset += numBytesForTotal;
|
|
484
|
+
if (currentMessagePendingLength < 4) {
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
allocateMessage(new DataView(messageLengthBuffer.buffer).getUint32(0, false));
|
|
488
|
+
messageLengthBuffer = null;
|
|
489
|
+
}
|
|
490
|
+
const numBytesToWrite = Math.min(currentMessageTotalLength - currentMessagePendingLength, chunkLength - currentOffset);
|
|
491
|
+
currentMessage.set(value.slice(currentOffset, currentOffset + numBytesToWrite), currentMessagePendingLength);
|
|
492
|
+
currentMessagePendingLength += numBytesToWrite;
|
|
493
|
+
currentOffset += numBytesToWrite;
|
|
494
|
+
if (currentMessageTotalLength && currentMessageTotalLength === currentMessagePendingLength) {
|
|
495
|
+
yield currentMessage;
|
|
496
|
+
currentMessage = null;
|
|
497
|
+
currentMessageTotalLength = 0;
|
|
498
|
+
currentMessagePendingLength = 0;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
return { [Symbol.asyncIterator]: iterator };
|
|
504
|
+
}
|
|
505
|
+
var init_getChunkedStream = require_rolldown_runtime.__esmMin((() => {}));
|
|
506
|
+
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getUnmarshalledStream.js
|
|
509
|
+
function getUnmarshalledStream(source, options) {
|
|
510
|
+
const messageUnmarshaller = getMessageUnmarshaller(options.deserializer, options.toUtf8);
|
|
511
|
+
return { [Symbol.asyncIterator]: async function* () {
|
|
512
|
+
for await (const chunk of source) {
|
|
513
|
+
const message = options.eventStreamCodec.decode(chunk);
|
|
514
|
+
const type = await messageUnmarshaller(message);
|
|
515
|
+
if (type === undefined) continue;
|
|
516
|
+
yield type;
|
|
517
|
+
}
|
|
518
|
+
} };
|
|
519
|
+
}
|
|
520
|
+
function getMessageUnmarshaller(deserializer, toUtf8) {
|
|
521
|
+
return async function(message) {
|
|
522
|
+
const { value: messageType } = message.headers[":message-type"];
|
|
523
|
+
if (messageType === "error") {
|
|
524
|
+
const unmodeledError = new Error(message.headers[":error-message"].value || "UnknownError");
|
|
525
|
+
unmodeledError.name = message.headers[":error-code"].value;
|
|
526
|
+
throw unmodeledError;
|
|
527
|
+
} else if (messageType === "exception") {
|
|
528
|
+
const code = message.headers[":exception-type"].value;
|
|
529
|
+
const exception = { [code]: message };
|
|
530
|
+
const deserializedException = await deserializer(exception);
|
|
531
|
+
if (deserializedException.$unknown) {
|
|
532
|
+
const error = new Error(toUtf8(message.body));
|
|
533
|
+
error.name = code;
|
|
534
|
+
throw error;
|
|
535
|
+
}
|
|
536
|
+
throw deserializedException[code];
|
|
537
|
+
} else if (messageType === "event") {
|
|
538
|
+
const event = { [message.headers[":event-type"].value]: message };
|
|
539
|
+
const deserialized = await deserializer(event);
|
|
540
|
+
if (deserialized.$unknown) return;
|
|
541
|
+
return deserialized;
|
|
542
|
+
} else {
|
|
543
|
+
throw Error(`Unrecognizable event type: ${message.headers[":event-type"].value}`);
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
var init_getUnmarshalledStream = require_rolldown_runtime.__esmMin((() => {}));
|
|
548
|
+
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/EventStreamMarshaller.js
|
|
551
|
+
var EventStreamMarshaller$1, eventStreamSerdeProvider$1;
|
|
552
|
+
var init_EventStreamMarshaller$1 = require_rolldown_runtime.__esmMin((() => {
|
|
553
|
+
init_EventStreamCodec();
|
|
554
|
+
init_MessageDecoderStream();
|
|
555
|
+
init_MessageEncoderStream();
|
|
556
|
+
init_SmithyMessageDecoderStream();
|
|
557
|
+
init_SmithyMessageEncoderStream();
|
|
558
|
+
init_getChunkedStream();
|
|
559
|
+
init_getUnmarshalledStream();
|
|
560
|
+
EventStreamMarshaller$1 = class {
|
|
561
|
+
eventStreamCodec;
|
|
562
|
+
utfEncoder;
|
|
563
|
+
constructor({ utf8Encoder, utf8Decoder }) {
|
|
564
|
+
this.eventStreamCodec = new EventStreamCodec(utf8Encoder, utf8Decoder);
|
|
565
|
+
this.utfEncoder = utf8Encoder;
|
|
566
|
+
}
|
|
567
|
+
deserialize(body, deserializer) {
|
|
568
|
+
const inputStream = getChunkedStream(body);
|
|
569
|
+
return new SmithyMessageDecoderStream({
|
|
570
|
+
messageStream: new MessageDecoderStream({
|
|
571
|
+
inputStream,
|
|
572
|
+
decoder: this.eventStreamCodec
|
|
573
|
+
}),
|
|
574
|
+
deserializer: getMessageUnmarshaller(deserializer, this.utfEncoder)
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
serialize(inputStream, serializer) {
|
|
578
|
+
return new MessageEncoderStream({
|
|
579
|
+
messageStream: new SmithyMessageEncoderStream({
|
|
580
|
+
inputStream,
|
|
581
|
+
serializer
|
|
582
|
+
}),
|
|
583
|
+
encoder: this.eventStreamCodec,
|
|
584
|
+
includeEndFrame: true
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
eventStreamSerdeProvider$1 = (options) => new EventStreamMarshaller$1(options);
|
|
589
|
+
}));
|
|
590
|
+
|
|
591
|
+
//#endregion
|
|
592
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
|
|
593
|
+
async function* readableToIterable(readStream) {
|
|
594
|
+
let streamEnded = false;
|
|
595
|
+
let generationEnded = false;
|
|
596
|
+
const records = new Array();
|
|
597
|
+
readStream.on("error", (err) => {
|
|
598
|
+
if (!streamEnded) {
|
|
599
|
+
streamEnded = true;
|
|
600
|
+
}
|
|
601
|
+
if (err) {
|
|
602
|
+
throw err;
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
readStream.on("data", (data) => {
|
|
606
|
+
records.push(data);
|
|
607
|
+
});
|
|
608
|
+
readStream.on("end", () => {
|
|
609
|
+
streamEnded = true;
|
|
610
|
+
});
|
|
611
|
+
while (!generationEnded) {
|
|
612
|
+
const value = await new Promise((resolve) => setTimeout(() => resolve(records.shift()), 0));
|
|
613
|
+
if (value) {
|
|
614
|
+
yield value;
|
|
615
|
+
}
|
|
616
|
+
generationEnded = streamEnded && records.length === 0;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
var EventStreamMarshaller, eventStreamSerdeProvider;
|
|
620
|
+
var init_EventStreamMarshaller = require_rolldown_runtime.__esmMin((() => {
|
|
621
|
+
init_EventStreamMarshaller$1();
|
|
622
|
+
EventStreamMarshaller = class {
|
|
623
|
+
universalMarshaller;
|
|
624
|
+
constructor({ utf8Encoder, utf8Decoder }) {
|
|
625
|
+
this.universalMarshaller = new EventStreamMarshaller$1({
|
|
626
|
+
utf8Decoder,
|
|
627
|
+
utf8Encoder
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
deserialize(body, deserializer) {
|
|
631
|
+
const bodyIterable = typeof body[Symbol.asyncIterator] === "function" ? body : readableToIterable(body);
|
|
632
|
+
return this.universalMarshaller.deserialize(bodyIterable, deserializer);
|
|
633
|
+
}
|
|
634
|
+
serialize(input, serializer) {
|
|
635
|
+
return node_stream.Readable.from(this.universalMarshaller.serialize(input, serializer));
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
eventStreamSerdeProvider = (options) => new EventStreamMarshaller(options);
|
|
639
|
+
}));
|
|
640
|
+
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/utils.js
|
|
643
|
+
var readableStreamToIterable, iterableToReadableStream;
|
|
644
|
+
var init_utils = require_rolldown_runtime.__esmMin((() => {
|
|
645
|
+
readableStreamToIterable = (readableStream) => ({ [Symbol.asyncIterator]: async function* () {
|
|
646
|
+
const reader = readableStream.getReader();
|
|
647
|
+
try {
|
|
648
|
+
while (true) {
|
|
649
|
+
const { done, value } = await reader.read();
|
|
650
|
+
if (done) return;
|
|
651
|
+
yield value;
|
|
652
|
+
}
|
|
653
|
+
} finally {
|
|
654
|
+
reader.releaseLock();
|
|
655
|
+
}
|
|
656
|
+
} });
|
|
657
|
+
iterableToReadableStream = (asyncIterable) => {
|
|
658
|
+
const iterator = asyncIterable[Symbol.asyncIterator]();
|
|
659
|
+
return new ReadableStream({ async pull(controller) {
|
|
660
|
+
const { done, value } = await iterator.next();
|
|
661
|
+
if (done) {
|
|
662
|
+
return controller.close();
|
|
663
|
+
}
|
|
664
|
+
controller.enqueue(value);
|
|
665
|
+
} });
|
|
666
|
+
};
|
|
667
|
+
}));
|
|
668
|
+
|
|
669
|
+
//#endregion
|
|
670
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-config-resolver/EventStreamSerdeConfig.js
|
|
671
|
+
var resolveEventStreamSerdeConfig;
|
|
672
|
+
var init_EventStreamSerdeConfig = require_rolldown_runtime.__esmMin((() => {
|
|
673
|
+
resolveEventStreamSerdeConfig = (input) => Object.assign(input, { eventStreamMarshaller: input.eventStreamSerdeProvider(input) });
|
|
674
|
+
}));
|
|
675
|
+
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js
|
|
678
|
+
var EventStreamSerde;
|
|
679
|
+
var init_EventStreamSerde = require_rolldown_runtime.__esmMin((() => {
|
|
680
|
+
require_checksum.init_serde();
|
|
681
|
+
EventStreamSerde = class {
|
|
682
|
+
marshaller;
|
|
683
|
+
serializer;
|
|
684
|
+
deserializer;
|
|
685
|
+
serdeContext;
|
|
686
|
+
defaultContentType;
|
|
687
|
+
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType }) {
|
|
688
|
+
this.marshaller = marshaller;
|
|
689
|
+
this.serializer = serializer;
|
|
690
|
+
this.deserializer = deserializer;
|
|
691
|
+
this.serdeContext = serdeContext;
|
|
692
|
+
this.defaultContentType = defaultContentType;
|
|
693
|
+
}
|
|
694
|
+
async serializeEventStream({ eventStream, requestSchema, initialRequest }) {
|
|
695
|
+
const marshaller = this.marshaller;
|
|
696
|
+
const eventStreamMember = requestSchema.getEventStreamMember();
|
|
697
|
+
const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
|
|
698
|
+
const serializer = this.serializer;
|
|
699
|
+
const defaultContentType = this.defaultContentType;
|
|
700
|
+
const initialRequestMarker = Symbol("initialRequestMarker");
|
|
701
|
+
const eventStreamIterable = { async *[Symbol.asyncIterator]() {
|
|
702
|
+
if (initialRequest) {
|
|
703
|
+
const headers = {
|
|
704
|
+
":event-type": {
|
|
705
|
+
type: "string",
|
|
706
|
+
value: "initial-request"
|
|
707
|
+
},
|
|
708
|
+
":message-type": {
|
|
709
|
+
type: "string",
|
|
710
|
+
value: "event"
|
|
711
|
+
},
|
|
712
|
+
":content-type": {
|
|
713
|
+
type: "string",
|
|
714
|
+
value: defaultContentType
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
serializer.write(requestSchema, initialRequest);
|
|
718
|
+
const body = serializer.flush();
|
|
719
|
+
yield {
|
|
720
|
+
[initialRequestMarker]: true,
|
|
721
|
+
headers,
|
|
722
|
+
body
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
for await (const page of eventStream) {
|
|
726
|
+
yield page;
|
|
727
|
+
}
|
|
728
|
+
} };
|
|
729
|
+
return marshaller.serialize(eventStreamIterable, (event) => {
|
|
730
|
+
if (event[initialRequestMarker]) {
|
|
731
|
+
return {
|
|
732
|
+
headers: event.headers,
|
|
733
|
+
body: event.body
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
let unionMember = "";
|
|
737
|
+
for (const key in event) {
|
|
738
|
+
if (key !== "__type") {
|
|
739
|
+
unionMember = key;
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(unionMember, unionSchema, event);
|
|
744
|
+
const headers = {
|
|
745
|
+
":event-type": {
|
|
746
|
+
type: "string",
|
|
747
|
+
value: eventType
|
|
748
|
+
},
|
|
749
|
+
":message-type": {
|
|
750
|
+
type: "string",
|
|
751
|
+
value: "event"
|
|
752
|
+
},
|
|
753
|
+
":content-type": {
|
|
754
|
+
type: "string",
|
|
755
|
+
value: explicitPayloadContentType ?? defaultContentType
|
|
756
|
+
},
|
|
757
|
+
...additionalHeaders
|
|
758
|
+
};
|
|
759
|
+
return {
|
|
760
|
+
headers,
|
|
761
|
+
body
|
|
762
|
+
};
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
async deserializeEventStream({ response, responseSchema, initialResponseContainer }) {
|
|
766
|
+
const marshaller = this.marshaller;
|
|
767
|
+
const eventStreamMember = responseSchema.getEventStreamMember();
|
|
768
|
+
const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
|
|
769
|
+
const memberSchemas = unionSchema.getMemberSchemas();
|
|
770
|
+
const initialResponseMarker = Symbol("initialResponseMarker");
|
|
771
|
+
const asyncIterable = marshaller.deserialize(response.body, async (event) => {
|
|
772
|
+
let unionMember = "";
|
|
773
|
+
for (const key in event) {
|
|
774
|
+
if (key !== "__type") {
|
|
775
|
+
unionMember = key;
|
|
776
|
+
break;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
const body = event[unionMember].body;
|
|
780
|
+
if (unionMember === "initial-response") {
|
|
781
|
+
const dataObject = await this.deserializer.read(responseSchema, body);
|
|
782
|
+
delete dataObject[eventStreamMember];
|
|
783
|
+
return {
|
|
784
|
+
[initialResponseMarker]: true,
|
|
785
|
+
...dataObject
|
|
786
|
+
};
|
|
787
|
+
} else if (unionMember in memberSchemas) {
|
|
788
|
+
const eventStreamSchema = memberSchemas[unionMember];
|
|
789
|
+
if (eventStreamSchema.isStructSchema()) {
|
|
790
|
+
const out = {};
|
|
791
|
+
let hasBindings = false;
|
|
792
|
+
for (const [name, member] of eventStreamSchema.structIterator()) {
|
|
793
|
+
const { eventHeader, eventPayload } = member.getMergedTraits();
|
|
794
|
+
hasBindings = hasBindings || Boolean(eventHeader || eventPayload);
|
|
795
|
+
if (eventPayload) {
|
|
796
|
+
if (member.isBlobSchema()) {
|
|
797
|
+
out[name] = body;
|
|
798
|
+
} else if (member.isStringSchema()) {
|
|
799
|
+
out[name] = (this.serdeContext?.utf8Encoder ?? require_checksum.toUtf8)(body);
|
|
800
|
+
} else if (member.isStructSchema()) {
|
|
801
|
+
out[name] = await this.deserializer.read(member, body);
|
|
802
|
+
}
|
|
803
|
+
} else if (eventHeader) {
|
|
804
|
+
const value = event[unionMember].headers[name]?.value;
|
|
805
|
+
if (value != null) {
|
|
806
|
+
if (member.isNumericSchema()) {
|
|
807
|
+
if (value && typeof value === "object" && "bytes" in value) {
|
|
808
|
+
out[name] = BigInt(value.toString());
|
|
809
|
+
} else {
|
|
810
|
+
out[name] = Number(value);
|
|
811
|
+
}
|
|
812
|
+
} else {
|
|
813
|
+
out[name] = value;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
if (hasBindings) {
|
|
819
|
+
return { [unionMember]: out };
|
|
820
|
+
}
|
|
821
|
+
if (body.byteLength === 0) {
|
|
822
|
+
return { [unionMember]: {} };
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
return { [unionMember]: await this.deserializer.read(eventStreamSchema, body) };
|
|
826
|
+
} else {
|
|
827
|
+
return { $unknown: event };
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
const asyncIterator = asyncIterable[Symbol.asyncIterator]();
|
|
831
|
+
const firstEvent = await asyncIterator.next();
|
|
832
|
+
if (firstEvent.done) {
|
|
833
|
+
return asyncIterable;
|
|
834
|
+
}
|
|
835
|
+
if (firstEvent.value?.[initialResponseMarker]) {
|
|
836
|
+
if (!responseSchema) {
|
|
837
|
+
throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");
|
|
838
|
+
}
|
|
839
|
+
for (const key in firstEvent.value) {
|
|
840
|
+
initialResponseContainer[key] = firstEvent.value[key];
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return { async *[Symbol.asyncIterator]() {
|
|
844
|
+
if (!firstEvent?.value?.[initialResponseMarker]) {
|
|
845
|
+
yield firstEvent.value;
|
|
846
|
+
}
|
|
847
|
+
while (true) {
|
|
848
|
+
const { done, value } = await asyncIterator.next();
|
|
849
|
+
if (done) {
|
|
850
|
+
break;
|
|
851
|
+
}
|
|
852
|
+
yield value;
|
|
853
|
+
}
|
|
854
|
+
} };
|
|
855
|
+
}
|
|
856
|
+
writeEventBody(unionMember, unionSchema, event) {
|
|
857
|
+
const serializer = this.serializer;
|
|
858
|
+
let eventType = unionMember;
|
|
859
|
+
let explicitPayloadMember = null;
|
|
860
|
+
let explicitPayloadContentType;
|
|
861
|
+
const isKnownSchema = (() => {
|
|
862
|
+
const struct = unionSchema.getSchema();
|
|
863
|
+
return struct[4].includes(unionMember);
|
|
864
|
+
})();
|
|
865
|
+
const additionalHeaders = {};
|
|
866
|
+
if (!isKnownSchema) {
|
|
867
|
+
const [type, value] = event[unionMember];
|
|
868
|
+
eventType = type;
|
|
869
|
+
serializer.write(15, value);
|
|
870
|
+
} else {
|
|
871
|
+
const eventSchema = unionSchema.getMemberSchema(unionMember);
|
|
872
|
+
if (eventSchema.isStructSchema()) {
|
|
873
|
+
for (const [memberName, memberSchema] of eventSchema.structIterator()) {
|
|
874
|
+
const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
|
|
875
|
+
if (eventPayload) {
|
|
876
|
+
explicitPayloadMember = memberName;
|
|
877
|
+
} else if (eventHeader) {
|
|
878
|
+
const value = event[unionMember][memberName];
|
|
879
|
+
let type = "binary";
|
|
880
|
+
if (memberSchema.isNumericSchema()) {
|
|
881
|
+
if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
|
|
882
|
+
type = "integer";
|
|
883
|
+
} else {
|
|
884
|
+
type = "long";
|
|
885
|
+
}
|
|
886
|
+
} else if (memberSchema.isTimestampSchema()) {
|
|
887
|
+
type = "timestamp";
|
|
888
|
+
} else if (memberSchema.isStringSchema()) {
|
|
889
|
+
type = "string";
|
|
890
|
+
} else if (memberSchema.isBooleanSchema()) {
|
|
891
|
+
type = "boolean";
|
|
892
|
+
}
|
|
893
|
+
if (value != null) {
|
|
894
|
+
additionalHeaders[memberName] = {
|
|
895
|
+
type,
|
|
896
|
+
value
|
|
897
|
+
};
|
|
898
|
+
delete event[unionMember][memberName];
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
if (explicitPayloadMember !== null) {
|
|
903
|
+
const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
|
|
904
|
+
if (payloadSchema.isBlobSchema()) {
|
|
905
|
+
explicitPayloadContentType = "application/octet-stream";
|
|
906
|
+
} else if (payloadSchema.isStringSchema()) {
|
|
907
|
+
explicitPayloadContentType = "text/plain";
|
|
908
|
+
}
|
|
909
|
+
serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
|
|
910
|
+
} else {
|
|
911
|
+
serializer.write(eventSchema, event[unionMember]);
|
|
912
|
+
}
|
|
913
|
+
} else if (eventSchema.isUnitSchema()) {
|
|
914
|
+
serializer.write(eventSchema, {});
|
|
915
|
+
} else {
|
|
916
|
+
throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
const messageSerialization = serializer.flush() ?? new Uint8Array();
|
|
920
|
+
const body = typeof messageSerialization === "string" ? (this.serdeContext?.utf8Decoder ?? require_checksum.fromUtf8)(messageSerialization) : messageSerialization;
|
|
921
|
+
return {
|
|
922
|
+
body,
|
|
923
|
+
eventType,
|
|
924
|
+
explicitPayloadContentType,
|
|
925
|
+
additionalHeaders
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
}));
|
|
930
|
+
|
|
931
|
+
//#endregion
|
|
932
|
+
//#region ../../node_modules/.pnpm/@smithy+core@3.29.3/node_modules/@smithy/core/dist-es/submodules/event-streams/index.js
|
|
933
|
+
var init_event_streams = require_rolldown_runtime.__esmMin((() => {
|
|
934
|
+
init_EventStreamCodec();
|
|
935
|
+
init_HeaderMarshaller();
|
|
936
|
+
init_Int64();
|
|
937
|
+
init_MessageDecoderStream();
|
|
938
|
+
init_MessageEncoderStream();
|
|
939
|
+
init_SmithyMessageDecoderStream();
|
|
940
|
+
init_SmithyMessageEncoderStream();
|
|
941
|
+
init_EventStreamMarshaller();
|
|
942
|
+
init_utils();
|
|
943
|
+
init_EventStreamMarshaller$1();
|
|
944
|
+
init_getChunkedStream();
|
|
945
|
+
init_getUnmarshalledStream();
|
|
946
|
+
init_EventStreamSerdeConfig();
|
|
947
|
+
init_EventStreamSerde();
|
|
948
|
+
}));
|
|
949
|
+
|
|
950
|
+
//#endregion
|
|
951
|
+
init_event_streams();
|
|
952
|
+
exports.EventStreamSerde = EventStreamSerde;
|
|
953
|
+
exports.eventStreamSerdeProvider = eventStreamSerdeProvider;
|