@smithy/core 3.24.0 → 3.24.1

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 (60) hide show
  1. package/dist-cjs/submodules/schema/index.js +12 -0
  2. package/dist-cjs/submodules/serde/index.browser.js +37 -36
  3. package/dist-cjs/submodules/serde/index.js +39 -37
  4. package/dist-cjs/submodules/serde/index.native.js +37 -36
  5. package/dist-es/submodules/schema/TypeRegistry.js +12 -0
  6. package/dist-es/submodules/serde/index.browser.js +4 -2
  7. package/dist-es/submodules/serde/index.js +5 -2
  8. package/dist-es/submodules/serde/index.native.js +4 -2
  9. package/dist-es/submodules/serde/uuid/v4.js +30 -29
  10. package/dist-types/pagination/createPaginator.d.ts +2 -2
  11. package/dist-types/request-builder/requestBuilder.d.ts +2 -1
  12. package/dist-types/setFeature.d.ts +3 -3
  13. package/dist-types/submodules/cbor/cbor-decode.d.ts +4 -3
  14. package/dist-types/submodules/cbor/cbor-types.d.ts +4 -4
  15. package/dist-types/submodules/cbor/cbor.d.ts +3 -4
  16. package/dist-types/submodules/checksum/chunked-blob-reader/chunked-blob-reader.d.ts +2 -1
  17. package/dist-types/submodules/client/smithy-client/client.d.ts +2 -5
  18. package/dist-types/submodules/client/smithy-client/default-error-handler.d.ts +2 -2
  19. package/dist-types/submodules/client/smithy-client/emitWarningIfUnsupportedVersion.d.ts +1 -2
  20. package/dist-types/submodules/client/smithy-client/exceptions.d.ts +2 -2
  21. package/dist-types/submodules/client/smithy-client/extensions/defaultExtensionConfiguration.d.ts +7 -7
  22. package/dist-types/submodules/client/smithy-client/get-array-if-single-item.d.ts +2 -2
  23. package/dist-types/submodules/client/smithy-client/get-value-from-text-node.d.ts +2 -2
  24. package/dist-types/submodules/client/smithy-client/object-mapping.d.ts +22 -21
  25. package/dist-types/submodules/client/smithy-client/ser-utils.d.ts +1 -2
  26. package/dist-types/submodules/client/smithy-client/serde-json.d.ts +1 -3
  27. package/dist-types/submodules/client/util-waiter/utils/validate.d.ts +2 -2
  28. package/dist-types/submodules/config/config-resolver/endpointsConfig/resolveEndpointsConfig.d.ts +2 -2
  29. package/dist-types/submodules/config/property-provider/CredentialsProviderError.d.ts +2 -3
  30. package/dist-types/submodules/config/property-provider/ProviderError.d.ts +2 -3
  31. package/dist-types/submodules/config/property-provider/TokenProviderError.d.ts +2 -3
  32. package/dist-types/submodules/config/property-provider/chain.d.ts +2 -3
  33. package/dist-types/submodules/config/shared-ini-file-loader/getSSOTokenFromFile.d.ts +2 -1
  34. package/dist-types/submodules/endpoints/middleware-endpoint/resolveEndpointConfig.d.ts +6 -5
  35. package/dist-types/submodules/endpoints/util-endpoints/cache/EndpointCache.d.ts +2 -2
  36. package/dist-types/submodules/endpoints/util-endpoints/getEndpointUrlConfig.d.ts +2 -1
  37. package/dist-types/submodules/protocols/collect-stream-body.d.ts +2 -2
  38. package/dist-types/submodules/protocols/extended-encode-uri-component.d.ts +2 -2
  39. package/dist-types/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +4 -4
  40. package/dist-types/submodules/protocols/protocol-http/httpHandler.d.ts +2 -5
  41. package/dist-types/submodules/protocols/requestBuilder.d.ts +2 -1
  42. package/dist-types/submodules/retry/util-retry/constants.d.ts +4 -4
  43. package/dist-types/submodules/serde/date-utils.d.ts +7 -19
  44. package/dist-types/submodules/serde/index.browser.d.ts +2 -2
  45. package/dist-types/submodules/serde/index.d.ts +2 -2
  46. package/dist-types/submodules/serde/index.native.d.ts +2 -2
  47. package/dist-types/submodules/serde/lazy-json.d.ts +4 -6
  48. package/dist-types/submodules/serde/parse-utils.d.ts +31 -51
  49. package/dist-types/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +3 -12
  50. package/dist-types/submodules/serde/split-every.d.ts +1 -2
  51. package/dist-types/submodules/serde/util-stream/createBufferedReadable.browser.d.ts +2 -1
  52. package/dist-types/submodules/serde/util-stream/createBufferedReadable.d.ts +2 -1
  53. package/dist-types/submodules/serde/util-stream/stream-collector.browser.d.ts +2 -1
  54. package/dist-types/submodules/serde/uuid/v4.d.ts +12 -7
  55. package/dist-types/util-identity-and-auth/memoizeIdentityProvider.d.ts +2 -1
  56. package/package.json +1 -1
  57. package/dist-es/submodules/serde/generateIdempotencyToken.js +0 -2
  58. package/dist-es/submodules/serde/uuid/randomUUID.js +0 -3
  59. package/dist-types/submodules/serde/generateIdempotencyToken.d.ts +0 -2
  60. package/dist-types/submodules/serde/uuid/randomUUID.d.ts +0 -1
