diff --git a/api-codegen.config.cjs b/api-codegen.config.cjs deleted file mode 100644 index bc3dac69..00000000 --- a/api-codegen.config.cjs +++ /dev/null @@ -1,42 +0,0 @@ -//? NOTE: Orval does not support ESM configs at the moment -// eslint-disable-next-line @typescript-eslint/no-var-requires -const { resolve } = require("path"); - -const apiPath = resolve(__dirname, "./src/common/api"); -const clientPath = "generated/client.ts"; - -const targetPaths = { - indexer: resolve(apiPath, "indexer", clientPath), - prices: resolve(apiPath, "prices", clientPath), -}; - -module.exports = { - /** - * Docs: https://test-dev.potlock.io/api/schema/swagger-ui - */ - indexer: { - input: "https://test-dev.potlock.io/api/schema", - - output: { - target: targetPaths.indexer, - client: "swr", - }, - - hooks: { - afterAllFilesWrite: `eslint --fix ${targetPaths.indexer}`, - }, - }, - - prices: { - input: "https://prices.intear.tech/openapi", - - output: { - target: targetPaths.prices, - client: "swr", - }, - - hooks: { - afterAllFilesWrite: `eslint --fix ${targetPaths.prices}`, - }, - }, -}; diff --git a/api.config.cjs b/api.config.cjs index 3a8eb5ed..0e4ee24f 100644 --- a/api.config.cjs +++ b/api.config.cjs @@ -1,5 +1,13 @@ +//? NOTE: Orval does not support ESM configs at the moment +// eslint-disable-next-line @typescript-eslint/no-var-requires +const { resolve } = require("path"); + +const apiPath = resolve(__dirname, "./src/common/api"); +const clientPath = "internal/client.generated.ts"; + const targetPaths = { - indexer: "./src/common/api/indexer/internal/client.generated.ts", + indexer: resolve(apiPath, "indexer", clientPath), + prices: resolve(apiPath, "prices", clientPath), }; module.exports = { @@ -8,10 +16,27 @@ module.exports = { */ indexer: { input: "https://test-dev.potlock.io/api/schema", - output: { target: targetPaths.indexer, client: "swr" }, + + output: { + target: targetPaths.indexer, + client: "swr", + }, hooks: { afterAllFilesWrite: `eslint --fix ${targetPaths.indexer}`, }, }, + + prices: { + input: "https://prices.intear.tech/openapi", + + output: { + target: targetPaths.prices, + client: "swr", + }, + + hooks: { + afterAllFilesWrite: `eslint --fix ${targetPaths.prices}`, + }, + }, }; diff --git a/src/common/api/prices/hooks.ts b/src/common/api/prices/hooks.ts index 79b25e0c..e2534582 100644 --- a/src/common/api/prices/hooks.ts +++ b/src/common/api/prices/hooks.ts @@ -1,13 +1,13 @@ import { ByTokenId } from "@/common/types"; -import { PRICES_REQUEST_CONFIG } from "./config"; -import * as swrBindings from "./generated/client"; +import * as generatedClient from "./internal/client.generated"; +import { PRICES_REQUEST_CONFIG } from "./internal/config"; /** * https://prices.intear.tech/swagger-ui/#/Token%20Prices/get_get_token_price */ export const useTokenUsdPrice = ({ tokenId }: Partial) => { - const queryResult = swrBindings.useGetGetTokenPrice( + const queryResult = generatedClient.useGetGetTokenPrice( { token_id: tokenId ?? "unknown" }, { diff --git a/src/common/api/prices/index.ts b/src/common/api/prices/index.ts index a207f310..a88faa46 100644 --- a/src/common/api/prices/index.ts +++ b/src/common/api/prices/index.ts @@ -1,4 +1,4 @@ -export { PRICES_REQUEST_CONFIG } from "./config"; -export * as pricesClient from "./generated/client"; +export { PRICES_REQUEST_CONFIG } from "./internal/config"; +export * as pricesClient from "./internal/client.generated"; export * as prices from "./hooks"; export * from "./types"; diff --git a/src/common/api/prices/generated/client.ts b/src/common/api/prices/internal/client.generated.ts similarity index 100% rename from src/common/api/prices/generated/client.ts rename to src/common/api/prices/internal/client.generated.ts diff --git a/src/common/api/prices/config.ts b/src/common/api/prices/internal/config.ts similarity index 100% rename from src/common/api/prices/config.ts rename to src/common/api/prices/internal/config.ts diff --git a/src/common/api/prices/types.ts b/src/common/api/prices/types.ts index 3c96c73b..f51d109e 100644 --- a/src/common/api/prices/types.ts +++ b/src/common/api/prices/types.ts @@ -1 +1 @@ -export type * from "./generated/client"; +export type * from "./internal/client.generated";