@jjrawlins/cdk-iam-policy-builder-helper 0.0.56 → 0.0.58

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-iam-policy-builder-helper/go.mod +1 -1
  3. package/cdk-iam-policy-builder-helper/jsii/jsii.go +2 -2
  4. package/cdk-iam-policy-builder-helper/version +1 -1
  5. package/node_modules/@aws-sdk/client-iam/package.json +34 -34
  6. package/node_modules/@aws-sdk/client-sso/package.json +32 -32
  7. package/node_modules/@aws-sdk/core/dist-cjs/index.js +5 -5
  8. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +5 -5
  9. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.js +1 -1
  10. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +1 -1
  11. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +1 -1
  12. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsQueryProtocol.js +1 -1
  13. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +1 -1
  14. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/ProtocolLib.d.ts +4 -4
  15. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +7 -7
  16. package/node_modules/@aws-sdk/core/package.json +11 -11
  17. package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
  18. package/node_modules/@aws-sdk/credential-provider-http/package.json +10 -10
  19. package/node_modules/@aws-sdk/credential-provider-ini/package.json +13 -13
  20. package/node_modules/@aws-sdk/credential-provider-node/package.json +12 -12
  21. package/node_modules/@aws-sdk/credential-provider-process/package.json +6 -6
  22. package/node_modules/@aws-sdk/credential-provider-sso/package.json +8 -8
  23. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -7
  24. package/node_modules/@aws-sdk/middleware-host-header/dist-cjs/index.js +35 -63
  25. package/node_modules/@aws-sdk/middleware-host-header/package.json +4 -4
  26. package/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js +44 -75
  27. package/node_modules/@aws-sdk/middleware-logger/package.json +3 -3
  28. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-cjs/index.js +19 -48
  29. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +4 -4
  30. package/node_modules/@aws-sdk/middleware-user-agent/package.json +7 -7
  31. package/node_modules/@aws-sdk/nested-clients/package.json +32 -32
  32. package/node_modules/@aws-sdk/region-config-resolver/dist-cjs/index.js +59 -95
  33. package/node_modules/@aws-sdk/region-config-resolver/package.json +5 -5
  34. package/node_modules/@aws-sdk/token-providers/package.json +7 -7
  35. package/node_modules/@aws-sdk/types/dist-cjs/index.js +18 -290
  36. package/node_modules/@aws-sdk/types/package.json +2 -2
  37. package/node_modules/@aws-sdk/util-endpoints/dist-cjs/index.js +395 -469
  38. package/node_modules/@aws-sdk/util-endpoints/package.json +5 -5
  39. package/node_modules/@aws-sdk/util-user-agent-browser/package.json +3 -3
  40. package/node_modules/@aws-sdk/util-user-agent-node/package.json +5 -5
  41. package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +106 -160
  42. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  43. package/node_modules/@smithy/abort-controller/package.json +2 -2
  44. package/node_modules/@smithy/config-resolver/package.json +4 -4
  45. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +3 -15
  46. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +16 -14
  47. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +226 -190
  48. package/node_modules/@smithy/core/dist-es/index.js +1 -1
  49. package/node_modules/@smithy/core/dist-es/submodules/cbor/CborCodec.js +4 -15
  50. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +3 -2
  51. package/node_modules/@smithy/core/dist-es/submodules/protocols/SerdeContext.js +6 -0
  52. package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +1 -0
  53. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +3 -5
  54. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/HttpInterceptingShapeDeserializer.js +3 -2
  55. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +3 -5
  56. package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +18 -11
  57. package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js +5 -1
  58. package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js +5 -1
  59. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +24 -6
  60. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js +0 -2
  61. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +6 -0
  62. package/node_modules/@smithy/core/dist-types/index.d.ts +1 -1
  63. package/node_modules/@smithy/core/dist-types/submodules/cbor/CborCodec.d.ts +5 -10
  64. package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpProtocol.d.ts +5 -2
  65. package/node_modules/@smithy/core/dist-types/submodules/protocols/SerdeContext.d.ts +8 -0
  66. package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +1 -0
  67. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +3 -4
  68. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +5 -2
  69. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +5 -2
  70. package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/ToStringShapeSerializer.d.ts +3 -4
  71. package/node_modules/@smithy/core/dist-types/submodules/schema/TypeRegistry.d.ts +5 -6
  72. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +22 -1
  73. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +5 -0
  74. package/node_modules/@smithy/core/dist-types/ts3.4/index.d.ts +1 -1
  75. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/CborCodec.d.ts +5 -10
  76. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +5 -2
  77. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/SerdeContext.d.ts +8 -0
  78. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
  79. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +3 -4
  80. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +5 -2
  81. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +5 -2
  82. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/ToStringShapeSerializer.d.ts +3 -4
  83. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/TypeRegistry.d.ts +5 -6
  84. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +22 -1
  85. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/SimpleSchema.d.ts +5 -0
  86. package/node_modules/@smithy/core/package.json +7 -7
  87. package/node_modules/@smithy/credential-provider-imds/package.json +5 -5
  88. package/node_modules/@smithy/fetch-http-handler/package.json +5 -5
  89. package/node_modules/@smithy/hash-node/package.json +2 -2
  90. package/node_modules/@smithy/invalid-dependency/package.json +2 -2
  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 +6 -6
  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,169 +10,12 @@ 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