@@ -1,54 +1,49 @@
1
1
  /**
2
- * @internal
3
- *
4
2
  * Give an input string, strictly parses a boolean value.
5
3
  *
4
+ * @internal
6
5
  * @param value - The boolean string to parse.
7
6
  * @returns true for "true", false for "false", otherwise an error is thrown.
8
7
  */
9
8
  export declare const parseBoolean: (value: string) => boolean;
10
9
  /**
11
- * @internal
12
- *
13
10
  * Asserts a value is a boolean and returns it.
14
11
  * Casts strings and numbers with a warning if there is evidence that they were
15
12
  * intended to be booleans.
13
+ * otherwise an error is thrown.
16
14
  *
15
+ * @internal
17
16
  * @param value - A value that is expected to be a boolean.
18
17
  * @returns The value if it's a boolean, undefined if it's null/undefined,
19
- * otherwise an error is thrown.
20
18
  */
21
19
  export declare const expectBoolean: (value: any) => boolean | undefined;
22
20
  /**
23
- * @internal
24
- *
25
21
  * Asserts a value is a number and returns it.
26
22
  * Casts strings with a warning if the string is a parseable number.
27
23
  * This is to unblock slight API definition/implementation inconsistencies.
24
+ * otherwise an error is thrown.
28
25
  *
26
+ * @internal
29
27
  * @param value - A value that is expected to be a number.
30
28
  * @returns The value if it's a number, undefined if it's null/undefined,
31
- * otherwise an error is thrown.
32
29
  */
33
30
  export declare const expectNumber: (value: any) => number | undefined;
34
31
  /**
35
- * @internal
36
- *
37
32
  * Asserts a value is a 32-bit float and returns it.
33
+ * otherwise an error is thrown.
38
34
  *
35
+ * @internal
39
36
  * @param value - A value that is expected to be a 32-bit float.
40
37
  * @returns The value if it's a float, undefined if it's null/undefined,
41
- * otherwise an error is thrown.
42
38
  */
43
39
  export declare const expectFloat32: (value: any) => number | undefined;
44
40
  /**
45
- * @internal
46
- *
47
41
  * Asserts a value is an integer and returns it.
42
+ * otherwise an error is thrown.
48
43
  *
44
+ * @internal
49
45
  * @param value - A value that is expected to be an integer.
50
46
  * @returns The value if it's an integer, undefined if it's null/undefined,
51
- * otherwise an error is thrown.
52
47
  */
53
48
  export declare const expectLong: (value: any) => number | undefined;
54
49
  /**
@@ -58,88 +53,80 @@ export declare const expectLong: (value: any) => number | undefined;
58
53
  */
59
54
  export declare const expectInt: (value: any) => number | undefined;
