Skip to content

Commit

Permalink
Bump prettier to 3.2.5 (#1265)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored May 9, 2024
1 parent 0ee4d33 commit 74a4554
Show file tree
Hide file tree
Showing 78 changed files with 847 additions and 1,658 deletions.
2 changes: 2 additions & 0 deletions .changeset/fuzzy-coats-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"karma-sourcemap-loader": "0.3.8",
"karma-typescript": "5.5.3",
"karma-webpack": "5.0.0",
"prettier": "2.2.1",
"prettier": "3.2.5",
"puppeteer": "^19.2.0",
"ts-jest": "28.0.5",
"turbo": "latest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export const getResolvedHostname = (
regionHostname
? regionHostname
: partitionHostname
? partitionHostname.replace("{region}", resolvedRegion)
: undefined;
? partitionHostname.replace("{region}", resolvedRegion)
: undefined;
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface HttpAuthSchemeEndpointRuleSetPluginOptions<
TConfig extends object,
TContext extends HandlerExecutionContext,
TParameters extends HttpAuthSchemeParameters,
TInput extends object
TInput extends object,
> {
httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>;
identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>;
Expand All @@ -43,7 +43,7 @@ export const getHttpAuthSchemeEndpointRuleSetPlugin = <
TConfig extends object,
TContext extends HandlerExecutionContext,
TParameters extends HttpAuthSchemeParameters,
TInput extends object
TInput extends object,
>(
config: TConfig & PreviouslyResolved<TParameters>,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface HttpAuthSchemePluginOptions<
TConfig extends object,
TContext extends HandlerExecutionContext,
TParameters extends HttpAuthSchemeParameters,
TInput extends object
TInput extends object,
> {
httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>;
identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>;
Expand All @@ -43,7 +43,7 @@ export const getHttpAuthSchemePlugin = <
TConfig extends object,
TContext extends HandlerExecutionContext,
TParameters extends HttpAuthSchemeParameters,
TInput extends object
TInput extends object,
>(
config: TConfig & PreviouslyResolved<TParameters>,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface HttpAuthSchemeMiddlewareOptions<
TConfig extends object,
TContext extends HandlerExecutionContext,
TParameters extends HttpAuthSchemeParameters,
TInput extends object
TInput extends object,
> {
httpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<TConfig, TContext, TParameters, TInput>;
identityProviderConfigProvider: (config: TConfig) => Promise<IdentityProviderConfig>;
Expand Down Expand Up @@ -65,50 +65,51 @@ function convertHttpAuthSchemesToMap(httpAuthSchemes: HttpAuthScheme[]): Map<Htt
/**
* @internal
*/
export const httpAuthSchemeMiddleware = <
TInput extends object,
Output extends object,
TConfig extends object,
TContext extends HttpAuthSchemeMiddlewareHandlerExecutionContext,
TParameters extends HttpAuthSchemeParameters
>(
config: TConfig & PreviouslyResolved<TParameters>,
mwOptions: HttpAuthSchemeMiddlewareOptions<TConfig, TContext, TParameters, TInput>
): SerializeMiddleware<TInput, Output> => (
next: SerializeHandler<TInput, Output>,
context: HttpAuthSchemeMiddlewareHandlerExecutionContext
): SerializeHandler<TInput, Output> => async (
args: SerializeHandlerArguments<TInput>
): Promise<SerializeHandlerOutput<Output>> => {
const options = config.httpAuthSchemeProvider(
await mwOptions.httpAuthSchemeParametersProvider(config, context as TContext, args.input)
);
const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
const smithyContext: HttpAuthSchemeMiddlewareSmithyContext = getSmithyContext(context);
const failureReasons = [];
for (const option of options) {
const scheme = authSchemes.get(option.schemeId);
if (!scheme) {
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`);
continue;
export const httpAuthSchemeMiddleware =
<
TInput extends object,
Output extends object,
TConfig extends object,
TContext extends HttpAuthSchemeMiddlewareHandlerExecutionContext,
TParameters extends HttpAuthSchemeParameters,
>(
config: TConfig & PreviouslyResolved<TParameters>,
mwOptions: HttpAuthSchemeMiddlewareOptions<TConfig, TContext, TParameters, TInput>
): SerializeMiddleware<TInput, Output> =>
(
next: SerializeHandler<TInput, Output>,
context: HttpAuthSchemeMiddlewareHandlerExecutionContext
): SerializeHandler<TInput, Output> =>
async (args: SerializeHandlerArguments<TInput>): Promise<SerializeHandlerOutput<Output>> => {
const options = config.httpAuthSchemeProvider(
await mwOptions.httpAuthSchemeParametersProvider(config, context as TContext, args.input)
);
const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
const smithyContext: HttpAuthSchemeMiddlewareSmithyContext = getSmithyContext(context);
const failureReasons = [];
for (const option of options) {
const scheme = authSchemes.get(option.schemeId);
if (!scheme) {
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`);
continue;
}
const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config));
if (!identityProvider) {
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`);
continue;
}
const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {};
option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties);
option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties);
smithyContext.selectedHttpAuthScheme = {
httpAuthOption: option,
identity: await identityProvider(option.identityProperties),
signer: scheme.signer,
};
break;
}
const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config));
if (!identityProvider) {
failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`);
continue;
if (!smithyContext.selectedHttpAuthScheme) {
throw new Error(failureReasons.join("\n"));
}
const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {};
option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties);
option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties);
smithyContext.selectedHttpAuthScheme = {
httpAuthOption: option,
identity: await identityProvider(option.identityProperties),
signer: scheme.signer,
};
break;
}
if (!smithyContext.selectedHttpAuthScheme) {
throw new Error(failureReasons.join("\n"));
}
return next(args);
};
return next(args);
};
55 changes: 27 additions & 28 deletions packages/core/src/middleware-http-signing/httpSigningMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,31 @@ const defaultSuccessHandler: SuccessHandler = (
/**
* @internal
*/
export const httpSigningMiddleware = <Input extends object, Output extends object>(
config: object
): FinalizeRequestMiddleware<Input, Output> => (
next: FinalizeHandler<Input, Output>,
context: HttpSigningMiddlewareHandlerExecutionContext
): FinalizeHandler<Input, Output> => async (
args: FinalizeHandlerArguments<Input>
): Promise<FinalizeHandlerOutput<Output>> => {
if (!HttpRequest.isInstance(args.request)) {
return next(args);
}
export const httpSigningMiddleware =
<Input extends object, Output extends object>(config: object): FinalizeRequestMiddleware<Input, Output> =>
(
next: FinalizeHandler<Input, Output>,
context: HttpSigningMiddlewareHandlerExecutionContext
): FinalizeHandler<Input, Output> =>
async (args: FinalizeHandlerArguments<Input>): Promise<FinalizeHandlerOutput<Output>> => {
if (!HttpRequest.isInstance(args.request)) {
return next(args);
}

const smithyContext: HttpSigningMiddlewareSmithyContext = getSmithyContext(context);
const scheme = smithyContext.selectedHttpAuthScheme;
if (!scheme) {
throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
}
const {
httpAuthOption: { signingProperties = {} },
identity,
signer,
} = scheme;
const output = await next({
...args,
request: await signer.sign(args.request, identity, signingProperties),
}).catch((signer.errorHandler || defaultErrorHandler)(signingProperties));
(signer.successHandler || defaultSuccessHandler)(output.response, signingProperties);
return output;
};
const smithyContext: HttpSigningMiddlewareSmithyContext = getSmithyContext(context);
const scheme = smithyContext.selectedHttpAuthScheme;
if (!scheme) {
throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
}
const {
httpAuthOption: { signingProperties = {} },
identity,
signer,
} = scheme;
const output = await next({
...args,
request: await signer.sign(args.request, identity, signingProperties),
}).catch((signer.errorHandler || defaultErrorHandler)(signingProperties));
(signer.successHandler || defaultSuccessHandler)(output.response, signingProperties);
return output;
};
2 changes: 1 addition & 1 deletion packages/core/src/pagination/createPaginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const makePagedClientRequest = async <ClientType extends Client<any, any, any>,
export function createPaginator<
PaginationConfigType extends PaginationConfiguration,
InputType extends object,
OutputType extends object
OutputType extends object,
>(
ClientCtor: any,
CommandCtor: any,
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/protocols/requestBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export class RequestBuilder {

private resolvePathStack: Array<(path: string) => void> = [];

public constructor(private input: any, private context: SerdeContext) {}
public constructor(
private input: any,
private context: SerdeContext
) {}

public async build() {
const { hostname, protocol = "https", port, path: basePath } = await this.context.endpoint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { CredentialsProviderError } from "@smithy/property-provider";
export class InstanceMetadataV1FallbackError extends CredentialsProviderError {
public name = "InstanceMetadataV1FallbackError";

constructor(message: string, public readonly tryNextLink: boolean = true) {
constructor(
message: string,
public readonly tryNextLink: boolean = true
) {
super(message, tryNextLink);
Object.setPrototypeOf(this, InstanceMetadataV1FallbackError.prototype);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("fromInstanceMetadata", () => {
beforeEach(() => {
(staticStabilityProvider as jest.Mock).mockImplementation((input) => input);
(getInstanceMetadataEndpoint as jest.Mock).mockResolvedValue({ hostname });
((isImdsCredentials as unknown) as jest.Mock).mockReturnValue(true);
(isImdsCredentials as unknown as jest.Mock).mockReturnValue(true);
(providerConfigFromInit as jest.Mock).mockReturnValue({
timeout: mockTimeout,
maxRetries: mockMaxRetries,
Expand Down Expand Up @@ -139,7 +139,7 @@ describe("fromInstanceMetadata", () => {
.mockResolvedValueOnce(JSON.stringify(mockImdsCreds));

(retry as jest.Mock).mockImplementation((fn: any) => fn());
((isImdsCredentials as unknown) as jest.Mock).mockReturnValueOnce(false);
(isImdsCredentials as unknown as jest.Mock).mockReturnValueOnce(false);

await expect(fromInstanceMetadata()()).rejects.toEqual(
new CredentialsProviderError("Invalid response received from instance metadata service.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("getExtendedInstanceMetadataCredentials()", () => {
});

it("should extend the expiration random time(5~10 mins) from now", () => {
const anyDate: Date = ("any date" as unknown) as Date;
const anyDate: Date = "any date" as unknown as Date;
(Math.random as jest.Mock).mockReturnValue(0.5);
expect(getExtendedInstanceMetadataCredentials({ ...staticSecret, expiration: anyDate }, logger)).toEqual({
...staticSecret,
Expand All @@ -33,7 +33,7 @@ describe("getExtendedInstanceMetadataCredentials()", () => {
});

it("should print warning message when extending the credentials", () => {
const anyDate: Date = ("any date" as unknown) as Date;
const anyDate: Date = "any date" as unknown as Date;
getExtendedInstanceMetadataCredentials({ ...staticSecret, expiration: anyDate }, logger);
expect(logger.warn).toBeCalledWith(expect.stringContaining("Attempting credential expiration extension"));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe("staticStabilityProvider", () => {

it("should allow custom logger to print warning messages", async () => {
const provider = jest.fn().mockResolvedValueOnce(mockCreds).mockRejectedValue("Error");
const logger = ({ warn: jest.fn() } as unknown) as Logger;
const logger = { warn: jest.fn() } as unknown as Logger;
const stableProvider = staticStabilityProvider(provider, { logger });
expect(await stableProvider()).toEqual(mockCreds); // load initial creds
await stableProvider();
Expand Down
42 changes: 3 additions & 39 deletions packages/eventstream-codec/src/HeaderMarshaller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,45 +182,9 @@ describe("HeaderMarshaller", () => {
[
"a sequence of headers",
Uint8Array.from([
0x04,
0xf0,
0x9f,
0xa6,
0x84,
0x06,
0x00,
0x04,
0xde,
0xad,
0xbe,
0xef,
0x04,
0xf0,
0x9f,
0x8f,
0x87,
0x00,
0x04,
0xf0,
0x9f,
0x90,
0x8e,
0x07,
0x00,
0x07,
0xe2,
0x98,
0x83,
0xf0,
0x9f,
0x92,
0xa9,
0x04,
0xf0,
0x9f,
0x90,
0xb4,
0x01,
0x04, 0xf0, 0x9f, 0xa6, 0x84, 0x06, 0x00, 0x04, 0xde, 0xad, 0xbe, 0xef, 0x04, 0xf0, 0x9f, 0x8f, 0x87, 0x00,
0x04, 0xf0, 0x9f, 0x90, 0x8e, 0x07, 0x00, 0x07, 0xe2, 0x98, 0x83, 0xf0, 0x9f, 0x92, 0xa9, 0x04, 0xf0, 0x9f,
0x90, 0xb4, 0x01,
]),
{
"🦄": {
Expand Down
5 changes: 4 additions & 1 deletion packages/eventstream-codec/src/HeaderMarshaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { Int64 } from "./Int64";
* @internal
*/
export class HeaderMarshaller {
constructor(private readonly toUtf8: Encoder, private readonly fromUtf8: Decoder) {}
constructor(
private readonly toUtf8: Encoder,
private readonly fromUtf8: Decoder
) {}

format(headers: MessageHeaders): Uint8Array {
const chunks: Array<Uint8Array> = [];
Expand Down
Loading

0 comments on commit 74a4554

Please sign in to comment.