@jjrawlins/cdk-ami-builder 0.0.51 → 0.0.53

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 (139) hide show
  1. package/.jsii +3 -3
  2. package/cdk-ami-builder/jsii/jsii.go +2 -2
  3. package/cdk-ami-builder/version +1 -1
  4. package/lib/ImagePipeline/ImagePipeline.js +1 -1
  5. package/lib/Lambdas/CheckStateMachineStatus/CheckStateMachineStatus-function.js +1 -1
  6. package/lib/Lambdas/StartStateMachine/StartStateMachine-function.js +1 -1
  7. package/node_modules/@aws-sdk/client-ec2/dist-cjs/endpoint/ruleset.js +1 -1
  8. package/node_modules/@aws-sdk/client-ec2/dist-cjs/index.js +42 -0
  9. package/node_modules/@aws-sdk/client-ec2/dist-es/endpoint/ruleset.js +1 -1
  10. package/node_modules/@aws-sdk/client-ec2/dist-es/models/models_1.js +42 -0
  11. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/CreateCapacityReservationFleetCommand.d.ts +2 -2
  12. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/CreateFleetCommand.d.ts +4 -4
  13. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/CreateLaunchTemplateCommand.d.ts +1 -1
  14. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/CreateLaunchTemplateVersionCommand.d.ts +2 -2
  15. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeCapacityReservationFleetsCommand.d.ts +1 -1
  16. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeFleetsCommand.d.ts +4 -4
  17. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeInstanceImageMetadataCommand.d.ts +1 -1
  18. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeInstanceTypeOfferingsCommand.d.ts +1 -1
  19. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeInstanceTypesCommand.d.ts +2 -2
  20. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeInstancesCommand.d.ts +1 -1
  21. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeLaunchTemplateVersionsCommand.d.ts +1 -1
  22. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeReservedInstancesCommand.d.ts +1 -1
  23. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeReservedInstancesModificationsCommand.d.ts +1 -1
  24. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeReservedInstancesOfferingsCommand.d.ts +2 -2
  25. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeSpotFleetRequestsCommand.d.ts +2 -2
  26. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeSpotInstanceRequestsCommand.d.ts +1 -1
  27. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/DescribeSpotPriceHistoryCommand.d.ts +2 -2
  28. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/GetLaunchTemplateDataCommand.d.ts +1 -1
  29. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/ImportInstanceCommand.d.ts +1 -1
  30. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/ModifyFleetCommand.d.ts +1 -1
  31. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/ModifyReservedInstancesCommand.d.ts +1 -1
  32. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/ModifySpotFleetRequestCommand.d.ts +1 -1
  33. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/RequestSpotFleetCommand.d.ts +2 -2
  34. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/RequestSpotInstancesCommand.d.ts +2 -2
  35. package/node_modules/@aws-sdk/client-ec2/dist-types/commands/RunInstancesCommand.d.ts +2 -2
  36. package/node_modules/@aws-sdk/client-ec2/dist-types/models/models_1.d.ts +42 -0
  37. package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/models/models_1.d.ts +42 -0
  38. package/node_modules/@aws-sdk/client-ec2/package.json +1 -1
  39. package/node_modules/@smithy/abort-controller/package.json +2 -2
  40. package/node_modules/@smithy/config-resolver/package.json +4 -4
  41. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +3 -15
  42. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +16 -14
  43. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +161 -138
  44. package/node_modules/@smithy/core/dist-es/index.js +1 -1
  45. package/node_modules/@smithy/core/dist-es/submodules/cbor/CborCodec.js +4 -15
  46. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +3 -2
  47. package/node_modules/@smithy/core/dist-es/submodules/protocols/SerdeContext.js +6 -0
  48. package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +1 -0
  49. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +3 -5
  50. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/HttpInterceptingShapeDeserializer.js +3 -2
  51. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +3 -5
  52. package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +4 -4
  53. package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js +5 -1
  54. package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js +5 -1
  55. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +24 -6
  56. package/node_modules/@smithy/core/dist-types/index.d.ts +1 -1
  57. package/node_modules/@smithy/core/dist-types/submodules/cbor/CborCodec.d.ts +5 -10
  58. package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpProtocol.d.ts +5 -2
  59. package/node_modules/@smithy/core/dist-types/submodules/protocols/SerdeContext.d.ts +8 -0
  60. package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +1 -0
  61. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +3 -4
  62. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +5 -2
  63. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +5 -2
  64. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/ToStringShapeSerializer.d.ts +3 -4
  65. package/node_modules/@smithy/core/dist-types/submodules/schema/TypeRegistry.d.ts +4 -4
  66. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +22 -1
  67. package/node_modules/@smithy/core/dist-types/ts3.4/index.d.ts +1 -1
  68. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/CborCodec.d.ts +5 -10
  69. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +5 -2
  70. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/SerdeContext.d.ts +8 -0
  71. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
  72. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +3 -4
  73. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +5 -2
  74. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +5 -2
  75. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/ToStringShapeSerializer.d.ts +3 -4
  76. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/TypeRegistry.d.ts +4 -4
  77. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +22 -1
  78. package/node_modules/@smithy/core/package.json +7 -7
  79. package/node_modules/@smithy/credential-provider-imds/package.json +5 -5
  80. package/node_modules/@smithy/eventstream-codec/package.json +2 -2
  81. package/node_modules/@smithy/eventstream-serde-browser/package.json +3 -3
  82. package/node_modules/@smithy/eventstream-serde-config-resolver/package.json +2 -2
  83. package/node_modules/@smithy/eventstream-serde-node/package.json +3 -3
  84. package/node_modules/@smithy/eventstream-serde-universal/package.json +6 -4
  85. package/node_modules/@smithy/fetch-http-handler/package.json +5 -5
  86. package/node_modules/@smithy/hash-blob-browser/package.json +2 -2
  87. package/node_modules/@smithy/hash-node/package.json +2 -2
  88. package/node_modules/@smithy/hash-stream-node/package.json +2 -2
  89. package/node_modules/@smithy/invalid-dependency/package.json +2 -2
  90. package/node_modules/@smithy/md5-js/package.json +3 -3
  91. package/node_modules/@smithy/middleware-content-length/package.json +3 -3
  92. package/node_modules/@smithy/middleware-endpoint/package.json +8 -8
  93. package/node_modules/@smithy/middleware-retry/package.json +8 -8
  94. package/node_modules/@smithy/middleware-serde/package.json +3 -3
  95. package/node_modules/@smithy/middleware-stack/package.json +2 -2
  96. package/node_modules/@smithy/node-config-provider/package.json +4 -4
  97. package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +30 -6
  98. package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +7 -3
  99. package/node_modules/@smithy/node-http-handler/dist-es/set-connection-timeout.js +1 -1
  100. package/node_modules/@smithy/node-http-handler/dist-es/set-request-timeout.js +21 -0
  101. package/node_modules/@smithy/node-http-handler/dist-es/set-socket-timeout.js +2 -3
  102. package/node_modules/@smithy/node-http-handler/dist-types/set-request-timeout.d.ts +6 -0
  103. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-request-timeout.d.ts +6 -0
  104. package/node_modules/@smithy/node-http-handler/package.json +5 -5
  105. package/node_modules/@smithy/property-provider/package.json +2 -2
  106. package/node_modules/@smithy/protocol-http/package.json +2 -2
  107. package/node_modules/@smithy/querystring-builder/package.json +2 -2
  108. package/node_modules/@smithy/querystring-parser/package.json +2 -2
  109. package/node_modules/@smithy/service-error-classification/package.json +2 -2
  110. package/node_modules/@smithy/shared-ini-file-loader/package.json +2 -2
  111. package/node_modules/@smithy/signature-v4/package.json +4 -4
  112. package/node_modules/@smithy/smithy-client/dist-cjs/index.js +5 -4
  113. package/node_modules/@smithy/smithy-client/dist-es/command.js +5 -4
  114. package/node_modules/@smithy/smithy-client/dist-types/command.d.ts +3 -3
  115. package/node_modules/@smithy/smithy-client/dist-types/ts3.4/command.d.ts +3 -3
  116. package/node_modules/@smithy/smithy-client/package.json +7 -7
  117. package/node_modules/@smithy/types/dist-es/index.js +1 -0
  118. package/node_modules/@smithy/types/dist-es/schema/static-schemas.js +1 -0
  119. package/node_modules/@smithy/types/dist-types/http/httpHandlerInitialization.d.ts +17 -10
  120. package/node_modules/@smithy/types/dist-types/index.d.ts +1 -0
  121. package/node_modules/@smithy/types/dist-types/schema/schema.d.ts +2 -1
  122. package/node_modules/@smithy/types/dist-types/schema/static-schemas.d.ts +82 -0
  123. package/node_modules/@smithy/types/dist-types/ts3.4/http/httpHandlerInitialization.d.ts +17 -10
  124. package/node_modules/@smithy/types/dist-types/ts3.4/index.d.ts +1 -0
  125. package/node_modules/@smithy/types/dist-types/ts3.4/schema/schema.d.ts +2 -1
  126. package/node_modules/@smithy/types/dist-types/ts3.4/schema/static-schemas.d.ts +101 -0
  127. package/node_modules/@smithy/types/package.json +1 -1
  128. package/node_modules/@smithy/url-parser/package.json +3 -3
  129. package/node_modules/@smithy/util-defaults-mode-browser/package.json +4 -4
  130. package/node_modules/@smithy/util-defaults-mode-node/package.json +7 -7
  131. package/node_modules/@smithy/util-endpoints/package.json +3 -3
  132. package/node_modules/@smithy/util-middleware/package.json +2 -2
  133. package/node_modules/@smithy/util-retry/package.json +3 -3
  134. package/node_modules/@smithy/util-stream/package.json +4 -4
  135. package/node_modules/@smithy/util-waiter/package.json +3 -3
  136. package/package.json +3 -3
  137. /package/node_modules/@smithy/core/dist-es/{protocols → request-builder}/requestBuilder.js +0 -0
  138. /package/node_modules/@smithy/core/dist-types/{protocols → request-builder}/requestBuilder.d.ts +0 -0
  139. /package/node_modules/@smithy/core/dist-types/ts3.4/{protocols → request-builder}/requestBuilder.d.ts +0 -0
