@smithy/core 3.39.0 → 3.41.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/CHANGELOG.md +16 -0
- package/dist-cjs/submodules/protocols/index.js +600 -328
- package/dist-cjs/submodules/retry/index.browser.js +8 -8
- package/dist-cjs/submodules/retry/index.js +8 -8
- package/dist-cjs/submodules/serde/index.browser.js +9 -4
- package/dist-cjs/submodules/serde/index.js +9 -4
- package/dist-cjs/submodules/serde/index.native.js +9 -4
- package/dist-es/submodules/protocols/HttpBindingNormalizedSchema.js +215 -0
- package/dist-es/submodules/protocols/HttpBindingProtocol.js +223 -195
- package/dist-es/submodules/protocols/HttpProtocol.js +22 -23
- package/dist-es/submodules/protocols/extended-encode-uri-component.js +3 -0
- package/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +54 -47
- package/dist-es/submodules/protocols/serde/HttpInterceptingShapeDeserializer.js +23 -18
- package/dist-es/submodules/protocols/serde/HttpInterceptingShapeSerializer.js +12 -5
- package/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +33 -27
- package/dist-es/submodules/protocols/serde/determineTimestampFormat.js +5 -5
- package/dist-es/submodules/retry/util-retry/StandardRetryStrategy.js +2 -2
- package/dist-es/submodules/retry/util-retry/retries-2026-config.js +6 -6
- package/dist-es/submodules/serde/quote-header.js +1 -1
- package/dist-es/submodules/serde/schema-serde-lib/schema-date-utils.js +4 -0
- package/dist-es/submodules/serde/split-header.js +4 -3
- package/dist-types/submodules/protocols/HttpBindingNormalizedSchema.d.ts +75 -0
- package/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +11 -8
- package/dist-types/submodules/protocols/HttpProtocol.d.ts +2 -2
- package/dist-types/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +2 -1
- package/dist-types/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +4 -0
- package/dist-types/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +3 -0
- package/dist-types/submodules/protocols/serde/ToStringShapeSerializer.d.ts +2 -0
- package/dist-types/submodules/retry/util-retry/retries-2026-config.d.ts +16 -6
- package/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +1 -1
- package/dist-types/ts3.4/submodules/protocols/HttpBindingNormalizedSchema.d.ts +81 -0
- package/dist-types/ts3.4/submodules/protocols/HttpBindingProtocol.d.ts +11 -8
- package/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +1 -1
- package/dist-types/ts3.4/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +2 -1
- package/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +4 -0
- package/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +3 -0
- package/dist-types/ts3.4/submodules/protocols/serde/ToStringShapeSerializer.d.ts +2 -0
- package/dist-types/ts3.4/submodules/retry/util-retry/retries-2026-config.d.ts +16 -6
- package/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
1
|
import { LazyJsonString, NumericValue, _parseEpochTimestamp, _parseRfc3339DateTimeWithOffset, _parseRfc7231DateTime, fromBase64, splitHeader, toUtf8, } from "@smithy/core/serde";
|
|
2
|
+
import { HttpBindingNormalizedSchema, } from "../HttpBindingNormalizedSchema";
|
|
3
3
|
import { SerdeContext } from "../SerdeContext";
|
|
4
|
-
import { determineTimestampFormat } from "./determineTimestampFormat";
|
|
5
4
|
export class FromStringShapeDeserializer extends SerdeContext {
|
|
6
5
|
settings;
|
|
7
6
|
constructor(settings) {
|
|
@@ -9,56 +8,64 @@ export class FromStringShapeDeserializer extends SerdeContext {
|
|
|
9
8
|
this.settings = settings;
|
|
10
9
|
}
|
|
11
10
|
read(_schema, data) {
|
|
12
|
-
const ns =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const ns = HttpBindingNormalizedSchema.of(_schema);
|
|
12
|
+
const traits = ns.getMergedTraits();
|
|
13
|
+
const location = ns.getHttpBindingLocation(traits);
|
|
14
|
+
return this.readHttpBinding(ns.getHttpBindingValue(location, traits), data, location);
|
|
15
|
+
}
|
|
16
|
+
readHttpBinding([ns, flags, collectionValue], data, location) {
|
|
17
|
+
const schema = flags & 0xff;
|
|
18
|
+
if ((schema & 0b1100_0000) === 0b0100_0000) {
|
|
19
|
+
collectionValue ??= ns.getHttpBindingCollectionValue(location);
|
|
20
|
+
return splitHeader(data).map((item) => this.readHttpBinding(collectionValue, item, location));
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
switch (schema) {
|
|
23
|
+
case 21:
|
|
24
|
+
case 42:
|
|
25
|
+
return (this.serdeContext?.base64Decoder ?? fromBase64)(data);
|
|
26
|
+
case 4:
|
|
27
|
+
case 5:
|
|
28
|
+
case 6:
|
|
29
|
+
case 7: {
|
|
30
|
+
const bindingFormat = this.settings.httpBindings ? (flags >> 14) & 0b11 : 0;
|
|
31
|
+
const format = this.settings.timestampFormat.useTrait && schema > 4
|
|
32
|
+
? schema
|
|
33
|
+
: bindingFormat
|
|
34
|
+
? bindingFormat + 4
|
|
35
|
+
: this.settings.timestampFormat.default;
|
|
36
|
+
switch (format) {
|
|
37
|
+
case 5:
|
|
38
|
+
return _parseRfc3339DateTimeWithOffset(data);
|
|
39
|
+
case 6:
|
|
40
|
+
return _parseRfc7231DateTime(data);
|
|
41
|
+
case 7:
|
|
42
|
+
return _parseEpochTimestamp(data);
|
|
43
|
+
default:
|
|
44
|
+
console.warn("Missing timestamp format, parsing value with Date constructor:", data);
|
|
45
|
+
return new Date(data);
|
|
46
|
+
}
|
|
31
47
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (mediaType) {
|
|
37
|
-
if (ns.getMergedTraits().httpHeader) {
|
|
38
|
-
intermediateValue = this.base64ToUtf8(intermediateValue);
|
|
48
|
+
case 0: {
|
|
49
|
+
const media = (flags >> 8) & 0b11;
|
|
50
|
+
if (!media) {
|
|
51
|
+
return data;
|
|
39
52
|
}
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
intermediateValue =
|
|
53
|
+
let intermediateValue = data;
|
|
54
|
+
if ((location & 0b110) === 0b110) {
|
|
55
|
+
intermediateValue = (this.serdeContext?.utf8Encoder ?? toUtf8)((this.serdeContext?.base64Decoder ?? fromBase64)(intermediateValue));
|
|
43
56
|
}
|
|
44
|
-
return intermediateValue;
|
|
57
|
+
return media === 2 ? LazyJsonString.from(intermediateValue) : intermediateValue;
|
|
45
58
|
}
|
|
59
|
+
case 1:
|
|
60
|
+
return Number(data);
|
|
61
|
+
case 2:
|
|
62
|
+
return data.toLowerCase() === "true";
|
|
63
|
+
case 17:
|
|
64
|
+
return BigInt(data);
|
|
65
|
+
case 19:
|
|
66
|
+
return new NumericValue(data, "bigDecimal");
|
|
67
|
+
default:
|
|
68
|
+
return data;
|
|
46
69
|
}
|
|
47
|
-
if (ns.isNumericSchema()) {
|
|
48
|
-
return Number(data);
|
|
49
|
-
}
|
|
50
|
-
if (ns.isBigIntegerSchema()) {
|
|
51
|
-
return BigInt(data);
|
|
52
|
-
}
|
|
53
|
-
if (ns.isBigDecimalSchema()) {
|
|
54
|
-
return new NumericValue(data, "bigDecimal");
|
|
55
|
-
}
|
|
56
|
-
if (ns.isBooleanSchema()) {
|
|
57
|
-
return String(data).toLowerCase() === "true";
|
|
58
|
-
}
|
|
59
|
-
return data;
|
|
60
|
-
}
|
|
61
|
-
base64ToUtf8(base64String) {
|
|
62
|
-
return (this.serdeContext?.utf8Encoder ?? toUtf8)((this.serdeContext?.base64Decoder ?? fromBase64)(base64String));
|
|
63
70
|
}
|
|
64
71
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
1
|
import { fromUtf8, toUtf8 } from "@smithy/core/serde";
|
|
2
|
+
import { HttpBindingNormalizedSchema, } from "../HttpBindingNormalizedSchema";
|
|
3
3
|
import { SerdeContext } from "../SerdeContext";
|
|
4
4
|
import { FromStringShapeDeserializer } from "./FromStringShapeDeserializer";
|
|
5
5
|
export class HttpInterceptingShapeDeserializer extends SerdeContext {
|
|
@@ -16,27 +16,32 @@ export class HttpInterceptingShapeDeserializer extends SerdeContext {
|
|
|
16
16
|
this.serdeContext = serdeContext;
|
|
17
17
|
}
|
|
18
18
|
read(schema, data) {
|
|
19
|
-
const ns =
|
|
19
|
+
const ns = HttpBindingNormalizedSchema.of(schema);
|
|
20
20
|
const traits = ns.getMergedTraits();
|
|
21
|
-
const toString = this.serdeContext?.utf8Encoder ?? toUtf8;
|
|
22
21
|
if (traits.httpHeader || traits.httpResponseCode) {
|
|
23
|
-
|
|
22
|
+
const value = ns.getHttpBindingValue(0b100_110, traits);
|
|
23
|
+
return this.readHttpBinding(value, data, 0b100_110);
|
|
24
24
|
}
|
|
25
25
|
if (traits.httpPayload) {
|
|
26
|
-
|
|
27
|
-
const toBytes = this.serdeContext?.utf8Decoder ?? fromUtf8;
|
|
28
|
-
if (typeof data === "string") {
|
|
29
|
-
return toBytes(data);
|
|
30
|
-
}
|
|
31
|
-
return data;
|
|
32
|
-
}
|
|
33
|
-
else if (ns.isStringSchema()) {
|
|
34
|
-
if ("byteLength" in data) {
|
|
35
|
-
return toString(data);
|
|
36
|
-
}
|
|
37
|
-
return data;
|
|
38
|
-
}
|
|
26
|
+
return this.readPayload(ns.getHttpBindingValue(0b100_100, traits), data);
|
|
39
27
|
}
|
|
40
|
-
return this.
|
|
28
|
+
return this.readCodec(ns, data);
|
|
29
|
+
}
|
|
30
|
+
readHttpBinding(binding, data, location) {
|
|
31
|
+
const value = typeof data === "string" ? data : (this.serdeContext?.utf8Encoder ?? toUtf8)(data);
|
|
32
|
+
return this.stringDeserializer.readHttpBinding(binding, value, location);
|
|
33
|
+
}
|
|
34
|
+
readPayload([schema, flags], data) {
|
|
35
|
+
const type = flags & 0xff;
|
|
36
|
+
if (type === 21 || type === 42) {
|
|
37
|
+
return typeof data === "string" ? (this.serdeContext?.utf8Decoder ?? fromUtf8)(data) : data;
|
|
38
|
+
}
|
|
39
|
+
if (type === 0) {
|
|
40
|
+
return typeof data === "string" ? data : (this.serdeContext?.utf8Encoder ?? toUtf8)(data);
|
|
41
|
+
}
|
|
42
|
+
return this.readCodec(schema, data);
|
|
43
|
+
}
|
|
44
|
+
readCodec(schema, data) {
|
|
45
|
+
return this.codecDeserializer.read(schema, data);
|
|
41
46
|
}
|
|
42
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpBindingNormalizedSchema, } from "../HttpBindingNormalizedSchema";
|
|
2
2
|
import { ToStringShapeSerializer } from "./ToStringShapeSerializer";
|
|
3
3
|
export class HttpInterceptingShapeSerializer {
|
|
4
4
|
codecSerializer;
|
|
@@ -13,14 +13,21 @@ export class HttpInterceptingShapeSerializer {
|
|
|
13
13
|
this.stringSerializer.setSerdeContext(serdeContext);
|
|
14
14
|
}
|
|
15
15
|
write(schema, value) {
|
|
16
|
-
const ns =
|
|
16
|
+
const ns = HttpBindingNormalizedSchema.of(schema);
|
|
17
17
|
const traits = ns.getMergedTraits();
|
|
18
18
|
if (traits.httpHeader || traits.httpLabel || traits.httpQuery) {
|
|
19
|
-
|
|
20
|
-
this.
|
|
19
|
+
const location = ns.getHttpBindingLocation(traits);
|
|
20
|
+
this.writeHttpBinding(ns.getHttpBindingValue(location, traits), value, location);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
this.writeCodec(ns, value);
|
|
24
|
+
}
|
|
25
|
+
writeHttpBinding(binding, value, location) {
|
|
26
|
+
this.stringSerializer.writeHttpBinding(binding, value, location);
|
|
27
|
+
this.buffer = this.stringSerializer.flush();
|
|
28
|
+
}
|
|
29
|
+
writeCodec(schema, value) {
|
|
30
|
+
this.codecSerializer.write(schema, value);
|
|
24
31
|
}
|
|
25
32
|
flush() {
|
|
26
33
|
if (this.buffer !== undefined) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
1
|
import { LazyJsonString, dateToUtcString, generateIdempotencyToken, quoteHeader, toBase64 } from "@smithy/core/serde";
|
|
2
|
+
import { HttpBindingNormalizedSchema, } from "../HttpBindingNormalizedSchema";
|
|
3
3
|
import { SerdeContext } from "../SerdeContext";
|
|
4
|
-
import { determineTimestampFormat } from "./determineTimestampFormat";
|
|
5
4
|
export class ToStringShapeSerializer extends SerdeContext {
|
|
6
5
|
settings;
|
|
7
6
|
stringBuffer = "";
|
|
@@ -10,18 +9,29 @@ export class ToStringShapeSerializer extends SerdeContext {
|
|
|
10
9
|
this.settings = settings;
|
|
11
10
|
}
|
|
12
11
|
write(schema, value) {
|
|
13
|
-
const ns =
|
|
12
|
+
const ns = HttpBindingNormalizedSchema.of(schema);
|
|
13
|
+
const traits = ns.getMergedTraits();
|
|
14
|
+
const location = ns.getHttpBindingLocation(traits);
|
|
15
|
+
this.writeHttpBinding(ns.getHttpBindingValue(location, traits), value, location);
|
|
16
|
+
}
|
|
17
|
+
writeHttpBinding([ns, flags, collectionValue], value, location) {
|
|
18
|
+
const schema = flags & 0xff;
|
|
14
19
|
switch (typeof value) {
|
|
15
20
|
case "object":
|
|
16
21
|
if (value === null) {
|
|
17
22
|
this.stringBuffer = "null";
|
|
18
23
|
return;
|
|
19
24
|
}
|
|
20
|
-
if (
|
|
25
|
+
if (schema >= 4 && schema <= 7) {
|
|
21
26
|
if (!(value instanceof Date)) {
|
|
22
27
|
throw new Error(`@smithy/core/protocols - received non-Date value ${value} when schema expected Date in ${ns.getName(true)}`);
|
|
23
28
|
}
|
|
24
|
-
const
|
|
29
|
+
const bindingFormat = this.settings.httpBindings ? (flags >> 14) & 0b11 : 0;
|
|
30
|
+
const format = this.settings.timestampFormat.useTrait && schema > 4
|
|
31
|
+
? schema
|
|
32
|
+
: bindingFormat
|
|
33
|
+
? bindingFormat + 4
|
|
34
|
+
: this.settings.timestampFormat.default;
|
|
25
35
|
switch (format) {
|
|
26
36
|
case 5:
|
|
27
37
|
this.stringBuffer = value.toISOString().replace(".000Z", "Z");
|
|
@@ -38,20 +48,24 @@ export class ToStringShapeSerializer extends SerdeContext {
|
|
|
38
48
|
}
|
|
39
49
|
return;
|
|
40
50
|
}
|
|
41
|
-
if (
|
|
51
|
+
if ((schema === 21 || schema === 42) &&
|
|
52
|
+
"byteLength" in value) {
|
|
42
53
|
this.stringBuffer = (this.serdeContext?.base64Encoder ?? toBase64)(value);
|
|
43
54
|
return;
|
|
44
55
|
}
|
|
45
|
-
if (
|
|
56
|
+
if ((schema & 0b1100_0000) === 0b0100_0000 && Array.isArray(value)) {
|
|
57
|
+
collectionValue ??= ns.getHttpBindingCollectionValue(location);
|
|
58
|
+
const valueSchemaType = collectionValue[1] & 0xff;
|
|
59
|
+
const isTimestamp = valueSchemaType >= 4 &&
|
|
60
|
+
valueSchemaType <= 7;
|
|
46
61
|
let buffer = "";
|
|
47
62
|
for (const item of value) {
|
|
48
|
-
this.
|
|
63
|
+
this.writeHttpBinding(collectionValue, item, location);
|
|
49
64
|
const headerItem = this.flush();
|
|
50
|
-
|
|
51
|
-
if (buffer !== "") {
|
|
65
|
+
if (buffer) {
|
|
52
66
|
buffer += ", ";
|
|
53
67
|
}
|
|
54
|
-
buffer +=
|
|
68
|
+
buffer += isTimestamp ? headerItem : quoteHeader(headerItem);
|
|
55
69
|
}
|
|
56
70
|
this.stringBuffer = buffer;
|
|
57
71
|
return;
|
|
@@ -59,27 +73,19 @@ export class ToStringShapeSerializer extends SerdeContext {
|
|
|
59
73
|
this.stringBuffer = JSON.stringify(value, null, 2);
|
|
60
74
|
break;
|
|
61
75
|
case "string":
|
|
62
|
-
const
|
|
76
|
+
const media = (flags >> 8) & 0b11;
|
|
63
77
|
let intermediateValue = value;
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.stringBuffer = (this.serdeContext?.base64Encoder ?? toBase64)(intermediateValue.toString());
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
78
|
+
if (media === 2) {
|
|
79
|
+
intermediateValue = LazyJsonString.from(intermediateValue);
|
|
80
|
+
}
|
|
81
|
+
if (media && (location & 0b110) === 0b110) {
|
|
82
|
+
this.stringBuffer = (this.serdeContext?.base64Encoder ?? toBase64)(intermediateValue.toString());
|
|
83
|
+
return;
|
|
73
84
|
}
|
|
74
85
|
this.stringBuffer = value;
|
|
75
86
|
break;
|
|
76
87
|
default:
|
|
77
|
-
|
|
78
|
-
this.stringBuffer = generateIdempotencyToken();
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
this.stringBuffer = String(value);
|
|
82
|
-
}
|
|
88
|
+
this.stringBuffer = (flags >> 10) & 1 ? generateIdempotencyToken() : String(value);
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
91
|
flush() {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export function determineTimestampFormat(ns, settings) {
|
|
2
2
|
if (settings.timestampFormat.useTrait) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return
|
|
3
|
+
const schema = ns.getSchema();
|
|
4
|
+
if (schema === 5 ||
|
|
5
|
+
schema === 6 ||
|
|
6
|
+
schema === 7) {
|
|
7
|
+
return schema;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
const { httpLabel, httpPrefixHeaders, httpHeader, httpQuery } = ns.getMergedTraits();
|
|
@@ -31,7 +31,7 @@ export class StandardRetryStrategy {
|
|
|
31
31
|
this.retryBackoffStrategy ??= new DefaultRetryBackoffStrategy();
|
|
32
32
|
}
|
|
33
33
|
async acquireInitialRetryToken(retryTokenScope) {
|
|
34
|
-
return new DefaultRetryToken(Retry.delay(), 0, undefined,
|
|
34
|
+
return new DefaultRetryToken(Retry.delay(), 0, undefined, retryTokenScope.includes(":longpoll"));
|
|
35
35
|
}
|
|
36
36
|
async refreshRetryTokenForRetry(token, errorInfo) {
|
|
37
37
|
const maxAttempts = await this.getMaxAttempts();
|
|
@@ -47,7 +47,7 @@ export class StandardRetryStrategy {
|
|
|
47
47
|
retryDelay = Math.max(delayFromErrorType, Math.min(errorInfo.retryAfterHint.getTime() - Date.now(), delayFromErrorType + 5_000));
|
|
48
48
|
}
|
|
49
49
|
if (!shouldRetry) {
|
|
50
|
-
const longPollBackoff =
|
|
50
|
+
const longPollBackoff = retryCode === refusal.capacity && isLongPoll ? retryDelay : 0;
|
|
51
51
|
if (longPollBackoff > 0) {
|
|
52
52
|
await new Promise((r) => setTimeout(r, longPollBackoff));
|
|
53
53
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export class Retry {
|
|
2
|
-
static v2026 =
|
|
2
|
+
static v2026 = true;
|
|
3
3
|
static delay() {
|
|
4
|
-
return
|
|
4
|
+
return 50;
|
|
5
5
|
}
|
|
6
6
|
static throttlingDelay() {
|
|
7
|
-
return
|
|
7
|
+
return 1_000;
|
|
8
8
|
}
|
|
9
9
|
static cost() {
|
|
10
|
-
return
|
|
10
|
+
return 14;
|
|
11
11
|
}
|
|
12
12
|
static throttlingCost() {
|
|
13
|
-
return
|
|
13
|
+
return 5;
|
|
14
14
|
}
|
|
15
15
|
static modifiedCostType() {
|
|
16
|
-
return
|
|
16
|
+
return "THROTTLING";
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -4,6 +4,7 @@ const time = `(\\d?\\d):(\\d{2}):(\\d{2})(?:\\.(\\d+))?`;
|
|
|
4
4
|
const date = `(\\d?\\d)`;
|
|
5
5
|
const year = `(\\d{4})`;
|
|
6
6
|
const RFC3339_WITH_OFFSET = new RegExp(/^(\d{4})-(\d\d)-(\d\d)[tT](\d\d):(\d\d):(\d\d)(\.(\d+))?(([-+]\d\d:\d\d)|[zZ])$/);
|
|
7
|
+
const IMF_FIXDATE_NATIVE = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:0[1-9]|[12]\d|3[01]) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [1-9]\d{3} (?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d GMT$/;
|
|
7
8
|
const IMF_FIXDATE = new RegExp(`^${ddd}, ${date} ${mmm} ${year} ${time} GMT$`);
|
|
8
9
|
const RFC_850_DATE = new RegExp(`^${ddd}, ${date}-${mmm}-(\\d\\d) ${time} GMT$`);
|
|
9
10
|
const ASC_TIME = new RegExp(`^${ddd} ${mmm} ( [1-9]|\\d\\d) ${time} ${year}$`);
|
|
@@ -63,6 +64,9 @@ export const _parseRfc7231DateTime = (value) => {
|
|
|
63
64
|
if (typeof value !== "string") {
|
|
64
65
|
throw new TypeError("RFC7231 timestamps must be strings.");
|
|
65
66
|
}
|
|
67
|
+
if (IMF_FIXDATE_NATIVE.test(value)) {
|
|
68
|
+
return new Date(value);
|
|
69
|
+
}
|
|
66
70
|
let day;
|
|
67
71
|
let month;
|
|
68
72
|
let year;
|
|
@@ -2,13 +2,13 @@ export const splitHeader = (value) => {
|
|
|
2
2
|
const z = value.length;
|
|
3
3
|
const values = [];
|
|
4
4
|
let withinQuotes = false;
|
|
5
|
-
let
|
|
5
|
+
let escaped = false;
|
|
6
6
|
let anchor = 0;
|
|
7
7
|
for (let i = 0; i < z; ++i) {
|
|
8
8
|
const char = value[i];
|
|
9
9
|
switch (char) {
|
|
10
10
|
case `"`:
|
|
11
|
-
if (
|
|
11
|
+
if (!escaped) {
|
|
12
12
|
withinQuotes = !withinQuotes;
|
|
13
13
|
}
|
|
14
14
|
break;
|
|
@@ -20,7 +20,7 @@ export const splitHeader = (value) => {
|
|
|
20
20
|
break;
|
|
21
21
|
default:
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
escaped = char === "\\" && !escaped;
|
|
24
24
|
}
|
|
25
25
|
values.push(value.slice(anchor));
|
|
26
26
|
return values.map((v) => {
|
|
@@ -31,6 +31,7 @@ export const splitHeader = (value) => {
|
|
|
31
31
|
}
|
|
32
32
|
if (v[0] === `"` && v[z - 1] === `"`) {
|
|
33
33
|
v = v.slice(1, z - 1);
|
|
34
|
+
return v.replace(/\\(["\\])/g, "$1");
|
|
34
35
|
}
|
|
35
36
|
return v.replace(/\\"/g, '"');
|
|
36
37
|
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { NormalizedSchema } from "@smithy/core/schema";
|
|
2
|
+
import type { OperationSchema, StaticStructureSchema } from "@smithy/types";
|
|
3
|
+
export type HttpBody = 0b100_000;
|
|
4
|
+
export type HttpLabel = 0b100_001;
|
|
5
|
+
export type HttpQuery = 0b100_010;
|
|
6
|
+
export type HttpQueryParams = 0b100_011;
|
|
7
|
+
export type HttpPayload = 0b100_100;
|
|
8
|
+
export type HttpResponseCode = 0b100_101;
|
|
9
|
+
export type HttpHeader = 0b100_110;
|
|
10
|
+
export type HttpPrefixHeaders = 0b100_111;
|
|
11
|
+
export type HttpBindingLocation = HttpBody | HttpHeader | HttpQuery | HttpLabel | HttpPayload | HttpPrefixHeaders | HttpQueryParams | HttpResponseCode;
|
|
12
|
+
/**
|
|
13
|
+
* The low byte is the schema type. Higher bits cache HTTP serde traits.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export type HttpBindingValue = readonly [
|
|
18
|
+
schema: HttpBindingNormalizedSchema,
|
|
19
|
+
flags: number,
|
|
20
|
+
collectionValue?: HttpBindingValue
|
|
21
|
+
];
|
|
22
|
+
export type HttpBinding = readonly [
|
|
23
|
+
memberName: string,
|
|
24
|
+
value: HttpBindingValue,
|
|
25
|
+
location: HttpBindingLocation,
|
|
26
|
+
wireName?: string
|
|
27
|
+
];
|
|
28
|
+
export type HttpPathSegment = readonly [value: string, kind: 0 | 1 | 2];
|
|
29
|
+
export type HttpOperationBindings = readonly [
|
|
30
|
+
method: string | undefined,
|
|
31
|
+
path: string | undefined,
|
|
32
|
+
query: readonly (readonly [string, string])[],
|
|
33
|
+
pathSegments: readonly HttpPathSegment[] | undefined,
|
|
34
|
+
hostPrefix: string | undefined
|
|
35
|
+
];
|
|
36
|
+
export type HttpBindingIndex = {
|
|
37
|
+
request: {
|
|
38
|
+
memberBindings: HttpBinding[];
|
|
39
|
+
byName: Record<string, HttpBinding>;
|
|
40
|
+
hasIdempotency?: boolean;
|
|
41
|
+
hasPrefixHeaders?: boolean;
|
|
42
|
+
syntheticBodySchema?: StaticStructureSchema;
|
|
43
|
+
contentTypeInstruction?: string | null;
|
|
44
|
+
};
|
|
45
|
+
response: {
|
|
46
|
+
bodyMemberNames: string[];
|
|
47
|
+
syntheticBodySchema?: StaticStructureSchema;
|
|
48
|
+
bindings: {
|
|
49
|
+
payload?: HttpBinding;
|
|
50
|
+
statusCode?: HttpBinding;
|
|
51
|
+
headers: Record<string, HttpBinding>;
|
|
52
|
+
prefixHeaders: HttpBinding[];
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* A normalized schema with lazily cached HTTP binding metadata.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export declare class HttpBindingNormalizedSchema extends NormalizedSchema {
|
|
62
|
+
private static readonly identity;
|
|
63
|
+
private readonly identity;
|
|
64
|
+
private bindings?;
|
|
65
|
+
private constructor();
|
|
66
|
+
static of(schema: Parameters<typeof NormalizedSchema.of>[0]): HttpBindingNormalizedSchema;
|
|
67
|
+
getHttpBindingLocation(traits: ReturnType<NormalizedSchema["getMergedTraits"]>): HttpBindingLocation;
|
|
68
|
+
getHttpBindingValue(location: HttpBindingLocation, traits: ReturnType<NormalizedSchema["getMergedTraits"]>, nested?: boolean): HttpBindingValue;
|
|
69
|
+
getHttpBindingCollectionValue(location: HttpBindingLocation, traits?: import("@smithy/types").SchemaTraitsObject): HttpBindingValue;
|
|
70
|
+
getHttpBindings(): HttpBindingIndex;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export declare const getHttpOperationBindings: (schema: OperationSchema) => HttpOperationBindings;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { NormalizedSchema, type TypeRegistry } from "@smithy/core/schema";
|
|
2
1
|
import { HttpRequest } from "@smithy/core/transport";
|
|
2
|
+
import type { TypeRegistry } from "@smithy/core/schema";
|
|
3
3
|
import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, Schema, SerdeFunctions } from "@smithy/types";
|
|
4
|
+
import { type HttpBindingValue } from "./HttpBindingNormalizedSchema";
|
|
4
5
|
import { HttpProtocol } from "./HttpProtocol";
|
|
6
|
+
import type { HttpInterceptingShapeSerializer } from "./serde/HttpInterceptingShapeSerializer";
|
|
7
|
+
type HttpBindingSerializer = Pick<HttpInterceptingShapeSerializer<any>, "writeHttpBinding" | "writeCodec">;
|
|
5
8
|
/**
|
|
6
9
|
* Base for HTTP-binding protocols. Downstream examples
|
|
7
10
|
* include AWS REST JSON and AWS REST XML.
|
|
@@ -14,7 +17,10 @@ export declare abstract class HttpBindingProtocol extends HttpProtocol {
|
|
|
14
17
|
*/
|
|
15
18
|
protected compositeErrorRegistry: TypeRegistry;
|
|
16
19
|
serializeRequest<Input extends object>(operationSchema: OperationSchema, _input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
|
|
17
|
-
|
|
20
|
+
private serializeHttpBindings;
|
|
21
|
+
protected serializeQuery(value: HttpBindingValue, data: any, wireName: string | undefined, query: HttpRequest["query"], directSerializer?: HttpBindingSerializer): void;
|
|
22
|
+
private serializeHttpValue;
|
|
23
|
+
private serializePath;
|
|
18
24
|
deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
|
|
19
25
|
/**
|
|
20
26
|
* The base method ignores HTTP bindings.
|
|
@@ -22,10 +28,7 @@ export declare abstract class HttpBindingProtocol extends HttpProtocol {
|
|
|
22
28
|
* @deprecated (only this signature) use signature without headerBindings.
|
|
23
29
|
* @override
|
|
24
30
|
*/
|
|
25
|
-
protected deserializeHttpMessage(schema: Schema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, headerBindings: Set<string>, dataObject: any): Promise<string[]
|
|
26
|
-
|
|
27
|
-
}>;
|
|
28
|
-
protected deserializeHttpMessage(schema: Schema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any): Promise<string[] & {
|
|
29
|
-
discardResponseBody?: boolean;
|
|
30
|
-
}>;
|
|
31
|
+
protected deserializeHttpMessage(schema: Schema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, headerBindings: Set<string>, dataObject: any): Promise<string[]>;
|
|
32
|
+
protected deserializeHttpMessage(schema: Schema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any): Promise<string[]>;
|
|
31
33
|
}
|
|
34
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EventStreamSerde } from "@smithy/core/event-streams";
|
|
2
|
-
import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
|
|
2
|
+
import { type NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
|
|
3
3
|
import type { ClientProtocol, Codec, Endpoint, EndpointBearer, EndpointV2, EventStreamMarshaller, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, Schema, SerdeFunctions, ShapeDeserializer, ShapeSerializer, StaticErrorSchema } from "@smithy/types";
|
|
4
4
|
import { SerdeContext } from "./SerdeContext";
|
|
5
5
|
/**
|
|
@@ -40,7 +40,7 @@ export declare abstract class HttpProtocol extends SerdeContext implements Clien
|
|
|
40
40
|
abstract serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
|
|
41
41
|
updateServiceEndpoint(request: IHttpRequest, endpoint: EndpointV2 | Endpoint): IHttpRequest;
|
|
42
42
|
abstract deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
|
|
43
|
-
protected setHostPrefix<Input extends object>(request: IHttpRequest, operationSchema: OperationSchema, input: Input): void;
|
|
43
|
+
protected setHostPrefix<Input extends object>(request: IHttpRequest, operationSchema: OperationSchema, input: Input, operation?: import("./HttpBindingNormalizedSchema").HttpOperationBindings): void;
|
|
44
44
|
protected abstract handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
|
|
45
45
|
protected deserializeMetadata(output: IHttpResponse): ResponseMetadata;
|
|
46
46
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CodecSettings, Schema, ShapeDeserializer } from "@smithy/types";
|
|
2
|
+
import { type HttpBindingLocation, type HttpBindingValue } from "../HttpBindingNormalizedSchema";
|
|
2
3
|
import { SerdeContext } from "../SerdeContext";
|
|
3
4
|
/**
|
|
4
5
|
* This deserializer reads strings.
|
|
@@ -9,5 +10,5 @@ export declare class FromStringShapeDeserializer extends SerdeContext implements
|
|
|
9
10
|
private settings;
|
|
10
11
|
constructor(settings: CodecSettings);
|
|
11
12
|
read(_schema: Schema, data: string): any;
|
|
12
|
-
|
|
13
|
+
readHttpBinding([ns, flags, collectionValue]: HttpBindingValue, data: string, location: HttpBindingLocation): any;
|
|
13
14
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CodecSettings, Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
|
|
2
|
+
import { type HttpBindingLocation, type HttpBindingValue } from "../HttpBindingNormalizedSchema";
|
|
2
3
|
import { SerdeContext } from "../SerdeContext";
|
|
3
4
|
/**
|
|
4
5
|
* This deserializer is a dispatcher that decides whether to use a string deserializer
|
|
@@ -18,4 +19,7 @@ export declare class HttpInterceptingShapeDeserializer<CodecShapeDeserializer ex
|
|
|
18
19
|
*/
|
|
19
20
|
setSerdeContext(serdeContext: SerdeFunctions): void;
|
|
20
21
|
read(schema: Schema, data: string | Uint8Array): any | Promise<any>;
|
|
22
|
+
readHttpBinding(binding: HttpBindingValue, data: string | Uint8Array, location: HttpBindingLocation): any;
|
|
23
|
+
readPayload([schema, flags]: HttpBindingValue, data: string | Uint8Array): any | Promise<any>;
|
|
24
|
+
readCodec(schema: Schema, data: string | Uint8Array): any | Promise<any>;
|
|
21
25
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CodecSettings, ConfigurableSerdeContext, Schema as ISchema, SerdeFunctions, ShapeSerializer } from "@smithy/types";
|
|
2
|
+
import { type HttpBindingLocation, type HttpBindingValue } from "../HttpBindingNormalizedSchema";
|
|
2
3
|
import { ToStringShapeSerializer } from "./ToStringShapeSerializer";
|
|
3
4
|
/**
|
|
4
5
|
* This serializer decides whether to dispatch to a string serializer or a codec serializer
|
|
@@ -19,5 +20,7 @@ export declare class HttpInterceptingShapeSerializer<CodecShapeSerializer extend
|
|
|
19
20
|
*/
|
|
20
21
|
setSerdeContext(serdeContext: SerdeFunctions): void;
|
|
21
22
|
write(schema: ISchema, value: unknown): void;
|
|
23
|
+
writeHttpBinding(binding: HttpBindingValue, value: unknown, location: HttpBindingLocation): void;
|
|
24
|
+
writeCodec(schema: ISchema, value: unknown): void;
|
|
22
25
|
flush(): string | Uint8Array;
|
|
23
26
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CodecSettings, Schema, ShapeSerializer } from "@smithy/types";
|
|
2
|
+
import { type HttpBindingLocation, type HttpBindingValue } from "../HttpBindingNormalizedSchema";
|
|
2
3
|
import { SerdeContext } from "../SerdeContext";
|
|
3
4
|
/**
|
|
4
5
|
* Serializes a shape to string.
|
|
@@ -10,5 +11,6 @@ export declare class ToStringShapeSerializer extends SerdeContext implements Sha
|
|
|
10
11
|
private stringBuffer;
|
|
11
12
|
constructor(settings: CodecSettings);
|
|
12
13
|
write(schema: Schema, value: unknown): void;
|
|
14
|
+
writeHttpBinding([ns, flags, collectionValue]: HttpBindingValue, value: unknown, location: HttpBindingLocation): void;
|
|
13
15
|
flush(): string;
|
|
14
16
|
}
|