@smithy/core 3.3.3 → 3.5.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.
Files changed (116) hide show
  1. package/dist-cjs/submodules/cbor/index.js +212 -2
  2. package/dist-cjs/submodules/protocols/index.js +667 -2
  3. package/dist-cjs/submodules/schema/index.js +771 -0
  4. package/dist-cjs/submodules/serde/index.js +680 -2
  5. package/dist-es/submodules/cbor/CborCodec.js +136 -0
  6. package/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +74 -0
  7. package/dist-es/submodules/cbor/index.js +3 -1
  8. package/dist-es/submodules/cbor/parseCborBody.js +3 -2
  9. package/dist-es/submodules/protocols/HttpBindingProtocol.js +183 -0
  10. package/dist-es/submodules/protocols/HttpProtocol.js +164 -0
  11. package/dist-es/submodules/protocols/RpcProtocol.js +68 -0
  12. package/dist-es/submodules/protocols/index.js +7 -0
  13. package/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +64 -0
  14. package/dist-es/submodules/protocols/serde/HttpInterceptingShapeDeserializer.js +38 -0
  15. package/dist-es/submodules/protocols/serde/HttpInterceptingShapeSerializer.js +30 -0
  16. package/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +87 -0
  17. package/dist-es/submodules/protocols/serde/determineTimestampFormat.js +20 -0
  18. package/dist-es/submodules/schema/TypeRegistry.js +49 -0
  19. package/dist-es/submodules/schema/deref.js +6 -0
  20. package/dist-es/submodules/schema/index.js +12 -0
  21. package/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js +23 -0
  22. package/dist-es/submodules/schema/middleware/schema-middleware-types.js +1 -0
  23. package/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js +60 -0
  24. package/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js +16 -0
  25. package/dist-es/submodules/schema/schemas/ErrorSchema.js +17 -0
  26. package/dist-es/submodules/schema/schemas/ListSchema.js +15 -0
  27. package/dist-es/submodules/schema/schemas/MapSchema.js +16 -0
  28. package/dist-es/submodules/schema/schemas/NormalizedSchema.js +291 -0
  29. package/dist-es/submodules/schema/schemas/OperationSchema.js +16 -0
  30. package/dist-es/submodules/schema/schemas/Schema.js +6 -0
  31. package/dist-es/submodules/schema/schemas/SimpleSchema.js +15 -0
  32. package/dist-es/submodules/schema/schemas/StructureSchema.js +22 -0
  33. package/dist-es/submodules/schema/schemas/sentinels.js +16 -0
  34. package/dist-es/submodules/serde/copyDocumentWithTransform.js +53 -0
  35. package/dist-es/submodules/serde/date-utils.js +190 -0
  36. package/dist-es/submodules/serde/index.js +7 -0
  37. package/dist-es/submodules/serde/lazy-json.js +24 -0
  38. package/dist-es/submodules/serde/parse-utils.js +230 -0
  39. package/dist-es/submodules/serde/quote-header.js +6 -0
  40. package/dist-es/submodules/serde/split-every.js +27 -0
  41. package/dist-es/submodules/serde/split-header.js +37 -0
  42. package/dist-types/submodules/cbor/CborCodec.d.ts +29 -0
  43. package/dist-types/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +22 -0
  44. package/dist-types/submodules/cbor/index.d.ts +3 -1
  45. package/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +15 -0
  46. package/dist-types/submodules/protocols/HttpProtocol.d.ts +29 -0
  47. package/dist-types/submodules/protocols/RpcProtocol.d.ts +11 -0
  48. package/dist-types/submodules/protocols/index.d.ts +7 -0
  49. package/dist-types/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +14 -0
  50. package/dist-types/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +18 -0
  51. package/dist-types/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +20 -0
  52. package/dist-types/submodules/protocols/serde/ToStringShapeSerializer.d.ts +15 -0
  53. package/dist-types/submodules/protocols/serde/determineTimestampFormat.d.ts +9 -0
  54. package/dist-types/submodules/schema/TypeRegistry.d.ts +55 -0
  55. package/dist-types/submodules/schema/deref.d.ts +6 -0
  56. package/dist-types/submodules/schema/index.d.ts +12 -0
  57. package/dist-types/submodules/schema/middleware/getSchemaSerdePlugin.d.ts +14 -0
  58. package/dist-types/submodules/schema/middleware/schema-middleware-types.d.ts +8 -0
  59. package/dist-types/submodules/schema/middleware/schemaDeserializationMiddleware.d.ts +9 -0
  60. package/dist-types/submodules/schema/middleware/schemaSerializationMiddleware.d.ts +6 -0
  61. package/dist-types/submodules/schema/schemas/ErrorSchema.d.ts +38 -0
  62. package/dist-types/submodules/schema/schemas/ListSchema.d.ts +20 -0
  63. package/dist-types/submodules/schema/schemas/MapSchema.d.ts +25 -0
  64. package/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +122 -0
  65. package/dist-types/submodules/schema/schemas/OperationSchema.d.ts +20 -0
  66. package/dist-types/submodules/schema/schemas/Schema.d.ts +11 -0
  67. package/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +20 -0
  68. package/dist-types/submodules/schema/schemas/StructureSchema.d.ts +21 -0
  69. package/dist-types/submodules/schema/schemas/sentinels.d.ts +21 -0
  70. package/dist-types/submodules/serde/copyDocumentWithTransform.d.ts +5 -0
  71. package/dist-types/submodules/serde/date-utils.d.ts +73 -0
  72. package/dist-types/submodules/serde/index.d.ts +7 -0
  73. package/dist-types/submodules/serde/lazy-json.d.ts +45 -0
  74. package/dist-types/submodules/serde/parse-utils.d.ts +270 -0
  75. package/dist-types/submodules/serde/quote-header.d.ts +6 -0
  76. package/dist-types/submodules/serde/split-every.d.ts +11 -0
  77. package/dist-types/submodules/serde/split-header.d.ts +5 -0
  78. package/dist-types/ts3.4/submodules/cbor/CborCodec.d.ts +29 -0
  79. package/dist-types/ts3.4/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +22 -0
  80. package/dist-types/ts3.4/submodules/cbor/index.d.ts +3 -1
  81. package/dist-types/ts3.4/submodules/protocols/HttpBindingProtocol.d.ts +15 -0
  82. package/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +29 -0
  83. package/dist-types/ts3.4/submodules/protocols/RpcProtocol.d.ts +11 -0
  84. package/dist-types/ts3.4/submodules/protocols/index.d.ts +7 -0
  85. package/dist-types/ts3.4/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +14 -0
  86. package/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +18 -0
  87. package/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +20 -0
  88. package/dist-types/ts3.4/submodules/protocols/serde/ToStringShapeSerializer.d.ts +15 -0
  89. package/dist-types/ts3.4/submodules/protocols/serde/determineTimestampFormat.d.ts +9 -0
  90. package/dist-types/ts3.4/submodules/schema/TypeRegistry.d.ts +55 -0
  91. package/dist-types/ts3.4/submodules/schema/deref.d.ts +6 -0
  92. package/dist-types/ts3.4/submodules/schema/index.d.ts +12 -0
  93. package/dist-types/ts3.4/submodules/schema/middleware/getSchemaSerdePlugin.d.ts +14 -0
  94. package/dist-types/ts3.4/submodules/schema/middleware/schema-middleware-types.d.ts +11 -0
  95. package/dist-types/ts3.4/submodules/schema/middleware/schemaDeserializationMiddleware.d.ts +9 -0
  96. package/dist-types/ts3.4/submodules/schema/middleware/schemaSerializationMiddleware.d.ts +6 -0
  97. package/dist-types/ts3.4/submodules/schema/schemas/ErrorSchema.d.ts +38 -0
  98. package/dist-types/ts3.4/submodules/schema/schemas/ListSchema.d.ts +20 -0
  99. package/dist-types/ts3.4/submodules/schema/schemas/MapSchema.d.ts +25 -0
  100. package/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +125 -0
  101. package/dist-types/ts3.4/submodules/schema/schemas/OperationSchema.d.ts +20 -0
  102. package/dist-types/ts3.4/submodules/schema/schemas/Schema.d.ts +11 -0
  103. package/dist-types/ts3.4/submodules/schema/schemas/SimpleSchema.d.ts +20 -0
  104. package/dist-types/ts3.4/submodules/schema/schemas/StructureSchema.d.ts +24 -0
  105. package/dist-types/ts3.4/submodules/schema/schemas/sentinels.d.ts +21 -0
  106. package/dist-types/ts3.4/submodules/serde/copyDocumentWithTransform.d.ts +5 -0
  107. package/dist-types/ts3.4/submodules/serde/date-utils.d.ts +73 -0
  108. package/dist-types/ts3.4/submodules/serde/index.d.ts +7 -0
  109. package/dist-types/ts3.4/submodules/serde/lazy-json.d.ts +45 -0
  110. package/dist-types/ts3.4/submodules/serde/parse-utils.d.ts +270 -0
  111. package/dist-types/ts3.4/submodules/serde/quote-header.d.ts +6 -0
  112. package/dist-types/ts3.4/submodules/serde/split-every.d.ts +11 -0
  113. package/dist-types/ts3.4/submodules/serde/split-header.d.ts +5 -0
  114. package/package.json +18 -7
  115. package/schema.d.ts +7 -0
  116. package/schema.js +6 -0
