@cdk8s/awscdk-resolver 0.0.348 → 0.0.349

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 (57) hide show
  1. package/.jsii +2 -2
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +44 -15
  4. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +261 -0
  5. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +129 -39
  6. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +25 -0
  7. package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +36 -15
  8. package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +200 -0
  9. package/node_modules/@smithy/core/dist-es/submodules/event-streams/index.js +1 -0
  10. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +11 -26
  11. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +36 -0
  12. package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +36 -10
  13. package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +1 -0
  14. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +17 -0
  15. package/node_modules/@smithy/core/dist-types/submodules/cbor/CborCodec.d.ts +6 -2
  16. package/node_modules/@smithy/core/dist-types/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +1 -0
  17. package/node_modules/@smithy/core/dist-types/submodules/cbor/parseCborBody.d.ts +1 -1
  18. package/node_modules/@smithy/core/dist-types/submodules/event-streams/EventStreamSerde.d.ts +60 -0
  19. package/node_modules/@smithy/core/dist-types/submodules/event-streams/index.d.ts +1 -0
  20. package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
  21. package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpProtocol.d.ts +39 -1
  22. package/node_modules/@smithy/core/dist-types/submodules/protocols/RpcProtocol.d.ts +1 -1
  23. package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +1 -0
  24. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +1 -1
  25. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +1 -1
  26. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +1 -1
  27. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/ToStringShapeSerializer.d.ts +1 -1
  28. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/determineTimestampFormat.d.ts +1 -1
  29. package/node_modules/@smithy/core/dist-types/submodules/schema/middleware/getSchemaSerdePlugin.d.ts +1 -1
  30. package/node_modules/@smithy/core/dist-types/submodules/schema/middleware/schemaDeserializationMiddleware.d.ts +1 -1
  31. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +10 -0
  32. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +1 -1
  33. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/sentinels.d.ts +1 -1
  34. package/node_modules/@smithy/core/dist-types/submodules/serde/copyDocumentWithTransform.d.ts +1 -1
  35. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/CborCodec.d.ts +5 -1
  36. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +1 -0
  37. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/event-streams/EventStreamSerde.d.ts +60 -0
  38. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/event-streams/index.d.ts +1 -0
  39. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +39 -1
  40. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
  41. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/determineTimestampFormat.d.ts +1 -1
  42. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +10 -0
  43. package/node_modules/@smithy/core/event-streams.d.ts +7 -0
  44. package/node_modules/@smithy/core/event-streams.js +6 -0
  45. package/node_modules/@smithy/core/package.json +11 -1
  46. package/node_modules/@smithy/middleware-endpoint/package.json +2 -2
  47. package/node_modules/@smithy/middleware-retry/package.json +4 -4
  48. package/node_modules/@smithy/smithy-client/dist-cjs/index.js +43 -6
  49. package/node_modules/@smithy/smithy-client/dist-cjs/schemaLogFilter.js +1 -0
  50. package/node_modules/@smithy/smithy-client/dist-es/command.js +7 -4
  51. package/node_modules/@smithy/smithy-client/dist-es/schemaLogFilter.js +34 -0
  52. package/node_modules/@smithy/smithy-client/dist-types/schemaLogFilter.d.ts +9 -0
  53. package/node_modules/@smithy/smithy-client/dist-types/ts3.4/schemaLogFilter.d.ts +9 -0
  54. package/node_modules/@smithy/smithy-client/package.json +3 -3
  55. package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
  56. package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
  57. package/package.json +3 -3
package/.jsii CHANGED
@@ -4082,6 +4082,6 @@
4082
4082
  "symbolId": "src/resolve:AwsCdkResolver"
4083
4083
  }
4084
4084
  },
4085
- "version": "0.0.348",
4086
- "fingerprint": "4oLXJxuZ4msooUQiut6oA6GZde7/YahIKTLTwjnToEQ="
4085
+ "version": "0.0.349",
4086
+ "fingerprint": "Ssh81c6YE8Axive49bo4YXXwtDDOlA0INDClwcrheUM="
4087
4087
  }
