@aws-sdk/core 3.975.2 → 3.976.0
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/submodules/httpAuthSchemes/index.js +1 -1
- package/dist-cjs/submodules/protocols/index.js +8 -8
- package/dist-es/submodules/httpAuthSchemes/utils/getDateHeader.js +1 -1
- package/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +1 -1
- package/dist-es/submodules/protocols/json/JsonShapeSerializer.js +1 -1
- package/dist-es/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.js +182 -0
- package/dist-es/submodules/protocols/json/experimental/ByteJsonShapeSerializer.js +473 -0
- package/dist-es/submodules/protocols/xml/XmlShapeDeserializer.js +2 -2
- package/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +4 -4
- package/dist-types/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.d.ts +29 -0
- package/dist-types/submodules/protocols/json/experimental/ByteJsonShapeSerializer.d.ts +59 -0
- package/dist-types/ts3.4/index.d.ts +1 -5
- package/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +2 -4
- package/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConstants.d.ts +1 -3
- package/dist-types/ts3.4/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts +2 -4
- package/dist-types/ts3.4/submodules/client/index.browser.d.ts +3 -12
- package/dist-types/ts3.4/submodules/client/index.d.ts +4 -16
- package/dist-types/ts3.4/submodules/client/index.native.d.ts +3 -12
- package/dist-types/ts3.4/submodules/client/longPollMiddleware.d.ts +2 -4
- package/dist-types/ts3.4/submodules/client/middleware-host-header/hostHeaderMiddleware.d.ts +5 -9
- package/dist-types/ts3.4/submodules/client/middleware-logger/loggerMiddleware.d.ts +3 -6
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/configuration.d.ts +1 -2
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.browser.d.ts +1 -3
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.d.ts +1 -3
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.browser.d.ts +1 -4
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.d.ts +1 -4
- package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.native.d.ts +1 -4
- package/dist-types/ts3.4/submodules/client/middleware-user-agent/check-features.d.ts +2 -6
- package/dist-types/ts3.4/submodules/client/middleware-user-agent/configurations.d.ts +1 -1
- package/dist-types/ts3.4/submodules/client/middleware-user-agent/user-agent-middleware.d.ts +4 -7
- package/dist-types/ts3.4/submodules/client/region-config-resolver/extensions.d.ts +2 -2
- package/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.d.ts +1 -1
- package/dist-types/ts3.4/submodules/client/setCredentialFeature.d.ts +3 -8
- package/dist-types/ts3.4/submodules/client/setFeature.d.ts +1 -1
- package/dist-types/ts3.4/submodules/client/setTokenFeature.d.ts +1 -1
- package/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/isVirtualHostableS3Bucket.d.ts +1 -1
- package/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partition.d.ts +1 -1
- package/dist-types/ts3.4/submodules/client/util-endpoints/resolveDefaultAwsRegionalEndpointsConfig.d.ts +3 -9
- package/dist-types/ts3.4/submodules/client/util-endpoints/types/RuleSetObject.d.ts +1 -5
- package/dist-types/ts3.4/submodules/client/util-user-agent-browser/createUserAgentStringParsingProvider.d.ts +1 -3
- package/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.d.ts +2 -6
- package/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.native.d.ts +2 -6
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/defaultUserAgent.d.ts +2 -6
- package/dist-types/ts3.4/submodules/client/util-user-agent-node/nodeAppIdConfigOptions.d.ts +1 -3
- package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.d.ts +2 -5
- package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.d.ts +4 -6
- package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/NODE_AUTH_SCHEME_PREFERENCE_OPTIONS.d.ts +1 -3
- package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/index.d.ts +2 -8
- package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.d.ts +3 -8
- package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.d.ts +8 -17
- package/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getUpdatedSystemClockOffset.d.ts +1 -1
- package/dist-types/ts3.4/submodules/httpAuthSchemes/utils/isClockSkewed.d.ts +1 -4
- package/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +6 -19
- package/dist-types/ts3.4/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.d.ts +2 -2
- package/dist-types/ts3.4/submodules/protocols/common.d.ts +1 -1
- package/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -5
- package/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +2 -2
- package/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +3 -3
- package/dist-types/ts3.4/submodules/protocols/json/JsonCodec.d.ts +1 -4
- package/dist-types/ts3.4/submodules/protocols/json/JsonShapeSerializer.d.ts +1 -5
- package/dist-types/ts3.4/submodules/protocols/json/awsExpectUnion.d.ts +1 -3
- package/dist-types/ts3.4/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.d.ts +14 -0
- package/dist-types/ts3.4/submodules/protocols/json/experimental/ByteJsonShapeSerializer.d.ts +30 -0
- package/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +1 -1
- package/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +4 -13
- package/dist-types/ts3.4/submodules/protocols/query/AwsQueryProtocol.d.ts +4 -7
- package/dist-types/ts3.4/submodules/protocols/query/QueryShapeSerializer.d.ts +1 -1
- package/dist-types/ts3.4/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +3 -3
- package/dist-types/ts3.4/submodules/protocols/xml/parseXmlBody.d.ts +3 -12
- package/dist-types/ts3.4/submodules/util/util-format-url/format-url.d.ts +1 -1
- package/package.json +65 -64
- package/dist-es/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.js +0 -135
- package/dist-types/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.d.ts +0 -27
- package/dist-types/ts3.4/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.d.ts +0 -17
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import { determineTimestampFormat } from "@smithy/core/protocols";
|
|
2
|
+
import { NormalizedSchema } from "@smithy/core/schema";
|
|
3
|
+
import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue, toBase64 } from "@smithy/core/serde";
|
|
4
|
+
import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
|
|
5
|
+
const encoder = new TextEncoder();
|
|
6
|
+
const OPEN_BRACE = 0x7b;
|
|
7
|
+
const CLOSE_BRACE = 0x7d;
|
|
8
|
+
const OPEN_BRACKET = 0x5b;
|
|
9
|
+
const CLOSE_BRACKET = 0x5d;
|
|
10
|
+
const QUOTE = 0x22;
|
|
11
|
+
const COLON = 0x3a;
|
|
12
|
+
const COMMA = 0x2c;
|
|
13
|
+
const BACKSLASH = 0x5c;
|
|
14
|
+
const TRUE = new Uint8Array([0x74, 0x72, 0x75, 0x65]);
|
|
15
|
+
const FALSE = new Uint8Array([0x66, 0x61, 0x6c, 0x73, 0x65]);
|
|
16
|
+
const NULL = new Uint8Array([0x6e, 0x75, 0x6c, 0x6c]);
|
|
17
|
+
const ESCAPE_TABLE = new Array(128).fill(null);
|
|
18
|
+
ESCAPE_TABLE[0x08] = "b";
|
|
19
|
+
ESCAPE_TABLE[0x09] = "t";
|
|
20
|
+
ESCAPE_TABLE[0x0a] = "n";
|
|
21
|
+
ESCAPE_TABLE[0x0c] = "f";
|
|
22
|
+
ESCAPE_TABLE[0x0d] = "r";
|
|
23
|
+
ESCAPE_TABLE[0x22] = '"';
|
|
24
|
+
ESCAPE_TABLE[0x5c] = "\\";
|
|
25
|
+
for (let i = 0; i < 0x20; i++) {
|
|
26
|
+
if (ESCAPE_TABLE[i] === null) {
|
|
27
|
+
ESCAPE_TABLE[i] = "u00" + i.toString(16).padStart(2, "0");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const INITIAL_BUFFER_SIZE = 2048;
|
|
31
|
+
function alloc(size) {
|
|
32
|
+
return typeof Buffer !== "undefined" ? Buffer.allocUnsafe(size) : new Uint8Array(size);
|
|
33
|
+
}
|
|
34
|
+
export class ByteJsonShapeSerializer extends SerdeContextConfig {
|
|
35
|
+
settings;
|
|
36
|
+
json;
|
|
37
|
+
i = 0;
|
|
38
|
+
rootSchema;
|
|
39
|
+
sizeHistory = new Uint32Array(20);
|
|
40
|
+
sizeHistoryIndex = 0;
|
|
41
|
+
constructor(settings) {
|
|
42
|
+
super();
|
|
43
|
+
this.settings = settings;
|
|
44
|
+
this.json = alloc(INITIAL_BUFFER_SIZE);
|
|
45
|
+
}
|
|
46
|
+
write(schema, value) {
|
|
47
|
+
this.i = 0;
|
|
48
|
+
this.rootSchema = NormalizedSchema.of(schema);
|
|
49
|
+
this.writeValue(this.rootSchema, value, undefined);
|
|
50
|
+
}
|
|
51
|
+
writeDiscriminatedDocument(schema, value) {
|
|
52
|
+
this.i = 0;
|
|
53
|
+
this.rootSchema = NormalizedSchema.of(schema);
|
|
54
|
+
const ns = this.rootSchema;
|
|
55
|
+
if (ns.isStructSchema() && value != null && typeof value === "object") {
|
|
56
|
+
this.ensure(2);
|
|
57
|
+
this.json[this.i++] = OPEN_BRACE;
|
|
58
|
+
this.writeAsciiQuoted("__type");
|
|
59
|
+
this.json[this.i++] = COLON;
|
|
60
|
+
this.writeAsciiQuoted(ns.getName(true) ?? "Unknown");
|
|
61
|
+
let wroteAny = true;
|
|
62
|
+
const { jsonName } = this.settings;
|
|
63
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
64
|
+
const item = value[memberName];
|
|
65
|
+
if (item == null && !memberSchema.isIdempotencyToken()) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (wroteAny) {
|
|
69
|
+
this.ensure(1);
|
|
70
|
+
this.json[this.i++] = COMMA;
|
|
71
|
+
}
|
|
72
|
+
const targetKey = jsonName ? (memberSchema.getMergedTraits().jsonName ?? memberName) : memberName;
|
|
73
|
+
this.writeAsciiQuoted(targetKey);
|
|
74
|
+
this.json[this.i++] = COLON;
|
|
75
|
+
this.writeValue(memberSchema, item, ns);
|
|
76
|
+
wroteAny = true;
|
|
77
|
+
}
|
|
78
|
+
this.ensure(1);
|
|
79
|
+
this.json[this.i++] = CLOSE_BRACE;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.writeValue(ns, value, undefined);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
flush() {
|
|
86
|
+
this.rootSchema = undefined;
|
|
87
|
+
const finalPosition = this.i;
|
|
88
|
+
this.i = 0;
|
|
89
|
+
this.sizeHistory[this.sizeHistoryIndex] = finalPosition;
|
|
90
|
+
this.sizeHistoryIndex = (this.sizeHistoryIndex + 1) % 20;
|
|
91
|
+
let max = INITIAL_BUFFER_SIZE;
|
|
92
|
+
for (let i = 0; i < 20; i++) {
|
|
93
|
+
if (this.sizeHistory[i] > max)
|
|
94
|
+
max = this.sizeHistory[i];
|
|
95
|
+
}
|
|
96
|
+
if (this.json.byteLength < max) {
|
|
97
|
+
this.json = alloc(max);
|
|
98
|
+
}
|
|
99
|
+
return this.json.slice(0, finalPosition);
|
|
100
|
+
}
|
|
101
|
+
ensure(byteCount) {
|
|
102
|
+
const { i, json } = this;
|
|
103
|
+
if (i + byteCount > json.length) {
|
|
104
|
+
let newSize = json.length * 2;
|
|
105
|
+
while (newSize < i + byteCount) {
|
|
106
|
+
newSize *= 2;
|
|
107
|
+
}
|
|
108
|
+
const next = alloc(newSize);
|
|
109
|
+
next.set(this.json);
|
|
110
|
+
this.json = next;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
writeAscii(s) {
|
|
114
|
+
const z = s.length;
|
|
115
|
+
this.ensure(z);
|
|
116
|
+
let { i, json } = this;
|
|
117
|
+
for (let j = 0; j < z; ++j) {
|
|
118
|
+
json[i] = s.charCodeAt(j);
|
|
119
|
+
i += 1;
|
|
120
|
+
}
|
|
121
|
+
this.i = i;
|
|
122
|
+
}
|
|
123
|
+
writeAsciiQuoted(s) {
|
|
124
|
+
const z = s.length;
|
|
125
|
+
this.ensure(z + 4);
|
|
126
|
+
let { json, i } = this;
|
|
127
|
+
json[i++] = QUOTE;
|
|
128
|
+
for (let j = 0; j < z; ++j) {
|
|
129
|
+
json[i++] = s.charCodeAt(j);
|
|
130
|
+
}
|
|
131
|
+
json[i++] = QUOTE;
|
|
132
|
+
this.i = i;
|
|
133
|
+
}
|
|
134
|
+
writeJsonString(s) {
|
|
135
|
+
this.ensure(s.length * 2 + 2);
|
|
136
|
+
this.json[this.i++] = QUOTE;
|
|
137
|
+
const z = s.length;
|
|
138
|
+
for (let j = 0; j < z; ++j) {
|
|
139
|
+
const c = s.charCodeAt(j);
|
|
140
|
+
if (c > 0x22 && c < 0x5c) {
|
|
141
|
+
this.json[this.i++] = c;
|
|
142
|
+
}
|
|
143
|
+
else if (c < 0x80) {
|
|
144
|
+
const esc = ESCAPE_TABLE[c];
|
|
145
|
+
if (esc !== null) {
|
|
146
|
+
this.ensure(esc.length + 1);
|
|
147
|
+
this.json[this.i++] = BACKSLASH;
|
|
148
|
+
for (let j = 0; j < esc.length; j++) {
|
|
149
|
+
this.json[this.i++] = esc.charCodeAt(j);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
this.json[this.i++] = c;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else if (c >= 0xd800 && c <= 0xdbff) {
|
|
157
|
+
const next = j + 1 < z ? s.charCodeAt(j + 1) : 0;
|
|
158
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
159
|
+
this.ensure(4);
|
|
160
|
+
const { written } = encoder.encodeInto(s.substring(j, j + 2), this.json.subarray(this.i));
|
|
161
|
+
this.i += written;
|
|
162
|
+
j++;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
this.ensure(6);
|
|
166
|
+
this.writeUnicodeEscape(c);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else if (c >= 0xdc00 && c <= 0xdfff) {
|
|
170
|
+
this.ensure(6);
|
|
171
|
+
this.writeUnicodeEscape(c);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
let { i, json } = this;
|
|
175
|
+
if (c < 0x800) {
|
|
176
|
+
json[i++] = 0xc0 | (c >> 6);
|
|
177
|
+
json[i++] = 0x80 | (c & 0x3f);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
json[i++] = 0xe0 | (c >> 12);
|
|
181
|
+
json[i++] = 0x80 | ((c >> 6) & 0x3f);
|
|
182
|
+
json[i++] = 0x80 | (c & 0x3f);
|
|
183
|
+
}
|
|
184
|
+
this.i = i;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
this.json[this.i++] = QUOTE;
|
|
188
|
+
}
|
|
189
|
+
writeUnicodeEscape(code) {
|
|
190
|
+
let { json, i } = this;
|
|
191
|
+
json[i++] = BACKSLASH;
|
|
192
|
+
json[i++] = 0x75;
|
|
193
|
+
const hex = code.toString(16).padStart(4, "0");
|
|
194
|
+
for (let j = 0; j < 4; ++j) {
|
|
195
|
+
json[i++] = hex.charCodeAt(j);
|
|
196
|
+
}
|
|
197
|
+
this.i = i;
|
|
198
|
+
}
|
|
199
|
+
static B64 = (() => {
|
|
200
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
201
|
+
const table = new Uint8Array(64);
|
|
202
|
+
for (let i = 0; i < 64; i++)
|
|
203
|
+
table[i] = chars.charCodeAt(i);
|
|
204
|
+
return table;
|
|
205
|
+
})();
|
|
206
|
+
writeBase64(data) {
|
|
207
|
+
const b64Len = Math.ceil(data.length / 3) * 4;
|
|
208
|
+
this.ensure(b64Len + 2);
|
|
209
|
+
const json = this.json;
|
|
210
|
+
const B64 = ByteJsonShapeSerializer.B64;
|
|
211
|
+
let i = this.i;
|
|
212
|
+
json[i++] = QUOTE;
|
|
213
|
+
const len = data.length;
|
|
214
|
+
const remainder = len % 3;
|
|
215
|
+
const mainLen = len - remainder;
|
|
216
|
+
for (let j = 0; j < mainLen; j += 3) {
|
|
217
|
+
const a = data[j];
|
|
218
|
+
const b = data[j + 1];
|
|
219
|
+
const c = data[j + 2];
|
|
220
|
+
json[i++] = B64[a >> 2];
|
|
221
|
+
json[i++] = B64[((a & 0x03) << 4) | (b >> 4)];
|
|
222
|
+
json[i++] = B64[((b & 0x0f) << 2) | (c >> 6)];
|
|
223
|
+
json[i++] = B64[c & 0x3f];
|
|
224
|
+
}
|
|
225
|
+
if (remainder === 2) {
|
|
226
|
+
const a = data[mainLen];
|
|
227
|
+
const b = data[mainLen + 1];
|
|
228
|
+
json[i++] = B64[a >> 2];
|
|
229
|
+
json[i++] = B64[((a & 0x03) << 4) | (b >> 4)];
|
|
230
|
+
json[i++] = B64[(b & 0x0f) << 2];
|
|
231
|
+
json[i++] = 0x3d;
|
|
232
|
+
}
|
|
233
|
+
else if (remainder === 1) {
|
|
234
|
+
const a = data[mainLen];
|
|
235
|
+
json[i++] = B64[a >> 2];
|
|
236
|
+
json[i++] = B64[(a & 0x03) << 4];
|
|
237
|
+
json[i++] = 0x3d;
|
|
238
|
+
json[i++] = 0x3d;
|
|
239
|
+
}
|
|
240
|
+
json[i++] = QUOTE;
|
|
241
|
+
this.i = i;
|
|
242
|
+
}
|
|
243
|
+
writeValue(schema, value, container) {
|
|
244
|
+
if (value == null) {
|
|
245
|
+
if (container?.isStructSchema()) {
|
|
246
|
+
if (value === undefined) {
|
|
247
|
+
const ns = NormalizedSchema.of(schema);
|
|
248
|
+
if (ns.isIdempotencyToken()) {
|
|
249
|
+
this.writeAsciiQuoted(generateIdempotencyToken());
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
this.ensure(4);
|
|
256
|
+
this.json.set(NULL, this.i);
|
|
257
|
+
this.i += 4;
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const ns = NormalizedSchema.of(schema);
|
|
261
|
+
const isObject = typeof value === "object";
|
|
262
|
+
if (isObject) {
|
|
263
|
+
if (ns.isStructSchema()) {
|
|
264
|
+
this.writeStruct(ns, value);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (Array.isArray(value) && (ns.isListSchema() || ns.isDocumentSchema())) {
|
|
268
|
+
this.writeList(ns, value, ns.isDocumentSchema());
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (ns.isMapSchema()) {
|
|
272
|
+
this.writeMap(ns, value, false);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (value instanceof Uint8Array && (ns.isBlobSchema() || ns.isDocumentSchema())) {
|
|
276
|
+
this.writeBase64(value);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (value instanceof Date && (ns.isTimestampSchema() || ns.isDocumentSchema())) {
|
|
280
|
+
this.writeTimestamp(ns, value);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (value instanceof NumericValue) {
|
|
284
|
+
this.writeAscii(value.string);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (ns.isDocumentSchema()) {
|
|
288
|
+
if (Array.isArray(value)) {
|
|
289
|
+
this.writeList(ns, value, true);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
this.writeMap(ns, value, true);
|
|
293
|
+
}
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const json = JSON.stringify(value);
|
|
297
|
+
this.writeAscii(json);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (typeof value === "string") {
|
|
301
|
+
if (ns.isStringSchema()) {
|
|
302
|
+
const mediaType = ns.getMergedTraits().mediaType;
|
|
303
|
+
if (mediaType) {
|
|
304
|
+
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
|
305
|
+
if (isJson) {
|
|
306
|
+
this.writeJsonString(LazyJsonString.from(value).toString());
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (ns.isBlobSchema()) {
|
|
312
|
+
const b64 = (this.serdeContext?.base64Encoder ?? toBase64)(value);
|
|
313
|
+
this.writeAsciiQuoted(b64);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
this.writeJsonString(value);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (typeof value === "number") {
|
|
320
|
+
if (ns.isNumericSchema() && (Math.abs(value) === Infinity || isNaN(value))) {
|
|
321
|
+
this.writeAsciiQuoted(String(value));
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const numStr = String(value);
|
|
325
|
+
this.writeAscii(numStr);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (typeof value === "boolean") {
|
|
329
|
+
this.ensure(5);
|
|
330
|
+
if (value) {
|
|
331
|
+
this.json.set(TRUE, this.i);
|
|
332
|
+
this.i += 4;
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
this.json.set(FALSE, this.i);
|
|
336
|
+
this.i += 5;
|
|
337
|
+
}
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (typeof value === "bigint") {
|
|
341
|
+
this.writeAscii(value.toString());
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
this.writeAscii(String(value));
|
|
345
|
+
}
|
|
346
|
+
writeStruct(ns, value) {
|
|
347
|
+
this.ensure(2);
|
|
348
|
+
this.json[this.i++] = OPEN_BRACE;
|
|
349
|
+
let first = true;
|
|
350
|
+
let wroteAny = false;
|
|
351
|
+
const hasType = typeof value.__type === "string";
|
|
352
|
+
let writtenKeys;
|
|
353
|
+
if (hasType) {
|
|
354
|
+
writtenKeys = new Set();
|
|
355
|
+
}
|
|
356
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
357
|
+
const item = value[memberName];
|
|
358
|
+
if (item == null && !memberSchema.isIdempotencyToken())
|
|
359
|
+
continue;
|
|
360
|
+
if (!first) {
|
|
361
|
+
this.ensure(1);
|
|
362
|
+
this.json[this.i++] = COMMA;
|
|
363
|
+
}
|
|
364
|
+
first = false;
|
|
365
|
+
wroteAny = true;
|
|
366
|
+
const targetKey = this.settings.jsonName ? (memberSchema.getMergedTraits().jsonName ?? memberName) : memberName;
|
|
367
|
+
if (writtenKeys) {
|
|
368
|
+
writtenKeys.add(memberName);
|
|
369
|
+
writtenKeys.add(targetKey);
|
|
370
|
+
}
|
|
371
|
+
this.writeAsciiQuoted(targetKey);
|
|
372
|
+
this.json[this.i++] = COLON;
|
|
373
|
+
this.writeValue(memberSchema, item, ns);
|
|
374
|
+
}
|
|
375
|
+
if (!wroteAny && ns.isUnionSchema()) {
|
|
376
|
+
const { $unknown } = value;
|
|
377
|
+
if (Array.isArray($unknown)) {
|
|
378
|
+
const [k, v] = $unknown;
|
|
379
|
+
this.writeAsciiQuoted(k);
|
|
380
|
+
this.ensure(1);
|
|
381
|
+
this.json[this.i++] = COLON;
|
|
382
|
+
this.writeValue(15, v, ns);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
else if (hasType) {
|
|
386
|
+
for (const k in value) {
|
|
387
|
+
const targetKey = this.settings.jsonName ? (writtenKeys.has(k) ? k : k) : k;
|
|
388
|
+
if (writtenKeys.has(targetKey))
|
|
389
|
+
continue;
|
|
390
|
+
writtenKeys.add(targetKey);
|
|
391
|
+
const v = value[k];
|
|
392
|
+
if (!first) {
|
|
393
|
+
this.ensure(1);
|
|
394
|
+
this.json[this.i++] = COMMA;
|
|
395
|
+
}
|
|
396
|
+
first = false;
|
|
397
|
+
this.writeAsciiQuoted(targetKey);
|
|
398
|
+
this.ensure(1);
|
|
399
|
+
this.json[this.i++] = COLON;
|
|
400
|
+
this.writeValue(15, v, undefined);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
this.ensure(1);
|
|
404
|
+
this.json[this.i++] = CLOSE_BRACE;
|
|
405
|
+
}
|
|
406
|
+
writeList(ns, value, isDocument) {
|
|
407
|
+
this.ensure(2);
|
|
408
|
+
this.json[this.i++] = OPEN_BRACKET;
|
|
409
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
410
|
+
const valueSchema = ns.getValueSchema();
|
|
411
|
+
for (let i = 0; i < value.length; ++i) {
|
|
412
|
+
const item = value[i];
|
|
413
|
+
if (isDocument ? item === undefined : item == null && !sparse) {
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (i !== 0) {
|
|
417
|
+
this.ensure(1);
|
|
418
|
+
this.json[this.i++] = COMMA;
|
|
419
|
+
}
|
|
420
|
+
this.writeValue(valueSchema, item, undefined);
|
|
421
|
+
}
|
|
422
|
+
this.ensure(1);
|
|
423
|
+
this.json[this.i++] = CLOSE_BRACKET;
|
|
424
|
+
}
|
|
425
|
+
writeMap(ns, value, isDocument) {
|
|
426
|
+
this.ensure(2);
|
|
427
|
+
this.json[this.i++] = OPEN_BRACE;
|
|
428
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
429
|
+
const valueSchema = ns.getValueSchema();
|
|
430
|
+
let first = true;
|
|
431
|
+
for (const k in value) {
|
|
432
|
+
const v = value[k];
|
|
433
|
+
if (isDocument ? v === undefined : v == null && !sparse) {
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
if (!first) {
|
|
437
|
+
this.ensure(1);
|
|
438
|
+
this.json[this.i++] = COMMA;
|
|
439
|
+
}
|
|
440
|
+
first = false;
|
|
441
|
+
this.writeJsonString(k);
|
|
442
|
+
this.ensure(1);
|
|
443
|
+
this.json[this.i++] = COLON;
|
|
444
|
+
this.writeValue(valueSchema, v, undefined);
|
|
445
|
+
}
|
|
446
|
+
this.ensure(1);
|
|
447
|
+
this.json[this.i++] = CLOSE_BRACE;
|
|
448
|
+
}
|
|
449
|
+
writeTimestamp(ns, value) {
|
|
450
|
+
const format = determineTimestampFormat(ns, this.settings);
|
|
451
|
+
switch (format) {
|
|
452
|
+
case 5: {
|
|
453
|
+
const iso = value.toISOString().replace(".000Z", "Z");
|
|
454
|
+
this.writeAsciiQuoted(iso);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
case 6: {
|
|
458
|
+
this.writeAsciiQuoted(dateToUtcString(value));
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
case 7: {
|
|
462
|
+
const epochSecs = String(value.getTime() / 1000);
|
|
463
|
+
this.writeAscii(epochSecs);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
default: {
|
|
467
|
+
const epochSecs = String(value.getTime() / 1000);
|
|
468
|
+
this.writeAscii(epochSecs);
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
@@ -98,8 +98,8 @@ export class XmlShapeDeserializer extends SerdeContextConfig {
|
|
|
98
98
|
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
99
99
|
const memberTraits = memberSchema.getMergedTraits();
|
|
100
100
|
const xmlObjectKey = !memberTraits.httpPayload
|
|
101
|
-
? memberSchema.getMemberTraits().xmlName ?? memberName
|
|
102
|
-
: memberTraits.xmlName ?? memberSchema.getName();
|
|
101
|
+
? (memberSchema.getMemberTraits().xmlName ?? memberName)
|
|
102
|
+
: (memberTraits.xmlName ?? memberSchema.getName());
|
|
103
103
|
if (union) {
|
|
104
104
|
unionSerde.mark(xmlObjectKey);
|
|
105
105
|
}
|
|
@@ -55,8 +55,8 @@ export class XmlShapeSerializer extends SerdeContextConfig {
|
|
|
55
55
|
writeStruct(ns, value, parentXmlns) {
|
|
56
56
|
const traits = ns.getMergedTraits();
|
|
57
57
|
const name = ns.isMemberSchema() && !traits.httpPayload
|
|
58
|
-
? ns.getMemberTraits().xmlName ?? ns.getMemberName()
|
|
59
|
-
: traits.xmlName ?? ns.getName();
|
|
58
|
+
? (ns.getMemberTraits().xmlName ?? ns.getMemberName())
|
|
59
|
+
: (traits.xmlName ?? ns.getName());
|
|
60
60
|
if (!name || !ns.isStructSchema()) {
|
|
61
61
|
throw new Error(`@aws-sdk/core/protocols - xml serializer, cannot write struct with empty name or non-struct, schema=${ns.getName(true)}.`);
|
|
62
62
|
}
|
|
@@ -125,10 +125,10 @@ export class XmlShapeSerializer extends SerdeContextConfig {
|
|
|
125
125
|
}
|
|
126
126
|
else if (listValueSchema.isStructSchema()) {
|
|
127
127
|
const struct = this.writeStruct(listValueSchema, value, xmlns);
|
|
128
|
-
container.addChildNode(struct.withName(flat ? listTraits.xmlName ?? listMember.getMemberName() : listValueTraits.xmlName ?? "member"));
|
|
128
|
+
container.addChildNode(struct.withName(flat ? (listTraits.xmlName ?? listMember.getMemberName()) : (listValueTraits.xmlName ?? "member")));
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
|
-
const listItemNode = XmlNode.of(flat ? listTraits.xmlName ?? listMember.getMemberName() : listValueTraits.xmlName ?? "member");
|
|
131
|
+
const listItemNode = XmlNode.of(flat ? (listTraits.xmlName ?? listMember.getMemberName()) : (listValueTraits.xmlName ?? "member"));
|
|
132
132
|
this.writeSimpleInto(listValueSchema, value, listItemNode, xmlns);
|
|
133
133
|
container.addChildNode(listItemNode);
|
|
134
134
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DocumentType, Schema, ShapeDeserializer } from "@smithy/types";
|
|
2
|
+
import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
|
|
3
|
+
import type { JsonSettings } from "../JsonCodec";
|
|
4
|
+
/**
|
|
5
|
+
* Performance-optimized JSON deserializer.
|
|
6
|
+
*
|
|
7
|
+
* Skips UTF-8 decoding when the runtime supports JSON.parse(Buffer) (Node 22+).
|
|
8
|
+
*
|
|
9
|
+
* After JSON.parse, lists, maps, and document containers are mutated in place
|
|
10
|
+
* (element values are overwritten with their deserialized form) rather than
|
|
11
|
+
* copied into new arrays/objects. Structs allocate a fresh object because
|
|
12
|
+
* jsonName traits require key renaming, and building the output object
|
|
13
|
+
* incrementally lets V8 assign a stable hidden class rather than
|
|
14
|
+
* deoptimizing from repeated property deletion/addition on an existing shape.
|
|
15
|
+
*
|
|
16
|
+
* In-place mutation is safe here because the parsed tree is locally owned
|
|
17
|
+
* after JSON.parse with no external references, so rewriting values avoids
|
|
18
|
+
* redundant allocation and GC pressure.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare class BufferJsonShapeDeserializer extends SerdeContextConfig implements ShapeDeserializer<string> {
|
|
23
|
+
readonly settings: JsonSettings;
|
|
24
|
+
constructor(settings: JsonSettings);
|
|
25
|
+
read(schema: Schema, data: string | Uint8Array | unknown): Promise<any>;
|
|
26
|
+
readObject(schema: Schema, data: DocumentType): any;
|
|
27
|
+
protected _read(schema: Schema, value: unknown): any;
|
|
28
|
+
private _readStruct;
|
|
29
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Schema, ShapeSerializer } from "@smithy/types";
|
|
2
|
+
import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
|
|
3
|
+
import type { JsonSettings } from "../JsonCodec";
|
|
4
|
+
/**
|
|
5
|
+
* Experimental single-pass JSON serializer that writes directly to a Uint8Array buffer.
|
|
6
|
+
* Fewer intermediate states as when compared to the initial multi-pass implementation.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class ByteJsonShapeSerializer extends SerdeContextConfig implements ShapeSerializer<Uint8Array> {
|
|
11
|
+
readonly settings: JsonSettings;
|
|
12
|
+
private json;
|
|
13
|
+
private i;
|
|
14
|
+
private rootSchema;
|
|
15
|
+
private readonly sizeHistory;
|
|
16
|
+
private sizeHistoryIndex;
|
|
17
|
+
constructor(settings: JsonSettings);
|
|
18
|
+
write(schema: Schema, value: unknown): void;
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
writeDiscriminatedDocument(schema: Schema, value: unknown): void;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the serialized JSON as a Uint8Array (UTF-8 bytes).
|
|
25
|
+
* This is the primary output — pass directly to request.body.
|
|
26
|
+
*/
|
|
27
|
+
flush(): Uint8Array;
|
|
28
|
+
private ensure;
|
|
29
|
+
/**
|
|
30
|
+
* Write a raw ASCII string (no JSON escaping). Used for pre-validated content
|
|
31
|
+
* like numeric literals and pre-encoded base64.
|
|
32
|
+
*/
|
|
33
|
+
private writeAscii;
|
|
34
|
+
/**
|
|
35
|
+
* Write a quoted ASCII string with no escape checking.
|
|
36
|
+
* Used for struct member keys (jsonName or model names) which are
|
|
37
|
+
* guaranteed to be safe ASCII identifiers. No control chars, quotes,
|
|
38
|
+
* backslashes, or non-ASCII.
|
|
39
|
+
* Ensures extra room for surrounding structural chars (comma, colon).
|
|
40
|
+
*/
|
|
41
|
+
private writeAsciiQuoted;
|
|
42
|
+
/**
|
|
43
|
+
* Write a JSON-escaped string including the surrounding quotes.
|
|
44
|
+
* Fast-path for ASCII, falls back to TextEncoder for multi-byte.
|
|
45
|
+
*/
|
|
46
|
+
private writeJsonString;
|
|
47
|
+
private writeUnicodeEscape;
|
|
48
|
+
private static readonly B64;
|
|
49
|
+
/**
|
|
50
|
+
* Write a Uint8Array as a quoted base64 string directly into the buffer.
|
|
51
|
+
* No intermediate JS string, no escape checking (base64 alphabet is safe ASCII).
|
|
52
|
+
*/
|
|
53
|
+
private writeBase64;
|
|
54
|
+
private writeValue;
|
|
55
|
+
private writeStruct;
|
|
56
|
+
private writeList;
|
|
57
|
+
private writeMap;
|
|
58
|
+
private writeTimestamp;
|
|
59
|
+
}
|
|
@@ -58,8 +58,4 @@ export {
|
|
|
58
58
|
XmlShapeDeserializer,
|
|
59
59
|
XmlShapeSerializer,
|
|
60
60
|
} from "@aws-sdk/core/protocols";
|
|
61
|
-
export {
|
|
62
|
-
JsonSettings,
|
|
63
|
-
QuerySerializerSettings,
|
|
64
|
-
XmlSettings,
|
|
65
|
-
} from "@aws-sdk/core/protocols";
|
|
61
|
+
export { JsonSettings, QuerySerializerSettings, XmlSettings } from "@aws-sdk/core/protocols";
|
package/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { Provider } from "@smithy/types";
|
|
2
2
|
import { AccountIdEndpointMode } from "./AccountIdEndpointModeConstants";
|
|
3
3
|
export interface AccountIdEndpointModeInputConfig {
|
|
4
|
-
accountIdEndpointMode?:
|
|
5
|
-
| AccountIdEndpointMode
|
|
6
|
-
| Provider<AccountIdEndpointMode>;
|
|
4
|
+
accountIdEndpointMode?: AccountIdEndpointMode | Provider<AccountIdEndpointMode>;
|
|
7
5
|
}
|
|
8
6
|
interface PreviouslyResolved {}
|
|
9
7
|
export interface AccountIdEndpointModeResolvedConfig {
|
|
10
8
|
accountIdEndpointMode: Provider<AccountIdEndpointMode>;
|
|
11
9
|
}
|
|
12
10
|
export declare const resolveAccountIdEndpointModeConfig: <T>(
|
|
13
|
-
input: T & AccountIdEndpointModeInputConfig & PreviouslyResolved
|
|
11
|
+
input: T & AccountIdEndpointModeInputConfig & PreviouslyResolved,
|
|
14
12
|
) => T & AccountIdEndpointModeResolvedConfig;
|
|
15
13
|
export {};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export type AccountIdEndpointMode = "disabled" | "preferred" | "required";
|
|
2
2
|
export declare const DEFAULT_ACCOUNT_ID_ENDPOINT_MODE = "preferred";
|
|
3
3
|
export declare const ACCOUNT_ID_ENDPOINT_MODE_VALUES: AccountIdEndpointMode[];
|
|
4
|
-
export declare function validateAccountIdEndpointMode(
|
|
5
|
-
value: any
|
|
6
|
-
): value is AccountIdEndpointMode;
|
|
4
|
+
export declare function validateAccountIdEndpointMode(value: any): value is AccountIdEndpointMode;
|
package/dist-types/ts3.4/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { LoadedConfigSelectors } from "@smithy/core/config";
|
|
2
2
|
import { AccountIdEndpointMode } from "./AccountIdEndpointModeConstants";
|
|
3
|
-
export declare const ENV_ACCOUNT_ID_ENDPOINT_MODE =
|
|
4
|
-
|
|
5
|
-
export declare const CONFIG_ACCOUNT_ID_ENDPOINT_MODE =
|
|
6
|
-
"account_id_endpoint_mode";
|
|
3
|
+
export declare const ENV_ACCOUNT_ID_ENDPOINT_MODE = "AWS_ACCOUNT_ID_ENDPOINT_MODE";
|
|
4
|
+
export declare const CONFIG_ACCOUNT_ID_ENDPOINT_MODE = "account_id_endpoint_mode";
|
|
7
5
|
export declare const NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS: LoadedConfigSelectors<AccountIdEndpointMode>;
|
|
@@ -22,10 +22,7 @@ export {
|
|
|
22
22
|
export { recursionDetectionMiddlewareOptions } from "./middleware-recursion-detection/configuration";
|
|
23
23
|
export { getRecursionDetectionPlugin } from "./middleware-recursion-detection/getRecursionDetectionPlugin.browser";
|
|
24
24
|
export { recursionDetectionMiddleware } from "./middleware-recursion-detection/recursionDetectionMiddleware.browser";
|
|
25
|
-
export {
|
|
26
|
-
DEFAULT_UA_APP_ID,
|
|
27
|
-
resolveUserAgentConfig,
|
|
28
|
-
} from "./middleware-user-agent/configurations";
|
|
25
|
+
export { DEFAULT_UA_APP_ID, resolveUserAgentConfig } from "./middleware-user-agent/configurations";
|
|
29
26
|
export {
|
|
30
27
|
UserAgentInputConfig,
|
|
31
28
|
UserAgentResolvedConfig,
|
|
@@ -77,10 +74,7 @@ export {
|
|
|
77
74
|
EndpointRuleObject,
|
|
78
75
|
} from "./util-endpoints/types/EndpointRuleObject";
|
|
79
76
|
export { ErrorRuleObject } from "./util-endpoints/types/ErrorRuleObject";
|
|
80
|
-
export {
|
|
81
|
-
RuleSetRules,
|
|
82
|
-
TreeRuleObject,
|
|
83
|
-
} from "./util-endpoints/types/TreeRuleObject";
|
|
77
|
+
export { RuleSetRules, TreeRuleObject } from "./util-endpoints/types/TreeRuleObject";
|
|
84
78
|
export {
|
|
85
79
|
DeprecatedObject,
|
|
86
80
|
ParameterObject,
|
|
@@ -103,10 +97,7 @@ export declare const REGION_INI_NAME: symbol;
|
|
|
103
97
|
export declare const NODE_REGION_CONFIG_OPTIONS: symbol;
|
|
104
98
|
export declare const NODE_REGION_CONFIG_FILE_OPTIONS: symbol;
|
|
105
99
|
export { resolveRegionConfig } from "./region-config-resolver/awsRegionConfig";
|
|
106
|
-
export {
|
|
107
|
-
RegionInputConfig,
|
|
108
|
-
RegionResolvedConfig,
|
|
109
|
-
} from "./region-config-resolver/awsRegionConfig";
|
|
100
|
+
export { RegionInputConfig, RegionResolvedConfig } from "./region-config-resolver/awsRegionConfig";
|
|
110
101
|
export { stsRegionDefaultResolver } from "./region-config-resolver/stsRegionDefaultResolver.browser";
|
|
111
102
|
export declare const stsRegionWarning: symbol;
|
|
112
103
|
export {
|