@smithy/core 3.7.2 → 3.9.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 (54) hide show
  1. package/dist-cjs/submodules/cbor/index.js +121 -53
  2. package/dist-cjs/submodules/event-streams/index.js +261 -0
  3. package/dist-cjs/submodules/protocols/index.js +197 -104
  4. package/dist-cjs/submodules/schema/index.js +37 -0
  5. package/dist-cjs/submodules/serde/index.js +6 -51
  6. package/dist-es/submodules/cbor/CborCodec.js +77 -41
  7. package/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +36 -15
  8. package/dist-es/submodules/event-streams/EventStreamSerde.js +200 -0
  9. package/dist-es/submodules/event-streams/index.js +1 -0
  10. package/dist-es/submodules/protocols/HttpBindingProtocol.js +86 -6
  11. package/dist-es/submodules/protocols/HttpProtocol.js +42 -94
  12. package/dist-es/submodules/protocols/RpcProtocol.js +36 -10
  13. package/dist-es/submodules/protocols/index.js +1 -0
  14. package/dist-es/submodules/schema/schemas/NormalizedSchema.js +26 -0
  15. package/dist-es/submodules/serde/copyDocumentWithTransform.js +1 -53
  16. package/dist-es/submodules/serde/generateIdempotencyToken.js +2 -0
  17. package/dist-es/submodules/serde/index.js +1 -0
  18. package/dist-types/submodules/cbor/CborCodec.d.ts +11 -2
  19. package/dist-types/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +1 -0
  20. package/dist-types/submodules/cbor/parseCborBody.d.ts +1 -1
  21. package/dist-types/submodules/event-streams/EventStreamSerde.d.ts +60 -0
  22. package/dist-types/submodules/event-streams/index.d.ts +1 -0
  23. package/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +9 -1
  24. package/dist-types/submodules/protocols/HttpProtocol.d.ts +42 -2
  25. package/dist-types/submodules/protocols/RpcProtocol.d.ts +1 -1
  26. package/dist-types/submodules/protocols/index.d.ts +1 -0
  27. package/dist-types/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +1 -1
  28. package/dist-types/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +1 -1
  29. package/dist-types/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +1 -1
  30. package/dist-types/submodules/protocols/serde/ToStringShapeSerializer.d.ts +1 -1
  31. package/dist-types/submodules/protocols/serde/determineTimestampFormat.d.ts +1 -1
  32. package/dist-types/submodules/schema/middleware/getSchemaSerdePlugin.d.ts +1 -1
  33. package/dist-types/submodules/schema/middleware/schemaDeserializationMiddleware.d.ts +1 -1
  34. package/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +15 -0
  35. package/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +1 -1
  36. package/dist-types/submodules/schema/schemas/sentinels.d.ts +1 -1
  37. package/dist-types/submodules/serde/copyDocumentWithTransform.d.ts +2 -1
  38. package/dist-types/submodules/serde/generateIdempotencyToken.d.ts +2 -0
  39. package/dist-types/submodules/serde/index.d.ts +1 -0
  40. package/dist-types/ts3.4/submodules/cbor/CborCodec.d.ts +10 -1
  41. package/dist-types/ts3.4/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +1 -0
  42. package/dist-types/ts3.4/submodules/event-streams/EventStreamSerde.d.ts +60 -0
  43. package/dist-types/ts3.4/submodules/event-streams/index.d.ts +1 -0
  44. package/dist-types/ts3.4/submodules/protocols/HttpBindingProtocol.d.ts +9 -1
  45. package/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +42 -2
  46. package/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
  47. package/dist-types/ts3.4/submodules/protocols/serde/determineTimestampFormat.d.ts +1 -1
  48. package/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +15 -0
  49. package/dist-types/ts3.4/submodules/serde/copyDocumentWithTransform.d.ts +1 -0
  50. package/dist-types/ts3.4/submodules/serde/generateIdempotencyToken.d.ts +2 -0
  51. package/dist-types/ts3.4/submodules/serde/index.d.ts +1 -0
  52. package/event-streams.d.ts +7 -0
  53. package/event-streams.js +6 -0
  54. package/package.json +19 -7
