@songtonyli/dsh-cli 0.1.36 → 0.1.38

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 (90) hide show
  1. package/README.md +1 -1
  2. package/bin/dsh.mjs +1 -1
  3. package/node_modules/@aws-sdk/core/package.json +6 -6
  4. package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
  5. package/node_modules/@aws-sdk/credential-provider-http/package.json +7 -7
  6. package/node_modules/@aws-sdk/credential-provider-ini/package.json +13 -13
  7. package/node_modules/@aws-sdk/credential-provider-login/package.json +6 -6
  8. package/node_modules/@aws-sdk/credential-provider-node/package.json +11 -11
  9. package/node_modules/@aws-sdk/credential-provider-process/package.json +5 -5
  10. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +6 -6
  11. package/node_modules/@aws-sdk/credential-provider-sso/package.json +7 -7
  12. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +6 -6
  13. package/node_modules/@aws-sdk/eventstream-handler-node/package.json +4 -4
  14. package/node_modules/@aws-sdk/middleware-eventstream/package.json +4 -4
  15. package/node_modules/@aws-sdk/middleware-websocket/package.json +7 -7
  16. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +3 -3
  17. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +3 -3
  18. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +3 -3
  19. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +3 -3
  20. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +14 -11
  21. package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/cognito-identity/schemas/schemas_0.js +2 -2
  22. package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/schemas/schemas_0.js +2 -2
  23. package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso/schemas/schemas_0.js +2 -2
  24. package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sso-oidc/schemas/schemas_0.js +2 -2
  25. package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/sts/schemas/schemas_0.js +13 -10
  26. package/node_modules/@aws-sdk/nested-clients/package.json +8 -8
  27. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +4 -4
  28. package/node_modules/@aws-sdk/types/package.json +2 -2
  29. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  30. package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
  31. package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
  32. package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
  33. package/node_modules/@deepseek-ai/dsh-tui-app/README.md +3 -3
  34. package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +3 -3
  35. package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +100 -42
  36. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +22 -37
  37. package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +26 -4
  38. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +49 -8
  39. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +12 -7
  40. package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +22 -22
  41. package/node_modules/@smithy/core/dist-es/submodules/cbor/parseCborBody.js +0 -15
  42. package/node_modules/@smithy/core/dist-es/submodules/client/index.js +1 -1
  43. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/command.js +8 -1
  44. package/node_modules/@smithy/core/dist-es/submodules/client/smithy-client/exceptions.js +18 -3
  45. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +49 -8
  46. package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +12 -7
  47. package/node_modules/@smithy/core/package.json +2 -2
  48. package/node_modules/@smithy/types/package.json +1 -1
  49. package/node_modules/undici/docs/docs/api/Agent.md +8 -8
  50. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
  51. package/node_modules/undici/docs/docs/api/Errors.md +25 -0
  52. package/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
  53. package/node_modules/undici/docs/docs/api/Pool.md +5 -6
  54. package/node_modules/undici/lib/api/readable.js +1 -2
  55. package/node_modules/undici/lib/core/request.js +23 -2
  56. package/node_modules/undici/lib/core/util.js +0 -39
  57. package/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
  58. package/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
  59. package/node_modules/undici/lib/dispatcher/client.js +1 -1
  60. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +3 -2
  61. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
  62. package/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
  63. package/node_modules/undici/lib/dispatcher/pool.js +90 -7
  64. package/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
  65. package/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
  66. package/node_modules/undici/lib/handler/redirect-handler.js +5 -0
  67. package/node_modules/undici/lib/handler/retry-handler.js +72 -13
  68. package/node_modules/undici/lib/interceptor/cache.js +4 -1
  69. package/node_modules/undici/lib/interceptor/decompress.js +236 -69
  70. package/node_modules/undici/lib/web/cache/cache.js +17 -8
  71. package/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
  72. package/node_modules/undici/lib/web/cookies/index.js +19 -7
  73. package/node_modules/undici/lib/web/cookies/util.js +3 -1
  74. package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
  75. package/node_modules/undici/lib/web/fetch/body.js +22 -15
  76. package/node_modules/undici/lib/web/fetch/data-url.js +6 -6
  77. package/node_modules/undici/lib/web/fetch/formdata.js +30 -36
  78. package/node_modules/undici/lib/web/fetch/headers.js +34 -31
  79. package/node_modules/undici/lib/web/fetch/index.js +38 -14
  80. package/node_modules/undici/lib/web/fetch/request.js +74 -79
  81. package/node_modules/undici/lib/web/fetch/response.js +43 -44
  82. package/node_modules/undici/lib/web/fetch/util.js +7 -7
  83. package/node_modules/undici/lib/web/infra/index.js +16 -1
  84. package/node_modules/undici/lib/web/webidl/index.js +2 -14
  85. package/node_modules/undici/lib/web/websocket/events.js +43 -26
  86. package/node_modules/undici/lib/web/websocket/receiver.js +5 -0
  87. package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
  88. package/node_modules/undici/lib/web/websocket/websocket.js +44 -41
  89. package/node_modules/undici/package.json +1 -1
  90. package/package.json +20 -20
