Skip to content

Commit

Permalink
Update dependency prettier to v3 (#327)
Browse files Browse the repository at this point in the history
* Update dependency prettier to v3

* Fix style

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Xiao <michael.xiao@smartcontract.com>
  • Loading branch information
renovate[bot] and mxiao-cll authored Nov 28, 2024
1 parent 09b7561 commit ba46fd3
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/cache/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export class RedisCache<T = unknown> implements Cache<T> {
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()
Expand Down
29 changes: 14 additions & 15 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,14 @@ type SettingValueType = string | number | boolean
type SettingType<C extends SettingDefinition> = 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 =
| {
Expand Down Expand Up @@ -552,16 +552,16 @@ export type Settings<T extends SettingsDefinitionMap> = {
}
? K
: T[K]['required'] extends true
? K
: never]: SettingType<T[K]>
? K
: never]: SettingType<T[K]>
} & {
-readonly [K in keyof T as T[K] extends {
default: SettingValueType
}
? never
: T[K]['required'] extends true
? never
: K]?: SettingType<T[K]> | undefined
? never
: K]?: SettingType<T[K]> | undefined
}

export type BaseAdapterSettings = Settings<BaseSettingsDefinitionType>
Expand All @@ -574,9 +574,8 @@ export type CustomSettingsDefinition<T = SettingsDefinitionMap> = Record<keyof T
export type EmptySettingsDefinitionMap = Record<string, never>
export type SettingsDefinitionMap = Record<string, SettingDefinition>
export type ValidationErrorMessage = string | undefined
export type SettingsDefinitionFromConfig<T> = T extends AdapterConfig<infer Definition>
? Definition
: never
export type SettingsDefinitionFromConfig<T> =
T extends AdapterConfig<infer Definition> ? Definition : never

export type SettingDefinitionDetails = {
type: string
Expand Down
15 changes: 9 additions & 6 deletions src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,13 @@ export const groupArrayByKey = <T extends Record<string, string>, 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<T[K], T[]>)
return array.reduce(
(groupedItems, item) => {
const keyValue = item[key]
groupedItems[keyValue] ??= []
groupedItems[keyValue].push(item)
return groupedItems
},
{} as Record<T[K], T[]>,
)
}
5 changes: 4 additions & 1 deletion src/util/requester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/validation/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,18 @@ export class AdapterTimeoutError extends AdapterError {
}
}
export class AdapterDataProviderError extends AdapterError {
constructor(input: Partial<AdapterError>, public timestamps: ResponseTimestamps) {
constructor(
input: Partial<AdapterError>,
public timestamps: ResponseTimestamps,
) {
super({ ...input, metricsLabel: HttpRequestType.DP_ERROR })
}
}
export class AdapterConnectionError extends AdapterError {
constructor(input: Partial<AdapterError>, public timestamps: ResponseTimestamps) {
constructor(
input: Partial<AdapterError>,
public timestamps: ResponseTimestamps,
) {
super({ ...input, metricsLabel: HttpRequestType.CONNECTION_ERROR })
}
}
Expand Down
30 changes: 18 additions & 12 deletions src/validation/input-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ type ParameterType = PrimitiveParameterTypeString | InputParametersDefinition
type TypeFromTypeString<T extends ParameterType> = T extends 'string'
? string
: T extends 'number'
? number
: T extends 'boolean'
? boolean
: T extends InputParametersDefinition
? TypeFromDefinition<T>
: never
? number
: T extends 'boolean'
? boolean
: T extends InputParametersDefinition
? TypeFromDefinition<T>
: never

/**
* All posible types for specifying options for an InputParameter
Expand Down Expand Up @@ -220,10 +220,10 @@ export type TypeFromDefinition<T extends InputParametersDefinition> = unknown ex
type TypeFromDefinitionIsDefined<T extends InputParameter> = T['required'] extends true
? true
: T['array'] extends true
? true
: IsUnknown<T['default']> extends false
? true
: false
? true
: IsUnknown<T['default']> extends false
? true
: false

/**
* Util type to represent the absence of input parameters for an adapter endpoint.
Expand Down Expand Up @@ -261,7 +261,10 @@ class ProcessedParam<const T extends InputParameter = InputParameter> {
/** Definition for the type of this parameter */
type: PrimitiveParameterTypeString | InputParameters<InputParametersDefinition>

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
Expand Down Expand Up @@ -378,7 +381,10 @@ export class InputParameters<const T extends ProperInputParametersDefinition> {

params: ProcessedParam[]

constructor(public definition: T, public examples?: TypeFromDefinition<T>[]) {
constructor(
public definition: T,
public examples?: TypeFromDefinition<T>[],
) {
this.params = Object.entries(this.definition).map(
([name, param]) => new ProcessedParam(name, param),
)
Expand Down
6 changes: 3 additions & 3 deletions test/price.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ test('crypto price endpoint has common aliases', async (t) => {
providerDataReceivedUnixMs: 0,
providerIndicatedTimeUnixMs: undefined,
},
} as AdapterResponse<PriceTestTypes['Response']>)
}) as AdapterResponse<PriceTestTypes['Response']>

const data = {
base: 'BTC',
Expand Down Expand Up @@ -461,7 +461,7 @@ test('price adapter throws if non-crypto endpoint reuses aliases', async (t) =>
providerDataReceivedUnixMs: 0,
providerIndicatedTimeUnixMs: undefined,
},
} as AdapterResponse<PriceTestTypes['Response']>)
}) as AdapterResponse<PriceTestTypes['Response']>

const adapter = new PriceAdapter({
name: 'TEST',
Expand Down Expand Up @@ -499,7 +499,7 @@ test('can create a price adapter with only a single ', async (t) => {
providerDataReceivedUnixMs: 0,
providerIndicatedTimeUnixMs: undefined,
},
} as AdapterResponse<PriceTestTypes['Response']>)
}) as AdapterResponse<PriceTestTypes['Response']>

const adapter = new PriceAdapter({
name: 'TEST',
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ba46fd3

Please sign in to comment.