60
55
  /**
61
- * @internal
62
- *
63
56
  * Asserts a value is a 32-bit integer and returns it.
57
+ * otherwise an error is thrown.
64
58
  *
59
+ * @internal
65
60
  * @param value - A value that is expected to be an integer.
66
61
  * @returns The value if it's an integer, undefined if it's null/undefined,
67
- * otherwise an error is thrown.
68
62
  */
69
63
  export declare const expectInt32: (value: any) => number | undefined;
70
64
  /**
71
- * @internal
72
- *
73
65
  * Asserts a value is a 16-bit integer and returns it.
66
+ * otherwise an error is thrown.
74
67
  *
68
+ * @internal
75
69
  * @param value - A value that is expected to be an integer.
76
70
  * @returns The value if it's an integer, undefined if it's null/undefined,
77
- * otherwise an error is thrown.
78
71
  */
79
72
  export declare const expectShort: (value: any) => number | undefined;
80
73
  /**
81
- * @internal
82
- *
83
74
  * Asserts a value is an 8-bit integer and returns it.
75
+ * otherwise an error is thrown.
84
76
  *
77
+ * @internal
85
78
  * @param value - A value that is expected to be an integer.
86
79
  * @returns The value if it's an integer, undefined if it's null/undefined,
87
- * otherwise an error is thrown.
88
80
  */
89
81
  export declare const expectByte: (value: any) => number | undefined;
90
82
  /**
91
- * @internal
92
- *
93
83
  * Asserts a value is not null or undefined and returns it, or throws an error.
94
84
  *
85
+ * @internal
95
86
  * @param value - A value that is expected to be defined
96
87
  * @param location - The location where we're expecting to find a defined object (optional)
97
88
  * @returns The value if it's not undefined, otherwise throws an error
98
89
  */
99
90
  export declare const expectNonNull: <T>(value: T | null | undefined, location?: string) => T;
100
91
  /**
101
- * @internal
102
- *
103
92
  * Asserts a value is an JSON-like object and returns it. This is expected to be used
104
93
  * with values parsed from JSON (arrays, objects, numbers, strings, booleans).
94
+ * otherwise an error is thrown.
105
95
  *
96
+ * @internal
106
97
  * @param value - A value that is expected to be an object
107
98
  * @returns The value if it's an object, undefined if it's null/undefined,
108
- * otherwise an error is thrown.
109
99
  */
110
100
  export declare const expectObject: (value: any) => Record<string, any> | undefined;
111
101
  /**
112
- * @internal
113
- *
114
102
  * Asserts a value is a string and returns it.
115
103
  * Numbers and boolean will be cast to strings with a warning.
104
+ * otherwise an error is thrown.
116
105
  *
106
+ * @internal
117
107
  * @param value - A value that is expected to be a string.
118
108
  * @returns The value if it's a string, undefined if it's null/undefined,
119
- * otherwise an error is thrown.
120
109
  */
121
110
  export declare const expectString: (value: any) => string | undefined;
122
111
  /**
123
- * @internal
124
- *
125
112
  * Asserts a value is a JSON-like object with only one non-null/non-undefined key and
126
113
  * returns it.
114
+ * non-undefined key.
115
+ * an error is thrown.
127
116
  *
117
+ * @internal
128
118
  * @param value - A value that is expected to be an object with exactly one non-null,
129
- * non-undefined key.
130
119
  * @returns the value if it's a union, undefined if it's null/undefined, otherwise
131
- * an error is thrown.
132
120
  */
133
121
  export declare const expectUnion: (value: unknown) => Record<string, any> | undefined;
134
122
  /**
135
- * @internal
136
- *
137
123
  * Parses a value into a double. If the value is null or undefined, undefined
138
124
  * will be returned. If the value is a string, it will be parsed by the standard
139
125
  * parseFloat with one exception: NaN may only be explicitly set as the string
140
126
  * "NaN", any implicit Nan values will result in an error being thrown. If any
141
127
  * other type is provided, an exception will be thrown.
142
128
  *
129
+ * @internal
143
130
  * @param value - A number or string representation of a double.
144
131
  * @returns The value as a number, or undefined if it's null/undefined.
145
132
  */