@@ -10,103 +10,6 @@ const deref = (schemaRef) => {
10
10
  return schemaRef;
11
11
  };
12
12
 
13
- const schemaDeserializationMiddleware = (config) => (next, context) => async (args) => {
14
- const { response } = await next(args);
15
- const { operationSchema } = utilMiddleware.getSmithyContext(context);
16
- try {
17
- const parsed = await config.protocol.deserializeResponse(operationSchema, {
18
- ...config,
19
- ...context,
20
- }, response);
21
- return {
22
- response,
23
- output: parsed,
24
- };
25
- }
26
- catch (error) {
27
- Object.defineProperty(error, "$response", {
28
- value: response,
29
- });
30
- if (!("$metadata" in error)) {
31
- const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
32
- try {
33
- error.message += "\n " + hint;
34
- }
35
- catch (e) {
36
- if (!context.logger || context.logger?.constructor?.name === "NoOpLogger") {
37
- console.warn(hint);
38
- }
39
- else {
40
- context.logger?.warn?.(hint);
41
- }
42
- }
43
- if (typeof error.$responseBodyText !== "undefined") {
44
- if (error.$response) {
45
- error.$response.body = error.$responseBodyText;
46
- }
47
- }
48
- try {
49
- if (protocolHttp.HttpResponse.isInstance(response)) {
50
- const { headers = {} } = response;
51
- const headerEntries = Object.entries(headers);
52
- error.$metadata = {
53
- httpStatusCode: response.statusCode,
54
- requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries),
55
- extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries),
56
- cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries),
57
- };
58
- }
59
- }
60
- catch (e) {
61
- }
62
- }
63
- throw error;
64
- }
65
- };
66
- const findHeader = (pattern, headers) => {
67
- return (headers.find(([k]) => {
68
- return k.match(pattern);
69
- }) || [void 0, void 0])[1];
70
- };
71
-
72
- const schemaSerializationMiddleware = (config) => (next, context) => async (args) => {
73
- const { operationSchema } = utilMiddleware.getSmithyContext(context);
74
- const endpoint = context.endpointV2?.url && config.urlParser
75
- ? async () => config.urlParser(context.endpointV2.url)
76
- : config.endpoint;
77
- const request = await config.protocol.serializeRequest(operationSchema, args.input, {
78
- ...config,
79
- ...context,
80
- endpoint,
81
- });
82
- return next({
83
- ...args,
84
- request,
85
- });
86
- };
87
-
88
- const deserializerMiddlewareOption = {
89
- name: "deserializerMiddleware",
90
- step: "deserialize",
91
- tags: ["DESERIALIZER"],
92
- override: true,
93
- };
94
- const serializerMiddlewareOption = {
95
- name: "serializerMiddleware",
96
- step: "serialize",
97
- tags: ["SERIALIZER"],
98
- override: true,
99
- };
100
- function getSchemaSerdePlugin(config) {
101
- return {
102
- applyToStack: (commandStack) => {
103
- commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption);
104
- commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption);
105
- config.protocol.setSerdeContext(config);
106
- },
107
- };
108
- }
109
-
110
13
  class TypeRegistry {
111
14
  namespace;
112
15
  schemas;
@@ -134,11 +37,11 @@ class TypeRegistry {
134
37
  }
135
38
  return this.schemas.get(id);
136
39
  }
