@smithy/core 3.13.0 → 3.15.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/index.js +308 -412
- package/dist-cjs/submodules/cbor/index.js +957 -969
- package/dist-cjs/submodules/event-streams/index.js +200 -249
- package/dist-cjs/submodules/protocols/index.js +795 -895
- package/dist-cjs/submodules/schema/index.js +536 -799
- package/dist-cjs/submodules/serde/index.js +675 -679
- package/dist-es/submodules/cbor/CborCodec.js +6 -2
- package/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +3 -3
- package/dist-es/submodules/cbor/cbor-decode.js +18 -18
- package/dist-es/submodules/cbor/cbor-encode.js +5 -5
- package/dist-es/submodules/event-streams/EventStreamSerde.js +10 -3
- package/dist-es/submodules/protocols/HttpBindingProtocol.js +4 -4
- package/dist-es/submodules/protocols/HttpProtocol.js +5 -3
- package/dist-es/submodules/protocols/RpcProtocol.js +2 -2
- package/dist-es/submodules/protocols/requestBuilder.js +9 -7
- package/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +21 -17
- package/dist-es/submodules/protocols/serde/HttpInterceptingShapeDeserializer.js +3 -0
- package/dist-es/submodules/protocols/serde/HttpInterceptingShapeSerializer.js +3 -0
- package/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +7 -6
- package/dist-es/submodules/protocols/serde/determineTimestampFormat.js +5 -6
- package/dist-es/submodules/schema/TypeRegistry.js +4 -1
- package/dist-es/submodules/schema/index.js +1 -0
- package/dist-es/submodules/schema/schemas/ErrorSchema.js +3 -5
- package/dist-es/submodules/schema/schemas/ListSchema.js +5 -5
- package/dist-es/submodules/schema/schemas/MapSchema.js +6 -5
- package/dist-es/submodules/schema/schemas/NormalizedSchema.js +92 -178
- package/dist-es/submodules/schema/schemas/OperationSchema.js +6 -5
- package/dist-es/submodules/schema/schemas/Schema.js +3 -0
- package/dist-es/submodules/schema/schemas/SimpleSchema.js +5 -5
- package/dist-es/submodules/schema/schemas/StructureSchema.js +6 -5
- package/dist-es/submodules/schema/schemas/sentinels.js +14 -14
- package/dist-es/submodules/schema/schemas/translateTraits.js +22 -0
- package/dist-es/submodules/serde/index.js +1 -0
- package/dist-es/submodules/serde/schema-serde-lib/schema-date-utils.js +110 -0
- package/dist-es/submodules/serde/value/NumericValue.js +6 -26
- package/dist-es/util-identity-and-auth/DefaultIdentityProviderConfig.js +1 -1
- package/dist-es/util-identity-and-auth/memoizeIdentityProvider.js +4 -2
- package/dist-types/submodules/schema/index.d.ts +1 -0
- package/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +5 -24
- package/dist-types/submodules/schema/schemas/sentinels.d.ts +2 -0
- package/dist-types/submodules/schema/schemas/translateTraits.d.ts +7 -0
- package/dist-types/submodules/serde/index.d.ts +1 -0
- package/dist-types/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +47 -0
- package/dist-types/ts3.4/submodules/schema/index.d.ts +1 -0
- package/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +5 -24
- package/dist-types/ts3.4/submodules/schema/schemas/sentinels.d.ts +2 -0
- package/dist-types/ts3.4/submodules/schema/schemas/translateTraits.d.ts +7 -0
- package/dist-types/ts3.4/submodules/serde/index.d.ts +1 -0
- package/dist-types/ts3.4/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +47 -0
- package/package.json +11 -11
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
|
-
import {
|
|
2
|
+
import { _parseEpochTimestamp, generateIdempotencyToken } from "@smithy/core/serde";
|
|
3
3
|
import { fromBase64 } from "@smithy/util-base64";
|
|
4
4
|
import { cbor } from "./cbor";
|
|
5
5
|
import { dateToTag } from "./parseCborBody";
|
|
6
6
|
export class CborCodec {
|
|
7
|
+
serdeContext;
|
|
7
8
|
createSerializer() {
|
|
8
9
|
const serializer = new CborShapeSerializer();
|
|
9
10
|
serializer.setSerdeContext(this.serdeContext);
|
|
@@ -19,6 +20,8 @@ export class CborCodec {
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
export class CborShapeSerializer {
|
|
23
|
+
serdeContext;
|
|
24
|
+
value;
|
|
22
25
|
setSerdeContext(serdeContext) {
|
|
23
26
|
this.serdeContext = serdeContext;
|
|
24
27
|
}
|
|
@@ -96,6 +99,7 @@ export class CborShapeSerializer {
|
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
export class CborShapeDeserializer {
|
|
102
|
+
serdeContext;
|
|
99
103
|
setSerdeContext(serdeContext) {
|
|
100
104
|
this.serdeContext = serdeContext;
|
|
101
105
|
}
|
|
@@ -106,7 +110,7 @@ export class CborShapeDeserializer {
|
|
|
106
110
|
readValue(_schema, value) {
|
|
107
111
|
const ns = NormalizedSchema.of(_schema);
|
|
108
112
|
if (ns.isTimestampSchema() && typeof value === "number") {
|
|
109
|
-
return
|
|
113
|
+
return _parseEpochTimestamp(value);
|
|
110
114
|
}
|
|
111
115
|
if (ns.isBlobSchema()) {
|
|
112
116
|
if (typeof value === "string") {
|
|
@@ -4,11 +4,11 @@ import { getSmithyContext } from "@smithy/util-middleware";
|
|
|
4
4
|
import { CborCodec } from "./CborCodec";
|
|
5
5
|
import { loadSmithyRpcV2CborErrorCode } from "./parseCborBody";
|
|
6
6
|
export class SmithyRpcV2CborProtocol extends RpcProtocol {
|
|
7
|
+
codec = new CborCodec();
|
|
8
|
+
serializer = this.codec.createSerializer();
|
|
9
|
+
deserializer = this.codec.createDeserializer();
|
|
7
10
|
constructor({ defaultNamespace }) {
|
|
8
11
|
super({ defaultNamespace });
|
|
9
|
-
this.codec = new CborCodec();
|
|
10
|
-
this.serializer = this.codec.createSerializer();
|
|
11
|
-
this.deserializer = this.codec.createDeserializer();
|
|
12
12
|
}
|
|
13
13
|
getShapeId() {
|
|
14
14
|
return "smithy.protocols#rpcv2Cbor";
|
|
@@ -15,8 +15,8 @@ export function decode(at, to) {
|
|
|
15
15
|
if (at >= to) {
|
|
16
16
|
throw new Error("unexpected end of (decode) payload.");
|
|
17
17
|
}
|
|
18
|
-
const major = (payload[at] &
|
|
19
|
-
const minor = payload[at] &
|
|
18
|
+
const major = (payload[at] & 0b1110_0000) >> 5;
|
|
19
|
+
const minor = payload[at] & 0b0001_1111;
|
|
20
20
|
switch (major) {
|
|
21
21
|
case majorUint64:
|
|
22
22
|
case majorNegativeInt64:
|
|
@@ -168,13 +168,13 @@ const minorValueToArgumentLength = {
|
|
|
168
168
|
};
|
|
169
169
|
export function bytesToFloat16(a, b) {
|
|
170
170
|
const sign = a >> 7;
|
|
171
|
-
const exponent = (a &
|
|
172
|
-
const fraction = ((a &
|
|
171
|
+
const exponent = (a & 0b0111_1100) >> 2;
|
|
172
|
+
const fraction = ((a & 0b0000_0011) << 8) | b;
|
|
173
173
|
const scalar = sign === 0 ? 1 : -1;
|
|
174
174
|
let exponentComponent;
|
|
175
175
|
let summation;
|
|
176
176
|
if (exponent === 0b00000) {
|
|
177
|
-
if (fraction ===
|
|
177
|
+
if (fraction === 0b00000_00000) {
|
|
178
178
|
return 0;
|
|
179
179
|
}
|
|
180
180
|
else {
|
|
@@ -183,7 +183,7 @@ export function bytesToFloat16(a, b) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
else if (exponent === 0b11111) {
|
|
186
|
-
if (fraction ===
|
|
186
|
+
if (fraction === 0b00000_00000) {
|
|
187
187
|
return scalar * Infinity;
|
|
188
188
|
}
|
|
189
189
|
else {
|
|
@@ -198,7 +198,7 @@ export function bytesToFloat16(a, b) {
|
|
|
198
198
|
return scalar * (exponentComponent * summation);
|
|
199
199
|
}
|
|
200
200
|
function decodeCount(at, to) {
|
|
201
|
-
const minor = payload[at] &
|
|
201
|
+
const minor = payload[at] & 0b0001_1111;
|
|
202
202
|
if (minor < 24) {
|
|
203
203
|
_offset = 1;
|
|
204
204
|
return minor;
|
|
@@ -241,14 +241,14 @@ function decodeUtf8StringIndefinite(at, to) {
|
|
|
241
241
|
at += 1;
|
|
242
242
|
const vector = [];
|
|
243
243
|
for (const base = at; at < to;) {
|
|
244
|
-
if (payload[at] ===
|
|
244
|
+
if (payload[at] === 0b1111_1111) {
|
|
245
245
|
const data = alloc(vector.length);
|
|
246
246
|
data.set(vector, 0);
|
|
247
247
|
_offset = at - base + 2;
|
|
248
248
|
return bytesToUtf8(data, 0, data.length);
|
|
249
249
|
}
|
|
250
|
-
const major = (payload[at] &
|
|
251
|
-
const minor = payload[at] &
|
|
250
|
+
const major = (payload[at] & 0b1110_0000) >> 5;
|
|
251
|
+
const minor = payload[at] & 0b0001_1111;
|
|
252
252
|
if (major !== majorUtf8String) {
|
|
253
253
|
throw new Error(`unexpected major type ${major} in indefinite string.`);
|
|
254
254
|
}
|
|
@@ -279,14 +279,14 @@ function decodeUnstructuredByteStringIndefinite(at, to) {
|
|
|
279
279
|
at += 1;
|
|
280
280
|
const vector = [];
|
|
281
281
|
for (const base = at; at < to;) {
|
|
282
|
-
if (payload[at] ===
|
|
282
|
+
if (payload[at] === 0b1111_1111) {
|
|
283
283
|
const data = alloc(vector.length);
|
|
284
284
|
data.set(vector, 0);
|
|
285
285
|
_offset = at - base + 2;
|
|
286
286
|
return data;
|
|
287
287
|
}
|
|
288
|
-
const major = (payload[at] &
|
|
289
|
-
const minor = payload[at] &
|
|
288
|
+
const major = (payload[at] & 0b1110_0000) >> 5;
|
|
289
|
+
const minor = payload[at] & 0b0001_1111;
|
|
290
290
|
if (major !== majorUnstructuredByteString) {
|
|
291
291
|
throw new Error(`unexpected major type ${major} in indefinite string.`);
|
|
292
292
|
}
|
|
@@ -321,7 +321,7 @@ function decodeListIndefinite(at, to) {
|
|
|
321
321
|
at += 1;
|
|
322
322
|
const list = [];
|
|
323
323
|
for (const base = at; at < to;) {
|
|
324
|
-
if (payload[at] ===
|
|
324
|
+
if (payload[at] === 0b1111_1111) {
|
|
325
325
|
_offset = at - base + 2;
|
|
326
326
|
return list;
|
|
327
327
|
}
|
|
@@ -342,7 +342,7 @@ function decodeMap(at, to) {
|
|
|
342
342
|
if (at >= to) {
|
|
343
343
|
throw new Error("unexpected end of map payload.");
|
|
344
344
|
}
|
|
345
|
-
const major = (payload[at] &
|
|
345
|
+
const major = (payload[at] & 0b1110_0000) >> 5;
|
|
346
346
|
if (major !== majorUtf8String) {
|
|
347
347
|
throw new Error(`unexpected major type ${major} for map key at index ${at}.`);
|
|
348
348
|
}
|
|
@@ -363,11 +363,11 @@ function decodeMapIndefinite(at, to) {
|
|
|
363
363
|
if (at >= to) {
|
|
364
364
|
throw new Error("unexpected end of map payload.");
|
|
365
365
|
}
|
|
366
|
-
if (payload[at] ===
|
|
366
|
+
if (payload[at] === 0b1111_1111) {
|
|
367
367
|
_offset = at - base + 2;
|
|
368
368
|
return map;
|
|
369
369
|
}
|
|
370
|
-
const major = (payload[at] &
|
|
370
|
+
const major = (payload[at] & 0b1110_0000) >> 5;
|
|
371
371
|
if (major !== majorUtf8String) {
|
|
372
372
|
throw new Error(`unexpected major type ${major} for map key.`);
|
|
373
373
|
}
|
|
@@ -380,7 +380,7 @@ function decodeMapIndefinite(at, to) {
|
|
|
380
380
|
throw new Error("expected break marker.");
|
|
381
381
|
}
|
|
382
382
|
function decodeSpecial(at, to) {
|
|
383
|
-
const minor = payload[at] &
|
|
383
|
+
const minor = payload[at] & 0b0001_1111;
|
|
384
384
|
switch (minor) {
|
|
385
385
|
case specialTrue:
|
|
386
386
|
case specialFalse:
|
|
@@ -9,11 +9,11 @@ let cursor = 0;
|
|
|
9
9
|
function ensureSpace(bytes) {
|
|
10
10
|
const remaining = data.byteLength - cursor;
|
|
11
11
|
if (remaining < bytes) {
|
|
12
|
-
if (cursor <
|
|
12
|
+
if (cursor < 16_000_000) {
|
|
13
13
|
resize(Math.max(data.byteLength * 4, data.byteLength + bytes));
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
resize(data.byteLength + bytes +
|
|
16
|
+
resize(data.byteLength + bytes + 16_000_000);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -127,7 +127,7 @@ export function encode(_input) {
|
|
|
127
127
|
else if (n < 65536) {
|
|
128
128
|
data[cursor++] = (major << 5) | extendedFloat16;
|
|
129
129
|
data[cursor++] = n >> 8;
|
|
130
|
-
data[cursor++] = n &
|
|
130
|
+
data[cursor++] = n & 0b1111_1111;
|
|
131
131
|
}
|
|
132
132
|
else if (n < 4294967296) {
|
|
133
133
|
data[cursor++] = (major << 5) | extendedFloat32;
|
|
@@ -149,7 +149,7 @@ export function encode(_input) {
|
|
|
149
149
|
b >>= BigInt(8);
|
|
150
150
|
}
|
|
151
151
|
ensureSpace(bigIntBytes.byteLength * 2);
|
|
152
|
-
data[cursor++] = nonNegative ?
|
|
152
|
+
data[cursor++] = nonNegative ? 0b110_00010 : 0b110_00011;
|
|
153
153
|
if (USE_BUFFER) {
|
|
154
154
|
encodeHeader(majorUnstructuredByteString, Buffer.byteLength(bigIntBytes));
|
|
155
155
|
}
|
|
@@ -191,7 +191,7 @@ export function encode(_input) {
|
|
|
191
191
|
const decimalIndex = input.string.indexOf(".");
|
|
192
192
|
const exponent = decimalIndex === -1 ? 0 : decimalIndex - input.string.length + 1;
|
|
193
193
|
const mantissa = BigInt(input.string.replace(".", ""));
|
|
194
|
-
data[cursor++] =
|
|
194
|
+
data[cursor++] = 0b110_00100;
|
|
195
195
|
encodeStack.push(mantissa);
|
|
196
196
|
encodeStack.push(exponent);
|
|
197
197
|
encodeHeader(majorList, 2);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { SCHEMA } from "@smithy/core/schema";
|
|
2
1
|
import { fromUtf8 } from "@smithy/util-utf8";
|
|
3
2
|
export class EventStreamSerde {
|
|
3
|
+
marshaller;
|
|
4
|
+
serializer;
|
|
5
|
+
deserializer;
|
|
6
|
+
serdeContext;
|
|
7
|
+
defaultContentType;
|
|
4
8
|
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }) {
|
|
5
9
|
this.marshaller = marshaller;
|
|
6
10
|
this.serializer = serializer;
|
|
@@ -123,12 +127,15 @@ export class EventStreamSerde {
|
|
|
123
127
|
let eventType = unionMember;
|
|
124
128
|
let explicitPayloadMember = null;
|
|
125
129
|
let explicitPayloadContentType;
|
|
126
|
-
const isKnownSchema =
|
|
130
|
+
const isKnownSchema = (() => {
|
|
131
|
+
const struct = unionSchema.getSchema();
|
|
132
|
+
return struct.memberNames.includes(unionMember);
|
|
133
|
+
})();
|
|
127
134
|
const additionalHeaders = {};
|
|
128
135
|
if (!isKnownSchema) {
|
|
129
136
|
const [type, value] = event[unionMember];
|
|
130
137
|
eventType = type;
|
|
131
|
-
serializer.write(
|
|
138
|
+
serializer.write(15, value);
|
|
132
139
|
}
|
|
133
140
|
else {
|
|
134
141
|
const eventSchema = unionSchema.getMemberSchema(unionMember);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NormalizedSchema,
|
|
1
|
+
import { NormalizedSchema, translateTraits } from "@smithy/core/schema";
|
|
2
2
|
import { splitEvery, splitHeader } from "@smithy/core/serde";
|
|
3
3
|
import { HttpRequest } from "@smithy/protocol-http";
|
|
4
4
|
import { sdkStreamMixin } from "@smithy/util-stream";
|
|
@@ -31,7 +31,7 @@ export class HttpBindingProtocol extends HttpProtocol {
|
|
|
31
31
|
if (endpoint) {
|
|
32
32
|
this.updateServiceEndpoint(request, endpoint);
|
|
33
33
|
this.setHostPrefix(request, operationSchema, input);
|
|
34
|
-
const opTraits =
|
|
34
|
+
const opTraits = translateTraits(operationSchema.traits);
|
|
35
35
|
if (opTraits.http) {
|
|
36
36
|
request.method = opTraits.http[0];
|
|
37
37
|
const [path, search] = opTraits.http[1].split("?");
|
|
@@ -155,7 +155,7 @@ export class HttpBindingProtocol extends HttpProtocol {
|
|
|
155
155
|
if (response.statusCode >= 300) {
|
|
156
156
|
const bytes = await collectBody(response.body, context);
|
|
157
157
|
if (bytes.byteLength > 0) {
|
|
158
|
-
Object.assign(dataObject, await deserializer.read(
|
|
158
|
+
Object.assign(dataObject, await deserializer.read(15, bytes));
|
|
159
159
|
}
|
|
160
160
|
await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
|
|
161
161
|
throw new Error("@smithy/core/protocols - HTTP Protocol error handler failed to throw.");
|
|
@@ -221,7 +221,7 @@ export class HttpBindingProtocol extends HttpProtocol {
|
|
|
221
221
|
headerListValueSchema.getMergedTraits().httpHeader = key;
|
|
222
222
|
let sections;
|
|
223
223
|
if (headerListValueSchema.isTimestampSchema() &&
|
|
224
|
-
headerListValueSchema.getSchema() ===
|
|
224
|
+
headerListValueSchema.getSchema() === 4) {
|
|
225
225
|
sections = splitEvery(value, ",", 2);
|
|
226
226
|
}
|
|
227
227
|
else {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
2
|
import { HttpRequest, HttpResponse } from "@smithy/protocol-http";
|
|
3
3
|
export class HttpProtocol {
|
|
4
|
+
options;
|
|
5
|
+
serdeContext;
|
|
4
6
|
constructor(options) {
|
|
5
7
|
this.options = options;
|
|
6
8
|
}
|
|
@@ -27,10 +29,10 @@ export class HttpProtocol {
|
|
|
27
29
|
request.fragment = endpoint.url.hash || void 0;
|
|
28
30
|
request.username = endpoint.url.username || void 0;
|
|
29
31
|
request.password = endpoint.url.password || void 0;
|
|
32
|
+
if (!request.query) {
|
|
33
|
+
request.query = {};
|
|
34
|
+
}
|
|
30
35
|
for (const [k, v] of endpoint.url.searchParams.entries()) {
|
|
31
|
-
if (!request.query) {
|
|
32
|
-
request.query = {};
|
|
33
|
-
}
|
|
34
36
|
request.query[k] = v;
|
|
35
37
|
}
|
|
36
38
|
return request;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NormalizedSchema
|
|
1
|
+
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
2
|
import { HttpRequest } from "@smithy/protocol-http";
|
|
3
3
|
import { collectBody } from "./collect-stream-body";
|
|
4
4
|
import { HttpProtocol } from "./HttpProtocol";
|
|
@@ -64,7 +64,7 @@ export class RpcProtocol extends HttpProtocol {
|
|
|
64
64
|
if (response.statusCode >= 300) {
|
|
65
65
|
const bytes = await collectBody(response.body, context);
|
|
66
66
|
if (bytes.byteLength > 0) {
|
|
67
|
-
Object.assign(dataObject, await deserializer.read(
|
|
67
|
+
Object.assign(dataObject, await deserializer.read(15, bytes));
|
|
68
68
|
}
|
|
69
69
|
await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
|
|
70
70
|
throw new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.");
|
|
@@ -4,16 +4,18 @@ export function requestBuilder(input, context) {
|
|
|
4
4
|
return new RequestBuilder(input, context);
|
|
5
5
|
}
|
|
6
6
|
export class RequestBuilder {
|
|
7
|
+
input;
|
|
8
|
+
context;
|
|
9
|
+
query = {};
|
|
10
|
+
method = "";
|
|
11
|
+
headers = {};
|
|
12
|
+
path = "";
|
|
13
|
+
body = null;
|
|
14
|
+
hostname = "";
|
|
15
|
+
resolvePathStack = [];
|
|
7
16
|
constructor(input, context) {
|
|
8
17
|
this.input = input;
|
|
9
18
|
this.context = context;
|
|
10
|
-
this.query = {};
|
|
11
|
-
this.method = "";
|
|
12
|
-
this.headers = {};
|
|
13
|
-
this.path = "";
|
|
14
|
-
this.body = null;
|
|
15
|
-
this.hostname = "";
|
|
16
|
-
this.resolvePathStack = [];
|
|
17
19
|
}
|
|
18
20
|
async build() {
|
|
19
21
|
const { hostname, protocol = "https", port, path: basePath } = await this.context.endpoint();
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { NormalizedSchema
|
|
2
|
-
import {
|
|
1
|
+
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
|
+
import { _parseEpochTimestamp, _parseRfc3339DateTimeWithOffset, _parseRfc7231DateTime, LazyJsonString, NumericValue, splitHeader, } from "@smithy/core/serde";
|
|
3
3
|
import { fromBase64 } from "@smithy/util-base64";
|
|
4
4
|
import { toUtf8 } from "@smithy/util-utf8";
|
|
5
5
|
import { determineTimestampFormat } from "./determineTimestampFormat";
|
|
6
6
|
export class FromStringShapeDeserializer {
|
|
7
|
+
settings;
|
|
8
|
+
serdeContext;
|
|
7
9
|
constructor(settings) {
|
|
8
10
|
this.settings = settings;
|
|
9
11
|
}
|
|
@@ -21,12 +23,12 @@ export class FromStringShapeDeserializer {
|
|
|
21
23
|
if (ns.isTimestampSchema()) {
|
|
22
24
|
const format = determineTimestampFormat(ns, this.settings);
|
|
23
25
|
switch (format) {
|
|
24
|
-
case
|
|
25
|
-
return
|
|
26
|
-
case
|
|
27
|
-
return
|
|
28
|
-
case
|
|
29
|
-
return
|
|
26
|
+
case 5:
|
|
27
|
+
return _parseRfc3339DateTimeWithOffset(data);
|
|
28
|
+
case 6:
|
|
29
|
+
return _parseRfc7231DateTime(data);
|
|
30
|
+
case 7:
|
|
31
|
+
return _parseEpochTimestamp(data);
|
|
30
32
|
default:
|
|
31
33
|
console.warn("Missing timestamp format, parsing value with Date constructor:", data);
|
|
32
34
|
return new Date(data);
|
|
@@ -46,15 +48,17 @@ export class FromStringShapeDeserializer {
|
|
|
46
48
|
return intermediateValue;
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
if (ns.isNumericSchema()) {
|
|
52
|
+
return Number(data);
|
|
53
|
+
}
|
|
54
|
+
if (ns.isBigIntegerSchema()) {
|
|
55
|
+
return BigInt(data);
|
|
56
|
+
}
|
|
57
|
+
if (ns.isBigDecimalSchema()) {
|
|
58
|
+
return new NumericValue(data, "bigDecimal");
|
|
59
|
+
}
|
|
60
|
+
if (ns.isBooleanSchema()) {
|
|
61
|
+
return String(data).toLowerCase() === "true";
|
|
58
62
|
}
|
|
59
63
|
return data;
|
|
60
64
|
}
|
|
@@ -2,6 +2,9 @@ import { NormalizedSchema } from "@smithy/core/schema";
|
|
|
2
2
|
import { fromUtf8, toUtf8 } from "@smithy/util-utf8";
|
|
3
3
|
import { FromStringShapeDeserializer } from "./FromStringShapeDeserializer";
|
|
4
4
|
export class HttpInterceptingShapeDeserializer {
|
|
5
|
+
codecDeserializer;
|
|
6
|
+
stringDeserializer;
|
|
7
|
+
serdeContext;
|
|
5
8
|
constructor(codecDeserializer, codecSettings) {
|
|
6
9
|
this.codecDeserializer = codecDeserializer;
|
|
7
10
|
this.stringDeserializer = new FromStringShapeDeserializer(codecSettings);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
2
|
import { ToStringShapeSerializer } from "./ToStringShapeSerializer";
|
|
3
3
|
export class HttpInterceptingShapeSerializer {
|
|
4
|
+
codecSerializer;
|
|
5
|
+
stringSerializer;
|
|
6
|
+
buffer;
|
|
4
7
|
constructor(codecSerializer, codecSettings, stringSerializer = new ToStringShapeSerializer(codecSettings)) {
|
|
5
8
|
this.codecSerializer = codecSerializer;
|
|
6
9
|
this.stringSerializer = stringSerializer;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { NormalizedSchema
|
|
1
|
+
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
2
|
import { dateToUtcString, LazyJsonString, quoteHeader } from "@smithy/core/serde";
|
|
3
3
|
import { toBase64 } from "@smithy/util-base64";
|
|
4
4
|
import { determineTimestampFormat } from "./determineTimestampFormat";
|
|
5
5
|
export class ToStringShapeSerializer {
|
|
6
|
+
settings;
|
|
7
|
+
stringBuffer = "";
|
|
8
|
+
serdeContext = undefined;
|
|
6
9
|
constructor(settings) {
|
|
7
10
|
this.settings = settings;
|
|
8
|
-
this.stringBuffer = "";
|
|
9
|
-
this.serdeContext = undefined;
|
|
10
11
|
}
|
|
11
12
|
setSerdeContext(serdeContext) {
|
|
12
13
|
this.serdeContext = serdeContext;
|
|
@@ -25,13 +26,13 @@ export class ToStringShapeSerializer {
|
|
|
25
26
|
}
|
|
26
27
|
const format = determineTimestampFormat(ns, this.settings);
|
|
27
28
|
switch (format) {
|
|
28
|
-
case
|
|
29
|
+
case 5:
|
|
29
30
|
this.stringBuffer = value.toISOString().replace(".000Z", "Z");
|
|
30
31
|
break;
|
|
31
|
-
case
|
|
32
|
+
case 6:
|
|
32
33
|
this.stringBuffer = dateToUtcString(value);
|
|
33
34
|
break;
|
|
34
|
-
case
|
|
35
|
+
case 7:
|
|
35
36
|
this.stringBuffer = String(value.getTime() / 1000);
|
|
36
37
|
break;
|
|
37
38
|
default:
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { SCHEMA } from "@smithy/core/schema";
|
|
2
1
|
export function determineTimestampFormat(ns, settings) {
|
|
3
2
|
if (settings.timestampFormat.useTrait) {
|
|
4
3
|
if (ns.isTimestampSchema() &&
|
|
5
|
-
(ns.getSchema() ===
|
|
6
|
-
ns.getSchema() ===
|
|
7
|
-
ns.getSchema() ===
|
|
4
|
+
(ns.getSchema() === 5 ||
|
|
5
|
+
ns.getSchema() === 6 ||
|
|
6
|
+
ns.getSchema() === 7)) {
|
|
8
7
|
return ns.getSchema();
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
10
|
const { httpLabel, httpPrefixHeaders, httpHeader, httpQuery } = ns.getMergedTraits();
|
|
12
11
|
const bindingFormat = settings.httpBindings
|
|
13
12
|
? typeof httpPrefixHeaders === "string" || Boolean(httpHeader)
|
|
14
|
-
?
|
|
13
|
+
? 6
|
|
15
14
|
: Boolean(httpQuery) || Boolean(httpLabel)
|
|
16
|
-
?
|
|
15
|
+
? 5
|
|
17
16
|
: undefined
|
|
18
17
|
: undefined;
|
|
19
18
|
return bindingFormat ?? settings.timestampFormat.default;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export class TypeRegistry {
|
|
2
|
+
namespace;
|
|
3
|
+
schemas;
|
|
4
|
+
exceptions;
|
|
5
|
+
static registries = new Map();
|
|
2
6
|
constructor(namespace, schemas = new Map(), exceptions = new Map()) {
|
|
3
7
|
this.namespace = namespace;
|
|
4
8
|
this.schemas = schemas;
|
|
@@ -52,4 +56,3 @@ export class TypeRegistry {
|
|
|
52
56
|
return this.normalizeShapeId(shapeId).split("#")[0];
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
|
-
TypeRegistry.registries = new Map();
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Schema } from "./Schema";
|
|
2
2
|
import { StructureSchema } from "./StructureSchema";
|
|
3
3
|
export class ErrorSchema extends StructureSchema {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
4
|
+
static symbol = Symbol.for("@smithy/err");
|
|
5
|
+
ctor;
|
|
6
|
+
symbol = ErrorSchema.symbol;
|
|
8
7
|
}
|
|
9
|
-
ErrorSchema.symbol = Symbol.for("@smithy/err");
|
|
10
8
|
export const error = (namespace, name, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), {
|
|
11
9
|
name,
|
|
12
10
|
namespace,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Schema } from "./Schema";
|
|
2
2
|
export class ListSchema extends Schema {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
static symbol = Symbol.for("@smithy/lis");
|
|
4
|
+
name;
|
|
5
|
+
traits;
|
|
6
|
+
valueSchema;
|
|
7
|
+
symbol = ListSchema.symbol;
|
|
7
8
|
}
|
|
8
|
-
ListSchema.symbol = Symbol.for("@smithy/lis");
|
|
9
9
|
export const list = (namespace, name, traits, valueSchema) => Schema.assign(new ListSchema(), {
|
|
10
10
|
name,
|
|
11
11
|
namespace,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Schema } from "./Schema";
|
|
2
2
|
export class MapSchema extends Schema {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
static symbol = Symbol.for("@smithy/map");
|
|
4
|
+
name;
|
|
5
|
+
traits;
|
|
6
|
+
keySchema;
|
|
7
|
+
valueSchema;
|
|
8
|
+
symbol = MapSchema.symbol;
|
|
7
9
|
}
|
|
8
|
-
MapSchema.symbol = Symbol.for("@smithy/map");
|
|
9
10
|
export const map = (namespace, name, traits, keySchema, valueSchema) => Schema.assign(new MapSchema(), {
|
|
10
11
|
name,
|
|
11
12
|
namespace,
|