@smithy/core 3.28.0 → 3.29.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.
@@ -1090,6 +1090,23 @@ const _json = (obj) => {
1090
1090
  return obj;
1091
1091
  };
1092
1092
 
1093
+ function makeBuilder(common, service, name, ep) {
1094
+ return function makeCommand(added, plugins, op, $, smithyContext = {}) {
1095
+ const epMerged = Object.assign({}, common, added);
1096
+ return Command.classBuilder()
1097
+ .ep(epMerged)
1098
+ .m(function (CommandCtor, clientStack, config, options) {
1099
+ const list = plugins.call(this, CommandCtor, clientStack, config, options);
1100
+ list.unshift(ep(config, CommandCtor.getEndpointParameterInstructions()));
1101
+ return list;
1102
+ })
1103
+ .s(service, op, smithyContext)
1104
+ .n(name, op.charAt(0).toUpperCase() + op.slice(1) + "Command")
1105
+ .sc($)
1106
+ .build();
1107
+ };
1108
+ }
1109
+
1093
1110
  exports.Client = Client;
1094
1111
  exports.Command = Command;
1095
1112
  exports.NoOpLogger = NoOpLogger;
@@ -1114,6 +1131,7 @@ exports.invalidFunction = invalidFunction;
1114
1131
  exports.invalidProvider = invalidProvider;
1115
1132
  exports.isSerializableHeaderValue = isSerializableHeaderValue;
1116
1133
  exports.loadConfigsForDefaultMode = loadConfigsForDefaultMode;
1134
+ exports.makeBuilder = makeBuilder;
1117
1135
  exports.map = map;
1118
1136
  exports.resolveChecksumRuntimeConfig = resolveChecksumRuntimeConfig;
1119
1137
  exports.resolveDefaultRuntimeConfig = resolveDefaultRuntimeConfig;
@@ -24,3 +24,4 @@ export { map, convertMap, take, } from "./smithy-client/object-mapping";
24
24
  export { schemaLogFilter } from "./smithy-client/schemaLogFilter";
25
25
  export { serializeFloat, serializeDateTime } from "./smithy-client/ser-utils";
26
26
  export { _json } from "./smithy-client/serde-json";
