@cdk8s/awscdk-resolver 0.0.635 → 0.0.636
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/.jsii +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +3 -3
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.js +182 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/experimental/ByteJsonShapeSerializer.js +473 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.d.ts +29 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/experimental/ByteJsonShapeSerializer.d.ts +59 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.d.ts +14 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/experimental/ByteJsonShapeSerializer.d.ts +30 -0
- package/node_modules/@aws-sdk/core/package.json +2 -1
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +34 -11
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +34 -11
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +34 -11
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/event-streams/EventStreamSerde.d.ts +10 -2
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/event-streams/EventStreamSerde.d.ts +10 -2
- package/node_modules/@smithy/core/package.json +1 -1
- package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
- package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
- package/node_modules/@smithy/node-http-handler/package.json +2 -2
- package/node_modules/@smithy/signature-v4/package.json +2 -2
- package/package.json +2 -2
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.js +0 -135
- package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.d.ts +0 -27
- package/node_modules/@aws-sdk/core/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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DocumentType, Schema, ShapeDeserializer } from "@smithy/types";
|
|
2
|
+
import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
|
|
3
|
+
import { JsonSettings } from "../JsonCodec";
|
|
4
|
+
export declare class BufferJsonShapeDeserializer
|
|
5
|
+
extends SerdeContextConfig
|
|
6
|
+
implements ShapeDeserializer<string>
|
|
7
|
+
{
|
|
8
|
+
readonly settings: JsonSettings;
|
|
9
|
+
constructor(settings: JsonSettings);
|
|
10
|
+
read(schema: Schema, data: string | Uint8Array | unknown): Promise<any>;
|
|
11
|
+
readObject(schema: Schema, data: DocumentType): any;
|
|
12
|
+
protected _read(schema: Schema, value: unknown): any;
|
|
13
|
+
private _readStruct;
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Schema, ShapeSerializer } from "@smithy/types";
|
|
2
|
+
import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
|
|
3
|
+
import { JsonSettings } from "../JsonCodec";
|
|
4
|
+
export declare class ByteJsonShapeSerializer
|
|
5
|
+
extends SerdeContextConfig
|
|
6
|
+
implements ShapeSerializer<Uint8Array>
|
|
7
|
+
{
|
|
8
|
+
readonly settings: JsonSettings;
|
|
9
|
+
private json;
|
|
10
|
+
private i;
|
|
11
|
+
private rootSchema;
|
|
12
|
+
private readonly sizeHistory;
|
|
13
|
+
private sizeHistoryIndex;
|
|
14
|
+
constructor(settings: JsonSettings);
|
|
15
|
+
write(schema: Schema, value: unknown): void;
|
|
16
|
+
writeDiscriminatedDocument(schema: Schema, value: unknown): void;
|
|
17
|
+
flush(): Uint8Array;
|
|
18
|
+
private ensure;
|
|
19
|
+
private writeAscii;
|
|
20
|
+
private writeAsciiQuoted;
|
|
21
|
+
private writeJsonString;
|
|
22
|
+
private writeUnicodeEscape;
|
|
23
|
+
private static readonly B64;
|
|
24
|
+
private writeBase64;
|
|
25
|
+
private writeValue;
|
|
26
|
+
private writeStruct;
|
|
27
|
+
private writeList;
|
|
28
|
+
private writeMap;
|
|
29
|
+
private writeTimestamp;
|
|
30
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.976.0",
|
|
4
4
|
"description": "Core functions & classes shared by multiple AWS SDK clients.",
|
|
5
5
|
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages-internal/core",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -102,6 +102,7 @@
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
"scripts": {
|
|
105
|
+
"benchmark:json": "npx tsx scripts/benchmark-json-serializer.ts",
|
|
105
106
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
106
107
|
"build:cjs": "node ../../scripts/compilation/inline && premove ./dist-cjs/api-extractor-type-index.js",
|
|
107
108
|
"build:es": "premove dist-es && tsc -p tsconfig.es.json && premove ./dist-es/api-extractor-type-index.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-provider-env",
|
|
3
|
-
"version": "3.972.
|
|
3
|
+
"version": "3.972.60",
|
|
4
4
|
"description": "AWS credential provider that sources credentials from known environment variables",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aws",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"test:watch": "yarn g:vitest watch"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@aws-sdk/core": "^3.
|
|
46
|
+
"@aws-sdk/core": "^3.976.0",
|
|
47
47
|
"@aws-sdk/types": "^3.974.2",
|
|
48
48
|
"@smithy/core": "^3.29.4",
|
|
49
49
|
"@smithy/types": "^4.16.1",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-provider-http",
|
|
3
|
-
"version": "3.972.
|
|
3
|
+
"version": "3.972.62",
|
|
4
4
|
"description": "AWS credential provider for containers and HTTP sources",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aws",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@aws-sdk/core": "^3.
|
|
56
|
+
"@aws-sdk/core": "^3.976.0",
|
|
57
57
|
"@aws-sdk/types": "^3.974.2",
|
|
58
58
|
"@smithy/core": "^3.29.4",
|
|
59
59
|
"@smithy/fetch-http-handler": "^5.6.6",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/credential-provider-ini",
|
|
3
|
-
"version": "3.973.
|
|
3
|
+
"version": "3.973.5",
|
|
4
4
|
"description": "AWS credential provider that sources credentials from ~/.aws/credentials and ~/.aws/config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aws",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@aws-sdk/core": "^3.
|
|
49
|
-
"@aws-sdk/credential-provider-env": "^3.972.
|
|
50
|
-
"@aws-sdk/credential-provider-http": "^3.972.
|
|
51
|
-
"@aws-sdk/credential-provider-login": "^3.972.
|
|
52
|
-
"@aws-sdk/credential-provider-process": "^3.972.
|
|
53
|
-
"@aws-sdk/credential-provider-sso": "^3.973.
|
|
54
|
-
"@aws-sdk/credential-provider-web-identity": "^3.972.
|
|
55
|
-
"@aws-sdk/nested-clients": "^3.997.
|
|
48
|
+
"@aws-sdk/core": "^3.976.0",
|
|
49
|
+
"@aws-sdk/credential-provider-env": "^3.972.60",
|
|
50
|
+
"@aws-sdk/credential-provider-http": "^3.972.62",
|
|
51
|
+
"@aws-sdk/credential-provider-login": "^3.972.67",
|
|
52
|
+
"@aws-sdk/credential-provider-process": "^3.972.60",
|
|
53
|
+
"@aws-sdk/credential-provider-sso": "^3.973.4",
|
|
54
|
+
"@aws-sdk/credential-provider-web-identity": "^3.972.66",
|
|
55
|
+
"@aws-sdk/nested-clients": "^3.997.34",
|
|
56
56
|
"@aws-sdk/types": "^3.974.2",
|
|
57
57
|
"@smithy/core": "^3.29.4",
|
|
58
58
|
"@smithy/credential-provider-imds": "^4.4.9",
|