@smithy/core 3.40.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist-cjs/submodules/protocols/index.js +600 -328
  3. package/dist-cjs/submodules/serde/index.browser.js +9 -4
  4. package/dist-cjs/submodules/serde/index.js +9 -4
  5. package/dist-cjs/submodules/serde/index.native.js +9 -4
  6. package/dist-es/submodules/protocols/HttpBindingNormalizedSchema.js +215 -0
  7. package/dist-es/submodules/protocols/HttpBindingProtocol.js +223 -195
  8. package/dist-es/submodules/protocols/HttpProtocol.js +22 -23
  9. package/dist-es/submodules/protocols/extended-encode-uri-component.js +3 -0
  10. package/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +54 -47
  11. package/dist-es/submodules/protocols/serde/HttpInterceptingShapeDeserializer.js +23 -18
  12. package/dist-es/submodules/protocols/serde/HttpInterceptingShapeSerializer.js +12 -5
  13. package/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +33 -27
  14. package/dist-es/submodules/protocols/serde/determineTimestampFormat.js +5 -5
  15. package/dist-es/submodules/serde/quote-header.js +1 -1
  16. package/dist-es/submodules/serde/schema-serde-lib/schema-date-utils.js +4 -0
  17. package/dist-es/submodules/serde/split-header.js +4 -3
  18. package/dist-types/submodules/protocols/HttpBindingNormalizedSchema.d.ts +75 -0
  19. package/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +11 -8
  20. package/dist-types/submodules/protocols/HttpProtocol.d.ts +2 -2
  21. package/dist-types/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +2 -1
  22. package/dist-types/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +4 -0
  23. package/dist-types/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +3 -0
  24. package/dist-types/submodules/protocols/serde/ToStringShapeSerializer.d.ts +2 -0
  25. package/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +1 -1
  26. package/dist-types/ts3.4/submodules/protocols/HttpBindingNormalizedSchema.d.ts +81 -0
  27. package/dist-types/ts3.4/submodules/protocols/HttpBindingProtocol.d.ts +11 -8
  28. package/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +1 -1
  29. package/dist-types/ts3.4/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +2 -1
  30. package/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +4 -0
  31. package/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +3 -0
  32. package/dist-types/ts3.4/submodules/protocols/serde/ToStringShapeSerializer.d.ts +2 -0
  33. package/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +1 -1
  34. package/package.json +1 -1
@@ -0,0 +1,81 @@
1
+ import { NormalizedSchema } from "@smithy/core/schema";
2
+ import { OperationSchema, StaticStructureSchema } from "@smithy/types";
3
+ export type HttpBody = 32;
4
+ export type HttpLabel = 33;
5
+ export type HttpQuery = 34;
6
+ export type HttpQueryParams = 35;
7
+ export type HttpPayload = 36;
8
+ export type HttpResponseCode = 37;
9
+ export type HttpHeader = 38;
10
+ export type HttpPrefixHeaders = 39;
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 [
29
+ /*value*/ string,
30
+ /*kind*/ 0 | 1 | 2
31
+ ];
32
+ export type HttpOperationBindings = readonly [
33
+ /*method*/ string | undefined,
34
+ /*path*/ string | undefined,
35
+ /*query*/ readonly (readonly [
36
+ string,
37
+ string
38
+ ])[],
39
+ /*pathSegments*/ readonly HttpPathSegment[] | undefined,
40
+ /*hostPrefix*/ string | undefined
41
+ ];
42
+ export type HttpBindingIndex = {
43
+ request: {
44
+ memberBindings: HttpBinding[];
45
+ byName: Record<string, HttpBinding>;
46
+ hasIdempotency?: boolean;
47
+ hasPrefixHeaders?: boolean;
48
+ syntheticBodySchema?: StaticStructureSchema;
49
+ contentTypeInstruction?: string | null;
50
+ };
51
+ response: {
52
+ bodyMemberNames: string[];
53
+ syntheticBodySchema?: StaticStructureSchema;
54
+ bindings: {
55
+ payload?: HttpBinding;
56
+ statusCode?: HttpBinding;
57
+ headers: Record<string, HttpBinding>;
58
+ prefixHeaders: HttpBinding[];
59
+ };
60
+ };
61
+ };
62
+ /**
63
+ * A normalized schema with lazily cached HTTP binding metadata.
64
+ *
65
+ * @internal
66
+ */
67
+ export declare class HttpBindingNormalizedSchema extends NormalizedSchema {
68
+ private static readonly identity;
69
+ private readonly identity;
70
+ private bindings?;
71
+ private constructor();
72
+ static of(schema: Parameters<typeof NormalizedSchema.of>[0]): HttpBindingNormalizedSchema;
73
+ getHttpBindingLocation(traits: ReturnType<NormalizedSchema["getMergedTraits"]>): HttpBindingLocation;
74
+ getHttpBindingValue(location: HttpBindingLocation, traits: ReturnType<NormalizedSchema["getMergedTraits"]>, nested?: boolean): HttpBindingValue;
75
+ getHttpBindingCollectionValue(location: HttpBindingLocation, traits?: import("@smithy/types").SchemaTraitsObject): HttpBindingValue;
76
+ getHttpBindings(): HttpBindingIndex;
77
+ }
78
+ /**
79
+ * @internal
80
+ */
81
+ export declare const getHttpOperationBindings: (schema: OperationSchema) => HttpOperationBindings;
@@ -1,7 +1,10 @@
1
- import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
2
1
  import { HttpRequest } from "@smithy/core/transport";
2
+ import { TypeRegistry } from "@smithy/core/schema";
3
3
  import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, Schema, SerdeFunctions } from "@smithy/types";
4
+ import { HttpBindingValue } from "./HttpBindingNormalizedSchema";
4
5
  import { HttpProtocol } from "./HttpProtocol";
6
+ import { 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
- protected serializeQuery(ns: NormalizedSchema, data: any, query: HttpRequest["query"]): void;
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
- discardResponseBody?: boolean;
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 {};
@@ -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 { CodecSettings, Schema, ShapeDeserializer } from "@smithy/types";
2
+ import { HttpBindingLocation, 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
- private base64ToUtf8;
13
+ readHttpBinding([ns, flags, collectionValue]: HttpBindingValue, data: string, location: HttpBindingLocation): any;
13
14
  }
@@ -1,4 +1,5 @@
1
1
  import { CodecSettings, Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
2
+ import { HttpBindingLocation, 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 { CodecSettings, ConfigurableSerdeContext, Schema as ISchema, SerdeFunctions, ShapeSerializer } from "@smithy/types";
2
+ import { HttpBindingLocation, 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 { CodecSettings, Schema, ShapeSerializer } from "@smithy/types";
2
+ import { HttpBindingLocation, 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
  }
@@ -31,7 +31,7 @@ export declare class NormalizedSchema implements INormalizedSchema {
31
31
  * @param ref - a polymorphic SchemaRef to be dereferenced/normalized.
32
32
  * @param memberName - optional memberName if this NormalizedSchema should be considered a member schema.
33
33
  */
34
- private constructor();
34
+ protected constructor(ref: $SchemaRef, memberName?: string | undefined);
35
35
  static [Symbol.hasInstance](lhs: unknown): lhs is NormalizedSchema;
36
36
  /**
37
37
  * Static constructor that attempts to avoid wrapping a NormalizedSchema within another.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.40.0",
3
+ "version": "3.41.0",
4
4
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/core",
5
5
  "license": "Apache-2.0",
6
6
  "author": {