27
+ export { makeBuilder } from "./smithy-client/client-command-builder";
@@ -0,0 +1,17 @@
1
+ import { Command } from "./command";
2
+ export function makeBuilder(common, service, name, ep) {
3
+ return function makeCommand(added, plugins, op, $, smithyContext = {}) {
4
+ const epMerged = Object.assign({}, common, added);
5
+ return Command.classBuilder()
6
+ .ep(epMerged)
7
+ .m(function (CommandCtor, clientStack, config, options) {
8
+ const list = plugins.call(this, CommandCtor, clientStack, config, options);
9
+ list.unshift(ep(config, CommandCtor.getEndpointParameterInstructions()));
10
+ return list;
11
+ })
12
+ .s(service, op, smithyContext)
13
+ .n(name, op.charAt(0).toUpperCase() + op.slice(1) + "Command")
14
+ .sc($)
15
+ .build();
16
+ };
17
+ }
@@ -24,3 +24,4 @@ export { map, convertMap, take, type ObjectMappingInstructions, type SourceMappi
24
24
  export { schemaLogFilter } from "./smithy-client/schemaLogFilter";
25
25
  export { serializeFloat, serializeDateTime } from "./smithy-client/ser-utils";
26
26
  export { _json } from "./smithy-client/serde-json";
27
+ export { makeBuilder } from "./smithy-client/client-command-builder";
@@ -0,0 +1,22 @@
1
+ import type { EndpointParameterInstructions, Logger, MetadataBearer, OptionalParameter, Pluggable, RequestHandler, StaticOperationSchema } from "@smithy/types";
2
+ import { type CommandImpl } from "./command";
3
+ /**
4
+ * Higher order factory for Command builders specific to a client.
5
+ * Produces a command factory that creates Command classes with
6
+ * pre-configured endpoint params, middleware, and schema.
7
+ *
8
+ * @param common - common endpoint params.
9
+ * @param service - service shape name.
10
+ * @param name - SDK Client Name.
11
+ * @param ep - endpoint plugin provider.
12
+ *
13
+ * @internal
14
+ */
15
+ export declare function makeBuilder<C extends {
16
+ logger?: Logger;
17
+ requestHandler: RequestHandler<any, any, any>;
18
+ }, SI extends object, SO extends MetadataBearer>(common: EndpointParameterInstructions, service: string, name: string, ep: (config: any, instructions: any) => Pluggable<any, any>): <I extends SI, O extends SO>(added: EndpointParameterInstructions, plugins: (CommandCtor: any, clientStack: any, config: any, options: any) => Pluggable<any, any>[], op: string, $: StaticOperationSchema, smithyContext?: Record<string, unknown>) => {
19
+ new (input: I): CommandImpl<I, O, C, SI, SO>;
20
+ new (...[input]: OptionalParameter<I>): CommandImpl<I, O, C, SI, SO>;
21
+ getEndpointParameterInstructions(): EndpointParameterInstructions;
22
+ };
@@ -1,5 +1,4 @@
1
- import { type Handler, type HandlerExecutionContext, type Command as ICommand, type HttpRequest as IHttpRequest, type HttpResponse as IHttpResponse, type MiddlewareStack as IMiddlewareStack, type Logger, type MetadataBearer, type OperationSchema, type OptionalParameter, type Pluggable, type RequestHandler, type SerdeContext, type StaticOperationSchema } from "@smithy/types";
2
- type EndpointParameterInstructions = Record<string, unknown>;
1
+ import { type EndpointParameterInstructions, type Handler, type HandlerExecutionContext, type Command as ICommand, type HttpRequest as IHttpRequest, type HttpResponse as IHttpResponse, type MiddlewareStack as IMiddlewareStack, type Logger, type MetadataBearer, type OperationSchema, type OptionalParameter, type Pluggable, type RequestHandler, type SerdeContext, type StaticOperationSchema } from "@smithy/types";
3
2
  /**
4
3
  * @public
5
4
  */
@@ -12,7 +11,7 @@ export declare abstract class Command<Input extends ClientInput, Output extends
12
11
  * @internal
13
12
  */
14
13
  static classBuilder<I extends SI, O extends SO, C extends {
15
- logger: Logger;
14
+ logger?: Logger;
16
15
  requestHandler: RequestHandler<any, any, any>;
17
16
  }, SI extends object = any, SO extends MetadataBearer = any>(): ClassBuilder<I, O, C, SI, SO>;
18
17
  abstract resolveMiddleware(stack: IMiddlewareStack<ClientInput, ClientOutput>, configuration: ResolvedClientConfiguration, options: any): Handler<Input, Output>;
@@ -20,7 +19,7 @@ export declare abstract class Command<Input extends ClientInput, Output extends
20
19
  * @internal
21
20
  */
22
21
  resolveMiddlewareWithContext(clientStack: IMiddlewareStack<any, any>, configuration: {
23
- logger: Logger;
22
+ logger?: Logger;
24
23
  requestHandler: RequestHandler<any, any, any>;
25
24
  }, options: any, { middlewareFn, clientName, commandName, inputFilterSensitiveLog, outputFilterSensitiveLog, smithyContext, additionalContext, CommandCtor, }: ResolveMiddlewareContextArgs): import("@smithy/types").InitializeHandler<any, Output>;
26
25
  }