package/lib/resolve.js CHANGED
@@ -61,5 +61,5 @@ class AwsCdkResolver {
61
61
  }
62
62
  exports.AwsCdkResolver = AwsCdkResolver;
63
63
  _a = JSII_RTTI_SYMBOL_1;
64
- AwsCdkResolver[_a] = { fqn: "@cdk8s/awscdk-resolver.AwsCdkResolver", version: "0.0.348" };
64
+ AwsCdkResolver[_a] = { f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GNhbiBoYXBwZW4gaWYgZWl0aGVyOlxuICAgIC8vIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tXG4gICAgLy8gIDEuIFVzZXIgZGlkbid0IGRlZmluZSBhbiBvdXRwdXQuXG4gICAgLy8gIDIuIE91dHB1dCB3YXMgZGVmaW5lZCBpbiBhIGRpZmZlcmVudCBzdGFjayB0aGFuIHRoZSB0b2tlbnMgY29tcHJpc2luZyBpdHMgdmFsdWUuXG4gICAgLy8gIDMuIE5vbmUgb2YgdGhlIHRva2VucyBjb21wcmlzaW5nIHRoZSB2YWx1ZSBhcmUgYSBSZWZlcmVuY2UuXG4gICAgdGhyb3cgbmV3IEVycm9yKGBVbmFibGUgdG8gZmluZCBvdXRwdXQgZGVmaW5lZCBmb3IgJHt2YWx1ZX0gKEluc3BlY3RlZCBzdGFja3M6ICR7aW5zcGVjdGVkU3RhY2tzLm1hcChzID0+IHMuc3RhY2tOYW1lKS5qb2luKCcsJyl9KWApO1xuXG4gIH1cblxuICBwcml2YXRlIGZldGNoT3V0cHV0VmFsdWUob3V0cHV0OiBDZm5PdXRwdXQpIHtcblxuICAgIGNvbnN0IHNjcmlwdCA9IHBhdGguam9pbihfX2Rpcm5hbWUsICcuLicsICdsaWInLCAnZmV0Y2gtb3V0cHV0LXZhbHVlLmpzJyk7XG4gICAgcmV0dXJuIEpTT04ucGFyc2UoZXhlY0ZpbGVTeW5jKHByb2Nlc3MuZXhlY1BhdGgsIFtcbiAgICAgIHNjcmlwdCxcbiAgICAgIFN0YWNrLm9mKG91dHB1dCkuc3RhY2tOYW1lLFxuICAgICAgb3V0cHV0Lm5vZGUuaWQsXG4gICAgXSwgeyBlbmNvZGluZzogJ3V0Zi04Jywgc3RkaW86IFsncGlwZSddIH0pLnRvU3RyaW5nKCkudHJpbSgpKTtcblxuICB9XG5cbn1cbiJdfQ==
@@ -895,6 +895,10 @@ var CborShapeDeserializer = class {
895
895
  const data2 = cbor.deserialize(bytes);
896
896
  return this.readValue(schema, data2);
897
897
  }
898
+ /**
899
+ * Public because it's called by the protocol implementation to deserialize errors.
900
+ * @internal
901
+ */
898
902
  readValue(_schema, value) {
899
903
  const ns = import_schema.NormalizedSchema.of(_schema);
900
904
  if (ns.isTimestampSchema() && typeof value === "number") {
@@ -972,9 +976,9 @@ var SmithyRpcV2CborProtocol = class extends import_protocols2.RpcProtocol {
972
976
  async serializeRequest(operationSchema, input, context) {
973
977
  const request = await super.serializeRequest(operationSchema, input, context);
974
978
  Object.assign(request.headers, {
975
- "content-type": "application/cbor",
979
+ "content-type": this.getDefaultContentType(),
976
980
  "smithy-protocol": "rpc-v2-cbor",
977
- accept: "application/cbor"
981
+ accept: this.getDefaultContentType()
978
982
  });
979
983
  if ((0, import_schema2.deref)(operationSchema.input) === "unit") {
980
984
  delete request.body;
@@ -1002,25 +1006,50 @@ var SmithyRpcV2CborProtocol = class extends import_protocols2.RpcProtocol {
1002
1006
  return super.deserializeResponse(operationSchema, context, response);
1003
1007
  }
1004
1008
  async handleError(operationSchema, context, response, dataObject, metadata) {
1005
- const error = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
1009
+ const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
1006
1010
  let namespace = this.options.defaultNamespace;
1007
- if (error.includes("#")) {
1008
- [namespace] = error.split("#");
1011
+ if (errorName.includes("#")) {
1012
+ [namespace] = errorName.split("#");
1009
1013
  }
1014
+ const errorMetadata = {
1015
+ $metadata: metadata,
1016
+ $response: response,
1017
+ $fault: response.statusCode <= 500 ? "client" : "server"
1018
+ };
1010
1019
  const registry = import_schema2.TypeRegistry.for(namespace);
1011
- const errorSchema = registry.getSchema(error);
1012
- if (!errorSchema) {
1013
- throw new Error("schema not found for " + error);
1020
+ let errorSchema;
1021
+ try {
1022
+ errorSchema = registry.getSchema(errorName);
1023
+ } catch (e) {
1024
+ if (dataObject.Message) {
1025
+ dataObject.message = dataObject.Message;
1026
+ }
1027
+ const baseExceptionSchema = import_schema2.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
1028
+ if (baseExceptionSchema) {
1029
+ const ErrorCtor = baseExceptionSchema.ctor;
1030
+ throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
1031
+ }
1032
+ throw Object.assign(new Error(errorName), errorMetadata, dataObject);
1014
1033
  }
1034
+ const ns = import_schema2.NormalizedSchema.of(errorSchema);
1015
1035
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
1016
1036
  const exception = new errorSchema.ctor(message);
1017
- Object.assign(exception, {
1018
- $metadata: metadata,
1019
- $response: response,
1020
- message,
1021
- ...dataObject
1022
- });
1023
- throw exception;
1037
+ const output = {};
1038
+ for (const [name, member] of ns.structIterator()) {
1039
+ output[name] = this.deserializer.readValue(member, dataObject[name]);
1040
+ }
1041
+ throw Object.assign(
1042
+ exception,
1043
+ errorMetadata,
1044
+ {
1045
+ $fault: ns.getMergedTraits().error,
1046
+ message
1047
+ },
1048
+ output
1049
+ );
1050
+ }
1051
+ getDefaultContentType() {
1052
+ return "application/cbor";
1024
1053
  }
1025
1054
  };
1026
1055
  // Annotate the CommonJS export names for ESM import in node:
@@ -0,0 +1,261 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/submodules/event-streams/index.ts
20
+ var event_streams_exports = {};
21
+ __export(event_streams_exports, {
22
+ EventStreamSerde: () => EventStreamSerde
23
+ });
24
+ module.exports = __toCommonJS(event_streams_exports);
25
+
26
+ // src/submodules/event-streams/EventStreamSerde.ts
27
+ var import_schema = require("@smithy/core/schema");
28
+ var import_util_utf8 = require("@smithy/util-utf8");
29
+ var EventStreamSerde = class {
30
+ /**
31
+ * Properties are injected by the HttpProtocol.
32
+ */
33
+ constructor({
34
+ marshaller,
35
+ serializer,
36
+ deserializer,
37
+ serdeContext,
38
+ defaultContentType
39
+ }) {
40
+ this.marshaller = marshaller;
41
+ this.serializer = serializer;
42
+ this.deserializer = deserializer;
43
+ this.serdeContext = serdeContext;
44
+ this.defaultContentType = defaultContentType;
45
+ }
46
+ /**
47
+ * @param eventStream - the iterable provided by the caller.
48
+ * @param requestSchema - the schema of the event stream container (struct).
49
+ * @param [initialRequest] - only provided if the initial-request is part of the event stream (RPC).
50
+ *
51
+ * @returns a stream suitable for the HTTP body of a request.
52
+ */
53
+ async serializeEventStream({
54
+ eventStream,
55
+ requestSchema,
56
+ initialRequest
57
+ }) {
58
+ const marshaller = this.marshaller;
59
+ const eventStreamMember = requestSchema.getEventStreamMember();
60
+ const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
61
+ const memberSchemas = unionSchema.getMemberSchemas();
62
+ const serializer = this.serializer;
63
+ const defaultContentType = this.defaultContentType;
64
+ const initialRequestMarker = Symbol("initialRequestMarker");
65
+ const eventStreamIterable = {
66
+ async *[Symbol.asyncIterator]() {
67
+ if (initialRequest) {
68
+ const headers = {
69
+ ":event-type": { type: "string", value: "initial-request" },
70
+ ":message-type": { type: "string", value: "event" },
71
+ ":content-type": { type: "string", value: defaultContentType }
72
+ };
73
+ serializer.write(requestSchema, initialRequest);
74
+ const body = serializer.flush();
75
+ yield {
76
+ [initialRequestMarker]: true,
77
+ headers,
78
+ body
79
+ };
80
+ }
81
+ for await (const page of eventStream) {
82
+ yield page;
83
+ }
84
+ }
85
+ };
86
+ return marshaller.serialize(eventStreamIterable, (event) => {
87
+ if (event[initialRequestMarker]) {
88
+ return {
89
+ headers: event.headers,
90
+ body: event.body
91
+ };
92
+ }
93
+ const unionMember = Object.keys(event).find((key) => {
94
+ return key !== "__type";
95
+ }) ?? "";
96
+ const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(
97
+ unionMember,
98
+ unionSchema,
99
+ event
100
+ );
101
+ const headers = {
102
+ ":event-type": { type: "string", value: eventType },
103
+ ":message-type": { type: "string", value: "event" },
104
+ ":content-type": { type: "string", value: explicitPayloadContentType ?? defaultContentType },
105
+ ...additionalHeaders
106
+ };
107
+ return {
108
+ headers,
109
+ body
110
+ };
111
+ });
112
+ }
113
+ /**
114
+ * @param response - http response from which to read the event stream.
115
+ * @param unionSchema - schema of the event stream container (struct).
116
+ * @param [initialResponseContainer] - provided and written to only if the initial response is part of the event stream (RPC).
117
+ *
118
+ * @returns the asyncIterable of the event stream for the end-user.
119
+ */
120
+ async deserializeEventStream({
121
+ response,
122
+ responseSchema,
123
+ initialResponseContainer
124
+ }) {
125
+ const marshaller = this.marshaller;
126
+ const eventStreamMember = responseSchema.getEventStreamMember();
127
+ const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
128
+ const memberSchemas = unionSchema.getMemberSchemas();
129
+ const initialResponseMarker = Symbol("initialResponseMarker");
130
+ const asyncIterable = marshaller.deserialize(response.body, async (event) => {
131
+ const unionMember = Object.keys(event).find((key) => {
132
+ return key !== "__type";
133
+ }) ?? "";
134
+ if (unionMember === "initial-response") {
135
+ const dataObject = await this.deserializer.read(responseSchema, event[unionMember].body);
136
+ delete dataObject[eventStreamMember];
137
+ return {
138
+ [initialResponseMarker]: true,
139
+ ...dataObject
140
+ };
141
+ } else if (unionMember in memberSchemas) {
142
+ const eventStreamSchema = memberSchemas[unionMember];
143
+ return {
144
+ [unionMember]: await this.deserializer.read(eventStreamSchema, event[unionMember].body)
145
+ };
146
+ } else {
147
+ return {
148
+ $unknown: event
149
+ };
150
+ }
151
+ });
152
+ const asyncIterator = asyncIterable[Symbol.asyncIterator]();
153
+ const firstEvent = await asyncIterator.next();
154
+ if (firstEvent.done) {
155
+ return asyncIterable;
156
+ }
157
+ if (firstEvent.value?.[initialResponseMarker]) {
158
+ if (!responseSchema) {
159
+ throw new Error(
160
+ "@smithy::core/protocols - initial-response event encountered in event stream but no response schema given."
161
+ );
162
+ }
163
+ for (const [key, value] of Object.entries(firstEvent.value)) {
164
+ initialResponseContainer[key] = value;
165
+ }
166
+ }
167
+ return {
168
+ async *[Symbol.asyncIterator]() {
169
+ if (!firstEvent?.value?.[initialResponseMarker]) {
170
+ yield firstEvent.value;
171
+ }
172
+ while (true) {
173
+ const { done, value } = await asyncIterator.next();
174
+ if (done) {
175
+ break;
176
+ }
177
+ yield value;
178
+ }
179
+ }
180
+ };
181
+ }
182
+ /**
183
+ * @param unionMember - member name within the structure that contains an event stream union.
184
+ * @param unionSchema - schema of the union.
185
+ * @param event
186
+ *
187
+ * @returns the event body (bytes) and event type (string).
188
+ */
189
+ writeEventBody(unionMember, unionSchema, event) {
190
+ const serializer = this.serializer;
191
+ let eventType = unionMember;
192
+ let explicitPayloadMember = null;
193
+ let explicitPayloadContentType;
194
+ const isKnownSchema = unionSchema.hasMemberSchema(unionMember);
195
+ const additionalHeaders = {};
196
+ if (!isKnownSchema) {
197
+ const [type, value] = event[unionMember];
198
+ eventType = type;
199
+ serializer.write(import_schema.SCHEMA.DOCUMENT, value);
200
+ } else {
201
+ const eventSchema = unionSchema.getMemberSchema(unionMember);
202
+ if (eventSchema.isStructSchema()) {
203
+ for (const [memberName, memberSchema] of eventSchema.structIterator()) {
204
+ const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
205
+ if (eventPayload) {
206
+ explicitPayloadMember = memberName;
207
+ break;
208
+ } else if (eventHeader) {
209
+ const value = event[unionMember][memberName];
210
+ let type = "binary";
211
+ if (memberSchema.isNumericSchema()) {
212
+ if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
213
+ type = "integer";
214
+ } else {
215
+ type = "long";
216
+ }
217
+ } else if (memberSchema.isTimestampSchema()) {
218
+ type = "timestamp";
219
+ } else if (memberSchema.isStringSchema()) {
220
+ type = "string";
221
+ } else if (memberSchema.isBooleanSchema()) {
222
+ type = "boolean";
223
+ }
224
+ if (value != null) {
225
+ additionalHeaders[memberName] = {
226
+ type,
227
+ value
228
+ };
229
+ delete event[unionMember][memberName];
230
+ }
231
+ }
232
+ }
233
+ if (explicitPayloadMember !== null) {
234
+ const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
235
+ if (payloadSchema.isBlobSchema()) {
236
+ explicitPayloadContentType = "application/octet-stream";
237
+ } else if (payloadSchema.isStringSchema()) {
238
+ explicitPayloadContentType = "text/plain";
239
+ }
240
+ serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
241
+ } else {
242
+ serializer.write(eventSchema, event[unionMember]);
243
+ }
244
+ } else {
245
+ throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
246
+ }
247
+ }
248
+ const messageSerialization = serializer.flush();
249
+ const body = typeof messageSerialization === "string" ? (this.serdeContext?.utf8Decoder ?? import_util_utf8.fromUtf8)(messageSerialization) : messageSerialization;
250
+ return {
251
+ body,
252
+ eventType,
253
+ explicitPayloadContentType,
254
+ additionalHeaders
255
+ };
256
+ }
257
+ };
258
+ // Annotate the CommonJS export names for ESM import in node:
259
+ 0 && (module.exports = {
260
+ EventStreamSerde
261
+ });
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/submodules/protocols/index.ts
@@ -23,6 +33,7 @@ __export(protocols_exports, {
23
33
  HttpBindingProtocol: () => HttpBindingProtocol,
24
34
  HttpInterceptingShapeDeserializer: () => HttpInterceptingShapeDeserializer,
25
35
  HttpInterceptingShapeSerializer: () => HttpInterceptingShapeSerializer,
36
+ HttpProtocol: () => HttpProtocol,
26
37
  RequestBuilder: () => RequestBuilder,
27
38
  RpcProtocol: () => RpcProtocol,
28
39
  ToStringShapeSerializer: () => ToStringShapeSerializer,
@@ -136,9 +147,75 @@ var HttpProtocol = class {
136
147
  cfId: output.headers["x-amz-cf-id"]
137
148
  };
138
149
  }
150
+ /**
151
+ * @param eventStream - the iterable provided by the caller.
152
+ * @param requestSchema - the schema of the event stream container (struct).
153
+ * @param [initialRequest] - only provided if the initial-request is part of the event stream (RPC).
154
+ *
155
+ * @returns a stream suitable for the HTTP body of a request.
156
+ */
157
+ async serializeEventStream({
158
+ eventStream,
159
+ requestSchema,
160
+ initialRequest
161
+ }) {
162
+ const eventStreamSerde = await this.loadEventStreamCapability();
163
+ return eventStreamSerde.serializeEventStream({
164
+ eventStream,
165
+ requestSchema,
166
+ initialRequest
167
+ });
168
+ }
169
+ /**
170
+ * @param response - http response from which to read the event stream.
171
+ * @param unionSchema - schema of the event stream container (struct).
172
+ * @param [initialResponseContainer] - provided and written to only if the initial response is part of the event stream (RPC).
173
+ *
174
+ * @returns the asyncIterable of the event stream.
175
+ */
176
+ async deserializeEventStream({
177
+ response,
178
+ responseSchema,
179
+ initialResponseContainer
180
+ }) {
181
+ const eventStreamSerde = await this.loadEventStreamCapability();
182
+ return eventStreamSerde.deserializeEventStream({
183
+ response,
184
+ responseSchema,
185
+ initialResponseContainer
186
+ });
187
+ }
188
+ /**
189
+ * Loads eventStream capability async (for chunking).
190
+ */
191
+ async loadEventStreamCapability() {
192
+ const { EventStreamSerde } = await Promise.resolve().then(() => __toESM(require("@smithy/core/event-streams")));
193
+ return new EventStreamSerde({
194
+ marshaller: this.getEventStreamMarshaller(),
195
+ serializer: this.serializer,
196
+ deserializer: this.deserializer,
197
+ serdeContext: this.serdeContext,
198
+ defaultContentType: this.getDefaultContentType()
199
+ });
200
+ }
201
+ /**
202
+ * @returns content-type default header value for event stream events and other documents.
203
+ */
204
+ getDefaultContentType() {
205
+ throw new Error(
206
+ `@smithy/core/protocols - ${this.constructor.name} getDefaultContentType() implementation missing.`
207
+ );
208
+ }
139
209
  async deserializeHttpMessage(schema, context, response, arg4, arg5) {
140
210
  return [];
141
211
  }
212
+ getEventStreamMarshaller() {
213
+ const context = this.serdeContext;
214
+ if (!context.eventStreamMarshaller) {
215
+ throw new Error("@smithy/core - HttpProtocol: eventStreamMarshaller missing in serdeContext.");
216
+ }
217
+ return context.eventStreamMarshaller;
218
+ }
142
219
  };
143
220
 
144
221
  // src/submodules/protocols/HttpBindingProtocol.ts
@@ -192,7 +269,12 @@ var HttpBindingProtocol = class extends HttpProtocol {
192
269
  if (isStreaming) {
193
270
  const isEventStream = memberNs.isStructSchema();
194
271
  if (isEventStream) {
195
- throw new Error("serialization of event streams is not yet implemented");
272
+ if (input[memberName]) {
273
+ payload = await this.serializeEventStream({
274
+ eventStream: input[memberName],
275
+ requestSchema: ns
276
+ });
277
+ }
196
278
  } else {
197
279
  payload = inputMemberValue;
198
280
  }
@@ -307,11 +389,8 @@ var HttpBindingProtocol = class extends HttpProtocol {
307
389
  }
308
390
  }
309
391
  }
310
- const output = {
311
- $metadata: this.deserializeMetadata(response),
312
- ...dataObject
313
- };
314
- return output;
392
+ dataObject.$metadata = this.deserializeMetadata(response);
393
+ return dataObject;
315
394
  }
316
395
  async deserializeHttpMessage(schema, context, response, arg4, arg5) {
317
396
  let dataObject;
@@ -330,25 +409,9 @@ var HttpBindingProtocol = class extends HttpProtocol {
330
409
  if (isStreaming) {
331
410
  const isEventStream = memberSchema.isStructSchema();
332
411
  if (isEventStream) {
333
- const context2 = this.serdeContext;
334
- if (!context2.eventStreamMarshaller) {
335
- throw new Error("@smithy/core - HttpProtocol: eventStreamMarshaller missing in serdeContext.");
336
- }
337
- const memberSchemas = memberSchema.getMemberSchemas();
338
- dataObject[memberName] = context2.eventStreamMarshaller.deserialize(response.body, async (event) => {
339
- const unionMember = Object.keys(event).find((key) => {
340
- return key !== "__type";
341
- }) ?? "";
342
- if (unionMember in memberSchemas) {
343
- const eventStreamSchema = memberSchemas[unionMember];
344
- return {
345
- [unionMember]: await deserializer.read(eventStreamSchema, event[unionMember].body)
346
- };
347
- } else {
348
- return {
349
- $unknown: event
350
- };
351
- }
412
+ dataObject[memberName] = await this.deserializeEventStream({
413
+ response,
414
+ responseSchema: ns
352
415
  });
353
416
  } else {
354
417
  dataObject[memberName] = (0, import_util_stream2.sdkStreamMixin)(response.body);
@@ -430,8 +493,26 @@ var RpcProtocol = class extends HttpProtocol {
430
493
  ...input
431
494
  };
432
495
  if (input) {
433
- serializer.write(schema, _input);
434
- payload = serializer.flush();
496
+ const eventStreamMember = ns.getEventStreamMember();
497
+ if (eventStreamMember) {
498
+ if (_input[eventStreamMember]) {
499
+ const initialRequest = {};
500
+ for (const [memberName, memberSchema] of ns.structIterator()) {
501
+ if (memberName !== eventStreamMember && _input[memberName]) {
502
+ serializer.write(memberSchema, _input[memberName]);
503
+ initialRequest[memberName] = serializer.flush();
504
+ }
505
+ }
506
+ payload = await this.serializeEventStream({
507
+ eventStream: _input[eventStreamMember],
508
+ requestSchema: ns,
509
+ initialRequest
510
+ });
511
+ }
512
+ } else {
513
+ serializer.write(schema, _input);
514
+ payload = serializer.flush();
515
+ }
435
516
  }
436
517
  request.headers = headers;
437
518
  request.query = query;
@@ -444,9 +525,9 @@ var RpcProtocol = class extends HttpProtocol {
444
525
  const ns = import_schema3.NormalizedSchema.of(operationSchema.output);
445
526
  const dataObject = {};
446
527
  if (response.statusCode >= 300) {
447
- const bytes2 = await collectBody(response.body, context);
448
- if (bytes2.byteLength > 0) {
449
- Object.assign(dataObject, await deserializer.read(import_schema3.SCHEMA.DOCUMENT, bytes2));
528
+ const bytes = await collectBody(response.body, context);
529
+ if (bytes.byteLength > 0) {
530
+ Object.assign(dataObject, await deserializer.read(import_schema3.SCHEMA.DOCUMENT, bytes));
450
531
  }
451
532
  await this.handleError(operationSchema, context, response, dataObject, this.deserializeMetadata(response));
452
533
  throw new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.");
@@ -456,15 +537,21 @@ var RpcProtocol = class extends HttpProtocol {
456
537
  delete response.headers[header];
457
538
  response.headers[header.toLowerCase()] = value;
458
539
  }
459
- const bytes = await collectBody(response.body, context);
460
- if (bytes.byteLength > 0) {
461
- Object.assign(dataObject, await deserializer.read(ns, bytes));
540
+ const eventStreamMember = ns.getEventStreamMember();
541
+ if (eventStreamMember) {
542
+ dataObject[eventStreamMember] = await this.deserializeEventStream({
543
+ response,
544
+ responseSchema: ns,
545
+ initialResponseContainer: dataObject
546
+ });
547
+ } else {
548
+ const bytes = await collectBody(response.body, context);
549
+ if (bytes.byteLength > 0) {
550
+ Object.assign(dataObject, await deserializer.read(ns, bytes));
551
+ }
462
552
  }
463
- const output = {
464
- $metadata: this.deserializeMetadata(response),
465
- ...dataObject
466
- };
467
- return output;
553
+ dataObject.$metadata = this.deserializeMetadata(response);
554
+ return dataObject;
468
555
  }
469
556
  };
470
557
 
@@ -721,7 +808,9 @@ var ToStringShapeSerializer = class {
721
808
  if (ns.isTimestampSchema()) {
722
809
  if (!(value instanceof Date)) {
723
810
  throw new Error(
724
- `@smithy/core/protocols - received non-Date value ${value} when schema expected Date in ${ns.getName(true)}`
811
+ `@smithy/core/protocols - received non-Date value ${value} when schema expected Date in ${ns.getName(
812
+ true
813
+ )}`
725
814
  );
726
815
  }
727
816
  const format = determineTimestampFormat(ns, this.settings);
@@ -822,6 +911,7 @@ var HttpInterceptingShapeSerializer = class {
822
911
  HttpBindingProtocol,
823
912
  HttpInterceptingShapeDeserializer,
824
913
  HttpInterceptingShapeSerializer,
914
+ HttpProtocol,
825
915
  RequestBuilder,
826
916
  RpcProtocol,
827
917
  ToStringShapeSerializer,
@@ -748,6 +748,17 @@ var NormalizedSchema = class _NormalizedSchema {
748
748
  }
749
749
  throw new Error(`@smithy/core/schema - the schema ${this.getName(true)} does not have a value member.`);
750
750
  }
751
+ /**
752
+ * @param member - to query.
753
+ * @returns whether there is a memberSchema with the given member name. False if not a structure (or union).
754
+ */
755
+ hasMemberSchema(member) {
756
+ if (this.isStructSchema()) {
757
+ const struct2 = this.getSchema();
758
+ return member in struct2.members;
759
+ }
760
+ return false;
761
+ }
751
762
  /**
752
763
  * @returns the NormalizedSchema for the given member name. The returned instance will return true for `isMemberSchema()`
753
764
  * and will have the member name given.
@@ -794,6 +805,20 @@ var NormalizedSchema = class _NormalizedSchema {
794
805
  }
795
806
  return {};
796
807
  }
808
+ /**
809
+ * @returns member name of event stream or empty string indicating none exists or this
810
+ * isn't a structure schema.
811
+ */
812
+ getEventStreamMember() {
813
+ if (this.isStructSchema()) {
814
+ for (const [memberName, memberSchema] of this.structIterator()) {
815
+ if (memberSchema.isStreaming() && memberSchema.isStructSchema()) {
816
+ return memberName;
817
+ }
818
+ }
819
+ }
820
+ return "";
821
+ }
797
822
  /**
798
823
  * Allows iteration over members of a structure schema.
799
824
  * Each yield is a pair of the member name and member schema.