@@ -151,27 +138,25 @@ export declare const strictParseDouble: (value: string | number) => number | und
151
138
  */
152
139
  export declare const strictParseFloat: (value: string | number) => number | undefined;
153
140
  /**
154
- * @internal
155
- *
156
141
  * Parses a value into a float. If the value is null or undefined, undefined
157
142
  * will be returned. If the value is a string, it will be parsed by the standard
158
143
  * parseFloat with one exception: NaN may only be explicitly set as the string
159
144
  * "NaN", any implicit Nan values will result in an error being thrown. If any
160
145
  * other type is provided, an exception will be thrown.
161
146
  *
147
+ * @internal
162
148
  * @param value - A number or string representation of a float.
163
149
  * @returns The value as a number, or undefined if it's null/undefined.
164
150
  */
165
151
  export declare const strictParseFloat32: (value: string | number) => number | undefined;
166
152
  /**
167
- * @internal
168
- *
169
153
  * Asserts a value is a number and returns it. If the value is a string
170
154
  * representation of a non-numeric number type (NaN, Infinity, -Infinity),
171
155
  * the value will be parsed. Any other string value will result in an exception
172
156
  * being thrown. Null or undefined will be returned as undefined. Any other
173
157
  * type will result in an exception being thrown.
174
158
  *
159
+ * @internal
175
160
  * @param value - A number or string representation of a non-numeric float.
176
161
  * @returns The value as a number, or undefined if it's null/undefined.
177
162
  */
@@ -189,27 +174,25 @@ export declare const handleFloat: (value: string | number) => number | undefined
189
174
  */
190
175
  export declare const limitedParseFloat: (value: string | number) => number | undefined;
191
176
  /**
192
- * @internal
193
- *
194
177
  * Asserts a value is a 32-bit float and returns it. If the value is a string
195
178
  * representation of a non-numeric number type (NaN, Infinity, -Infinity),
196
179
  * the value will be parsed. Any other string value will result in an exception
197
180
  * being thrown. Null or undefined will be returned as undefined. Any other
198
181
  * type will result in an exception being thrown.
199
182
  *
183
+ * @internal
200
184
  * @param value - A number or string representation of a non-numeric float.
201
185
  * @returns The value as a number, or undefined if it's null/undefined.
202
186
  */
203
187
  export declare const limitedParseFloat32: (value: string | number) => number | undefined;
204
188
  /**
205
- * @internal
206
- *
207
189
  * Parses a value into an integer. If the value is null or undefined, undefined
208
190
  * will be returned. If the value is a string, it will be parsed by parseFloat
209
191
  * and the result will be asserted to be an integer. If the parsed value is not
210
192
  * an integer, or the raw value is any type other than a string or number, an
211
193
  * exception will be thrown.
212
194
  *
195
+ * @internal
213
196
  * @param value - A number or string representation of an integer.
214
197
  * @returns The value as a number, or undefined if it's null/undefined.
215
198
  */
@@ -221,40 +204,37 @@ export declare const strictParseLong: (value: string | number) => number | undef
221
204
  */
222
205
  export declare const strictParseInt: (value: string | number) => number | undefined;
223
206
  /**
224
- * @internal
225
- *
226
207
  * Parses a value into a 32-bit integer. If the value is null or undefined, undefined
227
208
  * will be returned. If the value is a string, it will be parsed by parseFloat
228
209
  * and the result will be asserted to be an integer. If the parsed value is not
229
210
  * an integer, or the raw value is any type other than a string or number, an
230
211
  * exception will be thrown.
231
212
  *
213
+ * @internal
232
214
  * @param value - A number or string representation of a 32-bit integer.
233
215
  * @returns The value as a number, or undefined if it's null/undefined.
234
216
  */
235
217
  export declare const strictParseInt32: (value: string | number) => number | undefined;
236
218
  /**
237
- * @internal
238
- *
239
219
  * Parses a value into a 16-bit integer. If the value is null or undefined, undefined
240
220
  * will be returned. If the value is a string, it will be parsed by parseFloat
241
221
  * and the result will be asserted to be an integer. If the parsed value is not
242
222
  * an integer, or the raw value is any type other than a string or number, an
243
223
  * exception will be thrown.
244
224
  *
225
+ * @internal
245
226
  * @param value - A number or string representation of a 16-bit integer.
246
227
  * @returns The value as a number, or undefined if it's null/undefined.
247
228
  */