@@ -0,0 +1,270 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Give an input string, strictly parses a boolean value.
5
+ *
6
+ * @param value - The boolean string to parse.
7
+ * @returns true for "true", false for "false", otherwise an error is thrown.
8
+ */
9
+ export declare const parseBoolean: (value: string) => boolean;
10
+ /**
11
+ * @internal
12
+ *
13
+ * Asserts a value is a boolean and returns it.
14
+ * Casts strings and numbers with a warning if there is evidence that they were
15
+ * intended to be booleans.
16
+ *
17
+ * @param value - A value that is expected to be a boolean.
18
+ * @returns The value if it's a boolean, undefined if it's null/undefined,
19
+ * otherwise an error is thrown.
20
+ */
21
+ export declare const expectBoolean: (value: any) => boolean | undefined;
22
+ /**
23
+ * @internal
24
+ *
25
+ * Asserts a value is a number and returns it.
26
+ * Casts strings with a warning if the string is a parseable number.
27
+ * This is to unblock slight API definition/implementation inconsistencies.
28
+ *
29
+ * @param value - A value that is expected to be a number.
30
+ * @returns The value if it's a number, undefined if it's null/undefined,
31
+ * otherwise an error is thrown.
32
+ */
33
+ export declare const expectNumber: (value: any) => number | undefined;
34
+ /**
35
+ * @internal
36
+ *
37
+ * Asserts a value is a 32-bit float and returns it.
38
+ *
39
+ * @param value - A value that is expected to be a 32-bit float.
40
+ * @returns The value if it's a float, undefined if it's null/undefined,
41
+ * otherwise an error is thrown.
42
+ */
43
+ export declare const expectFloat32: (value: any) => number | undefined;
44
+ /**
45
+ * @internal
46
+ *
47
+ * Asserts a value is an integer and returns it.
48
+ *
49
+ * @param value - A value that is expected to be an integer.
50
+ * @returns The value if it's an integer, undefined if it's null/undefined,
51
+ * otherwise an error is thrown.
52
+ */
53
+ export declare const expectLong: (value: any) => number | undefined;
54
+ /**
55
+ * @internal
56
+ *
57
+ * @deprecated Use expectLong
58
+ */
59
+ export declare const expectInt: (value: any) => number | undefined;
60
+ /**
61
+ * @internal
62
+ *
63
+ * Asserts a value is a 32-bit integer and returns it.
64
+ *
65
+ * @param value - A value that is expected to be an integer.
66
+ * @returns The value if it's an integer, undefined if it's null/undefined,
67
+ * otherwise an error is thrown.
68
+ */
69
+ export declare const expectInt32: (value: any) => number | undefined;
70
+ /**
71
+ * @internal
72
+ *
73
+ * Asserts a value is a 16-bit integer and returns it.
74
+ *
75
+ * @param value - A value that is expected to be an integer.
76
+ * @returns The value if it's an integer, undefined if it's null/undefined,
77
+ * otherwise an error is thrown.
78
+ */
79
+ export declare const expectShort: (value: any) => number | undefined;
80
+ /**
81
+ * @internal
82
+ *
83
+ * Asserts a value is an 8-bit integer and returns it.
84
+ *
85
+ * @param value - A value that is expected to be an integer.
86
+ * @returns The value if it's an integer, undefined if it's null/undefined,
87
+ * otherwise an error is thrown.
88
+ */
89
+ export declare const expectByte: (value: any) => number | undefined;
90
+ /**
91
+ * @internal
92
+ *
93
+ * Asserts a value is not null or undefined and returns it, or throws an error.
94
+ *
95
+ * @param value - A value that is expected to be defined
96
+ * @param location - The location where we're expecting to find a defined object (optional)
97
+ * @returns The value if it's not undefined, otherwise throws an error
98
+ */
99
+ export declare const expectNonNull: <T>(value: T | null | undefined, location?: string) => T;
100
+ /**
101
+ * @internal
102
+ *
103
+ * Asserts a value is an JSON-like object and returns it. This is expected to be used
104
+ * with values parsed from JSON (arrays, objects, numbers, strings, booleans).
105
+ *
106
+ * @param value - A value that is expected to be an object
107
+ * @returns The value if it's an object, undefined if it's null/undefined,
108
+ * otherwise an error is thrown.
109
+ */
110
+ export declare const expectObject: (value: any) => Record<string, any> | undefined;
111
+ /**
112
+ * @internal
113
+ *
114
+ * Asserts a value is a string and returns it.
115
+ * Numbers and boolean will be cast to strings with a warning.
116
+ *
117
+ * @param value - A value that is expected to be a string.
118
+ * @returns The value if it's a string, undefined if it's null/undefined,
119
+ * otherwise an error is thrown.
120
+ */
121
+ export declare const expectString: (value: any) => string | undefined;
122
+ /**
123
+ * @internal
124
+ *
125
+ * Asserts a value is a JSON-like object with only one non-null/non-undefined key and
126
+ * returns it.
127
+ *
128
+ * @param value - A value that is expected to be an object with exactly one non-null,
129
+ * non-undefined key.
130
+ * @returns the value if it's a union, undefined if it's null/undefined, otherwise
131
+ * an error is thrown.
132
+ */
133
+ export declare const expectUnion: (value: unknown) => Record<string, any> | undefined;
134
+ /**
135
+ * @internal
136
+ *
137
+ * Parses a value into a double. If the value is null or undefined, undefined
138
+ * will be returned. If the value is a string, it will be parsed by the standard
139
+ * parseFloat with one exception: NaN may only be explicitly set as the string
140
+ * "NaN", any implicit Nan values will result in an error being thrown. If any
141
+ * other type is provided, an exception will be thrown.
142
+ *
143
+ * @param value - A number or string representation of a double.
144
+ * @returns The value as a number, or undefined if it's null/undefined.
145
+ */
146
+ export declare const strictParseDouble: (value: string | number) => number | undefined;
147
+ /**
148
+ * @internal
149
+ *
150
+ * @deprecated Use strictParseDouble
151
+ */
152
+ export declare const strictParseFloat: (value: string | number) => number | undefined;
153
+ /**
154
+ * @internal
155
+ *
156
+ * Parses a value into a float. If the value is null or undefined, undefined
157
+ * will be returned. If the value is a string, it will be parsed by the standard
158
+ * parseFloat with one exception: NaN may only be explicitly set as the string
159
+ * "NaN", any implicit Nan values will result in an error being thrown. If any
160
+ * other type is provided, an exception will be thrown.
161
+ *
162
+ * @param value - A number or string representation of a float.
163
+ * @returns The value as a number, or undefined if it's null/undefined.
164
+ */
165
+ export declare const strictParseFloat32: (value: string | number) => number | undefined;
166
+ /**
167
+ * @internal
168
+ *
169
+ * Asserts a value is a number and returns it. If the value is a string
170
+ * representation of a non-numeric number type (NaN, Infinity, -Infinity),
171
+ * the value will be parsed. Any other string value will result in an exception
172
+ * being thrown. Null or undefined will be returned as undefined. Any other
173
+ * type will result in an exception being thrown.
174
+ *
175
+ * @param value - A number or string representation of a non-numeric float.
176
+ * @returns The value as a number, or undefined if it's null/undefined.
177
+ */
178
+ export declare const limitedParseDouble: (value: string | number) => number | undefined;
179
+ /**
180
+ * @internal
181
+ *
182
+ * @deprecated Use limitedParseDouble
183
+ */
184
+ export declare const handleFloat: (value: string | number) => number | undefined;
185
+ /**
186
+ * @internal
187
+ *
188
+ * @deprecated Use limitedParseDouble
189
+ */
190
+ export declare const limitedParseFloat: (value: string | number) => number | undefined;
191
+ /**
192
+ * @internal
193
+ *
194
+ * Asserts a value is a 32-bit float and returns it. If the value is a string
195
+ * representation of a non-numeric number type (NaN, Infinity, -Infinity),
196
+ * the value will be parsed. Any other string value will result in an exception
197
+ * being thrown. Null or undefined will be returned as undefined. Any other
198
+ * type will result in an exception being thrown.
199
+ *
200
+ * @param value - A number or string representation of a non-numeric float.
201
+ * @returns The value as a number, or undefined if it's null/undefined.
202
+ */
203
+ export declare const limitedParseFloat32: (value: string | number) => number | undefined;
204
+ /**
205
+ * @internal
206
+ *
207
+ * Parses a value into an integer. If the value is null or undefined, undefined
208
+ * will be returned. If the value is a string, it will be parsed by parseFloat
209
+ * and the result will be asserted to be an integer. If the parsed value is not
210
+ * an integer, or the raw value is any type other than a string or number, an
211
+ * exception will be thrown.
212
+ *
213
+ * @param value - A number or string representation of an integer.
214
+ * @returns The value as a number, or undefined if it's null/undefined.
215
+ */
216
+ export declare const strictParseLong: (value: string | number) => number | undefined;
217
+ /**
218
+ * @internal
219
+ *
220
+ * @deprecated Use strictParseLong
221
+ */
222
+ export declare const strictParseInt: (value: string | number) => number | undefined;
223
+ /**
224
+ * @internal
225
+ *
226
+ * Parses a value into a 32-bit integer. If the value is null or undefined, undefined
227
+ * will be returned. If the value is a string, it will be parsed by parseFloat
228
+ * and the result will be asserted to be an integer. If the parsed value is not
229
+ * an integer, or the raw value is any type other than a string or number, an
230
+ * exception will be thrown.
231
+ *
232
+ * @param value - A number or string representation of a 32-bit integer.
233
+ * @returns The value as a number, or undefined if it's null/undefined.
234
+ */
235
+ export declare const strictParseInt32: (value: string | number) => number | undefined;
236
+ /**
237
+ * @internal
238
+ *
239
+ * Parses a value into a 16-bit integer. If the value is null or undefined, undefined
240
+ * will be returned. If the value is a string, it will be parsed by parseFloat
241
+ * and the result will be asserted to be an integer. If the parsed value is not
242
+ * an integer, or the raw value is any type other than a string or number, an
243
+ * exception will be thrown.
244
+ *
245
+ * @param value - A number or string representation of a 16-bit integer.
246
+ * @returns The value as a number, or undefined if it's null/undefined.
247
+ */
248
+ export declare const strictParseShort: (value: string | number) => number | undefined;
249
+ /**
250
+ * @internal
251
+ *
252
+ * Parses a value into an 8-bit integer. If the value is null or undefined, undefined
253
+ * will be returned. If the value is a string, it will be parsed by parseFloat
254
+ * and the result will be asserted to be an integer. If the parsed value is not
255
+ * an integer, or the raw value is any type other than a string or number, an
256
+ * exception will be thrown.
257
+ *
258
+ * @param value - A number or string representation of an 8-bit integer.
259
+ * @returns The value as a number, or undefined if it's null/undefined.
260
+ */
261
+ export declare const strictParseByte: (value: string | number) => number | undefined;
262
+ /**
263
+ * @internal
264
+ */
265
+ export declare const logger: {
266
+ warn: {
267
+ (...data: any[]): void;
268
+ (message?: any, ...optionalParams: any[]): void;
269
+ };
270
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @public
3
+ * @param part - header list element
4
+ * @returns quoted string if part contains delimiter.
5
+ */
6
+ export declare function quoteHeader(part: string): string;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Given an input string, splits based on the delimiter after a given
5
+ * number of delimiters has been encountered.
6
+ *
7
+ * @param value - The input string to split.
8
+ * @param delimiter - The delimiter to split on.
9
+ * @param numDelimiters - The number of delimiters to have encountered to split.
10
+ */
11
+ export declare function splitEvery(value: string, delimiter: string, numDelimiters: number): Array<string>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @param value - header string value.
3
+ * @returns value split by commas that aren't in quotes.
4
+ */
5
+ export declare const splitHeader: (value: string) => string[];
@@ -0,0 +1,29 @@
1
+ import { Codec, Schema, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
2
+ /**
3
+ * @alpha
4
+ */
5
+ export declare class CborCodec implements Codec<Uint8Array, Uint8Array> {
6
+ private serdeContext?;
7
+ createSerializer(): CborShapeSerializer;
8
+ createDeserializer(): CborShapeDeserializer;
9
+ setSerdeContext(serdeContext: SerdeFunctions): void;
10
+ }
11
+ /**
12
+ * @alpha
13
+ */
14
+ export declare class CborShapeSerializer implements ShapeSerializer {
15
+ private serdeContext?;
16
+ private value;
17
+ setSerdeContext(serdeContext: SerdeFunctions): void;
18
+ write(schema: Schema, value: unknown): void;
19
+ flush(): Uint8Array;
20
+ }
21
+ /**
22
+ * @alpha
23
+ */
24
+ export declare class CborShapeDeserializer implements ShapeDeserializer {
25
+ private serdeContext?;
26
+ setSerdeContext(serdeContext: SerdeFunctions): void;
27
+ read(schema: Schema, bytes: Uint8Array): any;
28
+ private readValue;
29
+ }
@@ -0,0 +1,22 @@
1
+ import { RpcProtocol } from "@smithy/core/protocols";
2
+ import { OperationSchema } from "@smithy/core/schema";
3
+ import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, ResponseMetadata, SerdeFunctions } from "@smithy/types";
4
+ import { CborCodec } from "./CborCodec";
5
+ /**
6
+ * Client protocol for Smithy RPCv2 CBOR.
7
+ *
8
+ * @alpha
9
+ */
10
+ export declare class SmithyRpcV2CborProtocol extends RpcProtocol {
11
+ private codec;
12
+ protected serializer: import("./CborCodec").CborShapeSerializer;
13
+ protected deserializer: import("./CborCodec").CborShapeDeserializer;
14
+ constructor({ defaultNamespace }: {
15
+ defaultNamespace: string;
16
+ });
17
+ getShapeId(): string;
18
+ getPayloadCodec(): CborCodec;
19
+ serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
20
+ deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
21
+ protected handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
22
+ }
@@ -1,3 +1,5 @@
1
1
  export { cbor } from "./cbor";
2
+ export { tag, tagSymbol } from "./cbor-types";
2
3
  export * from "./parseCborBody";
3
- export { tagSymbol, tag } from "./cbor-types";
4
+ export * from "./SmithyRpcV2CborProtocol";
5
+ export * from "./CborCodec";
@@ -0,0 +1,15 @@
1
+ import { NormalizedSchema } from "@smithy/core/schema";
2
+ import { HttpRequest } from "@smithy/protocol-http";
3
+ import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, SerdeFunctions } from "@smithy/types";
4
+ import { HttpProtocol } from "./HttpProtocol";
5
+ /**
6
+ * Base for HTTP-binding protocols. Downstream examples
7
+ * include AWS REST JSON and AWS REST XML.
8
+ *
9
+ * @alpha
10
+ */
11
+ export declare abstract class HttpBindingProtocol extends HttpProtocol {
12
+ serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
13
+ protected serializeQuery(ns: NormalizedSchema, data: any, query: HttpRequest["query"]): void;
14
+ deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
15
+ }
@@ -0,0 +1,29 @@
1
+ import { ClientProtocol, Codec, Endpoint, EndpointBearer, EndpointV2, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, Schema, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
2
+ /**
3
+ * Abstract base for HTTP-based client protocols.
4
+ *
5
+ * @alpha
6
+ */
7
+ export declare abstract class HttpProtocol implements ClientProtocol<IHttpRequest, IHttpResponse> {
8
+ readonly options: {
9
+ defaultNamespace: string;
10
+ };
11
+ protected abstract serializer: ShapeSerializer<string | Uint8Array>;
12
+ protected abstract deserializer: ShapeDeserializer<string | Uint8Array>;
13
+ protected serdeContext?: SerdeFunctions;
14
+ protected constructor(options: {
15
+ defaultNamespace: string;
16
+ });
17
+ abstract getShapeId(): string;
18
+ abstract getPayloadCodec(): Codec<any, any>;
19
+ getRequestType(): new (...args: any[]) => IHttpRequest;
20
+ getResponseType(): new (...args: any[]) => IHttpResponse;
21
+ setSerdeContext(serdeContext: SerdeFunctions): void;
22
+ abstract serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
23
+ updateServiceEndpoint(request: IHttpRequest, endpoint: EndpointV2 | Endpoint): IHttpRequest;
24
+ abstract deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
25
+ protected setHostPrefix<Input extends object>(request: IHttpRequest, operationSchema: OperationSchema, input: Input): void;
26
+ protected abstract handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
27
+ protected deserializeMetadata(output: IHttpResponse): ResponseMetadata;
28
+ protected deserializeHttpMessage(schema: Schema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, headerBindings: Set<string>, dataObject: any): Promise<string[]>;
29
+ }
@@ -0,0 +1,11 @@
1
+ import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, SerdeFunctions } from "@smithy/types";
2
+ import { HttpProtocol } from "./HttpProtocol";
3
+ /**
4
+ * Abstract base for RPC-over-HTTP protocols.
5
+ *
6
+ * @alpha
7
+ */
8
+ export declare abstract class RpcProtocol extends HttpProtocol {
9
+ serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
10
+ deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
11
+ }
@@ -1,4 +1,11 @@
1
1
  export * from "./collect-stream-body";
