@cdk8s/awscdk-resolver 0.0.357 → 0.0.359

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 (100) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws/lambda-invoke-store/LICENSE +175 -0
  4. package/node_modules/@aws/lambda-invoke-store/README.md +182 -0
  5. package/node_modules/@aws/lambda-invoke-store/dist/invoke-store.d.ts +52 -0
  6. package/node_modules/@aws/lambda-invoke-store/dist/invoke-store.js +90 -0
  7. package/node_modules/@aws/lambda-invoke-store/package.json +36 -0
  8. package/node_modules/@aws-sdk/client-cloudformation/package.json +3 -3
  9. package/node_modules/@aws-sdk/client-sso/package.json +2 -2
  10. package/node_modules/@aws-sdk/credential-provider-ini/package.json +4 -4
  11. package/node_modules/@aws-sdk/credential-provider-node/package.json +4 -4
  12. package/node_modules/@aws-sdk/credential-provider-sso/package.json +3 -3
  13. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +2 -2
  14. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-cjs/index.js +14 -32
  15. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-cjs/recursionDetectionMiddleware.js +32 -0
  16. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-cjs/recursionDetectionMiddleware.native.js +5 -0
  17. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-es/configuration.js +7 -0
  18. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-es/getRecursionDetectionPlugin.js +7 -0
  19. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-es/index.js +2 -37
  20. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-es/recursionDetectionMiddleware.browser.js +1 -0
  21. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-es/recursionDetectionMiddleware.js +28 -0
  22. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-es/recursionDetectionMiddleware.native.js +1 -0
  23. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/configuration.d.ts +5 -0
  24. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/getRecursionDetectionPlugin.d.ts +5 -0
  25. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/index.d.ts +2 -18
  26. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/recursionDetectionMiddleware.browser.d.ts +6 -0
  27. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/recursionDetectionMiddleware.d.ts +6 -0
  28. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/recursionDetectionMiddleware.native.d.ts +6 -0
  29. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/ts3.4/configuration.d.ts +3 -0
  30. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/ts3.4/getRecursionDetectionPlugin.d.ts +4 -0
  31. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/ts3.4/index.d.ts +2 -18
  32. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/ts3.4/recursionDetectionMiddleware.browser.d.ts +5 -0
  33. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/ts3.4/recursionDetectionMiddleware.d.ts +5 -0
  34. package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/ts3.4/recursionDetectionMiddleware.native.d.ts +5 -0
  35. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +7 -2
  36. package/node_modules/@aws-sdk/nested-clients/package.json +2 -2
  37. package/node_modules/@aws-sdk/token-providers/package.json +2 -2
  38. package/node_modules/@smithy/abort-controller/package.json +2 -2
  39. package/node_modules/@smithy/config-resolver/package.json +4 -4
  40. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +14 -16
  41. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +155 -221
  42. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +12 -10
  43. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js +12 -22
  44. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js +9 -20
  45. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js +10 -21
  46. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +76 -87
  47. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/OperationSchema.js +11 -12
  48. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js +16 -3
  49. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +9 -20
  50. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js +10 -27
  51. package/node_modules/@smithy/core/dist-types/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +1 -2
  52. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ErrorSchema.d.ts +3 -16
  53. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ListSchema.d.ts +3 -5
  54. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/MapSchema.d.ts +3 -9
  55. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +15 -13
  56. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/OperationSchema.d.ts +3 -2
  57. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/Schema.d.ts +5 -1
  58. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +3 -5
  59. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/StructureSchema.d.ts +3 -6
  60. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +1 -2
  61. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ErrorSchema.d.ts +3 -16
  62. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ListSchema.d.ts +3 -5
  63. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/MapSchema.d.ts +3 -9
  64. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +15 -13
  65. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/OperationSchema.d.ts +3 -2
  66. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/Schema.d.ts +5 -1
  67. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/SimpleSchema.d.ts +3 -5
  68. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/StructureSchema.d.ts +3 -9
  69. package/node_modules/@smithy/core/package.json +7 -7
  70. package/node_modules/@smithy/credential-provider-imds/package.json +5 -5
  71. package/node_modules/@smithy/fetch-http-handler/package.json +5 -5
  72. package/node_modules/@smithy/hash-node/package.json +2 -2
  73. package/node_modules/@smithy/invalid-dependency/package.json +2 -2
  74. package/node_modules/@smithy/middleware-content-length/package.json +3 -3
  75. package/node_modules/@smithy/middleware-endpoint/package.json +8 -8
  76. package/node_modules/@smithy/middleware-retry/package.json +8 -8
  77. package/node_modules/@smithy/middleware-serde/package.json +3 -3
  78. package/node_modules/@smithy/middleware-stack/package.json +2 -2
  79. package/node_modules/@smithy/node-config-provider/package.json +4 -4
  80. package/node_modules/@smithy/node-http-handler/package.json +5 -5
  81. package/node_modules/@smithy/property-provider/package.json +2 -2
  82. package/node_modules/@smithy/protocol-http/package.json +2 -2
  83. package/node_modules/@smithy/querystring-builder/package.json +2 -2
  84. package/node_modules/@smithy/querystring-parser/package.json +2 -2
  85. package/node_modules/@smithy/service-error-classification/package.json +2 -2
  86. package/node_modules/@smithy/shared-ini-file-loader/package.json +2 -2
  87. package/node_modules/@smithy/signature-v4/package.json +4 -4
  88. package/node_modules/@smithy/smithy-client/package.json +7 -7
  89. package/node_modules/@smithy/types/dist-types/schema/schema.d.ts +9 -2
  90. package/node_modules/@smithy/types/dist-types/ts3.4/schema/schema.d.ts +13 -3
  91. package/node_modules/@smithy/types/package.json +1 -1
  92. package/node_modules/@smithy/url-parser/package.json +3 -3
  93. package/node_modules/@smithy/util-defaults-mode-browser/package.json +4 -4
  94. package/node_modules/@smithy/util-defaults-mode-node/package.json +7 -7
  95. package/node_modules/@smithy/util-endpoints/package.json +3 -3
  96. package/node_modules/@smithy/util-middleware/package.json +2 -2
  97. package/node_modules/@smithy/util-retry/package.json +3 -3
  98. package/node_modules/@smithy/util-stream/package.json +4 -4
  99. package/node_modules/@smithy/util-waiter/package.json +3 -3
  100. package/package.json +5 -5