@@ -1,8 +1,5 @@
1
- import { NormalizedSchema, SCHEMA } from "@smithy/core/schema";
2
- import { splitEvery, splitHeader } from "@smithy/core/serde";
1
+ import { NormalizedSchema } from "@smithy/core/schema";
3
2
  import { HttpRequest, HttpResponse } from "@smithy/protocol-http";
4
- import { sdkStreamMixin } from "@smithy/util-stream";
5
- import { collectBody } from "./collect-stream-body";
6
3
  export class HttpProtocol {
7
4
  constructor(options) {
8
5
  this.options = options;
@@ -75,97 +72,48 @@ export class HttpProtocol {
75
72
  cfId: output.headers["x-amz-cf-id"],
76
73
  };
77
74
  }
75
+ async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {
76
+ const eventStreamSerde = await this.loadEventStreamCapability();
77
+ return eventStreamSerde.serializeEventStream({
78
+ eventStream,
79
+ requestSchema,
80
+ initialRequest,
81
+ });
82
+ }
83
+ async deserializeEventStream({ response, responseSchema, initialResponseContainer, }) {
84
+ const eventStreamSerde = await this.loadEventStreamCapability();
85
+ return eventStreamSerde.deserializeEventStream({
86
+ response,
87
+ responseSchema,
88
+ initialResponseContainer,
89
+ });
90
+ }
91
+ async loadEventStreamCapability() {
92
+ const { EventStreamSerde } = await import("@smithy/core/event-streams");
93
+ return new EventStreamSerde({
94
+ marshaller: this.getEventStreamMarshaller(),
95
+ serializer: this.serializer,
96
+ deserializer: this.deserializer,
97
+ serdeContext: this.serdeContext,
98
+ defaultContentType: this.getDefaultContentType(),
99
+ });
100
+ }
101
+ getDefaultContentType() {
102
+ throw new Error(`@smithy/core/protocols - ${this.constructor.name} getDefaultContentType() implementation missing.`);
103
+ }
78
104
  async deserializeHttpMessage(schema, context, response, arg4, arg5) {
79
- let dataObject;
80
- if (arg4 instanceof Set) {
81
- dataObject = arg5;
82
- }
83
- else {
84
- dataObject = arg4;
85
- }
86
- const deserializer = this.deserializer;
87
- const ns = NormalizedSchema.of(schema);
88
- const nonHttpBindingMembers = [];
89
- for (const [memberName, memberSchema] of ns.structIterator()) {
90
- const memberTraits = memberSchema.getMemberTraits();
91
- if (memberTraits.httpPayload) {
92
- const isStreaming = memberSchema.isStreaming();
93
- if (isStreaming) {
94
- const isEventStream = memberSchema.isStructSchema();
95
- if (isEventStream) {
96
- const context = this.serdeContext;
97
- if (!context.eventStreamMarshaller) {
98
- throw new Error("@smithy/core - HttpProtocol: eventStreamMarshaller missing in serdeContext.");
99
- }
100
- const memberSchemas = memberSchema.getMemberSchemas();
101
- dataObject[memberName] = context.eventStreamMarshaller.deserialize(response.body, async (event) => {
102
- const unionMember = Object.keys(event).find((key) => {
103
- return key !== "__type";
104
- }) ?? "";
105
- if (unionMember in memberSchemas) {
106
- const eventStreamSchema = memberSchemas[unionMember];
107
- return {
108
- [unionMember]: await deserializer.read(eventStreamSchema, event[unionMember].body),
109
- };
110
- }
111
- else {
112
- return {
113
- $unknown: event,
114
- };
115
- }
116
- });
117
- }
118
- else {
119
- dataObject[memberName] = sdkStreamMixin(response.body);
120
- }
121
- }
122
- else if (response.body) {
123
- const bytes = await collectBody(response.body, context);
124
- if (bytes.byteLength > 0) {
125
- dataObject[memberName] = await deserializer.read(memberSchema, bytes);
126
- }
127
- }
128
- }
129
- else if (memberTraits.httpHeader) {
130
- const key = String(memberTraits.httpHeader).toLowerCase();
131
- const value = response.headers[key];
132
- if (null != value) {
133
- if (memberSchema.isListSchema()) {
134
- const headerListValueSchema = memberSchema.getValueSchema();
135
- let sections;
136
- if (headerListValueSchema.isTimestampSchema() &&
137
- headerListValueSchema.getSchema() === SCHEMA.TIMESTAMP_DEFAULT) {
138
- sections = splitEvery(value, ",", 2);
139
- }
140
- else {
141
- sections = splitHeader(value);
142
- }
143
- const list = [];
144
- for (const section of sections) {
145
- list.push(await deserializer.read([headerListValueSchema, { httpHeader: key }], section.trim()));
146
- }
147
- dataObject[memberName] = list;
148
- }
149
- else {
150
- dataObject[memberName] = await deserializer.read(memberSchema, value);
151
- }
152
- }
153
- }
154
- else if (memberTraits.httpPrefixHeaders !== undefined) {
155
- dataObject[memberName] = {};
156
- for (const [header, value] of Object.entries(response.headers)) {
157
- if (header.startsWith(memberTraits.httpPrefixHeaders)) {
158
- dataObject[memberName][header.slice(memberTraits.httpPrefixHeaders.length)] = await deserializer.read([memberSchema.getValueSchema(), { httpHeader: header }], value);
159
- }
160
- }
161
- }
162
- else if (memberTraits.httpResponseCode) {
163
- dataObject[memberName] = response.statusCode;
164
- }
165
- else {
166
- nonHttpBindingMembers.push(memberName);
167
- }
105
+ void schema;
106
+ void context;
107
+ void response;
108
+ void arg4;
109
+ void arg5;
110
+ return [];
111
+ }
112
+ getEventStreamMarshaller() {
113
+ const context = this.serdeContext;
114
+ if (!context.eventStreamMarshaller) {
115
+ throw new Error("@smithy/core - HttpProtocol: eventStreamMarshaller missing in serdeContext.");
168
116
  }
169
- return nonHttpBindingMembers;
117
+ return context.eventStreamMarshaller;
170
118
  }
171
119
  }
@@ -29,8 +29,27 @@ export class RpcProtocol extends HttpProtocol {
29
29
  ...input,
30
30
  };
31
31
  if (input) {
32
- serializer.write(schema, _input);
33
- payload = serializer.flush();
32
+ const eventStreamMember = ns.getEventStreamMember();
33
+ if (eventStreamMember) {
34
+ if (_input[eventStreamMember]) {
35
+ const initialRequest = {};
36
+ for (const [memberName, memberSchema] of ns.structIterator()) {
37
+ if (memberName !== eventStreamMember && _input[memberName]) {
38
+ serializer.write(memberSchema, _input[memberName]);
39
+ initialRequest[memberName] = serializer.flush();
40
+ }
41
+ }
42
+ payload = await this.serializeEventStream({
43
+ eventStream: _input[eventStreamMember],
44
+ requestSchema: ns,
45
+ initialRequest,
46
+ });
47
+ }
48
+ }
49
+ else {
50
+ serializer.write(schema, _input);
51
+ payload = serializer.flush();
52
+ }
34
53
  }
35
54
  request.headers = headers;
36
55
  request.query = query;
@@ -55,14 +74,21 @@ export class RpcProtocol extends HttpProtocol {
55
74
  delete response.headers[header];
56
75
  response.headers[header.toLowerCase()] = value;
57
76
  }
58
- const bytes = await collectBody(response.body, context);
59
- if (bytes.byteLength > 0) {
60
- Object.assign(dataObject, await deserializer.read(ns, bytes));
77
+ const eventStreamMember = ns.getEventStreamMember();
78
+ if (eventStreamMember) {
79
+ dataObject[eventStreamMember] = await this.deserializeEventStream({
80
+ response,
81
+ responseSchema: ns,
82
+ initialResponseContainer: dataObject,
83
+ });
61
84
  }
62
- const output = {
63
- $metadata: this.deserializeMetadata(response),
64
- ...dataObject,
65
- };
66
- return output;
85
+ else {
86
+ const bytes = await collectBody(response.body, context);
87
+ if (bytes.byteLength > 0) {
88
+ Object.assign(dataObject, await deserializer.read(ns, bytes));
89
+ }
90
+ }
91
+ dataObject.$metadata = this.deserializeMetadata(response);
92
+ return dataObject;
67
93
  }
68
94
  }