@@ -41,7 +40,7 @@ type ResolveMiddlewareContextArgs = {
41
40
  * @internal
42
41
  */
43
42
  declare class ClassBuilder<I extends SI, O extends SO, C extends {
44
- logger: Logger;
43
+ logger?: Logger;
45
44
  requestHandler: RequestHandler<any, any, any>;
46
45
  }, SI extends object = any, SO extends MetadataBearer = any> {
47
46
  private _init;
@@ -110,7 +109,7 @@ declare class ClassBuilder<I extends SI, O extends SO, C extends {
110
109
  * @public
111
110
  */
112
111
  export interface CommandImpl<I extends SI, O extends SO, C extends {
113
- logger: Logger;
112
+ logger?: Logger;
114
113
  requestHandler: RequestHandler<any, any, any>;
115
114
  }, SI extends object = any, SO extends MetadataBearer = any> extends Command<I, O, C, SI, SO> {
116
115
  readonly input: I;
@@ -7,18 +7,17 @@ export { isValidHostLabel } from "@smithy/core/transport";
7
7
  export { customEndpointFunctions } from "./util-endpoints/utils/customEndpointFunctions";
8
8
  export { resolveEndpoint } from "./util-endpoints/resolveEndpoint";
9
9
  export * from "./util-endpoints/types";
10
- export declare const getEndpointFromInstructions: <T extends import("@smithy/types").EndpointParameters, CommandInput extends Record<string, unknown>, Config extends Record<string, unknown>>(commandInput: CommandInput, instructionsSupplier: import("./middleware-endpoint/adaptors/getEndpointFromInstructions").EndpointParameterInstructionsSupplier, clientConfig: Partial<import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>> & Config, context?: import("@smithy/types").HandlerExecutionContext) => Promise<import("@smithy/types").EndpointV2>;
10
+ export declare const getEndpointFromInstructions: <T extends import("@smithy/types").EndpointParameters, CommandInput extends object, Config extends object>(commandInput: CommandInput, instructionsSupplier: import("./middleware-endpoint/adaptors/getEndpointFromInstructions").EndpointParameterInstructionsSupplier, clientConfig: Partial<import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>> & Config, context?: import("@smithy/types").HandlerExecutionContext) => Promise<import("@smithy/types").EndpointV2>;
11
11
  export declare const resolveEndpointConfig: <T, P extends import("@smithy/types").EndpointParameters = import("@smithy/types").EndpointParameters>(input: T & import("./middleware-endpoint/resolveEndpointConfig").EndpointInputConfig<P> & import("./middleware-endpoint/resolveEndpointConfig").PreviouslyResolved<P>) => T & import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<P>;
12
12
  export declare const endpointMiddleware: <T extends import("@smithy/types").EndpointParameters>({ config, instructions, }: {
13
13
  config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>;
14
- instructions: import("./middleware-endpoint/types").EndpointParameterInstructions;
14
+ instructions: import("@smithy/types").EndpointParameterInstructions;
15
15
  }) => import("@smithy/types").SerializeMiddleware<any, any>;
16
- export declare const getEndpointPlugin: <T extends import("@smithy/types").EndpointParameters>(config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>, instructions: import("./middleware-endpoint/types").EndpointParameterInstructions) => import("@smithy/types").Pluggable<any, any>;
16
+ export declare const getEndpointPlugin: <T extends import("@smithy/types").EndpointParameters>(config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>, instructions: import("@smithy/types").EndpointParameterInstructions) => import("@smithy/types").Pluggable<any, any>;
17
17
  export { resolveParams, type EndpointParameterInstructionsSupplier, } from "./middleware-endpoint/adaptors/getEndpointFromInstructions";
18
18
  export { toEndpointV1 as middlewareEndpointToEndpointV1 } from "./middleware-endpoint/adaptors/toEndpointV1";
19
19
  export { endpointMiddlewareOptions } from "./middleware-endpoint/getEndpointPlugin";
20
20
  export type { EndpointInputConfig, EndpointResolvedConfig } from "./middleware-endpoint/resolveEndpointConfig";
21
21
  export { resolveEndpointRequiredConfig } from "./middleware-endpoint/resolveEndpointRequiredConfig";
22
22
  export type { EndpointRequiredInputConfig, EndpointRequiredResolvedConfig, } from "./middleware-endpoint/resolveEndpointRequiredConfig";
23
- export type { EndpointParameterInstructions } from "./middleware-endpoint/types";
24
- export type { BuiltInParamInstruction, ClientContextParamInstruction, ContextParamInstruction, OperationContextParamInstruction, StaticContextParamInstruction, } from "./middleware-endpoint/types";
23
+ export type { EndpointParameterInstructions, BuiltInParamInstruction, ClientContextParamInstruction, ContextParamInstruction, OperationContextParamInstruction, StaticContextParamInstruction, } from "@smithy/types";
@@ -7,18 +7,17 @@ export { isValidHostLabel } from "@smithy/core/transport";
7
7
  export { customEndpointFunctions } from "./util-endpoints/utils/customEndpointFunctions";
8
8
  export { resolveEndpoint } from "./util-endpoints/resolveEndpoint";
9
9
  export * from "./util-endpoints/types";
10
- export declare const getEndpointFromInstructions: <T extends import("@smithy/types").EndpointParameters, CommandInput extends Record<string, unknown>, Config extends Record<string, unknown>>(commandInput: CommandInput, instructionsSupplier: import("./middleware-endpoint/adaptors/getEndpointFromInstructions").EndpointParameterInstructionsSupplier, clientConfig: Partial<import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>> & Config, context?: import("@smithy/types").HandlerExecutionContext) => Promise<import("@smithy/types").EndpointV2>;
10
+ export declare const getEndpointFromInstructions: <T extends import("@smithy/types").EndpointParameters, CommandInput extends object, Config extends object>(commandInput: CommandInput, instructionsSupplier: import("./middleware-endpoint/adaptors/getEndpointFromInstructions").EndpointParameterInstructionsSupplier, clientConfig: Partial<import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>> & Config, context?: import("@smithy/types").HandlerExecutionContext) => Promise<import("@smithy/types").EndpointV2>;
11
11
  export declare const resolveEndpointConfig: <T, P extends import("@smithy/types").EndpointParameters = import("@smithy/types").EndpointParameters>(input: T & import("./middleware-endpoint/resolveEndpointConfig").EndpointInputConfig<P> & import("./middleware-endpoint/resolveEndpointConfig").PreviouslyResolved<P>) => T & import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<P>;
12
12
  export declare const endpointMiddleware: <T extends import("@smithy/types").EndpointParameters>({ config, instructions, }: {
13
13
  config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>;
14
- instructions: import("./middleware-endpoint/types").EndpointParameterInstructions;
14
+ instructions: import("@smithy/types").EndpointParameterInstructions;
15
15
  }) => import("@smithy/types").SerializeMiddleware<any, any>;
16
- export declare const getEndpointPlugin: <T extends import("@smithy/types").EndpointParameters>(config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>, instructions: import("./middleware-endpoint/types").EndpointParameterInstructions) => import("@smithy/types").Pluggable<any, any>;
16
+ export declare const getEndpointPlugin: <T extends import("@smithy/types").EndpointParameters>(config: import("./middleware-endpoint/resolveEndpointConfig").EndpointResolvedConfig<T>, instructions: import("@smithy/types").EndpointParameterInstructions) => import("@smithy/types").Pluggable<any, any>;
17
17
  export { resolveParams, type EndpointParameterInstructionsSupplier, } from "./middleware-endpoint/adaptors/getEndpointFromInstructions";
18
18
  export { toEndpointV1 as middlewareEndpointToEndpointV1 } from "./middleware-endpoint/adaptors/toEndpointV1";
19
19
  export { endpointMiddlewareOptions } from "./middleware-endpoint/getEndpointPlugin";
20
20
  export type { EndpointInputConfig, EndpointResolvedConfig } from "./middleware-endpoint/resolveEndpointConfig";
21
21
  export { resolveEndpointRequiredConfig } from "./middleware-endpoint/resolveEndpointRequiredConfig";
22
22
  export type { EndpointRequiredInputConfig, EndpointRequiredResolvedConfig, } from "./middleware-endpoint/resolveEndpointRequiredConfig";
23
- export type { EndpointParameterInstructions } from "./middleware-endpoint/types";
24
- export type { BuiltInParamInstruction, ClientContextParamInstruction, ContextParamInstruction, OperationContextParamInstruction, StaticContextParamInstruction, } from "./middleware-endpoint/types";
23
+ export type { EndpointParameterInstructions, BuiltInParamInstruction, ClientContextParamInstruction, ContextParamInstruction, OperationContextParamInstruction, StaticContextParamInstruction, } from "@smithy/types";
@@ -1,6 +1,5 @@
1
- import type { EndpointParameters, EndpointV2, HandlerExecutionContext } from "@smithy/types";
1
+ import type { EndpointParameterInstructions, EndpointParameters, EndpointV2, HandlerExecutionContext } from "@smithy/types";
2
2
  import type { EndpointResolvedConfig } from "../resolveEndpointConfig";
3
- import type { EndpointParameterInstructions } from "../types";
4
3
  /**
5
4
  * @internal
6
5
  */
@@ -14,8 +13,8 @@ export type GetEndpointFromConfig = (serviceId?: string) => Promise<string | und
14
13
  /**
15
14
  * @internal
16
15
  */
17
- export declare function bindGetEndpointFromInstructions(getEndpointFromConfig: GetEndpointFromConfig): <T extends EndpointParameters, CommandInput extends Record<string, unknown>, Config extends Record<string, unknown>>(commandInput: CommandInput, instructionsSupplier: EndpointParameterInstructionsSupplier, clientConfig: Partial<EndpointResolvedConfig<T>> & Config, context?: HandlerExecutionContext) => Promise<EndpointV2>;
16
+ export declare function bindGetEndpointFromInstructions(getEndpointFromConfig: GetEndpointFromConfig): <T extends EndpointParameters, CommandInput extends object, Config extends object>(commandInput: CommandInput, instructionsSupplier: EndpointParameterInstructionsSupplier, clientConfig: Partial<EndpointResolvedConfig<T>> & Config, context?: HandlerExecutionContext) => Promise<EndpointV2>;
18
17
  /**
19
18
  * @internal
20
19
  */
21
- export declare const resolveParams: <T extends EndpointParameters, CommandInput extends Record<string, unknown>, Config extends Record<string, unknown>>(commandInput: CommandInput, instructionsSupplier: EndpointParameterInstructionsSupplier, clientConfig: Partial<EndpointResolvedConfig<T>> & Config) => Promise<EndpointParameters>;
20
+ export declare const resolveParams: <T extends EndpointParameters, CommandInput, Config>(commandInput: CommandInput, instructionsSupplier: EndpointParameterInstructionsSupplier, clientConfig: Partial<EndpointResolvedConfig<T>> & Config) => Promise<EndpointParameters>;
@@ -1,7 +1,6 @@
1
- import type { EndpointParameters, SerializeMiddleware } from "@smithy/types";
1
+ import type { EndpointParameterInstructions, EndpointParameters, SerializeMiddleware } from "@smithy/types";
2
2
  import { type GetEndpointFromConfig } from "./adaptors/getEndpointFromInstructions";
3
3
  import type { EndpointResolvedConfig } from "./resolveEndpointConfig";
4
- import type { EndpointParameterInstructions } from "./types";
5
4
  /**
6
5
  * @internal
7
6
  */
@@ -1,7 +1,6 @@
1
- import type { EndpointParameters, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types";
1
+ import type { EndpointParameterInstructions, EndpointParameters, Pluggable, RelativeMiddlewareOptions, SerializeHandlerOptions } from "@smithy/types";
2
2
  import type { GetEndpointFromConfig } from "./adaptors/getEndpointFromInstructions";
3
3
  import type { EndpointResolvedConfig } from "./resolveEndpointConfig";
4
- import type { EndpointParameterInstructions } from "./types";
5
4
  /**
6
5
  * @internal
7
6
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.28.0",
3
+ "version": "3.29.0",
4
4
  "scripts": {
5
5
  "benchmark:cbor": "node ./scripts/cbor-perf.mjs",
6
6
  "benchmark:checksum": "node ./scripts/checksum-perf.mjs",
@@ -170,7 +170,7 @@
170
170
  "license": "Apache-2.0",
171
171
  "sideEffects": false,
172
172
  "dependencies": {
173
- "@smithy/types": "^4.15.0",
173
+ "@smithy/types": "^4.15.1",
174
174
  "tslib": "^2.6.2"
175
175
  },
176
176
  "devDependencies": {
@@ -1,41 +0,0 @@
1
- /**
2
- * @internal
3
- */
4
- export interface EndpointParameterInstructions {
5
- [name: string]: BuiltInParamInstruction | ClientContextParamInstruction | StaticContextParamInstruction | ContextParamInstruction | OperationContextParamInstruction;
6
- }
7
- /**
8
- * @internal
9
- */
10
- export interface BuiltInParamInstruction {
11
- type: "builtInParams";
12
- name: string;
13
- }
14
- /**
15
- * @internal
16
- */
17
- export interface ClientContextParamInstruction {
18
- type: "clientContextParams";
19
- name: string;
20
- }
21
- /**
22
- * @internal
23
- */
24
- export interface StaticContextParamInstruction {
25
- type: "staticContextParams";
26
- value: string | boolean;
27
- }
28
- /**
29
- * @internal
30
- */
31
- export interface ContextParamInstruction {
32
- type: "contextParams";
33
- name: string;
34
- }
35
- /**
36
- * @internal
37
- */
38
- export interface OperationContextParamInstruction {
39
- type: "operationContextParams";
40
- get(input: any): any;
41
- }