@cdk8s/awscdk-resolver 0.0.713 → 0.0.715

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.
Files changed (79) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +1 -1
  4. package/node_modules/@aws-sdk/client-cloudformation/package.json +4 -4
  5. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +94 -1589
  6. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/index.js +1 -7
  7. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +1 -3
  8. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +1 -3
  9. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/index.d.ts +2 -8
  10. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_0Protocol.d.ts +1 -2
  11. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJson1_1Protocol.d.ts +1 -2
  12. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +2 -3
  13. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/AwsRestJsonProtocol.d.ts +2 -3
  14. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/index.d.ts +10 -10
  15. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_0Protocol.d.ts +1 -2
  16. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJson1_1Protocol.d.ts +1 -2
  17. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +2 -3
  18. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +2 -3
  19. package/node_modules/@aws-sdk/core/package.json +2 -2
  20. package/node_modules/@aws-sdk/credential-provider-env/package.json +3 -3
  21. package/node_modules/@aws-sdk/credential-provider-http/package.json +3 -3
  22. package/node_modules/@aws-sdk/credential-provider-ini/package.json +10 -10
  23. package/node_modules/@aws-sdk/credential-provider-login/package.json +4 -4
  24. package/node_modules/@aws-sdk/credential-provider-node/package.json +8 -8
  25. package/node_modules/@aws-sdk/credential-provider-process/package.json +3 -3
  26. package/node_modules/@aws-sdk/credential-provider-sso/package.json +5 -5
  27. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +4 -4
  28. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  29. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  30. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  31. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  32. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  33. package/node_modules/@aws-sdk/nested-clients/package.json +3 -3
  34. package/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +37 -19
  35. package/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js +37 -19
  36. package/node_modules/@aws-sdk/token-providers/package.json +4 -4
  37. package/package.json +7 -7
  38. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonSettings.js +0 -1
  39. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js +0 -20
  40. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonSettings.js +0 -1
  41. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js +0 -160
  42. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js +0 -193
  43. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.js +0 -103
  44. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js +0 -20
  45. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js +0 -200
  46. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js +0 -519
  47. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/detectBufferParsing.js +0 -18
  48. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js +0 -46
  49. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReviver.js +0 -121
  50. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/needsReviver.js +0 -41
  51. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/parseJsonBody.js +0 -89
  52. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonSettings.d.ts +0 -7
  53. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v1/JsonCodec.d.ts +0 -15
  54. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v1/JsonSettings.d.ts +0 -7
  55. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +0 -14
  56. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +0 -29
  57. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +0 -51
  58. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +0 -13
  59. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +0 -30
  60. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +0 -60
  61. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/detectBufferParsing.d.ts +0 -1
  62. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/jsonReplacer.d.ts +0 -21
  63. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/jsonReviver.d.ts +0 -15
  64. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/needsReviver.d.ts +0 -11
  65. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/parseJsonBody.d.ts +0 -22
  66. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/JsonSettings.d.ts +0 -4
  67. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonCodec.d.ts +0 -11
  68. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonSettings.d.ts +0 -4
  69. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +0 -13
  70. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +0 -18
  71. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +0 -27
  72. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +0 -9
  73. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +0 -15
  74. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +0 -39
  75. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/detectBufferParsing.d.ts +0 -1
  76. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReplacer.d.ts +0 -7
  77. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +0 -7
  78. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/needsReviver.d.ts +0 -2
  79. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +0 -14
