@smithy/core 3.13.0 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist-cjs/index.js +308 -412
  2. package/dist-cjs/submodules/cbor/index.js +957 -969
  3. package/dist-cjs/submodules/event-streams/index.js +200 -249
  4. package/dist-cjs/submodules/protocols/index.js +795 -895
  5. package/dist-cjs/submodules/schema/index.js +536 -799
  6. package/dist-cjs/submodules/serde/index.js +675 -679
  7. package/dist-es/submodules/cbor/CborCodec.js +6 -2
  8. package/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +3 -3
  9. package/dist-es/submodules/cbor/cbor-decode.js +18 -18
  10. package/dist-es/submodules/cbor/cbor-encode.js +5 -5
  11. package/dist-es/submodules/event-streams/EventStreamSerde.js +10 -3
  12. package/dist-es/submodules/protocols/HttpBindingProtocol.js +4 -4
  13. package/dist-es/submodules/protocols/HttpProtocol.js +5 -3
  14. package/dist-es/submodules/protocols/RpcProtocol.js +2 -2
  15. package/dist-es/submodules/protocols/requestBuilder.js +9 -7
  16. package/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +21 -17
  17. package/dist-es/submodules/protocols/serde/HttpInterceptingShapeDeserializer.js +3 -0
  18. package/dist-es/submodules/protocols/serde/HttpInterceptingShapeSerializer.js +3 -0
  19. package/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +7 -6
  20. package/dist-es/submodules/protocols/serde/determineTimestampFormat.js +5 -6
  21. package/dist-es/submodules/schema/TypeRegistry.js +4 -1
  22. package/dist-es/submodules/schema/index.js +1 -0
  23. package/dist-es/submodules/schema/schemas/ErrorSchema.js +3 -5
  24. package/dist-es/submodules/schema/schemas/ListSchema.js +5 -5
  25. package/dist-es/submodules/schema/schemas/MapSchema.js +6 -5
  26. package/dist-es/submodules/schema/schemas/NormalizedSchema.js +92 -178
  27. package/dist-es/submodules/schema/schemas/OperationSchema.js +6 -5
  28. package/dist-es/submodules/schema/schemas/Schema.js +3 -0
  29. package/dist-es/submodules/schema/schemas/SimpleSchema.js +5 -5
  30. package/dist-es/submodules/schema/schemas/StructureSchema.js +6 -5
  31. package/dist-es/submodules/schema/schemas/sentinels.js +14 -14
  32. package/dist-es/submodules/schema/schemas/translateTraits.js +22 -0
  33. package/dist-es/submodules/serde/index.js +1 -0
  34. package/dist-es/submodules/serde/schema-serde-lib/schema-date-utils.js +110 -0
  35. package/dist-es/submodules/serde/value/NumericValue.js +6 -26
  36. package/dist-es/util-identity-and-auth/DefaultIdentityProviderConfig.js +1 -1
  37. package/dist-es/util-identity-and-auth/memoizeIdentityProvider.js +4 -2
  38. package/dist-types/submodules/schema/index.d.ts +1 -0
  39. package/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +5 -24
  40. package/dist-types/submodules/schema/schemas/sentinels.d.ts +2 -0
  41. package/dist-types/submodules/schema/schemas/translateTraits.d.ts +7 -0
  42. package/dist-types/submodules/serde/index.d.ts +1 -0
  43. package/dist-types/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +47 -0
  44. package/dist-types/ts3.4/submodules/schema/index.d.ts +1 -0
  45. package/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +5 -24
  46. package/dist-types/ts3.4/submodules/schema/schemas/sentinels.d.ts +2 -0
  47. package/dist-types/ts3.4/submodules/schema/schemas/translateTraits.d.ts +7 -0
  48. package/dist-types/ts3.4/submodules/serde/index.d.ts +1 -0
  49. package/dist-types/ts3.4/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +47 -0
  50. package/package.json +11 -11
@@ -1,5 +1,7 @@
1
- export const createIsIdentityExpiredFunction = (expirationMs) => (identity) => doesIdentityRequireRefresh(identity) && identity.expiration.getTime() - Date.now() < expirationMs;
2
- export const EXPIRATION_MS = 300000;
1
+ export const createIsIdentityExpiredFunction = (expirationMs) => function isIdentityExpired(identity) {
2
+ return doesIdentityRequireRefresh(identity) && identity.expiration.getTime() - Date.now() < expirationMs;
3
+ };
4
+ export const EXPIRATION_MS = 300_000;
3
5
  export const isIdentityExpired = createIsIdentityExpiredFunction(EXPIRATION_MS);
