From ba46fd3fcdf9c3c3c9efaaaf68d65665515fdd0e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:49:00 -0500 Subject: [PATCH] Update dependency prettier to v3 (#327) * Update dependency prettier to v3 * Fix style --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Michael Xiao --- package.json | 2 +- src/cache/redis.ts | 5 ++++- src/config/index.ts | 29 ++++++++++++++--------------- src/util/index.ts | 15 +++++++++------ src/util/requester.ts | 5 ++++- src/validation/error.ts | 10 ++++++++-- src/validation/input-params.ts | 30 ++++++++++++++++++------------ test/price.test.ts | 6 +++--- yarn.lock | 8 ++++---- 9 files changed, 65 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 7379dc60..19b27bfc 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "eslint-config-prettier": "9.1.0", "eslint-plugin-tsdoc": "0.4.0", "mocksse": "1.0.4", - "prettier": "2.8.8", + "prettier": "3.4.1", "ts-node": "10.9.2", "ts-node-dev": "2.0.0", "typedoc": "0.27.1", diff --git a/src/cache/redis.ts b/src/cache/redis.ts index d937030d..899a1cd6 100644 --- a/src/cache/redis.ts +++ b/src/cache/redis.ts @@ -24,7 +24,10 @@ export class RedisCache implements Cache { type = CacheTypes.Redis private localCache: LocalCache - constructor(private client: Redis, localCacheCapacity: number) { + constructor( + private client: Redis, + localCacheCapacity: number, + ) { // Local cache is used for fast reads. Every SET to redis also sets the value to local cache. this.localCache = new LocalCache(localCacheCapacity) this.defineCommands() diff --git a/src/config/index.ts b/src/config/index.ts index b5b9435f..730193fa 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -469,14 +469,14 @@ type SettingValueType = string | number | boolean type SettingType = C['type'] extends 'string' ? string : C['type'] extends 'number' - ? number - : C['type'] extends 'boolean' - ? boolean - : C['type'] extends 'enum' - ? C['options'] extends readonly string[] - ? C['options'][number] - : never - : never + ? number + : C['type'] extends 'boolean' + ? boolean + : C['type'] extends 'enum' + ? C['options'] extends readonly string[] + ? C['options'][number] + : never + : never export type BaseSettingsDefinitionType = typeof BaseSettingsDefinition export type SettingDefinition = | { @@ -552,16 +552,16 @@ export type Settings = { } ? K : T[K]['required'] extends true - ? K - : never]: SettingType + ? K + : never]: SettingType } & { -readonly [K in keyof T as T[K] extends { default: SettingValueType } ? never : T[K]['required'] extends true - ? never - : K]?: SettingType | undefined + ? never + : K]?: SettingType | undefined } export type BaseAdapterSettings = Settings @@ -574,9 +574,8 @@ export type CustomSettingsDefinition = Record export type SettingsDefinitionMap = Record export type ValidationErrorMessage = string | undefined -export type SettingsDefinitionFromConfig = T extends AdapterConfig - ? Definition - : never +export type SettingsDefinitionFromConfig = + T extends AdapterConfig ? Definition : never export type SettingDefinitionDetails = { type: string diff --git a/src/util/index.ts b/src/util/index.ts index 9450829f..7965c362 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -166,10 +166,13 @@ export const groupArrayByKey = , K extends keyo array: T[], key: K, ) => { - return array.reduce((groupedItems, item) => { - const keyValue = item[key] - groupedItems[keyValue] ??= [] - groupedItems[keyValue].push(item) - return groupedItems - }, {} as Record) + return array.reduce( + (groupedItems, item) => { + const keyValue = item[key] + groupedItems[keyValue] ??= [] + groupedItems[keyValue].push(item) + return groupedItems + }, + {} as Record, + ) } diff --git a/src/util/requester.ts b/src/util/requester.ts index 0d6d4458..2286cd72 100644 --- a/src/util/requester.ts +++ b/src/util/requester.ts @@ -100,7 +100,10 @@ export class Requester { private timeout: number private sleepBeforeRequeueingMs: number - constructor(private rateLimiter: RateLimiter, adapterSettings: AdapterSettings) { + constructor( + private rateLimiter: RateLimiter, + adapterSettings: AdapterSettings, + ) { this.maxRetries = adapterSettings.RETRY this.timeout = adapterSettings.API_TIMEOUT this.sleepBeforeRequeueingMs = adapterSettings.REQUESTER_SLEEP_BEFORE_REQUEUEING_MS diff --git a/src/validation/error.ts b/src/validation/error.ts index ee239ba2..9ccd07ef 100644 --- a/src/validation/error.ts +++ b/src/validation/error.ts @@ -102,12 +102,18 @@ export class AdapterTimeoutError extends AdapterError { } } export class AdapterDataProviderError extends AdapterError { - constructor(input: Partial, public timestamps: ResponseTimestamps) { + constructor( + input: Partial, + public timestamps: ResponseTimestamps, + ) { super({ ...input, metricsLabel: HttpRequestType.DP_ERROR }) } } export class AdapterConnectionError extends AdapterError { - constructor(input: Partial, public timestamps: ResponseTimestamps) { + constructor( + input: Partial, + public timestamps: ResponseTimestamps, + ) { super({ ...input, metricsLabel: HttpRequestType.CONNECTION_ERROR }) } } diff --git a/src/validation/input-params.ts b/src/validation/input-params.ts index 9156c01c..445fdd3f 100644 --- a/src/validation/input-params.ts +++ b/src/validation/input-params.ts @@ -30,12 +30,12 @@ type ParameterType = PrimitiveParameterTypeString | InputParametersDefinition type TypeFromTypeString = T extends 'string' ? string : T extends 'number' - ? number - : T extends 'boolean' - ? boolean - : T extends InputParametersDefinition - ? TypeFromDefinition - : never + ? number + : T extends 'boolean' + ? boolean + : T extends InputParametersDefinition + ? TypeFromDefinition + : never /** * All posible types for specifying options for an InputParameter @@ -220,10 +220,10 @@ export type TypeFromDefinition = unknown ex type TypeFromDefinitionIsDefined = T['required'] extends true ? true : T['array'] extends true - ? true - : IsUnknown extends false - ? true - : false + ? true + : IsUnknown extends false + ? true + : false /** * Util type to represent the absence of input parameters for an adapter endpoint. @@ -261,7 +261,10 @@ class ProcessedParam { /** Definition for the type of this parameter */ type: PrimitiveParameterTypeString | InputParameters - constructor(public name: string, public definition: T) { + constructor( + public name: string, + public definition: T, + ) { this.aliases = [this.name, ...(this.definition.aliases || [])] this.type = typeof definition.type === 'object' ? new InputParameters(definition.type) : definition.type @@ -378,7 +381,10 @@ export class InputParameters { params: ProcessedParam[] - constructor(public definition: T, public examples?: TypeFromDefinition[]) { + constructor( + public definition: T, + public examples?: TypeFromDefinition[], + ) { this.params = Object.entries(this.definition).map( ([name, param]) => new ProcessedParam(name, param), ) diff --git a/test/price.test.ts b/test/price.test.ts index 757c6483..3391ef63 100644 --- a/test/price.test.ts +++ b/test/price.test.ts @@ -419,7 +419,7 @@ test('crypto price endpoint has common aliases', async (t) => { providerDataReceivedUnixMs: 0, providerIndicatedTimeUnixMs: undefined, }, - } as AdapterResponse) + }) as AdapterResponse const data = { base: 'BTC', @@ -461,7 +461,7 @@ test('price adapter throws if non-crypto endpoint reuses aliases', async (t) => providerDataReceivedUnixMs: 0, providerIndicatedTimeUnixMs: undefined, }, - } as AdapterResponse) + }) as AdapterResponse const adapter = new PriceAdapter({ name: 'TEST', @@ -499,7 +499,7 @@ test('can create a price adapter with only a single ', async (t) => { providerDataReceivedUnixMs: 0, providerIndicatedTimeUnixMs: undefined, }, - } as AdapterResponse) + }) as AdapterResponse const adapter = new PriceAdapter({ name: 'TEST', diff --git a/yarn.lock b/yarn.lock index 38c47537..ab35df36 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4046,10 +4046,10 @@ prepend-http@^1.0.1: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" integrity sha512-PhmXi5XmoyKw1Un4E+opM2KcsJInDvKyuOumcjjw3waw86ZNjHwVUOOWLc4bCzLdcKNaWBH9e99sbWzDQsVaYg== -prettier@2.8.8: - version "2.8.8" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" - integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== +prettier@3.4.1: + version "3.4.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.4.1.tgz#e211d451d6452db0a291672ca9154bc8c2579f7b" + integrity sha512-G+YdqtITVZmOJje6QkXQWzl3fSfMxFwm1tjTyo9exhkmWSqC4Yhd1+lug++IlR2mvRVAxEDDWYkQdeSztajqgg== pretty-bytes@^5.1.0, pretty-bytes@^5.2.0: version "5.6.0"