@jjrawlins/cdk-iam-policy-builder-helper 0.0.57 → 0.0.59

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 (157) hide show
  1. package/.jsii +3 -3
  2. package/cdk-iam-policy-builder-helper/go.mod +2 -2
  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 +6 -6
  8. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +6 -6
  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 +2 -2
  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/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +1 -2
  16. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +7 -7
  17. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +1 -1
  18. package/node_modules/@aws-sdk/core/package.json +11 -11
  19. package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
  20. package/node_modules/@aws-sdk/credential-provider-http/package.json +10 -10
  21. package/node_modules/@aws-sdk/credential-provider-ini/package.json +13 -13
  22. package/node_modules/@aws-sdk/credential-provider-node/package.json +12 -12
  23. package/node_modules/@aws-sdk/credential-provider-process/package.json +6 -6
  24. package/node_modules/@aws-sdk/credential-provider-sso/package.json +8 -8
  25. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -7
  26. package/node_modules/@aws-sdk/middleware-host-header/dist-cjs/index.js +35 -63
  27. package/node_modules/@aws-sdk/middleware-host-header/package.json +4 -4
  28. package/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js +44 -75
  29. package/node_modules/@aws-sdk/middleware-logger/package.json +3 -3
  30. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-cjs/index.js +19 -48
  31. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +4 -4
  32. package/node_modules/@aws-sdk/middleware-user-agent/package.json +7 -7
  33. package/node_modules/@aws-sdk/nested-clients/package.json +32 -32
  34. package/node_modules/@aws-sdk/region-config-resolver/dist-cjs/index.js +59 -95
  35. package/node_modules/@aws-sdk/region-config-resolver/package.json +5 -5
  36. package/node_modules/@aws-sdk/token-providers/package.json +7 -7
  37. package/node_modules/@aws-sdk/types/dist-cjs/index.js +18 -290
  38. package/node_modules/@aws-sdk/types/package.json +2 -2
  39. package/node_modules/@aws-sdk/util-endpoints/dist-cjs/index.js +395 -469
  40. package/node_modules/@aws-sdk/util-endpoints/package.json +5 -5
  41. package/node_modules/@aws-sdk/util-user-agent-browser/package.json +3 -3
  42. package/node_modules/@aws-sdk/util-user-agent-node/package.json +5 -5
  43. package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +106 -160
  44. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.browser.js +4 -1
  45. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  46. package/node_modules/@smithy/abort-controller/package.json +2 -2
  47. package/node_modules/@smithy/config-resolver/package.json +4 -4
  48. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +1 -2
  49. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +3 -3
  50. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +235 -220
  51. package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +1 -2
  52. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +4 -4
  53. package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +16 -9
  54. package/node_modules/@smithy/core/dist-es/submodules/schema/index.js +1 -0
  55. package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js +4 -6
  56. package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js +4 -6
  57. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +26 -35
  58. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js +0 -2
  59. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +6 -0
  60. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/operation.js +7 -0
  61. package/node_modules/@smithy/core/dist-types/submodules/schema/TypeRegistry.d.ts +1 -2
  62. package/node_modules/@smithy/core/dist-types/submodules/schema/index.d.ts +1 -0
  63. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ErrorSchema.d.ts +2 -0
  64. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ListSchema.d.ts +2 -0
  65. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/MapSchema.d.ts +2 -0
  66. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +4 -21
  67. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/OperationSchema.d.ts +2 -0
  68. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/Schema.d.ts +1 -0
  69. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +7 -0
  70. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/StructureSchema.d.ts +2 -0
  71. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/operation.d.ts +7 -0
  72. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/TypeRegistry.d.ts +1 -2
  73. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/index.d.ts +1 -0
  74. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ErrorSchema.d.ts +2 -0
  75. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ListSchema.d.ts +2 -0
  76. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/MapSchema.d.ts +2 -0
  77. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +4 -21
  78. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/OperationSchema.d.ts +2 -0
  79. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/Schema.d.ts +1 -0
  80. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/SimpleSchema.d.ts +7 -0
  81. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/StructureSchema.d.ts +2 -0
  82. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/operation.d.ts +7 -0
  83. package/node_modules/@smithy/core/package.json +7 -7
  84. package/node_modules/@smithy/credential-provider-imds/package.json +5 -5
  85. package/node_modules/@smithy/fetch-http-handler/package.json +5 -5
  86. package/node_modules/@smithy/hash-node/package.json +2 -2
  87. package/node_modules/@smithy/invalid-dependency/package.json +2 -2
  88. package/node_modules/@smithy/middleware-content-length/package.json +3 -3
  89. package/node_modules/@smithy/middleware-endpoint/package.json +8 -8
  90. package/node_modules/@smithy/middleware-retry/package.json +8 -8
  91. package/node_modules/@smithy/middleware-serde/package.json +3 -3
  92. package/node_modules/@smithy/middleware-stack/package.json +2 -2
  93. package/node_modules/@smithy/node-config-provider/package.json +4 -4
  94. package/node_modules/@smithy/node-http-handler/package.json +5 -5
  95. package/node_modules/@smithy/property-provider/package.json +2 -2
  96. package/node_modules/@smithy/protocol-http/package.json +2 -2
  97. package/node_modules/@smithy/querystring-builder/package.json +2 -2
  98. package/node_modules/@smithy/querystring-parser/package.json +2 -2
  99. package/node_modules/@smithy/service-error-classification/package.json +2 -2
  100. package/node_modules/@smithy/shared-ini-file-loader/dist-cjs/index.js +2 -1
  101. package/node_modules/@smithy/shared-ini-file-loader/dist-es/constants.js +1 -0
  102. package/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigData.js +1 -1
  103. package/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSharedConfigFiles.js +1 -1
  104. package/node_modules/@smithy/shared-ini-file-loader/dist-es/parseIni.js +1 -1
  105. package/node_modules/@smithy/shared-ini-file-loader/dist-types/constants.d.ts +4 -0
  106. package/node_modules/@smithy/shared-ini-file-loader/dist-types/loadSharedConfigFiles.d.ts +1 -4
  107. package/node_modules/@smithy/shared-ini-file-loader/dist-types/ts3.4/constants.d.ts +4 -0
  108. package/node_modules/@smithy/shared-ini-file-loader/dist-types/ts3.4/loadSharedConfigFiles.d.ts +1 -4
  109. package/node_modules/@smithy/shared-ini-file-loader/package.json +2 -2
  110. package/node_modules/@smithy/signature-v4/package.json +4 -4
  111. package/node_modules/@smithy/smithy-client/package.json +7 -7
  112. package/node_modules/@smithy/types/dist-es/index.js +1 -0
  113. package/node_modules/@smithy/types/dist-es/schema/schema-deprecated.js +1 -0
  114. package/node_modules/@smithy/types/dist-types/index.d.ts +1 -0
  115. package/node_modules/@smithy/types/dist-types/schema/schema-deprecated.d.ts +136 -0
  116. package/node_modules/@smithy/types/dist-types/schema/schema.d.ts +26 -68
  117. package/node_modules/@smithy/types/dist-types/schema/static-schemas.d.ts +8 -8
  118. package/node_modules/@smithy/types/dist-types/serde.d.ts +2 -2
  119. package/node_modules/@smithy/types/dist-types/ts3.4/index.d.ts +1 -0
  120. package/node_modules/@smithy/types/dist-types/ts3.4/schema/schema-deprecated.d.ts +142 -0
  121. package/node_modules/@smithy/types/dist-types/ts3.4/schema/schema.d.ts +27 -72
  122. package/node_modules/@smithy/types/dist-types/ts3.4/schema/static-schemas.d.ts +10 -10
  123. package/node_modules/@smithy/types/dist-types/ts3.4/serde.d.ts +2 -2
  124. package/node_modules/@smithy/types/package.json +1 -1
  125. package/node_modules/@smithy/url-parser/package.json +3 -3
  126. package/node_modules/@smithy/util-defaults-mode-browser/package.json +4 -4
  127. package/node_modules/@smithy/util-defaults-mode-node/package.json +7 -7
  128. package/node_modules/@smithy/util-endpoints/dist-cjs/index.js +31 -22
  129. package/node_modules/@smithy/util-endpoints/dist-es/utils/callFunction.js +1 -11
  130. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateExpression.js +15 -2
  131. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateRules.js +17 -2
  132. package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateTreeRule.js +1 -13
  133. package/node_modules/@smithy/util-endpoints/dist-es/utils/getEndpointProperties.js +25 -2
  134. package/node_modules/@smithy/util-endpoints/dist-es/utils/getEndpointProperty.js +1 -21
  135. package/node_modules/@smithy/util-endpoints/dist-types/ts3.4/utils/callFunction.d.ts +1 -2
  136. package/node_modules/@smithy/util-endpoints/dist-types/ts3.4/utils/evaluateExpression.d.ts +7 -2
  137. package/node_modules/@smithy/util-endpoints/dist-types/ts3.4/utils/evaluateRules.d.ts +6 -1
  138. package/node_modules/@smithy/util-endpoints/dist-types/ts3.4/utils/evaluateTreeRule.d.ts +1 -3
  139. package/node_modules/@smithy/util-endpoints/dist-types/ts3.4/utils/getEndpointProperties.d.ts +6 -0
  140. package/node_modules/@smithy/util-endpoints/dist-types/ts3.4/utils/getEndpointProperty.d.ts +1 -3
  141. package/node_modules/@smithy/util-endpoints/dist-types/utils/callFunction.d.ts +1 -2
  142. package/node_modules/@smithy/util-endpoints/dist-types/utils/evaluateExpression.d.ts +7 -2
  143. package/node_modules/@smithy/util-endpoints/dist-types/utils/evaluateRules.d.ts +6 -1
  144. package/node_modules/@smithy/util-endpoints/dist-types/utils/evaluateTreeRule.d.ts +1 -3
  145. package/node_modules/@smithy/util-endpoints/dist-types/utils/getEndpointProperties.d.ts +6 -0
  146. package/node_modules/@smithy/util-endpoints/dist-types/utils/getEndpointProperty.d.ts +1 -3
  147. package/node_modules/@smithy/util-endpoints/package.json +3 -3
  148. package/node_modules/@smithy/util-middleware/package.json +2 -2
  149. package/node_modules/@smithy/util-retry/package.json +3 -3
  150. package/node_modules/@smithy/util-stream/dist-cjs/index.js +8 -15
  151. package/node_modules/@smithy/util-stream/dist-es/blob/Uint8ArrayBlobAdapter.js +10 -3
  152. package/node_modules/@smithy/util-stream/package.json +4 -4
  153. package/node_modules/@smithy/util-waiter/package.json +3 -3
  154. package/package.json +5 -5
  155. package/node_modules/@smithy/util-stream/dist-es/blob/transforms.js +0 -15
  156. package/node_modules/@smithy/util-stream/dist-types/blob/transforms.d.ts +0 -9
  157. package/node_modules/@smithy/util-stream/dist-types/ts3.4/blob/transforms.d.ts +0 -9
