@smithy/core 3.11.1 → 3.13.0

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 (35) hide show
  1. package/dist-cjs/submodules/cbor/index.js +6 -4
  2. package/dist-cjs/submodules/schema/index.js +34 -11
  3. package/dist-cjs/submodules/serde/index.js +1 -1
  4. package/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +5 -3
  5. package/dist-es/submodules/schema/TypeRegistry.js +11 -5
  6. package/dist-es/submodules/schema/schemas/ErrorSchema.js +1 -1
  7. package/dist-es/submodules/schema/schemas/NormalizedSchema.js +15 -5
  8. package/dist-es/submodules/serde/generateIdempotencyToken.js +1 -1
  9. package/dist-types/submodules/schema/TypeRegistry.d.ts +11 -1
  10. package/dist-types/submodules/schema/schemas/ErrorSchema.d.ts +8 -1
  11. package/dist-types/submodules/serde/generateIdempotencyToken.d.ts +1 -1
  12. package/dist-types/ts3.4/submodules/schema/TypeRegistry.d.ts +11 -1
  13. package/dist-types/ts3.4/submodules/schema/schemas/ErrorSchema.d.ts +8 -1
  14. package/dist-types/ts3.4/submodules/serde/generateIdempotencyToken.d.ts +1 -1
  15. package/package.json +3 -4
  16. package/dist-cjs/getSmithyContext.js +0 -1
  17. package/dist-cjs/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.js +0 -1
  18. package/dist-cjs/middleware-http-auth-scheme/getHttpAuthSchemePlugin.js +0 -1
  19. package/dist-cjs/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js +0 -1
  20. package/dist-cjs/middleware-http-auth-scheme/index.js +0 -1
  21. package/dist-cjs/middleware-http-auth-scheme/resolveAuthOptions.js +0 -1
  22. package/dist-cjs/middleware-http-signing/getHttpSigningMiddleware.js +0 -1
  23. package/dist-cjs/middleware-http-signing/httpSigningMiddleware.js +0 -1
  24. package/dist-cjs/middleware-http-signing/index.js +0 -1
  25. package/dist-cjs/normalizeProvider.js +0 -1
  26. package/dist-cjs/pagination/createPaginator.js +0 -1
  27. package/dist-cjs/protocols/requestBuilder.js +0 -1
  28. package/dist-cjs/setFeature.js +0 -1
  29. package/dist-cjs/util-identity-and-auth/DefaultIdentityProviderConfig.js +0 -1
  30. package/dist-cjs/util-identity-and-auth/httpAuthSchemes/httpApiKeyAuth.js +0 -1
  31. package/dist-cjs/util-identity-and-auth/httpAuthSchemes/httpBearerAuth.js +0 -1
  32. package/dist-cjs/util-identity-and-auth/httpAuthSchemes/index.js +0 -1
  33. package/dist-cjs/util-identity-and-auth/httpAuthSchemes/noAuth.js +0 -1
  34. package/dist-cjs/util-identity-and-auth/index.js +0 -1
  35. package/dist-cjs/util-identity-and-auth/memoizeIdentityProvider.js +0 -1
@@ -1024,16 +1024,18 @@ var SmithyRpcV2CborProtocol = class extends import_protocols2.RpcProtocol {
1024
1024
  if (dataObject.Message) {
1025
1025
  dataObject.message = dataObject.Message;
1026
1026
  }
1027
- const baseExceptionSchema = import_schema2.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
1027
+ const synthetic = import_schema2.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
1028
+ const baseExceptionSchema = synthetic.getBaseException();
1028
1029
  if (baseExceptionSchema) {
1029
- const ErrorCtor = baseExceptionSchema.ctor;
1030
- throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
1030
+ const ErrorCtor2 = synthetic.getErrorCtor(baseExceptionSchema);
1031
+ throw Object.assign(new ErrorCtor2({ name: errorName }), errorMetadata, dataObject);
1031
1032
  }
1032
1033
  throw Object.assign(new Error(errorName), errorMetadata, dataObject);
1033
1034
  }
1034
1035
  const ns = import_schema2.NormalizedSchema.of(errorSchema);