- class TypeRegistry {
111
- namespace;
112
- schemas;
113
- exceptions;
114
- static registries = new Map();
115
- constructor(namespace, schemas = new Map(), exceptions = new Map()) {
116
- this.namespace = namespace;
117
- this.schemas = schemas;
118
- this.exceptions = exceptions;
119
- }
120
- static for(namespace) {
121
- if (!TypeRegistry.registries.has(namespace)) {
122
- TypeRegistry.registries.set(namespace, new TypeRegistry(namespace));
123
- }
124
- return TypeRegistry.registries.get(namespace);
125
- }
126
- register(shapeId, schema) {
127
- const qualifiedName = this.normalizeShapeId(shapeId);
128
- this.schemas.set(qualifiedName, schema);
129
- }
130
- getSchema(shapeId) {
131
- const id = this.normalizeShapeId(shapeId);
132
- if (!this.schemas.has(id)) {
133
- throw new Error(`@smithy/core/schema - schema not found for ${id}`);
134
- }
135
- return this.schemas.get(id);
136
- }
137
- registerError(errorSchema, ctor) {
138
- this.exceptions.set(errorSchema, ctor);
139
- }
140
- getErrorCtor(errorSchema) {
141
- return this.exceptions.get(errorSchema);
142
- }
143
- getBaseException() {
144
- for (const [id, schema] of this.schemas.entries()) {
145
- if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
146
- return schema;
147
- }
148
- }
149
- return undefined;
150
- }
151
- find(predicate) {
152
- return [...this.schemas.values()].find(predicate);
153
- }
154
- clear() {
155
- this.schemas.clear();
156
- this.exceptions.clear();
157
- }
158
- normalizeShapeId(shapeId) {
159
- if (shapeId.includes("#")) {
160
- return shapeId;
161
- }
162
- return this.namespace + "#" + shapeId;
163
- }
164
- getNamespace(shapeId) {
165
- return this.normalizeShapeId(shapeId).split("#")[0];
166
- }
167
- }
168
-
169
13
  class Schema {
170
14
  name;
171
15
  namespace;
172
16
  traits;
173
17
  static assign(instance, values) {
174
18
  const schema = Object.assign(instance, values);
175
- TypeRegistry.for(schema.namespace).register(schema.name, schema);
176
19
  return schema;
177
20
  }
178
21
  static [Symbol.hasInstance](lhs) {
@@ -188,6 +31,36 @@ class Schema {
188
31
  }
189
32
  }
190
33
 
34
+ class StructureSchema extends Schema {
35
+ static symbol = Symbol.for("@smithy/str");
36
+ name;
37
+ traits;
38
+ memberNames;
39
+ memberList;
40
+ symbol = StructureSchema.symbol;
41
+ }
42
+ const struct = (namespace, name, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), {
43
+ name,
44
+ namespace,
45
+ traits,
46
+ memberNames,
47
+ memberList,
48
+ });
49
+
50
+ class ErrorSchema extends StructureSchema {
51
+ static symbol = Symbol.for("@smithy/err");
52
+ ctor;
53
+ symbol = ErrorSchema.symbol;
54
+ }
55
+ const error = (namespace, name, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), {
56
+ name,
57
+ namespace,
58
+ traits,
59
+ memberNames,
60
+ memberList,
61
+ ctor: null,
62
+ });
63
+
191
64
  class ListSchema extends Schema {
192
65
  static symbol = Symbol.for("@smithy/lis");
193
66
  name;
@@ -234,34 +107,24 @@ const op = (namespace, name, traits, input, output) => Schema.assign(new Operati
234
107
  output,
235
108
  });