@@ -1,6 +1,7 @@
1
1
  export * from "./collect-stream-body";
2
2
  export * from "./extended-encode-uri-component";
3
3
  export * from "./HttpBindingProtocol";
4
+ export * from "./HttpProtocol";
4
5
  export * from "./RpcProtocol";
5
6
  export * from "./requestBuilder";
6
7
  export * from "./resolve-path";
@@ -183,6 +183,15 @@ export class NormalizedSchema {
183
183
  }
184
184
  return this.getSchema() === SCHEMA.STREAMING_BLOB;
185
185
  }
186
+ isIdempotencyToken() {
187
+ if (typeof this.traits === "number") {
188
+ return (this.traits & 0b0100) === 0b0100;
189
+ }
190
+ else if (typeof this.traits === "object") {
191
+ return !!this.traits.idempotencyToken;
192
+ }
193
+ return false;
194
+ }
186
195
  getMergedTraits() {
187
196
  if (this.normalizedTraits) {
188
197
  return this.normalizedTraits;
@@ -241,6 +250,13 @@ export class NormalizedSchema {
241
250
  }
242
251
  throw new Error(`@smithy/core/schema - the schema ${this.getName(true)} does not have a value member.`);
243
252
  }
253
+ hasMemberSchema(member) {
254
+ if (this.isStructSchema()) {
255
+ const struct = this.getSchema();
256
+ return member in struct.members;
257
+ }
258
+ return false;
259
+ }
244
260
  getMemberSchema(member) {
245
261
  if (this.isStructSchema()) {
246
262
  const struct = this.getSchema();
@@ -269,6 +285,16 @@ export class NormalizedSchema {
269
285
  }
270
286
  return {};
271
287
  }
288
+ getEventStreamMember() {
289
+ if (this.isStructSchema()) {
290
+ for (const [memberName, memberSchema] of this.structIterator()) {
291
+ if (memberSchema.isStreaming() && memberSchema.isStructSchema()) {
292
+ return memberName;
293
+ }
294
+ }
295
+ }
296
+ return "";
297
+ }
272
298
  *structIterator() {
273
299
  if (this.isUnitSchema()) {
274
300
  return;
@@ -1,53 +1 @@
1
- import { NormalizedSchema } from "@smithy/core/schema";
2
- export const copyDocumentWithTransform = (source, schemaRef, transform = (_) => _) => {
3
- const ns = NormalizedSchema.of(schemaRef);
4
- switch (typeof source) {
5
- case "undefined":
6
- case "boolean":
7
- case "number":
8
- case "string":
9
- case "bigint":
10
- case "symbol":
11
- return transform(source, ns);
12
- case "function":
13
- case "object":
14
- if (source === null) {
15
- return transform(null, ns);
16
- }
17
- if (Array.isArray(source)) {
18
- const newArray = new Array(source.length);
19
- let i = 0;
20
- for (const item of source) {
21
- newArray[i++] = copyDocumentWithTransform(item, ns.getValueSchema(), transform);
22
- }
23
- return transform(newArray, ns);
24
- }
25
- if ("byteLength" in source) {
26
- const newBytes = new Uint8Array(source.byteLength);
27
- newBytes.set(source, 0);
28
- return transform(newBytes, ns);
29
- }
30
- if (source instanceof Date) {
31
- return transform(source, ns);
32
- }
33
- const newObject = {};
34
- if (ns.isMapSchema()) {
35
- for (const key of Object.keys(source)) {
36
- newObject[key] = copyDocumentWithTransform(source[key], ns.getValueSchema(), transform);
37
- }
38
- }
39
- else if (ns.isStructSchema()) {
40
- for (const [key, memberSchema] of ns.structIterator()) {
41
- newObject[key] = copyDocumentWithTransform(source[key], memberSchema, transform);
42
- }
43
- }
44
- else if (ns.isDocumentSchema()) {
45
- for (const key of Object.keys(source)) {
46
- newObject[key] = copyDocumentWithTransform(source[key], ns.getValueSchema(), transform);
47
- }
48
- }
49
- return transform(newObject, ns);
50
- default:
51
- return transform(source, ns);
52
- }
53
- };
1
+ export const copyDocumentWithTransform = (source, schemaRef, transform = (_) => _) => source;
@@ -0,0 +1,2 @@
1
+ import { v4 as generateIdempotencyToken } from "uuid";
2
+ export { generateIdempotencyToken };
@@ -1,5 +1,6 @@
1
1
  export * from "./copyDocumentWithTransform";
2
2
  export * from "./date-utils";
3
+ export * from "./generateIdempotencyToken";
3
4
  export * from "./lazy-json";
4
5
  export * from "./parse-utils";
5
6
  export * from "./quote-header";
@@ -1,4 +1,4 @@
1
- import { Codec, Schema, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
1
+ import type { Codec, Schema, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
2
2
  /**
3
3
  * @alpha
4
4
  */
@@ -16,6 +16,11 @@ export declare class CborShapeSerializer implements ShapeSerializer {
16
16
  private value;
17
17
  setSerdeContext(serdeContext: SerdeFunctions): void;
18
18
  write(schema: Schema, value: unknown): void;
19
+ /**
20
+ * Recursive serializer transform that copies and prepares the user input object
21
+ * for CBOR serialization.
22
+ */
23
+ serialize(schema: Schema, source: unknown): any;
19
24
  flush(): Uint8Array;
20
25
  }
21
26
  /**
@@ -25,5 +30,9 @@ export declare class CborShapeDeserializer implements ShapeDeserializer {
25
30
  private serdeContext?;
26
31
  setSerdeContext(serdeContext: SerdeFunctions): void;
27
32
  read(schema: Schema, bytes: Uint8Array): any;
28
- private readValue;
33
+ /**
34
+ * Public because it's called by the protocol implementation to deserialize errors.
35
+ * @internal
36
+ */
37
+ readValue(_schema: Schema, value: any): any;
29
38
  }
@@ -19,4 +19,5 @@ export declare class SmithyRpcV2CborProtocol extends RpcProtocol {
19
19
  serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
20
20
  deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
21
21
  protected handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
22
+ protected getDefaultContentType(): string;
22
23
  }
@@ -1,5 +1,5 @@
1
1
  import { HttpRequest as __HttpRequest } from "@smithy/protocol-http";
2
- import { HeaderBag as __HeaderBag, HttpResponse, SerdeContext as __SerdeContext, SerdeContext } from "@smithy/types";
2
+ import type { HeaderBag as __HeaderBag, HttpResponse, SerdeContext as __SerdeContext, SerdeContext } from "@smithy/types";
3
3
  import { tagSymbol } from "./cbor-types";
4
4
  /**
5
5
  * @internal
@@ -0,0 +1,60 @@
1
+ import { NormalizedSchema } from "@smithy/core/schema";
2
+ import type { EventStreamMarshaller, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
3
+ /**
4
+ * Separated module for async mixin of EventStream serde capability.
5
+ * This is used by the HttpProtocol base class from \@smithy/core/protocols.
6
+ *
7
+ * @alpha
8
+ */
9
+ export declare class EventStreamSerde {
10
+ private readonly marshaller;
11
+ private readonly serializer;
12
+ private readonly deserializer;
13
+ private readonly serdeContext?;
14
+ private readonly defaultContentType;
15
+ /**
16
+ * Properties are injected by the HttpProtocol.
17
+ */
18
+ constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }: {
19
+ marshaller: EventStreamMarshaller;
20
+ serializer: ShapeSerializer<string | Uint8Array>;
21
+ deserializer: ShapeDeserializer<string | Uint8Array>;
22
+ serdeContext?: SerdeFunctions;
23
+ defaultContentType: string;
24
+ });
25
+ /**
26
+ * @param eventStream - the iterable provided by the caller.
27
+ * @param requestSchema - the schema of the event stream container (struct).
28
+ * @param [initialRequest] - only provided if the initial-request is part of the event stream (RPC).
29
+ *
30
+ * @returns a stream suitable for the HTTP body of a request.
31
+ */
32
+ serializeEventStream({ eventStream, requestSchema, initialRequest, }: {
33
+ eventStream: AsyncIterable<any>;
34
+ requestSchema: NormalizedSchema;
35
+ initialRequest?: any;
36
+ }): Promise<IHttpRequest["body"] | Uint8Array>;
37
+ /**
38
+ * @param response - http response from which to read the event stream.
39
+ * @param unionSchema - schema of the event stream container (struct).
40
+ * @param [initialResponseContainer] - provided and written to only if the initial response is part of the event stream (RPC).
41
+ *
42
+ * @returns the asyncIterable of the event stream for the end-user.
43
+ */
44
+ deserializeEventStream({ response, responseSchema, initialResponseContainer, }: {
45
+ response: IHttpResponse;
46
+ responseSchema: NormalizedSchema;
47
+ initialResponseContainer?: any;
48
+ }): Promise<AsyncIterable<{
49
+ [key: string]: any;
50
+ $unknown?: unknown;
51
+ }>>;
52
+ /**
53
+ * @param unionMember - member name within the structure that contains an event stream union.
54
+ * @param unionSchema - schema of the union.
55
+ * @param event
56
+ *
57
+ * @returns the event body (bytes) and event type (string).
58
+ */
59
+ private writeEventBody;
60
+ }
@@ -0,0 +1 @@
1
+ export * from "./EventStreamSerde";
@@ -1,6 +1,6 @@
1
1
  import { NormalizedSchema } from "@smithy/core/schema";
2
2
  import { HttpRequest } from "@smithy/protocol-http";
3
- import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, SerdeFunctions } from "@smithy/types";
3
+ import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, Schema, SerdeFunctions } from "@smithy/types";
4
4
  import { HttpProtocol } from "./HttpProtocol";
5
5
  /**
6
6
  * Base for HTTP-binding protocols. Downstream examples
@@ -12,4 +12,12 @@ export declare abstract class HttpBindingProtocol extends HttpProtocol {
12
12
  serializeRequest<Input extends object>(operationSchema: OperationSchema, _input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
13
13
  protected serializeQuery(ns: NormalizedSchema, data: any, query: HttpRequest["query"]): void;
14
14
  deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
15
+ /**
16
+ * The base method ignores HTTP bindings.
17
+ *
18
+ * @deprecated (only this signature) use signature without headerBindings.
19
+ * @override
20
+ */
21
+ protected deserializeHttpMessage(schema: Schema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, headerBindings: Set<string>, dataObject: any): Promise<string[]>;
22
+ protected deserializeHttpMessage(schema: Schema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any): Promise<string[]>;
15
23
  }