2
2
  export * from "./extended-encode-uri-component";
3
+ export * from "./HttpBindingProtocol";
4
+ export * from "./RpcProtocol";
3
5
  export * from "./requestBuilder";
4
6
  export * from "./resolve-path";
7
+ export * from "./serde/FromStringShapeDeserializer";
8
+ export * from "./serde/HttpInterceptingShapeDeserializer";
9
+ export * from "./serde/HttpInterceptingShapeSerializer";
10
+ export * from "./serde/ToStringShapeSerializer";
11
+ export * from "./serde/determineTimestampFormat";
@@ -0,0 +1,14 @@
1
+ import { CodecSettings, Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
2
+ /**
3
+ * This deserializer reads strings.
4
+ *
5
+ * @alpha
6
+ */
7
+ export declare class FromStringShapeDeserializer implements ShapeDeserializer<string> {
8
+ private settings;
9
+ private serdeContext;
10
+ constructor(settings: CodecSettings);
11
+ setSerdeContext(serdeContext: SerdeFunctions): void;
12
+ read(_schema: Schema, data: string): any;
13
+ private base64ToUtf8;
14
+ }
@@ -0,0 +1,18 @@
1
+ import { CodecSettings, Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
2
+ /**
3
+ * This deserializer is a dispatcher that decides whether to use a string deserializer
4
+ * or a codec deserializer based on HTTP traits.
5
+ *
6
+ * For example, in a JSON HTTP message, the deserialization of a field will differ depending on whether
7
+ * it is bound to the HTTP header (string) or body (JSON).
8
+ *
9
+ * @alpha
10
+ */
11
+ export declare class HttpInterceptingShapeDeserializer<CodecShapeDeserializer extends ShapeDeserializer<any>> implements ShapeDeserializer<string | Uint8Array> {
12
+ private codecDeserializer;
13
+ private stringDeserializer;
14
+ private serdeContext;
15
+ constructor(codecDeserializer: CodecShapeDeserializer, codecSettings: CodecSettings);
16
+ setSerdeContext(serdeContext: SerdeFunctions): void;
17
+ read(schema: Schema, data: string | Uint8Array): any | Promise<any>;
18
+ }
@@ -0,0 +1,20 @@
1
+ import { CodecSettings, Schema as ISchema, SerdeFunctions, ShapeSerializer } from "@smithy/types";
2
+ import { ToStringShapeSerializer } from "./ToStringShapeSerializer";
3
+ /**
4
+ * This serializer decides whether to dispatch to a string serializer or a codec serializer
5
+ * depending on HTTP binding traits within the given schema.
6
+ *
7
+ * For example, a JavaScript array is serialized differently when being written
8
+ * to a REST JSON HTTP header (comma-delimited string) and a REST JSON HTTP body (JSON array).
9
+ *
10
+ * @alpha
11
+ */
12
+ export declare class HttpInterceptingShapeSerializer<CodecShapeSerializer extends ShapeSerializer<string | Uint8Array>> implements ShapeSerializer<string | Uint8Array> {
13
+ private codecSerializer;
14
+ private stringSerializer;
15
+ private buffer;
16
+ constructor(codecSerializer: CodecShapeSerializer, codecSettings: CodecSettings, stringSerializer?: ToStringShapeSerializer);
17
+ setSerdeContext(serdeContext: SerdeFunctions): void;
18
+ write(schema: ISchema, value: unknown): void;
19
+ flush(): string | Uint8Array;
20
+ }
@@ -0,0 +1,15 @@
1
+ import { CodecSettings, Schema, SerdeFunctions, ShapeSerializer } from "@smithy/types";
2
+ /**
3
+ * Serializes a shape to string.
4
+ *
5
+ * @alpha
6
+ */
7
+ export declare class ToStringShapeSerializer implements ShapeSerializer<string> {
8
+ private settings;
9
+ private stringBuffer;
10
+ private serdeContext;
11
+ constructor(settings: CodecSettings);
12
+ setSerdeContext(serdeContext: SerdeFunctions): void;
13
+ write(schema: Schema, value: unknown): void;
14
+ flush(): string;
15
+ }
@@ -0,0 +1,9 @@
1
+ import { NormalizedSchema } from "@smithy/core/schema";
2
+ import { TimestampDateTimeSchema, TimestampEpochSecondsSchema, TimestampHttpDateSchema, CodecSettings } from "@smithy/types";
3
+ /**
4
+ * Assuming the schema is a timestamp type, the function resolves the format using
5
+ * either the timestamp's own traits, or the default timestamp format from the CodecSettings.
6
+ *
7
+ * @internal
8
+ */
9
+ export declare function determineTimestampFormat(ns: NormalizedSchema, settings: CodecSettings): TimestampDateTimeSchema | TimestampHttpDateSchema | TimestampEpochSecondsSchema;
@@ -0,0 +1,55 @@
1
+ import { Schema as ISchema } from "@smithy/types";
2
+ import { ErrorSchema } from "./schemas/ErrorSchema";
3
+ /**
4
+ * A way to look up schema by their ShapeId values.
5
+ *
6
+ * @alpha
7
+ */
8
+ export declare class TypeRegistry {
9
+ readonly namespace: string;
10
+ private schemas;
11
+ static readonly registries: Map<string, TypeRegistry>;
12
+ private constructor();
13
+ /**
14
+ * @param namespace - specifier.
15
+ * @returns the schema for that namespace, creating it if necessary.
16
+ */
17
+ static for(namespace: string): TypeRegistry;
18
+ /**
19
+ * Adds the given schema to a type registry with the same namespace.
20
+ *
21
+ * @param shapeId - to be registered.
22
+ * @param schema - to be registered.
23
+ */
24
+ register(shapeId: string, schema: ISchema): void;
25
+ /**
26
+ * @param shapeId - query.
27
+ * @returns the schema.
28
+ */
29
+ getSchema(shapeId: string): ISchema;
30
+ /**
31
+ * The smithy-typescript code generator generates a synthetic (i.e. unmodeled) base exception,
32
+ * because generated SDKs before the introduction of schemas have the notion of a ServiceBaseException, which
33
+ * is unique per service/model.
34
+ *
35
+ * This is generated under a unique prefix that is combined with the service namespace, and this
36
+ * method is used to retrieve it.
37
+ *
38
+ * The base exception synthetic schema is used when an error is returned by a service, but we cannot
39
+ * determine what existing schema to use to deserialize it.
40
+ *
41
+ * @returns the synthetic base exception of the service namespace associated with this registry instance.
42
+ */
43
+ getBaseException(): ErrorSchema | undefined;
44
+ /**
45
+ * @param predicate - criterion.
46
+ * @returns a schema in this registry matching the predicate.
47
+ */
48
+ find(predicate: (schema: ISchema) => boolean): ISchema | undefined;
49
+ /**
50
+ * Unloads the current TypeRegistry.
51
+ */
52
+ destroy(): void;
53
+ private normalizeShapeId;
54
+ private getNamespace;
55
+ }
@@ -0,0 +1,6 @@
1
+ import { Schema, SchemaRef } from "@smithy/types";
2
+ /**
3
+ * Dereferences a SchemaRef if needed.
4
+ * @internal
5
+ */
6
+ export declare const deref: (schemaRef: SchemaRef) => Schema;
@@ -0,0 +1,12 @@
1
+ export * from "./deref";
2
+ export * from "./middleware/getSchemaSerdePlugin";
3
+ export * from "./schemas/ListSchema";
4
+ export * from "./schemas/MapSchema";
5
+ export * from "./schemas/OperationSchema";
6
+ export * from "./schemas/ErrorSchema";
7
+ export * from "./schemas/NormalizedSchema";
8
+ export * from "./schemas/Schema";
9
+ export * from "./schemas/SimpleSchema";
10
+ export * from "./schemas/StructureSchema";
11
+ export * from "./schemas/sentinels";
12
+ export * from "./TypeRegistry";
@@ -0,0 +1,14 @@
1
+ import { DeserializeHandlerOptions, MetadataBearer, Pluggable, SerializeHandlerOptions } from "@smithy/types";
2
+ import { PreviouslyResolved } from "./schema-middleware-types";
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare const deserializerMiddlewareOption: DeserializeHandlerOptions;
7
+ /**
8
+ * @internal
9
+ */
10
+ export declare const serializerMiddlewareOption: SerializeHandlerOptions;
11
+ /**
12
+ * @internal
13
+ */
14
+ export declare function getSchemaSerdePlugin<InputType extends object = any, OutputType extends MetadataBearer = any>(config: PreviouslyResolved): Pluggable<InputType, OutputType>;
@@ -0,0 +1,11 @@
1
+ import { ClientProtocol, SerdeContext, UrlParser } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export type PreviouslyResolved = Pick<SerdeContext & {
6
+ urlParser: UrlParser;
7
+ protocol: ClientProtocol<any, any>;
8
+ }, Exclude<keyof (SerdeContext & {
9
+ urlParser: UrlParser;
10
+ protocol: ClientProtocol<any, any>;
11
+ }), "endpoint">>;
@@ -0,0 +1,9 @@
1
+ import { DeserializeHandler, DeserializeHandlerArguments, HandlerExecutionContext } from "@smithy/types";
2
+ import { PreviouslyResolved } from "./schema-middleware-types";
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare const schemaDeserializationMiddleware: <O>(config: PreviouslyResolved) => (next: DeserializeHandler<any, any>, context: HandlerExecutionContext) => (args: DeserializeHandlerArguments<any>) => Promise<{
7
+ response: unknown;
8
+ output: O;
9
+ }>;
@@ -0,0 +1,6 @@
1
+ import { HandlerExecutionContext, SerializeHandler, SerializeHandlerArguments } from "@smithy/types";
2
+ import { PreviouslyResolved } from "./schema-middleware-types";
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare const schemaSerializationMiddleware: (config: PreviouslyResolved) => (next: SerializeHandler<any, any>, context: HandlerExecutionContext) => (args: SerializeHandlerArguments<any>) => Promise<import("@smithy/types").SerializeHandlerOutput<any>>;