@@ -902,26 +902,11 @@ const loadSmithyRpcV2CborErrorCode = (output, data) => {
902
902
  if (cleanValue.indexOf(":") >= 0) {
903
903
  cleanValue = cleanValue.split(":")[0];
904
904
  }
905
- if (cleanValue.indexOf("#") >= 0) {
906
- cleanValue = cleanValue.split("#")[1];
907
- }
908
905
  return cleanValue;
909
906
  };
910
907
  if (data["__type"] !== undefined) {
911
908
  return sanitizeErrorCode(data["__type"]);
912
909
  }
913
- let codeKey;
914
- for (const key in data) {
915
- if (!hasOwn(data, key))
916
- continue;
917
- if (key.toLowerCase() === "code") {
918
- codeKey = key;
919
- break;
920
- }
921
- }
922
- if (codeKey && data[codeKey] !== undefined) {
923
- return sanitizeErrorCode(data[codeKey]);
924
- }
925
910
  };
926
911
  const checkCborResponse = (response) => {
927
912
  if (String(response.headers["smithy-protocol"]).toLowerCase() !== "rpc-v2-cbor") {
@@ -2278,37 +2263,37 @@ class SmithyRpcV2CborProtocol extends RpcProtocol {
2278
2263
  return super.deserializeResponse(operationSchema, context, response);
2279
2264
  }
2280
2265
  async handleError(operationSchema, context, response, dataObject, metadata) {
2281
- const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
2266
+ const errorIdentifier = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
2267
+ const preferredNamespaces = ["*"];
2268
+ const { defaultNamespace } = this.options;
2269
+ preferredNamespaces.unshift(defaultNamespace);
2270
+ const [namespace, errorShapeName] = (() => {
2271
+ if (errorIdentifier.includes("#")) {
2272
+ return errorIdentifier.split("#");
2273
+ }
2274
+ return [undefined, errorIdentifier];
2275
+ })();
2276
+ if (namespace) {
2277
+ preferredNamespaces.unshift(namespace);
2278
+ }
2282
2279
  const errorMetadata = {
2283
2280
  $metadata: metadata,
2284
- $fault: response.statusCode <= 500 ? "client" : "server",
2281
+ $fault: response.statusCode < 500 ? "client" : "server",
2285
2282
  };
2286
- let namespace = this.options.defaultNamespace;
2287
- if (errorName.includes("#")) {
2288
- [namespace] = errorName.split("#");
2289
- }
2290
- const registry = this.compositeErrorRegistry;
2291
- const nsRegistry = TypeRegistry.for(namespace);
2292
- registry.copyFrom(nsRegistry);
2293
- let errorSchema;
2294
- try {
2295
- errorSchema = registry.getSchema(errorName);
2283
+ const preferredRegistries = [this.compositeErrorRegistry];
2284
+ if (namespace) {
2285
+ preferredRegistries.push(TypeRegistry.for(namespace));
2296
2286
  }
2297
- catch (ignored) {
2287
+ preferredRegistries.push(TypeRegistry.for(defaultNamespace));
2288
+ const [errorSchema, ErrorCtor, errorMode] = this.resolveError(errorShapeName, preferredNamespaces, preferredRegistries);
2289
+ if (errorMode === "native" || errorMode === "synthetic") {
2298
2290
  if (dataObject.Message) {
2299
2291
  dataObject.message = dataObject.Message;
2300
2292
  }
2301
- const syntheticRegistry = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
2302
- registry.copyFrom(syntheticRegistry);
2303
- const baseExceptionSchema = registry.getBaseException();
2304
- if (baseExceptionSchema) {
2305
- const ErrorCtor = registry.getErrorCtor(baseExceptionSchema);
2306
- throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
2307
- }
2308
- throw Object.assign(new Error(errorName), errorMetadata, dataObject);
2293
+ const error = errorMode === "synthetic" ? new ErrorCtor({ name: errorShapeName }) : new Error(errorShapeName);
2294
+ throw Object.assign(error, errorMetadata, dataObject);
2309
2295
  }
2310
2296
  const ns = NormalizedSchema.of(errorSchema);
2311
- const ErrorCtor = registry.getErrorCtor(errorSchema);
2312
2297
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
2313
2298
  const exception = new ErrorCtor({});
2314
2299
  const output = {};
@@ -590,20 +590,27 @@ class Command {
590
590
  }
591
591
  const stack = clientStack.concat(this.middlewareStack);
592
592
  const { logger } = configuration;
593
+ const additionalSmithyContext = additionalContext[SMITHY_CONTEXT_KEY];
593
594
  const handlerExecutionContext = {
594
595
  logger,
595
596
  clientName,
596
597
  commandName,
597
598
  inputFilterSensitiveLog,
598
599
  outputFilterSensitiveLog,
600
+ ...additionalContext,
599
601
  [SMITHY_CONTEXT_KEY]: {
602
+ ...additionalSmithyContext,
600
603
  commandInstance: this,
601
604
  ...smithyContext,
605
+ ...(options?.metricsRecorder === undefined ? {} : { metricsRecorder: options.metricsRecorder }),
602
606
  },
603
- ...additionalContext,
604
607
  };
605
608
  const { requestHandler } = configuration;
606
609
  let requestOptions = options ?? {};
610
+ if (requestOptions.metricsRecorder) {
611
+ requestOptions = { ...requestOptions };
612
+ delete requestOptions.metricsRecorder;
613
+ }
607
614
  if (smithyContext.eventStream) {
608
615
  requestOptions = {
609
616
  isEventStream: true,
@@ -786,10 +793,25 @@ class ServiceException extends Error {
786
793
  return ServiceException.isInstance(instance);
787
794
  }
788
795
  if (ServiceException.isInstance(instance)) {
789
- if (candidate.name && this.name) {
790
- return this.prototype.isPrototypeOf(instance) || candidate.name === this.name;
796
+ if (this.prototype.isPrototypeOf(instance)) {
797
+ return true;
798
+ }
799
+ const targetName = this.name;
800
+ if (!targetName || !candidate.name) {
801
+ return false;
791
802
  }
792
- return this.prototype.isPrototypeOf(instance);
803
+ if (candidate.name === targetName) {
804
+ return true;
805
+ }
806
+ let proto = Object.getPrototypeOf(candidate);
807
+ while (proto && proto !== Object.prototype) {
808
+ const ctorName = proto.constructor?.name;
809
+ if (ctorName && ctorName !== "Error" && ctorName === targetName) {
810
+ return true;
811
+ }
812
+ proto = Object.getPrototypeOf(proto);
813
+ }
814
+ return false;
793
815
  }
794
816
  return false;
795
817
  }
@@ -39,7 +39,7 @@ class HttpProtocol extends SerdeContext {
39
39
  constructor(options) {
40
40
  super();
41
41
  this.options = options;
42
- this.compositeErrorRegistry = TypeRegistry.for(options.defaultNamespace);
42
+ this.compositeErrorRegistry = new TypeRegistry(options.defaultNamespace);
43
43
  for (const etr of options.errorTypeRegistries ?? []) {
44
44
  this.compositeErrorRegistry.copyFrom(etr);
45
45
  }
@@ -134,6 +134,47 @@ class HttpProtocol extends SerdeContext {
134
134
  cfId: output.headers["x-amz-cf-id"],
135
135
  };
136
136
  }
137
+ resolveError(name, namespaces, registries) {
138
+ const defaultErrorSchema = [-3, "", "Error", 0, [], [], 0];
139
+ let schema;
140
+ for (const registry of registries) {
141
+ for (const ns of namespaces) {
142
+ try {
143
+ if (ns === "*") {
144
+ schema = registry.getSchema(name);
145
+ }
146
+ else {
147
+ schema = registry.getSchema(ns + "#" + name);
148
+ }
149
+ const errorCtor = registry.getErrorCtor(schema);
150
+ if (errorCtor) {
151
+ return [schema, errorCtor, "modeled"];
152
+ }
153
+ else {
154
+ const syntheticErrorSchema = registry.getBaseException();
155
+ if (syntheticErrorSchema) {
156
+ const syntheticErrorCtor = registry.getErrorCtor(syntheticErrorSchema);
157
+ if (syntheticErrorCtor) {
158
+ return [schema, syntheticErrorCtor, "synthetic"];
159
+ }
160
+ }
161
+ }
162
+ }
163
+ catch (ignored) {
164
+ }
165
+ }
166
+ }
167
+ for (const registry of registries) {
168
+ const syntheticErrorSchema = registry.getBaseException();
169
+ if (syntheticErrorSchema) {
170
+ const syntheticErrorCtor = registry.getErrorCtor(syntheticErrorSchema);
171
+ if (syntheticErrorCtor) {
172
+ return [syntheticErrorSchema, syntheticErrorCtor, "synthetic"];
173
+ }
174
+ }
175
+ }
176
+ return [defaultErrorSchema, Error, "native"];
177
+ }
137
178
  async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {
138
179
  const eventStreamSerde = await this.loadEventStreamCapability();
139
180
  return eventStreamSerde.serializeEventStream({
@@ -162,13 +203,6 @@ class HttpProtocol extends SerdeContext {
162
203
  compositeErrorRegistry: this.compositeErrorRegistry,
163
204
  });
164
205
  }
165
- resolveEventStreamMarshaller(importedProvider) {
166
- const context = this.serdeContext;
167
- if (context.eventStreamMarshaller) {
168
- return context.eventStreamMarshaller;
169
- }
170
- return importedProvider(this.serdeContext);
171
- }
172
206
  getDefaultContentType() {
173
207
  throw new Error(`@smithy/core/protocols - ${this.constructor.name} getDefaultContentType() implementation missing.`);
174
208
  }
@@ -182,6 +216,13 @@ class HttpProtocol extends SerdeContext {
182
216
  }
183
217
  return context.eventStreamMarshaller;
184
218
  }
219
+ resolveEventStreamMarshaller(importedProvider) {
220
+ const context = this.serdeContext;
221
+ if (context.eventStreamMarshaller) {
222
+ return context.eventStreamMarshaller;
223
+ }
224
+ return importedProvider(this.serdeContext);
225
+ }
185
226
  }
186
227
 
187
228
  class HttpBindingProtocol extends HttpProtocol {
@@ -579,12 +579,12 @@ class TypeRegistry {
579
579
  this.namespace = namespace;
580
580
  this.schemas = schemas;
581
581
  this.exceptions = exceptions;
582
- }
583
- static for(namespace) {
584
582
  if (!TypeRegistry.registries.has(namespace)) {
585
- TypeRegistry.registries.set(namespace, new TypeRegistry(namespace));
583
+ TypeRegistry.registries.set(namespace, this);
586
584
  }
587
- return TypeRegistry.registries.get(namespace);
585
+ }
586
+ static for(namespace) {
587
+ return TypeRegistry.registries.get(namespace) ?? new TypeRegistry(namespace);
588
588
  }
589
589
  copyFrom(other) {
590
590
  const { schemas, exceptions } = this;
@@ -602,7 +602,9 @@ class TypeRegistry {
602
602
  register(shapeId, schema) {
603
603
  const qualifiedName = this.normalizeShapeId(shapeId);
604
604
  for (const r of [this, TypeRegistry.for(qualifiedName.split("#")[0])]) {
605
- r.schemas.set(qualifiedName, schema);
605
+ if (!r.schemas.has(qualifiedName)) {
606
+ r.schemas.set(qualifiedName, schema);
607
+ }
606
608
  }
607
609
  }
608
610
  getSchema(shapeId) {
@@ -627,9 +629,12 @@ class TypeRegistry {
627
629
  registerError(es, ctor) {
628
630
  const $error = es;
629
631
  const ns = $error[1];
632
+ const qualifiedName = ns + "#" + $error[2];
630
633
  for (const r of [this, TypeRegistry.for(ns)]) {
631
- r.schemas.set(ns + "#" + $error[2], $error);
632
- r.exceptions.set($error, ctor);
634
+ if (!r.schemas.has(qualifiedName) && !r.exceptions.has($error)) {
635
+ r.schemas.set(qualifiedName, $error);
636
+ r.exceptions.set($error, ctor);
637
+ }
633
638
  }
634
639
  }
635
640
  getErrorCtor(es) {
@@ -50,37 +50,37 @@ export class SmithyRpcV2CborProtocol extends RpcProtocol {
50
50
  return super.deserializeResponse(operationSchema, context, response);
51
51
  }
52
52
  async handleError(operationSchema, context, response, dataObject, metadata) {
53
- const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
53
+ const errorIdentifier = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
54
+ const preferredNamespaces = ["*"];
55
+ const { defaultNamespace } = this.options;
56
+ preferredNamespaces.unshift(defaultNamespace);
57
+ const [namespace, errorShapeName] = (() => {
58
+ if (errorIdentifier.includes("#")) {
59
+ return errorIdentifier.split("#");
60
+ }
61
+ return [undefined, errorIdentifier];
62
+ })();
63
+ if (namespace) {
64
+ preferredNamespaces.unshift(namespace);
65
+ }
54
66
  const errorMetadata = {
55
67
  $metadata: metadata,
56
- $fault: response.statusCode <= 500 ? "client" : "server",
68
+ $fault: response.statusCode < 500 ? "client" : "server",
57
69
  };
58
- let namespace = this.options.defaultNamespace;
59
- if (errorName.includes("#")) {
60
- [namespace] = errorName.split("#");
70
+ const preferredRegistries = [this.compositeErrorRegistry];
71
+ if (namespace) {
72
+ preferredRegistries.push(TypeRegistry.for(namespace));
61
73
  }
62
- const registry = this.compositeErrorRegistry;
63
- const nsRegistry = TypeRegistry.for(namespace);
64
- registry.copyFrom(nsRegistry);
65
- let errorSchema;
66
- try {
67
- errorSchema = registry.getSchema(errorName);
68
- }
69
- catch (ignored) {
74
+ preferredRegistries.push(TypeRegistry.for(defaultNamespace));
75
+ const [errorSchema, ErrorCtor, errorMode] = this.resolveError(errorShapeName, preferredNamespaces, preferredRegistries);
76
+ if (errorMode === "native" || errorMode === "synthetic") {
70
77
  if (dataObject.Message) {
71
78
  dataObject.message = dataObject.Message;
72
79
  }
73
- const syntheticRegistry = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
74
- registry.copyFrom(syntheticRegistry);
75
- const baseExceptionSchema = registry.getBaseException();
76
- if (baseExceptionSchema) {
77
- const ErrorCtor = registry.getErrorCtor(baseExceptionSchema);
78
- throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
79
- }
80
- throw Object.assign(new Error(errorName), errorMetadata, dataObject);
80
+ const error = errorMode === "synthetic" ? new ErrorCtor({ name: errorShapeName }) : new Error(errorShapeName);
81
+ throw Object.assign(error, errorMetadata, dataObject);
81
82
  }
82
83
  const ns = NormalizedSchema.of(errorSchema);
83
- const ErrorCtor = registry.getErrorCtor(errorSchema);
84
84
  const message = dataObject.message ?? dataObject.Message ?? "Unknown";
85
85
  const exception = new ErrorCtor({});
86
86
  const output = {};
@@ -42,26 +42,11 @@ export const loadSmithyRpcV2CborErrorCode = (output, data) => {
42
42
  if (cleanValue.indexOf(":") >= 0) {
43
43
  cleanValue = cleanValue.split(":")[0];
44
44
  }
45
- if (cleanValue.indexOf("#") >= 0) {
46
- cleanValue = cleanValue.split("#")[1];
47
- }
48
45
  return cleanValue;
49
46
  };
50
47
  if (data["__type"] !== undefined) {
51
48
  return sanitizeErrorCode(data["__type"]);
52
49
  }
53
- let codeKey;
54
- for (const key in data) {
55
- if (!hasOwn(data, key))
56
- continue;
57
- if (key.toLowerCase() === "code") {
58
- codeKey = key;
59
- break;
60
- }
61
- }
62
- if (codeKey && data[codeKey] !== undefined) {
63
- return sanitizeErrorCode(data[codeKey]);
64
- }
65
50
  };
66
51
  export const checkCborResponse = (response) => {
67
52
  if (String(response.headers["smithy-protocol"]).toLowerCase() !== "rpc-v2-cbor") {
@@ -5,7 +5,7 @@ export { invalidFunction } from "./invalid-dependency/invalidFunction";
5
5
  export { invalidProvider } from "./invalid-dependency/invalidProvider";
6
6
  export { createWaiter } from "./util-waiter/createWaiter";
7
7
  export { waiterServiceDefaults, WaiterState, checkExceptions, } from "./util-waiter/waiter";
8
- export { Client } from "./smithy-client/client";
8
+ export { Client, } from "./smithy-client/client";
9
9
  export { Command } from "./smithy-client/command";
10
10
  export { SENSITIVE_STRING } from "./smithy-client/constants";
11
11
  export { createAggregatedClient } from "./smithy-client/create-aggregated-client";
@@ -13,20 +13,27 @@ export class Command {
13
13
  }
14
14
  const stack = clientStack.concat(this.middlewareStack);
15
15
  const { logger } = configuration;
16
+ const additionalSmithyContext = additionalContext[SMITHY_CONTEXT_KEY];
16
17
  const handlerExecutionContext = {
17
18
  logger,
18
19
  clientName,
19
20
  commandName,
20
21
  inputFilterSensitiveLog,
21
22
  outputFilterSensitiveLog,
23
+ ...additionalContext,
22
24
  [SMITHY_CONTEXT_KEY]: {
25
+ ...additionalSmithyContext,
23
26
  commandInstance: this,
24
27
  ...smithyContext,
28
+ ...(options?.metricsRecorder === undefined ? {} : { metricsRecorder: options.metricsRecorder }),
25
29
  },
26
- ...additionalContext,
27
30
  };
28
31
  const { requestHandler } = configuration;
29
32
  let requestOptions = options ?? {};
33
+ if (requestOptions.metricsRecorder) {
34
+ requestOptions = { ...requestOptions };
35
+ delete requestOptions.metricsRecorder;
36
+ }
30
37
  if (smithyContext.eventStream) {
31
38
  requestOptions = {
32
39
  isEventStream: true,
@@ -27,10 +27,25 @@ export class ServiceException extends Error {
27
27
  return ServiceException.isInstance(instance);
28
28
  }
29
29
  if (ServiceException.isInstance(instance)) {
30
- if (candidate.name && this.name) {
31
- return this.prototype.isPrototypeOf(instance) || candidate.name === this.name;
30
+ if (this.prototype.isPrototypeOf(instance)) {
31
+ return true;
32
32
  }
33
- return this.prototype.isPrototypeOf(instance);
33
+ const targetName = this.name;
34
+ if (!targetName || !candidate.name) {
35
+ return false;
36
+ }
37
+ if (candidate.name === targetName) {
38
+ return true;
39
+ }
40
+ let proto = Object.getPrototypeOf(candidate);
41
+ while (proto && proto !== Object.prototype) {
42
+ const ctorName = proto.constructor?.name;
43
+ if (ctorName && ctorName !== "Error" && ctorName === targetName) {
44
+ return true;
45
+ }
46
+ proto = Object.getPrototypeOf(proto);
47
+ }
48
+ return false;
34
49
  }
35
50
  return false;
36
51
  }
@@ -8,7 +8,7 @@ export class HttpProtocol extends SerdeContext {
8
8
  constructor(options) {
9
9
  super();
10
10
  this.options = options;
11
- this.compositeErrorRegistry = TypeRegistry.for(options.defaultNamespace);
11
+ this.compositeErrorRegistry = new TypeRegistry(options.defaultNamespace);
12
12
  for (const etr of options.errorTypeRegistries ?? []) {
13
13
  this.compositeErrorRegistry.copyFrom(etr);
14
14
  }
@@ -103,6 +103,47 @@ export class HttpProtocol extends SerdeContext {
103
103
  cfId: output.headers["x-amz-cf-id"],
104
104
  };
105
105
  }
106
+ resolveError(name, namespaces, registries) {
107
+ const defaultErrorSchema = [-3, "", "Error", 0, [], [], 0];
108
+ let schema;
109
+ for (const registry of registries) {
110
+ for (const ns of namespaces) {
111
+ try {
112
+ if (ns === "*") {
113
+ schema = registry.getSchema(name);
114
+ }
115
+ else {
116
+ schema = registry.getSchema(ns + "#" + name);
117
+ }
118
+ const errorCtor = registry.getErrorCtor(schema);
119
+ if (errorCtor) {
120
+ return [schema, errorCtor, "modeled"];
121
+ }
122
+ else {
123
+ const syntheticErrorSchema = registry.getBaseException();
124
+ if (syntheticErrorSchema) {
125
+ const syntheticErrorCtor = registry.getErrorCtor(syntheticErrorSchema);
126
+ if (syntheticErrorCtor) {
127
+ return [schema, syntheticErrorCtor, "synthetic"];
128
+ }
129
+ }
130
+ }
131
+ }
132
+ catch (ignored) {
133
+ }
134
+ }
135
+ }
136
+ for (const registry of registries) {
137
+ const syntheticErrorSchema = registry.getBaseException();
138
+ if (syntheticErrorSchema) {
139
+ const syntheticErrorCtor = registry.getErrorCtor(syntheticErrorSchema);
140
+ if (syntheticErrorCtor) {
141
+ return [syntheticErrorSchema, syntheticErrorCtor, "synthetic"];
142
+ }
143
+ }
144
+ }
145
+ return [defaultErrorSchema, Error, "native"];
146
+ }
106
147
  async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {
107
148
  const eventStreamSerde = await this.loadEventStreamCapability();
108
149
  return eventStreamSerde.serializeEventStream({
@@ -131,13 +172,6 @@ export class HttpProtocol extends SerdeContext {
131
172
  compositeErrorRegistry: this.compositeErrorRegistry,
132
173
  });
133
174
  }
134
- resolveEventStreamMarshaller(importedProvider) {
135
- const context = this.serdeContext;
136
- if (context.eventStreamMarshaller) {
137
- return context.eventStreamMarshaller;
138
- }
139
- return importedProvider(this.serdeContext);
140
- }
141
175
  getDefaultContentType() {
142
176
  throw new Error(`@smithy/core/protocols - ${this.constructor.name} getDefaultContentType() implementation missing.`);
143
177
  }
@@ -156,4 +190,11 @@ export class HttpProtocol extends SerdeContext {
156
190
  }
157
191
  return context.eventStreamMarshaller;
158
192
  }
193
+ resolveEventStreamMarshaller(importedProvider) {
194
+ const context = this.serdeContext;
195
+ if (context.eventStreamMarshaller) {
196
+ return context.eventStreamMarshaller;
197
+ }
198
+ return importedProvider(this.serdeContext);
199
+ }
159
200
  }
@@ -7,12 +7,12 @@ export class TypeRegistry {
7
7
  this.namespace = namespace;
8
8
  this.schemas = schemas;
9
9
  this.exceptions = exceptions;
10
- }
11
- static for(namespace) {
12
10
  if (!TypeRegistry.registries.has(namespace)) {
13
- TypeRegistry.registries.set(namespace, new TypeRegistry(namespace));
11
+ TypeRegistry.registries.set(namespace, this);
14
12
  }
15
- return TypeRegistry.registries.get(namespace);
13
+ }
14
+ static for(namespace) {
15
+ return TypeRegistry.registries.get(namespace) ?? new TypeRegistry(namespace);
16
16
  }
17
17
  copyFrom(other) {
18
18
  const { schemas, exceptions } = this;
@@ -30,7 +30,9 @@ export class TypeRegistry {
30
30
  register(shapeId, schema) {
31
31
  const qualifiedName = this.normalizeShapeId(shapeId);
32
32
  for (const r of [this, TypeRegistry.for(qualifiedName.split("#")[0])]) {
33
- r.schemas.set(qualifiedName, schema);
33
+ if (!r.schemas.has(qualifiedName)) {
34
+ r.schemas.set(qualifiedName, schema);
35
+ }
34
36
  }
35
37
  }
36
38
  getSchema(shapeId) {
@@ -55,9 +57,12 @@ export class TypeRegistry {
55
57
  registerError(es, ctor) {
56
58
  const $error = es;
57
59
  const ns = $error[1];
60
+ const qualifiedName = ns + "#" + $error[2];
58
61
  for (const r of [this, TypeRegistry.for(ns)]) {
59
- r.schemas.set(ns + "#" + $error[2], $error);
60
- r.exceptions.set($error, ctor);
62
+ if (!r.schemas.has(qualifiedName) && !r.exceptions.has($error)) {
63
+ r.schemas.set(qualifiedName, $error);
64
+ r.exceptions.set($error, ctor);
65
+ }
61
66
  }
62
67
  }
63
68
  getErrorCtor(es) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.34.1",
3
+ "version": "3.35.0",
4
4
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/core",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -224,7 +224,7 @@
224
224
  }
225
225
  },
226
226
  "dependencies": {
227
- "@smithy/types": "^4.18.0",
227
+ "@smithy/types": "^4.19.0",
228
228
  "tslib": "^2.6.2"
229
229
  },
230
230
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/types",
3
- "version": "4.18.0",
3
+ "version": "4.19.0",
4
4
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/types",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -56,16 +56,16 @@ changes:
56
56
  `Infinity`, no limit is enforced. Must be a number greater than `0`.
57
57
  **Default:** `Infinity`.
58
58
 
59
- `Agent` inherits all {PoolOptions} (and therefore all {ClientOptions}). The
60
- per-origin {Pool} it creates uses the default unlimited `connections`, so
61
- concurrent requests to the same origin are spread across separate {Client}
62
- instances on separate sockets.
59
+ `Agent` inherits all {PoolOptions} (and therefore all {ClientOptions}). Each
60
+ origin gets a separate {Pool}, with `connections` acting as the maximum number
61
+ of clients that pool may create.
63
62
 
64
63
  > [!NOTE]
65
- > Because each concurrent request to an origin may use a different {Client},
66
- > HTTP/2 multiplexing on a shared session does not apply unless `connections` is
67
- > set to a small value (for example `connections: 1`). See {PoolOptions} and
68
- > {ClientOptions} for the full set of inherited options such as `allowH2`
64
+ > For an h2-capable HTTPS origin, the per-origin pool waits for the first TLS
65
+ > connection to finish ALPN negotiation. If the server selects h2, concurrent
66
+ > requests share that session up to `maxConcurrentStreams`. If it selects
67
+ > HTTP/1.1, normal connection fan-out resumes up to `connections`. See
68
+ > {PoolOptions} and {ClientOptions} for inherited options such as `allowH2`
69
69
  > (default `true`) and `maxConcurrentStreams` (default `100`).
70
70
 
71
71
  ### `agent.closed`
@@ -120,7 +120,8 @@ diagnosticsChannel.channel('undici:request:bodySent').subscribe(({ request }) =>
120
120
  added: v6.3.0
121
121
  -->
122
122
 
123
- Published after the response headers have been received.
123
+ Published after the response headers have been received. This includes a
124
+ successful CONNECT or protocol upgrade response.
124
125
 
125
126
  * `message` {Object}
126
127
  * `request` {Object} The same object published by
@@ -128,8 +129,9 @@ Published after the response headers have been received.
128
129
  * `response` {Object} The response being received.
129
130
  * `statusCode` {number} The HTTP status code.
130
131
  * `statusText` {string} The HTTP status message.
131
- * `headers` {Buffer[]} The raw response headers as an array of buffers,
132
- alternating between header name and value.
132
+ * `headers` {Buffer[]|Object} HTTP/1.1 response headers are an array of
133
+ buffers alternating between header name and value. HTTP/2 response
134
+ headers are an object.
133
135
 
134
136
  ```mjs
135
137
  import diagnosticsChannel from 'node:diagnostics_channel'
@@ -137,7 +139,7 @@ import diagnosticsChannel from 'node:diagnostics_channel'
137
139
  diagnosticsChannel.channel('undici:request:headers').subscribe(({ request, response }) => {
138
140
  console.log('statusCode', response.statusCode)
139
141
  console.log(response.statusText)
140
- console.log(response.headers.map((x) => x.toString()))
142
+ console.log(response.headers)
141
143
  })
142
144
  ```
143
145
 
@@ -168,8 +170,9 @@ diagnosticsChannel.channel('undici:request:bodyChunkReceived').subscribe(({ requ
168
170
  added: v6.3.0
169
171
  -->
170
172
 
171
- Published after the response body and trailers have been received, that is, once
172
- the response has fully completed.
173
+ Published once the response has fully completed. After an upgraded socket has
174
+ been passed to the request handler, this event is published with an empty
175
+ `trailers` array.
173
176
 
174
177
  * `message` {Object}
175
178
  * `request` {Object} The same object published by