@@ -1,4 +1,6 @@
1
- import { ClientProtocol, Codec, Endpoint, EndpointBearer, EndpointV2, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, Schema, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
1
+ import type { EventStreamSerde } from "@smithy/core/event-streams";
2
+ import { NormalizedSchema } from "@smithy/core/schema";
3
+ import type { ClientProtocol, Codec, Endpoint, EndpointBearer, EndpointV2, EventStreamMarshaller, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, Schema, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
2
4
  /**
3
5
  * Abstract base for HTTP-based client protocols.
4
6
  *
@@ -26,8 +28,46 @@ export declare abstract class HttpProtocol implements ClientProtocol<IHttpReques
26
28
  protected abstract handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
27
29
  protected deserializeMetadata(output: IHttpResponse): ResponseMetadata;
28
30
  /**
29
- * @deprecated use signature without headerBindings.
31
+ * @param eventStream - the iterable provided by the caller.
32
+ * @param requestSchema - the schema of the event stream container (struct).
33
+ * @param [initialRequest] - only provided if the initial-request is part of the event stream (RPC).
34
+ *
35
+ * @returns a stream suitable for the HTTP body of a request.
36
+ */
37
+ protected serializeEventStream({ eventStream, requestSchema, initialRequest, }: {
38
+ eventStream: AsyncIterable<any>;
39
+ requestSchema: NormalizedSchema;
40
+ initialRequest?: any;
41
+ }): Promise<IHttpRequest["body"]>;
42
+ /**
43
+ * @param response - http response from which to read the event stream.
44
+ * @param unionSchema - schema of the event stream container (struct).
45
+ * @param [initialResponseContainer] - provided and written to only if the initial response is part of the event stream (RPC).
46
+ *
47
+ * @returns the asyncIterable of the event stream.
48
+ */
49
+ protected deserializeEventStream({ response, responseSchema, initialResponseContainer, }: {
50
+ response: IHttpResponse;
51
+ responseSchema: NormalizedSchema;
52
+ initialResponseContainer?: any;
53
+ }): Promise<AsyncIterable<{
54
+ [key: string]: any;
55
+ $unknown?: unknown;
56
+ }>>;
57
+ /**
58
+ * Loads eventStream capability async (for chunking).
59
+ */
60
+ protected loadEventStreamCapability(): Promise<EventStreamSerde>;
61
+ /**
62
+ * @returns content-type default header value for event stream events and other documents.
63
+ */
64
+ protected getDefaultContentType(): string;
65
+ /**
66
+ * For HTTP binding protocols, this method is overridden in {@link HttpBindingProtocol}.
67
+ *
68
+ * @deprecated only use this for HTTP binding protocols.
30
69
  */
31
70
  protected deserializeHttpMessage(schema: Schema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, headerBindings: Set<string>, dataObject: any): Promise<string[]>;
32
71
  protected deserializeHttpMessage(schema: Schema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any): Promise<string[]>;
72
+ protected getEventStreamMarshaller(): EventStreamMarshaller;
33
73
  }
@@ -1,4 +1,4 @@
1
- import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, SerdeFunctions } from "@smithy/types";
1
+ import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, SerdeFunctions } from "@smithy/types";
2
2
  import { HttpProtocol } from "./HttpProtocol";