1036
+ const ErrorCtor = registry.getErrorCtor(errorSchema);
1035
1037
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
1036
- const exception = new errorSchema.ctor(message);
1038
+ const exception = new ErrorCtor(message);
1037
1039
  const output = {};
1038
1040
  for (const [name, member] of ns.structIterator()) {
1039
1041
  output[name] = this.deserializer.readValue(member, dataObject[name]);
@@ -153,9 +153,10 @@ function getSchemaSerdePlugin(config) {
153
153
 
154
154
  // src/submodules/schema/TypeRegistry.ts
155
155
  var TypeRegistry = class _TypeRegistry {
156
- constructor(namespace, schemas = /* @__PURE__ */ new Map()) {
156
+ constructor(namespace, schemas = /* @__PURE__ */ new Map(), exceptions = /* @__PURE__ */ new Map()) {
157
157
  this.namespace = namespace;
158
158
  this.schemas = schemas;
159
+ this.exceptions = exceptions;
159
160
  }
160
161
  static {
161
162
  this.registries = /* @__PURE__ */ new Map();
@@ -178,8 +179,7 @@ var TypeRegistry = class _TypeRegistry {
178
179
  */
179
180
  register(shapeId, schema) {
180
181
  const qualifiedName = this.normalizeShapeId(shapeId);
181
- const registry = _TypeRegistry.for(this.getNamespace(shapeId));
182
- registry.schemas.set(qualifiedName, schema);
182
+ this.schemas.set(qualifiedName, schema);
183
183
  }
184
184
  /**
185
185
  * @param shapeId - query.
@@ -192,6 +192,19 @@ var TypeRegistry = class _TypeRegistry {
192
192
  }
193
193
  return this.schemas.get(id);
194
194
  }
195
+ /**
196
+ * Associates an error schema with its constructor.
197
+ */
198
+ registerError(errorSchema, ctor) {
199
+ this.exceptions.set(errorSchema, ctor);
200
+ }
201
+ /**
202
+ * @param errorSchema - query.
203
+ * @returns Error constructor that extends the service's base exception.
204
+ */
205
+ getErrorCtor(errorSchema) {
206
+ return this.exceptions.get(errorSchema);
207
+ }
195
208
  /**
196
209
  * The smithy-typescript code generator generates a synthetic (i.e. unmodeled) base exception,
197
210
  * because generated SDKs before the introduction of schemas have the notion of a ServiceBaseException, which
@@ -223,9 +236,9 @@ var TypeRegistry = class _TypeRegistry {
223
236
  /**
224
237
  * Unloads the current TypeRegistry.
225
238
  */
226
- destroy() {
227
- _TypeRegistry.registries.delete(this.namespace);
239
+ clear() {
228
240
  this.schemas.clear();
241
+ this.exceptions.clear();
229
242
  }
230
243
  normalizeShapeId(shapeId) {
231
244
  if (shapeId.includes("#")) {
@@ -345,7 +358,7 @@ var error = (namespace, name, traits, memberNames, memberList, ctor) => Schema.a
345
358
  traits,
346
359
  memberNames,
347
360
  memberList,
348
- ctor
361
+ ctor: null
349
362
  });
350
363
 
351
364
  // src/submodules/schema/schemas/sentinels.ts
@@ -427,8 +440,9 @@ var NormalizedSchema = class _NormalizedSchema {
427
440
  this.memberTraits = 0;
428
441
  }
429
442
  if (schema instanceof _NormalizedSchema) {
443
+ const computedMemberTraits = this.memberTraits;
430
444
  Object.assign(this, schema);
431
- this.memberTraits = Object.assign({}, schema.getMemberTraits(), this.getMemberTraits());
445
+ this.memberTraits = Object.assign({}, computedMemberTraits, schema.getMemberTraits(), this.getMemberTraits());
432
446
  this.normalizedTraits = void 0;
433
447
  this.memberName = memberName ?? schema.memberName;
434
448
  return;
@@ -592,10 +606,19 @@ var NormalizedSchema = class _NormalizedSchema {
592
606
  * @returns whether the schema has the idempotencyToken trait.
593
607
  */
594
608
  isIdempotencyToken() {
595
- if (typeof this.traits === "number") {
596
- return (this.traits & 4) === 4;
597
- } else if (typeof this.traits === "object") {
598
- return !!this.traits.idempotencyToken;
609
+ if (this.normalizedTraits) {
610
+ return !!this.normalizedTraits.idempotencyToken;
611
+ }
612
+ for (const traits of [this.traits, this.memberTraits]) {
613
+ if (typeof traits === "number") {
614
+ if ((traits & 4) === 4) {
615
+ return true;
616
+ }
617
+ } else if (typeof traits === "object") {
618
+ if (!!traits.idempotencyToken) {
619
+ return true;
620
+ }
621
+ }
599
622
  }
600
623
  return false;
601
624
  }
@@ -518,7 +518,7 @@ var stripLeadingZeroes = (value) => {
518
518
  };
519
519
 
520
520
  // src/submodules/serde/generateIdempotencyToken.ts
521
- var import_uuid = require("uuid");
521
+ var import_uuid = require("@smithy/uuid");
522
522
 
523
523
  // src/submodules/serde/lazy-json.ts
524
524
  var LazyJsonString = function LazyJsonString2(val) {
@@ -70,16 +70,18 @@ export class SmithyRpcV2CborProtocol extends RpcProtocol {
70
70
  if (dataObject.Message) {
71
71
  dataObject.message = dataObject.Message;
72
72
  }
73
- const baseExceptionSchema = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
73
+ const synthetic = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
74
+ const baseExceptionSchema = synthetic.getBaseException();
74
75
  if (baseExceptionSchema) {
75
- const ErrorCtor = baseExceptionSchema.ctor;
76
+ const ErrorCtor = synthetic.getErrorCtor(baseExceptionSchema);
76
77
  throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
77
78
  }
78
79
  throw Object.assign(new Error(errorName), errorMetadata, dataObject);
79
80
  }
80
81
  const ns = NormalizedSchema.of(errorSchema);
82
+ const ErrorCtor = registry.getErrorCtor(errorSchema);
81
83
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
82
- const exception = new errorSchema.ctor(message);
84
+ const exception = new ErrorCtor(message);
83
85
  const output = {};
84
86
  for (const [name, member] of ns.structIterator()) {
85
87
  output[name] = this.deserializer.readValue(member, dataObject[name]);
@@ -1,7 +1,8 @@
1
1
  export class TypeRegistry {
2
- constructor(namespace, schemas = new Map()) {
2
+ constructor(namespace, schemas = new Map(), exceptions = new Map()) {
3
3
  this.namespace = namespace;
4
4
  this.schemas = schemas;
5
+ this.exceptions = exceptions;
5
6
  }
6
7
  static for(namespace) {
7
8
  if (!TypeRegistry.registries.has(namespace)) {
@@ -11,8 +12,7 @@ export class TypeRegistry {
11
12
  }
12
13
  register(shapeId, schema) {
13
14
  const qualifiedName = this.normalizeShapeId(shapeId);
14
- const registry = TypeRegistry.for(this.getNamespace(shapeId));
15
- registry.schemas.set(qualifiedName, schema);
15
+ this.schemas.set(qualifiedName, schema);
16
16
  }
17
17
  getSchema(shapeId) {
18
18
  const id = this.normalizeShapeId(shapeId);
@@ -21,6 +21,12 @@ export class TypeRegistry {
21
21
  }
22
22
  return this.schemas.get(id);
23
23
  }
24
+ registerError(errorSchema, ctor) {
25
+ this.exceptions.set(errorSchema, ctor);
26
+ }
27
+ getErrorCtor(errorSchema) {
28
+ return this.exceptions.get(errorSchema);
29
+ }
24
30
  getBaseException() {
25
31
  for (const [id, schema] of this.schemas.entries()) {
26
32
  if (id.startsWith("smithy.ts.sdk.synthetic.") && id.endsWith("ServiceException")) {
@@ -32,9 +38,9 @@ export class TypeRegistry {
32
38
  find(predicate) {
33
39
  return [...this.schemas.values()].find(predicate);
34
40
  }
35
- destroy() {
36
- TypeRegistry.registries.delete(this.namespace);
41
+ clear() {
37
42
  this.schemas.clear();
43
+ this.exceptions.clear();
38
44
  }
39
45
  normalizeShapeId(shapeId) {
40
46
  if (shapeId.includes("#")) {
@@ -13,5 +13,5 @@ export const error = (namespace, name, traits, memberNames, memberList, ctor) =>
13
13
  traits,
14
14
  memberNames,
15
15
  memberList,
16
- ctor,
16
+ ctor: null,
17
17
  });
@@ -31,8 +31,9 @@ export class NormalizedSchema {
31
31
  this.memberTraits = 0;
32
32
  }
33
33
  if (schema instanceof NormalizedSchema) {
34
+ const computedMemberTraits = this.memberTraits;
34
35
  Object.assign(this, schema);
35
- this.memberTraits = Object.assign({}, schema.getMemberTraits(), this.getMemberTraits());
36
+ this.memberTraits = Object.assign({}, computedMemberTraits, schema.getMemberTraits(), this.getMemberTraits());
36
37
  this.normalizedTraits = void 0;
37
38
  this.memberName = memberName ?? schema.memberName;
38
39
  return;
@@ -170,11 +171,20 @@ export class NormalizedSchema {
170
171
  return this.getSchema() === SCHEMA.STREAMING_BLOB;
171
172
  }
172
173
  isIdempotencyToken() {
173
- if (typeof this.traits === "number") {
174
- return (this.traits & 0b0100) === 0b0100;
174
+ if (this.normalizedTraits) {
175
+ return !!this.normalizedTraits.idempotencyToken;
175
176
  }
176
- else if (typeof this.traits === "object") {
177
- return !!this.traits.idempotencyToken;
177
+ for (const traits of [this.traits, this.memberTraits]) {
178
+ if (typeof traits === "number") {
179
+ if ((traits & 0b0100) === 0b0100) {
180
+ return true;
181
+ }
182
+ }
183
+ else if (typeof traits === "object") {
184
+ if (!!traits.idempotencyToken) {
185
+ return true;
186
+ }
187
+ }
178
188
  }
179
189
  return false;
180
190
  }
@@ -1,2 +1,2 @@
1
- import { v4 as generateIdempotencyToken } from "uuid";
1
+ import { v4 as generateIdempotencyToken } from "@smithy/uuid";
2
2
  export { generateIdempotencyToken };
@@ -8,6 +8,7 @@ import type { ErrorSchema } from "./schemas/ErrorSchema";
8
8
  export declare class TypeRegistry {
9
9
  readonly namespace: string;
10
10
  private schemas;
11
+ private exceptions;
11
12
  static readonly registries: Map<string, TypeRegistry>;
12
13
  private constructor();
13
14
  /**
@@ -27,6 +28,15 @@ export declare class TypeRegistry {
27
28
  * @returns the schema.
28
29
  */
29
30
  getSchema(shapeId: string): ISchema;
31
+ /**
32
+ * Associates an error schema with its constructor.
33
+ */
34
+ registerError(errorSchema: ErrorSchema, ctor: any): void;
35
+ /**
36
+ * @param errorSchema - query.
37
+ * @returns Error constructor that extends the service's base exception.
38
+ */
39
+ getErrorCtor(errorSchema: ErrorSchema): any;
30
40
  /**
31
41
  * The smithy-typescript code generator generates a synthetic (i.e. unmodeled) base exception,
32
42
  * because generated SDKs before the introduction of schemas have the notion of a ServiceBaseException, which
@@ -49,7 +59,7 @@ export declare class TypeRegistry {
49
59
  /**
50
60
  * Unloads the current TypeRegistry.
51
61
  */
52
- destroy(): void;
62
+ clear(): void;
53
63
  private normalizeShapeId;
54
64
  private getNamespace;
55
65
  }
@@ -10,6 +10,9 @@ import { StructureSchema } from "./StructureSchema";
10
10
  */
11
11
  export declare class ErrorSchema extends StructureSchema {
12
12
  static readonly symbol: unique symbol;
13
+ /**
14
+ * @deprecated - field unused.
15
+ */
13
16
  ctor: any;
14
17
  protected readonly symbol: symbol;
15
18
  }
@@ -25,4 +28,8 @@ export declare class ErrorSchema extends StructureSchema {
25
28
  * @param memberList - list of schemaRef corresponding to each
26
29
  * @param ctor - class reference for the existing Error extending class.
27
30
  */
28
- export declare const error: (namespace: string, name: string, traits: SchemaTraits, memberNames: string[], memberList: SchemaRef[], ctor: any) => ErrorSchema;
31
+ export declare const error: (namespace: string, name: string, traits: SchemaTraits, memberNames: string[], memberList: SchemaRef[],
32
+ /**
33
+ * @deprecated - field unused.
34
+ */
35
+ ctor?: any) => ErrorSchema;
@@ -1,2 +1,2 @@
1
- import { v4 as generateIdempotencyToken } from "uuid";
1
+ import { v4 as generateIdempotencyToken } from "@smithy/uuid";
2
2
  export { generateIdempotencyToken };
@@ -8,6 +8,7 @@ import { ErrorSchema } from "./schemas/ErrorSchema";
8
8
  export declare class TypeRegistry {
9
9
  readonly namespace: string;
10
10
  private schemas;
11
+ private exceptions;
11
12
  static readonly registries: Map<string, TypeRegistry>;
12
13
  private constructor();
13
14
  /**
@@ -27,6 +28,15 @@ export declare class TypeRegistry {
27
28
  * @returns the schema.
28
29
  */
29
30
  getSchema(shapeId: string): ISchema;
31
+ /**
32
+ * Associates an error schema with its constructor.
33
+ */
34
+ registerError(errorSchema: ErrorSchema, ctor: any): void;
35
+ /**
36
+ * @param errorSchema - query.
37
+ * @returns Error constructor that extends the service's base exception.
38
+ */
39
+ getErrorCtor(errorSchema: ErrorSchema): any;
30
40
  /**
31
41
  * The smithy-typescript code generator generates a synthetic (i.e. unmodeled) base exception,
32
42
  * because generated SDKs before the introduction of schemas have the notion of a ServiceBaseException, which
@@ -49,7 +59,7 @@ export declare class TypeRegistry {
49
59
  /**
50
60
  * Unloads the current TypeRegistry.
51
61
  */
52
- destroy(): void;
62
+ clear(): void;
53
63
  private normalizeShapeId;
54
64
  private getNamespace;
55
65
  }
@@ -10,6 +10,9 @@ import { StructureSchema } from "./StructureSchema";
10
10
  */
11
11
  export declare class ErrorSchema extends StructureSchema {
12
12
  static readonly symbol: unique symbol;
13
+ /**
14
+ * @deprecated - field unused.
15
+ */
13
16
  ctor: any;
14
17
  protected readonly symbol: symbol;
15
18
  }
@@ -25,4 +28,8 @@ export declare class ErrorSchema extends StructureSchema {
25
28
  * @param memberList - list of schemaRef corresponding to each
26
29
  * @param ctor - class reference for the existing Error extending class.
27
30
  */
28
- export declare const error: (namespace: string, name: string, traits: SchemaTraits, memberNames: string[], memberList: SchemaRef[], ctor: any) => ErrorSchema;
31
+ export declare const error: (namespace: string, name: string, traits: SchemaTraits, memberNames: string[], memberList: SchemaRef[],
32
+ /**
33
+ * @deprecated - field unused.
34
+ */
35
+ ctor?: any) => ErrorSchema;
@@ -1,2 +1,2 @@
1
- import { v4 as generateIdempotencyToken } from "uuid";
1
+ import { v4 as generateIdempotencyToken } from "@smithy/uuid";
2
2
  export { generateIdempotencyToken };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.11.1",
3
+ "version": "3.13.0",
4
4
  "scripts": {
5
5
  "build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
6
6
  "build:cjs": "node ../../scripts/inline core",
@@ -85,9 +85,8 @@
85
85
  "@smithy/util-middleware": "^4.1.1",
86
86
  "@smithy/util-stream": "^4.3.2",
87
87
  "@smithy/util-utf8": "^4.1.0",
88
- "@types/uuid": "^9.0.1",
89
- "tslib": "^2.6.2",
90
- "uuid": "^9.0.1"
88
+ "@smithy/uuid": "^1.0.0",
89
+ "tslib": "^2.6.2"
91
90
  },
92
91
  "engines": {
93
92
  "node": ">=18.0.0"
@@ -1 +0,0 @@
1
- module.exports = require("./index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("./index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("./index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");
@@ -1 +0,0 @@
1
- module.exports = require("../index.js");