236
109
 
237
- class StructureSchema extends Schema {
238
- static symbol = Symbol.for("@smithy/str");
110
+ class SimpleSchema extends Schema {
111
+ static symbol = Symbol.for("@smithy/sim");
239
112
  name;
113
+ schemaRef;
240
114
  traits;
241
- memberNames;
242
- memberList;
243
- symbol = StructureSchema.symbol;
115
+ symbol = SimpleSchema.symbol;
244
116
  }
245
- const struct = (namespace, name, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), {
117
+ const sim = (namespace, name, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
246
118
  name,
247
119
  namespace,
248
120
  traits,
249
- memberNames,
250
- memberList,
121
+ schemaRef,
251
122
  });
252
-
253
- class ErrorSchema extends StructureSchema {
254
- static symbol = Symbol.for("@smithy/err");
255
- ctor;
256
- symbol = ErrorSchema.symbol;
257
- }
258
- const error = (namespace, name, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), {
123
+ const simAdapter = (namespace, name, traits, schemaRef) => Schema.assign(new SimpleSchema(), {
259
124
  name,
260
125
  namespace,
261
126
  traits,
262
- memberNames,
263
- memberList,
264
- ctor: null,
127
+ schemaRef,
265
128
  });
266
129
 
267
130
  function translateTraits(indicator) {
@@ -305,12 +168,14 @@ class NormalizedSchema {
305
168
  let _ref = ref;
306
169
  let schema = ref;
307
170
  this._isMemberSchema = false;
308
- while (Array.isArray(_ref)) {
171
+ while (isMemberSchema(_ref)) {
309
172
  traitStack.push(_ref[1]);
310
173
  _ref = _ref[0];
311
174
  schema = deref(_ref);
312
175
  this._isMemberSchema = true;
313
176
  }
177
+ if (isStaticSchema(schema))
178
+ schema = hydrate(schema);
314
179
  if (traitStack.length > 0) {
315
180
  this.memberTraits = {};
316
181
  for (let i = traitStack.length - 1; i >= 0; --i) {
@@ -349,7 +214,7 @@ class NormalizedSchema {
349
214
  if (sc instanceof NormalizedSchema) {
350
215
  return sc;
351
216
  }
352
- if (Array.isArray(sc)) {
217
+ if (isMemberSchema(sc)) {
353
218
  const [ns, traits] = sc;
354
219
  if (ns instanceof NormalizedSchema) {
355
220
  Object.assign(ns.getMergedTraits(), translateTraits(traits));
@@ -474,7 +339,7 @@ class NormalizedSchema {
474
339
  if (this.isStructSchema() && struct.memberNames.includes(memberName)) {
475
340
  const i = struct.memberNames.indexOf(memberName);
476
341
  const memberSchema = struct.memberList[i];
477
- return member(Array.isArray(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
342
+ return member(isMemberSchema(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
478
343
  }
479
344
  if (this.isDocumentSchema()) {
480
345
  return member([15, 0], memberName);
@@ -524,20 +389,122 @@ function member(memberSchema, memberName) {
524
389
  const internalCtorAccess = NormalizedSchema;
525
390
  return new internalCtorAccess(memberSchema, memberName);
526
391
  }
392
+ function hydrate(ss) {
393
+ const [id, ...rest] = ss;
394
+ return {
395
+ [0]: simAdapter,
396
+ [1]: list,
397
+ [2]: map,
398
+ [3]: struct,
399
+ [-3]: error,
400
+ [9]: op,
401
+ }[id].call(null, ...rest);
402
+ }
403
+ const isMemberSchema = (sc) => Array.isArray(sc) && sc.length === 2;
404
+ const isStaticSchema = (sc) => Array.isArray(sc) && sc.length >= 5;
527
405
 
528
- class SimpleSchema extends Schema {
529
- static symbol = Symbol.for("@smithy/sim");
530
- name;
531
- schemaRef;
532
- traits;
533
- symbol = SimpleSchema.symbol;
406
+ const schemaDeserializationMiddleware = (config) => (next, context) => async (args) => {
407
+ const { response } = await next(args);
408
+ let { operationSchema } = utilMiddleware.getSmithyContext(context);
409
+ if (isStaticSchema(operationSchema)) {
410
+ operationSchema = hydrate(operationSchema);
411
+ }
412
+ try {
413
+ const parsed = await config.protocol.deserializeResponse(operationSchema, {
414
+ ...config,
415
+ ...context,
416
+ }, response);
417
+ return {
418
+ response,
419
+ output: parsed,
420
+ };
421
+ }
422
+ catch (error) {
423
+ Object.defineProperty(error, "$response", {
424
+ value: response,
425
+ });
426
+ if (!("$metadata" in error)) {
427
+ const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
428
+ try {
429
+ error.message += "\n " + hint;
430
+ }
431
+ catch (e) {
432
+ if (!context.logger || context.logger?.constructor?.name === "NoOpLogger") {
433
+ console.warn(hint);
434
+ }
435
+ else {
436
+ context.logger?.warn?.(hint);
437
+ }
438
+ }
439
+ if (typeof error.$responseBodyText !== "undefined") {
440
+ if (error.$response) {
441
+ error.$response.body = error.$responseBodyText;
442
+ }
443
+ }
444
+ try {
445
+ if (protocolHttp.HttpResponse.isInstance(response)) {
446
+ const { headers = {} } = response;
447
+ const headerEntries = Object.entries(headers);
448
+ error.$metadata = {
449
+ httpStatusCode: response.statusCode,
450
+ requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries),
451
+ extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries),
452
+ cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries),
453
+ };
454
+ }
455
+ }
456
+ catch (e) {
457
+ }
458
+ }
459
+ throw error;
460
+ }
461
+ };
462
+ const findHeader = (pattern, headers) => {
463
+ return (headers.find(([k]) => {
464
+ return k.match(pattern);
465
+ }) || [void 0, void 0])[1];
466
+ };
467
+
468
+ const schemaSerializationMiddleware = (config) => (next, context) => async (args) => {
469
+ let { operationSchema } = utilMiddleware.getSmithyContext(context);
470
+ if (isStaticSchema(operationSchema)) {
471
+ operationSchema = hydrate(operationSchema);
472
+ }
473
+ const endpoint = context.endpointV2?.url && config.urlParser
474
+ ? async () => config.urlParser(context.endpointV2.url)
475
+ : config.endpoint;
476
+ const request = await config.protocol.serializeRequest(operationSchema, args.input, {
477
+ ...config,
478
+ ...context,
479
+ endpoint,
480
+ });
481
+ return next({
482
+ ...args,
483
+ request,
484
+ });
485
+ };
486
+
487
+ const deserializerMiddlewareOption = {
488
+ name: "deserializerMiddleware",
489
+ step: "deserialize",
490
+ tags: ["DESERIALIZER"],
491
+ override: true,
492
+ };
493
+ const serializerMiddlewareOption = {
494
+ name: "serializerMiddleware",
495
+ step: "serialize",
496
+ tags: ["SERIALIZER"],
497
+ override: true,
498
+ };
499
+ function getSchemaSerdePlugin(config) {
500
+ return {
501
+ applyToStack: (commandStack) => {
502
+ commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption);
503
+ commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption);
504
+ config.protocol.setSerdeContext(config);
505
+ },
506
+ };
534
507
  }
535
- const sim = (namespace, name, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
536
- name,
537
- namespace,
538
- traits,
539
- schemaRef,
540
- });
541
508
 
542
509
  const SCHEMA = {
543
510
  BLOB: 0b0001_0101,
@@ -556,6 +523,72 @@ const SCHEMA = {
556
523
  MAP_MODIFIER: 0b1000_0000,
557
524
  };
558
525
 
526
+ class TypeRegistry {
527
+ namespace;
528
+ schemas;
529
+ exceptions;
530
+ static registries = new Map();
531
+ constructor(namespace, schemas = new Map(), exceptions = new Map()) {
532
+ this.namespace = namespace;
533
+ this.schemas = schemas;
534
+ this.exceptions = exceptions;
535
+ }
536
+ static for(namespace) {
537
+ if (!TypeRegistry.registries.has(namespace)) {
538
+ TypeRegistry.registries.set(namespace, new TypeRegistry(namespace));
539
+ }
540
+ return TypeRegistry.registries.get(namespace);
541
+ }
542
+ register(shapeId, schema) {
543
+ const qualifiedName = this.normalizeShapeId(shapeId);
544
+ const registry = TypeRegistry.for(qualifiedName.split("#")[0]);
545
+ registry.schemas.set(qualifiedName, schema);
546
+ }
547
+ getSchema(shapeId) {
548
+ const id = this.normalizeShapeId(shapeId);
549
+ if (!this.schemas.has(id)) {
550
+ throw new Error(`@smithy/core/schema - schema not found for ${id}`);
551
+ }
552
+ return this.schemas.get(id);
553
+ }
554
+ registerError(es, ctor) {
555
+ const $error = es;
556
+ const registry = TypeRegistry.for($error[1]);
557
+ registry.schemas.set($error[1] + "#" + $error[2], $error);
558
+ registry.exceptions.set($error, ctor);
559
+ }
560
+ getErrorCtor(es) {
561
+ const $error = es;
562
+ const registry = TypeRegistry.for($error[1]);
563
+ return registry.exceptions.get(es);
564
+ }
565
+ getBaseException() {
566
+ for (const exceptionKey of this.exceptions.keys()) {
567
+ if (Array.isArray(exceptionKey)) {
568
+ const [, ns, name] = exceptionKey;
569
+ const id = ns + "#" + name;
570
+ if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
571
+ return exceptionKey;
572
+ }
573
+ }
574
+ }
575
+ return undefined;
576
+ }
577
+ find(predicate) {
578
+ return [...this.schemas.values()].find(predicate);
579
+ }
580
+ clear() {
581
+ this.schemas.clear();
582
+ this.exceptions.clear();
583
+ }
584
+ normalizeShapeId(shapeId) {
585
+ if (shapeId.includes("#")) {
586
+ return shapeId;
587
+ }
588
+ return this.namespace + "#" + shapeId;
589
+ }
590
+ }
591
+
559
592
  exports.ErrorSchema = ErrorSchema;
560
593
  exports.ListSchema = ListSchema;
561
594
  exports.MapSchema = MapSchema;
@@ -570,10 +603,13 @@ exports.deref = deref;
570
603
  exports.deserializerMiddlewareOption = deserializerMiddlewareOption;
571
604
  exports.error = error;
572
605
  exports.getSchemaSerdePlugin = getSchemaSerdePlugin;
606
+ exports.hydrate = hydrate;
607
+ exports.isStaticSchema = isStaticSchema;
573
608
  exports.list = list;
574
609
  exports.map = map;
575
610
  exports.op = op;
576
611
  exports.serializerMiddlewareOption = serializerMiddlewareOption;
577
612
  exports.sim = sim;
613
+ exports.simAdapter = simAdapter;
578
614
  exports.struct = struct;
579
615
  exports.translateTraits = translateTraits;
@@ -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) {
@@ -16,7 +16,8 @@ export class TypeRegistry {
16
16
  }
17
17
  register(shapeId, schema) {
18
18
  const qualifiedName = this.normalizeShapeId(shapeId);
19
- this.schemas.set(qualifiedName, schema);
19
+ const registry = TypeRegistry.for(qualifiedName.split("#")[0]);
20
+ registry.schemas.set(qualifiedName, schema);
20
21
  }
21
22
  getSchema(shapeId) {
22
23
  const id = this.normalizeShapeId(shapeId);
@@ -25,16 +26,25 @@ export class TypeRegistry {
25
26
  }
26
27
  return this.schemas.get(id);
27
28
  }
28
- registerError(errorSchema, ctor) {
29
- this.exceptions.set(errorSchema, ctor);
29
+ registerError(es, ctor) {
30
+ const $error = es;
31
+ const registry = TypeRegistry.for($error[1]);
32
+ registry.schemas.set($error[1] + "#" + $error[2], $error);
33
+ registry.exceptions.set($error, ctor);
30
34
  }
31
- getErrorCtor(errorSchema) {
32
- return this.exceptions.get(errorSchema);
35
+ getErrorCtor(es) {
36
+ const $error = es;
37
+ const registry = TypeRegistry.for($error[1]);
38
+ return registry.exceptions.get(es);
33
39
  }
34
40
  getBaseException() {
35
- for (const [id, schema] of this.schemas.entries()) {
36
- if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
37
- return schema;
41
+ for (const exceptionKey of this.exceptions.keys()) {
42
+ if (Array.isArray(exceptionKey)) {
43
+ const [, ns, name] = exceptionKey;
44
+ const id = ns + "#" + name;
45
+ if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
46
+ return exceptionKey;
47
+ }
38
48
  }
39
49
  }
40
50
  return undefined;
@@ -52,7 +62,4 @@ export class TypeRegistry {
52
62
  }
53
63
  return this.namespace + "#" + shapeId;
54
64
  }
55
- getNamespace(shapeId) {
56
- return this.normalizeShapeId(shapeId).split("#")[0];
57
- }
58
65
  }