3
3
  /**
4
4
  * Abstract base for RPC-over-HTTP protocols.
@@ -1,6 +1,7 @@
1
1
  export * from "./collect-stream-body";
2
2
  export * from "./extended-encode-uri-component";
3
3
  export * from "./HttpBindingProtocol";
4
+ export * from "./HttpProtocol";
4
5
  export * from "./RpcProtocol";
5
6
  export * from "./requestBuilder";
6
7
  export * from "./resolve-path";
@@ -1,4 +1,4 @@
1
- import { CodecSettings, Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
1
+ import type { CodecSettings, Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
2
2
  /**
3
3
  * This deserializer reads strings.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { CodecSettings, Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
1
+ import type { CodecSettings, Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
2
2
  /**
3
3
  * This deserializer is a dispatcher that decides whether to use a string deserializer
4
4
  * or a codec deserializer based on HTTP traits.
@@ -1,4 +1,4 @@
1
- import { CodecSettings, Schema as ISchema, SerdeFunctions, ShapeSerializer } from "@smithy/types";
1
+ import type { CodecSettings, Schema as ISchema, SerdeFunctions, ShapeSerializer } from "@smithy/types";
2
2
  import { ToStringShapeSerializer } from "./ToStringShapeSerializer";
3
3
  /**
4
4
  * This serializer decides whether to dispatch to a string serializer or a codec serializer
@@ -1,4 +1,4 @@
1
- import { CodecSettings, Schema, SerdeFunctions, ShapeSerializer } from "@smithy/types";
1
+ import type { CodecSettings, Schema, SerdeFunctions, ShapeSerializer } from "@smithy/types";
2
2
  /**
3
3
  * Serializes a shape to string.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { NormalizedSchema } from "@smithy/core/schema";
2
- import { type TimestampDateTimeSchema, type TimestampEpochSecondsSchema, type TimestampHttpDateSchema, CodecSettings } from "@smithy/types";
2
+ import type { CodecSettings, TimestampDateTimeSchema, TimestampEpochSecondsSchema, TimestampHttpDateSchema } from "@smithy/types";
3
3
  /**
4
4
  * Assuming the schema is a timestamp type, the function resolves the format using
5
5
  * either the timestamp's own traits, or the default timestamp format from the CodecSettings.
@@ -1,4 +1,4 @@
1
- import { DeserializeHandlerOptions, MetadataBearer, Pluggable, SerializeHandlerOptions } from "@smithy/types";
1
+ import type { DeserializeHandlerOptions, MetadataBearer, Pluggable, SerializeHandlerOptions } from "@smithy/types";
2
2
  import { PreviouslyResolved } from "./schema-middleware-types";
3
3
  /**
4
4
  * @internal
@@ -1,4 +1,4 @@
1
- import { DeserializeHandler, DeserializeHandlerArguments, HandlerExecutionContext } from "@smithy/types";
1
+ import type { DeserializeHandler, DeserializeHandlerArguments, HandlerExecutionContext } from "@smithy/types";
2
2
  import { PreviouslyResolved } from "./schema-middleware-types";
3
3
  /**
4
4
  * @internal
@@ -66,6 +66,11 @@ export declare class NormalizedSchema implements INormalizedSchema {
66
66
  isBigIntegerSchema(): boolean;
67
67
  isBigDecimalSchema(): boolean;
68
68
  isStreaming(): boolean;
69
+ /**
70
+ * This is a shortcut to avoid calling `getMergedTraits().idempotencyToken` on every string.
71
+ * @returns whether the schema has the idempotencyToken trait.
72
+ */
73
+ isIdempotencyToken(): boolean;
69
74
  /**
70
75
  * @returns own traits merged with member traits, where member traits of the same trait key take priority.
71
76
  * This method is cached.
@@ -93,6 +98,11 @@ export declare class NormalizedSchema implements INormalizedSchema {
93
98
  * @throws Error if the schema is not a Map, List, nor Document.
94
99
  */