137
- registerError(errorSchema, ctor) {
138
- this.exceptions.set(errorSchema, ctor);
40
+ registerError(es, ctor) {
41
+ this.exceptions.set(es, ctor);
139
42
  }
140
- getErrorCtor(errorSchema) {
141
- return this.exceptions.get(errorSchema);
43
+ getErrorCtor(es) {
44
+ return this.exceptions.get(es);
142
45
  }
143
46
  getBaseException() {
144
47
  for (const [id, schema] of this.schemas.entries()) {
@@ -188,6 +91,36 @@ class Schema {
188
91
  }
189
92
  }
190
93
 
94
+ class StructureSchema extends Schema {
95
+ static symbol = Symbol.for("@smithy/str");
96
+ name;
97
+ traits;
98
+ memberNames;
99
+ memberList;
100
+ symbol = StructureSchema.symbol;
101
+ }
102
+ const struct = (namespace, name, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), {
103
+ name,
104
+ namespace,
105
+ traits,
106
+ memberNames,
107
+ memberList,
108
+ });
109
+
110
+ class ErrorSchema extends StructureSchema {
111
+ static symbol = Symbol.for("@smithy/err");
112
+ ctor;
113
+ symbol = ErrorSchema.symbol;
114
+ }
115
+ const error = (namespace, name, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), {
116
+ name,
117
+ namespace,
118
+ traits,
119
+ memberNames,
120
+ memberList,
121
+ ctor: null,
122
+ });
123
+
191
124
  class ListSchema extends Schema {
192
125
  static symbol = Symbol.for("@smithy/lis");
193
126
  name;
@@ -234,34 +167,18 @@ const op = (namespace, name, traits, input, output) => Schema.assign(new Operati
234
167
  output,
235
168
  });
236
169
 
237
- class StructureSchema extends Schema {
238
- static symbol = Symbol.for("@smithy/str");
170
+ class SimpleSchema extends Schema {
171
+ static symbol = Symbol.for("@smithy/sim");
239
172
  name;
173
+ schemaRef;
240
174
  traits;
241
- memberNames;
242
- memberList;
243
- symbol = StructureSchema.symbol;
244
- }
245
- const struct = (namespace, name, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), {
246
- name,
247
- namespace,
248
- traits,
249
- memberNames,
250
- memberList,
251
- });
252
-
253
- class ErrorSchema extends StructureSchema {
254
- static symbol = Symbol.for("@smithy/err");
255
- ctor;
256
- symbol = ErrorSchema.symbol;
175
+ symbol = SimpleSchema.symbol;
257
176
  }
258
- const error = (namespace, name, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), {
177
+ const sim = (namespace, name, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
259
178
  name,
260
179
  namespace,
261
180
  traits,
262
- memberNames,
263
- memberList,
264
- ctor: null,
181
+ schemaRef,
265
182
  });
266
183
 
267
184
  function translateTraits(indicator) {
@@ -305,12 +222,14 @@ class NormalizedSchema {
305
222
  let _ref = ref;
306
223
  let schema = ref;
307
224
  this._isMemberSchema = false;
308
- while (Array.isArray(_ref)) {
225
+ while (isMemberSchema(_ref)) {
309
226
  traitStack.push(_ref[1]);
310
227
  _ref = _ref[0];
311
228
  schema = deref(_ref);
312
229
  this._isMemberSchema = true;
313
230
  }
231
+ if (isStaticSchema(schema))
232
+ schema = hydrate(schema);
314
233
  if (traitStack.length > 0) {
315
234
  this.memberTraits = {};
316
235
  for (let i = traitStack.length - 1; i >= 0; --i) {
@@ -349,7 +268,7 @@ class NormalizedSchema {
349
268
  if (sc instanceof NormalizedSchema) {
350
269
  return sc;
351
270
  }
352
- if (Array.isArray(sc)) {
271
+ if (isMemberSchema(sc)) {
353
272
  const [ns, traits] = sc;
354
273
  if (ns instanceof NormalizedSchema) {
355
274
  Object.assign(ns.getMergedTraits(), translateTraits(traits));
@@ -474,7 +393,7 @@ class NormalizedSchema {
474
393
  if (this.isStructSchema() && struct.memberNames.includes(memberName)) {
475
394
  const i = struct.memberNames.indexOf(memberName);
476
395
  const memberSchema = struct.memberList[i];
477
- return member(Array.isArray(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
396
+ return member(isMemberSchema(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
478
397
  }
479
398
  if (this.isDocumentSchema()) {
480
399
  return member([15, 0], memberName);
@@ -524,20 +443,122 @@ function member(memberSchema, memberName) {
524
443
  const internalCtorAccess = NormalizedSchema;
525
444
  return new internalCtorAccess(memberSchema, memberName);
526
445
  }
446
+ function hydrate(ss) {
447
+ const [id, ...rest] = ss;
448
+ return {
449
+ [0]: sim,
450
+ [1]: list,
451
+ [2]: map,
452
+ [3]: struct,
453
+ [-3]: error,
454
+ [9]: op,
455
+ }[id].call(null, ...rest);
456
+ }
457
+ const isMemberSchema = (sc) => Array.isArray(sc) && sc.length === 2;
458
+ const isStaticSchema = (sc) => Array.isArray(sc) && sc.length >= 5;
527
459
 
528
- class SimpleSchema extends Schema {
529
- static symbol = Symbol.for("@smithy/sim");
530
- name;
531
- schemaRef;
532
- traits;
533
- symbol = SimpleSchema.symbol;
460
+ const schemaDeserializationMiddleware = (config) => (next, context) => async (args) => {
461
+ const { response } = await next(args);
462
+ let { operationSchema } = utilMiddleware.getSmithyContext(context);
463
+ if (isStaticSchema(operationSchema)) {
464
+ operationSchema = hydrate(operationSchema);
465
+ }
466
+ try {
467
+ const parsed = await config.protocol.deserializeResponse(operationSchema, {
468
+ ...config,
469
+ ...context,
470
+ }, response);
471
+ return {
472
+ response,
473
+ output: parsed,
474
+ };
475
+ }
476
+ catch (error) {
477
+ Object.defineProperty(error, "$response", {
478
+ value: response,
479
+ });
480
+ if (!("$metadata" in error)) {
481
+ const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
482
+ try {
483
+ error.message += "\n " + hint;
484
+ }
485
+ catch (e) {
486
+ if (!context.logger || context.logger?.constructor?.name === "NoOpLogger") {
487
+ console.warn(hint);
488
+ }
489
+ else {
490
+ context.logger?.warn?.(hint);
491
+ }
492
+ }
493
+ if (typeof error.$responseBodyText !== "undefined") {
494
+ if (error.$response) {
495
+ error.$response.body = error.$responseBodyText;
496
+ }
497
+ }
498
+ try {
499
+ if (protocolHttp.HttpResponse.isInstance(response)) {
500
+ const { headers = {} } = response;
501
+ const headerEntries = Object.entries(headers);
502
+ error.$metadata = {
503
+ httpStatusCode: response.statusCode,
504
+ requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries),
505
+ extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries),
506
+ cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries),
507
+ };
508
+ }
509
+ }
510
+ catch (e) {
511
+ }
512
+ }
513
+ throw error;
514
+ }
515
+ };
516
+ const findHeader = (pattern, headers) => {
517
+ return (headers.find(([k]) => {
518
+ return k.match(pattern);
519
+ }) || [void 0, void 0])[1];
520
+ };
521
+
522
+ const schemaSerializationMiddleware = (config) => (next, context) => async (args) => {
523
+ let { operationSchema } = utilMiddleware.getSmithyContext(context);
524
+ if (isStaticSchema(operationSchema)) {
525
+ operationSchema = hydrate(operationSchema);
526
+ }
527
+ const endpoint = context.endpointV2?.url && config.urlParser
528
+ ? async () => config.urlParser(context.endpointV2.url)
529
+ : config.endpoint;
530
+ const request = await config.protocol.serializeRequest(operationSchema, args.input, {
531
+ ...config,
532
+ ...context,
533
+ endpoint,
534
+ });
535
+ return next({
536
+ ...args,
537
+ request,
538
+ });
539
+ };
540
+
541
+ const deserializerMiddlewareOption = {
542
+ name: "deserializerMiddleware",
543
+ step: "deserialize",
544
+ tags: ["DESERIALIZER"],
545
+ override: true,
546
+ };
547
+ const serializerMiddlewareOption = {
548
+ name: "serializerMiddleware",
549
+ step: "serialize",
550
+ tags: ["SERIALIZER"],
551
+ override: true,
552
+ };
553
+ function getSchemaSerdePlugin(config) {
554
+ return {
555
+ applyToStack: (commandStack) => {
556
+ commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption);
557
+ commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption);
558
+ config.protocol.setSerdeContext(config);
559
+ },
560
+ };
534
561
  }
535
- const sim = (namespace, name, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
536
- name,
537
- namespace,
538
- traits,
539
- schemaRef,
540
- });
541
562
 
542
563
  const SCHEMA = {
543
564
  BLOB: 0b0001_0101,
@@ -570,6 +591,8 @@ exports.deref = deref;
570
591
  exports.deserializerMiddlewareOption = deserializerMiddlewareOption;
571
592
  exports.error = error;
572
593
  exports.getSchemaSerdePlugin = getSchemaSerdePlugin;
594
+ exports.hydrate = hydrate;
595
+ exports.isStaticSchema = isStaticSchema;
573
596
  exports.list = list;
574
597
  exports.map = map;
575
598
  exports.op = op;
@@ -3,6 +3,6 @@ export * from "./middleware-http-auth-scheme";
3
3
  export * from "./middleware-http-signing";
4
4
  export * from "./normalizeProvider";
5
5
  export { createPaginator } from "./pagination/createPaginator";
6
- export * from "./protocols/requestBuilder";
6
+ export * from "./request-builder/requestBuilder";
7
7
  export * from "./setFeature";
8
8
  export * from "./util-identity-and-auth";
@@ -1,10 +1,10 @@
1
+ import { SerdeContext } from "@smithy/core/protocols";
1
2
  import { NormalizedSchema } from "@smithy/core/schema";
2
3
  import { _parseEpochTimestamp, generateIdempotencyToken } from "@smithy/core/serde";
3
4
  import { fromBase64 } from "@smithy/util-base64";
4
5
  import { cbor } from "./cbor";
5
6
  import { dateToTag } from "./parseCborBody";
6
- export class CborCodec {
7
- serdeContext;
7
+ export class CborCodec extends SerdeContext {
8
8
  createSerializer() {
9
9
  const serializer = new CborShapeSerializer();
10
10
  serializer.setSerdeContext(this.serdeContext);
@@ -15,16 +15,9 @@ export class CborCodec {
15
15
  deserializer.setSerdeContext(this.serdeContext);
16
16
  return deserializer;
17
17
  }
18
- setSerdeContext(serdeContext) {
19
- this.serdeContext = serdeContext;
20
- }
21
18
  }
22
- export class CborShapeSerializer {
23
- serdeContext;
19
+ export class CborShapeSerializer extends SerdeContext {
24
20
  value;
25
- setSerdeContext(serdeContext) {
26
- this.serdeContext = serdeContext;
27
- }
28
21
  write(schema, value) {
29
22
  this.value = this.serialize(schema, value);
30
23
  }
@@ -98,11 +91,7 @@ export class CborShapeSerializer {
98
91
  return buffer;
99
92
  }
100
93
  }
101
- export class CborShapeDeserializer {
102
- serdeContext;
103
- setSerdeContext(serdeContext) {
104
- this.serdeContext = serdeContext;
105
- }
94
+ export class CborShapeDeserializer extends SerdeContext {
106
95
  read(schema, bytes) {
107
96
  const data = cbor.deserialize(bytes);
108
97
  return this.readValue(schema, data);
@@ -1,9 +1,10 @@
1
1
  import { NormalizedSchema } from "@smithy/core/schema";
2
2
  import { HttpRequest, HttpResponse } from "@smithy/protocol-http";
3
- export class HttpProtocol {
3
+ import { SerdeContext } from "./SerdeContext";
4
+ export class HttpProtocol extends SerdeContext {
4
5
  options;
5
- serdeContext;
6
6
  constructor(options) {
7
+ super();
7
8
  this.options = options;
8
9
  }
9
10
  getRequestType() {
@@ -0,0 +1,6 @@
1
+ export class SerdeContext {
2
+ serdeContext;
3
+ setSerdeContext(serdeContext) {
4
+ this.serdeContext = serdeContext;
5
+ }
6
+ }
@@ -10,3 +10,4 @@ export * from "./serde/HttpInterceptingShapeDeserializer";
10
10
  export * from "./serde/HttpInterceptingShapeSerializer";
11
11
  export * from "./serde/ToStringShapeSerializer";
12
12
  export * from "./serde/determineTimestampFormat";
13
+ export * from "./SerdeContext";
@@ -2,16 +2,14 @@ import { NormalizedSchema } from "@smithy/core/schema";
2
2
  import { _parseEpochTimestamp, _parseRfc3339DateTimeWithOffset, _parseRfc7231DateTime, LazyJsonString, NumericValue, splitHeader, } from "@smithy/core/serde";
3
3
  import { fromBase64 } from "@smithy/util-base64";
4
4
  import { toUtf8 } from "@smithy/util-utf8";
5
+ import { SerdeContext } from "../SerdeContext";
5
6
  import { determineTimestampFormat } from "./determineTimestampFormat";
6
- export class FromStringShapeDeserializer {
7
+ export class FromStringShapeDeserializer extends SerdeContext {
7
8
  settings;
8
- serdeContext;
9
9
  constructor(settings) {
10
+ super();
10
11
  this.settings = settings;
11
12
  }
12
- setSerdeContext(serdeContext) {
13
- this.serdeContext = serdeContext;
14
- }
15
13
  read(_schema, data) {
16
14
  const ns = NormalizedSchema.of(_schema);
17
15
  if (ns.isListSchema()) {
@@ -1,11 +1,12 @@
1
1
  import { NormalizedSchema } from "@smithy/core/schema";
2
2
  import { fromUtf8, toUtf8 } from "@smithy/util-utf8";
3
+ import { SerdeContext } from "../SerdeContext";
3
4
  import { FromStringShapeDeserializer } from "./FromStringShapeDeserializer";
4
- export class HttpInterceptingShapeDeserializer {
5
+ export class HttpInterceptingShapeDeserializer extends SerdeContext {
5
6
  codecDeserializer;
6
7
  stringDeserializer;
7
- serdeContext;
8
8
  constructor(codecDeserializer, codecSettings) {
9
+ super();
9
10
  this.codecDeserializer = codecDeserializer;
10
11
  this.stringDeserializer = new FromStringShapeDeserializer(codecSettings);
11
12
  }
@@ -1,17 +1,15 @@
1
1
  import { NormalizedSchema } from "@smithy/core/schema";
2
2
  import { dateToUtcString, LazyJsonString, quoteHeader } from "@smithy/core/serde";
3
3
  import { toBase64 } from "@smithy/util-base64";
4
+ import { SerdeContext } from "../SerdeContext";
4
5
  import { determineTimestampFormat } from "./determineTimestampFormat";
5
- export class ToStringShapeSerializer {
6
+ export class ToStringShapeSerializer extends SerdeContext {
6
7
  settings;
7
8
  stringBuffer = "";
8
- serdeContext = undefined;
9
9
  constructor(settings) {
10
+ super();
10
11
  this.settings = settings;
11
12
  }
12
- setSerdeContext(serdeContext) {
13
- this.serdeContext = serdeContext;
14
- }
15
13
  write(schema, value) {
16
14
  const ns = NormalizedSchema.of(schema);
17
15
  switch (typeof value) {
@@ -25,11 +25,11 @@ export class TypeRegistry {
25
25
  }
26
26
  return this.schemas.get(id);
27
27
  }
28
- registerError(errorSchema, ctor) {
29
- this.exceptions.set(errorSchema, ctor);
28
+ registerError(es, ctor) {
29
+ this.exceptions.set(es, ctor);
30
30
  }
31
- getErrorCtor(errorSchema) {
32
- return this.exceptions.get(errorSchema);
31
+ getErrorCtor(es) {
32
+ return this.exceptions.get(es);
33
33
  }
34
34
  getBaseException() {
35
35
  for (const [id, schema] of this.schemas.entries()) {
@@ -1,8 +1,12 @@
1
1
  import { HttpResponse } from "@smithy/protocol-http";
2
2
  import { getSmithyContext } from "@smithy/util-middleware";
3
+ import { hydrate, isStaticSchema } from "../schemas/NormalizedSchema";
3
4
  export const schemaDeserializationMiddleware = (config) => (next, context) => async (args) => {
4
5
  const { response } = await next(args);
5
- const { operationSchema } = getSmithyContext(context);
6
+ let { operationSchema } = getSmithyContext(context);
7
+ if (isStaticSchema(operationSchema)) {
8
+ operationSchema = hydrate(operationSchema);
9
+ }
6
10
  try {
7
11
  const parsed = await config.protocol.deserializeResponse(operationSchema, {
8
12
  ...config,
@@ -1,6 +1,10 @@
1
1
  import { getSmithyContext } from "@smithy/util-middleware";
2
+ import { hydrate, isStaticSchema } from "../schemas/NormalizedSchema";
2
3
  export const schemaSerializationMiddleware = (config) => (next, context) => async (args) => {
3
- const { operationSchema } = getSmithyContext(context);
4
+ let { operationSchema } = getSmithyContext(context);
5
+ if (isStaticSchema(operationSchema)) {
6
+ operationSchema = hydrate(operationSchema);
7
+ }
4
8
  const endpoint = context.endpointV2?.url && config.urlParser
5
9
  ? async () => config.urlParser(context.endpointV2.url)
6
10
  : config.endpoint;
@@ -1,8 +1,11 @@
1
1
  import { deref } from "../deref";
2
- import { ListSchema } from "./ListSchema";
3
- import { MapSchema } from "./MapSchema";
2
+ import { error } from "./ErrorSchema";
3
+ import { list, ListSchema } from "./ListSchema";
4
+ import { map, MapSchema } from "./MapSchema";
5
+ import { op } from "./OperationSchema";
4
6
  import { Schema } from "./Schema";
5
- import { StructureSchema } from "./StructureSchema";
7
+ import { sim } from "./SimpleSchema";
8
+ import { struct, StructureSchema } from "./StructureSchema";
6
9
  import { translateTraits } from "./translateTraits";
7
10
  export class NormalizedSchema {
8
11
  ref;
@@ -22,12 +25,14 @@ export class NormalizedSchema {
22
25
  let _ref = ref;
23
26
  let schema = ref;
24
27
  this._isMemberSchema = false;
25
- while (Array.isArray(_ref)) {
28
+ while (isMemberSchema(_ref)) {
26
29
  traitStack.push(_ref[1]);
27
30
  _ref = _ref[0];
28
31
  schema = deref(_ref);
29
32
  this._isMemberSchema = true;
30
33
  }
34
+ if (isStaticSchema(schema))
35
+ schema = hydrate(schema);
31
36
  if (traitStack.length > 0) {
32
37
  this.memberTraits = {};
33
38
  for (let i = traitStack.length - 1; i >= 0; --i) {
@@ -66,7 +71,7 @@ export class NormalizedSchema {
66
71
  if (sc instanceof NormalizedSchema) {
67
72
  return sc;
68
73
  }
69
- if (Array.isArray(sc)) {
74
+ if (isMemberSchema(sc)) {
70
75
  const [ns, traits] = sc;
71
76
  if (ns instanceof NormalizedSchema) {
72
77
  Object.assign(ns.getMergedTraits(), translateTraits(traits));
@@ -191,7 +196,7 @@ export class NormalizedSchema {
191
196
  if (this.isStructSchema() && struct.memberNames.includes(memberName)) {
192
197
  const i = struct.memberNames.indexOf(memberName);
193
198
  const memberSchema = struct.memberList[i];
194
- return member(Array.isArray(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
199
+ return member(isMemberSchema(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
195
200
  }
196
201
  if (this.isDocumentSchema()) {
197
202
  return member([15, 0], memberName);
@@ -241,3 +246,16 @@ function member(memberSchema, memberName) {
241
246
  const internalCtorAccess = NormalizedSchema;
242
247
  return new internalCtorAccess(memberSchema, memberName);
243
248
  }
249
+ export function hydrate(ss) {
250
+ const [id, ...rest] = ss;
251
+ return {
252
+ [0]: sim,
253
+ [1]: list,
254
+ [2]: map,
255
+ [3]: struct,
256
+ [-3]: error,
257
+ [9]: op,
258
+ }[id].call(null, ...rest);
259
+ }
260
+ const isMemberSchema = (sc) => Array.isArray(sc) && sc.length === 2;
261
+ export const isStaticSchema = (sc) => Array.isArray(sc) && sc.length >= 5;
@@ -3,6 +3,6 @@ export * from "./middleware-http-auth-scheme";
3
3
  export * from "./middleware-http-signing";
4
4
  export * from "./normalizeProvider";
5
5
  export { createPaginator } from "./pagination/createPaginator";
6
- export * from "./protocols/requestBuilder";
6
+ export * from "./request-builder/requestBuilder";
7
7
  export * from "./setFeature";
8
8
  export * from "./util-identity-and-auth";
@@ -1,20 +1,17 @@
1
- import type { Codec, Schema, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
1
+ import { SerdeContext } from "@smithy/core/protocols";
2
+ import type { Codec, Schema, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
2
3
  /**
3
4
  * @alpha
4
5
  */
5
- export declare class CborCodec implements Codec<Uint8Array, Uint8Array> {
6
- private serdeContext?;
6
+ export declare class CborCodec extends SerdeContext implements Codec<Uint8Array, Uint8Array> {
7
7
  createSerializer(): CborShapeSerializer;
8
8
  createDeserializer(): CborShapeDeserializer;
9
- setSerdeContext(serdeContext: SerdeFunctions): void;
10
9
  }
11
10
  /**
12
11
  * @alpha
13
12
  */
14
- export declare class CborShapeSerializer implements ShapeSerializer {
15
- private serdeContext?;
13
+ export declare class CborShapeSerializer extends SerdeContext implements ShapeSerializer {
16
14
  private value;
17
- setSerdeContext(serdeContext: SerdeFunctions): void;
18
15
  write(schema: Schema, value: unknown): void;
19
16
  /**
20
17
  * Recursive serializer transform that copies and prepares the user input object
@@ -26,9 +23,7 @@ export declare class CborShapeSerializer implements ShapeSerializer {
26
23
  /**
27
24
  * @alpha
28
25
  */
29
- export declare class CborShapeDeserializer implements ShapeDeserializer {
30
- private serdeContext?;
31
- setSerdeContext(serdeContext: SerdeFunctions): void;
26
+ export declare class CborShapeDeserializer extends SerdeContext implements ShapeDeserializer {
32
27
  read(schema: Schema, bytes: Uint8Array): any;
33
28
  /**
34
29
  * Public because it's called by the protocol implementation to deserialize errors.