4
6
  export const doesIdentityRequireRefresh = (identity) => identity.expiration !== undefined;
5
7
  export const memoizeIdentityProvider = (provider, isExpired, requiresRefresh) => {
@@ -9,4 +9,5 @@ export * from "./schemas/Schema";
9
9
  export * from "./schemas/SimpleSchema";
10
10
  export * from "./schemas/StructureSchema";
11
11
  export * from "./schemas/sentinels";
12
+ export * from "./schemas/translateTraits";
12
13
  export * from "./TypeRegistry";
@@ -1,4 +1,4 @@
1
- import type { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISchema, SchemaRef, SchemaTraits, SchemaTraitsObject } from "@smithy/types";
1
+ import type { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISchema, SchemaRef, SchemaTraitsObject } from "@smithy/types";
2
2
  /**
3
3
  * Wraps both class instances, numeric sentinel values, and member schema pairs.
4
4
  * Presents a consistent interface for interacting with polymorphic schema representations.
@@ -7,7 +7,7 @@ import type { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISc
7
7
  */
8
8
  export declare class NormalizedSchema implements INormalizedSchema {
9
9
  readonly ref: SchemaRef;
10
- private memberName?;
10
+ private readonly memberName?;
11
11
  static readonly symbol: unique symbol;
12
12
  protected readonly symbol: symbol;
13
13
  private readonly name;
@@ -26,11 +26,6 @@ export declare class NormalizedSchema implements INormalizedSchema {
26
26
  * Static constructor that attempts to avoid wrapping a NormalizedSchema within another.
27
27
  */
28
28
  static of(ref: SchemaRef): NormalizedSchema;
29
- /**
30
- * @param indicator - numeric indicator for preset trait combination.
31
- * @returns equivalent trait object.
32
- */
33
- static translateTraits(indicator: SchemaTraits): SchemaTraitsObject;
34
29
  /**
35
30
  * @returns the underlying non-normalized schema.
36
31
  */
@@ -42,11 +37,9 @@ export declare class NormalizedSchema implements INormalizedSchema {
42
37
  getName(withNamespace?: boolean): string | undefined;
43
38
  /**
44
39
  * @returns the member name if the schema is a member schema.
45
- * @throws Error when the schema isn't a member schema.
46
40
  */
47
41
  getMemberName(): string;
48
42
  isMemberSchema(): boolean;
49
- isUnitSchema(): boolean;
50
43
  /**
51
44
  * boolean methods on this class help control flow in shape serialization and deserialization.
52
45
  */
@@ -55,6 +48,7 @@ export declare class NormalizedSchema implements INormalizedSchema {
55
48
  isStructSchema(): boolean;
56
49
  isBlobSchema(): boolean;
57
50
  isTimestampSchema(): boolean;
51
+ isUnitSchema(): boolean;
58
52
  isDocumentSchema(): boolean;
59
53
  isStringSchema(): boolean;
60
54
  isBooleanSchema(): boolean;
@@ -94,20 +88,15 @@ export declare class NormalizedSchema implements INormalizedSchema {
94
88
  * @throws Error if the schema is not a Map, List, nor Document.
95
89
  */
96
90
  getValueSchema(): NormalizedSchema;
97
- /**
98
- * @param member - to query.
99
- * @returns whether there is a memberSchema with the given member name. False if not a structure (or union).
100
- */
101
- hasMemberSchema(member: string): boolean;
102
91
  /**
103
92
  * @returns the NormalizedSchema for the given member name. The returned instance will return true for `isMemberSchema()`
104
93
  * and will have the member name given.
105
- * @param member - which member to retrieve and wrap.
94
+ * @param memberName - which member to retrieve and wrap.
106
95
  *
107
96
  * @throws Error if member does not exist or the schema is neither a document nor structure.
108
97
  * Note that errors are assumed to be structures and unions are considered structures for these purposes.
109
98
  */
110
- getMemberSchema(member: string): NormalizedSchema;
99
+ getMemberSchema(memberName: string): NormalizedSchema;
111
100
  /**
112
101
  * This can be used for checking the members as a hashmap.
113
102
  * Prefer the structIterator method for iteration.
@@ -131,12 +120,4 @@ export declare class NormalizedSchema implements INormalizedSchema {
131
120
  * This avoids the overhead of calling Object.entries(ns.getMemberSchemas()).
132
121
  */
133
122
  structIterator(): Generator<[string, NormalizedSchema], undefined, undefined>;
134
- /**
135
- * Creates a normalized member schema from the given schema and member name.
136
- */
137
- private memberFrom;
138
- /**
139
- * @returns a last-resort human-readable name for the schema if it has no other identifiers.
140
- */
141
- private getSchemaName;
142
123
  }
@@ -2,6 +2,8 @@ import type { BigDecimalSchema, BigIntegerSchema, BlobSchema, BooleanSchema, Doc
2
2
  /**
3
3
  * Schema sentinel runtime values.
4
4
  * @alpha
5
+ *
6
+ * @deprecated use inline numbers with type annotation to save space.
5
7
  */
6
8
  export declare const SCHEMA: {
7
9
  BLOB: BlobSchema;
@@ -0,0 +1,7 @@
1
+ import type { SchemaTraits, SchemaTraitsObject } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ * @param indicator - numeric indicator for preset trait combination.
5
+ * @returns equivalent trait object.
6
+ */
7
+ export declare function translateTraits(indicator: SchemaTraits): SchemaTraitsObject;
@@ -4,6 +4,7 @@ export * from "./generateIdempotencyToken";
4
4
  export * from "./lazy-json";
5
5
  export * from "./parse-utils";
6
6
  export * from "./quote-header";
7
+ export * from "./schema-serde-lib/schema-date-utils";
7
8
  export * from "./split-every";
8
9
  export * from "./split-header";
9
10
  export * from "./value/NumericValue";
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Parses a value into a Date. Returns undefined if the input is null or
5
+ * undefined, throws an error if the input is not a number or a parseable string.
6
+ *
7
+ * Input strings must be an integer or floating point number. Fractional seconds are supported.
8
+ *
9
+ * @param value - the value to parse
10
+ * @returns a Date or undefined
11
+ */
12
+ export declare const _parseEpochTimestamp: (value: unknown) => Date | undefined;
13
+ /**
14
+ * @internal
15
+ *
16
+ * Parses a value into a Date. Returns undefined if the input is null or
17
+ * undefined, throws an error if the input is not a string that can be parsed
18
+ * as an RFC 3339 date.
19
+ *
20
+ * Input strings must conform to RFC3339 section 5.6, and can have a UTC
21
+ * offset. Fractional precision is supported.
22
+ *
23
+ * @see {@link https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14}
24
+ *
25
+ * @param value - the value to parse
26
+ * @returns a Date or undefined
27
+ */
28
+ export declare const _parseRfc3339DateTimeWithOffset: (value: unknown) => Date | undefined;
29
+ /**
30
+ * @internal
31
+ *
32
+ * Parses a value into a Date. Returns undefined if the input is null or
33
+ * undefined, throws an error if the input is not a string that can be parsed
34
+ * as an RFC 7231 date.
35
+ *
36
+ * Input strings must conform to RFC7231 section 7.1.1.1. Fractional seconds are supported.
37
+ *
38
+ * RFC 850 and unix asctime formats are also accepted.
39
+ * todo: practically speaking, are RFC 850 and asctime even used anymore?
40
+ * todo: can we remove those parts?
41
+ *
42
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7231.html#section-7.1.1.1}
43
+ *
44
+ * @param value - the value to parse.
45
+ * @returns a Date or undefined.
46
+ */
47
+ export declare const _parseRfc7231DateTime: (value: unknown) => Date | undefined;
@@ -9,4 +9,5 @@ export * from "./schemas/Schema";
9
9
  export * from "./schemas/SimpleSchema";
10
10
  export * from "./schemas/StructureSchema";
11
11
  export * from "./schemas/sentinels";
12
+ export * from "./schemas/translateTraits";
12
13
  export * from "./TypeRegistry";
@@ -1,4 +1,4 @@
1
- import { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISchema, SchemaRef, SchemaTraits, SchemaTraitsObject } from "@smithy/types";
1
+ import { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISchema, SchemaRef, SchemaTraitsObject } from "@smithy/types";
2
2
  /**
3
3
  * Wraps both class instances, numeric sentinel values, and member schema pairs.
4
4
  * Presents a consistent interface for interacting with polymorphic schema representations.
@@ -7,7 +7,7 @@ import { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISchema,
7
7
  */
8
8
  export declare class NormalizedSchema implements INormalizedSchema {
9
9
  readonly ref: SchemaRef;
10
- private memberName?;
10
+ private readonly memberName?;
11
11
  static readonly symbol: unique symbol;
12
12
  protected readonly symbol: symbol;
13
13
  private readonly name;
@@ -26,11 +26,6 @@ export declare class NormalizedSchema implements INormalizedSchema {
26
26
  * Static constructor that attempts to avoid wrapping a NormalizedSchema within another.
27
27
  */
28
28
  static of(ref: SchemaRef): NormalizedSchema;
29
- /**
30
- * @param indicator - numeric indicator for preset trait combination.
31
- * @returns equivalent trait object.
32
- */
33
- static translateTraits(indicator: SchemaTraits): SchemaTraitsObject;
34
29
  /**
35
30
  * @returns the underlying non-normalized schema.
36
31
  */
@@ -42,11 +37,9 @@ export declare class NormalizedSchema implements INormalizedSchema {
42
37
  getName(withNamespace?: boolean): string | undefined;
43
38
  /**
44
39
  * @returns the member name if the schema is a member schema.
45
- * @throws Error when the schema isn't a member schema.
46
40
  */
47
41
  getMemberName(): string;
48
42
  isMemberSchema(): boolean;
49
- isUnitSchema(): boolean;
50
43
  /**
51
44
  * boolean methods on this class help control flow in shape serialization and deserialization.
52
45
  */
@@ -55,6 +48,7 @@ export declare class NormalizedSchema implements INormalizedSchema {
55
48
  isStructSchema(): boolean;
56
49
  isBlobSchema(): boolean;
57
50
  isTimestampSchema(): boolean;
51
+ isUnitSchema(): boolean;
58
52
  isDocumentSchema(): boolean;
59
53
  isStringSchema(): boolean;
60
54
  isBooleanSchema(): boolean;
@@ -94,20 +88,15 @@ export declare class NormalizedSchema implements INormalizedSchema {
94
88
  * @throws Error if the schema is not a Map, List, nor Document.
95
89
  */
96
90
  getValueSchema(): NormalizedSchema;
97
- /**
98
- * @param member - to query.
99
- * @returns whether there is a memberSchema with the given member name. False if not a structure (or union).
100
- */
101
- hasMemberSchema(member: string): boolean;
102
91
  /**
103
92
  * @returns the NormalizedSchema for the given member name. The returned instance will return true for `isMemberSchema()`
104
93
  * and will have the member name given.
105
- * @param member - which member to retrieve and wrap.
94
+ * @param memberName - which member to retrieve and wrap.
106
95
  *
107
96
  * @throws Error if member does not exist or the schema is neither a document nor structure.
108
97
  * Note that errors are assumed to be structures and unions are considered structures for these purposes.
109
98
  */
110
- getMemberSchema(member: string): NormalizedSchema;
99
+ getMemberSchema(memberName: string): NormalizedSchema;
111
100
  /**
112
101
  * This can be used for checking the members as a hashmap.
113
102
  * Prefer the structIterator method for iteration.
@@ -134,12 +123,4 @@ export declare class NormalizedSchema implements INormalizedSchema {
134
123
  string,
135
124
  NormalizedSchema
136
125
  ], undefined, undefined>;
137
- /**
138
- * Creates a normalized member schema from the given schema and member name.
139
- */
140
- private memberFrom;
141
- /**
142
- * @returns a last-resort human-readable name for the schema if it has no other identifiers.
143
- */
144
- private getSchemaName;
145
126
  }
@@ -2,6 +2,8 @@ import { BigDecimalSchema, BigIntegerSchema, BlobSchema, BooleanSchema, Document
2
2
  /**
3
3
  * Schema sentinel runtime values.
4
4
  * @alpha
5
+ *
6
+ * @deprecated use inline numbers with type annotation to save space.
5
7
  */
6
8
  export declare const SCHEMA: {
7
9
  BLOB: BlobSchema;
@@ -0,0 +1,7 @@
1
+ import { SchemaTraits, SchemaTraitsObject } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ * @param indicator - numeric indicator for preset trait combination.
5
+ * @returns equivalent trait object.
6
+ */
7
+ export declare function translateTraits(indicator: SchemaTraits): SchemaTraitsObject;
@@ -4,6 +4,7 @@ export * from "./generateIdempotencyToken";
4
4
  export * from "./lazy-json";
5
5
  export * from "./parse-utils";
6
6
  export * from "./quote-header";
7
+ export * from "./schema-serde-lib/schema-date-utils";
7
8
  export * from "./split-every";
8
9
  export * from "./split-header";
9
10
  export * from "./value/NumericValue";
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @internal
3
+ *
4
+ * Parses a value into a Date. Returns undefined if the input is null or
5
+ * undefined, throws an error if the input is not a number or a parseable string.
6
+ *
7
+ * Input strings must be an integer or floating point number. Fractional seconds are supported.
8
+ *
9
+ * @param value - the value to parse
10
+ * @returns a Date or undefined
11
+ */
12
+ export declare const _parseEpochTimestamp: (value: unknown) => Date | undefined;
13
+ /**
14
+ * @internal
15
+ *
16
+ * Parses a value into a Date. Returns undefined if the input is null or
17
+ * undefined, throws an error if the input is not a string that can be parsed
18
+ * as an RFC 3339 date.
19
+ *
20
+ * Input strings must conform to RFC3339 section 5.6, and can have a UTC
21
+ * offset. Fractional precision is supported.
22
+ *
23
+ * @see {@link https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14}
24
+ *
25
+ * @param value - the value to parse
26
+ * @returns a Date or undefined
27
+ */
28
+ export declare const _parseRfc3339DateTimeWithOffset: (value: unknown) => Date | undefined;
29
+ /**
30
+ * @internal
31
+ *
32
+ * Parses a value into a Date. Returns undefined if the input is null or
33
+ * undefined, throws an error if the input is not a string that can be parsed
34
+ * as an RFC 7231 date.
35
+ *
36
+ * Input strings must conform to RFC7231 section 7.1.1.1. Fractional seconds are supported.
37
+ *
38
+ * RFC 850 and unix asctime formats are also accepted.
39
+ * todo: practically speaking, are RFC 850 and asctime even used anymore?
40
+ * todo: can we remove those parts?
41
+ *
42
+ * @see {@link https://datatracker.ietf.org/doc/html/rfc7231.html#section-7.1.1.1}
43
+ *
44
+ * @param value - the value to parse.
45
+ * @returns a Date or undefined.
46
+ */
47
+ export declare const _parseRfc7231DateTime: (value: unknown) => Date | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.13.0",
3
+ "version": "3.15.0",
4
4
  "scripts": {
5
5
  "build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
6
6
  "build:cjs": "node ../../scripts/inline core",
@@ -77,15 +77,15 @@
77
77
  "license": "Apache-2.0",
78
78
  "sideEffects": false,
79
79
  "dependencies": {
80
- "@smithy/middleware-serde": "^4.1.1",
81
- "@smithy/protocol-http": "^5.2.1",
82
- "@smithy/types": "^4.5.0",
83
- "@smithy/util-base64": "^4.1.0",
84
- "@smithy/util-body-length-browser": "^4.1.0",
85
- "@smithy/util-middleware": "^4.1.1",
86
- "@smithy/util-stream": "^4.3.2",
87
- "@smithy/util-utf8": "^4.1.0",
88
- "@smithy/uuid": "^1.0.0",
80
+ "@smithy/middleware-serde": "^4.2.0",
81
+ "@smithy/protocol-http": "^5.3.0",
82
+ "@smithy/types": "^4.6.0",
83
+ "@smithy/util-base64": "^4.3.0",
84
+ "@smithy/util-body-length-browser": "^4.2.0",
85
+ "@smithy/util-middleware": "^4.2.0",
86
+ "@smithy/util-stream": "^4.5.0",
87
+ "@smithy/util-utf8": "^4.2.0",
88
+ "@smithy/uuid": "^1.1.0",
89
89
  "tslib": "^2.6.2"
90
90
  },
91
91
  "engines": {
@@ -118,7 +118,7 @@
118
118
  "directory": "packages/core"
119
119
  },
120
120
  "devDependencies": {
121
- "@smithy/eventstream-serde-node": "^4.1.1",
121
+ "@smithy/eventstream-serde-node": "^4.2.0",
122
122
  "@types/node": "^18.11.9",
123
123
  "concurrently": "7.0.0",
124
124
  "downlevel-dts": "0.10.1",