@@ -1,25 +1,14 @@
1
- import { TypeRegistry } from "../TypeRegistry";
2
1
  import { Schema } from "./Schema";
3
2
  export class ListSchema extends Schema {
4
- constructor(name, traits, valueSchema) {
5
- super(name, traits);
6
- this.name = name;
7
- this.traits = traits;
8
- this.valueSchema = valueSchema;
3
+ constructor() {
4
+ super(...arguments);
9
5
  this.symbol = ListSchema.symbol;
10
6
  }
11
- static [Symbol.hasInstance](lhs) {
12
- const isPrototype = ListSchema.prototype.isPrototypeOf(lhs);
13
- if (!isPrototype && typeof lhs === "object" && lhs !== null) {
14
- const list = lhs;
15
- return list.symbol === ListSchema.symbol;
16
- }
17
- return isPrototype;
18
- }
19
- }
20
- ListSchema.symbol = Symbol.for("@smithy/core/schema::ListSchema");
21
- export function list(namespace, name, traits = {}, valueSchema) {
22
- const schema = new ListSchema(namespace + "#" + name, traits, typeof valueSchema === "function" ? valueSchema() : valueSchema);
23
- TypeRegistry.for(namespace).register(name, schema);
24
- return schema;
25
7
  }
8
+ ListSchema.symbol = Symbol.for("@smithy/lis");
9
+ export const list = (namespace, name, traits, valueSchema) => Schema.assign(new ListSchema(), {
10
+ name,
11
+ namespace,
12
+ traits,
13
+ valueSchema,
14
+ });
@@ -1,26 +1,15 @@
1
- import { TypeRegistry } from "../TypeRegistry";
2
1
  import { Schema } from "./Schema";
3
2
  export class MapSchema extends Schema {
4
- constructor(name, traits, keySchema, valueSchema) {
5
- super(name, traits);
6
- this.name = name;
7
- this.traits = traits;
8
- this.keySchema = keySchema;
9
- this.valueSchema = valueSchema;
3
+ constructor() {
4
+ super(...arguments);
10
5
  this.symbol = MapSchema.symbol;
11
6
  }
12
- static [Symbol.hasInstance](lhs) {
13
- const isPrototype = MapSchema.prototype.isPrototypeOf(lhs);
14
- if (!isPrototype && typeof lhs === "object" && lhs !== null) {
15
- const map = lhs;
16
- return map.symbol === MapSchema.symbol;
17
- }
18
- return isPrototype;
19
- }
20
- }
21
- MapSchema.symbol = Symbol.for("@smithy/core/schema::MapSchema");
22
- export function map(namespace, name, traits = {}, keySchema, valueSchema) {
23
- const schema = new MapSchema(namespace + "#" + name, traits, keySchema, typeof valueSchema === "function" ? valueSchema() : valueSchema);
24
- TypeRegistry.for(namespace).register(name, schema);
25
- return schema;
26
7
  }
8
+ MapSchema.symbol = Symbol.for("@smithy/map");
9
+ export const map = (namespace, name, traits, keySchema, valueSchema) => Schema.assign(new MapSchema(), {
10
+ name,
11
+ namespace,
12
+ traits,
13
+ keySchema,
14
+ valueSchema,
15
+ });
@@ -1,6 +1,7 @@
1
1
  import { deref } from "../deref";
2
2
  import { ListSchema } from "./ListSchema";
3
3
  import { MapSchema } from "./MapSchema";
4
+ import { Schema } from "./Schema";
4
5
  import { SCHEMA } from "./sentinels";
5
6
  import { SimpleSchema } from "./SimpleSchema";
6
7
  import { StructureSchema } from "./StructureSchema";
@@ -30,13 +31,9 @@ export class NormalizedSchema {
30
31
  this.memberTraits = 0;
31
32
  }
32
33
  if (schema instanceof NormalizedSchema) {
33
- this.name = schema.name;
34
- this.traits = schema.traits;
35
- this._isMemberSchema = schema._isMemberSchema;
36
- this.schema = schema.schema;
34
+ Object.assign(this, schema);
37
35
  this.memberTraits = Object.assign({}, schema.getMemberTraits(), this.getMemberTraits());
38
36
  this.normalizedTraits = void 0;
39
- this.ref = schema.ref;
40
37
  this.memberName = memberName ?? schema.memberName;
41
38
  return;
42
39
  }
@@ -48,24 +45,27 @@ export class NormalizedSchema {
48
45
  this.traits = 0;
49
46
  }
50
47
  this.name =
51
- (typeof this.schema === "object" ? this.schema?.name : void 0) ?? this.memberName ?? this.getSchemaName();
48
+ (this.schema instanceof Schema ? this.schema.getName?.() : void 0) ?? this.memberName ?? this.getSchemaName();
52
49
  if (this._isMemberSchema && !memberName) {
53
- throw new Error(`@smithy/core/schema - NormalizedSchema member schema ${this.getName(true)} must initialize with memberName argument.`);
50
+ throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(true)} missing member name.`);
54
51
  }
55
52
  }
56
53
  static [Symbol.hasInstance](lhs) {
57
- const isPrototype = NormalizedSchema.prototype.isPrototypeOf(lhs);
58
- if (!isPrototype && typeof lhs === "object" && lhs !== null) {
59
- const ns = lhs;
60
- return ns.symbol === NormalizedSchema.symbol;
61
- }
62
- return isPrototype;
54
+ return Schema[Symbol.hasInstance].bind(this)(lhs);
63
55
  }
64
- static of(ref, memberName) {
56
+ static of(ref) {
65
57
  if (ref instanceof NormalizedSchema) {
66
58
  return ref;
67
59
  }
68
- return new NormalizedSchema(ref, memberName);
60
+ if (Array.isArray(ref)) {
61
+ const [ns, traits] = ref;
62
+ if (ns instanceof NormalizedSchema) {
63
+ Object.assign(ns.getMergedTraits(), NormalizedSchema.translateTraits(traits));
64
+ return ns;
65
+ }
66
+ throw new Error(`@smithy/core/schema - may not init unwrapped member schema=${JSON.stringify(ref, null, 2)}.`);
67
+ }
68
+ return new NormalizedSchema(ref);
69
69
  }
70
70
  static translateTraits(indicator) {
71
71
  if (typeof indicator === "object") {
@@ -73,40 +73,26 @@ export class NormalizedSchema {
73
73
  }
74
74
  indicator = indicator | 0;
75
75
  const traits = {};
76
- if ((indicator & 1) === 1) {
77
- traits.httpLabel = 1;
78
- }
79
- if (((indicator >> 1) & 1) === 1) {
80
- traits.idempotent = 1;
81
- }
82
- if (((indicator >> 2) & 1) === 1) {
83
- traits.idempotencyToken = 1;
84
- }
85
- if (((indicator >> 3) & 1) === 1) {
86
- traits.sensitive = 1;
87
- }
88
- if (((indicator >> 4) & 1) === 1) {
89
- traits.httpPayload = 1;
90
- }
91
- if (((indicator >> 5) & 1) === 1) {
92
- traits.httpResponseCode = 1;
93
- }
94
- if (((indicator >> 6) & 1) === 1) {
95
- traits.httpQueryParams = 1;
76
+ let i = 0;
77
+ for (const trait of [
78
+ "httpLabel",
79
+ "idempotent",
80
+ "idempotencyToken",
81
+ "sensitive",
82
+ "httpPayload",
83
+ "httpResponseCode",
84
+ "httpQueryParams",
85
+ ]) {
86
+ if (((indicator >> i++) & 1) === 1) {
87
+ traits[trait] = 1;
88
+ }
96
89
  }
97
90
  return traits;
98
91
  }
99
- static memberFrom(memberSchema, memberName) {
100
- if (memberSchema instanceof NormalizedSchema) {
101
- memberSchema.memberName = memberName;
102
- memberSchema._isMemberSchema = true;
103
- return memberSchema;
104
- }
105
- return new NormalizedSchema(memberSchema, memberName);
106
- }
107
92
  getSchema() {
108
93
  if (this.schema instanceof NormalizedSchema) {
109
- return (this.schema = this.schema.getSchema());
94
+ Object.assign(this, { schema: this.schema.getSchema() });
95
+ return this.schema;
110
96
  }
111
97
  if (this.schema instanceof SimpleSchema) {
112
98
  return deref(this.schema.schemaRef);
@@ -123,7 +109,7 @@ export class NormalizedSchema {
123
109
  }
124
110
  getMemberName() {
125
111
  if (!this.isMemberSchema()) {
126
- throw new Error(`@smithy/core/schema - cannot get member name on non-member schema: ${this.getName(true)}`);
112
+ throw new Error(`@smithy/core/schema - non-member schema: ${this.getName(true)}`);
127
113
  }
128
114
  return this.memberName;
129
115
  }
@@ -147,9 +133,6 @@ export class NormalizedSchema {
147
133
  }
148
134
  return inner instanceof MapSchema;
149
135
  }
150
- isDocumentSchema() {
151
- return this.getSchema() === SCHEMA.DOCUMENT;
152
- }
153
136
  isStructSchema() {
154
137
  const inner = this.getSchema();
155
138
  return (inner !== null && typeof inner === "object" && "members" in inner) || inner instanceof StructureSchema;
@@ -161,6 +144,9 @@ export class NormalizedSchema {
161
144
  const schema = this.getSchema();
162
145
  return typeof schema === "number" && schema >= SCHEMA.TIMESTAMP_DEFAULT && schema <= SCHEMA.TIMESTAMP_EPOCH_SECONDS;
163
146
  }
147
+ isDocumentSchema() {
148
+ return this.getSchema() === SCHEMA.DOCUMENT;
149
+ }
164
150
  isStringSchema() {
165
151
  return this.getSchema() === SCHEMA.STRING;
166
152
  }
@@ -193,14 +179,11 @@ export class NormalizedSchema {
193
179
  return false;
194
180
  }
195
181
  getMergedTraits() {
196
- if (this.normalizedTraits) {
197
- return this.normalizedTraits;
198
- }
199
- this.normalizedTraits = {
200
- ...this.getOwnTraits(),
201
- ...this.getMemberTraits(),
202
- };
203
- return this.normalizedTraits;
182
+ return (this.normalizedTraits ??
183
+ (this.normalizedTraits = {
184
+ ...this.getOwnTraits(),
185
+ ...this.getMemberTraits(),
186
+ }));
204
187
  }
205
188
  getMemberTraits() {
206
189
  return NormalizedSchema.translateTraits(this.memberTraits);
@@ -210,80 +193,77 @@ export class NormalizedSchema {
210
193
  }
211
194
  getKeySchema() {
212
195
  if (this.isDocumentSchema()) {
213
- return NormalizedSchema.memberFrom([SCHEMA.DOCUMENT, 0], "key");
196
+ return this.memberFrom([SCHEMA.DOCUMENT, 0], "key");
214
197
  }
215
198
  if (!this.isMapSchema()) {
216
- throw new Error(`@smithy/core/schema - cannot get key schema for non-map schema: ${this.getName(true)}`);
199
+ throw new Error(`@smithy/core/schema - cannot get key for non-map: ${this.getName(true)}`);
217
200
  }
218
201
  const schema = this.getSchema();
219
202
  if (typeof schema === "number") {
220
- return NormalizedSchema.memberFrom([63 & schema, 0], "key");
203
+ return this.memberFrom([63 & schema, 0], "key");
221
204
  }
222
- return NormalizedSchema.memberFrom([schema.keySchema, 0], "key");
205
+ return this.memberFrom([schema.keySchema, 0], "key");
223
206
  }
224
207
  getValueSchema() {
225
208
  const schema = this.getSchema();
226
209
  if (typeof schema === "number") {
227
210
  if (this.isMapSchema()) {
228
- return NormalizedSchema.memberFrom([63 & schema, 0], "value");
211
+ return this.memberFrom([63 & schema, 0], "value");
229
212
  }
230
213
  else if (this.isListSchema()) {
231
- return NormalizedSchema.memberFrom([63 & schema, 0], "member");
214
+ return this.memberFrom([63 & schema, 0], "member");
232
215
  }
233
216
  }
234
217
  if (schema && typeof schema === "object") {
235
218
  if (this.isStructSchema()) {
236
- throw new Error(`cannot call getValueSchema() with StructureSchema ${this.getName(true)}`);
219
+ throw new Error(`may not getValueSchema() on structure ${this.getName(true)}`);
237
220
  }
238
221
  const collection = schema;
239
222
  if ("valueSchema" in collection) {
240
223
  if (this.isMapSchema()) {
241
- return NormalizedSchema.memberFrom([collection.valueSchema, 0], "value");
224
+ return this.memberFrom([collection.valueSchema, 0], "value");
242
225
  }
243
226
  else if (this.isListSchema()) {
244
- return NormalizedSchema.memberFrom([collection.valueSchema, 0], "member");
227
+ return this.memberFrom([collection.valueSchema, 0], "member");
245
228
  }
246
229
  }
247
230
  }
248
231
  if (this.isDocumentSchema()) {
249
- return NormalizedSchema.memberFrom([SCHEMA.DOCUMENT, 0], "value");
232
+ return this.memberFrom([SCHEMA.DOCUMENT, 0], "value");
250
233
  }
251
- throw new Error(`@smithy/core/schema - the schema ${this.getName(true)} does not have a value member.`);
234
+ throw new Error(`@smithy/core/schema - ${this.getName(true)} has no value member.`);
252
235
  }
253
236
  hasMemberSchema(member) {
254
237
  if (this.isStructSchema()) {
255
238
  const struct = this.getSchema();
256
- return member in struct.members;
239
+ return struct.memberNames.includes(member);
257
240
  }
258
241
  return false;
259
242
  }
260
243
  getMemberSchema(member) {
261
244
  if (this.isStructSchema()) {
262
245
  const struct = this.getSchema();
263
- if (!(member in struct.members)) {
264
- throw new Error(`@smithy/core/schema - the schema ${this.getName(true)} does not have a member with name=${member}.`);
246
+ if (!struct.memberNames.includes(member)) {
247
+ throw new Error(`@smithy/core/schema - ${this.getName(true)} has no member=${member}.`);
265
248
  }
266
- return NormalizedSchema.memberFrom(struct.members[member], member);
249
+ const i = struct.memberNames.indexOf(member);
250
+ const memberSchema = struct.memberList[i];
251
+ return this.memberFrom(Array.isArray(memberSchema) ? memberSchema : [memberSchema, 0], member);
267
252
  }
268
253
  if (this.isDocumentSchema()) {
269
- return NormalizedSchema.memberFrom([SCHEMA.DOCUMENT, 0], member);
254
+ return this.memberFrom([SCHEMA.DOCUMENT, 0], member);
270
255
  }
271
- throw new Error(`@smithy/core/schema - the schema ${this.getName(true)} does not have members.`);
256
+ throw new Error(`@smithy/core/schema - ${this.getName(true)} has no members.`);
272
257
  }
273
258
  getMemberSchemas() {
274
- const { schema } = this;
275
- const struct = schema;
276
- if (!struct || typeof struct !== "object") {
277
- return {};
278
- }
279
- if ("members" in struct) {
280
- const buffer = {};
281
- for (const member of struct.memberNames) {
282
- buffer[member] = this.getMemberSchema(member);
259
+ const buffer = {};
260
+ try {
261
+ for (const [k, v] of this.structIterator()) {
262
+ buffer[k] = v;
283
263
  }
284
- return buffer;
285
264
  }
286
- return {};
265
+ catch (ignored) { }
266
+ return buffer;
287
267
  }
288
268
  getEventStreamMember() {
289
269
  if (this.isStructSchema()) {
@@ -300,12 +280,21 @@ export class NormalizedSchema {
300
280
  return;
301
281
  }
302
282
  if (!this.isStructSchema()) {
303
- throw new Error("@smithy/core/schema - cannot acquire structIterator on non-struct schema.");
283
+ throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");
304
284
  }
305
285
  const struct = this.getSchema();
306
286
  for (let i = 0; i < struct.memberNames.length; ++i) {
307
- yield [struct.memberNames[i], NormalizedSchema.memberFrom([struct.memberList[i], 0], struct.memberNames[i])];
287
+ yield [struct.memberNames[i], this.memberFrom([struct.memberList[i], 0], struct.memberNames[i])];
288
+ }
289
+ }
290
+ memberFrom(memberSchema, memberName) {
291
+ if (memberSchema instanceof NormalizedSchema) {
292
+ return Object.assign(memberSchema, {
293
+ memberName,
294
+ _isMemberSchema: true,
295
+ });
308
296
  }
297
+ return new NormalizedSchema(memberSchema, memberName);
309
298
  }
310
299
  getSchemaName() {
311
300
  const schema = this.getSchema();
@@ -327,4 +316,4 @@ export class NormalizedSchema {
327
316
  return "Unknown";
328
317
  }
329
318
  }
330
- NormalizedSchema.symbol = Symbol.for("@smithy/core/schema::NormalizedSchema");
319
+ NormalizedSchema.symbol = Symbol.for("@smithy/nor");
@@ -1,16 +1,15 @@
1
- import { TypeRegistry } from "../TypeRegistry";
2
1
  import { Schema } from "./Schema";
3
2
  export class OperationSchema extends Schema {
4
- constructor(name, traits, input, output) {
5
- super(name, traits);
6
- this.name = name;
7
- this.traits = traits;
8
- this.input = input;
9
- this.output = output;
3
+ constructor() {
4
+ super(...arguments);
5
+ this.symbol = OperationSchema.symbol;
10
6
  }
11
7
  }
12
- export function op(namespace, name, traits = {}, input, output) {
13
- const schema = new OperationSchema(namespace + "#" + name, traits, input, output);
14
- TypeRegistry.for(namespace).register(name, schema);
15
- return schema;
16
- }
8
+ OperationSchema.symbol = Symbol.for("@smithy/ope");
9
+ export const op = (namespace, name, traits, input, output) => Schema.assign(new OperationSchema(), {
10
+ name,
11
+ namespace,
12
+ traits,
13
+ input,
14
+ output,
15
+ });
@@ -1,6 +1,19 @@
1
+ import { TypeRegistry } from "../TypeRegistry";
1
2
  export class Schema {
2
- constructor(name, traits) {
3
- this.name = name;
4
- this.traits = traits;
3
+ static assign(instance, values) {
4
+ const schema = Object.assign(instance, values);
5
+ TypeRegistry.for(schema.namespace).register(schema.name, schema);
6
+ return schema;
7
+ }
8
+ static [Symbol.hasInstance](lhs) {
9
+ const isPrototype = this.prototype.isPrototypeOf(lhs);
10
+ if (!isPrototype && typeof lhs === "object" && lhs !== null) {
11
+ const list = lhs;
12
+ return list.symbol === this.symbol;
13
+ }
14
+ return isPrototype;
15
+ }
16
+ getName() {
17
+ return this.namespace + "#" + this.name;
5
18
  }
6
19
  }
@@ -1,25 +1,14 @@
1
- import { TypeRegistry } from "../TypeRegistry";
2
1
  import { Schema } from "./Schema";
3
2
  export class SimpleSchema extends Schema {
4
- constructor(name, schemaRef, traits) {
5
- super(name, traits);
6
- this.name = name;
7
- this.schemaRef = schemaRef;
8
- this.traits = traits;
3
+ constructor() {
4
+ super(...arguments);
9
5
  this.symbol = SimpleSchema.symbol;
10
6
  }
11
- static [Symbol.hasInstance](lhs) {
12
- const isPrototype = SimpleSchema.prototype.isPrototypeOf(lhs);
13
- if (!isPrototype && typeof lhs === "object" && lhs !== null) {
14
- const sim = lhs;
15
- return sim.symbol === SimpleSchema.symbol;
16
- }
17
- return isPrototype;
18
- }
19
- }
20
- SimpleSchema.symbol = Symbol.for("@smithy/core/schema::SimpleSchema");
21
- export function sim(namespace, name, schemaRef, traits) {
22
- const schema = new SimpleSchema(namespace + "#" + name, schemaRef, traits);
23
- TypeRegistry.for(namespace).register(name, schema);
24
- return schema;
25
7
  }
8
+ SimpleSchema.symbol = Symbol.for("@smithy/sim");
9
+ export const sim = (namespace, name, schemaRef, traits) => Schema.assign(new SimpleSchema(), {
10
+ name,
11
+ namespace,
12
+ traits,
13
+ schemaRef,
14
+ });
@@ -1,32 +1,15 @@
1
- import { TypeRegistry } from "../TypeRegistry";
2
1
  import { Schema } from "./Schema";
3
2
  export class StructureSchema extends Schema {
4
- constructor(name, traits, memberNames, memberList) {
5
- super(name, traits);
6
- this.name = name;
7
- this.traits = traits;
8
- this.memberNames = memberNames;
9
- this.memberList = memberList;
3
+ constructor() {
4
+ super(...arguments);
10
5
  this.symbol = StructureSchema.symbol;
11
- this.members = {};
12
- for (let i = 0; i < memberNames.length; ++i) {
13
- this.members[memberNames[i]] = Array.isArray(memberList[i])
14
- ? memberList[i]
15
- : [memberList[i], 0];
16
- }
17
6
  }
18
- static [Symbol.hasInstance](lhs) {
19
- const isPrototype = StructureSchema.prototype.isPrototypeOf(lhs);
20
- if (!isPrototype && typeof lhs === "object" && lhs !== null) {
21
- const struct = lhs;
22
- return struct.symbol === StructureSchema.symbol;
23
- }
24
- return isPrototype;
25
- }
26
- }
27
- StructureSchema.symbol = Symbol.for("@smithy/core/schema::StructureSchema");
28
- export function struct(namespace, name, traits, memberNames, memberList) {
29
- const schema = new StructureSchema(namespace + "#" + name, traits, memberNames, memberList);
30
- TypeRegistry.for(namespace).register(name, schema);
31
- return schema;
32
7
  }
8
+ StructureSchema.symbol = Symbol.for("@smithy/str");
9
+ export const struct = (namespace, name, traits, memberNames, memberList) => Schema.assign(new StructureSchema(), {
10
+ name,
11
+ namespace,
12
+ traits,
13
+ memberNames,
14
+ memberList,
15
+ });
@@ -1,6 +1,5 @@
1
1
  import { RpcProtocol } from "@smithy/core/protocols";
2
- import type { OperationSchema } from "@smithy/core/schema";
3
- import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, ResponseMetadata, SerdeFunctions } from "@smithy/types";
2
+ import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions } from "@smithy/types";
4
3
  import { CborCodec } from "./CborCodec";
5
4
  /**
6
5
  * Client protocol for Smithy RPCv2 CBOR.
@@ -9,22 +9,9 @@ import { StructureSchema } from "./StructureSchema";
9
9
  * @alpha
10
10
  */
11
11
  export declare class ErrorSchema extends StructureSchema {
12
- name: string;
13
- traits: SchemaTraits;
14
- memberNames: string[];
15
- memberList: SchemaRef[];
16
- /**
17
- * Constructor for a modeled service exception class that extends Error.
18
- */
12
+ static readonly symbol: unique symbol;
19
13
  ctor: any;
20
- static symbol: symbol;
21
- protected symbol: symbol;
22
- constructor(name: string, traits: SchemaTraits, memberNames: string[], memberList: SchemaRef[],
23
- /**
24
- * Constructor for a modeled service exception class that extends Error.
25
- */
26
- ctor: any);
27
- static [Symbol.hasInstance](lhs: unknown): lhs is ErrorSchema;
14
+ protected readonly symbol: symbol;
28
15
  }
29
16
  /**
30
17
  * Factory for ErrorSchema, to reduce codegen output and register the schema.
@@ -38,4 +25,4 @@ export declare class ErrorSchema extends StructureSchema {
38
25
  * @param memberList - list of schemaRef corresponding to each
39
26
  * @param ctor - class reference for the existing Error extending class.
40
27
  */
41
- export declare function error(namespace: string, name: string, traits: SchemaTraits | undefined, memberNames: string[], memberList: SchemaRef[], ctor: any): ErrorSchema;
28
+ export declare const error: (namespace: string, name: string, traits: SchemaTraits, memberNames: string[], memberList: SchemaRef[], ctor: any) => ErrorSchema;
@@ -7,17 +7,15 @@ import { Schema } from "./Schema";
7
7
  * @alpha
8
8
  */
9
9
  export declare class ListSchema extends Schema implements IListSchema {
10
+ static readonly symbol: unique symbol;
10
11
  name: string;
11
12
  traits: SchemaTraits;
12
13
  valueSchema: SchemaRef;
13
- static symbol: symbol;
14
- protected symbol: symbol;
15
- constructor(name: string, traits: SchemaTraits, valueSchema: SchemaRef);
16
- static [Symbol.hasInstance](lhs: unknown): lhs is ListSchema;
14
+ protected readonly symbol: symbol;
17
15
  }
18
16
  /**
19
17
  * Factory for ListSchema.
20
18
  *
21
19
  * @internal
22
20
  */
23
- export declare function list(namespace: string, name: string, traits: SchemaTraits | undefined, valueSchema: SchemaRef): ListSchema;
21
+ export declare const list: (namespace: string, name: string, traits: SchemaTraits, valueSchema: SchemaRef) => ListSchema;
@@ -5,6 +5,7 @@ import { Schema } from "./Schema";
5
5
  * @alpha
6
6
  */
7
7
  export declare class MapSchema extends Schema implements IMapSchema {
8
+ static readonly symbol: unique symbol;
8
9
  name: string;
9
10
  traits: SchemaTraits;
10
11
  /**
@@ -12,17 +13,10 @@ export declare class MapSchema extends Schema implements IMapSchema {
12
13
  */
13
14
  keySchema: SchemaRef;
14
15
  valueSchema: SchemaRef;
15
- static symbol: symbol;
16
- protected symbol: symbol;
17
- constructor(name: string, traits: SchemaTraits,
18
- /**
19
- * This is expected to be StringSchema, but may have traits.
20
- */
21
- keySchema: SchemaRef, valueSchema: SchemaRef);
22
- static [Symbol.hasInstance](lhs: unknown): lhs is MapSchema;
16
+ protected readonly symbol: symbol;
23
17
  }
24
18
  /**
25
19
  * Factory for MapSchema.
26
20
  * @internal
27
21
  */
28
- export declare function map(namespace: string, name: string, traits: SchemaTraits | undefined, keySchema: SchemaRef, valueSchema: SchemaRef): MapSchema;
22
+ export declare const map: (namespace: string, name: string, traits: SchemaTraits, keySchema: SchemaRef, valueSchema: SchemaRef) => MapSchema;