95
100
  getValueSchema(): NormalizedSchema;
101
+ /**
102
+ * @param member - to query.
103
+ * @returns whether there is a memberSchema with the given member name. False if not a structure (or union).
104
+ */
105
+ hasMemberSchema(member: string): boolean;
96
106
  /**
97
107
  * @returns the NormalizedSchema for the given member name. The returned instance will return true for `isMemberSchema()`
98
108
  * and will have the member name given.
@@ -111,6 +121,11 @@ export declare class NormalizedSchema implements INormalizedSchema {
111
121
  * @returns a map of member names to member schemas (normalized).
112
122
  */
113
123
  getMemberSchemas(): Record<string, NormalizedSchema>;
124
+ /**
125
+ * @returns member name of event stream or empty string indicating none exists or this
126
+ * isn't a structure schema.
127
+ */
128
+ getEventStreamMember(): string;
114
129
  /**
115
130
  * Allows iteration over members of a structure schema.
116
131
  * Each yield is a pair of the member name and member schema.
@@ -1,4 +1,4 @@
1
- import { SchemaRef, SchemaTraits, TraitsSchema } from "@smithy/types";
1
+ import type { SchemaRef, SchemaTraits, TraitsSchema } from "@smithy/types";
2
2
  import { Schema } from "./Schema";
3
3
  /**
4
4
  * Although numeric values exist for most simple schema, this class is used for cases where traits are
@@ -1,4 +1,4 @@
1
- import { BigDecimalSchema, BigIntegerSchema, BlobSchema, BooleanSchema, DocumentSchema, ListSchemaModifier, MapSchemaModifier, NumericSchema, StreamingBlobSchema, StringSchema, TimestampDateTimeSchema, TimestampDefaultSchema, TimestampEpochSecondsSchema, TimestampHttpDateSchema } from "@smithy/types";
1
+ import type { BigDecimalSchema, BigIntegerSchema, BlobSchema, BooleanSchema, DocumentSchema, ListSchemaModifier, MapSchemaModifier, NumericSchema, StreamingBlobSchema, StringSchema, TimestampDateTimeSchema, TimestampDefaultSchema, TimestampEpochSecondsSchema, TimestampHttpDateSchema } from "@smithy/types";
2
2
  /**
3
3
  * Schema sentinel runtime values.
4
4
  * @alpha
@@ -1,5 +1,6 @@
1
- import { SchemaRef } from "@smithy/types";
1
+ import type { SchemaRef } from "@smithy/types";
2
2
  /**
3
3
  * @internal
4
+ * @deprecated the former functionality has been internalized to the CborCodec.
4
5
  */
5
6
  export declare const copyDocumentWithTransform: (source: any, schemaRef: SchemaRef, transform?: (_: any, schemaRef: SchemaRef) => any) => any;