248
229
  export declare const strictParseShort: (value: string | number) => number | undefined;
249
230
  /**
250
- * @internal
251
- *
252
231
  * Parses a value into an 8-bit integer. If the value is null or undefined, undefined
253
232
  * will be returned. If the value is a string, it will be parsed by parseFloat
254
233
  * and the result will be asserted to be an integer. If the parsed value is not
255
234
  * an integer, or the raw value is any type other than a string or number, an
256
235
  * exception will be thrown.
257
236
  *
237
+ * @internal
258
238
  * @param value - A number or string representation of an 8-bit integer.
259
239
  * @returns The value as a number, or undefined if it's null/undefined.
260
240
  */
@@ -1,46 +1,37 @@
1
1
  /**
2
- * @internal
3
- *
4
2
  * Parses a value into a Date. Returns undefined if the input is null or
5
3
  * undefined, throws an error if the input is not a number or a parseable string.
6
- *
7
4
  * Input strings must be an integer or floating point number. Fractional seconds are supported.
8
5
  *
6
+ * @internal
9
7
  * @param value - the value to parse
10
8
  * @returns a Date or undefined
11
9
  */
12
10
  export declare const _parseEpochTimestamp: (value: unknown) => Date | undefined;
13
11
  /**
14
- * @internal
15
- *
16
12
  * Parses a value into a Date. Returns undefined if the input is null or
17
13
  * undefined, throws an error if the input is not a string that can be parsed
18
14
  * as an RFC 3339 date.
19
- *
20
15
  * Input strings must conform to RFC3339 section 5.6, and can have a UTC
21
16
  * offset. Fractional precision is supported.
22
17
  *
18
+ * @internal
23
19
  * @see {@link https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14}
24
- *
25
20
  * @param value - the value to parse
26
21
  * @returns a Date or undefined
27
22
  */
28
23
  export declare const _parseRfc3339DateTimeWithOffset: (value: unknown) => Date | undefined;
29
24
  /**
30
- * @internal
31
- *
32
25
  * Parses a value into a Date. Returns undefined if the input is null or
33
26
  * undefined, throws an error if the input is not a string that can be parsed
34
27
  * as an RFC 7231 date.
35
- *
36
28
  * Input strings must conform to RFC7231 section 7.1.1.1. Fractional seconds are supported.
37
- *
38
29
  * RFC 850 and unix asctime formats are also accepted.
39
30
  * todo: practically speaking, are RFC 850 and asctime even used anymore?
40
31
  * todo: can we remove those parts?
41
32
  *
33
+ * @internal
42
34
  * @see {@link https://datatracker.ietf.org/doc/html/rfc7231.html#section-7.1.1.1}
43
- *
44
35
  * @param value - the value to parse.
45
36
  * @returns a Date or undefined.
46
37
  */
@@ -1,9 +1,8 @@
1
1
  /**
2
- * @internal
3
- *
4
2
  * Given an input string, splits based on the delimiter after a given
5
3
  * number of delimiters has been encountered.
6
4
  *
5
+ * @internal
7
6
  * @param value - The input string to split.
8
7
  * @param delimiter - The delimiter to split on.
9
8
  * @param numDelimiters - The number of delimiters to have encountered to split.
@@ -4,12 +4,13 @@ export type BufferStore = [string, ByteArrayCollector, ByteArrayCollector?];
4
4
  export type BufferUnion = string | Uint8Array;
5
5
  export type Modes = 0 | 1 | 2;
6
6
  /**
7
+ * the minimum size is met, except for the last chunk.
8
+ *
7
9
  * @internal
8
10
  * @param upstream - any ReadableStream.
9
11
  * @param size - byte or character length minimum. Buffering occurs when a chunk fails to meet this value.
10
12
  * @param logger - for emitting warnings when buffering occurs.
11
13
  * @returns another stream of the same data, but buffers chunks until
12
- * the minimum size is met, except for the last chunk.
13
14
  */