@@ -1,519 +0,0 @@
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
- import { JsonBytesStringAdapter } from "./JsonBytesStringAdapter";
6
- const encoder = new TextEncoder();
7
- const OPEN_BRACE = 0x7b;
8
- const CLOSE_BRACE = 0x7d;
9
- const OPEN_BRACKET = 0x5b;
10
- const CLOSE_BRACKET = 0x5d;
11
- const QUOTE = 0x22;
12
- const COLON = 0x3a;
13
- const COMMA = 0x2c;
14
- const BACKSLASH = 0x5c;
15
- const TRUE = new Uint8Array([0x74, 0x72, 0x75, 0x65]);
16
- const FALSE = new Uint8Array([0x66, 0x61, 0x6c, 0x73, 0x65]);
17
- const NULL = new Uint8Array([0x6e, 0x75, 0x6c, 0x6c]);
18
- const ESCAPE_TABLE = new Array(128).fill(null);
19
- ESCAPE_TABLE[0x08] = "b";
20
- ESCAPE_TABLE[0x09] = "t";
21
- ESCAPE_TABLE[0x0a] = "n";
22
- ESCAPE_TABLE[0x0c] = "f";
23
- ESCAPE_TABLE[0x0d] = "r";
24
- ESCAPE_TABLE[0x22] = '"';
25
- ESCAPE_TABLE[0x5c] = "\\";
26
- for (let i = 0; i < 0x20; i++) {
27
- if (ESCAPE_TABLE[i] === null) {
28
- ESCAPE_TABLE[i] = "u00" + i.toString(16).padStart(2, "0");
29
- }
30
- }
31
- const INITIAL_BUFFER_SIZE = 2048;
32
- function alloc(size) {
33
- return JsonBytesStringAdapter.allocUnsafe(size);
34
- }
35
- export class JsonShapeSerializer2 extends SerdeContextConfig {
36
- settings;
37
- json;
38
- i = 0;
39
- rootSchema;
40
- rawValue;
41
- passthrough = false;
42
- constructor(settings) {
43
- super();
44
- this.settings = settings;
45
- this.json = alloc(INITIAL_BUFFER_SIZE);
46
- }
47
- write(schema, value) {
48
- this.i = 0;
49
- this.rawValue = value;
50
- this.rootSchema = NormalizedSchema.of(schema);
51
- this.passthrough = this.rootSchema.isBlobSchema() || this.rootSchema.isStringSchema();
52
- if (!this.passthrough) {
53
- this.writeValue(this.rootSchema, value, undefined);
54
- }
55
- }
56
- writeDiscriminatedDocument(schema, value) {
57
- this.i = 0;
58
- this.rootSchema = NormalizedSchema.of(schema);
59
- const ns = this.rootSchema;
60
- if (ns.isStructSchema() && value != null && typeof value === "object") {
61
- this.writeValue(ns, value, undefined);
62
- const prefix = `"__type":"${ns.getName(true) ?? "Unknown"}",`;
63
- const z = prefix.length;
64
- this.ensure(z);
65
- this.json.copyWithin(1 + z, 1, this.i);
66
- encoder.encodeInto(prefix, this.json.subarray(1));
67
- this.i += z;
68
- }
69
- else {
70
- this.writeValue(ns, value, undefined);
71
- }
72
- }
73
- flush() {
74
- this.rootSchema = undefined;
75
- const finalPosition = this.i;
76
- this.i = 0;
77
- const raw = this.rawValue;
78
- this.rawValue = undefined;
79
- if (finalPosition === 0) {
80
- return raw;
81
- }
82
- const result = this.json.subarray(0, finalPosition);
83
- this.json = alloc(INITIAL_BUFFER_SIZE);
84
- return result;
85
- }
86
- ensure(byteCount) {
87
- const { i, json } = this;
88
- if (i + byteCount > json.length) {
89
- let newSize = json.length * 2;
90
- while (newSize < i + byteCount) {
91
- newSize *= 2;
92
- }
93
- const next = alloc(newSize);
94
- next.set(this.json);
95
- this.json = next;
96
- }
97
- }
98
- writeAscii(s) {
99
- const z = s.length;
100
- this.ensure(z);
101
- let { i, json } = this;
102
- for (let j = 0; j < z; ++j) {
103
- json[i] = s.charCodeAt(j);
104
- i += 1;
105
- }
106
- this.i = i;
107
- }
108
- writeAsciiQuoted(s) {
109
- const z = s.length;
110
- this.ensure(z + 4);
111
- let { json, i } = this;
112
- json[i++] = QUOTE;
113
- for (let j = 0; j < z; ++j) {
114
- json[i++] = s.charCodeAt(j);
115
- }
116
- json[i++] = QUOTE;
117
- this.i = i;
118
- }
119
- writeJsonString(s) {
120
- this.ensure(s.length * 3 + 2);
121
- this.json[this.i++] = QUOTE;
122
- const z = s.length;
123
- for (let j = 0; j < z; ++j) {
124
- const c = s.charCodeAt(j);
125
- if (c > 0x22 && c < 0x5c) {
126
- this.json[this.i++] = c;
127
- }
128
- else if (c < 0x80) {
129
- const esc = ESCAPE_TABLE[c];
130
- if (esc !== null) {
131
- this.ensure(esc.length + 1);
132
- this.json[this.i++] = BACKSLASH;
133
- for (let k = 0; k < esc.length; k++) {
134
- this.json[this.i++] = esc.charCodeAt(k);
135
- }
136
- }
137
- else {
138
- this.json[this.i++] = c;
139
- }
140
- }
141
- else if (c >= 0xd800 && c <= 0xdbff) {
142
- const next = j + 1 < z ? s.charCodeAt(j + 1) : 0;
143
- if (next >= 0xdc00 && next <= 0xdfff) {
144
- this.ensure(4);
145
- const { written } = encoder.encodeInto(s.substring(j, j + 2), this.json.subarray(this.i));
146
- this.i += written;
147
- ++j;
148
- }
149
- else {
150
- this.ensure(6);
151
- this.writeUnicodeEscape(c);
152
- }
153
- }
154
- else if (c >= 0xdc00 && c <= 0xdfff) {
155
- this.ensure(6);
156
- this.writeUnicodeEscape(c);
157
- }
158
- else {
159
- let { i, json } = this;
160
- if (c < 0x800) {
161
- json[i++] = 0xc0 | (c >> 6);
162
- json[i++] = 0x80 | (c & 0x3f);
163
- }
164
- else {
165
- json[i++] = 0xe0 | (c >> 12);
166
- json[i++] = 0x80 | ((c >> 6) & 0x3f);
167
- json[i++] = 0x80 | (c & 0x3f);
168
- }
169
- this.i = i;
170
- }
171
- }
172
- this.json[this.i++] = QUOTE;
173
- }
174
- writeUnicodeEscape(code) {
175
- let { json, i } = this;
176
- json[i++] = BACKSLASH;
177
- json[i++] = 0x75;
178
- const hex = code.toString(16).padStart(4, "0");
179
- for (let j = 0; j < 4; ++j) {
180
- json[i++] = hex.charCodeAt(j);
181
- }
182
- this.i = i;
183
- }
184
- static B64 = (() => {
185
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
186
- const table = new Uint8Array(64);
187
- for (let i = 0; i < 64; ++i) {
188
- table[i] = chars.charCodeAt(i);
189
- }
190
- return table;
191
- })();
192
- writeBase64(data) {
193
- const b64Len = Math.ceil(data.length / 3) * 4;
194
- this.ensure(b64Len + 2);
195
- const json = this.json;
196
- const B64 = JsonShapeSerializer2.B64;
197
- let i = this.i;
198
- json[i++] = QUOTE;
199
- const len = data.length;
200
- const remainder = len % 3;
201
- const mainLen = len - remainder;
202
- for (let j = 0; j < mainLen; j += 3) {
203
- const a = data[j];
204
- const b = data[j + 1];
205
- const c = data[j + 2];
206
- json[i++] = B64[a >> 2];
207
- json[i++] = B64[((a & 0x03) << 4) | (b >> 4)];
208
- json[i++] = B64[((b & 0x0f) << 2) | (c >> 6)];
209
- json[i++] = B64[c & 0x3f];
210
- }
211
- if (remainder === 2) {
212
- const a = data[mainLen];
213
- const b = data[mainLen + 1];
214
- json[i++] = B64[a >> 2];
215
- json[i++] = B64[((a & 0x03) << 4) | (b >> 4)];
216
- json[i++] = B64[(b & 0x0f) << 2];
217
- json[i++] = 0x3d;
218
- }
219
- else if (remainder === 1) {
220
- const a = data[mainLen];
221
- json[i++] = B64[a >> 2];
222
- json[i++] = B64[(a & 0x03) << 4];
223
- json[i++] = 0x3d;
224
- json[i++] = 0x3d;
225
- }
226
- json[i++] = QUOTE;
227
- this.i = i;
228
- }
229
- writeValue(schema, value, container) {
230
- if (value == null) {
231
- if (container?.isStructSchema()) {
232
- if (value === undefined) {
233
- const ns = NormalizedSchema.of(schema);
234
- if (ns.isIdempotencyToken()) {
235
- this.writeAsciiQuoted(generateIdempotencyToken());
236
- return;
237
- }
238
- }
239
- return;
240
- }
241
- this.ensure(4);
242
- this.json.set(NULL, this.i);
243
- this.i += 4;
244
- return;
245
- }
246
- const ns = NormalizedSchema.of(schema);
247
- const isObject = typeof value === "object";
248
- if (ns.isStringSchema()) {
249
- const mediaType = ns.getMergedTraits().mediaType;
250
- if (mediaType) {
251
- const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
252
- if (isJson) {
253
- this.writeJsonString(LazyJsonString.from(value).toString());
254
- return;
255
- }
256
- }
257
- }
258
- if (isObject) {
259
- if (ns.isStructSchema()) {
260
- this.writeStruct(ns, value);
261
- return;
262
- }
263
- if (Array.isArray(value) && (ns.isListSchema() || ns.isDocumentSchema())) {
264
- this.writeList(ns, value, ns.isDocumentSchema());
265
- return;
266
- }
267
- if (ns.isMapSchema()) {
268
- this.writeMap(ns, value, false);
269
- return;
270
- }
271
- if (value instanceof Uint8Array && (ns.isBlobSchema() || ns.isDocumentSchema())) {
272
- this.writeBase64(value);
273
- return;
274
- }
275
- if (value instanceof Date && (ns.isTimestampSchema() || ns.isDocumentSchema())) {
276
- this.writeTimestamp(ns, value);
277
- return;
278
- }
279
- if (value instanceof NumericValue) {
280
- this.writeAscii(value.string);
281
- return;
282
- }
283
- if (ns.isDocumentSchema()) {
284
- if (Array.isArray(value)) {
285
- this.writeList(ns, value, true);
286
- }
287
- else {
288
- this.writeMap(ns, value, true);
289
- }
290
- return;
291
- }
292
- const json = JSON.stringify(value);
293
- this.writeAscii(json);
294
- return;
295
- }
296
- if (typeof value === "string") {
297
- if (ns.isBlobSchema()) {
298
- const b64 = (this.serdeContext?.base64Encoder ?? toBase64)(value);
299
- this.writeAsciiQuoted(b64);
300
- return;
301
- }
302
- this.writeJsonString(value);
303
- return;
304
- }
305
- if (typeof value === "number") {
306
- if (Math.abs(value) === Infinity || Number.isNaN(value)) {
307
- this.writeAsciiQuoted(String(value));
308
- return;
309
- }
310
- const numStr = String(value);
311
- this.writeAscii(numStr);
312
- return;
313
- }
314
- if (typeof value === "boolean") {
315
- this.ensure(5);
316
- let { i, json } = this;
317
- if (value) {
318
- json.set(TRUE, i);
319
- i += 4;
320
- }
321
- else {
322
- json.set(FALSE, i);
323
- i += 5;
324
- }
325
- this.i = i;
326
- return;
327
- }
328
- if (typeof value === "bigint") {
329
- this.writeAscii(value.toString());
330
- return;
331
- }
332
- this.writeAscii(String(value));
333
- }
334
- writeStruct(ns, value) {
335
- this.ensure(2);
336
- this.json[this.i++] = OPEN_BRACE;
337
- let wroteAny = false;
338
- const hasType = typeof value.__type === "string";
339
- let writtenKeys;
340
- if (hasType) {
341
- writtenKeys = new Set();
342
- }
343
- for (const [memberName, memberSchema] of ns.structIterator()) {
344
- const item = value[memberName];
345
- if (item == null && !memberSchema.isIdempotencyToken()) {
346
- continue;
347
- }
348
- if (wroteAny) {
349
- this.ensure(1);
350
- this.json[this.i++] = COMMA;
351
- }
352
- wroteAny = true;
353
- const targetKey = this.settings.jsonName ? (memberSchema.getMergedTraits().jsonName ?? memberName) : memberName;
354
- if (writtenKeys) {
355
- writtenKeys.add(memberName);
356
- writtenKeys.add(targetKey);
357
- }
358
- this.writeAsciiQuoted(targetKey);
359
- this.json[this.i++] = COLON;
360
- this.writeValue(memberSchema, item, ns);
361
- }
362
- if (!wroteAny && ns.isUnionSchema()) {
363
- const { $unknown } = value;
364
- if (Array.isArray($unknown)) {
365
- const [k, v] = $unknown;
366
- this.writeAsciiQuoted(k);
367
- this.ensure(1);
368
- this.json[this.i++] = COLON;
369
- this.writeValue(15, v, ns);
370
- }
371
- }
372
- else if (hasType) {
373
- for (const k in value) {
374
- if (writtenKeys.has(k)) {
375
- continue;
376
- }
377
- writtenKeys.add(k);
378
- const v = value[k];
379
- if (wroteAny) {
380
- this.ensure(1);
381
- this.json[this.i++] = COMMA;
382
- }
383
- wroteAny = true;
384
- this.writeAsciiQuoted(k);
385
- this.ensure(1);
386
- this.json[this.i++] = COLON;
387
- this.writeValue(15, v, undefined);
388
- }
389
- }
390
- this.ensure(1);
391
- this.json[this.i++] = CLOSE_BRACE;
392
- }
393
- writeList(ns, value, isDocument) {
394
- const sparse = !!ns.getMergedTraits().sparse;
395
- const valueSchema = ns.getValueSchema();
396
- if (!isDocument) {
397
- if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
398
- let hasSpecials = false;
399
- for (let i = 0; i < value.length; ++i) {
400
- const v = value[i];
401
- if (Number.isNaN(v) || v === Infinity || v === -Infinity || (v == null && !sparse)) {
402
- hasSpecials = true;
403
- break;
404
- }
405
- }
406
- let json;
407
- if (!hasSpecials) {
408
- json = JSON.stringify(value);
409
- }
410
- else {
411
- const out = [];
412
- for (let i = 0; i < value.length; ++i) {
413
- const v = value[i];
414
- if (v == null && !sparse)
415
- continue;
416
- if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
417
- out.push(String(v));
418
- }
419
- else {
420
- out.push(v);
421
- }
422
- }
423
- json = JSON.stringify(out);
424
- }
425
- this.ensure(json.length * 3);
426
- this.i += encoder.encodeInto(json, this.json.subarray(this.i)).written;
427
- return;
428
- }
429
- }
430
- this.ensure(2);
431
- this.json[this.i++] = OPEN_BRACKET;
432
- let wroteFirstItem = false;
433
- for (let i = 0; i < value.length; ++i) {
434
- const item = value[i];
435
- if (isDocument ? item === undefined : item == null && !sparse) {
436
- continue;
437
- }
438
- if (wroteFirstItem) {
439
- this.ensure(1);
440
- this.json[this.i++] = COMMA;
441
- }
442
- this.writeValue(valueSchema, item, undefined);
443
- wroteFirstItem = true;
444
- }
445
- this.ensure(1);
446
- this.json[this.i++] = CLOSE_BRACKET;
447
- }
448
- writeMap(ns, value, isDocument) {
449
- const sparse = !!ns.getMergedTraits().sparse;
450
- const valueSchema = ns.getValueSchema();
451
- if (!isDocument) {
452
- if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
453
- let modifications;
454
- for (const k in value) {
455
- const v = value[k];
456
- if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
457
- (modifications ??= {})[k] = v;
458
- value[k] = String(v);
459
- }
460
- else if (v === null && !sparse) {
461
- (modifications ??= {})[k] = null;
462
- value[k] = undefined;
463
- }
464
- }
465
- const json = JSON.stringify(value);
466
- if (modifications) {
467
- Object.assign(value, modifications);
468
- }
469
- this.ensure(json.length * 3);
470
- this.i += encoder.encodeInto(json, this.json.subarray(this.i)).written;
471
- return;
472
- }
473
- }
474
- this.ensure(2);
475
- this.json[this.i++] = OPEN_BRACE;
476
- let first = true;
477
- for (const k in value) {
478
- const v = value[k];
479
- if (isDocument ? v === undefined : v == null && !sparse) {
480
- continue;
481
- }
482
- if (!first) {
483
- this.ensure(1);
484
- this.json[this.i++] = COMMA;
485
- }
486
- first = false;
487
- this.writeJsonString(k);
488
- this.ensure(1);
489
- this.json[this.i++] = COLON;
490
- this.writeValue(valueSchema, v, undefined);
491
- }
492
- this.ensure(1);
493
- this.json[this.i++] = CLOSE_BRACE;
494
- }
495
- writeTimestamp(ns, value) {
496
- const format = determineTimestampFormat(ns, this.settings);
497
- switch (format) {
498
- case 5: {
499
- const iso = value.toISOString().replace(".000Z", "Z");
500
- this.writeAsciiQuoted(iso);
501
- return;
502
- }
503
- case 6: {
504
- this.writeAsciiQuoted(dateToUtcString(value));
505
- return;
506
- }
507
- case 7: {
508
- const epochSecs = String(value.getTime() / 1000);
509
- this.writeAscii(epochSecs);
510
- return;
511
- }
512
- default: {
513
- const epochSecs = String(value.getTime() / 1000);
514
- this.writeAscii(epochSecs);
515
- return;
516
- }
517
- }
518
- }
519
- }
@@ -1,18 +0,0 @@
1
- let canParseBuffer;
2
- export function detectBufferParsing() {
3
- if (canParseBuffer === undefined) {
4
- try {
5
- if (typeof Buffer !== "function") {
6
- canParseBuffer = false;
7
- }
8
- else {
9
- const result = JSON.parse(Buffer.from([0x7b, 0x7d]));
10
- canParseBuffer = result !== null && typeof result === "object";
11
- }
12
- }
13
- catch {
14
- canParseBuffer = false;
15
- }
16
- }
17
- return canParseBuffer;
18
- }
@@ -1,46 +0,0 @@
1
- import { NumericValue } from "@smithy/core/serde";
2
- const NUMERIC_CONTROL_CHAR = String.fromCharCode(925);
3
- export class JsonReplacer {
4
- values = new Map();
5
- counter = 0;
6
- stage = 0;
7
- createReplacer() {
8
- if (this.stage === 1) {
9
- throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");
10
- }
11
- if (this.stage === 2) {
12
- throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
13
- }
14
- this.stage = 1;
15
- return (key, value) => {
16
- if (value instanceof NumericValue) {
17
- const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value.string;
18
- this.values.set(`"${v}"`, value.string);
19
- return v;
20
- }
21
- if (typeof value === "bigint") {
22
- const s = value.toString();
23
- const v = `${NUMERIC_CONTROL_CHAR + "b" + this.counter++}_` + s;
24
- this.values.set(`"${v}"`, s);
25
- return v;
26
- }
27
- return value;
28
- };
29
- }
30
- replaceInJson(json) {
31
- if (this.stage === 0) {
32
- throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");
33
- }
34
- if (this.stage === 2) {
35
- throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
36
- }
37
- this.stage = 2;
38
- if (this.counter === 0) {
39
- return json;
40
- }
41
- for (const [key, value] of this.values) {
42
- json = json.replace(key, value);
43
- }
44
- return json;
45
- }
46
- }
@@ -1,121 +0,0 @@
1
- import { NumericValue } from "@smithy/core/serde";
2
- export function jsonReviver(key, value, context) {
3
- if (context?.source) {
4
- const numericString = context.source;
5
- if (typeof value === "number") {
6
- const inSafeRange = value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER;
7
- if (inSafeRange) {
8
- if (isRepresentable(numericString, value)) {
9
- return value;
10
- }
11
- return new NumericValue(numericString, "bigDecimal");
12
- }
13
- else {
14
- if (isFractionalBigNumeric(numericString)) {
15
- return new NumericValue(numericString, "bigDecimal");
16
- }
17
- if (/[eE]/.test(numericString)) {
18
- return expandExponentToBigInt(numericString);
19
- }
20
- return BigInt(numericString);
21
- }
22
- }
23
- }
24
- return value;
25
- }
26
- function isFractionalBigNumeric(s) {
27
- const dotIndex = s.indexOf(".");
28
- if (dotIndex === -1) {
29
- return false;
30
- }
31
- const eIndex = s.search(/[eE]/);
32
- if (eIndex === -1) {
33
- return true;
34
- }
35
- const fracDigits = eIndex - dotIndex - 1;
36
- const exp = parseInt(s.slice(eIndex + 1), 10);
37
- return exp < fracDigits;
38
- }
39
- function isRepresentable(numericString, value) {
40
- if (numericString === String(value)) {
41
- return true;
42
- }
43
- if (Object.is(value, -0)) {
44
- return true;
45
- }
46
- if (/[eE]/.test(numericString)) {
47
- return expandToDecimal(numericString) === expandToDecimal(String(value));
48
- }
49
- const normalized = numericString.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
50
- const canonical = String(value);
51
- if (normalized === canonical) {
52
- return true;
53
- }
54
- if (/[eE]/.test(canonical)) {
55
- return normalized === expandToDecimal(canonical);
56
- }
57
- return false;
58
- }
59
- function expandToDecimal(s) {
60
- const negative = s.startsWith("-");
61
- const abs = negative ? s.slice(1) : s;
62
- const eIndex = abs.search(/[eE]/);
63
- let result;
64
- if (eIndex === -1) {
65
- result = abs;
66
- }
67
- else {
68
- const exp = parseInt(abs.slice(eIndex + 1), 10);
69
- const mantissa = abs.slice(0, eIndex);
70
- const dotIndex = mantissa.indexOf(".");
71
- let digits;
72
- let intLen;
73
- if (dotIndex === -1) {
74
- digits = mantissa;
75
- intLen = mantissa.length;
76
- }
77
- else {
78
- digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
79
- intLen = dotIndex;
80
- }
81
- digits = digits.replace(/0+$/, "") || "0";
82
- const newDotPos = intLen + exp;
83
- if (digits === "0") {
84
- result = "0";
85
- }
86
- else if (newDotPos <= 0) {
87
- result = "0." + "0".repeat(-newDotPos) + digits;
88
- }
89
- else if (newDotPos >= digits.length) {
90
- result = digits + "0".repeat(newDotPos - digits.length);
91
- }
92
- else {
93
- result = digits.slice(0, newDotPos) + "." + digits.slice(newDotPos);
94
- }
95
- }
96
- if (result.includes(".")) {
97
- result = result.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
98
- }
99
- return (negative ? "-" : "") + result;
100
- }
101
- function expandExponentToBigInt(s) {
102
- const eIndex = s.search(/[eE]/);
103
- const exp = parseInt(s.slice(eIndex + 1), 10);
104
- const negative = s.startsWith("-");
105
- const mantissa = s.slice(negative ? 1 : 0, eIndex);
106
- const dotIndex = mantissa.indexOf(".");
107
- let digits;
108
- let shift;
109
- if (dotIndex === -1) {
110
- digits = mantissa;
111
- shift = exp;
112
- }
113
- else {
114
- digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
115
- const fracDigits = mantissa.length - dotIndex - 1;
116
- shift = exp - fracDigits;
117
- }
118
- digits = digits.replace(/0+$/, "") || "0";
119
- const result = BigInt(digits) * 10n ** BigInt(shift + (mantissa.replace(".", "").length - digits.length));
120
- return negative ? -result : result;
121
- }