@@ -10,63 +10,111 @@ const deref = (schemaRef) => {
10
10
  return schemaRef;
11
11
  };
12
12
 
13
- class TypeRegistry {
14
- namespace;
15
- schemas;
16
- exceptions;
17
- static registries = new Map();
18
- constructor(namespace, schemas = new Map(), exceptions = new Map()) {
19
- this.namespace = namespace;
20
- this.schemas = schemas;
21
- this.exceptions = exceptions;
22
- }
23
- static for(namespace) {
24
- if (!TypeRegistry.registries.has(namespace)) {
25
- TypeRegistry.registries.set(namespace, new TypeRegistry(namespace));
26
- }
27
- return TypeRegistry.registries.get(namespace);
28
- }
29
- register(shapeId, schema) {
30
- const qualifiedName = this.normalizeShapeId(shapeId);
31
- this.schemas.set(qualifiedName, schema);
32
- }
33
- getSchema(shapeId) {
34
- const id = this.normalizeShapeId(shapeId);
35
- if (!this.schemas.has(id)) {
36
- throw new Error(`@smithy/core/schema - schema not found for ${id}`);
37
- }
38
- return this.schemas.get(id);
39
- }
40
- registerError(es, ctor) {
41
- this.exceptions.set(es, ctor);
42
- }
43
- getErrorCtor(es) {
44
- return this.exceptions.get(es);
13
+ const operation = (namespace, name, traits, input, output) => ({
14
+ name,
15
+ namespace,
16
+ traits,
17
+ input,
18
+ output,
19
+ });
20
+
21
+ const schemaDeserializationMiddleware = (config) => (next, context) => async (args) => {
22
+ const { response } = await next(args);
23
+ const { operationSchema } = utilMiddleware.getSmithyContext(context);
24
+ const [, ns, n, t, i, o] = operationSchema ?? [];
25
+ try {
26
+ const parsed = await config.protocol.deserializeResponse(operation(ns, n, t, i, o), {
27
+ ...config,
28
+ ...context,
29
+ }, response);
30
+ return {
31
+ response,
32
+ output: parsed,
33
+ };
45
34
  }
46
- getBaseException() {
47
- for (const [id, schema] of this.schemas.entries()) {
48
- if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
49
- return schema;
35
+ catch (error) {
36
+ Object.defineProperty(error, "$response", {
37
+ value: response,
38
+ });
39
+ if (!("$metadata" in error)) {
40
+ const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
41
+ try {
42
+ error.message += "\n " + hint;
43
+ }
44
+ catch (e) {
45
+ if (!context.logger || context.logger?.constructor?.name === "NoOpLogger") {
46
+ console.warn(hint);
47
+ }
48
+ else {
49
+ context.logger?.warn?.(hint);
50
+ }
51
+ }
52
+ if (typeof error.$responseBodyText !== "undefined") {
53
+ if (error.$response) {
54
+ error.$response.body = error.$responseBodyText;
55
+ }
56
+ }
57
+ try {
58
+ if (protocolHttp.HttpResponse.isInstance(response)) {
59
+ const { headers = {} } = response;
60
+ const headerEntries = Object.entries(headers);
61
+ error.$metadata = {
62
+ httpStatusCode: response.statusCode,
63
+ requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries),
64
+ extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries),
65
+ cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries),
66
+ };
67
+ }
68
+ }
69
+ catch (e) {
50
70
  }
51
71
  }
52
- return undefined;
53
- }
54
- find(predicate) {
55
- return [...this.schemas.values()].find(predicate);
56
- }
57
- clear() {
58
- this.schemas.clear();
59
- this.exceptions.clear();
60
- }
61
- normalizeShapeId(shapeId) {
62
- if (shapeId.includes("#")) {
63
- return shapeId;
64
- }
65
- return this.namespace + "#" + shapeId;
66
- }
67
- getNamespace(shapeId) {
68
- return this.normalizeShapeId(shapeId).split("#")[0];
72
+ throw error;
69
73
  }
74
+ };
75
+ const findHeader = (pattern, headers) => {
76
+ return (headers.find(([k]) => {
77
+ return k.match(pattern);
78
+ }) || [void 0, void 0])[1];
79
+ };
80
+
81
+ const schemaSerializationMiddleware = (config) => (next, context) => async (args) => {
82
+ const { operationSchema } = utilMiddleware.getSmithyContext(context);
83
+ const [, ns, n, t, i, o] = operationSchema ?? [];
84
+ const endpoint = context.endpointV2?.url && config.urlParser
85
+ ? async () => config.urlParser(context.endpointV2.url)
86
+ : config.endpoint;
87
+ const request = await config.protocol.serializeRequest(operation(ns, n, t, i, o), args.input, {
88
+ ...config,
89
+ ...context,
90
+ endpoint,
91
+ });
92
+ return next({
93
+ ...args,
94
+ request,
95
+ });
96
+ };
97
+
98
+ const deserializerMiddlewareOption = {
99
+ name: "deserializerMiddleware",
100
+ step: "deserialize",
101
+ tags: ["DESERIALIZER"],
102
+ override: true,
103
+ };
104
+ const serializerMiddlewareOption = {
105
+ name: "serializerMiddleware",
106
+ step: "serialize",
107
+ tags: ["SERIALIZER"],
108
+ override: true,
109
+ };
110
+ function getSchemaSerdePlugin(config) {
111
+ return {
112
+ applyToStack: (commandStack) => {
113
+ commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption);
114
+ commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption);
115
+ config.protocol.setSerdeContext(config);
116
+ },
117
+ };
70
118
  }
