Skip to content

Commit

Permalink
chore(packages): re-export types from @smithy/types (#4900)
Browse files Browse the repository at this point in the history
  • Loading branch information
srchase committed Jul 10, 2023
1 parent ed452d6 commit e0751b4
Show file tree
Hide file tree
Showing 32 changed files with 164 additions and 2,216 deletions.
1 change: 1 addition & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"directory": "packages/types"
},
"dependencies": {
"@smithy/types": "1.1.0",
"tslib": "^2.5.0"
},
"devDependencies": {
Expand Down
54 changes: 1 addition & 53 deletions packages/types/src/abort.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1 @@
/**
* @public
*/
export interface AbortHandler {
(this: AbortSignal, ev: any): any;
}

/**
* @public
*
* Holders of an AbortSignal object may query if the associated operation has
* been aborted and register an onabort handler.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
*/
export interface AbortSignal {
/**
* Whether the action represented by this signal has been cancelled.
*/
readonly aborted: boolean;

/**
* A function to be invoked when the action represented by this signal has
* been cancelled.
*/
onabort: AbortHandler | Function | null;
}

/**
* @public
*
* The AWS SDK uses a Controller/Signal model to allow for cooperative
* cancellation of asynchronous operations. When initiating such an operation,
* the caller can create an AbortController and then provide linked signal to
* subtasks. This allows a single source to communicate to multiple consumers
* that an action has been aborted without dictating how that cancellation
* should be handled.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortController
*/
export interface AbortController {
/**
* An object that reports whether the action associated with this
* `AbortController` has been cancelled.
*/
readonly signal: AbortSignal;

/**
* Declares the operation associated with this AbortController to have been
* cancelled.
*/
abort(): void;
}
export { AbortController, AbortHandler, AbortSignal } from "@smithy/types";
62 changes: 1 addition & 61 deletions packages/types/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1 @@
/**
* @internal
*
* Authentication schemes represent a way that the service will authenticate the customer’s identity.
*/
export interface AuthScheme {
/**
* @example "sigv4a" or "sigv4"
*/
name: "sigv4" | "sigv4a" | string;
/**
* @example "s3"
*/
signingName: string;
/**
* @example "us-east-1"
*/
signingRegion: string;
/**
* @example ["*"]
* @example ["us-west-2", "us-east-1"]
*/
signingRegionSet?: string[];
/**
* @deprecated this field was renamed to signingRegion.
*/
signingScope?: never;
properties: Record<string, unknown>;
}

// As described in the Smithy documentation:
// https://github.com/awslabs/smithy/blob/main/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude.smithy
/**
* @internal
*/
export interface HttpAuthDefinition {
/**
* Defines the location of where the Auth is serialized.
*/
in: HttpAuthLocation;

/**
* Defines the name of the HTTP header or query string parameter
* that contains the Auth.
*/
name: string;

/**
* Defines the security scheme to use on the `Authorization` header value.
* This can only be set if the "in" property is set to {@link HttpAuthLocation.HEADER}.
*/
scheme?: string;
}

/**
* @internal
*/
export enum HttpAuthLocation {
HEADER = "header",
QUERY = "query",
}
export { AuthScheme, HttpAuthDefinition, HttpAuthLocation } from "@smithy/types";
71 changes: 1 addition & 70 deletions packages/types/src/checksum.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1 @@
import { SourceData } from "./crypto";

/**
* @public
*
* An object that provides a checksum of data provided in chunks to `update`.
* The checksum may be performed incrementally as chunks are received or all
* at once when the checksum is finalized, depending on the underlying
* implementation.
*
* It's recommended to compute checksum incrementally to avoid reading the
* entire payload in memory.
*
* A class that implements this interface may accept an optional secret key in its
* constructor while computing checksum value, when using HMAC. If provided,
* this secret key would be used when computing checksum.
*/
export interface Checksum {
/**
* Constant length of the digest created by the algorithm in bytes.
*/
digestLength?: number;

/**
* Creates a new checksum object that contains a deep copy of the internal
* state of the current `Checksum` object.
*/
copy?(): Checksum;

/**
* Returns the digest of all of the data passed.
*/
digest(): Promise<Uint8Array>;

/**
* Allows marking a checksum for checksums that support the ability
* to mark and reset.
*
* @param readLimit - The maximum limit of bytes that can be read
* before the mark position becomes invalid.
*/
mark?(readLimit: number): void;

/**
* Resets the checksum to its initial value.
*/
reset(): void;

/**
* Adds a chunk of data for which checksum needs to be computed.
* This can be called many times with new data as it is streamed.
*
* Implementations may override this method which passes second param
* which makes Checksum object stateless.
*
* @param chunk - The buffer to update checksum with.
*/
update(chunk: Uint8Array): void;
}

/**
* @public
*
* A constructor for a Checksum that may be used to calculate an HMAC. Implementing
* classes should not directly hold the provided key in memory beyond the
* lexical scope of the constructor.
*/
export interface ChecksumConstructor {
new (secret?: SourceData): Checksum;
}
export { Checksum, ChecksumConstructor } from "@smithy/types";
38 changes: 1 addition & 37 deletions packages/types/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1 @@
import { Command } from "./command";
import { MiddlewareStack } from "./middleware";
import { MetadataBearer } from "./response";

/**
* @public
*
* function definition for different overrides of client's 'send' function.
*/
interface InvokeFunction<InputTypes extends object, OutputTypes extends MetadataBearer, ResolvedClientConfiguration> {
<InputType extends InputTypes, OutputType extends OutputTypes>(
command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>,
options?: any
): Promise<OutputType>;
<InputType extends InputTypes, OutputType extends OutputTypes>(
command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>,
options: any,
cb: (err: any, data?: OutputType) => void
): void;
<InputType extends InputTypes, OutputType extends OutputTypes>(
command: Command<InputTypes, InputType, OutputTypes, OutputType, ResolvedClientConfiguration>,
options?: any,
cb?: (err: any, data?: OutputType) => void
): Promise<OutputType> | void;
}

/**
* A general interface for service clients, idempotent to browser or node clients
* This type corresponds to SmithyClient(https://github.com/aws/aws-sdk-js-v3/blob/main/packages/smithy-client/src/client.ts).
* It's provided for using without importing the SmithyClient class.
*/
export interface Client<Input extends object, Output extends MetadataBearer, ResolvedClientConfiguration> {
readonly config: ResolvedClientConfiguration;
middlewareStack: MiddlewareStack<Input, Output>;
send: InvokeFunction<Input, Output, ResolvedClientConfiguration>;
destroy: () => void;
}
export { Client } from "@smithy/types";
22 changes: 1 addition & 21 deletions packages/types/src/command.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
import { Handler, MiddlewareStack } from "./middleware";
import { MetadataBearer } from "./response";

/**
* @public
*/
export interface Command<
ClientInput extends object,
InputType extends ClientInput,
ClientOutput extends MetadataBearer,
OutputType extends ClientOutput,
ResolvedConfiguration
> {
readonly input: InputType;
readonly middlewareStack: MiddlewareStack<InputType, OutputType>;
resolveMiddleware(
stack: MiddlewareStack<ClientInput, ClientOutput>,
configuration: ResolvedConfiguration,
options: any
): Handler<InputType, OutputType>;
}
export { Command } from "@smithy/types";
1 change: 1 addition & 0 deletions packages/types/src/connection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ConnectConfiguration, ConnectionManager, ConnectionManagerConfiguration, ConnectionPool } from "@smithy/types";
7 changes: 0 additions & 7 deletions packages/types/src/connection/config.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/types/src/connection/index.ts

This file was deleted.

33 changes: 0 additions & 33 deletions packages/types/src/connection/manager.ts

This file was deleted.

28 changes: 0 additions & 28 deletions packages/types/src/connection/pool.ts

This file was deleted.

Loading

0 comments on commit e0751b4

Please sign in to comment.