14
15
  export declare function createBufferedReadableStream(upstream: ReadableStream, size: number, logger?: Logger): ReadableStream;
15
16
  /**
@@ -1,12 +1,13 @@
1
1
  import { Readable } from "node:stream";
2
2
  import type { Logger } from "@smithy/types";
3
3
  /**
4
+ * the minimum size is met, except for the last chunk.
5
+ *
4
6
  * @internal
5
7
  * @param upstream - any Readable or ReadableStream.
6
8
  * @param size - byte or character length minimum. Buffering occurs when a chunk fails to meet this value.
7
9
  * @param logger - for emitting warnings when buffering occurs.
8
10
  * @returns another stream of the same data and stream class, but buffers chunks until
9
- * the minimum size is met, except for the last chunk.
10
11
  */
11
12
  export declare function createBufferedReadable(upstream: Readable, size: number, logger?: Logger): Readable;
12
13
  /**
@@ -1,5 +1,6 @@
1
1
  /**
2
- * @internal
3
2
  * Inlined from @smithy/fetch-http-handler streamCollector.
3
+ *
4
+ * @internal
4
5
  */
5
6
  export declare const streamCollector: (stream: Blob | ReadableStream) => Promise<Uint8Array>;
@@ -1,19 +1,24 @@
1
1
  /**
2
- * Generates a RFC4122 version 4 UUID
2
+ * @internal
3
+ */
4
+ export type GetRandomValues = (array: Uint8Array) => Uint8Array;
5
+ /**
6
+ * Creates a RFC4122 version 4 UUID generator.
3
7
  *
4
- * This function generates a random UUID using one of two methods:
5
- * 1. The native randomUUID() function if available
6
- * 2. A fallback implementation using crypto.getRandomValues()
8
+ * Uses the native crypto.randomUUID() if available, otherwise falls back
9
+ * to a manual implementation using the provided getRandomValues function.
7
10
  *
8
11
  * The fallback implementation:
9
- * - Generates 16 random bytes using crypto.getRandomValues()
12
+ * - Generates 16 random bytes using getRandomValues()
10
13
  * - Sets the version bits to indicate version 4
11
14
  * - Sets the variant bits to indicate RFC4122
12
15
  * - Formats the bytes as a UUID string with dashes
13
16
  *
14
- * @returns A version 4 UUID string in the format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
17
+ * @param getRandomValues - platform-specific random byte source.
18
+ * @returns A function that generates version 4 UUID strings
19
+ * in the format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
15
20
  * where x is any hexadecimal digit and y is one of 8, 9, a, or b.
16
21
  *
17
22
  * @internal
18
23
  */
19
- export declare const v4: () => string;
24
+ export declare function bindV4(getRandomValues: GetRandomValues): () => string;
@@ -4,8 +4,9 @@ import type { Identity, IdentityProvider } from "@smithy/types";
4
4
  */
5
5
  export declare const createIsIdentityExpiredFunction: (expirationMs: number) => (identity: Identity) => boolean;
6
6
  /**
7
- * @internal
8
7
  * This may need to be configurable in the future, but for now it is defaulted to 5min.
8
+ *
9
+ * @internal
9
10
  */
10
11
  export declare const EXPIRATION_MS = 300000;
11
12
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.24.0",
3
+ "version": "3.24.1",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",
6
6
  "build:es:cjs": "yarn g:tsc -p tsconfig.es.json && node ../../scripts/inline core",
@@ -1,2 +0,0 @@
1
- import { v4 as generateIdempotencyToken } from "./uuid/v4";
2
- export { generateIdempotencyToken };
@@ -1,3 +0,0 @@
1
- export const randomUUID = typeof crypto !== "undefined" && typeof crypto.randomUUID === "function"
2
- ? crypto.randomUUID.bind(crypto)
3
- : undefined;
@@ -1,2 +0,0 @@
1
- import { v4 as generateIdempotencyToken } from "./uuid/v4";
2
- export { generateIdempotencyToken };
@@ -1 +0,0 @@
1
- export declare const randomUUID: (() => `${string}-${string}-${string}-${string}-${string}`) | undefined;