71
119
 
72
120
  class Schema {
@@ -75,7 +123,6 @@ class Schema {
75
123
  traits;
76
124
  static assign(instance, values) {
77
125
  const schema = Object.assign(instance, values);
78
- TypeRegistry.for(schema.namespace).register(schema.name, schema);
79
126
  return schema;
80
127
  }
81
128
  static [Symbol.hasInstance](lhs) {
@@ -91,36 +138,6 @@ class Schema {
91
138
  }
92
139
  }
93
140
 
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
-
124
141
  class ListSchema extends Schema {
125
142
  static symbol = Symbol.for("@smithy/lis");
126
143
  name;
@@ -167,18 +184,34 @@ const op = (namespace, name, traits, input, output) => Schema.assign(new Operati
167
184
  output,
168
185
  });
169
186
 
170
- class SimpleSchema extends Schema {
171
- static symbol = Symbol.for("@smithy/sim");
187
+ class StructureSchema extends Schema {
188
+ static symbol = Symbol.for("@smithy/str");
172
189
  name;
173
- schemaRef;
174
190
  traits;
175
- symbol = SimpleSchema.symbol;
191
+ memberNames;
192
+ memberList;
193
+ symbol = StructureSchema.symbol;
176
194
  }
177
- const sim = (namespace, name, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
195
+ const struct = (namespace, name, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), {
178
196
  name,
179
197
  namespace,
180
198
  traits,
181
- schemaRef,
199
+ memberNames,
200
+ memberList,
201
+ });
202
+
203
+ class ErrorSchema extends StructureSchema {
204
+ static symbol = Symbol.for("@smithy/err");
205
+ ctor;
206
+ symbol = ErrorSchema.symbol;
207
+ }
208
+ const error = (namespace, name, traits, memberNames, memberList, ctor) => Schema.assign(new ErrorSchema(), {
209
+ name,
210
+ namespace,
211
+ traits,
212
+ memberNames,
213
+ memberList,
214
+ ctor: null,
182
215
  });
183
216
 
184
217
  function translateTraits(indicator) {
@@ -228,8 +261,6 @@ class NormalizedSchema {
228
261
  schema = deref(_ref);
229
262
  this._isMemberSchema = true;
230
263
  }
231
- if (isStaticSchema(schema))
232
- schema = hydrate(schema);
233
264
  if (traitStack.length > 0) {
234
265
  this.memberTraits = {};
235
266
  for (let i = traitStack.length - 1; i >= 0; --i) {
@@ -249,19 +280,25 @@ class NormalizedSchema {
249
280
  return;
250
281
  }
251
282
  this.schema = deref(schema);
252
- if (this.schema && typeof this.schema === "object") {
253
- this.traits = this.schema?.traits ?? {};
283
+ if (isStaticSchema(this.schema)) {
284
+ this.name = `${this.schema[1]}#${this.schema[2]}`;
285
+ this.traits = this.schema[3];
254
286
  }
255
287
  else {
288
+ this.name = this.memberName ?? String(schema);
256
289
  this.traits = 0;
257
290
  }
258
- this.name = (this.schema instanceof Schema ? this.schema.getName?.() : void 0) ?? this.memberName ?? String(schema);
259
291
  if (this._isMemberSchema && !memberName) {
260
292
  throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(true)} missing member name.`);
261
293
  }
262
294
  }
263
295
  static [Symbol.hasInstance](lhs) {
264
- return Schema[Symbol.hasInstance].bind(this)(lhs);
296
+ const isPrototype = this.prototype.isPrototypeOf(lhs);
297
+ if (!isPrototype && typeof lhs === "object" && lhs !== null) {
298
+ const ns = lhs;
299
+ return ns.symbol === this.symbol;
300
+ }
301
+ return isPrototype;
265
302
  }
266
303
  static of(ref) {
267
304
  const sc = deref(ref);
@@ -279,7 +316,11 @@ class NormalizedSchema {
279
316
  return new NormalizedSchema(sc);
280
317
  }
281
318
  getSchema() {
282
- return deref(this.schema?.schemaRef ?? this.schema);
319
+ const sc = this.schema;
320
+ if (sc[0] === 0) {
321
+ return sc[4];
322
+ }
323
+ return sc;
283
324
  }
284
325
  getName(withNamespace = false) {
285
326
  const { name } = this;
@@ -296,17 +337,18 @@ class NormalizedSchema {
296
337
  const sc = this.getSchema();
297
338
  return typeof sc === "number"
298
339
  ? sc >= 64 && sc < 128
299
- : sc instanceof ListSchema;
340
+ : sc[0] === 1;
300
341
  }
301
342
  isMapSchema() {
302
343
  const sc = this.getSchema();
303
344
  return typeof sc === "number"
304
345
  ? sc >= 128 && sc <= 0b1111_1111
305
- : sc instanceof MapSchema;
346
+ : sc[0] === 2;
306
347
  }
307
348
  isStructSchema() {
308
349
  const sc = this.getSchema();
309
- return (sc !== null && typeof sc === "object" && "members" in sc) || sc instanceof StructureSchema;
350
+ return (sc[0] === 3 ||
351
+ sc[0] === -3);
310
352
  }
311
353
  isBlobSchema() {
312
354
  const sc = this.getSchema();
@@ -370,7 +412,7 @@ class NormalizedSchema {
370
412
  const schema = this.getSchema();
371
413
  const memberSchema = isDoc
372
414
  ? 15
373
- : schema?.keySchema ?? 0;
415
+ : schema[4] ?? 0;
374
416
  return member([memberSchema, 0], "key");
375
417
  }
376
418
  getValueSchema() {
@@ -379,7 +421,7 @@ class NormalizedSchema {
379
421
  const memberSchema = typeof sc === "number"
380
422
  ? 0b0011_1111 & sc
381
423
  : sc && typeof sc === "object" && (isMap || isList)
382
- ? sc.valueSchema
424
+ ? sc[3 + sc[0]]
383
425
  : isDoc
384
426
  ? 15
385
427
  : void 0;
@@ -390,9 +432,9 @@ class NormalizedSchema {
390
432
  }
391
433
  getMemberSchema(memberName) {
392
434
  const struct = this.getSchema();
393
- if (this.isStructSchema() && struct.memberNames.includes(memberName)) {
394
- const i = struct.memberNames.indexOf(memberName);
395
- const memberSchema = struct.memberList[i];
435
+ if (this.isStructSchema() && struct[4].includes(memberName)) {
436
+ const i = struct[4].indexOf(memberName);
437
+ const memberSchema = struct[5][i];
396
438
  return member(isMemberSchema(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
397
439
  }
398
440
  if (this.isDocumentSchema()) {
@@ -428,8 +470,8 @@ class NormalizedSchema {
428
470
  throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");
429
471
  }
430
472
  const struct = this.getSchema();
431
- for (let i = 0; i < struct.memberNames.length; ++i) {
432
- yield [struct.memberNames[i], member([struct.memberList[i], 0], struct.memberNames[i])];
473
+ for (let i = 0; i < struct[4].length; ++i) {
474
+ yield [struct[4][i], member([struct[5][i], 0], struct[4][i])];
433
475
  }
434
476
  }
435
477
  }
@@ -443,122 +485,28 @@ function member(memberSchema, memberName) {
443
485
  const internalCtorAccess = NormalizedSchema;
444
486
  return new internalCtorAccess(memberSchema, memberName);
445
487
  }
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
488
  const isMemberSchema = (sc) => Array.isArray(sc) && sc.length === 2;
458
489
  const isStaticSchema = (sc) => Array.isArray(sc) && sc.length >= 5;
459
490
 
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
- };
491
+ class SimpleSchema extends Schema {
492
+ static symbol = Symbol.for("@smithy/sim");
493
+ name;
494
+ schemaRef;
495
+ traits;
496
+ symbol = SimpleSchema.symbol;
561
497
  }
498
+ const sim = (namespace, name, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
499
+ name,
500
+ namespace,
501
+ traits,
502
+ schemaRef,
503
+ });
504
+ const simAdapter = (namespace, name, traits, schemaRef) => Schema.assign(new SimpleSchema(), {
505
+ name,
506
+ namespace,
507
+ traits,
508
+ schemaRef,
509
+ });
562
510
 
563
511
  const SCHEMA = {
564
512
  BLOB: 0b0001_0101,
@@ -577,6 +525,72 @@ const SCHEMA = {
577
525
  MAP_MODIFIER: 0b1000_0000,
578
526
  };
579
527
 
528
+ class TypeRegistry {
529
+ namespace;
530
+ schemas;
531
+ exceptions;
532
+ static registries = new Map();
533
+ constructor(namespace, schemas = new Map(), exceptions = new Map()) {
534
+ this.namespace = namespace;
535
+ this.schemas = schemas;
536
+ this.exceptions = exceptions;
537
+ }
538
+ static for(namespace) {
539
+ if (!TypeRegistry.registries.has(namespace)) {
540
+ TypeRegistry.registries.set(namespace, new TypeRegistry(namespace));
541
+ }
542
+ return TypeRegistry.registries.get(namespace);
543
+ }
544
+ register(shapeId, schema) {
545
+ const qualifiedName = this.normalizeShapeId(shapeId);
546
+ const registry = TypeRegistry.for(qualifiedName.split("#")[0]);
547
+ registry.schemas.set(qualifiedName, schema);
548
+ }
549
+ getSchema(shapeId) {
550
+ const id = this.normalizeShapeId(shapeId);
551
+ if (!this.schemas.has(id)) {
552
+ throw new Error(`@smithy/core/schema - schema not found for ${id}`);
553
+ }
554
+ return this.schemas.get(id);
555
+ }
556
+ registerError(es, ctor) {
557
+ const $error = es;
558
+ const registry = TypeRegistry.for($error[1]);
559
+ registry.schemas.set($error[1] + "#" + $error[2], $error);
560
+ registry.exceptions.set($error, ctor);
561
+ }
562
+ getErrorCtor(es) {
563
+ const $error = es;
564
+ const registry = TypeRegistry.for($error[1]);
565
+ return registry.exceptions.get($error);
566
+ }
567
+ getBaseException() {
568
+ for (const exceptionKey of this.exceptions.keys()) {
569
+ if (Array.isArray(exceptionKey)) {
570
+ const [, ns, name] = exceptionKey;
571
+ const id = ns + "#" + name;
572
+ if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
573
+ return exceptionKey;
574
+ }
575
+ }
576
+ }
577
+ return undefined;
578
+ }
579
+ find(predicate) {
580
+ return [...this.schemas.values()].find(predicate);
581
+ }
582
+ clear() {
583
+ this.schemas.clear();
584
+ this.exceptions.clear();
585
+ }
586
+ normalizeShapeId(shapeId) {
587
+ if (shapeId.includes("#")) {
588
+ return shapeId;
589
+ }
590
+ return this.namespace + "#" + shapeId;
591
+ }
592
+ }
593
+
580
594
  exports.ErrorSchema = ErrorSchema;
581
595
  exports.ListSchema = ListSchema;
582
596
  exports.MapSchema = MapSchema;
@@ -591,12 +605,13 @@ exports.deref = deref;
591
605
  exports.deserializerMiddlewareOption = deserializerMiddlewareOption;
592
606
  exports.error = error;
593
607
  exports.getSchemaSerdePlugin = getSchemaSerdePlugin;
594
- exports.hydrate = hydrate;
595
608
  exports.isStaticSchema = isStaticSchema;
596
609
  exports.list = list;
597
610
  exports.map = map;
598
611
  exports.op = op;
612
+ exports.operation = operation;
599
613
  exports.serializerMiddlewareOption = serializerMiddlewareOption;
600
614
  exports.sim = sim;
615
+ exports.simAdapter = simAdapter;
601
616
  exports.struct = struct;
602
617
  exports.translateTraits = translateTraits;
@@ -16,7 +16,6 @@ export class EventStreamSerde {
16
16
  const marshaller = this.marshaller;
17
17
  const eventStreamMember = requestSchema.getEventStreamMember();
18
18
  const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
19
- const memberSchemas = unionSchema.getMemberSchemas();
20
19
  const serializer = this.serializer;
21
20
  const defaultContentType = this.defaultContentType;
22
21
  const initialRequestMarker = Symbol("initialRequestMarker");
@@ -129,7 +128,7 @@ export class EventStreamSerde {
129
128
  let explicitPayloadContentType;
130
129
  const isKnownSchema = (() => {
131
130
  const struct = unionSchema.getSchema();
132
- return struct.memberNames.includes(unionMember);
131
+ return struct[4].includes(unionMember);
133
132
  })();
134
133
  const additionalHeaders = {};
135
134
  if (!isKnownSchema) {
@@ -1,4 +1,4 @@
1
- import { NormalizedSchema } from "@smithy/core/schema";
1
+ import { NormalizedSchema, translateTraits } from "@smithy/core/schema";
2
2
  import { HttpRequest, HttpResponse } from "@smithy/protocol-http";
3
3
  import { SerdeContext } from "./SerdeContext";
4
4
  export class HttpProtocol extends SerdeContext {
@@ -50,10 +50,10 @@ export class HttpProtocol extends SerdeContext {
50
50
  }
51
51
  }
52
52
  setHostPrefix(request, operationSchema, input) {
53
- const operationNs = NormalizedSchema.of(operationSchema);
54
53
  const inputNs = NormalizedSchema.of(operationSchema.input);
55
- if (operationNs.getMergedTraits().endpoint) {
56
- let hostPrefix = operationNs.getMergedTraits().endpoint?.[0];
54
+ const opTraits = translateTraits(operationSchema.traits ?? {});
55
+ if (opTraits.endpoint) {
56
+ let hostPrefix = opTraits.endpoint?.[0];
57
57
  if (typeof hostPrefix === "string") {
58
58
  const hostLabelInputs = [...inputNs.structIterator()].filter(([, member]) => member.getMergedTraits().hostLabel);
59
59
  for (const [name] of hostLabelInputs) {
@@ -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);
@@ -26,15 +27,24 @@ export class TypeRegistry {
26
27
  return this.schemas.get(id);
27
28
  }
28
29
  registerError(es, ctor) {
29
- this.exceptions.set(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
35
  getErrorCtor(es) {
32
- return this.exceptions.get(es);
36
+ const $error = es;
37
+ const registry = TypeRegistry.for($error[1]);
38
+ return registry.exceptions.get($error);
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
  }
@@ -3,6 +3,7 @@ export * from "./middleware/getSchemaSerdePlugin";
3
3
  export * from "./schemas/ListSchema";
4
4
  export * from "./schemas/MapSchema";
5
5
  export * from "./schemas/OperationSchema";
6
+ export * from "./schemas/operation";
6
7
  export * from "./schemas/ErrorSchema";
7
8
  export * from "./schemas/NormalizedSchema";
8
9
  export * from "./schemas/Schema";